DUNE PDELab (git)

jacobianapplyengine.hh
1#ifndef DUNE_PDELAB_GRIDOPERATOR_DEFAULT_JACOBIANAPPLYENGINE_HH
2#define DUNE_PDELAB_GRIDOPERATOR_DEFAULT_JACOBIANAPPLYENGINE_HH
3
5#include <dune/pdelab/gridoperator/common/assemblerutilities.hh>
6#include <dune/pdelab/gridoperator/common/localassemblerenginebase.hh>
7#include <dune/pdelab/constraints/common/constraints.hh>
8#include <dune/pdelab/localoperator/callswitch.hh>
9
10namespace Dune{
11 namespace PDELab{
12
20 template<typename LA>
23 {
24 public:
25
26 template<typename TrialConstraintsContainer, typename TestConstraintsContainer>
27 bool needsConstraintsCaching(const TrialConstraintsContainer& cu, const TestConstraintsContainer& cv) const
28 {
29 return false;
30 }
31
33 typedef LA LocalAssembler;
34
36 typedef typename LA::LocalOperator LOP;
37
39 static constexpr bool isLinear = LOP::isLinear;
40
42 typedef typename LA::Traits::Range Range;
43 typedef typename Range::ElementType RangeElement;
44
46 typedef typename LA::Traits::Domain Domain;
47 typedef typename Domain::ElementType DomainElement;
48
50 typedef typename LA::LFSU LFSU;
51 typedef typename LA::LFSUCache LFSUCache;
52 typedef typename LFSU::Traits::GridFunctionSpace GFSU;
53 typedef typename LA::LFSV LFSV;
54 typedef typename LA::LFSVCache LFSVCache;
55 typedef typename LFSV::Traits::GridFunctionSpace GFSV;
56
57 typedef typename Domain::template ConstLocalView<LFSUCache> DomainView;
58 typedef typename Range::template LocalView<LFSVCache> RangeView;
59
67 : local_assembler(local_assembler_),
68 lop(local_assembler_.localOperator()),
69 result_view_inside(local_result_inside,1.0),
70 result_view_outside(local_result_outside,1.0)
71 {}
72
75 bool requireSkeleton() const
76 { return local_assembler.doAlphaSkeleton(); }
77 bool requireSkeletonTwoSided() const
78 { return local_assembler.doSkeletonTwoSided(); }
79 bool requireUVVolume() const
80 { return local_assembler.doAlphaVolume(); }
81 bool requireUVSkeleton() const
82 { return local_assembler.doAlphaSkeleton(); }
83 bool requireUVBoundary() const
84 { return local_assembler.doAlphaBoundary(); }
85 bool requireUVVolumePostSkeleton() const
86 { return local_assembler.doAlphaVolumePostSkeleton(); }
88
91 {
92 return local_assembler;
93 }
94
96 const typename LocalAssembler::Traits::TrialGridFunctionSpaceConstraints& trialConstraints() const
97 {
98 return localAssembler().trialConstraints();
99 }
100
102 const typename LocalAssembler::Traits::TestGridFunctionSpaceConstraints& testConstraints() const
103 {
104 return localAssembler().testConstraints();
105 }
106
109 void setSolution(const Domain & solution_)
110 {
111 global_solution_view_inside.attach(solution_);
112 global_solution_view_outside.attach(solution_);
113 }
114
117 void setUpdate(const Domain & update_)
118 {
119 global_update_view_inside.attach(update_);
120 global_update_view_outside.attach(update_);
121 }
122
125 void setResult(Range & result_)
126 {
127 global_result_view_inside.attach(result_);
128 global_result_view_outside.attach(result_);
129 }
130
134 template<typename EG, typename LFSUC, typename LFSVC>
135 void onBindLFSUV(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
136 {
137 global_solution_view_inside.bind(lfsu_cache);
138 // In the linear case the solution is not needed and we drop this part
139 if (not isLinear)
140 local_solution_inside.resize(lfsu_cache.size());
141 global_update_view_inside.bind(lfsu_cache);
142 local_update_inside.resize(lfsu_cache.size());
143 }
144
145 template<typename EG, typename LFSVC>
146 void onBindLFSV(const EG & eg, const LFSVC & lfsv_cache)
147 {
148 global_result_view_inside.bind(lfsv_cache);
149 local_result_inside.assign(lfsv_cache.size(),0.0);
150 }
151
152 template<typename IG, typename LFSUC, typename LFSVC>
153 void onBindLFSUVInside(const IG & ig, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
154 {
155 global_solution_view_inside.bind(lfsu_cache);
156 // In the linear case the solution is not needed and we drop this part
157 if (not isLinear)
158 local_solution_inside.resize(lfsu_cache.size());
159 global_update_view_inside.bind(lfsu_cache);
160 local_update_inside.resize(lfsu_cache.size());
161 }
162
163 template<typename IG, typename LFSUC, typename LFSVC>
164 void onBindLFSUVOutside(const IG & ig,
165 const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache,
166 const LFSUC & lfsu_n_cache, const LFSVC & lfsv_n_cache)
167 {
168 global_solution_view_outside.bind(lfsu_n_cache);
169 // In the linear case the solution is not needed and we drop this part
170 if (not isLinear)
171 local_solution_outside.resize(lfsu_n_cache.size());
172 global_update_view_outside.bind(lfsu_n_cache);
173 local_update_outside.resize(lfsu_n_cache.size());
174 }
175
176 template<typename IG, typename LFSVC>
177 void onBindLFSVInside(const IG & ig, const LFSVC & lfsv_cache)
178 {
179 global_result_view_inside.bind(lfsv_cache);
180 local_result_inside.assign(lfsv_cache.size(),0.0);
181 }
182
183 template<typename IG, typename LFSVC>
184 void onBindLFSVOutside(const IG & ig,
185 const LFSVC & lfsv_s_cache,
186 const LFSVC & lfsv_n_cache)
187 {
188 global_result_view_outside.bind(lfsv_n_cache);
189 local_result_outside.assign(lfsv_n_cache.size(),0.0);
190 }
191
193
197 template<typename EG, typename LFSVC>
198 void onUnbindLFSV(const EG & eg, const LFSVC & lfsv_cache)
199 {
200 global_result_view_inside.add(local_result_inside);
201 global_result_view_inside.commit();
202 }
203
204 template<typename IG, typename LFSVC>
205 void onUnbindLFSVInside(const IG & ig, const LFSVC & lfsv_cache)
206 {
207 global_result_view_inside.add(local_result_inside);
208 global_result_view_inside.commit();
209 }
210
211 template<typename IG, typename LFSVC>
212 void onUnbindLFSVOutside(const IG & ig,
213 const LFSVC & lfsv_s_cache,
214 const LFSVC & lfsv_n_cache)
215 {
216 global_result_view_outside.add(local_result_outside);
217 global_result_view_outside.commit();
218 }
220
223 template<typename LFSUC>
224 void loadCoefficientsLFSUInside(const LFSUC & lfsu_s_cache)
225 {
226 // In the linear case the solution is not needed and we drop this part
227 if (not isLinear)
228 global_solution_view_inside.read(local_solution_inside);
229 global_update_view_inside.read(local_update_inside);
230 }
231 template<typename LFSUC>
232 void loadCoefficientsLFSUOutside(const LFSUC & lfsu_n_cache)
233 {
234 // In the linear case the solution is not needed and we drop this part
235 if (not isLinear)
236 global_solution_view_outside.read(local_solution_outside);
237 global_update_view_outside.read(local_update_outside);
238 }
239 template<typename LFSUC>
240 void loadCoefficientsLFSUCoupling(const LFSUC & lfsu_c_cache)
241 {
242 DUNE_THROW(Dune::NotImplemented,"No coupling lfsu available for ");
243 }
245
248
249 void postAssembly(const GFSU& gfsu, const GFSV& gfsv)
250 {
251 if(local_assembler.doPostProcessing())
252 Dune::PDELab::constrain_residual(local_assembler.testConstraints(),
253 global_result_view_inside.container());
254 }
255
257
260
267 template <typename EG> bool skipEntity(const EG &eg)
268 {
269 return localAssembler().skipEntity(eg) ||
270 (LocalAssembler::isNonOverlapping &&
271 eg.entity().partitionType() != Dune::InteriorEntity);
272 }
273
280 template<typename IG>
281 bool skipIntersection(const IG & ig)
282 {
283 return localAssembler().skipIntersection(ig);
284 }
285
286 template<typename EG, typename LFSUC, typename LFSVC>
287 void assembleUVVolume(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
288 {
289 result_view_inside.setWeight(local_assembler.weight());
290 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doAlphaVolume>::
291 jacobian_apply_volume(lop,eg,lfsu_cache.localFunctionSpace(),local_solution_inside,local_update_inside,lfsv_cache.localFunctionSpace(),result_view_inside);
292 }
293
294 template<typename IG, typename LFSUC, typename LFSVC>
295 void assembleUVSkeleton(const IG & ig, const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache,
296 const LFSUC & lfsu_n_cache, const LFSVC & lfsv_n_cache)
297 {
298 result_view_inside.setWeight(local_assembler.weight());
299 result_view_outside.setWeight(local_assembler.weight());
300 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doAlphaSkeleton>::
301 jacobian_apply_skeleton(lop,ig,
302 lfsu_s_cache.localFunctionSpace(),local_solution_inside,local_update_inside,lfsv_s_cache.localFunctionSpace(),
303 lfsu_n_cache.localFunctionSpace(),local_solution_outside,local_update_outside,lfsv_n_cache.localFunctionSpace(),
304 result_view_inside,result_view_outside);
305 }
306
307 template<typename IG, typename LFSUC, typename LFSVC>
308 void assembleUVBoundary(const IG & ig, const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache)
309 {
310 result_view_inside.setWeight(local_assembler.weight());
311 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doAlphaBoundary>::
312 jacobian_apply_boundary(lop,ig,lfsu_s_cache.localFunctionSpace(),local_solution_inside,local_update_inside,lfsv_s_cache.localFunctionSpace(),result_view_inside);
313 }
314
315 template<typename IG, typename LFSUC, typename LFSVC>
316 static void assembleUVEnrichedCoupling(const IG & ig,
317 const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache,
318 const LFSUC & lfsu_n_cache, const LFSVC & lfsv_n_cache,
319 const LFSUC & lfsu_coupling_cache, const LFSVC & lfsv_coupling_cache)
320 {
321 DUNE_THROW(Dune::NotImplemented,"Assembling of coupling spaces is not implemented for ");
322 }
323
324 template<typename EG, typename LFSUC, typename LFSVC>
325 void assembleUVVolumePostSkeleton(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
326 {
327 result_view_inside.setWeight(local_assembler.weight());
328 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doAlphaVolumePostSkeleton>::
329 jacobian_apply_volume_post_skeleton(lop,eg,lfsu_cache.localFunctionSpace(),local_solution_inside,local_update_inside,lfsv_cache.localFunctionSpace(),result_view_inside);
330 }
331
333
334 private:
337 const LocalAssembler & local_assembler;
338
340 const LOP & lop;
341
343 DomainView global_solution_view_inside;
344 DomainView global_solution_view_outside;
345
347 DomainView global_update_view_inside;
348 DomainView global_update_view_outside;
349
351 RangeView global_result_view_inside;
352 RangeView global_result_view_outside;
353
356 typedef Dune::PDELab::TrialSpaceTag LocalTrialSpaceTag;
357 typedef Dune::PDELab::TestSpaceTag LocalTestSpaceTag;
358
361
363 DomainVector local_solution_inside;
365 DomainVector local_solution_outside;
367 DomainVector local_update_inside;
369 DomainVector local_update_outside;
371 RangeVector local_result_inside;
373 RangeVector local_result_outside;
375 typename RangeVector::WeightedAccumulationView result_view_inside;
377 typename RangeVector::WeightedAccumulationView result_view_outside;
379
380 }; // End of class DefaultLocalJacobianAssemblerEngine
381
382 }
383}
384#endif // DUNE_PDELAB_GRIDOPERATOR_DEFAULT_JACOBIANAPPLYENGINE_HH
Default exception for dummy implementations.
Definition: exceptions.hh:263
The local assembler engine for DUNE grids which assembles the local application of the Jacobian.
Definition: jacobianapplyengine.hh:23
bool skipIntersection(const IG &ig)
Definition: jacobianapplyengine.hh:281
void postAssembly(const GFSU &gfsu, const GFSV &gfsv)
Definition: jacobianapplyengine.hh:249
bool requireSkeleton() const
Definition: jacobianapplyengine.hh:75
const LocalAssembler::Traits::TrialGridFunctionSpaceConstraints & trialConstraints() const
Trial space constraints.
Definition: jacobianapplyengine.hh:96
DefaultLocalJacobianApplyAssemblerEngine(const LocalAssembler &local_assembler_)
Constructor.
Definition: jacobianapplyengine.hh:66
void setUpdate(const Domain &update_)
Definition: jacobianapplyengine.hh:117
void setResult(Range &result_)
Definition: jacobianapplyengine.hh:125
void loadCoefficientsLFSUInside(const LFSUC &lfsu_s_cache)
Definition: jacobianapplyengine.hh:224
LA::LFSU LFSU
The local function spaces.
Definition: jacobianapplyengine.hh:50
LA::Traits::Range Range
The type of the result vector.
Definition: jacobianapplyengine.hh:42
void onBindLFSUV(const EG &eg, const LFSUC &lfsu_cache, const LFSVC &lfsv_cache)
Definition: jacobianapplyengine.hh:135
void onUnbindLFSV(const EG &eg, const LFSVC &lfsv_cache)
Definition: jacobianapplyengine.hh:198
bool skipEntity(const EG &eg)
Definition: jacobianapplyengine.hh:267
const LocalAssembler::Traits::TestGridFunctionSpaceConstraints & testConstraints() const
Test space constraints.
Definition: jacobianapplyengine.hh:102
LA LocalAssembler
The type of the wrapping local assembler.
Definition: jacobianapplyengine.hh:33
LA::LocalOperator LOP
The type of the local operator.
Definition: jacobianapplyengine.hh:36
static constexpr bool isLinear
Wheter the local operator is linear.
Definition: jacobianapplyengine.hh:39
const LocalAssembler & localAssembler() const
Public access to the wrapping local assembler.
Definition: jacobianapplyengine.hh:90
LA::Traits::Domain Domain
The type of the solution vector.
Definition: jacobianapplyengine.hh:46
void setSolution(const Domain &solution_)
Definition: jacobianapplyengine.hh:109
Base class for LocalAssemblerEngine implementations to avoid boilerplate code.
Definition: localassemblerenginebase.hh:22
void assign(size_type size, const T &value)
Resize the container to size and assign the passed value to all entries.
Definition: localvector.hh:330
WeightedVectorAccumulationView< LocalVector > WeightedAccumulationView
An accumulate-only view of this container that automatically applies a weight to all contributions.
Definition: localvector.hh:211
void resize(size_type size)
Resize the container.
Definition: localvector.hh:324
void setWeight(weight_type weight)
Resets the weighting coefficient of the view.
Definition: localvector.hh:72
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
@ InteriorEntity
all interior entities
Definition: gridenums.hh:31
void constrain_residual(const CG &cg, XG &xg)
transform residual into transformed basis: r -> r~
Definition: constraints.hh:904
Dune namespace.
Definition: alignedallocator.hh:13
Definition: localfunctionspacetags.hh:54
Definition: localfunctionspacetags.hh:48
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 23, 23:29, 2024)