1#ifndef __DUNE_ACFEM_MODELS_MODULES_TRANSPORTMODEL_HH__
2#define __DUNE_ACFEM_MODELS_MODULES_TRANSPORTMODEL_HH__
4#include "../operatorparts/modeladapter.hh"
42 template<
class FunctionSpace,
class Velocity>
44 :
public OperatorPartsExpression<TransportOperatorParts<FunctionSpace, Velocity> >
50 typedef typename Velocity::LocalFunctionType LocalVelocityType;
52 typedef Velocity VelocityType;
53 typedef typename TraitsType::FunctionSpaceType FunctionSpaceType;
54 typedef typename VelocityType::GridPartType GridPartType;
56 typedef typename FunctionSpaceType::DomainType DomainType;
57 typedef typename FunctionSpaceType::RangeType RangeType;
58 typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
59 typedef typename FunctionSpaceType::HessianRangeType HessianRangeType;
62 dimDomain = FunctionSpaceType::dimDomain,
63 dimRange = FunctionSpaceType::dimRange,
64 dimWorld = GridPartType::dimensionworld
67 static_assert((int)VelocityType::FunctionSpaceType::dimRange == (
int)dimWorld && dimDomain == dimWorld,
68 "This is meant for dimensionworld vector-fields, "
69 "like fluids, deformations etc.");
71 typedef typename FunctionSpaceType::DomainFieldType DomainFieldType;
72 typedef typename FunctionSpaceType::RangeFieldType RangeFieldType;
76 TransportOperatorParts(
const Fem::Function<typename VelocityType::FunctionSpaceType, VelocityType>& velocity,
77 const std::string& name =
"")
78 : velocity_(velocity),
79 localVelocity_(velocity_()),
80 name_(name ==
"" ?
"(-U_iU_jD_iPhi_j+Bndry)" : name)
83 std::string name()
const
89 template<
class Entity>
92 localVelocity_.init(entity);
96 template<
class Intersection>
105 template<
class Entity,
class Po
int>
107 const JacobianRangeType& DuBar,
108 const Entity& entity,
110 const RangeType& value,
111 const JacobianRangeType& jacobian,
112 JacobianRangeType&
flux)
const
114 assert(&entity == &localVelocity_.entity());
118 typename VelocityType::RangeType velocity;
119 localVelocity_.evaluate(x, velocity);
122 for (
int i = 0; i < dimRange; ++i) {
123 for (
int j = 0; j < dimWorld; ++j) {
124 flux[i][j] = - value[i] * velocity[j];
134 template<
class Entity,
class Po
int>
137 const RangeType& value,
138 const JacobianRangeType& jacobian,
139 const HessianRangeType& hessian,
140 RangeType& result)
const
142 assert(&entity == &localVelocity_.entity());
144 typename VelocityType::RangeType velocity;
145 localVelocity_.evaluate(x, velocity);
146 typename VelocityType::JacobianRangeType velocityJacobian;
147 localVelocity_.jacobian(x, velocityJacobian);
149 jacobian.mv(velocity, result);
151 RangeFieldType velocityDivergence = 0.;
152 for (
int i = 0; i < dimDomain; ++i) {
153 velocityDivergence += velocityJacobian[i][i];
155 result.axpy(velocityDivergence, value);
159 template<
class Intersection,
class Po
int>
161 const Intersection& intersection,
163 const DomainType& unitOuterNormal,
164 const RangeType& value,
165 RangeType& result)
const
167 typename VelocityType::RangeType velocity;
168 localVelocity_.evaluate(x, velocity);
171 result *= (velocity * unitOuterNormal);
176 mutable LocalVelocityType localVelocity_;
177 const std::string name_;
180 template<
class FunctionSpace,
class Velocity>
181 struct OperatorPartsTraits<TransportOperatorParts<FunctionSpace, Velocity> >
182 :
public DefaultOperatorPartsTraits<FunctionSpace>
189 isSemiDefinite =
false,
213 template<
class Object,
class Velocity>
215 TransportOperatorParts<typename Object::FunctionSpaceType, Velocity>
217 const Fem::Function<typename Velocity::FunctionSpaceType, Velocity>& velocity,
218 const std::string& name =
"")
230 template<
class Object,
class Velocity>
232 OperatorPartsAdapterModel<TransportOperatorParts<typename Object::FunctionSpaceType, Velocity>,
typename Velocity::GridPartType>
234 const Fem::Function<typename Velocity::FunctionSpaceType, Velocity>& velocity,
235 const std::string& name =
"")
238 typedef typename Velocity::GridPartType GridPartType;
239 return OperatorPartsAdapterModel<OperatorPartsType, GridPartType>(OperatorPartsType(velocity, name));
Default model implementation.
Definition: operatorparts.hh:387
void flux(const Entity &entity, const Point &x, const RangeType &value, const JacobianRangeType &jacobian, JacobianRangeType &flux) const
Definition: operatorparts.hh:450
Interface class for second order elliptic models.
Definition: operatorparts.hh:92
Define a model for an advection term.
Definition: transportmodel.hh:45
static TransportOperatorParts< typename Object::FunctionSpaceType, Velocity > transportOperatorParts(const Object &object, const Fem::Function< typename Velocity::FunctionSpaceType, Velocity > &velocity, const std::string &name="")
Generate an advection-model object.
Definition: transportmodel.hh:216
ConstituentFlags
Definition: transportmodel.hh:193
void linearizedFlux(const RangeType &uBar, const JacobianRangeType &DuBar, const Entity &entity, const Point &x, const RangeType &value, const JacobianRangeType &jacobian, JacobianRangeType &flux) const
Definition: transportmodel.hh:106
bool setIntersection(const Intersection &intersection) const
Per-intersection initialization for the boundary contributions.
Definition: transportmodel.hh:97
void fluxDivergence(const Entity &entity, const Point &x, const RangeType &value, const JacobianRangeType &jacobian, const HessianRangeType &hessian, RangeType &result) const
!
Definition: transportmodel.hh:135
static OperatorPartsAdapterModel< TransportOperatorParts< typename Object::FunctionSpaceType, Velocity >, typename Velocity::GridPartType > transportModel(const Object &object, const Fem::Function< typename Velocity::FunctionSpaceType, Velocity > &velocity, const std::string &name="")
Generate an advection-model object.
Definition: transportmodel.hh:233
void setEntity(const Entity &entity) const
Per entity initialization, if that is needed.
Definition: transportmodel.hh:90
StructureFlags
Definition: transportmodel.hh:186
void linearizedRobinFlux(const RangeType &uBar, const Intersection &intersection, const Point &x, const DomainType &unitOuterNormal, const RangeType &value, RangeType &result) const
Definition: transportmodel.hh:160
Traits-template which has to be specialized for each individual model.
Definition: operatorparts.hh:36