DUNE-ACFEM (unstable)

divergencemodel.hh
1 #ifndef __DUNE_ACFEM_MODELS_MODULES_DIVERGENCEMODEL_HH__
2 #define __DUNE_ACFEM_MODELS_MODULES_DIVERGENCEMODEL_HH__
3 
4 #include <dune/fem/gridpart/common/gridpart.hh>
5 
6 #include "../../common/gridfunctionspace.hh"
7 #include "../../expressions/terminal.hh"
8 #include "../modelbase.hh"
9 #include "../expressiontraits.hh"
10 
11 namespace Dune {
12 
13  namespace ACFem::PDEModel {
14 
43  template<class FunctionSpace>
45  : public ModelBase<FunctionSpace, typename FunctionSpace::ScalarFunctionSpaceType>
46  , public Expressions::SelfExpression<DivergenceModel<FunctionSpace> >
47  , public TypedValueExpression
48  {
49  static_assert(FunctionSpace::dimRange == FunctionSpace::dimDomain,
50  "DomainFunctionSpace must be a vector field with dimRange == dimDomain");
51  using ThisType = DivergenceModel;
53  public:
54  using typename BaseType::DomainJacobianRangeType;
55  using typename BaseType::RangeRangeType;
57 
58  DivergenceModel(const std::string& name)
59  : name_(name == "" ? "(div U)" : name)
60  {}
61 
62  std::string name() const
63  {
64  return name_;
65  }
66 
68  RangeRangeType linearizedSource(const DomainJacobianRangeType& jacobian) const
69  {
70  RangeRangeType result(jacobian[0][0]);
71  for (int i = 0; i < domainDimRange; ++i) {
72  result += jacobian[i][i];
73  }
74  return result;
75  }
76 
77  protected:
78  const std::string name_;
79  };
80 
82 
83 
94  template<class Object,
95  std::enable_if_t<Object::FunctionSpaceType::ScalarFunctionSpaceType::dimRange == 1, int> = 0>
96  static inline auto
97  divergenceModel(const Object& object, const std::string& name = "")
98  {
99  using FunctionSpace = typename Object::FunctionSpaceType;
100  return expressionClosure(DivergenceModel<typename Fem::ToNewDimRangeFunctionSpace<FunctionSpace, FunctionSpace::dimDomain>::Type>(name));
101  }
102 
106  template<class GridPartTraits>
107  static inline auto
108  divergenceModel(const Fem::GridPartInterface<GridPartTraits>& gridPart,
109  const std::string& name = "")
110  {
111  using GridPartType = typename Fem::GridPartInterface<GridPartTraits>::GridPartType;
112  return divergenceModel(GridFunctionSpace<GridPartType>{}, name);
113  }
114 
116 
118 
120 
121  } // namespace ACFem::PDEModel
122 
123  namespace ACFem {
124 
126 
127  }
128 
129 } //Namespace Dune
130 
131 
132 #endif // __DUNE_ACFEM_MODELS_MODULES_DIVERGENCEMODEL_HH__
A divergence model, for example to implement divergence constraints.
Definition: divergencemodel.hh:48
static constexpr int domainDimRange
Definition: modelbase.hh:88
constexpr decltype(auto) expressionClosure(T &&t)
Do-nothing default implementation for pathologic cases.
Definition: interface.hh:93
static auto divergenceModel(const Fem::GridPartInterface< GridPartTraits > &gridPart, const std::string &name="")
Generate a DivergenceModel from a GridPart, using ctype as field and dimensionWorld as dimension.
Definition: divergencemodel.hh:108
RangeRangeType linearizedSource(const DomainJacobianRangeType &jacobian) const
The linearized source term as function of local coordinates.
Definition: divergencemodel.hh:68
Terminals may derive from this class to express that they are expressions.
Definition: terminal.hh:25
A structure defining some basic default types and methods.
Definition: modelbase.hh:41
typename DomainFunctionSpaceType::JacobianRangeType DomainJacobianRangeType
The type returned by classifyBoundary().
Definition: modelbase.hh:71
typename RangeFunctionSpaceType::RangeType RangeRangeType
The type returned by classifyBoundary().
Definition: modelbase.hh:77
static constexpr int domainDimRange
Definition: modelbase.hh:88
A tag structure signalling that this expression carries its value in its type.
Definition: tags.hh:100
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (Apr 29, 22:29, 2024)