DUNE-ACFEM (2.5.1)

modelinterface.hh
1#ifndef __DUNE_ACFEM_MODELINTERFACE_HH__
2#define __DUNE_ACFEM_MODELINTERFACE_HH__
3
4#include <dune/fem/misc/bartonnackmaninterface.hh>
5#include <dune/fem/gridpart/common/gridpart.hh>
6#include <dune/fem/space/common/discretefunctionspace.hh>
7
8#include "../expressions/expressionoperations.hh"
9#include "../models/boundaryindicator.hh" // for EmptyBoundaryIndicator
10#include "../operators/functionals/zerofunctional.hh"
11#include "../operators/functionals/nonzerofunctional.hh"
12#include "../functions/boundarysupportedfunction.hh"
13#include "../functions/constantfunction.hh" // for ZeroGridFunction
14#include "../functions/gridfunctionexpression.hh"
15#include "../functions/boundaryfunctionexpression.hh"
16#include "operatorparts/zerooperatorparts.hh"
17
18namespace Dune {
19
20 namespace ACFem {
21
47 template<class Model>
49
55 template<class FunctionSpace, class GridPart>
57 {
59 typedef FunctionSpace FunctionSpaceType;
60
62 typedef typename FunctionSpaceType::ScalarFunctionSpaceType ScalarFunctionSpaceType;
63
65 typedef GridPart GridPartType;
66
69
80 typedef EmptyBoundaryIndicatorType DirichletIndicatorType;
81
90 typedef
94
116 typedef
121
129
138 typedef EmptyBoundaryIndicatorType NeumannIndicatorType;
139
150 typedef
154
160 template<class DiscreteFunctionSpace>
162 {
163 typedef DiscreteFunctionSpace DiscreteFunctionSpaceType;
165 };
167
168 };
169
189 template<class ModelType>
191 : public Fem::BartonNackmanInterface<ModelInterface<ModelType>, ModelType>
192 {
193 typedef ModelInterface ThisType;
194 typedef ModelType ImplementationType;
196 typedef Fem::BartonNackmanInterface<ThisType, ImplementationType> BaseType;
197 using BaseType::asImp;
198 protected:
199 ModelInterface() {}
200 ModelInterface(const ModelInterface& other) {}
201 ModelInterface& operator=(const ModelInterface& other) {}
202 public:
203 typedef typename TraitsType::FunctionSpaceType FunctionSpaceType;
204 typedef typename TraitsType::GridPartType GridPartType;
205 typedef typename GridPartType::template Codim<0>::EntityType EntityType;
206 typedef typename GridPartType::IntersectionType IntersectionType;
207
208 typedef typename FunctionSpaceType::DomainType DomainType;
209 typedef typename FunctionSpaceType::RangeType RangeType;
210 typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
211 typedef typename FunctionSpaceType::HessianRangeType HessianRangeType;
212
213 typedef typename FunctionSpaceType::DomainFieldType DomainFieldType;
214 typedef typename FunctionSpaceType::RangeFieldType RangeFieldType;
215
216 enum { dimDomain = FunctionSpaceType::dimDomain,
217 dimRange = FunctionSpaceType::dimRange };
218
219 typedef typename TraitsType::OperatorPartsType OperatorPartsType;
220
226 typedef typename TraitsType::BulkForcesFunctionType BulkForcesFunctionType;
227 typedef typename TraitsType::NeumannBoundaryFunctionType NeumannBoundaryFunctionType;
228 typedef typename TraitsType::NeumannIndicatorType NeumannIndicatorType;
229
231 template<class DiscreteFunctionSpace>
233 : public TraitsType::template ForcesFunctionalTraits<DiscreteFunctionSpace>
234 {};
236
241 typedef typename TraitsType::DirichletBoundaryFunctionType DirichletBoundaryFunctionType;
242 typedef typename TraitsType::DirichletWeightFunctionType DirichletWeightFunctionType;
243 typedef typename TraitsType::DirichletIndicatorType DirichletIndicatorType;
245
247 std::string name() const
248 {
249 return asImp().name();
250 }
251
253 OperatorPartsType operatorParts() const
254 {
255 return asImp().operatorParts();
256 }
257
263 BulkForcesFunctionType bulkForcesFunction(const GridPartType& gridPart) const {
264 return asImp().bulkForcesFunction(gridPart);
265 }
266
270 template<class DiscreteFunctionSpace>
271 typename TraitsType::template ForcesFunctionalTraits<DiscreteFunctionSpace>::FunctionalType
272 forcesFunctional(const DiscreteFunctionSpace& space) const
273 {
274 return asImp().forcesFunctional(space);
275 }
276
277 static_assert(std::is_same<typename DirichletBoundaryFunctionType::IndicatorType,
278 typename DirichletWeightFunctionType::IndicatorType>::value,
279 "DirichletBoundaryFunctionType and DirichletWeightFunctionType must be "
280 "BoundarySupportedFunction's sub-ordinate to the same BoundaryIndicator type.");
281
285 DirichletBoundaryFunctionType dirichletBoundaryFunction(const GridPartType& gridPart) const {
286 CHECK_INTERFACE_IMPLEMENTATION(asImp().dirichletBoundaryFunction(gridPart));
287 return asImp().dirichletBoundaryFunction(gridPart);
288 }
289
294 DirichletWeightFunctionType dirichletWeightFunction(const GridPartType& gridPart) const {
295 CHECK_INTERFACE_IMPLEMENTATION(asImp().dirichletWeightFunction(gridPart));
296 return asImp().dirichletWeightFunction(gridPart);
297 }
298
302 NeumannBoundaryFunctionType neumannBoundaryFunction(const GridPartType& gridPart) const {
303 return asImp().neumannBoundaryFunction(gridPart);
304 }
305
311 return asImp().dirichletIndicator();
312 }
313
319 return asImp().neumannIndicator();
320 }
321 };
322
327 template<class ModelType>
329 : public ModelInterface<ModelType>
330 {
331 typedef ModelType ImplementationType;
332 typedef ModelInterface<ImplementationType> BaseType;
335 typedef DefaultModelTraits<typename TraitsType::FunctionSpaceType,
336 typename TraitsType::GridPartType>
338 protected:
339 DefaultModel() {}
340 public:
341 typedef typename DefaultTraitsType::FunctionSpaceType FunctionSpaceType;
342 typedef typename DefaultTraitsType::GridPartType GridPartType;
343
344 typedef typename FunctionSpaceType::DomainType DomainType;
345 typedef typename FunctionSpaceType::RangeType RangeType;
346 typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
347 typedef typename FunctionSpaceType::HessianRangeType HessianRangeType;
348
349 typedef typename FunctionSpaceType::DomainFieldType DomainFieldType;
350 typedef typename FunctionSpaceType::RangeFieldType RangeFieldType;
351
352 enum {
353 dimDomain = FunctionSpaceType::dimDomain,
354 dimRange = FunctionSpaceType::dimRange
355 };
356
357 typedef typename BaseType::EntityType EntityType;
358 typedef typename BaseType::IntersectionType IntersectionType;
359
364
372 typedef typename TraitsType::OperatorPartsType OperatorPartsType;
373
375 template<class DiscreteFunctionSpace>
377 : public TraitsType::template ForcesFunctionalTraits<DiscreteFunctionSpace>
378 {};
379
381 std::string name() const
382 {
383 return "DefaultModel";
384 }
385
386 OperatorPartsType operatorParts() const
387 {
388 return OperatorPartsType();
389 }
390
392 BulkForcesFunctionType bulkForcesFunction(const GridPartType& gridPart) const
393 {
394 return BulkForcesFunctionType(gridPart);
395 }
396
398 template<class DiscreteFunctionSpace>
399 typename TraitsType::template ForcesFunctionalTraits<DiscreteFunctionSpace>::FunctionalType
400 forcesFunctional(const DiscreteFunctionSpace& space) const
401 {
403 }
404
407 {
410 }
411
413 DirichletWeightFunctionType dirichletWeightFunction(const GridPartType& gridPart) const {
414 typedef
416 OneFunctionType;
417 return DirichletWeightFunctionType(OneFunctionType(gridPart), DirichletIndicatorType());
418 }
419
420
422 NeumannBoundaryFunctionType neumannBoundaryFunction(const GridPartType& gridPart) const
423 {
426 }
427
430 return DirichletIndicatorType();
431 }
432
435 return NeumannIndicatorType();
436 }
437 };
438
445 template<class Model>
447 {
448 typedef Model ModelType;
450 protected:
451 typedef
452 Fem::DiscreteFunctionSpaceAdapter<typename InterfaceType::FunctionSpaceType,
453 typename InterfaceType::GridPartType>
454 DiscreteAdapterSpaceType;
455 typedef
456 typename InterfaceType::template ForcesFunctionalTraits<DiscreteAdapterSpaceType>::FunctionalType
457 AdaptedForcesFunctionalType;
458 enum {
459 allDirichlet =
460 std::is_same<typename InterfaceType::DirichletIndicatorType,
461 EntireBoundaryIndicatorType>::value
462 };
463 public:
464 enum ConstituentFlags {
465 hasFlux = InterfaceType::OperatorPartsType::hasFlux,
466 hasSources = InterfaceType::OperatorPartsType::hasSources,
467 hasRobinFlux = InterfaceType::OperatorPartsType::hasRobinFlux,
471 hasRobinBoundary = hasRobinFlux,
473 };
474 };
475
477 template<class Model>
479 : public ModelConstituents<Model>
480 {};
481
497 template<class Model>
498 void printConstituents(const Model& model, std::ostream& os = std::cout)
499 {
500 typedef ModelConstituents<Model> HasType;
501
502 os << "Constituents of model \"" << model.name() << "\"" << std::endl;
503 os << "Flux: " << std::to_string(HasType::hasFlux) << std::endl;
504 os << "Sources: " << std::to_string(HasType::hasSources) << std::endl;
505 os << "RobinFlux: " << std::to_string(HasType::hasRobinFlux) << std::endl;
506 os << "BulkForces: " << std::to_string(HasType::hasBulkForces) << std::endl;
507 os << "ForcesFunctional: " << std::to_string(HasType::hasForcesFunctional) << std::endl;
508 os << "DirichletBoundary: " << std::to_string(HasType::hasDirichletBoundary) << std::endl;
509 os << "NeumannBoundary: " << std::to_string(HasType::hasNeumannBoundary) << std::endl;
510 os << "RobinBoundary: " << std::to_string(HasType::hasRobinBoundary) << std::endl;
511 os << std::endl;
512
513 // also list the structure flags:
514 os << "isLinear: " << std::to_string(Model::OperatorPartsType::isLinear) << std::endl;
515 os << "isSymmetric: " << std::to_string(Model::OperatorPartsType::isSymmetric) << std::endl;
516 os << "isSemiDefinite: " << std::to_string(Model::OperatorPartsType::isSemiDefinite) << std::endl;
517
518 os << std::endl;
519 }
520
549 template<class DiscreteFunctionSpace, class LinearFunctional>
551 {
552 typedef DiscreteFunctionSpace DiscreteFunctionSpaceType;
553 protected:
554 typedef LinearFunctional FunctionalImplType;
555 typedef typename DiscreteFunctionSpaceType::FunctionSpaceType FunctionSpaceType;
556 typedef typename DiscreteFunctionSpaceType::GridPartType GridPartType;
557 typedef
558 Fem::DiscreteFunctionSpaceAdapter<FunctionSpaceType, GridPartType>
559 AdapterSpaceType;
560 enum {
561 isSameSpace = std::is_same<typename FunctionalImplType::DiscreteFunctionSpaceType,
562 DiscreteFunctionSpaceType>::value,
563 isAdapterSpace = std::is_same<AdapterSpaceType, DiscreteFunctionSpaceType>::value,
565 };
566 static_assert(isSameSpace || isAdapterSpace || isZeroFunctional,
567 "Behold! Invalid use of dummy classes!");
568 public:
569 // The hard requirement is that the type we construct here must
570 // define DiscreteFunctionSpace as DiscreteFunctionSpaceType
571 typedef
572 typename std::conditional<isZeroFunctional, // remap to suitable zero
574 typename std::conditional<isSameSpace, // identity
575 FunctionalImplType,
577 FunctionalType;
578 };
579
581
583
584 } // namespace ACFem
585
586} //Namespace Dune
587
588#endif // __DUNE_ACFEM_MODELINTERFACE_HH__
A function with potentially partial support on the boundary.
Definition: boundarysupportedfunction.hh:234
Default model implementation.
Definition: modelinterface.hh:330
NeumannIndicatorType neumannIndicator() const
Generate an object to identify parts of the boundary subject to Neumann boundary conditions.
Definition: modelinterface.hh:434
TraitsType::template ForcesFunctionalTraits< DiscreteFunctionSpace >::FunctionalType forcesFunctional(const DiscreteFunctionSpace &space) const
Generate an instance of a class defining a functional which forms part of the force-terms for the mod...
Definition: modelinterface.hh:400
DirichletIndicatorType dirichletIndicator() const
Generate an object to identify parts of the boundary subject to Dirichlet boundary conditions.
Definition: modelinterface.hh:429
std::string name() const
Print a descriptive name for debugging and output.
Definition: modelinterface.hh:381
DirichletWeightFunctionType dirichletWeightFunction(const GridPartType &gridPart) const
Generate an instance of a class defining a "left hand side" weight on the Dirichlet boundary conditio...
Definition: modelinterface.hh:413
BulkForcesFunctionType bulkForcesFunction(const GridPartType &gridPart) const
Generate an instance of a class defining the bulk-forces the model is subject to.
Definition: modelinterface.hh:392
DirichletBoundaryFunctionType dirichletBoundaryFunction(const GridPartType &gridPart) const
Generate an instance of a class defining Dirichlet boundary values as a Fem grid-function.
Definition: modelinterface.hh:406
NeumannBoundaryFunctionType neumannBoundaryFunction(const GridPartType &gridPart) const
Generate an instance of a class defining Neumann boundary values as a Fem grid-function.
Definition: modelinterface.hh:422
A grid-function which is constant with a scalar fractional value.
Definition: constantfunction.hh:598
Interface class for second order elliptic models.
Definition: modelinterface.hh:192
TraitsType::template ForcesFunctionalTraits< DiscreteFunctionSpace >::FunctionalType forcesFunctional(const DiscreteFunctionSpace &space) const
Generate an instance of a class defining a functional which forms part of the force-terms for the mod...
Definition: modelinterface.hh:272
NeumannBoundaryFunctionType neumannBoundaryFunction(const GridPartType &gridPart) const
Generate an instance of a class defining Neumann boundary values as a Fem grid-function.
Definition: modelinterface.hh:302
std::string name() const
Print a descriptive name for debugging and output.
Definition: modelinterface.hh:247
OperatorPartsType operatorParts() const
Return the integral kernels for the bilinear form.
Definition: modelinterface.hh:253
DirichletIndicatorType dirichletIndicator() const
Generate an object to identify parts of the boundary subject to Dirichlet boundary conditions.
Definition: modelinterface.hh:310
BulkForcesFunctionType bulkForcesFunction(const GridPartType &gridPart) const
Generate an instance of a class defining the bulk-forces the model is subject to.
Definition: modelinterface.hh:263
TraitsType::DirichletBoundaryFunctionType DirichletBoundaryFunctionType
A BoundarySupportedFunction which must be sub-ordinate to the DirichletIndicatorType.
Definition: modelinterface.hh:241
DirichletBoundaryFunctionType dirichletBoundaryFunction(const GridPartType &gridPart) const
Generate an instance of a class defining Dirichlet boundary values as a Fem grid-function.
Definition: modelinterface.hh:285
TraitsType::DirichletIndicatorType DirichletIndicatorType
A BoundarySupportedFunction which must be sub-ordinate to the DirichletIndicatorType.
Definition: modelinterface.hh:243
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
TraitsType::NeumannIndicatorType NeumannIndicatorType
A function modelling "force" terms in the bulk-phase.
Definition: modelinterface.hh:228
DirichletWeightFunctionType dirichletWeightFunction(const GridPartType &gridPart) const
Generate an instance of a class defining a "left hand side" weight on the Dirichlet boundary conditio...
Definition: modelinterface.hh:294
NeumannIndicatorType neumannIndicator() const
Generate an object to identify parts of the boundary subject to Neumann boundary conditions.
Definition: modelinterface.hh:318
Just a place-holder to aid in automatic type-deduction.
Definition: nonzerofunctional.hh:43
This is the famous "do-nothing" functional.
Definition: zerofunctional.hh:42
A grid-function always returning 0.
Definition: constantfunction.hh:352
Define a simple zero model to optimize expression templates.
Definition: zerooperatorparts.hh:31
const Implementation & asImp(const Fem::BartonNackmanInterface< Interface, Implementation > &arg)
Up-cast to the implementation for any Fem::BartonNackmanInterface.
Definition: expressionoperations.hh:71
void printConstituents(const Model &model, std::ostream &os=std::cout)
Examine the given model and print to the given stream was has been found.
Definition: modelinterface.hh:498
Helper structure to define an optional functional as part of the "right hand side".
Definition: modelinterface.hh:162
A structure defining some trivial default values for the template structure ModelTraits<ModelType>,...
Definition: modelinterface.hh:57
BoundarySupportedFunction< ZeroGridFunction< FunctionSpaceType, GridPartType >, NeumannIndicatorType > NeumannBoundaryFunctionType
A function modelling the "right hand side" inhomogeneous von Neumann as for inhomogeneous Robin bound...
Definition: modelinterface.hh:153
EmptyBoundaryIndicatorType NeumannIndicatorType
Something satisfying the BoundaryIndicatorInterface.
Definition: modelinterface.hh:138
ZeroOperatorParts< FunctionSpace > OperatorPartsType
The integral kernel of the bilinear form.
Definition: modelinterface.hh:68
FunctionSpaceType::ScalarFunctionSpaceType ScalarFunctionSpaceType
The compatible scalar-valued function space.
Definition: modelinterface.hh:62
BoundarySupportedFunction< ZeroGridFunction< FunctionSpaceType, GridPartType >, DirichletIndicatorType > DirichletBoundaryFunctionType
A BoundarySupportedFunction which must be sub-ordinate to the DirichletIndicatorType.
Definition: modelinterface.hh:93
FunctionSpace FunctionSpaceType
The FunctionSpace defining domain and range co-ordinates.
Definition: modelinterface.hh:59
GridPart GridPartType
The GridPart the model is meant for.
Definition: modelinterface.hh:65
BoundarySupportedFunction< FractionGridFunction< ScalarFunctionSpaceType, GridPartType, 1L, 1UL >, DirichletIndicatorType > DirichletWeightFunctionType
A scalar BoundarySupportedFunction which defines "weighted" Dirichlet values of the form.
Definition: modelinterface.hh:119
EmptyBoundaryIndicatorType DirichletIndicatorType
Something satisfying the BoundaryIndicatorInterface.
Definition: modelinterface.hh:80
ZeroGridFunction< FunctionSpaceType, GridPartType > BulkForcesFunctionType
A function modelling "force" terms in the bulk-phase.
Definition: modelinterface.hh:128
Definition: modelinterface.hh:378
A traits class in order to collect properties of expressions.
Definition: expressionoperations.hh:465
Utiliy class to aid in the definition of ModelInterface::ForcesFunctionalTraits.
Definition: modelinterface.hh:551
A helper class which identifies which components are provided by the given model.
Definition: modelinterface.hh:447
Helper structure to define an optional functional as part of the "right hand side".
Definition: modelinterface.hh:234
Traits-template which has to be specialized for each individual model.
Definition: modelinterface.hh:48
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)