This source file includes following definitions.
- grid_dim
- world_dim
- size
- begin
- end
- begin
- end
- cbegin
- cend
- name
- size
- begin
- end
- begin
- end
- cbegin
- cend
- name
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 #ifndef GRID_H
26 #define GRID_H
27
28 #include <memory>
29 #include <config.h>
30 #include <dune/grid/geometrygrid.hh>
31 #include <dune/fem/gridpart/adaptiveleafgridpart.hh>
32 #include <dune/grid/geometrygrid/coordfunction.hh>
33 #include <dune/fem/solver/timeprovider.hh>
34 #include <dune/fem/space/common/functionspace.hh>
35 #include <dune/fem/space/lagrange.hh>
36 #include <dune/fem/function/adaptivefunction.hh>
37 #include <dune/fem/function/blockvectorfunction.hh>
38
39 #include "esfem_fwd.h"
40
41 namespace Esfem{
42 namespace Grid{
43 inline constexpr int grid_dim(){
44 return Dune::GridSelector::dimgrid;
45 }
46 inline constexpr int world_dim(){
47 return Dune::GridSelector::dimworld;
48 }
49
50 static_assert( grid_dim() == 2, "Bad grid dimension.");
51 static_assert( world_dim() == 3, "Bad world dimension.");
52
53 class Deformation
54 : public Dune::
55 AnalyticalCoordFunction<double, world_dim(), world_dim(), Deformation>
56 {
57 public:
58 using Base = Dune::AnalyticalCoordFunction
59 <double, world_dim(), world_dim(), Deformation>;
60 using Domain = Base::DomainVector;
61 using Range = Base::RangeVector;
62
63
64 Deformation();
65
66 explicit Deformation(const std::string& fname);
67
68 ~Deformation();
69
70
71 void evaluate(const Domain&, Range&) const;
72
73 void set_timeProvider(const Dune::Fem::TimeProviderBase&);
74
75 Deformation& operator=(const Vec_FEfun&);
76 private:
77 struct Data;
78
79 std::unique_ptr<Data> d_ptr;
80 };
81
82 class Grid_and_time{
83 public:
84
85 using Host_grid = Dune::GridSelector::GridType;
86
87 using Grid = Dune::GeometryGrid<Host_grid, Deformation>;
88
89 using Grid_part
90 = Dune::Fem::AdaptiveLeafGridPart<Grid, Dune::InteriorBorder_Partition>;
91
92 using Function_space = Dune::Fem::
93 FunctionSpace<double, double, Grid::dimensionworld, 1>;
94
95 using FE_space = Dune::Fem::
96 LagrangeDiscreteFunctionSpace<Function_space, Grid_part, POLORDER>;
97
98 using Vec_Function_space = Dune::Fem::
99 FunctionSpace<double, double, Grid::dimensionworld, Grid::dimensionworld>;
100
101 using Vec_FE_space = Dune::Fem::
102 LagrangeDiscreteFunctionSpace<Vec_Function_space, Grid_part, POLORDER>;
103
104
105 explicit Grid_and_time(const Io::Parameter&);
106
107 explicit Grid_and_time(const Io::Parameter&, const std::string& dgf_file,
108 const double t0);
109
110 ~Grid_and_time();
111
112
113 void next_timeStep(const double);
114
115 void new_nodes(const Vec_FEfun&);
116
117
118 Dune::Fem::TimeProviderBase& time_provider();
119
120 const Dune::Fem::TimeProviderBase& time_provider() const;
121
122
123 Grid& grid() const;
124
125 Grid_part& grid_part() const;
126
127
128 FE_space& fe_space() const;
129
130
131 Vec_FE_space& vec_fe_space() const;
132 private:
133 struct Data;
134
135 std::unique_ptr<Data> d_ptr;
136 };
137 class Scal_FEfun{
138 public:
139
140 using Dune_FEfun
141 = Dune::Fem::ISTLBlockVectorDiscreteFunction<Grid_and_time::FE_space>;
142
143 explicit Scal_FEfun(const std::string& name, const Grid_and_time& gt);
144 explicit Scal_FEfun(const Scal_FEfun&, const Grid_and_time&);
145 Scal_FEfun& operator=(const Scal_FEfun&);
146
147 operator Dune_FEfun&(){ return fun; }
148 operator const Dune_FEfun&() const { return fun; }
149
150 auto size() const { return fun.size(); }
151 auto begin() { return fun.dbegin(); }
152 auto end() { return fun.dend(); }
153 auto begin() const { return fun.dbegin(); }
154 auto end() const { return fun.dend(); }
155 auto cbegin() const { return fun.dbegin(); }
156 auto cend() const { return fun.dend(); }
157 auto name() const { return fun.name(); }
158
159 Scal_FEfun& operator+=(const double d);
160 Scal_FEfun& operator*=(const double d);
161 private:
162 Dune_FEfun fun;
163 };
164 class Vec_FEfun{
165 public:
166 using Dune_FEfun
167 = Dune::Fem::AdaptiveDiscreteFunction<Grid_and_time::Vec_FE_space>;
168
169
170
171 explicit Vec_FEfun(const std::string& name, const Grid_and_time&);
172 explicit Vec_FEfun(const Vec_FEfun&, const Grid_and_time&);
173 Vec_FEfun& operator=(const Vec_FEfun&);
174
175 operator Dune_FEfun&(){ return fun; }
176 operator const Dune_FEfun&() const { return fun; }
177
178 auto size() const { return fun.size(); }
179 auto begin() { return fun.dbegin(); }
180 auto end() { return fun.dend(); }
181 auto begin() const { return fun.dbegin(); }
182 auto end() const { return fun.dend(); }
183 auto cbegin() const { return fun.dbegin(); }
184 auto cend() const { return fun.dend(); }
185 auto name() const { return fun.name(); }
186
187 Vec_FEfun& operator+=(const double);
188 Vec_FEfun& operator*=(const double);
189 private:
190 Dune_FEfun fun;
191 };
192 }
193 }
194
195 #endif