DUNE PDELab (2.7)

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
125 void setTime(Real time_)
126 {
127 lop->setTime(time_);
128 }
129
132 {
133 return weight_;
134 }
135
138 weight_ = weight;
139 }
140
143 void preStage (Real time_, int r_) { lop->preStage(time_,r_); }
144 void preStep (Real time_, Real dt_, std::size_t stages_){ lop->preStep(time_,dt_,stages_); }
145 void postStep (){ lop->postStep(); }
146 void postStage (){ lop->postStage(); }
147 Real suggestTimestep (Real dt) const{return lop->suggestTimestep(dt); }
149
150 bool reconstructBorderEntries() const
151 {
152 return _reconstruct_border_entries;
153 }
154
157
161 (typename Traits::MatrixPattern & p)
162 {
163 pattern_engine.setPattern(p);
164 return pattern_engine;
165 }
166
170 (typename Traits::Residual & r, const typename Traits::Solution & x)
171 {
172 residual_engine.setResidual(r);
173 residual_engine.setSolution(x);
174 return residual_engine;
175 }
176
180 (typename Traits::Jacobian & a, const typename Traits::Solution & x)
181 {
182 jacobian_engine.setJacobian(a);
183 jacobian_engine.setSolution(x);
184 return jacobian_engine;
185 }
186
190 (const typename Traits::Domain & update, typename Traits::Range & result)
191 {
192 jacobian_apply_engine.setUpdate(update);
193 jacobian_apply_engine.setResult(result);
194 return jacobian_apply_engine;
195 }
196
200 (const typename Traits::Domain & solution, const typename Traits::Domain & update, typename Traits::Range & result)
201 {
202 jacobian_apply_engine.setSolution(solution);
203 jacobian_apply_engine.setUpdate(update);
204 jacobian_apply_engine.setResult(result);
205 return jacobian_apply_engine;
206 }
207
209
214 static constexpr bool doAlphaVolume() { return LOP::doAlphaVolume; }
215 static constexpr bool doLambdaVolume() { return LOP::doLambdaVolume; }
216 static constexpr bool doAlphaSkeleton() { return LOP::doAlphaSkeleton; }
217 static constexpr bool doLambdaSkeleton() { return LOP::doLambdaSkeleton; }
218 static constexpr bool doAlphaBoundary() { return LOP::doAlphaBoundary; }
219 static constexpr bool doLambdaBoundary() { return LOP::doLambdaBoundary; }
220 static constexpr bool doAlphaVolumePostSkeleton() { return LOP::doAlphaVolumePostSkeleton; }
221 static constexpr bool doLambdaVolumePostSkeleton() { return LOP::doLambdaVolumePostSkeleton; }
222 static constexpr bool doSkeletonTwoSided() { return LOP::doSkeletonTwoSided; }
223 static constexpr bool doPatternVolume() { return LOP::doPatternVolume; }
224 static constexpr bool doPatternSkeleton() { return LOP::doPatternSkeleton; }
225 static constexpr bool doPatternBoundary() { return LOP::doPatternBoundary; }
226 static constexpr bool doPatternVolumePostSkeleton() { return LOP::doPatternVolumePostSkeleton; }
227 static constexpr bool isLinear() { return LOP::isLinear;}
229
231
234 bool doPreProcessing() const { return doPreProcessing_; }
235
240 void preProcessing(bool v)
241 {
242 doPreProcessing_ = v;
243 }
244
246
249 bool doPostProcessing() const { return doPostProcessing_; }
250
255 void postProcessing(bool v)
256 {
257 doPostProcessing_ = v;
258 }
259
260 template<typename GFSV, typename GC, typename C>
261 void set_trivial_rows(const GFSV& gfsv, GC& globalcontainer, const C& c) const
262 {
263 typedef typename C::const_iterator global_row_iterator;
264 for (global_row_iterator cit = c.begin(); cit != c.end(); ++cit)
265 globalcontainer.clear_row_block(cit->first,1);
266 }
267
268 template<typename GFSV, typename GC>
269 void set_trivial_rows(const GFSV& gfsv, GC& globalcontainer, const EmptyTransformation& c) const
270 {
271 }
272
273 template<typename GFSV, typename GC>
274 void handle_dirichlet_constraints(const GFSV& gfsv, GC& globalcontainer) const
275 {
276 globalcontainer.flush();
277 set_trivial_rows(gfsv,globalcontainer,*this->pconstraintsv);
278 globalcontainer.finalize();
279 }
280
281 private:
282
284 std::shared_ptr<LOP> lop;
285
287 RangeField weight_;
288
291 bool doPreProcessing_;
292
295 bool doPostProcessing_;
296
299 LocalPatternAssemblerEngine pattern_engine;
300 LocalResidualAssemblerEngine residual_engine;
301 LocalJacobianAssemblerEngine jacobian_engine;
302 LocalJacobianApplyAssemblerEngine jacobian_apply_engine;
304
305 bool _reconstruct_border_entries;
306 };
307
308 } // end namespace PDELab
309} // end namespace Dune
310#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
Dune::PDELab::LocalFunctionSpace< GFSU, Dune::PDELab::TrialSpaceTag > LFSU
Definition: localassembler.hh:68
void postProcessing(bool v)
Definition: localassembler.hh:255
LocalJacobianApplyAssemblerEngine & localJacobianApplyAssemblerEngine(const typename Traits::Domain &solution, const typename Traits::Domain &update, typename Traits::Range &result)
Definition: localassembler.hh:200
static constexpr bool doAlphaVolume()
Query methods for the assembler engines. Theses methods do not belong to the assembler interface,...
Definition: localassembler.hh:214
const LOP & localOperator() const
get a reference to the local operator
Definition: localassembler.hh:117
void preStage(Real time_, int r_)
Definition: localassembler.hh:143
LocalJacobianAssemblerEngine & localJacobianAssemblerEngine(typename Traits::Jacobian &a, const typename Traits::Solution &x)
Definition: localassembler.hh:180
void preProcessing(bool v)
Definition: localassembler.hh:240
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:125
bool doPreProcessing() const
Query whether to do preprocessing in the engines.
Definition: localassembler.hh:234
bool doPostProcessing() const
Query whether to do postprocessing in the engines.
Definition: localassembler.hh:249
LocalPatternAssemblerEngine & localPatternAssemblerEngine(typename Traits::MatrixPattern &p)
Definition: localassembler.hh:161
LocalJacobianApplyAssemblerEngine & localJacobianApplyAssemblerEngine(const typename Traits::Domain &update, typename Traits::Range &result)
Definition: localassembler.hh:190
RangeField weight() const
Obtain the weight that was set last.
Definition: localassembler.hh:131
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:137
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:170
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:189
Create a local function space from a global function space.
Definition: localfunctionspace.hh:717
Dune namespace.
Definition: alignedallocator.hh:14
shared_ptr< T > stackobject_to_shared_ptr(T &t)
Create a shared_ptr for a stack-allocated object.
Definition: shared_ptr.hh:75
This file implements the class shared_ptr (a reference counting pointer), for those systems that don'...
Definition: assemblerutilities.hh:23
GO::Traits::Range Residual
The type of the range (residual).
Definition: assemblerutilities.hh:60
MatrixBackend::template Pattern< Jacobian, TestGridFunctionSpace, TrialGridFunctionSpace > MatrixPattern
The matrix pattern.
Definition: assemblerutilities.hh:74
GO::Traits::TrialGridFunctionSpace TrialGridFunctionSpace
The trial grid function space.
Definition: assemblerutilities.hh:26
GO::Traits::Jacobian Jacobian
The type of the jacobian.
Definition: assemblerutilities.hh:67
GO::Traits::TestGridFunctionSpace TestGridFunctionSpace
The test grid function space.
Definition: assemblerutilities.hh:29
GO::Traits::Domain Solution
The type of the domain (solution).
Definition: assemblerutilities.hh:50
GO::Traits::Range Range
The type of the range (residual).
Definition: assemblerutilities.hh:57
GO::Traits::Domain Domain
The type of the domain (solution).
Definition: assemblerutilities.hh:47
GO::Traits::TrialGridFunctionSpaceConstraints TrialGridFunctionSpaceConstraints
The type of the trial grid function space constraints.
Definition: assemblerutilities.hh:33
GO::Traits::TestGridFunctionSpaceConstraints TestGridFunctionSpaceConstraints
The type of the test grid function space constraints.
Definition: assemblerutilities.hh:36
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)