1#ifndef ELLIPTC_MODEL_HH
2#define ELLIPTC_MODEL_HH
7#include <dune/fem/solver/timeprovider.hh>
8#include <dune/fem/io/parameter.hh>
10#include "modelinterface.hh"
11#include "probleminterface.hh"
12#include "../functions/gridfunctionexpression.hh"
13#include "../functions/gridfunctionwrapper.hh"
75 template<
class FunctionSpace,
class Gr
idPart,
class Problem = ProblemInterface<FunctionSpace> >
77 :
public DefaultModel<EllipticModel<FunctionSpace, GridPart, Problem> >
85 typedef typename InterfaceType::FunctionSpaceType FunctionSpaceType;
86 typedef typename InterfaceType::GridPartType GridPartType;
87 typedef typename InterfaceType::EntityType EntityType;
88 typedef typename InterfaceType::IntersectionType IntersectionType;
90 typedef typename FunctionSpaceType::DomainType DomainType;
91 typedef typename FunctionSpaceType::RangeType RangeType;
92 typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
93 typedef typename FunctionSpaceType::HessianRangeType HessianRangeType;
95 typedef typename FunctionSpaceType::DomainFieldType DomainFieldType;
96 typedef typename FunctionSpaceType::RangeFieldType RangeFieldType;
98 typedef Problem ProblemType ;
100 typedef typename ProblemType::DirichletBoundaryType DirichletBoundaryType;
101 typedef typename ProblemType::NeumannBoundaryType NeumannBoundaryType;
102 typedef typename ProblemType::RightHandSideType BulkForcesType;
103 typedef typename ProblemType::ExactSolutionType ExactSolutionType;
109 typedef typename TraitsType::ExactSolutionFunctionType ExactSolutionFunctionType;
111 typedef typename TraitsType::DirichletIndicatorType DirichletIndicatorType;
112 typedef typename TraitsType::NeumannIndicatorType NeumannIndicatorType;
113 typedef typename TraitsType::RobinIndicatorType RobinIndicatorType;
125 dirichletIndicator_(*this),
126 neumannIndicator_(*this),
127 robinIndicator_(*this),
128 lastRobinIndication_(false)
131 void setEntity(
const EntityType& entity)
const
136 bool setIntersection(
const IntersectionType& intersection)
const
138 lastRobinIndication_ = robinIndicator_.applies(intersection);
139 return lastRobinIndication_;
143 template<
class Entity,
class Po
int>
144 void flux(
const Entity& entity,
146 const RangeType& value,
147 const JacobianRangeType& jacobian,
148 JacobianRangeType&
flux)
const
155 template<
class Entity,
class Po
int>
157 const JacobianRangeType& DuBar,
158 const Entity& entity,
160 const RangeType& value,
161 const JacobianRangeType& jacobian,
162 JacobianRangeType&
flux)
const
165 const DomainType xGlobal = entity.geometry().global(coordinate(x));
166 problem_.secondOrderCoefficient(xGlobal, jacobian,
flux);
170 template<
class Entity,
class Po
int>
173 const RangeType& value,
174 const JacobianRangeType& jacobian,
175 RangeType& result)
const
181 template<
class Entity,
class Po
int>
183 const JacobianRangeType& DuBar,
184 const Entity& entity,
186 const RangeType& value,
187 const JacobianRangeType& jacobian,
188 RangeType& result)
const
190 const DomainType xGlobal = entity.geometry().global(coordinate(x));
192 if (
problem_.has(ProblemType::ZeroOrderCoefficient)) {
194 problem_.zeroOrderCoefficient(xGlobal, value, tmp);
197 if (
problem_.has(ProblemType::FirstOrderCoefficient)) {
199 problem_.firstOrderCoefficient(xGlobal, value, jacobian, tmp);
205 template<
class Intersection,
class Po
int>
208 const DomainType& unitOuterNormal,
209 const RangeType& value,
210 RangeType& result)
const
216 template<
class Intersection,
class Po
int>
218 const Intersection& intersection,
220 const DomainType& unitOuterNormal,
221 const RangeType& value,
222 RangeType& result)
const
224 if (!lastRobinIndication_) {
228 const DomainType xGlobal = intersection.inside()->geometry().global(coordinate(x));
230 problem_.robinData(xGlobal, value, result);
234 template<
class Entity,
class Po
int>
237 const RangeType& value,
238 const JacobianRangeType& jacobian,
239 const HessianRangeType& hessian,
240 RangeType& result)
const
242 const DomainType xGlobal = entity.geometry().global(coordinate(x));
245 if (
problem_.has(ProblemType::SecondOrderCoefficient)) {
246 problem_.secondOrderCoefficient(xGlobal, jacobian, hessian, result);
256 typedef BulkForcesFunctionType FunctionType;
258 return FunctionType(
"Bulk Forces", bulkForcesFunction_, gridPart);
266 typedef typename TraitsType::DirichletBoundaryGridFunctionType GridFunctionType;
267 typedef DirichletBoundaryFunctionType FunctionType;
269 auto gridFunction = GridFunctionType(
"Dirichlet Boundary Values", dirichletFunction_, gridPart);
271 return FunctionType(gridFunction, dirichletIndicator_);
278 typedef DirichletWeightFunctionType FunctionType;
282 return FunctionType(gridFunction, dirichletIndicator_);
288 NeumannBoundaryFunctionType
291 typedef typename TraitsType::NeumannBoundaryGridFunctionType GridFunctionType;
292 typedef NeumannBoundaryFunctionType FunctionType;
294 auto gridFunction = GridFunctionType(
"Neumann Boundary Values", neumannFunction_, gridPart);
296 return FunctionType(gridFunction, neumannIndicator_);
302 ExactSolutionFunctionType
305 typedef ExactSolutionFunctionType FunctionType;
307 return FunctionType(
"Exact Solution", solutionFunction_, gridPart);
310 DirichletIndicatorType dirichletIndicator()
const {
311 return dirichletIndicator_;
314 NeumannIndicatorType neumannIndicator()
const {
315 return neumannIndicator_;
318 RobinIndicatorType robinIndicator()
const {
319 return robinIndicator_;
336 DirichletBoundaryType dirichletFunction_;
337 NeumannBoundaryType neumannFunction_;
338 BulkForcesType bulkForcesFunction_;
339 ExactSolutionType solutionFunction_;
341 DirichletIndicatorType dirichletIndicator_;
342 NeumannIndicatorType neumannIndicator_;
343 RobinIndicatorType robinIndicator_;
345 mutable bool lastRobinIndication_;
348 template<
class FunctionSpace,
class Gr
idPart,
class Problem>
354 typedef Problem ProblemType;
356 typedef typename ProblemType::DirichletBoundaryType DirichletBoundaryType;
357 typedef typename ProblemType::NeumannBoundaryType NeumannBoundaryType;
358 typedef typename ProblemType::RightHandSideType BulkForcesType;
359 typedef typename ProblemType::ExactSolutionType ExactSolutionType;
361 typedef typename FunctionSpace::DomainType DomainType;
366 isSemiDefinite =
true
374 typedef FunctionSpace FunctionSpaceType;
375 typedef typename FunctionSpace::ScalarFunctionSpaceType ScalarFunctionSpaceType;
376 typedef GridPart GridPartType;
378 struct DirichletIndicator
381 DirichletIndicator(
const ModelType& model) : model_(model)
384 template<
class Intersection>
385 bool applies(
const Intersection& intersection)
const
387 const int bndId = intersection.boundaryId();
388 const DomainType center = intersection.geometry().center();
390 return model_.problem().isDirichletSegment(bndId, center);
393 const ModelType& model_;
396 typedef DirichletIndicator DirichletIndicatorType;
398 struct NeumannIndicator
399 : DefaultBoundaryIndicator<NeumannIndicator>
401 NeumannIndicator(
const ModelType& model) : model_(model)
404 template<
class Intersection>
405 bool applies(
const Intersection& intersection)
const
407 const int bndId = intersection.boundaryId();
408 const DomainType center = intersection.geometry().center();
410 return model_.problem().isNeumannSegment(bndId, center);
413 const ModelType& model_;
415 typedef NeumannIndicator NeumannIndicatorType;
417 struct RobinIndicator
418 : DefaultBoundaryIndicator<RobinIndicator>
420 RobinIndicator(
const ModelType& model) : model_(model)
423 template<
class Intersection>
424 bool applies(
const Intersection& intersection)
const
426 const int bndId = intersection.boundaryId();
427 const DomainType center = intersection.geometry().center();
429 return model_.problem().isRobinSegment(bndId, center);
432 const ModelType& model_;
434 typedef RobinIndicator RobinIndicatorType;
436 typedef GridFunctionAdapter<BulkForcesType, GridPartType> BulkForcesFunctionType;
437 typedef GridFunctionAdapter<ExactSolutionType, GridPartType> ExactSolutionFunctionType;
439 typedef GridFunctionAdapter<DirichletBoundaryType, GridPartType> DirichletBoundaryGridFunctionType;
441 BoundarySupportedFunction<DirichletBoundaryGridFunctionType, DirichletIndicatorType>
442 DirichletBoundaryFunctionType;
444 BoundarySupportedFunction<FractionGridFunction<ScalarFunctionSpaceType, GridPartType, 1L, 1UL>,
445 DirichletIndicatorType>
446 DirichletWeightFunctionType;
448 typedef GridFunctionAdapter<NeumannBoundaryType, GridPartType> NeumannBoundaryGridFunctionType;
450 BoundarySupportedFunction<NeumannBoundaryGridFunctionType, NeumannIndicatorType>
451 NeumannBoundaryFunctionType;
Default model implementation.
Definition: modelinterface.hh:330
Interface class for second order elliptic models.
Definition: modelinterface.hh:192
TraitsType::DirichletBoundaryFunctionType DirichletBoundaryFunctionType
A BoundarySupportedFunction which must be sub-ordinate to the DirichletIndicatorType.
Definition: modelinterface.hh:241
TraitsType::BulkForcesFunctionType BulkForcesFunctionType
A function modelling "force" terms in the bulk-phase.
Definition: modelinterface.hh:226
TraitsType::DirichletWeightFunctionType DirichletWeightFunctionType
A BoundarySupportedFunction which must be sub-ordinate to the DirichletIndicatorType.
Definition: modelinterface.hh:242
TraitsType::NeumannBoundaryFunctionType NeumannBoundaryFunctionType
A function modelling "force" terms in the bulk-phase.
Definition: modelinterface.hh:227
BulkForcesFunctionType bulkForcesFunction(const GridPartType &gridPart) const
Return a grid functin adapter for the external forces, see class Dune::Fem::GridFunctionAdapter.
Definition: ellipticmodel.hh:254
void fluxDivergence(const Entity &entity, const Point &x, const RangeType &value, const JacobianRangeType &jacobian, const HessianRangeType &hessian, RangeType &result) const
Definition: ellipticmodel.hh:235
ExactSolutionFunctionType exactSolutionFunction(const GridPartType &gridPart) const
Return a grid function for a "exact solution" for experimental convergence tests.
Definition: ellipticmodel.hh:303
ConstituentFlags
Definition: ellipticmodel.hh:369
void robinFlux(const Intersection &intersection, const Point &x, const DomainType &unitOuterNormal, const RangeType &value, RangeType &result) const
Definition: ellipticmodel.hh:206
const ProblemType & problem_
Pointer to the underlying problem.
Definition: ellipticmodel.hh:326
const ProblemType & problem() const
return reference to problem
Definition: ellipticmodel.hh:323
void linearizedFlux(const RangeType &uBar, const JacobianRangeType &DuBar, const Entity &entity, const Point &x, const RangeType &value, const JacobianRangeType &jacobian, JacobianRangeType &flux) const
Definition: ellipticmodel.hh:156
DirichletBoundaryFunctionType dirichletBoundaryFunction(const GridPartType &gridPart) const
Return a grid functin adapter for the Dirichlet boundary values, see class Dune::Fem::GridFunctionAda...
Definition: ellipticmodel.hh:264
EllipticModel(const ProblemType &problem)
Constructor taking problem reference.
Definition: ellipticmodel.hh:119
DirichletWeightFunctionType dirichletWeightFunction(const GridPartType &gridPart) const
Return the trivial constant one function as Dirichlet weight.
Definition: ellipticmodel.hh:276
void linearizedSource(const RangeType &uBar, const JacobianRangeType &DuBar, const Entity &entity, const Point &x, const RangeType &value, const JacobianRangeType &jacobian, RangeType &result) const
Definition: ellipticmodel.hh:182
void source(const Entity &entity, const Point &x, const RangeType &value, const JacobianRangeType &jacobian, RangeType &result) const
Definition: ellipticmodel.hh:171
void linearizedRobinFlux(const RangeType &uBar, const Intersection &intersection, const Point &x, const DomainType &unitOuterNormal, const RangeType &value, RangeType &result) const
Definition: ellipticmodel.hh:217
NeumannBoundaryFunctionType neumannBoundaryFunction(const GridPartType &gridPart) const
Return a grid functin adapter for the Neumann boundary values, see class Dune::Fem::GridFunctionAdapt...
Definition: ellipticmodel.hh:289
void flux(const Entity &entity, const Point &x, const RangeType &value, const JacobianRangeType &jacobian, JacobianRangeType &flux) const
Definition: ellipticmodel.hh:144
FractionGridFunction< typename FunctionSpace::FunctionSpaceType::ScalarFunctionSpaceType, GridPart, 1L, 1UL > oneFunction(const FunctionSpace &space, const GridPart &gridPart)
Generate a proper constant-one function from the given Fem::FunctionSpace and Fem::GridPart.
Definition: gridfunctionexpression.hh:157
Default boundary indicator: like EntireBoundaryIndicator<false>
Definition: boundaryindicator.hh:76
A structure defining some trivial default values for the template structure ModelTraits<ModelType>,...
Definition: modelinterface.hh:57
A model for a second order elliptic operator.
Definition: ellipticmodel.hh:78
Traits-template which has to be specialized for each individual model.
Definition: modelinterface.hh:48