DUNE-ACFEM (unstable)

robinmodel.hh
1 #ifndef __DUNE_ACFEM_MODELS_MODULES_ROBINMODEL_HH__
2 #define __DUNE_ACFEM_MODELS_MODULES_ROBINMODEL_HH__
3 
4 #include "../indicators/boundaryindicator.hh"
5 #include "../modelbase.hh"
6 #include "../expressiontraits.hh"
7 
8 namespace Dune {
9 
10  namespace ACFem::PDEModel {
11 
63  template<class FunctionSpace, class Indicator = EntireBoundaryIndicator>
65  : public ModelBase<FunctionSpace>
66  , public Expressions::SelfExpression<RobinBoundaryModel<FunctionSpace, Indicator> >
67  , public MPL::UniqueTags<ConditionalType<ExpressionTraits<Indicator>::isVolatile, VolatileExpression, void>,
68  ConditionalType<IsConstantExprArg<Indicator>::value, ConstantExpression, void>,
69  ConditionalType<IsTypedValue<Indicator>::value, TypedValueExpression, void>,
70  PositiveExpression,
71  SymmetricModel>
72  {
75  public:
76  typedef Indicator IndicatorType;
77 
78  using typename BaseType::DomainType;
79  using typename BaseType::RangeType;
80  using typename BaseType::BoundaryConditionsType;
81  using BaseType::dimRange;
82 
83  template<class IndicatorArg,
84  std::enable_if_t<(std::is_constructible<Indicator, IndicatorArg>::value
85  && std::is_default_constructible<IndicatorArg>::value
86  ), int> = 0>
87  RobinBoundaryModel(IndicatorArg&& indicator = IndicatorArg(), const std::string& name = "")
88  : indicator_(std::forward<IndicatorArg>(indicator)),
89  supported_(false, std::bitset<dimRange>()),
90  name_(name == "" ? "Robin(1)" : name)
91  {}
92 
93  template<class IndicatorArg,
94  std::enable_if_t<(std::is_constructible<Indicator, IndicatorArg>::value
95  && !std::is_default_constructible<IndicatorArg>::value
96  ), int> = 0>
97  RobinBoundaryModel(IndicatorArg&& indicator, const std::string& name = "")
98  : indicator_(std::forward<IndicatorArg>(indicator)),
99  supported_(false, std::bitset<dimRange>()),
100  name_(name == "" ? "Robin(1)" : name)
101  {}
102 
103  std::string name() const
104  {
105  return name_;
106  }
107 
108  protected:
109  enum {
112  };
113 
114  public:
116  template<class Intersection>
117  auto classifyBoundary(const Intersection& intersection)
118  {
119  supported_.first = IndicatorTraits<IndicatorType>::globalSupport || indicator_.applies(intersection);
120  return supported_;
121  }
122 
124  auto linearizedRobinFlux(const DomainType& unitOuterNormal,
125  const RangeType& value) const
126  {
127  if constexpr (globalSupport) {
128  return value;
129  } else if constexpr (emptySupport) {
130  return zero(value);
131  } else {
132  return supported_.first ? value : RangeType(0.);
133  }
134  }
135 
136  protected:
137  IndicatorType indicator_;
138  BoundaryConditionsType supported_;
139  std::string name_;
140  };
141 
143 
172  template<class Object, class Indicator = EntireBoundaryIndicator>
173  constexpr auto
174  robinZeroModel(const Object& object,
175  Indicator&& where = Indicator{},
176  const std::string& name = "")
177  {
178  typedef RobinBoundaryModel<typename Object::FunctionSpaceType, Indicator> ModelType;
179  return expressionClosure(ModelType(std::forward<Indicator>(where), name));
180  }
181 
182  template<class Object, class Indicator, std::enable_if_t<ExpressionTraits<Indicator>::isZero, int> = 0>
183  constexpr auto
184  robinZeroModel(const Object& object, Indicator&& where, const std::string& name = "")
185  {
186  return zeroModel(object);
187  }
188 
197  template<class GridFunction, class Indicator = EntireBoundaryIndicator>
198  constexpr auto
199  robinBoundaryModel(GridFunction&& values,
200  Indicator&& where = Indicator(),
201  const std::string& name = "")
202  {
203  return
205  std::forward<GridFunction>(values), std::forward<Indicator>(where), name)
206  +
208  std::forward<GridFunction>(values), std::forward<Indicator>(where), name);
209  }
210 
212 
214 
216 
217  } // namespace ACFem::PDEModel::
218 
219  namespace ACFem {
220 
222  using PDEModel::robinZeroModel;
223 
224  }
225 
226 } //Namespace Dune
227 
228 
229 #endif // __DUNE_ACFEM_MODELS_MODULES_ROBINMODEL_HH__
A (homogeneous) Robin-boundary model.
Definition: robinmodel.hh:72
constexpr decltype(auto) expressionClosure(T &&t)
Do-nothing default implementation for pathologic cases.
Definition: interface.hh:93
constexpr auto zero(T &&t)
Use the zero fraction as canonical zero element for scalars.
Definition: constantoperations.hh:80
auto classifyBoundary(const Intersection &intersection)
Definition: robinmodel.hh:117
auto linearizedRobinFlux(const DomainType &unitOuterNormal, const RangeType &value) const
Definition: robinmodel.hh:124
constexpr auto robinZeroModel(const Object &object, Indicator &&where=Indicator{}, const std::string &name="")
Generate homogeneous Robin boundary conditions fitting the specified object.
Definition: robinmodel.hh:174
constexpr auto robinBoundaryModel(GridFunction &&values, Indicator &&where=Indicator(), const std::string &name="")
Generate a RobinBoundaryModel from given grid-function and boundary indicator.
Definition: robinmodel.hh:199
auto zeroModel(const T &t, const std::string &name, F closure=F{})
Generate a zero model fitting the specified object.
Definition: zeromodel.hh:77
constexpr auto neumannBoundaryModel(Fct &&values, Indicator &&where=std::decay_t< Indicator >{}, const std::string &name="")
Generate NeumannBoundaryModel from given grid-function and boundary indicator.
Definition: neumannmodel.hh:189
Paraphrase isOne and isZero to indicator function talk.
Definition: boundaryindicator.hh:140
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
std::pair< bool, std::bitset< dimRange > > BoundaryConditionsType
The type returned by classifyBoundary().
Definition: modelbase.hh:98
typename FunctionSpaceType::DomainType DomainType
The type returned by classifyBoundary().
Definition: modelbase.hh:61
typename FunctionSpaceType::RangeType RangeType
The type returned by classifyBoundary().
Definition: modelbase.hh:62
static constexpr int dimRange
The type returned by classifyBoundary().
Definition: modelbase.hh:86
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 3, 22:32, 2024)