Skip to content
Snippets Groups Projects
Commit ce6d8778 authored by Oliver Sander's avatar Oliver Sander Committed by sander@PCPOOL.MI.FU-BERLIN.DE
Browse files

complete implementation, not tested beyond compilation yet, though

[[Imported from SVN: r4059]]
parent 57edb168
No related branches found
No related tags found
No related merge requests found
#ifndef HARMONIC_ENERGY_LOCAL_STIFFNESS_HH #ifndef HARMONIC_ENERGY_LOCAL_STIFFNESS_HH
#define HARMONIC_ENERGY_LOCAL_STIFFNESS_HH #define HARMONIC_ENERGY_LOCAL_STIFFNESS_HH
#include <dune/istl/bcrsmatrix.hh>
#include <dune/common/fmatrix.hh> #include <dune/common/fmatrix.hh>
#include <dune/istl/matrixindexset.hh> #include <dune/grid/common/quadraturerules.hh>
#include <dune/istl/matrix.hh>
#include <dune/disc/operators/localstiffness.hh> #include "localgeodesicfestiffness.hh"
#include "localgeodesicfefunction.hh"
template<class GridView, class TargetSpace> template<class GridView, class TargetSpace>
class HarmonicEnergyLocalStiffness class HarmonicEnergyLocalStiffness
: public Dune::LocalGeodesicFEStiffness<GridView,TargetSpace> : public LocalGeodesicFEStiffness<GridView,TargetSpace>
{ {
// grid types // grid types
typedef typename GridView::Grid::ctype DT; typedef typename GridView::Grid::ctype DT;
typedef typename TargetSpace::ctype RT;
typedef typename GridView::template Codim<0>::Entity Entity; typedef typename GridView::template Codim<0>::Entity Entity;
// some other sizes // some other sizes
...@@ -23,14 +24,18 @@ public: ...@@ -23,14 +24,18 @@ public:
//! Dimension of a tangent space //! Dimension of a tangent space
enum { blocksize = TargetSpace::TangentVector::size }; enum { blocksize = TargetSpace::TangentVector::size };
#if 0
// types for matrics, vectors and boundary conditions // types for matrics, vectors and boundary conditions
typedef Dune::FieldMatrix<RT,m,m> MBlockType; // one entry in the stiffness matrix typedef Dune::FieldMatrix<RT,m,m> MBlockType; // one entry in the stiffness matrix
typedef Dune::FieldVector<RT,m> VBlockType; // one entry in the global vectors typedef Dune::FieldVector<RT,m> VBlockType; // one entry in the global vectors
typedef Dune::array<Dune::BoundaryConditions::Flags,m> BCBlockType; // componentwise boundary conditions typedef Dune::array<Dune::BoundaryConditions::Flags,m> BCBlockType; // componentwise boundary conditions
#endif
#if 0
//! Default Constructor //! Default Constructor
HarmonicEnergyLocalStiffness () HarmonicEnergyLocalStiffness ()
{} {}
#endif
/** \brief Assemble the energy for a single element */ /** \brief Assemble the energy for a single element */
RT energy (const Entity& e, RT energy (const Entity& e,
...@@ -38,19 +43,19 @@ public: ...@@ -38,19 +43,19 @@ public:
}; };
template <class GridType, class RT> template <class GridView, class TargetSpace>
RT RodLocalStiffness<GridType, RT>:: typename HarmonicEnergyLocalStiffness<GridView, TargetSpace>::RT HarmonicEnergyLocalStiffness<GridView, TargetSpace>::
energy(const Entity& element, energy(const Entity& element,
const Dune::array<RigidBodyMotion<3>,2>& localSolution) const const std::vector<TargetSpace>& localSolution) const
{ {
RT energy = 0; RT energy = 0;
assert(element.type().isSimplex()); LocalGeodesicFEFunction<gridDim, double, TargetSpace> localGeodesicFEFunction(element.type(), localSolution);
int quadOrder = gridDim; int quadOrder = gridDim;
const Dune::QuadratureRule<double, 1>& quad const Dune::QuadratureRule<double, gridDim>& quad
= Dune::QuadratureRules<double, 1>::rule(element.type(), quadOrder); = Dune::QuadratureRules<double, gridDim>::rule(element.type(), quadOrder);
for (size_t pt=0; pt<quad.size(); pt++) { for (size_t pt=0; pt<quad.size(); pt++) {
...@@ -58,17 +63,24 @@ energy(const Entity& element, ...@@ -58,17 +63,24 @@ energy(const Entity& element,
const Dune::FieldVector<double,gridDim>& quadPos = quad[pt].position(); const Dune::FieldVector<double,gridDim>& quadPos = quad[pt].position();
const double integrationElement = element.geometry().integrationElement(quadPos); const double integrationElement = element.geometry().integrationElement(quadPos);
const Dune::FieldMatrix<double,gridDim,gridDim>& jacobianInverseTransposed = element.geometry().jacobianInverseTransposed(quadPos);
double weight = quad[pt].weight() * integrationElement; double weight = quad[pt].weight() * integrationElement;
for (int comp=0; comp<4; comp++) { // The derivative of the local function defined on the reference element
Dune::FieldMatrix<double, TargetSpace::EmbeddedTangentVector::size, gridDim> referenceDerivative = localGeodesicFEFunction.evaluateDerivative(quadPos);
// The derivative of the function defined on the actual element
Dune::FieldMatrix<double, TargetSpace::EmbeddedTangentVector::size, gridDim> derivative(0);
for (int dir=0; dir<gridDim; dir++) { for (int comp=0; comp<4; comp++)
jacobianInverseTransposed.umv(referenceDerivative[comp], derivative[comp]);
double derivative = localGeodesicFunction.evaluateDerivative(comp, dir); for (int comp=0; comp<4; comp++) {
energy += weight * derivative * derivative;
} for (int dir=0; dir<gridDim; dir++)
energy += weight * derivative[comp][dir] * derivative[comp][dir];
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment