dune-fem  2.4.1-rc
localfunctions.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_SHAPEFUNCTIONSET_LOCALFUNCTIONS_HH
2 #define DUNE_FEM_SHAPEFUNCTIONSET_LOCALFUNCTIONS_HH
3 
4 // C++ includes
5 #include <cstddef>
6 #include <vector>
7 
8 // dune-common includes
9 #include <dune/common/exceptions.hh>
10 
11 // dune-fem includes
14 
15 namespace Dune
16 {
17 
18  namespace Fem
19  {
20 
21  // LocalFunctionsShapeFunctionSetTraits
22  // ------------------------------------
23 
24  template< class LocalBasis >
26  {
27 
28  typedef typename LocalBasis::Traits Traits;
29 
30  public:
31  typedef typename Traits::DomainType DomainType;
32  typedef typename DomainType::value_type DomainFieldType;
33  static const int dimDomain = DomainType::dimension;
34 
35  typedef typename Traits::RangeType RangeType;
36  typedef typename RangeType::value_type RangeFieldType;
37  static const int dimRange = RangeType::dimension;
38 
40  };
41 
42 
43 
44  // LocalFunctionsShapeFunctionSet
45  // ------------------------------
46 
47  template< class LocalBasis >
49  {
50  // this type
52  // traits class
54 
55  public:
61 
62  explicit LocalFunctionsShapeFunctionSet ( const LocalBasis &localBasis )
63  : localBasis_( localBasis )
64  {
65  values_.reserve( size() );
66  jacobians_.reserve( size() );
67  }
68 
69  int order () const { return localBasis_.order(); }
70 
71  std::size_t size () const { return localBasis_.size(); }
72 
73  template< class Point, class Functor >
74  void evaluateEach ( const Point &x, Functor f ) const
75  {
76  localBasis_.evaluateFunction( coordinate( x ), values_ );
77  assert( values_.size() == size() );
78  callFunctor( values_, f );
79  }
80 
81  template< class Point, class Functor >
82  void jacobianEach ( const Point &x, Functor f ) const
83  {
84  localBasis_.evaluateJacobian( coordinate( x ), jacobians_ );
85  assert( jacobians_.size() == size() );
86  callFunctor( jacobians_, f );
87  }
88 
89  template< class Point, class Functor >
90  void hessianEach ( const Point &x, Functor f ) const
91  {
92  DUNE_THROW( NotImplemented, "Method hessianEach not implemented" );
93  }
94 
95  private:
96  template< class T, class Functor >
97  static void callFunctor ( const std::vector< T > &v, Functor f )
98  {
99  typedef typename std::vector< T >::const_iterator Iterator;
100  std::size_t i = 0;
101  for( Iterator it = v.begin(); it != v.end(); ++it )
102  f( i++, *it );
103  }
104 
105  LocalBasis localBasis_;
106  mutable std::vector< RangeType > values_;
107  mutable std::vector< JacobianRangeType > jacobians_;
108  };
109 
110  } // namespace Fem
111 
112 } // namespace Dune
113 
114 #endif // #ifndef DUNE_FEM_SHAPEFUNCTIONSET_LOCALFUNCTIONS_HH
FunctionSpaceType::HessianRangeType HessianRangeType
Definition: localfunctions.hh:60
static const int dimDomain
Definition: localfunctions.hh:33
A vector valued function space.
Definition: functionspace.hh:16
std::size_t size() const
Definition: localfunctions.hh:71
LocalFunctionsShapeFunctionSet(const LocalBasis &localBasis)
Definition: localfunctions.hh:62
FunctionSpaceType::DomainType DomainType
Definition: localfunctions.hh:57
VectorSpaceTraits< DomainField, RangeField, dimD, dimR >::LinearMappingType JacobianRangeType
Intrinsic type used for the jacobian values has a Dune::FieldMatrix type interface.
Definition: functionspaceinterface.hh:74
static const int dimRange
Definition: localfunctions.hh:37
FieldVector< FieldMatrix< RangeFieldType, dimDomain, dimDomain >, dimRange > HessianRangeType
Intrinsic type used for the hessian values has a Dune::FieldMatrix type interface.
Definition: functionspaceinterface.hh:78
FunctionSpaceType::JacobianRangeType JacobianRangeType
Definition: localfunctions.hh:59
int order() const
Definition: localfunctions.hh:69
void hessianEach(const Point &x, Functor f) const
Definition: localfunctions.hh:90
void jacobianEach(const Point &x, Functor f) const
Definition: localfunctions.hh:82
FunctionSpaceType::RangeType RangeType
Definition: localfunctions.hh:58
DomainType::value_type DomainFieldType
Definition: localfunctions.hh:32
Traits::DomainType DomainType
Definition: localfunctions.hh:31
Definition: coordinate.hh:4
VectorSpaceTraits< DomainField, RangeField, dimD, dimR >::DomainType DomainType
Type of domain vector (using type of domain field) has a Dune::FieldVector type interface.
Definition: functionspaceinterface.hh:66
Traits::RangeType RangeType
Definition: localfunctions.hh:35
Definition: localfunctions.hh:25
RangeType::value_type RangeFieldType
Definition: localfunctions.hh:36
VectorSpaceTraits< DomainField, RangeField, dimD, dimR >::RangeType RangeType
Type of range vector (using type of range field) has a Dune::FieldVector type interface.
Definition: functionspaceinterface.hh:70
FunctionSpace< DomainFieldType, RangeFieldType, dimDomain, dimRange > FunctionSpaceType
Definition: localfunctions.hh:39
Definition: localfunctions.hh:48
Traits::FunctionSpaceType FunctionSpaceType
Definition: localfunctions.hh:56
static const Point & coordinate(const Point &x)
Definition: coordinate.hh:11
void evaluateEach(const Point &x, Functor f) const
Definition: localfunctions.hh:74