dune-pdelab  2.7-git
default/localassembler.hh
Go to the documentation of this file.
1 #ifndef DUNE_PDELAB_GRIDOPERATOR_DEFAULT_LOCALASSEMBLER_HH
2 #define DUNE_PDELAB_GRIDOPERATOR_DEFAULT_LOCALASSEMBLER_HH
3 
4 #include <dune/typetree/typetree.hh>
5 
12 
13 namespace Dune{
14  namespace PDELab{
15 
30  template<typename GO, typename LOP, bool nonoverlapping_mode = false>
32  public Dune::PDELab::LocalAssemblerBase<typename GO::Traits::MatrixBackend,
33  typename GO::Traits::TrialGridFunctionSpaceConstraints,
34  typename GO::Traits::TestGridFunctionSpaceConstraints>
35  {
36  public:
37 
40 
42  typedef typename Traits::Residual::ElementType RangeField;
43  typedef RangeField Real;
44 
47 
50 
53 
55  typedef LOP LocalOperator;
56 
57  static const bool isNonOverlapping = nonoverlapping_mode;
58 
61  // Types of local function spaces
66 
68 
75 
76  // friend declarations such that engines are able to call scatter_jacobian() and add_entry() from base class
80 
82  DefaultLocalAssembler (LOP & lop, std::shared_ptr<typename GO::BorderDOFExchanger> border_dof_exchanger)
83  : lop_(lop), weight_(1.0), doPreProcessing_(true), doPostProcessing_(true),
84  pattern_engine(*this,border_dof_exchanger), residual_engine(*this), jacobian_engine(*this)
85  , jacobian_apply_engine(*this)
86  , _reconstruct_border_entries(isNonOverlapping)
87  {}
88 
90  DefaultLocalAssembler (LOP & lop, const CU& cu, const CV& cv,
91  std::shared_ptr<typename GO::BorderDOFExchanger> border_dof_exchanger)
92  : Base(cu, cv),
93  lop_(lop), weight_(1.0), doPreProcessing_(true), doPostProcessing_(true),
94  pattern_engine(*this,border_dof_exchanger), residual_engine(*this), jacobian_engine(*this)
95  , jacobian_apply_engine(*this)
96  , _reconstruct_border_entries(isNonOverlapping)
97  {}
98 
101  {
102  return lop_;
103  }
104 
106  const LOP &localOperator() const
107  {
108  return lop_;
109  }
110 
117  template<class EG>
118  bool skipEntity(const EG & eg) const
119  {
120  static_assert(
121  models<Impl::HasDoSkipEntity, LOP>(),
122  "Your local operator does not provide the 'doSkipEntity' flag. "
123  "If you are porting a previous implementation, set the flag to "
124  "false");
126  LOP, LOP::doSkipEntity>::skip_entity(lop_, eg);
127  }
128 
135  template<class IG>
136  bool skipIntersection(const IG & ig) const
137  {
138  static_assert(models<Impl::HasDoSkipIntersection, LOP>(),
139  "Your local operator does not provide the "
140  "'doSkipIntersection' flag. "
141  "If you are porting a previous implementation, set the "
142  "flag to false");
144  LOP, LOP::doSkipIntersection>::skip_intersection(lop_, ig);
145  }
146 
150  void setTime(Real time_)
151  {
152  lop_.setTime(time_);
153  }
154 
157  {
158  return weight_;
159  }
160 
163  weight_ = weight;
164  }
165 
168  void preStage (Real time_, int r_) { lop_.preStage(time_,r_); }
169  void preStep (Real time_, Real dt_, std::size_t stages_){ lop_.preStep(time_,dt_,stages_); }
170  void postStep (){ lop_.postStep(); }
171  void postStage (){ lop_.postStage(); }
172  Real suggestTimestep (Real dt) const{return lop_.suggestTimestep(dt); }
174 
176  {
177  return _reconstruct_border_entries;
178  }
179 
182 
186  (typename Traits::MatrixPattern & p)
187  {
188  pattern_engine.setPattern(p);
189  return pattern_engine;
190  }
191 
195  (typename Traits::Residual & r, const typename Traits::Solution & x)
196  {
197  residual_engine.setResidual(r);
198  residual_engine.setSolution(x);
199  return residual_engine;
200  }
201 
205  (typename Traits::Jacobian & a, const typename Traits::Solution & x)
206  {
207  jacobian_engine.setJacobian(a);
208  jacobian_engine.setSolution(x);
209  return jacobian_engine;
210  }
211 
215  (const typename Traits::Domain & update, typename Traits::Range & result)
216  {
217  jacobian_apply_engine.setUpdate(update);
218  jacobian_apply_engine.setResult(result);
219  return jacobian_apply_engine;
220  }
221 
225  (const typename Traits::Domain & solution, const typename Traits::Domain & update, typename Traits::Range & result)
226  {
227  jacobian_apply_engine.setSolution(solution);
228  jacobian_apply_engine.setUpdate(update);
229  jacobian_apply_engine.setResult(result);
230  return jacobian_apply_engine;
231  }
232 
234 
239  static constexpr bool doAlphaVolume() { return LOP::doAlphaVolume; }
240  static constexpr bool doLambdaVolume() { return LOP::doLambdaVolume; }
241  static constexpr bool doAlphaSkeleton() { return LOP::doAlphaSkeleton; }
242  static constexpr bool doLambdaSkeleton() { return LOP::doLambdaSkeleton; }
243  static constexpr bool doAlphaBoundary() { return LOP::doAlphaBoundary; }
244  static constexpr bool doLambdaBoundary() { return LOP::doLambdaBoundary; }
245  static constexpr bool doAlphaVolumePostSkeleton() { return LOP::doAlphaVolumePostSkeleton; }
246  static constexpr bool doLambdaVolumePostSkeleton() { return LOP::doLambdaVolumePostSkeleton; }
247  static constexpr bool doSkeletonTwoSided() { return LOP::doSkeletonTwoSided; }
248  static constexpr bool doPatternVolume() { return LOP::doPatternVolume; }
249  static constexpr bool doPatternSkeleton() { return LOP::doPatternSkeleton; }
250  static constexpr bool doPatternBoundary() { return LOP::doPatternBoundary; }
251  static constexpr bool doPatternVolumePostSkeleton() { return LOP::doPatternVolumePostSkeleton; }
252  static constexpr bool isLinear() { return LOP::isLinear;}
254 
256 
259  bool doPreProcessing() const { return doPreProcessing_; }
260 
265  void preProcessing(bool v)
266  {
267  doPreProcessing_ = v;
268  }
269 
271 
274  bool doPostProcessing() const { return doPostProcessing_; }
275 
280  void postProcessing(bool v)
281  {
282  doPostProcessing_ = v;
283  }
284 
285  private:
286 
288  LOP & lop_;
289 
291  RangeField weight_;
292 
295  bool doPreProcessing_;
296 
299  bool doPostProcessing_;
300 
303  LocalPatternAssemblerEngine pattern_engine;
304  LocalResidualAssemblerEngine residual_engine;
305  LocalJacobianAssemblerEngine jacobian_engine;
306  LocalJacobianApplyAssemblerEngine jacobian_apply_engine;
308 
309  bool _reconstruct_border_entries;
310  };
311 
312  } // end namespace PDELab
313 } // end namespace Dune
314 #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: 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
void setUpdate(const Domain &update_)
Definition: default/jacobianapplyengine.hh:117
void setResult(Range &result_)
Definition: default/jacobianapplyengine.hh:125
void setSolution(const Domain &solution_)
Definition: default/jacobianapplyengine.hh:109
void setSolution(const Solution &solution_)
Definition: default/jacobianengine.hh:120
void setJacobian(Jacobian &jacobian_)
Definition: default/jacobianengine.hh:110
The local assembler for DUNE grids.
Definition: default/localassembler.hh:35
DefaultLocalJacobianApplyAssemblerEngine< DefaultLocalAssembler > LocalJacobianApplyAssemblerEngine
Definition: default/localassembler.hh:74
Traits::Residual::ElementType RangeField
The local operators type for real numbers e.g. time.
Definition: default/localassembler.hh:42
RangeField weight() const
Obtain the weight that was set last.
Definition: default/localassembler.hh:156
DefaultLocalPatternAssemblerEngine< DefaultLocalAssembler > LocalPatternAssemblerEngine
Definition: default/localassembler.hh:71
Dune::PDELab::LocalFunctionSpace< GFSU, Dune::PDELab::TrialSpaceTag > LFSU
Definition: default/localassembler.hh:62
DefaultLocalResidualAssemblerEngine< DefaultLocalAssembler > LocalResidualAssemblerEngine
Definition: default/localassembler.hh:72
static constexpr bool doAlphaVolume()
Query methods for the assembler engines. Theses methods do not belong to the assembler interface,...
Definition: default/localassembler.hh:239
void setTime(Real time_)
Definition: default/localassembler.hh:150
static constexpr bool doSkeletonTwoSided()
Definition: default/localassembler.hh:247
bool doPreProcessing() const
Query whether to do preprocessing in the engines.
Definition: default/localassembler.hh:259
LocalJacobianAssemblerEngine & localJacobianAssemblerEngine(typename Traits::Jacobian &a, const typename Traits::Solution &x)
Definition: default/localassembler.hh:205
Dune::PDELab::LocalAssemblerTraits< GO > Traits
The traits class.
Definition: default/localassembler.hh:39
void preStage(Real time_, int r_)
Definition: default/localassembler.hh:168
bool reconstructBorderEntries() const
Definition: default/localassembler.hh:175
LOP LocalOperator
The local operator.
Definition: default/localassembler.hh:55
static constexpr bool doAlphaSkeleton()
Definition: default/localassembler.hh:241
bool skipIntersection(const IG &ig) const
Definition: default/localassembler.hh:136
LocalJacobianApplyAssemblerEngine & localJacobianApplyAssemblerEngine(const typename Traits::Domain &solution, const typename Traits::Domain &update, typename Traits::Range &result)
Definition: default/localassembler.hh:225
LFSIndexCache< LFSV, CV > LFSVCache
Definition: default/localassembler.hh:65
static constexpr bool doLambdaSkeleton()
Definition: default/localassembler.hh:242
void postStage()
Definition: default/localassembler.hh:171
Real suggestTimestep(Real dt) const
Definition: default/localassembler.hh:172
RangeField Real
Definition: default/localassembler.hh:43
void postStep()
Definition: default/localassembler.hh:170
Traits::TestGridFunctionSpaceConstraints CV
Definition: default/localassembler.hh:49
static constexpr bool doPatternBoundary()
Definition: default/localassembler.hh:250
bool skipEntity(const EG &eg) const
Definition: default/localassembler.hh:118
static const bool isNonOverlapping
Definition: default/localassembler.hh:57
LocalResidualAssemblerEngine & localResidualAssemblerEngine(typename Traits::Residual &r, const typename Traits::Solution &x)
Definition: default/localassembler.hh:195
DefaultLocalJacobianAssemblerEngine< DefaultLocalAssembler > LocalJacobianAssemblerEngine
Definition: default/localassembler.hh:73
void preProcessing(bool v)
Definition: default/localassembler.hh:265
static constexpr bool doLambdaBoundary()
Definition: default/localassembler.hh:244
void postProcessing(bool v)
Definition: default/localassembler.hh:280
static constexpr bool doPatternVolumePostSkeleton()
Definition: default/localassembler.hh:251
void setWeight(RangeField weight)
Notifies the assembler about the current weight of assembling.
Definition: default/localassembler.hh:162
DefaultLocalAssembler(LOP &lop, std::shared_ptr< typename GO::BorderDOFExchanger > border_dof_exchanger)
Constructor with empty constraints.
Definition: default/localassembler.hh:82
LocalJacobianApplyAssemblerEngine & localJacobianApplyAssemblerEngine(const typename Traits::Domain &update, typename Traits::Range &result)
Definition: default/localassembler.hh:215
Traits::TrialGridFunctionSpaceConstraints CU
Definition: default/localassembler.hh:48
static constexpr bool doAlphaBoundary()
Definition: default/localassembler.hh:243
static constexpr bool doAlphaVolumePostSkeleton()
Definition: default/localassembler.hh:245
static constexpr bool doPatternVolume()
Definition: default/localassembler.hh:248
Dune::PDELab::LocalAssemblerBase< typename Traits::MatrixBackend, CU, CV > Base
The base class of this local assembler.
Definition: default/localassembler.hh:52
DefaultLocalAssembler(LOP &lop, const CU &cu, const CV &cv, std::shared_ptr< typename GO::BorderDOFExchanger > border_dof_exchanger)
Constructor for non trivial constraints.
Definition: default/localassembler.hh:90
const LOP & localOperator() const
get a reference to the local operator
Definition: default/localassembler.hh:106
static constexpr bool doLambdaVolumePostSkeleton()
Definition: default/localassembler.hh:246
Traits::TestGridFunctionSpace GFSV
Definition: default/localassembler.hh:46
LOP & localOperator()
get a reference to the local operator
Definition: default/localassembler.hh:100
static constexpr bool isLinear()
Definition: default/localassembler.hh:252
LFSIndexCache< LFSU, CU > LFSUCache
Definition: default/localassembler.hh:64
void preStep(Real time_, Real dt_, std::size_t stages_)
Definition: default/localassembler.hh:169
static constexpr bool doPatternSkeleton()
Definition: default/localassembler.hh:249
Traits::TrialGridFunctionSpace GFSU
Definition: default/localassembler.hh:45
bool doPostProcessing() const
Query whether to do postprocessing in the engines.
Definition: default/localassembler.hh:274
static constexpr bool doLambdaVolume()
Definition: default/localassembler.hh:240
Dune::PDELab::LocalFunctionSpace< GFSV, Dune::PDELab::TestSpaceTag > LFSV
Definition: default/localassembler.hh:63
LocalPatternAssemblerEngine & localPatternAssemblerEngine(typename Traits::MatrixPattern &p)
Definition: default/localassembler.hh:186
void setPattern(Pattern &pattern_)
Definition: default/patternengine.hh:92
void setResidual(Residual &residual_)
Definition: default/residualengine.hh:114
void setSolution(const Solution &solution_)
Definition: default/residualengine.hh:122