3#ifndef DUNE_PDELAB_GRIDOPERATOR_ONESTEP_HH
4#define DUNE_PDELAB_GRIDOPERATOR_ONESTEP_HH
8#include <dune/pdelab/constraints/common/constraints.hh>
9#include <dune/pdelab/gridfunctionspace/genericdatahandle.hh>
10#include <dune/pdelab/gridoperator/common/gridoperatorutilities.hh>
11#include <dune/pdelab/gridoperator/onestep/localassembler.hh>
12#include <dune/pdelab/instationary/onestep.hh>
17 template<
typename GO0,
typename GO1,
bool implicit = true>
18 class OneStepGridOperator
23 typedef typename GO0::Pattern Pattern;
26 typedef typename GO0::Traits::Assembler Assembler;
30 typedef typename GO0::Traits::LocalAssembler LocalAssemblerDT0;
31 typedef typename GO1::Traits::LocalAssembler LocalAssemblerDT1;
35 typedef OneStepLocalAssembler<OneStepGridOperator,LocalAssemblerDT0,LocalAssemblerDT1> LocalAssembler;
38 typedef typename GO0::BorderDOFExchanger BorderDOFExchanger;
42 <
typename GO0::Traits::TrialGridFunctionSpace,
43 typename GO0::Traits::TestGridFunctionSpace,
44 typename GO0::Traits::MatrixBackend,
45 typename GO0::Traits::DomainField,
46 typename GO0::Traits::RangeField,
47 typename GO0::Traits::JacobianField,
48 typename GO0::Traits::TrialGridFunctionSpaceConstraints,
49 typename GO0::Traits::TestGridFunctionSpaceConstraints,
51 LocalAssembler> Traits;
60 template <
typename MFT>
61 struct MatrixContainer
63 typedef Jacobian Type;
73 OneStepGridOperator(GO0 & go0_, GO1 & go1_)
74 : global_assembler(go0_.assembler()),
76 la0(go0_.localAssembler()), la1(go1_.localAssembler()),
77 const_residual( go0_.testGridFunctionSpace() ),
78 local_assembler(la0,la1, const_residual)
80 GO0::setupGridOperators(std::tie(go0_,go1_));
82 local_assembler.setDTAssemblingMode(LocalAssembler::DoNotAssembleDT);
88 void divideMassTermByDeltaT()
92 local_assembler.setDTAssemblingMode(LocalAssembler::DivideOperator1ByDT);
94 void multiplySpatialTermByDeltaT()
98 local_assembler.setDTAssemblingMode(LocalAssembler::MultiplyOperator0ByDT);
104 return global_assembler.trialGridFunctionSpace();
110 return global_assembler.testGridFunctionSpace();
114 typename Traits::TrialGridFunctionSpace::Traits::SizeType globalSizeU ()
const
116 return trialGridFunctionSpace().globalSize();
120 typename Traits::TestGridFunctionSpace::Traits::SizeType globalSizeV ()
const
122 return testGridFunctionSpace().globalSize();
125 Assembler & assembler()
const {
return global_assembler; }
127 LocalAssembler & localAssembler()
const {
return local_assembler; }
130 void fill_pattern(Pattern & p)
const
135 PatternEngine & pattern_engine = local_assembler.localPatternAssemblerEngine(p);
136 global_assembler.assemble(pattern_engine);
140 typedef typename LocalAssembler::LocalExplicitPatternAssemblerEngine PatternEngine;
141 PatternEngine & pattern_engine = local_assembler.localExplicitPatternAssemblerEngine(p);
142 global_assembler.assemble(pattern_engine);
147 void preStage(
unsigned int stage,
const std::vector<Domain*> & x)
152 typedef typename LocalAssembler::LocalPreStageAssemblerEngine PreStageEngine;
153 local_assembler.setStage(stage);
154 PreStageEngine & prestage_engine = local_assembler.localPreStageAssemblerEngine(x);
155 global_assembler.assemble(prestage_engine);
159 void residual(
const Domain & x, Range & r)
const
164 typedef typename LocalAssembler::LocalResidualAssemblerEngine ResidualEngine;
165 ResidualEngine & residual_engine = local_assembler.localResidualAssemblerEngine(r,x);
166 global_assembler.assemble(residual_engine);
170 void jacobian(
const Domain & x, Jacobian & a)
const
175 typedef typename LocalAssembler::LocalJacobianAssemblerEngine JacobianEngine;
176 JacobianEngine & jacobian_engine = local_assembler.localJacobianAssemblerEngine(a,x);
177 global_assembler.assemble(jacobian_engine);
181 void explicit_jacobian_residual(
unsigned int stage,
const std::vector<Domain*> & x,
182 Jacobian & a, Range & r1, Range & r0)
187 local_assembler.setStage(stage);
189 typedef typename LocalAssembler::LocalExplicitJacobianResidualAssemblerEngine
190 ExplicitJacobianResidualEngine;
192 ExplicitJacobianResidualEngine & jacobian_residual_engine
193 = local_assembler.localExplicitJacobianResidualAssemblerEngine(a,r0,r1,x);
194 global_assembler.assemble(jacobian_residual_engine);
198 void jacobian_apply(
const Domain & update, Range & result)
const
200 if ((not la0.localOperator().isLinear) or (not la1.localOperator().isLinear))
202 global_assembler.assemble(local_assembler.localJacobianApplyAssemblerEngine(update, result));
206 void jacobian_apply(
const Domain & solution,
const Domain & update, Range & result)
const
208 if (la0.localOperator().isLinear and la1.localOperator().isLinear)
210 global_assembler.assemble(local_assembler.localJacobianApplyAssemblerEngine(solution, update, result));
214 template<
typename F,
typename X>
215 void interpolate (
unsigned stage,
const X& xold, F& f, X& x)
const
218 f.setTime(local_assembler.timeAtStage(stage));
220 go0.localAssembler().setTime(local_assembler.timeAtStage(stage));
223 go0.interpolate(xold,f,x);
230 auto es = trialGridFunctionSpace().entitySet();
231 if (es.comm().size() > 1)
233 CopyDataHandle<typename Traits::TrialGridFunctionSpace,X> data_handle(trialGridFunctionSpace(),x);
239 void setMethod (
const TimeSteppingParameterInterface<Real>& method_)
241 local_assembler.setMethod(method_);
245 void preStep (
const TimeSteppingParameterInterface<Real>& method_, Real time_, Real dt_)
247 local_assembler.setMethod(method_);
248 local_assembler.preStep(time_,dt_,method_.s());
266 Real suggestTimestep (Real dt)
const
268 Real suggested_dt =
std::min(la0.suggestTimestep(dt),la1.suggestTimestep(dt));
269 if (trialGridFunctionSpace().gridView().comm().
size()>1)
270 suggested_dt = trialGridFunctionSpace().gridView().comm().min(suggested_dt);
278 const_residual = Range(go0.testGridFunctionSpace());
281 void make_consistent(Jacobian& a)
const
283 go0.make_consistent(a);
288 return go0.matrixBackend();
293 return local_assembler.trialConstraints();
297 Assembler & global_assembler;
300 LocalAssemblerDT0 & la0;
301 LocalAssemblerDT1 & la1;
302 Range const_residual;
303 mutable LocalAssembler local_assembler;
Base class for Dune-Exceptions.
Definition: exceptions.hh:96
OneStepLocalPatternAssemblerEngine< OneStepLocalAssembler > LocalPatternAssemblerEngine
Definition: localassembler.hh:51
Dune::PDELab::TimeSteppingParameterInterface< Real > OneStepParameters
The type of the one step parameter object.
Definition: localassembler.hh:93
Traits::RangeField Real
The local operators type for real numbers e.g. time.
Definition: localassembler.hh:90
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
void interpolate(const F &f, const GFS &gfs, XG &xg)
interpolation from a given grid function
Definition: interpolate.hh:177
void copy_nonconstrained_dofs(const CG &cg, const XG &xgin, XG &xgout)
Definition: constraints.hh:987
constexpr auto min
Function object that returns the smaller of the given values.
Definition: hybridutilities.hh:506
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
Traits class for the grid operator.
Definition: gridoperatorutilities.hh:34
GFSU TrialGridFunctionSpace
The trial grid function space.
Definition: gridoperatorutilities.hh:37
GFSV TestGridFunctionSpace
The test grid function space.
Definition: gridoperatorutilities.hh:40
MB MatrixBackend
The matrix backend of the grid operator.
Definition: gridoperatorutilities.hh:51
Dune::PDELab::Backend::Matrix< MB, Domain, Range, JF > Jacobian
The type of the jacobian.
Definition: gridoperatorutilities.hh:72
Dune::PDELab::Backend::Vector< GFSV, RF > Range
The type of the range (residual).
Definition: gridoperatorutilities.hh:65
Dune::PDELab::Backend::Vector< GFSU, DF > Domain
The type of the domain (solution).
Definition: gridoperatorutilities.hh:58
GO::Traits::TrialGridFunctionSpaceConstraints TrialGridFunctionSpaceConstraints
The type of the trial grid function space constraints.
Definition: assemblerutilities.hh:61