dune-pdelab 2.7-git
Loading...
Searching...
No Matches
fastdg/localassembler.hh
Go to the documentation of this file.
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
8#include <dune/common/shared_ptr.hh>
9
10#include <dune/typetree/typetree.hh>
11
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;
50
53
56
59
61 typedef LOP LocalOperator;
62
63 static const bool isNonOverlapping = nonoverlapping_mode;
64
67 // Types of local function spaces
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");
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");
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
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
const P & p
Definition: constraints.hh:148
const IG & ig
Definition: constraints.hh:149
For backward compatibility – Do not use this!
Definition: adaptivity.hh:28
Impl::LocalAssemblerCallSwitchHelper< LOP, doIt > LocalAssemblerCallSwitch
Definition: callswitch.hh:407
Definition: constraintstransformation.hh:112
Definition: lfsindexcache.hh:979
Create a local function space from a global function space.
Definition: localfunctionspace.hh:725
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
Base class for local assembler.
Definition: assemblerutilities.hh:217
The fast DG local assembler engine for DUNE grids which assembles the local application of the Jacobi...
Definition: fastdg/jacobianapplyengine.hh:23
void setResult(Range &result_)
Definition: fastdg/jacobianapplyengine.hh:125
void setSolution(const Domain &solution_)
Definition: fastdg/jacobianapplyengine.hh:107
void setUpdate(const Domain &update_)
Definition: fastdg/jacobianapplyengine.hh:117
The fast DG local assembler engine for DUNE grids which assembles the jacobian matrix.
Definition: fastdg/jacobianengine.hh:27
void setSolution(const Solution &solution_)
Definition: fastdg/jacobianengine.hh:142
void setJacobian(Jacobian &jacobian_)
Definition: fastdg/jacobianengine.hh:132
The local assembler for DUNE grids.
Definition: fastdg/localassembler.hh:41
LOP & localOperator()
get a reference to the local operator
Definition: fastdg/localassembler.hh:111
static constexpr bool doAlphaVolumePostSkeleton()
Definition: fastdg/localassembler.hh:256
static constexpr bool doPatternVolume()
Definition: fastdg/localassembler.hh:259
static constexpr bool doLambdaBoundary()
Definition: fastdg/localassembler.hh:255
Traits::TrialGridFunctionSpaceConstraints CU
Definition: fastdg/localassembler.hh:54
FastDGLocalAssembler(LOP &lop_, const CU &cu_, const CV &cv_, std::shared_ptr< typename GO::BorderDOFExchanger > border_dof_exchanger)
Constructor for non trivial constraints.
Definition: fastdg/localassembler.hh:98
FastDGLocalResidualAssemblerEngine< FastDGLocalAssembler > LocalResidualAssemblerEngine
Definition: fastdg/localassembler.hh:78
static const bool isNonOverlapping
Definition: fastdg/localassembler.hh:63
void postStage()
Definition: fastdg/localassembler.hh:182
LFSIndexCache< LFSV, CV, true > LFSVCache
Definition: fastdg/localassembler.hh:71
bool reconstructBorderEntries() const
Definition: fastdg/localassembler.hh:186
LOP LocalOperator
The local operator.
Definition: fastdg/localassembler.hh:61
Traits::Residual::ElementType RangeField
The local operators type for real numbers e.g. time.
Definition: fastdg/localassembler.hh:48
bool skipEntity(const EG &eg) const
Definition: fastdg/localassembler.hh:129
Dune::PDELab::LocalFunctionSpace< GFSU, Dune::PDELab::TrialSpaceTag > LFSU
Definition: fastdg/localassembler.hh:68
static constexpr bool doLambdaVolume()
Definition: fastdg/localassembler.hh:251
void postStep()
Definition: fastdg/localassembler.hh:181
static constexpr bool doPatternBoundary()
Definition: fastdg/localassembler.hh:261
Traits::TestGridFunctionSpaceConstraints CV
Definition: fastdg/localassembler.hh:55
void postProcessing(bool v)
Definition: fastdg/localassembler.hh:291
static constexpr bool doAlphaSkeleton()
Definition: fastdg/localassembler.hh:252
Dune::PDELab::LocalFunctionSpace< GFSV, Dune::PDELab::TestSpaceTag > LFSV
Definition: fastdg/localassembler.hh:69
LocalJacobianApplyAssemblerEngine & localJacobianApplyAssemblerEngine(const typename Traits::Domain &solution, const typename Traits::Domain &update, typename Traits::Range &result)
Definition: fastdg/localassembler.hh:236
static constexpr bool doAlphaVolume()
Query methods for the assembler engines. Theses methods do not belong to the assembler interface,...
Definition: fastdg/localassembler.hh:250
const LOP & localOperator() const
get a reference to the local operator
Definition: fastdg/localassembler.hh:117
static constexpr bool doLambdaVolumePostSkeleton()
Definition: fastdg/localassembler.hh:257
RangeField Real
Definition: fastdg/localassembler.hh:49
void preStage(Real time_, int r_)
Definition: fastdg/localassembler.hh:179
bool skipIntersection(const IG &ig) const
Definition: fastdg/localassembler.hh:147
LocalJacobianAssemblerEngine & localJacobianAssemblerEngine(typename Traits::Jacobian &a, const typename Traits::Solution &x)
Definition: fastdg/localassembler.hh:216
static constexpr bool doAlphaBoundary()
Definition: fastdg/localassembler.hh:254
void preProcessing(bool v)
Definition: fastdg/localassembler.hh:276
FastDGLocalAssembler(LOP &lop_, std::shared_ptr< typename GO::BorderDOFExchanger > border_dof_exchanger)
Constructor with empty constraints.
Definition: fastdg/localassembler.hh:87
static constexpr bool doLambdaSkeleton()
Definition: fastdg/localassembler.hh:253
void setTime(Real time_)
Definition: fastdg/localassembler.hh:161
bool doPreProcessing() const
Query whether to do preprocessing in the engines.
Definition: fastdg/localassembler.hh:270
LFSIndexCache< LFSU, CU, true > LFSUCache
Definition: fastdg/localassembler.hh:70
bool doPostProcessing() const
Query whether to do postprocessing in the engines.
Definition: fastdg/localassembler.hh:285
Traits::TestGridFunctionSpace GFSV
Definition: fastdg/localassembler.hh:52
Traits::TrialGridFunctionSpace GFSU
Definition: fastdg/localassembler.hh:51
LocalPatternAssemblerEngine & localPatternAssemblerEngine(typename Traits::MatrixPattern &p)
Definition: fastdg/localassembler.hh:197
static constexpr bool doPatternSkeleton()
Definition: fastdg/localassembler.hh:260
LocalJacobianApplyAssemblerEngine & localJacobianApplyAssemblerEngine(const typename Traits::Domain &update, typename Traits::Range &result)
Definition: fastdg/localassembler.hh:226
RangeField weight() const
Obtain the weight that was set last.
Definition: fastdg/localassembler.hh:167
void preStep(Real time_, Real dt_, std::size_t stages_)
Definition: fastdg/localassembler.hh:180
Dune::PDELab::LocalAssemblerBase< typename Traits::MatrixBackend, CU, CV > Base
The base class of this local assembler.
Definition: fastdg/localassembler.hh:58
void set_trivial_rows(const GFSV &gfsv, GC &globalcontainer, const C &c) const
Definition: fastdg/localassembler.hh:297
FastDGLocalPatternAssemblerEngine< FastDGLocalAssembler > LocalPatternAssemblerEngine
Definition: fastdg/localassembler.hh:77
FastDGLocalJacobianAssemblerEngine< FastDGLocalAssembler > LocalJacobianAssemblerEngine
Definition: fastdg/localassembler.hh:79
Real suggestTimestep(Real dt) const
Definition: fastdg/localassembler.hh:183
void setWeight(RangeField weight)
Notifies the assembler about the current weight of assembling.
Definition: fastdg/localassembler.hh:173
static constexpr bool doPatternVolumePostSkeleton()
Definition: fastdg/localassembler.hh:262
Dune::PDELab::LocalAssemblerTraits< GO > Traits
The traits class.
Definition: fastdg/localassembler.hh:45
static constexpr bool doSkeletonTwoSided()
Definition: fastdg/localassembler.hh:258
void set_trivial_rows(const GFSV &gfsv, GC &globalcontainer, const EmptyTransformation &c) const
Definition: fastdg/localassembler.hh:305
FastDGLocalJacobianApplyAssemblerEngine< FastDGLocalAssembler > LocalJacobianApplyAssemblerEngine
Definition: fastdg/localassembler.hh:80
LocalResidualAssemblerEngine & localResidualAssemblerEngine(typename Traits::Residual &r, const typename Traits::Solution &x)
Definition: fastdg/localassembler.hh:206
static constexpr bool isLinear()
Definition: fastdg/localassembler.hh:263
void handle_dirichlet_constraints(const GFSV &gfsv, GC &globalcontainer) const
Definition: fastdg/localassembler.hh:310
The fast DG local assembler engine for DUNE grids which creates the matrix pattern.
Definition: fastdg/patternengine.hh:24
void setPattern(Pattern &pattern_)
Definition: fastdg/patternengine.hh:92
The fast DG local assembler engine for DUNE grids which assembles the residual vector.
Definition: fastdg/residualengine.hh:24
void setSolution(const Solution &solution_)
Definition: fastdg/residualengine.hh:148
void setResidual(Residual &residual_)
Definition: fastdg/residualengine.hh:140