DUNE-ACFEM (2.5.1)

robinmodel.hh
1 #ifndef __DUNE_ACFEM_MODELS_MODULES_ROBINMODEL_HH__
2 #define __DUNE_ACFEM_MODELS_MODULES_ROBINMODEL_HH__
3 
4 #include "../operatorparts/modeladapter.hh"
5 
6 namespace Dune {
7 
8  namespace ACFem {
9 
61  template<class FunctionSpace, class Indicator = EntireBoundaryIndicatorType>
63  : public OperatorPartsExpression<RobinBoundaryOperatorParts<FunctionSpace, Indicator> >
64  {
67  public:
68  typedef Indicator IndicatorType;
69  typedef FunctionSpace FunctionSpaceType;
70  typedef typename FunctionSpaceType::RangeType RangeType;
71  typedef typename FunctionSpaceType::DomainType DomainType;
72 
74  const std::string& name = "")
75  : indicator_(indicator),
76  name_(name == "" ? "Robin(1)" : name),
77  supported_(false)
78  {}
79 
80  std::string name() const
81  {
82  return name_;
83  }
84 
85  template<class Intersection>
86  bool setIntersection(const Intersection& intersection) const
87  {
88  supported_ = isDomainBoundary(intersection) && indicator_().applies(intersection);
89  return supported_;
90  }
91 
93  template<class Intersection, class Point>
94  void linearizedRobinFlux(const RangeType& uBar,
95  const Intersection& intersection,
96  const Point& x,
97  const DomainType& unitOuterNormal,
98  const RangeType& value,
99  RangeType& result) const
100  {
101  result = supported_ ? value : RangeType(0.); // it's that simple in this case ...
102  }
103 
104  protected:
106  const std::string name_;
107  mutable bool supported_;
108  };
109 
110  template<class FunctionSpace, class Indicator>
111  struct OperatorPartsTraits<RobinBoundaryOperatorParts<FunctionSpace, Indicator> >
112  : public DefaultOperatorPartsTraits<FunctionSpace>
113  {
116  {
117  isLinear = true,
118  isSymmetric = true,
119  isSemiDefinite = true
120  };
121 
124  hasFlux = false,
125  hasSources = false,
126  hasRobinFlux = true,
127  };
128  };
129 
131  template<class FunctionSpace>
132  class RobinBoundaryOperatorParts<FunctionSpace, EmptyBoundaryIndicatorType>
133  : public ZeroOperatorParts<FunctionSpace>,
134  public ExpressionTemplate<RobinBoundaryOperatorParts<FunctionSpace, EmptyBoundaryIndicatorType> >
135  {
137  public:
138  typedef FunctionSpace FunctionSpaceType;
139  typedef EmptyBoundaryIndicatorType IndicatorType;
140 
142  const std::string& name = "")
143  : BaseType(name == "" ? ("Robin(1)") : name)
144  {}
145  };
146 
148 
163  template<class Object, class Indicator = EntireBoundaryIndicatorType>
164  static inline
166  robinOperatorParts(const Object& object,
167  const BoundaryIndicatorInterface<Indicator>& where = Indicator(),
168  const std::string& name = "")
169  {
171  return OperatorPartsType(where, name);
172  }
173 
198  template<class Object, class Indicator = EntireBoundaryIndicatorType>
199  OperatorPartsAdapterModel<RobinBoundaryOperatorParts<typename Object::FunctionSpaceType, Indicator>,
200  typename Object::GridPartType>
201  robinZeroModel(const Object& object,
202  const BoundaryIndicatorInterface<Indicator>& where = Indicator())
203  {
205  typedef typename Object::GridPartType GridPartType;
206  return OperatorPartsAdapterModel<OperatorPartsType, GridPartType>(OperatorPartsType(where));
207  }
208 
221  template<class GridFunction, class Indicator = EntireBoundaryIndicatorType>
222  auto
223  robinBoundaryModel(const Fem::Function<typename GridFunction::FunctionSpaceType, GridFunction>& values,
224  const BoundaryIndicatorInterface<Indicator>& where = Indicator())
225  -> decltype(robinZeroModel(asImp(values),
226  where * neumannBoundaryModel(asImp(values), where).neumannIndicator())
227  +
228  neumannBoundaryModel(asImp(values), where))
229  {
230  auto neumannModel = neumannBoundaryModel(values, where);
231  auto robinIndicator = where * neumannModel.neumannIndicator();
232 
233  return robinZeroModel(asImp(values), robinIndicator) + neumannModel;
234  }
235 
237 
239 
241 
242  } // namespace ACFem
243 
244 } //Namespace Dune
245 
246 
247 #endif // __DUNE_ACFEM_MODELS_MODULES_ROBINMODEL_HH__
A simple interface class for a boundary-indicator.
Definition: boundaryindicator.hh:41
A (homogeneous) Robin-boundary model.
Definition: robinmodel.hh:64
Define a simple zero model to optimize expression templates.
Definition: zerooperatorparts.hh:31
bool isDomainBoundary(const Intersection &intersection)
Return true if at the global domain boundary.
Definition: boundaryindicator.hh:116
const Implementation & asImp(const Fem::BartonNackmanInterface< Interface, Implementation > &arg)
Up-cast to the implementation for any Fem::BartonNackmanInterface.
Definition: expressionoperations.hh:71
NeumannBoundaryModel< GridFunction, Indicator > neumannBoundaryModel(const Fem::Function< typename GridFunction::FunctionSpaceType, GridFunction > &values, const BoundaryIndicatorInterface< Indicator > &where=Indicator())
Generate a NeumannBoundaryModel from given grid-function and boundary indicator.
Definition: neumannmodel.hh:169
auto robinBoundaryModel(const Fem::Function< typename GridFunction::FunctionSpaceType, GridFunction > &values, const BoundaryIndicatorInterface< Indicator > &where=Indicator()) -> decltype(robinZeroModel(asImp(values), where *neumannBoundaryModel(asImp(values), where).neumannIndicator())+neumannBoundaryModel(asImp(values), where))
Generate a RobinBoundaryModel from given grid-function and boundary indicator.
Definition: robinmodel.hh:223
static RobinBoundaryOperatorParts< typename Object::FunctionSpaceType, Indicator > robinOperatorParts(const Object &object, const BoundaryIndicatorInterface< Indicator > &where=Indicator(), const std::string &name="")
Generate OperatorParts for (homogeneous) Robin boundary conditions.
Definition: robinmodel.hh:166
void linearizedRobinFlux(const RangeType &uBar, const Intersection &intersection, const Point &x, const DomainType &unitOuterNormal, const RangeType &value, RangeType &result) const
The linearized Robin-type flux term.
Definition: robinmodel.hh:94
OperatorPartsAdapterModel< RobinBoundaryOperatorParts< typename Object::FunctionSpaceType, Indicator >, typename Object::GridPartType > robinZeroModel(const Object &object, const BoundaryIndicatorInterface< Indicator > &where=Indicator())
Generate homogeneous Robin boundary conditions fitting the specified object.
Definition: robinmodel.hh:201
Provide up-cast functionality for expression templates.
Definition: expressionoperations.hh:37
Traits-template which has to be specialized for each individual model.
Definition: operatorparts.hh:36
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 16, 22:29, 2024)