DUNE PDELab (git)

localassembler.hh
1// -*- tab-width: 2; indent-tabs-mode: nil -*-
2// vi: set et ts=2 sw=2 sts=2:
3#ifndef DUNE_PDELAB_GRIDOPERATOR_FASTDG_LOCALASSEMBLER_HH
4#define DUNE_PDELAB_GRIDOPERATOR_FASTDG_LOCALASSEMBLER_HH
5
6#include <memory>
7
9
10#include <dune/typetree/typetree.hh>
11
12#include <dune/pdelab/gridoperator/fastdg/residualengine.hh>
13#include <dune/pdelab/gridoperator/fastdg/patternengine.hh>
14#include <dune/pdelab/gridoperator/fastdg/jacobianengine.hh>
15#include <dune/pdelab/gridoperator/fastdg/jacobianapplyengine.hh>
16#include <dune/pdelab/gridoperator/common/assemblerutilities.hh>
17#include <dune/pdelab/gridfunctionspace/lfsindexcache.hh>
18
19namespace Dune{
20 namespace PDELab{
21
36 template<typename GO, typename LOP, bool nonoverlapping_mode = false>
38 public Dune::PDELab::LocalAssemblerBase<typename GO::Traits::MatrixBackend,
39 typename GO::Traits::TrialGridFunctionSpaceConstraints,
40 typename GO::Traits::TestGridFunctionSpaceConstraints>
41 {
42 public:
43
46
48 typedef typename Traits::Residual::ElementType RangeField;
49 typedef RangeField Real;
50
51 typedef typename Traits::TrialGridFunctionSpace GFSU;
52 typedef typename Traits::TestGridFunctionSpace GFSV;
53
56
59
61 typedef LOP LocalOperator;
62
63 static const bool isNonOverlapping = nonoverlapping_mode;
64
67 // Types of local function spaces
70 typedef LFSIndexCache<LFSU,CU,true> LFSUCache;
71 typedef LFSIndexCache<LFSV,CV,true> LFSVCache;
72
74
81
82 // friend declarations such that engines are able to call scatter_jacobian() and add_entry() from base class
85
87 FastDGLocalAssembler (LOP & lop_, std::shared_ptr<typename GO::BorderDOFExchanger> border_dof_exchanger)
88 : lop(stackobject_to_shared_ptr(lop_)),
89 weight_(1.0),
90 doPreProcessing_(true),
91 doPostProcessing_(true),
92 pattern_engine(*this,border_dof_exchanger), residual_engine(*this), jacobian_engine(*this)
93 , jacobian_apply_engine(*this)
94 , _reconstruct_border_entries(isNonOverlapping)
95 {}
96
98 FastDGLocalAssembler (LOP & lop_, const CU& cu_, const CV& cv_,
99 std::shared_ptr<typename GO::BorderDOFExchanger> border_dof_exchanger)
100 : Base(cu_, cv_),
101 lop(stackobject_to_shared_ptr(lop_)),
102 weight_(1.0),
103 doPreProcessing_(true),
104 doPostProcessing_(true),
105 pattern_engine(*this,border_dof_exchanger), residual_engine(*this), jacobian_engine(*this)
106 , jacobian_apply_engine(*this)
107 , _reconstruct_border_entries(isNonOverlapping)
108 {}
109
112 {
113 return *lop;
114 }
115
117 const LOP &localOperator() const
118 {
119 return *lop;
120 }
121
128 template<class EG>
129 bool skipEntity(const EG & eg) const
130 {
131 static_assert(
132 models<Impl::HasDoSkipEntity, LOP>(),
133 "Your local operator does not provide the 'doSkipEntity' flag. "
134 "If you are porting a previous implementation, set the flag to "
135 "false");
136 return Dune::PDELab::LocalAssemblerCallSwitch<
137 LOP, LOP::doSkipEntity>::skip_entity(*lop, eg);
138 }
139
146 template<class IG>
147 bool skipIntersection(const IG & ig) const
148 {
149 static_assert(models<Impl::HasDoSkipIntersection, LOP>(),
150 "Your local operator does not provide the "
151 "'doSkipIntersection' flag. "
152 "If you are porting a previous implementation, set the "
153 "flag to false");
154 return Dune::PDELab::LocalAssemblerCallSwitch<
155 LOP, LOP::doSkipIntersection>::skip_intersection(*lop, ig);
156 }
157
161 void setTime(Real time_)
162 {
163 lop->setTime(time_);
164 }
165
168 {
169 return weight_;
170 }
171
174 weight_ = weight;
175 }
176
179 void preStage (Real time_, int r_) { lop->preStage(time_,r_); }
180 void preStep (Real time_, Real dt_, std::size_t stages_){ lop->preStep(time_,dt_,stages_); }
181 void postStep (){ lop->postStep(); }
182 void postStage (){ lop->postStage(); }
183 Real suggestTimestep (Real dt) const{return lop->suggestTimestep(dt); }
185
186 bool reconstructBorderEntries() const
187 {
188 return _reconstruct_border_entries;
189 }
190
193
197 (typename Traits::MatrixPattern & p)
198 {
199 pattern_engine.setPattern(p);
200 return pattern_engine;
201 }
202
206 (typename Traits::Residual & r, const typename Traits::Solution & x)
207 {
208 residual_engine.setResidual(r);
209 residual_engine.setSolution(x);
210 return residual_engine;
211 }
212
216 (typename Traits::Jacobian & a, const typename Traits::Solution & x)
217 {
218 jacobian_engine.setJacobian(a);
219 jacobian_engine.setSolution(x);
220 return jacobian_engine;
221 }
222
226 (const typename Traits::Domain & update, typename Traits::Range & result)
227 {
228 jacobian_apply_engine.setUpdate(update);
229 jacobian_apply_engine.setResult(result);
230 return jacobian_apply_engine;
231 }
232
236 (const typename Traits::Domain & solution, const typename Traits::Domain & update, typename Traits::Range & result)
237 {
238 jacobian_apply_engine.setSolution(solution);
239 jacobian_apply_engine.setUpdate(update);
240 jacobian_apply_engine.setResult(result);
241 return jacobian_apply_engine;
242 }
243
245
250 static constexpr bool doAlphaVolume() { return LOP::doAlphaVolume; }
251 static constexpr bool doLambdaVolume() { return LOP::doLambdaVolume; }
252 static constexpr bool doAlphaSkeleton() { return LOP::doAlphaSkeleton; }
253 static constexpr bool doLambdaSkeleton() { return LOP::doLambdaSkeleton; }
254 static constexpr bool doAlphaBoundary() { return LOP::doAlphaBoundary; }
255 static constexpr bool doLambdaBoundary() { return LOP::doLambdaBoundary; }
256 static constexpr bool doAlphaVolumePostSkeleton() { return LOP::doAlphaVolumePostSkeleton; }
257 static constexpr bool doLambdaVolumePostSkeleton() { return LOP::doLambdaVolumePostSkeleton; }
258 static constexpr bool doSkeletonTwoSided() { return LOP::doSkeletonTwoSided; }
259 static constexpr bool doPatternVolume() { return LOP::doPatternVolume; }
260 static constexpr bool doPatternSkeleton() { return LOP::doPatternSkeleton; }
261 static constexpr bool doPatternBoundary() { return LOP::doPatternBoundary; }
262 static constexpr bool doPatternVolumePostSkeleton() { return LOP::doPatternVolumePostSkeleton; }
263 static constexpr bool isLinear() { return LOP::isLinear;}
265
267
270 bool doPreProcessing() const { return doPreProcessing_; }
271
276 void preProcessing(bool v)
277 {
278 doPreProcessing_ = v;
279 }
280
282
285 bool doPostProcessing() const { return doPostProcessing_; }
286
291 void postProcessing(bool v)
292 {
293 doPostProcessing_ = v;
294 }
295
296 template<typename GFSV, typename GC, typename C>
297 void set_trivial_rows(const GFSV& gfsv, GC& globalcontainer, const C& c) const
298 {
299 typedef typename C::const_iterator global_row_iterator;
300 for (global_row_iterator cit = c.begin(); cit != c.end(); ++cit)
301 globalcontainer.clear_row_block(cit->first,1);
302 }
303
304 template<typename GFSV, typename GC>
305 void set_trivial_rows(const GFSV& gfsv, GC& globalcontainer, const EmptyTransformation& c) const
306 {
307 }
308
309 template<typename GFSV, typename GC>
310 void handle_dirichlet_constraints(const GFSV& gfsv, GC& globalcontainer) const
311 {
312 globalcontainer.flush();
313 set_trivial_rows(gfsv,globalcontainer,*this->pconstraintsv);
314 globalcontainer.finalize();
315 }
316
317 private:
318
320 std::shared_ptr<LOP> lop;
321
323 RangeField weight_;
324
327 bool doPreProcessing_;
328
331 bool doPostProcessing_;
332
335 LocalPatternAssemblerEngine pattern_engine;
336 LocalResidualAssemblerEngine residual_engine;
337 LocalJacobianAssemblerEngine jacobian_engine;
338 LocalJacobianApplyAssemblerEngine jacobian_apply_engine;
340
341 bool _reconstruct_border_entries;
342 };
343
344 } // end namespace PDELab
345} // end namespace Dune
346#endif
The local assembler for DUNE grids.
Definition: localassembler.hh:41
LOP & localOperator()
get a reference to the local operator
Definition: localassembler.hh:111
FastDGLocalAssembler(LOP &lop_, const CU &cu_, const CV &cv_, std::shared_ptr< typename GO::BorderDOFExchanger > border_dof_exchanger)
Constructor for non trivial constraints.
Definition: localassembler.hh:98
LOP LocalOperator
The local operator.
Definition: localassembler.hh:61
Traits::Residual::ElementType RangeField
The local operators type for real numbers e.g. time.
Definition: localassembler.hh:48
bool skipEntity(const EG &eg) const
Definition: localassembler.hh:129
Dune::PDELab::LocalFunctionSpace< GFSU, Dune::PDELab::TrialSpaceTag > LFSU
Definition: localassembler.hh:68
void postProcessing(bool v)
Definition: localassembler.hh:291
LocalJacobianApplyAssemblerEngine & localJacobianApplyAssemblerEngine(const typename Traits::Domain &solution, const typename Traits::Domain &update, typename Traits::Range &result)
Definition: localassembler.hh:236
static constexpr bool doAlphaVolume()
Query methods for the assembler engines. Theses methods do not belong to the assembler interface,...
Definition: localassembler.hh:250
const LOP & localOperator() const
get a reference to the local operator
Definition: localassembler.hh:117
void preStage(Real time_, int r_)
Definition: localassembler.hh:179
bool skipIntersection(const IG &ig) const
Definition: localassembler.hh:147
LocalJacobianAssemblerEngine & localJacobianAssemblerEngine(typename Traits::Jacobian &a, const typename Traits::Solution &x)
Definition: localassembler.hh:216
void preProcessing(bool v)
Definition: localassembler.hh:276
FastDGLocalAssembler(LOP &lop_, std::shared_ptr< typename GO::BorderDOFExchanger > border_dof_exchanger)
Constructor with empty constraints.
Definition: localassembler.hh:87
void setTime(Real time_)
Definition: localassembler.hh:161
bool doPreProcessing() const
Query whether to do preprocessing in the engines.
Definition: localassembler.hh:270
bool doPostProcessing() const
Query whether to do postprocessing in the engines.
Definition: localassembler.hh:285
LocalPatternAssemblerEngine & localPatternAssemblerEngine(typename Traits::MatrixPattern &p)
Definition: localassembler.hh:197
LocalJacobianApplyAssemblerEngine & localJacobianApplyAssemblerEngine(const typename Traits::Domain &update, typename Traits::Range &result)
Definition: localassembler.hh:226
RangeField weight() const
Obtain the weight that was set last.
Definition: localassembler.hh:167
Dune::PDELab::LocalAssemblerBase< typename Traits::MatrixBackend, CU, CV > Base
The base class of this local assembler.
Definition: localassembler.hh:58
FastDGLocalPatternAssemblerEngine< FastDGLocalAssembler > LocalPatternAssemblerEngine
Definition: localassembler.hh:77
void setWeight(RangeField weight)
Notifies the assembler about the current weight of assembling.
Definition: localassembler.hh:173
Dune::PDELab::LocalAssemblerTraits< GO > Traits
The traits class.
Definition: localassembler.hh:45
LocalResidualAssemblerEngine & localResidualAssemblerEngine(typename Traits::Residual &r, const typename Traits::Solution &x)
Definition: localassembler.hh:206
void setResult(Range &result_)
Definition: jacobianapplyengine.hh:125
void setSolution(const Domain &solution_)
Definition: jacobianapplyengine.hh:107
void setUpdate(const Domain &update_)
Definition: jacobianapplyengine.hh:117
void setSolution(const Solution &solution_)
Definition: jacobianengine.hh:142
void setJacobian(Jacobian &jacobian_)
Definition: jacobianengine.hh:132
void setPattern(Pattern &pattern_)
Definition: patternengine.hh:92
void setSolution(const Solution &solution_)
Definition: residualengine.hh:148
void setResidual(Residual &residual_)
Definition: residualengine.hh:140
Base class for local assembler.
Definition: assemblerutilities.hh:217
Create a local function space from a global function space.
Definition: localfunctionspace.hh:754
Dune namespace.
Definition: alignedallocator.hh:13
std::shared_ptr< T > stackobject_to_shared_ptr(T &t)
Create a shared_ptr for a stack-allocated object.
Definition: shared_ptr.hh:72
This file implements several utilities related to std::shared_ptr.
Definition: assemblerutilities.hh:51
GO::Traits::Range Residual
The type of the range (residual).
Definition: assemblerutilities.hh:88
MatrixBackend::template Pattern< Jacobian, TestGridFunctionSpace, TrialGridFunctionSpace > MatrixPattern
The matrix pattern.
Definition: assemblerutilities.hh:102
GO::Traits::TrialGridFunctionSpace TrialGridFunctionSpace
The trial grid function space.
Definition: assemblerutilities.hh:54
GO::Traits::Jacobian Jacobian
The type of the jacobian.
Definition: assemblerutilities.hh:95
GO::Traits::TestGridFunctionSpace TestGridFunctionSpace
The test grid function space.
Definition: assemblerutilities.hh:57
GO::Traits::Domain Solution
The type of the domain (solution).
Definition: assemblerutilities.hh:78
GO::Traits::Range Range
The type of the range (residual).
Definition: assemblerutilities.hh:85
GO::Traits::Domain Domain
The type of the domain (solution).
Definition: assemblerutilities.hh:75
GO::Traits::TrialGridFunctionSpaceConstraints TrialGridFunctionSpaceConstraints
The type of the trial grid function space constraints.
Definition: assemblerutilities.hh:61
GO::Traits::TestGridFunctionSpaceConstraints TestGridFunctionSpaceConstraints
The type of the test grid function space constraints.
Definition: assemblerutilities.hh:64
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)