DUNE-ACFEM (unstable)

bulkloadmodel.hh
1 #ifndef __DUNE_ACFEM_MODELS_MODULES_BULKLOADMODEL_HH__
2 #define __DUNE_ACFEM_MODELS_MODULES_BULKLOADMODEL_HH__
3 
4 #include "../../functions/localfunctiontraits.hh"
5 #include "../../functions/functiontraits.hh"
6 #include "../modelbase.hh"
7 
8 namespace Dune {
9 
10  namespace ACFem::PDEModel {
11 
40  template<class GridFunction>
42  : public ModelBase<typename std::decay_t<GridFunction>::FunctionSpaceType>
43  , public Expressions::SelfExpression<BulkLoadFunctionModel<GridFunction> >
44  , public MPL::UniqueTags<ConditionalType<IsConstantExprArg<GridFunction>::value, ConstantExpression, void>,
45  ConditionalType<IsTypedValue<GridFunction>::value, TypedValueExpression, void> >
46  {
48  "GridFunction must provide a local function");
49 
52  using LocalFunctionType = Fem::ConstLocalFunction<std::decay_t<GridFunction> >;
53  public:
54  using typename BaseType::RangeType;
55 
56  template<class FunctionArg, std::enable_if_t<std::is_constructible<LocalFunctionType, FunctionArg>::value, int> = 0>
57  BulkLoadFunctionModel(FunctionArg&& function, const std::string& name = "")
58  : localFunction_(std::forward<FunctionArg>(function))
59  , name_(name == "" ? "(" + localFunction_.gridFunction().name() + ", . )" : name)
60  {}
61 
62  std::string name() const
63  {
64  return name_;
65  }
66 
68  template<class Entity>
69  void bind(const Entity& entity)
70  {
71  localFunction_.bind(entity);
72  }
73 
75  void unbind()
76  {
77  localFunction_.unbind();
78  }
79 
81  template<class Quadrature>
82  RangeType source(const QuadraturePoint<Quadrature> &x) const
83  {
84  return localFunction_.evaluate(x);
85  }
86 
87  protected:
88  LocalFunctionType localFunction_;
89  std::string name_;
90  };
91 
93 
108  template<class Fct,
111  ), int> = 0>
112  constexpr auto bulkLoadFunctionModel(Fct&& f, const std::string& name = "")
113  {
114  return expressionClosure(BulkLoadFunctionModel<Fct>(std::forward<Fct>(f), name));
115  }
116 
121  template<class Fct, std::enable_if_t<GridFunction::HasRegularity<Fct, 1UL>::value, int> = 0>
122  constexpr auto bulkLoadFunctionModel(Fct&& f, const std::string& name = "")
123  {
124  using namespace Literals;
125  return bulkLoadFunctionModel(gridFunction(f.gridPart(), std::forward<Fct>(f), 0_c), name);
126  }
127 
128  template<class Fct, std::enable_if_t<ExpressionTraits<Fct>::isZero, int> = 0>
129  constexpr auto bulkLoadFunctionModel(Fct&& f, const std::string& name = "")
130  {
131  return zeroModel(f);
132  }
133 
135 
137 
139 
140  } // namespace ACFem::PDEModel
141 
142  namespace ACFem {
143 
145 
146  }
147 
148 } //Namespace Dune
149 
150 
151 #endif // __DUNE_ACFEM_MODELS_MODULES_BULKLOADMODEL_HH__
Wrap an existing GridFunction into a model which only conatains this ModelConstituent.
Definition: bulkloadmodel.hh:46
constexpr decltype(auto) expressionClosure(T &&t)
Do-nothing default implementation for pathologic cases.
Definition: interface.hh:93
std::is_base_of< Tag, std::decay_t< A > > HasTag
Evaluate to std::true_type if std::decay_t<A> is derived from Tag, otherwise to std::false_type.
Definition: tags.hh:176
auto gridFunction(const GridPart &gridPart, T &&t, IndexConstant< MaxOrder > maxOrder=IndexConstant< MaxOrder >{}, IndexConstant< IndeterminateId > id=IndexConstant< IndeterminateId >{})
Generate a BindableGridFunction which wraps a copy of T.
Definition: gridfunction.hh:23
RangeType source(const QuadraturePoint< Quadrature > &x) const
Definition: bulkloadmodel.hh:82
void unbind()
Definition: bulkloadmodel.hh:75
constexpr auto bulkLoadFunctionModel(Fct &&f, const std::string &name="")
Generate a BulkLoadFunctionModel for the "right hand side".
Definition: bulkloadmodel.hh:112
void bind(const Entity &entity)
Definition: bulkloadmodel.hh:69
auto zeroModel(const T &t, const std::string &name, F closure=F{})
Generate a zero model fitting the specified object.
Definition: zeromodel.hh:77
Fem::QuadraturePointWrapper< Quadrature > QuadraturePoint
Shortcut.
Definition: quadraturepoint.hh:23
Terminals may derive from this class to express that they are expressions.
Definition: terminal.hh:25
Definition: functiontraits.hh:98
A structure defining some basic default types and methods.
Definition: modelbase.hh:41
typename FunctionSpaceType::RangeType RangeType
The type returned by classifyBoundary().
Definition: modelbase.hh:62
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 3, 22:32, 2024)