DUNE-ACFEM (2.5.1)

coordinatefunctions.hh
1#ifndef DUNE_ACFEM_COORDINATEGRIDFUNCTIONS_HH
2#define DUNE_ACFEM_COORDINATEGRIDFUNCTIONS_HH
3
4#include "../functions/gridfunctionwrapper.hh"
5
6namespace Dune {
7
8 namespace ACFem {
9
16 template<class Field, unsigned dim>
18 : public Fem::Function<Fem::FunctionSpace<Field, Field, dim, dim>, IdentityFunction<Field, dim> >
19 {
21 typedef Fem::Function<Fem::FunctionSpace<Field, Field, dim, dim>, ThisType> BaseType;
22 public:
23 typedef typename BaseType::FunctionSpaceType FunctionSpaceType;
24
25 enum { dimRange = FunctionSpaceType::dimRange };
26 enum { dimDomain = FunctionSpaceType::dimDomain };
27
28 typedef typename FunctionSpaceType::RangeFieldType RangeFieldType;
29
30 typedef typename FunctionSpaceType::RangeType RangeType;
31 typedef typename FunctionSpaceType::DomainType DomainType;
32
33 typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
34 typedef typename FunctionSpaceType::HessianRangeType HessianRangeType;
35
36 IdentityFunction() {} // we have no state
37
38 void evaluate(const DomainType& x, RangeType& res) const
39 {
40 res = x;
41 }
42
43 void jacobian(const DomainType& x, JacobianRangeType& res) const
44 {
45 res = 0;
46 for (int i = 0; i < dimDomain; ++i) {
47 res[i][i] = 1.0;
48 }
49 }
50
51 void hessian(const DomainType& x, HessianRangeType& res) const
52 {
53 res = 0;
54 }
55 };
56
60 template<class Field, unsigned dim, unsigned N>
62 : public Fem::Function<Fem::FunctionSpace<Field, Field, dim, 1>, CoordinateFunction<Field, dim, N> >
63 {
65 typedef Fem::Function<Fem::FunctionSpace<Field, Field, dim, 1>, ThisType> BaseType;
66 public:
67 typedef typename BaseType::FunctionSpaceType FunctionSpaceType;
68
69 enum { dimRange = 1 };
70 enum { dimDomain = FunctionSpaceType::dimDomain };
71 enum { component = N };
72
73 typedef typename FunctionSpaceType::RangeFieldType RangeFieldType;
74
75 typedef typename FunctionSpaceType::RangeType RangeType;
76 typedef typename FunctionSpaceType::DomainType DomainType;
77
78 typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
79 typedef typename FunctionSpaceType::HessianRangeType HessianRangeType;
80
82 static_assert(component < (unsigned)dimDomain, "Index out of range");
83 }
84
85 void evaluate(const DomainType& x, RangeType& res) const
86 {
87 res = x[component];
88 }
89
90 void jacobian(const DomainType& x, JacobianRangeType& res) const
91 {
92 res = 0;
93 res[0][component] = 1.0;
94 }
95
96 void hessian(const DomainType& x, HessianRangeType& res) const
97 {
98 res = 0;
99 }
100 };
101
103
104 } // ACFem::
105
106} // Dune::
107
108
109#endif // DUN_ACFEM_GRIDFUNCITONWRAPPER_HH
110
Coordinate function returns a specific component of the world point, x_N, so to say.
Definition: coordinatefunctions.hh:63
A function which returns its argument.
Definition: coordinatefunctions.hh:19
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Aug 13, 22:30, 2024)