DUNE PDELab (2.7)

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
164 template<typename EG, typename LFSUC, typename LFSVC>
165 void onUnbindLFSUV(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
166 {
167 add_pattern(lfsv_cache,lfsu_cache,localpattern);
168 localpattern.clear();
169 }
170
171 template<typename IG, typename LFSUC, typename LFSVC>
172 void onUnbindLFSUVOutside(const IG& ig,
173 const LFSUC& lfsu_s_cache, const LFSVC& lfsv_s_cache,
174 const LFSUC& lfsu_n_cache, const LFSVC& lfsv_n_cache)
175 {
176 add_pattern(lfsv_s_cache,lfsu_n_cache,localpattern_sn);
177 localpattern_sn.clear();
178 add_pattern(lfsv_n_cache,lfsu_s_cache,localpattern_ns);
179 localpattern_ns.clear();
180 }
181
183
186
187 template<typename EG, typename LFSUC, typename LFSVC>
188 void assembleUVVolume(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
189 {
190 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doPatternVolume>::
191 pattern_volume(lop,lfsu_cache.localFunctionSpace(),lfsv_cache.localFunctionSpace(),localpattern);
192 }
193
194 template<typename IG, typename LFSUC, typename LFSVC>
195 void assembleUVSkeleton(const IG & ig, const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache,
196 const LFSUC & lfsu_n_cache, const LFSVC & lfsv_n_cache)
197 {
198 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doPatternSkeleton>::
199 pattern_skeleton(lop,
200 lfsu_s_cache.localFunctionSpace(),lfsv_s_cache.localFunctionSpace(),
201 lfsu_n_cache.localFunctionSpace(),lfsv_n_cache.localFunctionSpace(),
202 localpattern_sn, localpattern_ns);
203 }
204
205 template<typename IG, typename LFSUC, typename LFSVC>
206 void assembleUVBoundary(const IG & ig, const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache)
207 {
208 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doPatternBoundary>::
209 pattern_boundary(lop,lfsu_s_cache.localFunctionSpace(),lfsv_s_cache.localFunctionSpace(),localpattern);
210 }
211
212 template<typename IG, typename LFSUC, typename LFSVC>
213 static void assembleUVEnrichedCoupling(const IG & ig,
214 const LFSUC & lfsu_s_cache, const LFSVC & lfsv_s_cache,
215 const LFSUC & lfsu_n_cache, const LFSVC & lfsv_n_cache,
216 const LFSUC & lfsu_coupling_cache, const LFSVC & lfsv_coupling_cache)
217 {
218 DUNE_THROW(Dune::NotImplemented,"Assembling of coupling spaces is not implemented for ");
219 }
220
221 template<typename IG, typename LFSVC>
222 static void assembleVEnrichedCoupling(const IG & ig,
223 const LFSVC & lfsv_s_cache,
224 const LFSVC & lfsv_n_cache,
225 const LFSVC & lfsv_coupling_cache)
226 {
227 DUNE_THROW(Dune::NotImplemented,"Assembling of coupling spaces is not implemented for ");
228 }
229
230 template<typename EG, typename LFSUC, typename LFSVC>
231 void assembleUVVolumePostSkeleton(const EG & eg, const LFSUC & lfsu_cache, const LFSVC & lfsv_cache)
232 {
233 Dune::PDELab::LocalAssemblerCallSwitch<LOP,LOP::doPatternVolumePostSkeleton>::
234 pattern_volume_post_skeleton(lop,lfsu_cache.localFunctionSpace(),lfsv_cache.localFunctionSpace(),localpattern);
235 }
236
237
238 void postAssembly(const GFSU& gfsu, const GFSV& gfsv)
239 {
240 post_border_pattern_assembly(std::integral_constant<bool,LocalAssembler::isNonOverlapping>(),
241 gfsu,
242 gfsv);
243 }
244
245 void post_border_pattern_assembly(std::true_type, const GFSU& gfsu, const GFSV& gfsv)
246 {
247 if(local_assembler.doPostProcessing() and
248 local_assembler.reconstructBorderEntries())
249 {
250 communicationCache().finishInitialization();
251
252 typename LA::Traits::BorderDOFExchanger::template PatternExtender<Pattern>
253 data_handle(*_border_dof_exchanger,gfsu,gfsv,*pattern);
254 gfsv.gridView().communicate(data_handle,
257 }
258 }
259
260 void post_border_pattern_assembly(std::false_type, const GFSU& gfsu, const GFSV& gfsv)
261 {}
262
264
265
266 private:
267
268 typename LA::Traits::BorderDOFExchanger::CommunicationCache&
269 communicationCache()
270 {
271 return _border_dof_exchanger->communicationCache();
272 }
273
274 const typename LA::Traits::BorderDOFExchanger::CommunicationCache&
275 communicationCache() const
276 {
277 return _border_dof_exchanger->communicationCache();
278 }
279
281 const LocalAssembler & local_assembler;
282
284 const LOP & lop;
285
287 Pattern * pattern;
288
290 LocalPattern localpattern;
291 LocalPattern localpattern_sn, localpattern_ns;
292
293 BorderPattern _border_pattern;
294
295 std::shared_ptr<BorderDOFExchanger> _border_dof_exchanger;
296
297 }; // End of class DefaultLocalPatternAssemblerEngine
298
299 }
300}
301#endif // DUNE_PDELAB_GRIDOPERATOR_DEFAULT_PATTERNENGINE_HH
Default exception for dummy implementations.
Definition: exceptions.hh:261
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
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
void onUnbindLFSUV(const EG &eg, const LFSUC &lfsu_cache, const LFSVC &lfsv_cache)
Definition: patternengine.hh:165
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:188
Base class for LocalAssemblerEngine implementations to avoid boilerplate code.
Definition: localassemblerenginebase.hh:22
Layout description for a sparse linear operator.
Definition: assemblerutilities.hh:137
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
@ ForwardCommunication
communicate as given in InterfaceType
Definition: gridenums.hh:169
@ InteriorBorder_InteriorBorder_Interface
send/receive interior and border entities
Definition: gridenums.hh:85
Dune namespace.
Definition: alignedallocator.hh:14
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)