DUNE PDELab (git)

patternengine.hh
1#ifndef DUNE_PDELAB_GRIDOPERATOR_DEFAULT_PATTERNENGINE_HH
2#define DUNE_PDELAB_GRIDOPERATOR_DEFAULT_PATTERNENGINE_HH
3
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>
10
11namespace Dune{
12 namespace PDELab{
13
21 template<typename LA>
24 {
25 public:
26
27 template<typename TrialConstraintsContainer, typename TestConstraintsContainer>
28 bool needsConstraintsCaching(const TrialConstraintsContainer& cu, const TestConstraintsContainer& cv) const
29 {
30 return cu.containsNonDirichletConstraints() || cv.containsNonDirichletConstraints();
31 }
32
34 typedef LA LocalAssembler;
35
37 typedef typename LA::LocalOperator LOP;
38
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;
46
48 typedef typename LA::Traits::BorderDOFExchanger BorderDOFExchanger;
49 typedef typename BorderDOFExchanger::BorderPattern BorderPattern;
50
52 typedef typename LA::Traits::MatrixPattern Pattern;
53
55
56 typedef std::size_t size_type;
57
65 std::shared_ptr<typename LA::Traits::BorderDOFExchanger> border_dof_exchanger)
66 : local_assembler(local_assembler_)
67 , lop(local_assembler.localOperator())
68 , pattern(nullptr)
69 , _border_dof_exchanger(border_dof_exchanger)
70 {}
71
74 {
75 return local_assembler;
76 }
77
79 const typename LocalAssembler::Traits::TrialGridFunctionSpaceConstraints& trialConstraints() const
80 {
81 return localAssembler().trialConstraints();
82 }
83
85 const typename LocalAssembler::Traits::TestGridFunctionSpaceConstraints& testConstraints() const
86 {
87 return localAssembler().testConstraints();
88 }
89
92 void setPattern(Pattern & pattern_)
93 {
94 pattern = &pattern_;
95 }
96
99
100 bool requireSkeleton() const
101 {
102 return local_assembler.doPatternSkeleton();
103 }
104
105 bool requireUVVolume() const
106 {
107 return local_assembler.doPatternVolume();
108 }
109
110 bool requireUVSkeleton() const
111 {
112 return local_assembler.doPatternSkeleton();
113 }
114
115 bool requireUVBoundary() const
116 {
117 return local_assembler.doPatternBoundary();
118 }
119
120 bool requireUVVolumePostSkeleton() const
121 {
122 return local_assembler.doPatternVolumePostSkeleton();
123 }
124
126
128
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)
132 {
133 if (local_assembler.reconstructBorderEntries() &&
134 !communicationCache().initialized())
135 {
136 communicationCache().addEntries(lfsv_cache,lfsu_cache,p);
137 }
138 }
139
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)
143 {}
144
145 template<typename LFSVC, typename LFSUC>
146 void add_pattern(const LFSVC& lfsv_cache, const LFSUC& lfsu_cache, const LocalPattern& p)
147 {
148 for (size_type k=0; k<p.size(); ++k)
149 local_assembler.add_entry(*pattern,
150 lfsv_cache,p[k].i(),
151 lfsu_cache,p[k].j()
152 );
153
154 add_border_pattern(std::integral_constant<bool,LocalAssembler::isNonOverlapping>(),
155 lfsv_cache,
156 lfsu_cache,
157 p);
158 }
159
160
167 template<typename EG>
168 bool skipEntity(const EG & eg)
169 {
170 return localAssembler().skipEntity(eg);
171 }
172
179 template<typename IG>
180 bool skipIntersection(const IG & ig)
181 {
182 return localAssembler().skipIntersection(ig);
183 }
184
188 template<typename EG, typename LFSUC, typename LFSVC>
189 void onUnbindLFSUV(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
190 {
191 add_pattern(lfsv_cache,lfsu_cache,localpattern);
192 localpattern.clear();
193 }
194
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)
199 {
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();
204 }
205
207
210
211 template<typename EG, typename LFSUC, typename LFSVC>
212 void assembleUVVolume(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
213 {
214 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doPatternVolume>::
215 pattern_volume(lop,lfsu_cache.localFunctionSpace(),lfsv_cache.localFunctionSpace(),localpattern);
216 }
217
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)
221 {
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);
227 }
228
229 template<typename IG, typename LFSUC, typename LFSVC>
230 void assembleUVBoundary(const IG & ig, const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache)
231 {
232 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doPatternBoundary>::
233 pattern_boundary(lop,lfsu_s_cache.localFunctionSpace(),lfsv_s_cache.localFunctionSpace(),localpattern);
234 }
235
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)
241 {
242 DUNE_THROW(Dune::NotImplemented,"Assembling of coupling spaces is not implemented for ");
243 }
244
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)
250 {
251 DUNE_THROW(Dune::NotImplemented,"Assembling of coupling spaces is not implemented for ");
252 }
253
254 template<typename EG, typename LFSUC, typename LFSVC>
255 void assembleUVVolumePostSkeleton(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
256 {
257 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doPatternVolumePostSkeleton>::
258 pattern_volume_post_skeleton(lop,lfsu_cache.localFunctionSpace(),lfsv_cache.localFunctionSpace(),localpattern);
259 }
260
261
262 void postAssembly(const GFSU& gfsu, const GFSV& gfsv)
263 {
264 post_border_pattern_assembly(std::integral_constant<bool,LocalAssembler::isNonOverlapping>(),
265 gfsu,
266 gfsv);
267 }
268
269 void post_border_pattern_assembly(std::true_type, const GFSU& gfsu, const GFSV& gfsv)
270 {
271 if(local_assembler.doPostProcessing() and
272 local_assembler.reconstructBorderEntries())
273 {
274 communicationCache().finishInitialization();
275
276 typename LA::Traits::BorderDOFExchanger::template PatternExtender<Pattern>
277 data_handle(*_border_dof_exchanger,gfsu,gfsv,*pattern);
278 gfsv.gridView().communicate(data_handle,
281 }
282 }
283
284 void post_border_pattern_assembly(std::false_type, const GFSU& gfsu, const GFSV& gfsv)
285 {}
286
288
289
290 private:
291
292 typename LA::Traits::BorderDOFExchanger::CommunicationCache&
293 communicationCache()
294 {
295 return _border_dof_exchanger->communicationCache();
296 }
297
298 const typename LA::Traits::BorderDOFExchanger::CommunicationCache&
299 communicationCache() const
300 {
301 return _border_dof_exchanger->communicationCache();
302 }
303
305 const LocalAssembler & local_assembler;
306
308 const LOP & lop;
309
311 Pattern * pattern;
312
314 LocalPattern localpattern;
315 LocalPattern localpattern_sn, localpattern_ns;
316
317 BorderPattern _border_pattern;
318
319 std::shared_ptr<BorderDOFExchanger> _border_dof_exchanger;
320
321 }; // End of class DefaultLocalPatternAssemblerEngine
322
323 }
324}
325#endif // DUNE_PDELAB_GRIDOPERATOR_DEFAULT_PATTERNENGINE_HH
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
@ ForwardCommunication
communicate as given in InterfaceType
Definition: gridenums.hh:171
@ InteriorBorder_InteriorBorder_Interface
send/receive interior and border entities
Definition: gridenums.hh:87
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)