1#ifndef DUNE_PDELAB_GRIDOPERATOR_DEFAULT_JACOBIANAPPLYENGINE_HH
2#define DUNE_PDELAB_GRIDOPERATOR_DEFAULT_JACOBIANAPPLYENGINE_HH
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>
26 template<
typename TrialConstra
intsContainer,
typename TestConstra
intsContainer>
27 bool needsConstraintsCaching(
const TrialConstraintsContainer& cu,
const TestConstraintsContainer& cv)
const
36 typedef typename LA::LocalOperator
LOP;
39 static constexpr bool isLinear = LOP::isLinear;
42 typedef typename LA::Traits::Range
Range;
43 typedef typename Range::ElementType RangeElement;
46 typedef typename LA::Traits::Domain
Domain;
47 typedef typename Domain::ElementType DomainElement;
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;
57 typedef typename Domain::template ConstLocalView<LFSUCache> DomainView;
58 typedef typename Range::template LocalView<LFSVCache> RangeView;
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)
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(); }
92 return local_assembler;
96 const typename LocalAssembler::Traits::TrialGridFunctionSpaceConstraints&
trialConstraints()
const
102 const typename LocalAssembler::Traits::TestGridFunctionSpaceConstraints&
testConstraints()
const
111 global_solution_view_inside.attach(solution_);
112 global_solution_view_outside.attach(solution_);
119 global_update_view_inside.attach(update_);
120 global_update_view_outside.attach(update_);
127 global_result_view_inside.attach(result_);
128 global_result_view_outside.attach(result_);
134 template<
typename EG,
typename LFSUC,
typename LFSVC>
135 void onBindLFSUV(
const EG & eg,
const LFSUC & lfsu_cache,
const LFSVC & lfsv_cache)
137 global_solution_view_inside.bind(lfsu_cache);
140 local_solution_inside.
resize(lfsu_cache.size());
141 global_update_view_inside.bind(lfsu_cache);
142 local_update_inside.
resize(lfsu_cache.size());
145 template<
typename EG,
typename LFSVC>
146 void onBindLFSV(
const EG & eg,
const LFSVC & lfsv_cache)
148 global_result_view_inside.bind(lfsv_cache);
149 local_result_inside.
assign(lfsv_cache.size(),0.0);
152 template<
typename IG,
typename LFSUC,
typename LFSVC>
153 void onBindLFSUVInside(
const IG & ig,
const LFSUC & lfsu_cache,
const LFSVC & lfsv_cache)
155 global_solution_view_inside.bind(lfsu_cache);
158 local_solution_inside.
resize(lfsu_cache.size());
159 global_update_view_inside.bind(lfsu_cache);
160 local_update_inside.
resize(lfsu_cache.size());
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)
168 global_solution_view_outside.bind(lfsu_n_cache);
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());
176 template<
typename IG,
typename LFSVC>
177 void onBindLFSVInside(
const IG & ig,
const LFSVC & lfsv_cache)
179 global_result_view_inside.bind(lfsv_cache);
180 local_result_inside.
assign(lfsv_cache.size(),0.0);
183 template<
typename IG,
typename LFSVC>
184 void onBindLFSVOutside(
const IG & ig,
185 const LFSVC & lfsv_s_cache,
186 const LFSVC & lfsv_n_cache)
188 global_result_view_outside.bind(lfsv_n_cache);
189 local_result_outside.
assign(lfsv_n_cache.size(),0.0);
197 template<
typename EG,
typename LFSVC>
200 global_result_view_inside.add(local_result_inside);
201 global_result_view_inside.commit();
204 template<
typename IG,
typename LFSVC>
205 void onUnbindLFSVInside(
const IG & ig,
const LFSVC & lfsv_cache)
207 global_result_view_inside.add(local_result_inside);
208 global_result_view_inside.commit();
211 template<
typename IG,
typename LFSVC>
212 void onUnbindLFSVOutside(
const IG & ig,
213 const LFSVC & lfsv_s_cache,
214 const LFSVC & lfsv_n_cache)
216 global_result_view_outside.add(local_result_outside);
217 global_result_view_outside.commit();
223 template<
typename LFSUC>
228 global_solution_view_inside.read(local_solution_inside);
229 global_update_view_inside.read(local_update_inside);
231 template<
typename LFSUC>
232 void loadCoefficientsLFSUOutside(
const LFSUC & lfsu_n_cache)
236 global_solution_view_outside.read(local_solution_outside);
237 global_update_view_outside.read(local_update_outside);
239 template<
typename LFSUC>
240 void loadCoefficientsLFSUCoupling(
const LFSUC & lfsu_c_cache)
251 if(local_assembler.doPostProcessing())
253 global_result_view_inside.container());
270 (LocalAssembler::isNonOverlapping &&
280 template<
typename IG>
286 template<
typename EG,
typename LFSUC,
typename LFSVC>
287 void assembleUVVolume(
const EG & eg,
const LFSUC & lfsu_cache,
const LFSVC & lfsv_cache)
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);
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)
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);
307 template<
typename IG,
typename LFSUC,
typename LFSVC>
308 void assembleUVBoundary(
const IG & ig,
const LFSUC & lfsu_s_cache,
const LFSVC & lfsv_s_cache)
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);
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)
324 template<
typename EG,
typename LFSUC,
typename LFSVC>
325 void assembleUVVolumePostSkeleton(
const EG & eg,
const LFSUC & lfsu_cache,
const LFSVC & lfsv_cache)
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);
343 DomainView global_solution_view_inside;
344 DomainView global_solution_view_outside;
347 DomainView global_update_view_inside;
348 DomainView global_update_view_outside;
351 RangeView global_result_view_inside;
352 RangeView global_result_view_outside;
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;
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
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