DUNE PDELab (2.7)

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 assembleCell(const EG & eg)
224 {
225 return LocalAssembler::isNonOverlapping && eg.entity().partitionType() != Dune::InteriorEntity;
226 }
227
228 template<typename EG, typename LFSUC, typename LFSVC>
229 void assembleUVVolume(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
230 {
231 al_view.setWeight(local_assembler.weight());
232 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doAlphaVolume>::
233 jacobian_volume(lop,eg,lfsu_cache.localFunctionSpace(),xl,lfsv_cache.localFunctionSpace(),al_view);
234 }
235
236 template<typename IG, typename LFSUC, typename LFSVC>
237 void assembleUVSkeleton(const IG & ig, const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache,
238 const LFSUC & lfsu_n_cache, const LFSVC & lfsv_n_cache)
239 {
240 al_view.setWeight(local_assembler.weight());
241 al_sn_view.setWeight(local_assembler.weight());
242 al_ns_view.setWeight(local_assembler.weight());
243 al_nn_view.setWeight(local_assembler.weight());
244
245 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doAlphaSkeleton>::
246 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);
247 }
248
249 template<typename IG, typename LFSUC, typename LFSVC>
250 void assembleUVBoundary(const IG & ig, const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache)
251 {
252 al_view.setWeight(local_assembler.weight());
253 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doAlphaBoundary>::
254 jacobian_boundary(lop,ig,lfsu_s_cache.localFunctionSpace(),xl,lfsv_s_cache.localFunctionSpace(),al_view);
255 }
256
257 template<typename IG, typename LFSUC, typename LFSVC>
258 static void assembleUVEnrichedCoupling(const IG & ig,
259 const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache,
260 const LFSUC & lfsu_n_cache, const LFSVC & lfsv_n_cache,
261 const LFSUC & lfsu_coupling_cache, const LFSVC & lfsv_coupling_cache)
262 {
263 DUNE_THROW(Dune::NotImplemented,"Assembling of coupling spaces is not implemented for ");
264 }
265
266 template<typename IG, typename LFSVC>
267 static void assembleVEnrichedCoupling(const IG & ig,
268 const LFSVC & lfsv_s_cache,
269 const LFSVC & lfsv_n_cache,
270 const LFSVC & lfsv_coupling_cache)
271 {
272 DUNE_THROW(Dune::NotImplemented,"Assembling of coupling spaces is not implemented for ");
273 }
274
275 template<typename EG, typename LFSUC, typename LFSVC>
276 void assembleUVVolumePostSkeleton(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
277 {
278 al_view.setWeight(local_assembler.weight());
279 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doAlphaVolumePostSkeleton>::
280 jacobian_volume_post_skeleton(lop,eg,lfsu_cache.localFunctionSpace(),xl,lfsv_cache.localFunctionSpace(),al_view);
281 }
282
284
285 private:
288 const LocalAssembler & local_assembler;
289
291 const LOP & lop;
292
294 SolutionView global_s_s_view;
295 SolutionView global_s_n_view;
296
298 JacobianView global_a_ss_view;
299 JacobianView global_a_sn_view;
300 JacobianView global_a_ns_view;
301 JacobianView global_a_nn_view;
302
305 typedef Dune::PDELab::TrialSpaceTag LocalTrialSpaceTag;
306 typedef Dune::PDELab::TestSpaceTag LocalTestSpaceTag;
307
309 typedef typename std::conditional<
310 std::is_base_of<
311 lop::DiagonalJacobian,
312 LOP
313 >::value,
316 >::type JacobianMatrix;
317
318 SolutionVector xl;
319 SolutionVector xn;
320
321 JacobianMatrix al;
322 JacobianMatrix al_sn;
323 JacobianMatrix al_ns;
324 JacobianMatrix al_nn;
325
326 typename JacobianMatrix::WeightedAccumulationView al_view;
327 typename JacobianMatrix::WeightedAccumulationView al_sn_view;
328 typename JacobianMatrix::WeightedAccumulationView al_ns_view;
329 typename JacobianMatrix::WeightedAccumulationView al_nn_view;
330
332
333 }; // End of class DefaultLocalJacobianAssemblerEngine
334
335 }
336}
337#endif // DUNE_PDELAB_GRIDOPERATOR_DEFAULT_JACOBIANENGINE_HH
Default exception for dummy implementations.
Definition: exceptions.hh:261
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
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
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
bool assembleCell(const EG &eg)
Definition: jacobianengine.hh:223
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:323
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
@ InteriorEntity
all interior entities
Definition: gridenums.hh:29
Dune namespace.
Definition: alignedallocator.hh:14
Definition: localfunctionspacetags.hh:54
Definition: localfunctionspacetags.hh:48
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)