DUNE PDELab (git)

jacobianengine.hh
1#ifndef DUNE_PDELAB_GRIDOPERATOR_DEFAULT_JACOBIANENGINE_HH
2#define DUNE_PDELAB_GRIDOPERATOR_DEFAULT_JACOBIANENGINE_HH
3
4#include <dune/pdelab/constraints/common/constraints.hh>
6#include <dune/pdelab/gridoperator/common/localmatrix.hh>
7#include <dune/pdelab/gridoperator/common/diagonallocalmatrix.hh>
8#include <dune/pdelab/gridoperator/common/assemblerutilities.hh>
9#include <dune/pdelab/gridoperator/common/localassemblerenginebase.hh>
10#include <dune/pdelab/localoperator/callswitch.hh>
11#include <dune/pdelab/localoperator/flags.hh>
12
13namespace Dune{
14 namespace PDELab{
15
23 template<typename LA>
26 {
27 public:
28
29 template<typename TrialConstraintsContainer, typename TestConstraintsContainer>
30 bool needsConstraintsCaching(const TrialConstraintsContainer& cu, const TestConstraintsContainer& cv)
31 {
32 return cu.containsNonDirichletConstraints() || cv.containsNonDirichletConstraints();
33 }
34
36 typedef LA LocalAssembler;
37
39 typedef typename LA::LocalOperator LOP;
40
42 typedef typename LA::LFSU LFSU;
43 typedef typename LA::LFSUCache LFSUCache;
44 typedef typename LFSU::Traits::GridFunctionSpace GFSU;
45 typedef typename LA::LFSV LFSV;
46 typedef typename LA::LFSVCache LFSVCache;
47 typedef typename LFSV::Traits::GridFunctionSpace GFSV;
48
50 typedef typename LA::Traits::Jacobian Jacobian;
51 typedef typename Jacobian::ElementType JacobianElement;
52 typedef typename Jacobian::template LocalView<LFSVCache,LFSUCache> JacobianView;
53
55 typedef typename LA::Traits::Solution Solution;
56 typedef typename Solution::ElementType SolutionElement;
57 typedef typename Solution::template ConstLocalView<LFSUCache> SolutionView;
58
66 : local_assembler(local_assembler_),
67 lop(local_assembler_.localOperator()),
68 al_view(al,1.0),
69 al_sn_view(al_sn,1.0),
70 al_ns_view(al_ns,1.0),
71 al_nn_view(al_nn,1.0)
72 {}
73
76 bool requireSkeleton() const
77 { return local_assembler.doAlphaSkeleton(); }
78 bool requireSkeletonTwoSided() const
79 { return local_assembler.doSkeletonTwoSided(); }
80 bool requireUVVolume() const
81 { return local_assembler.doAlphaVolume(); }
82 bool requireUVSkeleton() const
83 { return local_assembler.doAlphaSkeleton(); }
84 bool requireUVBoundary() const
85 { return local_assembler.doAlphaBoundary(); }
86 bool requireUVVolumePostSkeleton() const
87 { return local_assembler.doAlphaVolumePostSkeleton(); }
89
92 {
93 return local_assembler;
94 }
95
97 const typename LocalAssembler::Traits::TrialGridFunctionSpaceConstraints& trialConstraints() const
98 {
99 return localAssembler().trialConstraints();
100 }
101
103 const typename LocalAssembler::Traits::TestGridFunctionSpaceConstraints& testConstraints() const
104 {
105 return localAssembler().testConstraints();
106 }
107
110 void setJacobian(Jacobian & jacobian_)
111 {
112 global_a_ss_view.attach(jacobian_);
113 global_a_sn_view.attach(jacobian_);
114 global_a_ns_view.attach(jacobian_);
115 global_a_nn_view.attach(jacobian_);
116 }
117
120 void setSolution(const Solution & solution_)
121 {
122 global_s_s_view.attach(solution_);
123 global_s_n_view.attach(solution_);
124 }
125
129 template<typename EG, typename LFSUC, typename LFSVC>
130 void onBindLFSUV(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
131 {
132 global_s_s_view.bind(lfsu_cache);
133 xl.resize(lfsu_cache.size());
134 global_a_ss_view.bind(lfsv_cache,lfsu_cache);
135 al.assign(lfsv_cache.size(),lfsu_cache.size(),0.0);
136 }
137
138 template<typename IG, typename LFSUC, typename LFSVC>
139 void onBindLFSUVOutside(const IG & ig,
140 const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache,
141 const LFSUC & lfsu_n_cache, const LFSVC & lfsv_n_cache)
142 {
143 global_s_n_view.bind(lfsu_n_cache);
144 xn.resize(lfsu_n_cache.size());
145 global_a_sn_view.bind(lfsv_s_cache,lfsu_n_cache);
146 al_sn.assign(lfsv_s_cache.size(),lfsu_n_cache.size(),0.0);
147 global_a_ns_view.bind(lfsv_n_cache,lfsu_s_cache);
148 al_ns.assign(lfsv_n_cache.size(),lfsu_s_cache.size(),0.0);
149 global_a_nn_view.bind(lfsv_n_cache,lfsu_n_cache);
150 al_nn.assign(lfsv_n_cache.size(),lfsu_n_cache.size(),0.0);
151 }
152
154
158 template<typename EG, typename LFSUC, typename LFSVC>
159 void onUnbindLFSUV(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
160 {
161 local_assembler.scatter_jacobian(al,global_a_ss_view,false);
162 }
163
164 template<typename IG, typename LFSUC, typename LFSVC>
165 void onUnbindLFSUVOutside(const IG & ig,
166 const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache,
167 const LFSUC & lfsu_n_cache, const LFSVC & lfsv_n_cache)
168 {
169 local_assembler.scatter_jacobian(al_sn,global_a_sn_view,false);
170 local_assembler.scatter_jacobian(al_ns,global_a_ns_view,false);
171 local_assembler.scatter_jacobian(al_nn,global_a_nn_view,false);
172 }
173
175
178 template<typename LFSUC>
179 void loadCoefficientsLFSUInside(const LFSUC & lfsu_cache)
180 {
181 global_s_s_view.read(xl);
182 }
183 template<typename LFSUC>
184 void loadCoefficientsLFSUOutside(const LFSUC & lfsu_n_cache)
185 {
186 global_s_n_view.read(xn);
187 }
188 template<typename LFSUC>
189 void loadCoefficientsLFSUCoupling(const LFSUC & lfsu_c_cache)
190 {
191 DUNE_THROW(Dune::NotImplemented,"No coupling lfsu_cache available for ");
192 }
194
197 void postAssembly(const GFSU& gfsu, const GFSV& gfsv)
198 {
199 Jacobian& jacobian = global_a_ss_view.container();
200 global_s_s_view.detach();
201 global_s_n_view.detach();
202 global_a_ss_view.detach();
203 global_a_sn_view.detach();
204 global_a_ns_view.detach();
205 global_a_nn_view.detach();
206
207 if(local_assembler.doPostProcessing())
208 local_assembler.handle_dirichlet_constraints(gfsv,jacobian);
209
210 }
212
215
222 template<typename EG>
223 bool skipEntity(const EG & eg)
224 {
225 return localAssembler().skipEntity(eg) ||
226 (LocalAssembler::isNonOverlapping &&
227 eg.entity().partitionType() != Dune::InteriorEntity);
228 }
229
236 template<typename IG>
237 bool skipIntersection(const IG & ig)
238 {
239 return localAssembler().skipIntersection(ig);
240 }
241
242 template<typename EG, typename LFSUC, typename LFSVC>
243 void assembleUVVolume(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
244 {
245 al_view.setWeight(local_assembler.weight());
246 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doAlphaVolume>::
247 jacobian_volume(lop,eg,lfsu_cache.localFunctionSpace(),xl,lfsv_cache.localFunctionSpace(),al_view);
248 }
249
250 template<typename IG, typename LFSUC, typename LFSVC>
251 void assembleUVSkeleton(const IG & ig, const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache,
252 const LFSUC & lfsu_n_cache, const LFSVC & lfsv_n_cache)
253 {
254 al_view.setWeight(local_assembler.weight());
255 al_sn_view.setWeight(local_assembler.weight());
256 al_ns_view.setWeight(local_assembler.weight());
257 al_nn_view.setWeight(local_assembler.weight());
258
259 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doAlphaSkeleton>::
260 jacobian_skeleton(lop,ig,lfsu_s_cache.localFunctionSpace(),xl,lfsv_s_cache.localFunctionSpace(),lfsu_n_cache.localFunctionSpace(),xn,lfsv_n_cache.localFunctionSpace(),al_view,al_sn_view,al_ns_view,al_nn_view);
261 }
262
263 template<typename IG, typename LFSUC, typename LFSVC>
264 void assembleUVBoundary(const IG & ig, const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache)
265 {
266 al_view.setWeight(local_assembler.weight());
267 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doAlphaBoundary>::
268 jacobian_boundary(lop,ig,lfsu_s_cache.localFunctionSpace(),xl,lfsv_s_cache.localFunctionSpace(),al_view);
269 }
270
271 template<typename IG, typename LFSUC, typename LFSVC>
272 static void assembleUVEnrichedCoupling(const IG & ig,
273 const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache,
274 const LFSUC & lfsu_n_cache, const LFSVC & lfsv_n_cache,
275 const LFSUC & lfsu_coupling_cache, const LFSVC & lfsv_coupling_cache)
276 {
277 DUNE_THROW(Dune::NotImplemented,"Assembling of coupling spaces is not implemented for ");
278 }
279
280 template<typename IG, typename LFSVC>
281 static void assembleVEnrichedCoupling(const IG & ig,
282 const LFSVC & lfsv_s_cache,
283 const LFSVC & lfsv_n_cache,
284 const LFSVC & lfsv_coupling_cache)
285 {
286 DUNE_THROW(Dune::NotImplemented,"Assembling of coupling spaces is not implemented for ");
287 }
288
289 template<typename EG, typename LFSUC, typename LFSVC>
290 void assembleUVVolumePostSkeleton(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
291 {
292 al_view.setWeight(local_assembler.weight());
293 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doAlphaVolumePostSkeleton>::
294 jacobian_volume_post_skeleton(lop,eg,lfsu_cache.localFunctionSpace(),xl,lfsv_cache.localFunctionSpace(),al_view);
295 }
296
298
299 private:
302 const LocalAssembler & local_assembler;
303
305 const LOP & lop;
306
308 SolutionView global_s_s_view;
309 SolutionView global_s_n_view;
310
312 JacobianView global_a_ss_view;
313 JacobianView global_a_sn_view;
314 JacobianView global_a_ns_view;
315 JacobianView global_a_nn_view;
316
319 typedef Dune::PDELab::TrialSpaceTag LocalTrialSpaceTag;
320 typedef Dune::PDELab::TestSpaceTag LocalTestSpaceTag;
321
323 typedef typename std::conditional<
324 std::is_base_of<
325 lop::DiagonalJacobian,
326 LOP
327 >::value,
330 >::type JacobianMatrix;
331
332 SolutionVector xl;
333 SolutionVector xn;
334
335 JacobianMatrix al;
336 JacobianMatrix al_sn;
337 JacobianMatrix al_ns;
338 JacobianMatrix al_nn;
339
340 typename JacobianMatrix::WeightedAccumulationView al_view;
341 typename JacobianMatrix::WeightedAccumulationView al_sn_view;
342 typename JacobianMatrix::WeightedAccumulationView al_ns_view;
343 typename JacobianMatrix::WeightedAccumulationView al_nn_view;
344
346
347 }; // End of class DefaultLocalJacobianAssemblerEngine
348
349 }
350}
351#endif // DUNE_PDELAB_GRIDOPERATOR_DEFAULT_JACOBIANENGINE_HH
Default exception for dummy implementations.
Definition: exceptions.hh:263
The local assembler engine for DUNE grids which assembles the jacobian matrix.
Definition: jacobianengine.hh:26
void loadCoefficientsLFSUInside(const LFSUC &lfsu_cache)
Definition: jacobianengine.hh:179
void onUnbindLFSUV(const EG &eg, const LFSUC &lfsu_cache, const LFSVC &lfsv_cache)
Definition: jacobianengine.hh:159
const LocalAssembler & localAssembler() const
Public access to the wrapping local assembler.
Definition: jacobianengine.hh:91
bool requireSkeleton() const
Definition: jacobianengine.hh:76
void setSolution(const Solution &solution_)
Definition: jacobianengine.hh:120
void postAssembly(const GFSU &gfsu, const GFSV &gfsv)
Definition: jacobianengine.hh:197
bool skipIntersection(const IG &ig)
Definition: jacobianengine.hh:237
LA LocalAssembler
The type of the wrapping local assembler.
Definition: jacobianengine.hh:36
void onBindLFSUV(const EG &eg, const LFSUC &lfsu_cache, const LFSVC &lfsv_cache)
Definition: jacobianengine.hh:130
LA::Traits::Solution Solution
The type of the solution vector.
Definition: jacobianengine.hh:55
void setJacobian(Jacobian &jacobian_)
Definition: jacobianengine.hh:110
bool skipEntity(const EG &eg)
Definition: jacobianengine.hh:223
LA::LocalOperator LOP
The type of the local operator.
Definition: jacobianengine.hh:39
const LocalAssembler::Traits::TestGridFunctionSpaceConstraints & testConstraints() const
Test space constraints.
Definition: jacobianengine.hh:103
LA::LFSU LFSU
The local function spaces.
Definition: jacobianengine.hh:42
const LocalAssembler::Traits::TrialGridFunctionSpaceConstraints & trialConstraints() const
Trial space constraints.
Definition: jacobianengine.hh:97
DefaultLocalJacobianAssemblerEngine(const LocalAssembler &local_assembler_)
Constructor.
Definition: jacobianengine.hh:65
LA::Traits::Jacobian Jacobian
The type of the jacobian matrix.
Definition: jacobianengine.hh:50
A dense matrix for storing data associated with the degrees of freedom of a pair of LocalFunctionSpac...
Definition: diagonallocalmatrix.hh:29
Base class for LocalAssemblerEngine implementations to avoid boilerplate code.
Definition: localassemblerenginebase.hh:22
A dense matrix for storing data associated with the degrees of freedom of a pair of LocalFunctionSpac...
Definition: localmatrix.hh:184
void resize(size_type size)
Resize the container.
Definition: localvector.hh:324
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
@ InteriorEntity
all interior entities
Definition: gridenums.hh:31
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 24, 23:30, 2024)