DUNE-ACFEM (unstable)

modelfacade.hh
1 #ifndef __DUNE_ACFEM_MODELS_MODELFACADE_HH__
2 #define __DUNE_ACFEM_MODELS_MODELFACADE_HH__
3 
4 #include "expressions.hh"
5 
6 namespace Dune {
7 
8  namespace ACFem::PDEModel {
9 
43  template<class Model, std::enable_if_t<IsPDEModel<Model>::value, int> = 0>
44  auto modelFacade(Model&& m)
45  {
46  return closure(std::forward<Model>(m), PDEModel::AllMethodTags{});
47  }
48 
49 #ifndef DOXYGEN
50  template<class Model>
51  using ModelFacade = decltype(modelFacade(std::declval<Model>()));
52 #else
70  template<class ModelImpl>
72  {
73  typedef ModelBase<typename ModelImpl::DomainFunctionSpaceType,
74  typename ModelImpl::RangeFunctionSpaceType> ModelBaseType;
75  typedef ModelFacade ThisType;
76  typedef OperationTraits<IdentityOperation> FunctorType;
77  typedef
78  PDEModel::UnaryModelExpression<FunctorType, ModelImpl,
82  public:
83  typedef ModelImpl ModelType;
84  typedef ModelIntrospection::Traits<ModelType> TraitsType;
85 
86  typedef typename ModelType::DomainType DomainType;
87 
88  typedef typename ModelType::FunctionSpaceType FunctionSpaceType;
89  typedef typename ModelType::DomainFunctionSpaceType DomainFunctionSpaceType;
90  typedef typename ModelType::RangeFunctionSpaceType RangeFunctionSpaceType;
91 
92  typedef typename ModelType::RangeType RangeType;
93  typedef typename ModelType::JacobianRangeType JacobianRangeType;
94  typedef typename ModelType::HessianRangeType HessianRangeType;
95 
96  typedef typename ModelType::RangeRangeType RangeRangeType;
97  typedef typename ModelType::RangeJacobianRangeType RangeJacobianRangeType;
98  typedef typename ModelType::RangeHessianRangeType RangeHessianRangeType;
99 
100  typedef typename ModelType::DomainRangeType DomainRangeType;
101  typedef typename ModelType::DomainJacobianRangeType DomainJacobianRangeType;
102  typedef typename ModelType::DomainHessianRangeType DomainHessianRangeType;
103 
104  typedef typename ModelType::BoundaryConditionsType BoundaryConditionsType;
105 
106  static_assert(std::is_base_of<ModelBaseType, ModelType>::value,
107  "A PDE-model is required to derive from class ModelBase");
108 
110  ModelFacade(const ModelType& model)
111  : methodProvider_(model)
112  {}
113 
117  ModelFacade(const ModelFacade& other)
118  : methodProvider_(other.methodProvider_)
119  {}
120 
125  : methodProvider_(std::move(other.methodProvider_))
126  {}
127 
129  operator const ModelType&() const { return methodProvider_.model(); }
130 
132  operator ModelType&() { return methodProvider_.model(); }
133 
135  ModelType& model()
136  {
137  return methodProvider_.model();
138  }
139 
141  const ModelType& model() const
142  {
143  return methodProvider_.model();
144  }
145 
153  template<class Entity>
154  void bind(const Entity& entity)
155  {
156  model().bind(entity);
157  }
158 
164  void unbind()
165  {
166  model().unbind();
167  }
168 
205  template<class Intersection>
206  BoundaryConditionsType classifyBoundary(const Intersection& intersection)
207  {
208  return model().classifyBoundary(intersection);
209  }
210 
212  std::string name() const
213  {
214  return model().name();
215  }
216 
235  template<class Quadrature>
237  const DomainRangeType& value,
238  const DomainJacobianRangeType& jacobian) const
239  {
240  return methodProvider_.flux(x, value, jacobian);
241  }
242 
265  template<class Quadrature>
266  auto linearizedFlux(const DomainRangeType& uBar,
267  const DomainJacobianRangeType& DuBar,
269  const DomainRangeType& value,
270  const DomainJacobianRangeType& jacobian) const
271  {
272  return methodProvider_.linearizedFlux(uBar, DuBar, x, value, jacobian);
273  }
274 
286  template<class Quadrature>
288  const DomainRangeType& value,
289  const DomainJacobianRangeType& jacobian) const
290  {
291  return methodProvider_.source(x, value, jacobian);
292  }
293 
311  template<class Quadrature>
312  auto linearizedSource(const DomainRangeType& uBar,
313  const DomainJacobianRangeType& DuBar,
315  const DomainRangeType& value,
316  const DomainJacobianRangeType& jacobian) const
317  {
318  return methodProvider_.linearizedSource(uBar, DuBar, x, value, jacobian);
319  }
320 
343  template<class Quadrature>
345  const DomainType& unitOuterNormal,
346  const DomainRangeType& value,
347  const DomainJacobianRangeType& jacobian) const
348  {
349  return methodProvider_.robinFlux(x, unitOuterNormal, value, jacobian);
350  }
351 
369  template<class Quadrature>
370  auto linearizedRobinFlux(const DomainRangeType& uBar,
371  const DomainJacobianRangeType& DuBar,
373  const DomainType& unitOuterNormal,
374  const DomainRangeType& value,
375  const DomainJacobianRangeType& jacobian) const
376  {
377  return methodProvider_.linearizedRobinFlux(uBar, DuBar, x, unitOuterNormal, value, jacobian);
378  }
379 
397  template<class Quadrature>
399  const DomainType& unitOuterNormal,
400  const DomainRangeType& value,
401  const DomainJacobianRangeType& jacobian) const
402  {
403  return methodProvider_.singularFlux(x, unitOuterNormal, value, jacobian);
404  }
405 
428  template<class Quadrature>
429  auto linearizedSingularFlux(const DomainRangeType& uBar,
430  const DomainJacobianRangeType& DuBar,
432  const DomainType& unitOuterNormal,
433  const DomainRangeType& value,
434  const DomainJacobianRangeType& jacobian) const
435  {
436  return methodProvider_.linearizedSingularFlux(uBar, DuBar, x, unitOuterNormal, value, jacobian);
437  }
438 
454  template<class Quadrature>
456  const DomainRangeType& value,
457  const DomainJacobianRangeType& jacobian,
458  const DomainHessianRangeType& hessian) const
459  {
460  return methodProvider_.fluxDivergence(x, value, jacobian, hessian);
461  }
462 
483  template<class Quadrature>
485  const DomainRangeType& value) const
486  {
487  return methodProvider_.dirichlet(x, value);
488  }
489 
502  template<class Quadrature>
503  auto linearizedDirichlet(const DomainRangeType& uBar,
505  const DomainRangeType& value) const
506  {
507  return methodProvider_.linearizedDirichlet(uBar, x, value);
508  }
509 
510  friend std::ostream& operator<<(std::ostream& out, const ThisType& arg)
511  {
512  return out << arg.model();
513  }
514 
515  private:
516  MethodProvider methodProvider_;
517  };
518 #endif
519 
521 
523 
524  } // namespace ACFem::PDEModel::
525 
526  namespace ACFem {
527 
528  using PDEModel::modelFacade;
529  using PDEModel::ModelFacade;
530 
531  }
532 
533 } //Namespace Dune
534 
535 #endif // __DUNE_ACFEM_MODELS_MODELFACADE_HH__
A class defining the "closure" type of all supported model-method and method-call-signatures.
Definition: modelfacade.hh:72
void unbind()
Unbind from the previously bound entity.
Definition: modelfacade.hh:164
auto linearizedRobinFlux(const DomainRangeType &uBar, const DomainJacobianRangeType &DuBar, const QuadraturePoint< Quadrature > &x, const DomainType &unitOuterNormal, const DomainRangeType &value, const DomainJacobianRangeType &jacobian) const
The linearized Robin-type flux term.
Definition: modelfacade.hh:370
auto linearizedSingularFlux(const DomainRangeType &uBar, const DomainJacobianRangeType &DuBar, const QuadraturePoint< Quadrature > &x, const DomainType &unitOuterNormal, const DomainRangeType &value, const DomainJacobianRangeType &jacobian) const
The linearized "singular flux" term.
Definition: modelfacade.hh:429
auto flux(const QuadraturePoint< Quadrature > &x, const DomainRangeType &value, const DomainJacobianRangeType &jacobian) const
Evaluate in local coordinates.
Definition: modelfacade.hh:236
ModelFacade(ModelFacade &&other)
Move constructor.
Definition: modelfacade.hh:124
auto linearizedSource(const DomainRangeType &uBar, const DomainJacobianRangeType &DuBar, const QuadraturePoint< Quadrature > &x, const DomainRangeType &value, const DomainJacobianRangeType &jacobian) const
The linearized source term as function of local coordinates.
Definition: modelfacade.hh:312
auto source(const QuadraturePoint< Quadrature > &x, const DomainRangeType &value, const DomainJacobianRangeType &jacobian) const
The zero-order term as function of local coordinates.
Definition: modelfacade.hh:287
auto robinFlux(const QuadraturePoint< Quadrature > &x, const DomainType &unitOuterNormal, const DomainRangeType &value, const DomainJacobianRangeType &jacobian) const
The non-linearized Robin-type flux term.
Definition: modelfacade.hh:344
ModelType & model()
Getter for wrapped model, non-const version.
Definition: modelfacade.hh:135
auto linearizedDirichlet(const DomainRangeType &uBar, const QuadraturePoint< Quadrature > &x, const DomainRangeType &value) const
Linearized Dirichlet values.
Definition: modelfacade.hh:503
const ModelType & model() const
Getter for wrapped model, const version.
Definition: modelfacade.hh:141
auto singularFlux(const QuadraturePoint< Quadrature > &x, const DomainType &unitOuterNormal, const DomainRangeType &value, const DomainJacobianRangeType &jacobian) const
The non-linearized singular boundary "flux" term.
Definition: modelfacade.hh:398
ModelFacade(const ModelFacade &other)
Copy constructor.
Definition: modelfacade.hh:117
void bind(const Entity &entity)
Bind to the given entity.
Definition: modelfacade.hh:154
ModelFacade(const ModelType &model)
Constructor from Model.
Definition: modelfacade.hh:110
auto linearizedFlux(const DomainRangeType &uBar, const DomainJacobianRangeType &DuBar, const QuadraturePoint< Quadrature > &x, const DomainRangeType &value, const DomainJacobianRangeType &jacobian) const
Evaluate the linearized flux in local coordinates.
Definition: modelfacade.hh:266
BoundaryConditionsType classifyBoundary(const Intersection &intersection)
Bind to the given intersection and classify the components w.r.t.
Definition: modelfacade.hh:206
auto dirichlet(const QuadraturePoint< Quadrature > &x, const DomainRangeType &value) const
Dirichlet values.
Definition: modelfacade.hh:484
auto fluxDivergence(const QuadraturePoint< Quadrature > &x, const DomainRangeType &value, const DomainJacobianRangeType &jacobian, const DomainHessianRangeType &hessian) const
Compute the point-wise value of the flux-part of the operator, meaning the part of the differential o...
Definition: modelfacade.hh:455
std::string name() const
Print a descriptive name for debugging and output.
Definition: modelfacade.hh:212
General unary model expression template.
Definition: unaryexpression.hh:1685
auto modelFacade(Model &&m)
Generate the closure model for all supported model-methods.
Definition: modelfacade.hh:44
MakeIndexSequence< numMethodTags > AllMethodTags
Sequence of all supported methods.
Definition: modeltraits.hh:75
TraitsHelper::MethodSignaturesClosureType MethodSignaturesClosureType
A sequence with the closure patterns for each method.
Definition: modeltraits.hh:634
Fem::QuadraturePointWrapper< Quadrature > QuadraturePoint
Shortcut.
Definition: quadraturepoint.hh:23
A structure defining some basic default types and methods.
Definition: modelbase.hh:41
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 16, 22:29, 2024)