DUNE PDELab (2.8)

jacobianresidualengine.hh
1#ifndef DUNE_PDELAB_GRIDOPERATOR_ONESTEP_JACOBIANRESIDUALENGINE_HH
2#define DUNE_PDELAB_GRIDOPERATOR_ONESTEP_JACOBIANRESIDUALENGINE_HH
3
4#include <cassert>
5
6#include <dune/pdelab/gridoperator/common/localassemblerenginebase.hh>
7
8namespace Dune{
9 namespace PDELab{
10
18 template<typename OSLA>
21 {
22 public:
25
26 template<typename TrialConstraintsContainer, typename TestConstraintsContainer>
27 bool needsConstraintsCaching(const TrialConstraintsContainer& cu, const TestConstraintsContainer& cv) const
28 {
29 return cu.containsNonDirichletConstraints() or cv.containsNonDirichletConstraints();
30 }
31
33 typedef typename OSLA::Real Real;
34
35 typedef OSLA LocalAssembler;
36 typedef typename LocalAssembler::LocalPreStageAssemblerEngine PreStageEngine;
37 typedef typename LocalAssembler::LocalResidualAssemblerEngine ResidualEngine;
38 typedef typename LocalAssembler::LocalAssemblerDT1::LocalJacobianAssemblerEngine JacobianEngine;
39
47 (LocalAssembler & local_assembler_)
48 : la(local_assembler_),
49 prestage_engine(nullptr),
50 jacobian_engine(nullptr)
51 {}
52
53 void setLocalPreStageEngine(PreStageEngine & prestage_engine_)
54 {
55 prestage_engine = & prestage_engine_;
56 }
57
58 void setLocalJacobianEngine(JacobianEngine & jacobian_engine_)
59 {
60 jacobian_engine = & jacobian_engine_;
61 }
62
65 bool requireSkeleton() const
66 {
67 return prestage_engine->requireSkeleton() or jacobian_engine->requireSkeleton();
68 }
69 bool requireSkeletonTwoSided() const
70 {
71 return prestage_engine->requireSkeletonTwoSided() or jacobian_engine->requireSkeletonTwoSided();
72 }
73 bool requireUVVolume() const
74 {
75 return prestage_engine->requireUVVolume() or jacobian_engine->requireUVVolume();
76 }
77 bool requireVVolume() const
78 {
79 return prestage_engine->requireVVolume() or jacobian_engine->requireVVolume();
80 }
81 bool requireUVSkeleton() const
82 {
83 return prestage_engine->requireUVSkeleton() or jacobian_engine->requireUVSkeleton();
84 }
85 bool requireVSkeleton() const
86 {
87 return prestage_engine->requireVSkeleton() or jacobian_engine->requireVSkeleton();
88 }
89 bool requireUVBoundary() const
90 {
91 return prestage_engine->requireUVBoundary() or jacobian_engine->requireUVBoundary();
92 }
93 bool requireVBoundary() const
94 {
95 return prestage_engine->requireVBoundary() or jacobian_engine->requireVBoundary();
96 }
97 bool requireUVVolumePostSkeleton() const
98 {
99 return prestage_engine->requireUVVolumePostSkeleton() or jacobian_engine->requireUVVolumePostSkeleton();
100 }
101 bool requireVVolumePostSkeleton() const
102 {
103 return prestage_engine->requireVVolumePostSkeleton() or jacobian_engine->requireVVolumePostSkeleton();
104 }
105
107
109 const LocalAssembler & localAssembler() const
110 {
111 return la;
112 }
113
117 template<typename EG, typename LFSU, typename LFSV>
118 void onBindLFSUV(const EG & eg, const LFSU & lfsu, const LFSV & lfsv)
119 {
120 if (prestage_engine->requireUVVolume() or prestage_engine->requireVVolume())
121 prestage_engine->onBindLFSUV(eg,lfsu,lfsv);
122 if (jacobian_engine->requireUVVolume() or jacobian_engine->requireVVolume())
123 jacobian_engine->onBindLFSUV(eg,lfsu,lfsv);
124 }
125
126 template<typename EG, typename LFSV>
127 void onBindLFSV(const EG & eg, const LFSV & lfsv)
128 {
129 if (prestage_engine->requireUVVolume() or prestage_engine->requireVVolume())
130 prestage_engine->onBindLFSV(eg,lfsv);
131 if (jacobian_engine->requireUVVolume() or jacobian_engine->requireVVolume())
132 jacobian_engine->onBindLFSV(eg,lfsv);
133 }
134
135 template<typename IG, typename LFSU, typename LFSV>
136 void onBindLFSUVInside(const IG & ig, const LFSU & lfsu, const LFSV & lfsv)
137 {
138 if (prestage_engine->requireUVVolume() or prestage_engine->requireVVolume())
139 prestage_engine->onBindLFSUVInside(ig,lfsu,lfsv);
140 if (jacobian_engine->requireUVVolume() or jacobian_engine->requireVVolume())
141 jacobian_engine->onBindLFSUVInside(ig,lfsu,lfsv);
142 }
143
144 template<typename IG, typename LFSU_S, typename LFSV_S, typename LFSU_N, typename LFSV_N>
145 void onBindLFSUVOutside(const IG & ig,
146 const LFSU_S & lfsus, const LFSV_S & lfsvs,
147 const LFSU_N & lfsun, const LFSV_N & lfsvn)
148 {
149 if (prestage_engine->requireSkeleton())
150 prestage_engine->onBindLFSUVOutside(ig,lfsus,lfsvs,lfsun,lfsvn);
151 if (jacobian_engine->requireSkeleton())
152 jacobian_engine->onBindLFSUVOutside(ig,lfsus,lfsvs,lfsun,lfsvn);
153 }
154
155 template<typename IG, typename LFSV>
156 void onBindLFSVInside(const IG & ig, const LFSV & lfsv)
157 {
158 if (prestage_engine->requireUVVolume() or prestage_engine->requireVVolume())
159 prestage_engine->onBindLFSVInside(ig,lfsv);
160 if (jacobian_engine->requireUVVolume() or jacobian_engine->requireVVolume())
161 jacobian_engine->onBindLFSVInside(ig,lfsv);
162 }
163
164 template<typename IG, typename LFSV_S, typename LFSV_N>
165 void onBindLFSVOutside(const IG & ig,
166 const LFSV_S & lfsvs,
167 const LFSV_N & lfsvn)
168 {
169 if (prestage_engine->requireSkeleton())
170 prestage_engine->onBindLFSVOutside(ig,lfsvs,lfsvn);
171 if (jacobian_engine->requireSkeleton())
172 jacobian_engine->onBindLFSVOutside(ig,lfsvs,lfsvn);
173 }
174
176
180 template<typename EG, typename LFSV>
181 void onUnbindLFSV(const EG & eg, const LFSV & lfsv)
182 {
183 if (prestage_engine->requireUVVolume() or prestage_engine->requireVVolume())
184 prestage_engine->onUnbindLFSV(eg,lfsv);
185 if (jacobian_engine->requireUVVolume() or jacobian_engine->requireVVolume())
186 jacobian_engine->onUnbindLFSV(eg,lfsv);
187 }
188
189 template<typename IG, typename LFSV>
190 void onUnbindLFSVInside(const IG & ig, const LFSV & lfsv)
191 {
192 if (prestage_engine->requireUVVolume() or prestage_engine->requireVVolume())
193 prestage_engine->onUnbindLFSVInside(ig,lfsv);
194 if (jacobian_engine->requireUVVolume() or jacobian_engine->requireVVolume())
195 jacobian_engine->onUnbindLFSVInside(ig,lfsv);
196 }
197
198 template<typename IG, typename LFSV_S, typename LFSV_N>
199 void onUnbindLFSVOutside(const IG & ig,
200 const LFSV_S & lfsvs,
201 const LFSV_N & lfsvn)
202 {
203 if (prestage_engine->requireSkeleton())
204 prestage_engine->onUnbindLFSVOutside(ig,lfsvs,lfsvn);
205 if (jacobian_engine->requireSkeleton())
206 jacobian_engine->onUnbindLFSVOutside(ig,lfsvs,lfsvn);
207 }
208
209 template<typename EG, typename LFSU, typename LFSV>
210 void onUnbindLFSUV(const EG& eg, const LFSU& lfsu, const LFSV& lfsv)
211 {
212 if (prestage_engine->requireUVVolume() or prestage_engine->requireVVolume())
213 prestage_engine->onUnbindLFSUV(eg,lfsu,lfsv);
214 if (jacobian_engine->requireUVVolume() or jacobian_engine->requireVVolume())
215 jacobian_engine->onUnbindLFSUV(eg,lfsu,lfsv);
216 }
217
218 template<typename IG, typename LFSU, typename LFSV>
219 void onUnbindLFSUVInside(const IG& ig, const LFSU& lfsu, const LFSV& lfsv)
220 {
221 if (prestage_engine->requireUVVolume() or prestage_engine->requireVVolume())
222 prestage_engine->onUnbindLFSUVInside(ig,lfsu,lfsv);
223 if (jacobian_engine->requireUVVolume() or jacobian_engine->requireVVolume())
224 jacobian_engine->onUnbindLFSUVInside(ig,lfsu,lfsv);
225 }
226
227 template<typename IG, typename LFSU_S, typename LFSV_S, typename LFSU_N, typename LFSV_N>
228 void onUnbindLFSUVOutside(const IG& ig,
229 const LFSU_S& lfsu_s, const LFSV_S& lfsv_s,
230 const LFSU_N& lfsu_n, const LFSV_N& lfsv_n)
231 {
232 if (prestage_engine->requireSkeleton())
233 prestage_engine->onUnbindLFSUVOutside(ig,lfsu_s,lfsv_s,lfsu_n,lfsv_n);
234 if (jacobian_engine->requireSkeleton())
235 jacobian_engine->onUnbindLFSUVOutside(ig,lfsu_s,lfsv_s,lfsu_n,lfsv_n);
236 }
237
238
240
243 template<typename LFSU>
244 void loadCoefficientsLFSUInside(const LFSU & lfsu_s)
245 {
246 if (prestage_engine->requireUVVolume())
247 prestage_engine->loadCoefficientsLFSUInside(lfsu_s);
248 if (jacobian_engine->requireUVVolume())
249 jacobian_engine->loadCoefficientsLFSUInside(lfsu_s);
250 }
251
252 template<typename LFSU>
253 void loadCoefficientsLFSUOutside(const LFSU & lfsu_n)
254 {
255 if (prestage_engine->requireUVSkeleton())
256 prestage_engine->loadCoefficientsLFSUOutside(lfsu_n);
257 if (jacobian_engine->requireUVSkeleton())
258 jacobian_engine->loadCoefficientsLFSUOutside(lfsu_n);
259 }
260
261 template<typename LFSU>
262 void loadCoefficientsLFSUCoupling(const LFSU & lfsu_c)
263 {
264 prestage_engine->loadCoefficientsLFSUCoupling(lfsu_c);
265 jacobian_engine->loadCoefficientsLFSUCoupling(lfsu_c);
266 }
268
271
273 {
274 prestage_engine->preAssembly();
275 jacobian_engine->preAssembly();
276 }
277
278 template<typename GFSU, typename GFSV>
279 void postAssembly(const GFSU& gfsu, const GFSV& gfsv)
280 {
281 prestage_engine->postAssembly(gfsu,gfsv);
282 jacobian_engine->postAssembly(gfsu,gfsv);
283 }
284
286
289
290 template<typename EG>
291 bool assembleCell(const EG & eg)
292 {
293 const bool abort_a = prestage_engine->assembleCell(eg);
294 const bool abort_c = jacobian_engine->assembleCell(eg);
295 return abort_a and abort_c;
296 }
297
298 template<typename EG, typename LFSU, typename LFSV>
299 void assembleUVVolume(const EG & eg, const LFSU & lfsu, const LFSV & lfsv)
300 {
301 if (prestage_engine->requireUVVolume())
302 prestage_engine->assembleUVVolume(eg,lfsu,lfsv);
303 la.setWeight(-1.0);
304 prestage_engine->setTimeInLastStage();
305 if (jacobian_engine->requireUVVolume())
306 jacobian_engine->assembleUVVolume(eg,lfsu,lfsv);
307 }
308
309 template<typename EG, typename LFSV>
310 void assembleVVolume(const EG & eg, const LFSV & lfsv)
311 {
312 if (prestage_engine->requireVVolume())
313 prestage_engine->assembleVVolume(eg,lfsv);
314 la.setWeight(-1.0);
315 prestage_engine->setTimeInLastStage();
316 if (jacobian_engine->requireVVolume())
317 jacobian_engine->assembleVVolume(eg,lfsv);
318 }
319
320 template<typename IG, typename LFSU_S, typename LFSV_S, typename LFSU_N, typename LFSV_N>
321 void assembleUVSkeleton(const IG & ig, const LFSU_S & lfsu_s, const LFSV_S & lfsv_s,
322 const LFSU_N & lfsu_n, const LFSV_N & lfsv_n)
323 {
324 if (prestage_engine->requireUVSkeleton())
325 prestage_engine->assembleUVSkeleton(ig,lfsu_s,lfsv_s,lfsu_n,lfsv_n);
326 la.setWeight(-1.0);
327 if (jacobian_engine->requireUVSkeleton())
328 jacobian_engine->assembleUVSkeleton(ig,lfsu_s,lfsv_s,lfsu_n,lfsv_n);
329 }
330
331 template<typename IG, typename LFSV_S, typename LFSV_N>
332 void assembleVSkeleton(const IG & ig, const LFSV_S & lfsv_s, const LFSV_N & lfsv_n)
333 {
334 if (prestage_engine->requireVSkeleton())
335 prestage_engine->assembleVSkeleton(ig,lfsv_s,lfsv_n);
336 la.setWeight(-1.0);
337 if (jacobian_engine->requireVSkeleton())
338 jacobian_engine->assembleVSkeleton(ig,lfsv_s,lfsv_n);
339 }
340
341 template<typename IG, typename LFSU, typename LFSV>
342 void assembleUVBoundary(const IG & ig, const LFSU & lfsu_s, const LFSV & lfsv_s)
343 {
344 if (prestage_engine->requireUVBoundary())
345 prestage_engine->assembleUVBoundary(ig,lfsu_s,lfsv_s);
346 la.setWeight(-1.0);
347 if (jacobian_engine->requireUVBoundary())
348 jacobian_engine->assembleUVBoundary(ig,lfsu_s,lfsv_s);
349 }
350
351 template<typename IG, typename LFSV>
352 void assembleVBoundary(const IG & ig, const LFSV & lfsv_s)
353 {
354 if (prestage_engine->requireVBoundary())
355 prestage_engine->assembleVBoundary(ig,lfsv_s);
356 la.setWeight(-1.0);
357 if (jacobian_engine->requireVBoundary())
358 jacobian_engine->assembleVBoundary(ig,lfsv_s);
359 }
360
361 template<typename IG, typename LFSU_S, typename LFSV_S, typename LFSU_N, typename LFSV_N,
362 typename LFSU_C, typename LFSV_C>
363 void assembleUVEnrichedCoupling(const IG & ig,
364 const LFSU_S & lfsu_s, const LFSV_S & lfsv_s,
365 const LFSU_N & lfsu_n, const LFSV_N & lfsv_n,
366 const LFSU_C & lfsu_coupling, const LFSV_C & lfsv_coupling)
367 {
368 prestage_engine->assembleUVEnrichedCoupling(ig,lfsu_s,lfsv_s,lfsu_n,lfsv_n,lfsu_coupling,lfsv_coupling);
369 la.setWeight(-1.0);
370 jacobian_engine->assembleUVEnrichedCoupling(ig,lfsu_s,lfsv_s,lfsu_n,lfsv_n,lfsu_coupling,lfsv_coupling);
371 }
372
373 template<typename IG, typename LFSV_S, typename LFSV_N, typename LFSV_C>
374 void assembleVEnrichedCoupling(const IG & ig,
375 const LFSV_S & lfsv_s,
376 const LFSV_N & lfsv_n,
377 const LFSV_C & lfsv_coupling)
378 {
379 prestage_engine->assembleVEnrichedCoupling(ig,lfsv_s,lfsv_n,lfsv_coupling);
380 la.setWeight(-1.0);
381 jacobian_engine->assembleVEnrichedCoupling(ig,lfsv_s,lfsv_n,lfsv_coupling);
382 }
383
384 template<typename EG, typename LFSU, typename LFSV>
385 void assembleUVVolumePostSkeleton(const EG & eg, const LFSU & lfsu, const LFSV & lfsv)
386 {
387 if (prestage_engine->requireUVVolumePostSkeleton())
388 prestage_engine->assembleUVVolumePostSkeleton(eg,lfsu,lfsv);
389 la.setWeight(-1.0);
390 if (jacobian_engine->requireUVVolumePostSkeleton())
391 jacobian_engine->assembleUVVolumePostSkeleton(eg,lfsu,lfsv);
392 }
393
394 template<typename EG, typename LFSV>
395 void assembleVVolumePostSkeleton(const EG & eg, const LFSV & lfsv)
396 {
397 if (prestage_engine->requireVVolumePostSkeleton())
398 prestage_engine->assembleVVolumePostSkeleton(eg,lfsv);
399 la.setWeight(-1.0);
400 if (jacobian_engine->requireVVolumePostSkeleton())
401 jacobian_engine->assembleVVolumePostSkeleton(eg,lfsv);
402 }
403
405
406 private:
407
410 LocalAssembler & la;
411
412 PreStageEngine * prestage_engine;
413 JacobianEngine * jacobian_engine;
414
415 }; // End of class OneStepJacobianResidualAssemblerEngine
416
417 }
418}
419#endif // DUNE_PDELAB_GRIDOPERATOR_ONESTEP_JACOBIANRESIDUALENGINE_HH
Base class for LocalAssemblerEngine implementations to avoid boilerplate code.
Definition: localassemblerenginebase.hh:22
The local assembler engine for DUNE grids which assembles the residual vector.
Definition: jacobianresidualengine.hh:21
OneStepExplicitLocalJacobianResidualAssemblerEngine(LocalAssembler &local_assembler_)
Constructor.
Definition: jacobianresidualengine.hh:47
void loadCoefficientsLFSUInside(const LFSU &lfsu_s)
Definition: jacobianresidualengine.hh:244
bool assembleCell(const EG &eg)
Definition: jacobianresidualengine.hh:291
bool requireSkeleton() const
Definition: jacobianresidualengine.hh:65
void onBindLFSUV(const EG &eg, const LFSU &lfsu, const LFSV &lfsv)
Definition: jacobianresidualengine.hh:118
OSLA OneStepLocalAssembler
The type of the wrapping local assembler.
Definition: jacobianresidualengine.hh:24
void onUnbindLFSV(const EG &eg, const LFSV &lfsv)
Definition: jacobianresidualengine.hh:181
OSLA::Real Real
The type for real numbers.
Definition: jacobianresidualengine.hh:33
void preAssembly()
Definition: jacobianresidualengine.hh:272
const LocalAssembler & localAssembler() const
Public access to the wrapping local assembler.
Definition: jacobianresidualengine.hh:109
Dune namespace.
Definition: alignedallocator.hh:11
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 22, 23:30, 2024)