DUNE-ACFEM (unstable)

incompressibletransportmodel.hh
1 #ifndef __DUNE_ACFEM_MODELS_MODULES_INCOMPRESSIBLETRANSPORTMODEL_HH__
2 #define __DUNE_ACFEM_MODELS_MODULES_INCOMPRESSIBLETRANSPORTMODEL_HH__
3 
4 #include <dune/fem/function/localfunction/const.hh>
5 
6 #include "../../expressions/terminal.hh"
7 
8 #include "../modelbase.hh"
9 
10 namespace Dune {
11 
12  namespace ACFem::PDEModel {
13 
44  template<class FunctionSpace, class GridFunction>
46  : public ModelBase<FunctionSpace>
47  , public Expressions::SelfExpression<IncompressibleTransportModel<FunctionSpace, GridFunction> >
48  {
50  "GridFunction must provide a local function");
51 
54  protected:
55  using LocalFunctionType = Fem::ConstLocalFunction<std::decay_t<GridFunction> >;
56  public:
57  using GridFunctionType = GridFunction;
58  using typename BaseType::RangeType;
59  using typename BaseType::JacobianRangeType;
60  using BaseType::dimDomain;
61  using BaseType::dimRange;
62 
63  enum {
64  dimWorld = dimDomain,
65  };
66 
67  static_assert((int)std::decay_t<GridFunctionType>::FunctionSpaceType::dimRange == (int)dimWorld
68  &&
69  (int)dimDomain == (int)dimWorld,
70  "This is meant for dimensionworld vector-fields, "
71  "like fluids, deformations etc.");
72 
73  // Interface methods that need to be reimplemented
74 
75  template<class FunctionArg, std::enable_if_t<std::is_constructible<LocalFunctionType, FunctionArg>::value, int> = 0>
76  IncompressibleTransportModel(FunctionArg&& velocity, const std::string& name = "")
77  : localFunction_(std::forward<FunctionArg>(velocity))
78  , name_(name == "" ? "(-U_iU_jD_iPhi_j+Bndry)" : name)
79  {}
80 
81  std::string name() const
82  {
83  return name_;
84  }
85 
87  template<class Entity>
88  void bind(const Entity& entity)
89  {
90  localFunction_.bind(entity);
91  }
92 
94  void unbind()
95  {
96  localFunction_.unbind();
97  }
98 
100  template<class Quadrature>
102  const JacobianRangeType& jacobian) const
103  {
104  const auto velocity = localFunction_.evaluate(x);
105 
106  RangeType result;
107  jacobian.mv(velocity, result);
108  return result;
109  }
110 
111  protected:
112  LocalFunctionType localFunction_;
113  std::string name_;
114  };
115 
117 
130  template<class Object, class Velocity>
131  constexpr auto
133  Velocity&& velocity,
134  const std::string& name = "")
135  {
136  return expressionClosure(IncompressibleTransportModel<typename std::decay_t<Object>::FunctionSpaceType, Velocity>(std::forward<Velocity>(velocity), name));
137  }
138 
139  template<class Object, class Velocity, std::enable_if_t<ExpressionTraits<Velocity>::isZero, int> = 0>
140  constexpr auto
141  incompressibleTransportModel(Object&& object,
142  Velocity&& velocity,
143  const std::string& name = "")
144  {
145  return zeroModel(object, name);
146  }
147 
149 
151 
153 
154  } // namespace ACFem::PDEModel
155 
156  namespace ACFem {
157 
158  using PDEModel::incompressibleTransportModel;
159 
160  }
161 
162 } //Namespace Dune
163 
164 
165 #endif // __DUNE_ACFEM_MODELS_MODULES_INCOMPRESSIBLETRANSPORTMODEL_HH__
Define a model for an advection term with a divergence-free velocity field.
Definition: incompressibletransportmodel.hh:48
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 linearizedSource(const QuadraturePoint< Quadrature > &x, const JacobianRangeType &jacobian) const
The linearized source term as function of local coordinates.
Definition: incompressibletransportmodel.hh:101
void unbind()
Unbind from the previously bound entity.
Definition: incompressibletransportmodel.hh:94
void bind(const Entity &entity)
Bind to the given entity.
Definition: incompressibletransportmodel.hh:88
constexpr auto incompressibleTransportModel(Object &&object, Velocity &&velocity, const std::string &name="")
Generate an advection-model object.
Definition: incompressibletransportmodel.hh:132
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
A structure defining some basic default types and methods.
Definition: modelbase.hh:41
typename FunctionSpaceType::JacobianRangeType JacobianRangeType
The type returned by classifyBoundary().
Definition: modelbase.hh:63
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
static constexpr int dimDomain
The type returned by classifyBoundary().
Definition: modelbase.hh:85
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 16, 22:29, 2024)