dune-fem  2.8-git
localfunctiongeometry.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_GRIDPART_COMMON_LOCALFUNCTIONGEOMETRY_HH
2 #define DUNE_FEM_GRIDPART_COMMON_LOCALFUNCTIONGEOMETRY_HH
3 
4 #include <type_traits>
5 #include <utility>
6 
7 #include <dune/common/fmatrix.hh>
8 #include <dune/common/fvector.hh>
9 
10 #include <dune/geometry/quadraturerules.hh>
11 #include <dune/geometry/referenceelements.hh>
12 
13 #include <dune/grid/common/geometry.hh>
14 
16 
18 
19 namespace Dune
20 {
21 
22  namespace Fem
23  {
24 
25  // LocalFunctionBasicGeometry
26  // --------------------------
27 
28  template< class LocalFunction >
30  {
33 
34  static const int mydimension = Entity::mydimension;
36 
37  typedef FieldVector< ctype, mydimension > LocalCoordinate;
38  typedef FieldVector< ctype, coorddimension > GlobalCoordinate;
39 
40  typedef FieldMatrix< ctype, mydimension, coorddimension > JacobianTransposed;
41 
42  template< class... Args, std::enable_if_t< std::is_constructible< LocalFunction, Args &&... >::value, int > = 0 >
43  LocalFunctionBasicGeometry ( Args &&... args )
44  : localFunction_( std::forward< Args >( args )... )
45  {}
46 
47  GlobalCoordinate global ( const LocalCoordinate &local ) const
48  {
49  GlobalCoordinate ret;
50  localFunction().evaluate( local, ret );
51  return ret;
52  }
53 
55  {
56  const auto gradFT = localFunction().entity().geometry().jacobianTransposed( local );
57 
58  FieldMatrix< ctype, coorddimension, coorddimension > gradPhi;
59  localFunction().jacobian( local, gradPhi );
60 
61  JacobianTransposed jacTransposed( 0 );
62  for( int i = 0; i < coorddimension; ++i )
63  {
64  FieldMatrixColumn< JacobianTransposed > col( jacTransposed, i );
65  gradFT.mv( gradPhi[ i ], col );
66  }
67  return jacTransposed;
68  }
69 
70  const QuadratureRule< ctype, mydimension > &quadrature ( int order ) const
71  {
72  return QuadratureRules< ctype, mydimension >::rule( type(), order + (2*localFunction().order() + 1) );
73  }
74 
75  GeometryType type () const { return localFunction().entity().type(); }
76 
77  void bind ( const Entity &entity ) { localFunction_.bind( entity ); }
78  void init ( const Entity &entity ) { bind( entity ); }
79 
80  const LocalFunction &localFunction () const { return localFunction_; }
81 
82  private:
83  LocalFunction localFunction_;
84  };
85 
86 
87 
88  // LocalFunctionGeometry
89  // ---------------------
90 
91  template< class LocalFunction >
93 
94  } // namespace Fem
95 
96 } // namespace Dune
97 
98 #endif // #ifndef DUNE_FEM_GRIDPART_COMMON_LOCALFUNCTIONGEOMETRY_HH
Definition: bindguard.hh:11
Definition: fmatrixcol.hh:16
interface for local functions
Definition: localfunction.hh:77
void evaluate(const PointType &x, RangeType &ret) const
evaluate the local function
Definition: localfunction.hh:311
void bind(const EntityType &entity)
initialize the local function for an entity
Definition: localfunction.hh:450
const EntityType & entity() const
obtain the entity, this local function lives on
Definition: localfunction.hh:302
void jacobian(const PointType &x, JacobianRangeType &ret) const
evaluate Jacobian of the local function
Definition: localfunction.hh:325
BasisFunctionSetType::EntityType EntityType
type of the entity, the local function lives on is given by the space
Definition: localfunction.hh:95
Definition: localfunctiongeometry.hh:30
static const int coorddimension
Definition: localfunctiongeometry.hh:35
const QuadratureRule< ctype, mydimension > & quadrature(int order) const
Definition: localfunctiongeometry.hh:70
LocalFunction::FunctionSpaceType::RangeFieldType ctype
Definition: localfunctiongeometry.hh:32
FieldMatrix< ctype, mydimension, coorddimension > JacobianTransposed
Definition: localfunctiongeometry.hh:40
LocalFunction::EntityType Entity
Definition: localfunctiongeometry.hh:31
GlobalCoordinate global(const LocalCoordinate &local) const
Definition: localfunctiongeometry.hh:47
GeometryType type() const
Definition: localfunctiongeometry.hh:75
static const int mydimension
Definition: localfunctiongeometry.hh:34
const LocalFunction & localFunction() const
Definition: localfunctiongeometry.hh:80
FieldVector< ctype, mydimension > LocalCoordinate
Definition: localfunctiongeometry.hh:37
void bind(const Entity &entity)
Definition: localfunctiongeometry.hh:77
FieldVector< ctype, coorddimension > GlobalCoordinate
Definition: localfunctiongeometry.hh:38
JacobianTransposed jacobianTransposed(const LocalCoordinate &local) const
Definition: localfunctiongeometry.hh:54
void init(const Entity &entity)
Definition: localfunctiongeometry.hh:78
LocalFunctionBasicGeometry(Args &&... args)
Definition: localfunctiongeometry.hh:43
Definition: simplegeometry.hh:26
@ dimRange
dimension of range vector space
Definition: functionspaceinterface.hh:48
FunctionSpaceTraits::RangeFieldType RangeFieldType
Intrinsic type used for values in the range field (usually a double)
Definition: functionspaceinterface.hh:63