1#ifndef DUNE_PDELAB_GRIDOPERATOR_FASTDG_JACOBIANAPPLYENGINE_HH
2#define DUNE_PDELAB_GRIDOPERATOR_FASTDG_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 ConstAliasedLocalView<LFSUCache> DomainView;
58 typedef typename Range::template AliasedLocalView<LFSVCache> RangeView;
67 : local_assembler(local_assembler_),
68 lop(local_assembler_.localOperator())
74 {
return local_assembler.doAlphaSkeleton(); }
75 bool requireSkeletonTwoSided()
const
76 {
return local_assembler.doSkeletonTwoSided(); }
77 bool requireUVVolume()
const
78 {
return local_assembler.doAlphaVolume(); }
79 bool requireUVSkeleton()
const
80 {
return local_assembler.doAlphaSkeleton(); }
81 bool requireUVBoundary()
const
82 {
return local_assembler.doAlphaBoundary(); }
83 bool requireUVVolumePostSkeleton()
const
84 {
return local_assembler.doAlphaVolumePostSkeleton(); }
90 return local_assembler;
94 const typename LocalAssembler::Traits::TrialGridFunctionSpaceConstraints&
trialConstraints()
const
100 const typename LocalAssembler::Traits::TestGridFunctionSpaceConstraints&
testConstraints()
const
110 DUNE_THROW(
Dune::Exception,
"In the linear case the jacobian apply does not depend on the current solution and this method should never be called.");
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)
138 global_solution_view_inside.bind(lfsu_cache);
139 global_update_view_inside.bind(lfsu_cache);
142 template<
typename EG,
typename LFSVC>
143 void onBindLFSV(
const EG & eg,
const LFSVC & lfsv_cache)
145 global_result_view_inside.bind(lfsv_cache);
148 template<
typename IG,
typename LFSUC,
typename LFSVC>
149 void onBindLFSUVInside(
const IG & ig,
const LFSUC & lfsu_cache,
const LFSVC & lfsv_cache)
152 global_solution_view_inside.bind(lfsu_cache);
153 global_update_view_inside.bind(lfsu_cache);
156 template<
typename IG,
typename LFSUC,
typename LFSVC>
157 void onBindLFSUVOutside(
const IG & ig,
158 const LFSUC & lfsu_s_cache,
const LFSVC & lfsv_s_cache,
159 const LFSUC & lfsu_n_cache,
const LFSVC & lfsv_n_cache)
162 global_solution_view_outside.bind(lfsu_n_cache);
163 global_update_view_outside.bind(lfsu_n_cache);
166 template<
typename IG,
typename LFSVC>
167 void onBindLFSVInside(
const IG & ig,
const LFSVC & lfsv_cache)
169 global_result_view_inside.bind(lfsv_cache);
172 template<
typename IG,
typename LFSVC>
173 void onBindLFSVOutside(
const IG & ig,
174 const LFSVC & lfsv_s_cache,
175 const LFSVC & lfsv_n_cache)
177 global_result_view_outside.bind(lfsv_n_cache);
185 template<
typename EG,
typename LFSVC>
188 global_result_view_inside.commit();
189 global_result_view_inside.unbind();
192 template<
typename IG,
typename LFSVC>
193 void onUnbindLFSVInside(
const IG & ig,
const LFSVC & lfsv_cache)
195 global_result_view_inside.commit();
196 global_result_view_inside.unbind();
199 template<
typename IG,
typename LFSVC>
200 void onUnbindLFSVOutside(
const IG & ig,
201 const LFSVC & lfsv_s_cache,
202 const LFSVC & lfsv_n_cache)
204 global_result_view_outside.commit();
205 global_result_view_outside.unbind();
211 template<
typename LFSUC>
215 template<
typename LFSUC>
216 void loadCoefficientsLFSUOutside(
const LFSUC & lfsu_n_cache)
219 template<
typename LFSUC>
220 void loadCoefficientsLFSUCoupling(
const LFSUC & lfsu_c_cache)
231 if(local_assembler.doPostProcessing())
233 global_result_view_inside.container());
247 (LocalAssembler::isNonOverlapping &&
257 template<
typename IG>
263 template<
typename EG,
typename LFSUC,
typename LFSVC>
264 void assembleUVVolume(
const EG & eg,
const LFSUC & lfsu_cache,
const LFSVC & lfsv_cache)
266 global_result_view_inside.setWeight(local_assembler.weight());
267 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doAlphaVolume>::
268 jacobian_apply_volume(lop,eg,lfsu_cache.localFunctionSpace(),global_solution_view_inside,global_update_view_inside,lfsv_cache.localFunctionSpace(),global_result_view_inside);
271 template<
typename IG,
typename LFSUC,
typename LFSVC>
272 void assembleUVSkeleton(
const IG & ig,
const LFSUC & lfsu_s_cache,
const LFSVC & lfsv_s_cache,
273 const LFSUC & lfsu_n_cache,
const LFSVC & lfsv_n_cache)
275 global_result_view_inside.setWeight(local_assembler.weight());
276 global_result_view_outside.setWeight(local_assembler.weight());
277 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doAlphaSkeleton>::
278 jacobian_apply_skeleton(lop,ig,
279 lfsu_s_cache.localFunctionSpace(),global_solution_view_inside,global_update_view_inside,lfsv_s_cache.localFunctionSpace(),
280 lfsu_n_cache.localFunctionSpace(),global_solution_view_outside,global_update_view_outside,lfsv_n_cache.localFunctionSpace(),
281 global_result_view_inside,global_result_view_outside);
284 template<
typename IG,
typename LFSUC,
typename LFSVC>
285 void assembleUVBoundary(
const IG & ig,
const LFSUC & lfsu_s_cache,
const LFSVC & lfsv_s_cache)
287 global_result_view_inside.setWeight(local_assembler.weight());
288 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doAlphaBoundary>::
289 jacobian_apply_boundary(lop,ig,lfsu_s_cache.localFunctionSpace(),global_solution_view_inside,global_update_view_inside,lfsv_s_cache.localFunctionSpace(),global_result_view_inside);
292 template<
typename IG,
typename LFSUC,
typename LFSVC>
293 static void assembleUVEnrichedCoupling(
const IG & ig,
294 const LFSUC & lfsu_s_cache,
const LFSVC & lfsv_s_cache,
295 const LFSUC & lfsu_n_cache,
const LFSVC & lfsv_n_cache,
296 const LFSUC & lfsu_coupling_cache,
const LFSVC & lfsv_coupling_cache)
301 template<
typename EG,
typename LFSUC,
typename LFSVC>
302 void assembleUVVolumePostSkeleton(
const EG & eg,
const LFSUC & lfsu_cache,
const LFSVC & lfsv_cache)
304 global_result_view_inside.setWeight(local_assembler.weight());
305 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doAlphaVolumePostSkeleton>::
306 jacobian_apply_volume_post_skeleton(lop,eg,lfsu_cache.localFunctionSpace(),global_solution_view_inside,global_update_view_inside,lfsv_cache.localFunctionSpace(),global_result_view_inside);
320 DomainView global_solution_view_inside;
321 DomainView global_solution_view_outside;
324 DomainView global_update_view_inside;
325 DomainView global_update_view_outside;
328 RangeView global_result_view_inside;
329 RangeView global_result_view_outside;
Base class for Dune-Exceptions.
Definition: exceptions.hh:94
Default exception for dummy implementations.
Definition: exceptions.hh:261
The fast DG local assembler engine for DUNE grids which assembles the local application of the Jacobi...
Definition: jacobianapplyengine.hh:23
LA LocalAssembler
The type of the wrapping local assembler.
Definition: jacobianapplyengine.hh:33
bool skipEntity(const EG &eg)
Definition: jacobianapplyengine.hh:244
void onBindLFSUV(const EG &eg, const LFSUC &lfsu_cache, const LFSVC &lfsv_cache)
Definition: jacobianapplyengine.hh:135
LA::LocalOperator LOP
The type of the local operator.
Definition: jacobianapplyengine.hh:36
LA::LFSU LFSU
The local function spaces.
Definition: jacobianapplyengine.hh:50
void loadCoefficientsLFSUInside(const LFSUC &lfsu_s_cache)
Definition: jacobianapplyengine.hh:212
void setResult(Range &result_)
Definition: jacobianapplyengine.hh:125
bool skipIntersection(const IG &ig)
Definition: jacobianapplyengine.hh:258
void postAssembly(const GFSU &gfsu, const GFSV &gfsv)
Definition: jacobianapplyengine.hh:229
LA::Traits::Range Range
The type of the result vector.
Definition: jacobianapplyengine.hh:42
static constexpr bool isLinear
Wheter the local operator is linear.
Definition: jacobianapplyengine.hh:39
LA::Traits::Domain Domain
The type of the solution vector.
Definition: jacobianapplyengine.hh:46
void setSolution(const Domain &solution_)
Definition: jacobianapplyengine.hh:107
const LocalAssembler & localAssembler() const
Public access to the wrapping local assembler.
Definition: jacobianapplyengine.hh:88
FastDGLocalJacobianApplyAssemblerEngine(const LocalAssembler &local_assembler_)
Constructor.
Definition: jacobianapplyengine.hh:66
const LocalAssembler::Traits::TrialGridFunctionSpaceConstraints & trialConstraints() const
Trial space constraints.
Definition: jacobianapplyengine.hh:94
const LocalAssembler::Traits::TestGridFunctionSpaceConstraints & testConstraints() const
Test space constraints.
Definition: jacobianapplyengine.hh:100
bool requireSkeleton() const
Definition: jacobianapplyengine.hh:73
void setUpdate(const Domain &update_)
Definition: jacobianapplyengine.hh:117
void onUnbindLFSV(const EG &eg, const LFSVC &lfsv_cache)
Definition: jacobianapplyengine.hh:186
Base class for LocalAssemblerEngine implementations to avoid boilerplate code.
Definition: localassemblerenginebase.hh:22
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
void constrain_residual(const CG &cg, XG &xg)
transform residual into transformed basis: r -> r~
Definition: constraints.hh:904
Dune namespace.
Definition: alignedallocator.hh:11
Definition: localfunctionspacetags.hh:54
Definition: localfunctionspacetags.hh:48