DUNE PDELab (git)

patternengine.hh
1#ifndef DUNE_PDELAB_GRIDOPERATOR_FASTDG_PATTERNENGINE_HH
2#define DUNE_PDELAB_GRIDOPERATOR_FASTDG_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
125 auto partition() const
126 {
127 return Partitions::all;
128 }
129
131
133
134 template<typename LFSVC, typename LFSUC>
135 void add_border_pattern(std::true_type, const LFSVC& lfsv_cache, const LFSUC& lfsu_cache,
136 const LocalPattern& p)
137 {
138 if (local_assembler.reconstructBorderEntries() &&
139 !communicationCache().initialized())
140 {
141 communicationCache().addEntries(lfsv_cache,lfsu_cache,p);
142 }
143 }
144
145 template<typename LFSVC, typename LFSUC>
146 void add_border_pattern(std::false_type, const LFSVC& lfsv_cache, const LFSUC& lfsu_cache,
147 const LocalPattern& p)
148 {}
149
150 template<typename LFSVC, typename LFSUC>
151 void add_pattern(const LFSVC& lfsv_cache, const LFSUC& lfsu_cache, const LocalPattern& p)
152 {
153 if (p.size() > 0)
154 {
155 local_assembler.add_entry(*pattern,
156 lfsv_cache,p[0].i(),
157 lfsu_cache,p[0].j()
158 );
159
160 }
161
162 add_border_pattern(std::integral_constant<bool,LocalAssembler::isNonOverlapping>(),
163 lfsv_cache,
164 lfsu_cache,
165 p);
166 }
167
174 template<typename EG>
175 bool skipEntity(const EG & eg)
176 {
177 return localAssembler().skipEntity(eg);
178 }
179
186 template<typename IG>
187 bool skipIntersection(const IG & ig)
188 {
189 return localAssembler().skipIntersection(ig);
190 }
191
195 template<typename EG, typename LFSUC, typename LFSVC>
196 void onUnbindLFSUV(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
197 {
198 add_pattern(lfsv_cache,lfsu_cache,localpattern);
199 localpattern.clear();
200 }
201
202 template<typename IG, typename LFSUC, typename LFSVC>
203 void onUnbindLFSUVOutside(const IG& ig,
204 const LFSUC& lfsu_s_cache, const LFSVC& lfsv_s_cache,
205 const LFSUC& lfsu_n_cache, const LFSVC& lfsv_n_cache)
206 {
207 add_pattern(lfsv_s_cache,lfsu_n_cache,localpattern_sn);
208 localpattern_sn.clear();
209 add_pattern(lfsv_n_cache,lfsu_s_cache,localpattern_ns);
210 localpattern_ns.clear();
211 }
212
214
217
218 template<typename EG, typename LFSUC, typename LFSVC>
219 void assembleUVVolume(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
220 {
221 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doPatternVolume>::
222 pattern_volume(lop,lfsu_cache.localFunctionSpace(),lfsv_cache.localFunctionSpace(),localpattern);
223 }
224
225 template<typename IG, typename LFSUC, typename LFSVC>
226 void assembleUVSkeleton(const IG & ig, const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache,
227 const LFSUC & lfsu_n_cache, const LFSVC & lfsv_n_cache)
228 {
229 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doPatternSkeleton>::
230 pattern_skeleton(lop,
231 lfsu_s_cache.localFunctionSpace(),lfsv_s_cache.localFunctionSpace(),
232 lfsu_n_cache.localFunctionSpace(),lfsv_n_cache.localFunctionSpace(),
233 localpattern_sn, localpattern_ns);
234 }
235
236 template<typename IG, typename LFSUC, typename LFSVC>
237 void assembleUVBoundary(const IG & ig, const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache)
238 {
239 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doPatternBoundary>::
240 pattern_boundary(lop,lfsu_s_cache.localFunctionSpace(),lfsv_s_cache.localFunctionSpace(),localpattern);
241 }
242
243 template<typename IG, typename LFSUC, typename LFSVC>
244 static void assembleUVEnrichedCoupling(const IG & ig,
245 const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache,
246 const LFSUC & lfsu_n_cache, const LFSVC & lfsv_n_cache,
247 const LFSUC & lfsu_coupling_cache, const LFSVC & lfsv_coupling_cache)
248 {
249 DUNE_THROW(Dune::NotImplemented,"Assembling of coupling spaces is not implemented for ");
250 }
251
252 template<typename IG, typename LFSVC>
253 static void assembleVEnrichedCoupling(const IG & ig,
254 const LFSVC & lfsv_s_cache,
255 const LFSVC & lfsv_n_cache,
256 const LFSVC & lfsv_coupling_cache)
257 {
258 DUNE_THROW(Dune::NotImplemented,"Assembling of coupling spaces is not implemented for ");
259 }
260
261 template<typename EG, typename LFSUC, typename LFSVC>
262 void assembleUVVolumePostSkeleton(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
263 {
264 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doPatternVolumePostSkeleton>::
265 pattern_volume_post_skeleton(lop,lfsu_cache.localFunctionSpace(),lfsv_cache.localFunctionSpace(),localpattern);
266 }
267
268
269 void postAssembly(const GFSU& gfsu, const GFSV& gfsv){
270 post_border_pattern_assembly(std::integral_constant<bool,LocalAssembler::isNonOverlapping>(),
271 gfsu,
272 gfsv);
273 }
274
275 void post_border_pattern_assembly(std::true_type, const GFSU& gfsu, const GFSV& gfsv)
276 {
277 if(local_assembler.doPostProcessing() &&
278 local_assembler.reconstructBorderEntries())
279 {
280 communicationCache().finishInitialization();
281
282 typename LA::Traits::BorderDOFExchanger::template PatternExtender<Pattern>
283 data_handle(*_border_dof_exchanger,gfsu,gfsv,*pattern);
284 gfsv.gridView().communicate(data_handle,
287 }
288 }
289
290 void post_border_pattern_assembly(std::false_type, const GFSU& gfsu, const GFSV& gfsv)
291 {}
292
294
295
296 private:
297
298 typename LA::Traits::BorderDOFExchanger::CommunicationCache&
299 communicationCache()
300 {
301 return _border_dof_exchanger->communicationCache();
302 }
303
304 const typename LA::Traits::BorderDOFExchanger::CommunicationCache&
305 communicationCache() const
306 {
307 return _border_dof_exchanger->communicationCache();
308 }
309
311 const LocalAssembler & local_assembler;
312
314 const LOP & lop;
315
317 Pattern * pattern;
318
320 LocalPattern localpattern;
321 LocalPattern localpattern_sn, localpattern_ns;
322
323 BorderPattern _border_pattern;
324
325 std::shared_ptr<BorderDOFExchanger> _border_dof_exchanger;
326
327 }; // End of class FastDGLocalPatternAssemblerEngine
328
329 }
330}
331#endif
Default exception for dummy implementations.
Definition: exceptions.hh:263
The fast DG local assembler engine for DUNE grids which creates the matrix pattern.
Definition: patternengine.hh:24
void setPattern(Pattern &pattern_)
Definition: patternengine.hh:92
void assembleUVVolume(const EG &eg, const LFSUC &lfsu_cache, const LFSVC &lfsv_cache)
Definition: patternengine.hh:219
LA::LFSU LFSU
The local function spaces.
Definition: patternengine.hh:40
LA::Traits::MatrixPattern Pattern
The type of the solution vector.
Definition: patternengine.hh:52
LA::Traits::BorderDOFExchanger BorderDOFExchanger
helper classes
Definition: patternengine.hh:48
LA::LocalOperator LOP
The type of the local operator.
Definition: patternengine.hh:37
void onUnbindLFSUV(const EG &eg, const LFSUC &lfsu_cache, const LFSVC &lfsv_cache)
Definition: patternengine.hh:196
bool skipIntersection(const IG &ig)
Definition: patternengine.hh:187
FastDGLocalPatternAssemblerEngine(const LocalAssembler &local_assembler_, std::shared_ptr< typename LA::Traits::BorderDOFExchanger > border_dof_exchanger)
Constructor.
Definition: patternengine.hh:64
bool requireSkeleton() const
Definition: patternengine.hh:100
const LocalAssembler::Traits::TrialGridFunctionSpaceConstraints & trialConstraints() const
Trial space constraints.
Definition: patternengine.hh:79
LA LocalAssembler
The type of the wrapping local assembler.
Definition: patternengine.hh:34
const LocalAssembler & localAssembler() const
Public access to the wrapping local assembler.
Definition: patternengine.hh:73
bool skipEntity(const EG &eg)
Definition: patternengine.hh:175
const LocalAssembler::Traits::TestGridFunctionSpaceConstraints & testConstraints() const
Test space constraints.
Definition: patternengine.hh:85
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
constexpr All all
PartitionSet for all partitions.
Definition: partitionset.hh:295
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)