DUNE-ACFEM (2.5.1)

dirichletmodel.hh
1#ifndef __DUNE_ACFEM_MODELS_MODULES_DIRICHLETMODEL_HH__
2#define __DUNE_ACFEM_MODELS_MODULES_DIRICHLETMODEL_HH__
3
4#include "../modelexpressionbase.hh"
5
6namespace Dune {
7
8 namespace ACFem {
9
42 template<class GridFunction, class Indicator = EntireBoundaryIndicatorType>
44 : public ModelExpression<DirichletBoundaryModel<GridFunction, Indicator> >
45 {
48 public:
49 typedef Indicator OuterIndicatorType;
50 typedef typename TraitsType::DirichletBoundaryFunctionType DirichletBoundaryFunctionType;
51 typedef typename TraitsType::DirichletWeightFunctionType DirichletWeightFunctionType;
52 typedef typename TraitsType::DirichletIndicatorType DirichletIndicatorType;
53 typedef typename TraitsType::FunctionSpaceType FunctionSpaceType;
54 typedef typename TraitsType::GridPartType GridPartType;
55
56 DirichletBoundaryModel(const Fem::Function<FunctionSpaceType, GridFunction>& function,
57 const
59 indicator = DirichletIndicatorType(),
60 const std::string& name = "")
61 : bndryFunction_(asImp(indicator) * asImp(function)),
62 name_(name == "" ? "Dirichlet(" + bndryFunction_().name() + ")" : name)
63 {}
64
65 std::string name() const
66 {
67 return name_;
68 }
69
70 DirichletBoundaryFunctionType dirichletBoundaryFunction(const GridPartType& gridPart) const
71 {
72 return bndryFunction_();
73 }
74
75 DirichletWeightFunctionType dirichletWeightFunction(const GridPartType& gridPart) const
76 {
77 return boundarySupportedFunction(oneFunction(bndryFunction_()), bndryFunction_().indicator());
78 }
79
80 DirichletIndicatorType dirichletIndicator() const {
81 return bndryFunction_().indicator();
82 }
83
85 const GridPartType& gridPart() const
86 {
87 return bndryFunction_().gridPart();
88 }
89
90 protected:
92 const std::string name_;
93 };
94
95 template<class GridFunction, class Indicator>
96 struct ModelTraits<DirichletBoundaryModel<GridFunction, Indicator> >
97 : public DefaultModelTraits<typename GridFunction::DiscreteFunctionSpaceType::FunctionSpaceType,
98 typename GridFunction::GridPartType>
99 {
100 protected:
101 typedef
102 DefaultModelTraits<typename GridFunction::DiscreteFunctionSpaceType::FunctionSpaceType,
103 typename GridFunction::GridPartType>
104 BaseType;
105 typedef Indicator OuterIndicatorType;
106 public:
108 isLinear = true,
109 isSymmetric = true,
110 isSemiDefinite = true
111 };
112
114 typedef
115 decltype(std::declval<OuterIndicatorType>() * std::declval<GridFunction>())
117
119 typedef
120 typename DirichletBoundaryFunctionType::IndicatorType
122
124 typedef
128 };
129
131 template<class GridFunction>
132 class DirichletBoundaryModel<GridFunction, EmptyBoundaryIndicatorType>
133 : public ZeroModel<typename GridFunction::FunctionSpaceType, typename GridFunction::GridPartType>
134 {
135 typedef
137 BaseType;
138 public:
139 typedef typename GridFunction::FunctionSpaceType FunctionSpaceType;
140 typedef EmptyBoundaryIndicatorType DirichletIndicatorType;
141
142 DirichletBoundaryModel(const Fem::Function<FunctionSpaceType, GridFunction>& function,
144 const std::string& name = "")
145 : BaseType(name == "" ? ("Dirichlet(" + asImp(function).name() + ")") : name)
146 {}
147 };
148
150
163 template<class GridFunction, class Indicator = EntireBoundaryIndicatorType>
165 dirichletBoundaryModel(const Fem::Function<typename GridFunction::FunctionSpaceType, GridFunction>& values,
166 const BoundaryIndicatorInterface<Indicator>& where = Indicator())
167 {
169 }
170
195 template<class Object, class Indicator = EntireBoundaryIndicatorType>
196 DirichletBoundaryModel<ZeroGridFunction<typename Object::FunctionSpaceType,
197 typename Object::GridPartType>, Indicator>
198 dirichletZeroModel(const Object& object,
199 const BoundaryIndicatorInterface<Indicator>& where = Indicator())
200 {
201 typedef
202 ZeroGridFunction<typename Object::FunctionSpaceType,
203 typename Object::GridPartType>
204 ZeroType;
205 return dirichletBoundaryModel(ZeroType(object.gridPart()), where);
206 }
207
209
211
213
214 } // namespace ACFem
215
216} //Namespace Dune
217
218
219#endif // __DUNE_ACFEM_MODELS_MODULES_DIRICHLETMODEL_HH__
A simple interface class for a boundary-indicator.
Definition: boundaryindicator.hh:41
A function with potentially partial support on the boundary.
Definition: boundarysupportedfunction.hh:234
A Dirichlet model.
Definition: dirichletmodel.hh:45
A grid-function always returning 0.
Definition: constantfunction.hh:352
Define a simple zero model to optimize expression templates.
Definition: zeromodel.hh:28
const Implementation & asImp(const Fem::BartonNackmanInterface< Interface, Implementation > &arg)
Up-cast to the implementation for any Fem::BartonNackmanInterface.
Definition: expressionoperations.hh:71
FractionGridFunction< typename FunctionSpace::FunctionSpaceType::ScalarFunctionSpaceType, GridPart, 1L, 1UL > oneFunction(const FunctionSpace &space, const GridPart &gridPart)
Generate a proper constant-one function from the given Fem::FunctionSpace and Fem::GridPart.
Definition: gridfunctionexpression.hh:157
BoundarySupportedFunction< GridFunction, Indicator > boundarySupportedFunction(const Fem::Function< typename GridFunction::FunctionSpaceType, GridFunction > &f, const BoundaryIndicatorInterface< Indicator > &c=EntireBoundaryIndicatorType())
Generate a function with partial support on the boundary.
Definition: boundarysupportedfunction.hh:604
DirichletBoundaryFunctionType::IndicatorType DirichletIndicatorType
Something satisfying the BoundaryIndicatorInterface.
Definition: dirichletmodel.hh:121
const GridPartType & gridPart() const
Return the GridPart (non-interface method)
Definition: dirichletmodel.hh:85
DirichletBoundaryModel< GridFunction, Indicator > dirichletBoundaryModel(const Fem::Function< typename GridFunction::FunctionSpaceType, GridFunction > &values, const BoundaryIndicatorInterface< Indicator > &where=Indicator())
Generate a DirichletBoundaryModel from given grid-function and boundary indicator.
Definition: dirichletmodel.hh:165
decltype(std::declval< OuterIndicatorType >() *std::declval< GridFunction >()) DirichletBoundaryFunctionType
A BoundarySupportedFunction which must be sub-ordinate to the DirichletIndicatorType.
Definition: dirichletmodel.hh:116
DirichletBoundaryModel< ZeroGridFunction< typename Object::FunctionSpaceType, typename Object::GridPartType >, Indicator > dirichletZeroModel(const Object &object, const BoundaryIndicatorInterface< Indicator > &where=Indicator())
Generate homogeneous Dirichlet boundary conditions fitting the specified object.
Definition: dirichletmodel.hh:198
BoundarySupportedFunction< decltype(oneFunction(std::declval< GridFunction >())), DirichletIndicatorType > DirichletWeightFunctionType
A scalar BoundarySupportedFunction which defines "weighted" Dirichlet values of the form.
Definition: dirichletmodel.hh:127
Traits-template which has to be specialized for each individual model.
Definition: modelinterface.hh:48
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Aug 13, 22:30, 2024)