1#ifndef DUNE_PDELAB_GRIDOPERATOR_DEFAULT_PATTERNENGINE_HH
2#define DUNE_PDELAB_GRIDOPERATOR_DEFAULT_PATTERNENGINE_HH
5#include <dune/pdelab/gridoperator/common/localmatrix.hh>
6#include <dune/pdelab/gridoperator/common/assemblerutilities.hh>
7#include <dune/pdelab/gridoperator/common/localassemblerenginebase.hh>
8#include <dune/pdelab/constraints/common/constraints.hh>
9#include <dune/pdelab/localoperator/callswitch.hh>
27 template<
typename TrialConstra
intsContainer,
typename TestConstra
intsContainer>
28 bool needsConstraintsCaching(
const TrialConstraintsContainer& cu,
const TestConstraintsContainer& cv)
const
30 return cu.containsNonDirichletConstraints() || cv.containsNonDirichletConstraints();
37 typedef typename LA::LocalOperator
LOP;
40 typedef typename LA::LFSU
LFSU;
41 typedef typename LA::LFSUCache LFSUCache;
42 typedef typename LFSU::Traits::GridFunctionSpace GFSU;
43 typedef typename LA::LFSV LFSV;
44 typedef typename LA::LFSVCache LFSVCache;
45 typedef typename LFSV::Traits::GridFunctionSpace GFSV;
49 typedef typename BorderDOFExchanger::BorderPattern BorderPattern;
52 typedef typename LA::Traits::MatrixPattern
Pattern;
56 typedef std::size_t size_type;
65 std::shared_ptr<typename LA::Traits::BorderDOFExchanger> border_dof_exchanger)
66 : local_assembler(local_assembler_)
67 , lop(local_assembler.localOperator())
69 , _border_dof_exchanger(border_dof_exchanger)
75 return local_assembler;
79 const typename LocalAssembler::Traits::TrialGridFunctionSpaceConstraints&
trialConstraints()
const
85 const typename LocalAssembler::Traits::TestGridFunctionSpaceConstraints&
testConstraints()
const
102 return local_assembler.doPatternSkeleton();
105 bool requireUVVolume()
const
107 return local_assembler.doPatternVolume();
110 bool requireUVSkeleton()
const
112 return local_assembler.doPatternSkeleton();
115 bool requireUVBoundary()
const
117 return local_assembler.doPatternBoundary();
120 bool requireUVVolumePostSkeleton()
const
122 return local_assembler.doPatternVolumePostSkeleton();
129 template<
typename LFSVC,
typename LFSUC>
130 void add_border_pattern(std::true_type,
const LFSVC& lfsv_cache,
const LFSUC& lfsu_cache,
131 const LocalPattern& p)
133 if (local_assembler.reconstructBorderEntries() &&
134 !communicationCache().initialized())
136 communicationCache().addEntries(lfsv_cache,lfsu_cache,p);
140 template<
typename LFSVC,
typename LFSUC>
141 void add_border_pattern(std::false_type,
const LFSVC& lfsv_cache,
const LFSUC& lfsu_cache,
142 const LocalPattern& p)
145 template<
typename LFSVC,
typename LFSUC>
146 void add_pattern(
const LFSVC& lfsv_cache,
const LFSUC& lfsu_cache,
const LocalPattern& p)
148 for (size_type k=0; k<p.size(); ++k)
149 local_assembler.add_entry(*pattern,
154 add_border_pattern(std::integral_constant<bool,LocalAssembler::isNonOverlapping>(),
167 template<
typename EG>
179 template<
typename IG>
188 template<
typename EG,
typename LFSUC,
typename LFSVC>
189 void onUnbindLFSUV(
const EG & eg,
const LFSUC & lfsu_cache,
const LFSVC & lfsv_cache)
191 add_pattern(lfsv_cache,lfsu_cache,localpattern);
192 localpattern.clear();
195 template<
typename IG,
typename LFSUC,
typename LFSVC>
196 void onUnbindLFSUVOutside(
const IG& ig,
197 const LFSUC& lfsu_s_cache,
const LFSVC& lfsv_s_cache,
198 const LFSUC& lfsu_n_cache,
const LFSVC& lfsv_n_cache)
200 add_pattern(lfsv_s_cache,lfsu_n_cache,localpattern_sn);
201 localpattern_sn.clear();
202 add_pattern(lfsv_n_cache,lfsu_s_cache,localpattern_ns);
203 localpattern_ns.clear();
211 template<
typename EG,
typename LFSUC,
typename LFSVC>
214 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doPatternVolume>::
215 pattern_volume(lop,lfsu_cache.localFunctionSpace(),lfsv_cache.localFunctionSpace(),localpattern);
218 template<
typename IG,
typename LFSUC,
typename LFSVC>
219 void assembleUVSkeleton(
const IG & ig,
const LFSUC & lfsu_s_cache,
const LFSVC & lfsv_s_cache,
220 const LFSUC & lfsu_n_cache,
const LFSVC & lfsv_n_cache)
222 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doPatternSkeleton>::
223 pattern_skeleton(lop,
224 lfsu_s_cache.localFunctionSpace(),lfsv_s_cache.localFunctionSpace(),
225 lfsu_n_cache.localFunctionSpace(),lfsv_n_cache.localFunctionSpace(),
226 localpattern_sn, localpattern_ns);
229 template<
typename IG,
typename LFSUC,
typename LFSVC>
230 void assembleUVBoundary(
const IG & ig,
const LFSUC & lfsu_s_cache,
const LFSVC & lfsv_s_cache)
232 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doPatternBoundary>::
233 pattern_boundary(lop,lfsu_s_cache.localFunctionSpace(),lfsv_s_cache.localFunctionSpace(),localpattern);
236 template<
typename IG,
typename LFSUC,
typename LFSVC>
237 static void assembleUVEnrichedCoupling(
const IG & ig,
238 const LFSUC & lfsu_s_cache,
const LFSVC & lfsv_s_cache,
239 const LFSUC & lfsu_n_cache,
const LFSVC & lfsv_n_cache,
240 const LFSUC & lfsu_coupling_cache,
const LFSVC & lfsv_coupling_cache)
245 template<
typename IG,
typename LFSVC>
246 static void assembleVEnrichedCoupling(
const IG & ig,
247 const LFSVC & lfsv_s_cache,
248 const LFSVC & lfsv_n_cache,
249 const LFSVC & lfsv_coupling_cache)
254 template<
typename EG,
typename LFSUC,
typename LFSVC>
255 void assembleUVVolumePostSkeleton(
const EG & eg,
const LFSUC & lfsu_cache,
const LFSVC & lfsv_cache)
257 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doPatternVolumePostSkeleton>::
258 pattern_volume_post_skeleton(lop,lfsu_cache.localFunctionSpace(),lfsv_cache.localFunctionSpace(),localpattern);
262 void postAssembly(
const GFSU& gfsu,
const GFSV& gfsv)
264 post_border_pattern_assembly(std::integral_constant<bool,LocalAssembler::isNonOverlapping>(),
269 void post_border_pattern_assembly(std::true_type,
const GFSU& gfsu,
const GFSV& gfsv)
271 if(local_assembler.doPostProcessing() and
272 local_assembler.reconstructBorderEntries())
274 communicationCache().finishInitialization();
276 typename LA::Traits::BorderDOFExchanger::template PatternExtender<Pattern>
277 data_handle(*_border_dof_exchanger,gfsu,gfsv,*pattern);
278 gfsv.gridView().communicate(data_handle,
284 void post_border_pattern_assembly(std::false_type,
const GFSU& gfsu,
const GFSV& gfsv)
292 typename LA::Traits::BorderDOFExchanger::CommunicationCache&
295 return _border_dof_exchanger->communicationCache();
298 const typename LA::Traits::BorderDOFExchanger::CommunicationCache&
299 communicationCache()
const
301 return _border_dof_exchanger->communicationCache();
314 LocalPattern localpattern;
315 LocalPattern localpattern_sn, localpattern_ns;
317 BorderPattern _border_pattern;
319 std::shared_ptr<BorderDOFExchanger> _border_dof_exchanger;
Default exception for dummy implementations.
Definition: exceptions.hh:263
The local assembler engine for DUNE grids which creates the matrix pattern.
Definition: patternengine.hh:24
LA::Traits::MatrixPattern Pattern
The type of the solution vector.
Definition: patternengine.hh:52
bool skipEntity(const EG &eg)
Definition: patternengine.hh:168
DefaultLocalPatternAssemblerEngine(const LocalAssembler &local_assembler_, std::shared_ptr< typename LA::Traits::BorderDOFExchanger > border_dof_exchanger)
Constructor.
Definition: patternengine.hh:64
LA::LocalOperator LOP
The type of the local operator.
Definition: patternengine.hh:37
LA LocalAssembler
The type of the wrapping local assembler.
Definition: patternengine.hh:34
bool requireSkeleton() const
Definition: patternengine.hh:100
const LocalAssembler & localAssembler() const
Public access to the wrapping local assembler.
Definition: patternengine.hh:73
void setPattern(Pattern &pattern_)
Definition: patternengine.hh:92
bool skipIntersection(const IG &ig)
Definition: patternengine.hh:180
void onUnbindLFSUV(const EG &eg, const LFSUC &lfsu_cache, const LFSVC &lfsv_cache)
Definition: patternengine.hh:189
LA::LFSU LFSU
The local function spaces.
Definition: patternengine.hh:40
const LocalAssembler::Traits::TestGridFunctionSpaceConstraints & testConstraints() const
Test space constraints.
Definition: patternengine.hh:85
const LocalAssembler::Traits::TrialGridFunctionSpaceConstraints & trialConstraints() const
Trial space constraints.
Definition: patternengine.hh:79
LA::Traits::BorderDOFExchanger BorderDOFExchanger
helper classes
Definition: patternengine.hh:48
void assembleUVVolume(const EG &eg, const LFSUC &lfsu_cache, const LFSVC &lfsv_cache)
Definition: patternengine.hh:212
Base class for LocalAssemblerEngine implementations to avoid boilerplate code.
Definition: localassemblerenginebase.hh:22
Layout description for a sparse linear operator.
Definition: assemblerutilities.hh:165
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
Dune namespace.
Definition: alignedallocator.hh:13