This source file includes following definitions.
- set_time_provider
- evaluate
- evaluate
- evaluate
1 #ifndef DEFORMATION_HH
2 #define DEFORMATION_HH
3
4 #include <dune/common/exceptions.hh>
5 #include <dune/grid/geometrygrid/coordfunction.hh>
6 #include <dune/fem/space/common/functionspace.hh>
7
8 #include<cassert>
9 #include<dune_bdf.hpp>
10
11 #include <Eigen/Dense>
12
13
14
15
16 class DeformationCoordFunction
17 : public Dune::AnalyticalCoordFunction<double, 3, 3, DeformationCoordFunction>{
18 typedef Dune::AnalyticalCoordFunction<double, 3, 3, DeformationCoordFunction>
19 BaseType;
20 public:
21 typedef Dune::Fem::FunctionSpace<double, double, 3, 3> FunctionSpaceType;
22
23 typedef BaseType::DomainVector DomainVector;
24 typedef BaseType::RangeVector RangeVector;
25
26 DeformationCoordFunction() {};
27 DeformationCoordFunction (BDF::EvoMapType& evoMap)
28 : evoMapPt {&evoMap} {}
29 void set_time_provider(Dune::Fem::TimeProviderBase& time_provider){
30 p_tp = &time_provider;
31 }
32 void evaluate (const DomainVector& x, RangeVector& y) const{
33
34
35
36
37
38
39
40
41
42
43
44 std::array<double, 3> domain_node { {x[0], x[1], x[2]} };
45
46 const std::array<double, 3> range_node = (*evoMapPt)[domain_node];
47 for(std::size_t s = 0; s < range_node.size(); ++s)
48 y[s] = range_node[s];
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69 }
70 private:
71 BDF::EvoMapType* evoMapPt = nullptr;
72
73 Dune::Fem::TimeProviderBase* p_tp = nullptr;
74 };
75
76
77
78
79
80
81 template <class DiscreteFunctionType>
82 class DeformationDiscreteFunction
83 : public Dune::DiscreteCoordFunction<double, 3,
84 DeformationDiscreteFunction<DiscreteFunctionType>
85 >{
86 typedef Dune::DiscreteCoordFunction<double, 3,
87 DeformationDiscreteFunction<DiscreteFunctionType>
88 > BaseType;
89 typedef typename DiscreteFunctionType::GridType GridType;
90 typedef typename DiscreteFunctionType::LocalFunctionType LocalFunctionType;
91 typedef typename DiscreteFunctionType::RangeType RangeType;
92 public:
93 DeformationDiscreteFunction (const DiscreteFunctionType& vertices )
94 : vertices_( vertices )
95 {}
96
97 template< class HostEntity , class RangeVector >
98 void evaluate ( const HostEntity& hostEntity, unsigned int corner,
99 RangeVector& y ) const{
100 DUNE_THROW(Dune::NotImplemented,"evaluate not implemented for codim > 0");
101 }
102
103 template <class RangeVector>
104 void evaluate ( const typename GridType:: template Codim<0>::Entity& entity,
105 unsigned int corner, RangeVector& y ) const{
106 typedef typename GridType::ctype ctype;
107 enum { dim = GridType::dimension };
108
109 const Dune::GenericReferenceElement<ctype, dim>& refElement
110 = Dune::GenericReferenceElements<ctype, dim>::general( entity.type() );
111
112 LocalFunctionType localVertices = vertices_.localFunction( entity );
113
114 localVertices.evaluate( refElement.position( corner, dim ), y );
115 }
116
117 protected:
118 const DiscreteFunctionType& vertices_;
119 };
120
121 #endif