5#ifndef __DUNE_ACFEM_PARAMETER_INTERFACE_HH__
6#define __DUNE_ACFEM_PARAMETER_INTERFACE_HH__
8#include <dune/fem/misc/bartonnackmaninterface.hh>
10#include "../expressions/expressionoperations.hh"
48 template<
class Field,
int dim>
51 enum { dimension = dim };
52 typedef Field FieldType;
53 typedef FieldVector<FieldType, dimension> ValueType;
57 template<
class ParameterImpl>
58 struct ParameterTraits
61 struct DummyParameterSpace {
62 typedef void ScalarParameterSpaceType;
63 typedef void FieldType;
64 typedef void ValueType;
65 enum { dimension = -1 };
67 typedef DummyParameterSpace ParameterSpaceType;
77 template<
class ParameterImpl>
79 :
public Dune::Fem::BartonNackmanInterface<ParameterInterface<ParameterImpl>, ParameterImpl>
82 typedef ParameterImpl ImplementationType;
83 typedef Dune::Fem::BartonNackmanInterface<ThisType, ImplementationType> BaseType;
84 typedef ParameterTraits<ParameterImpl> TraitsType;
91 typedef typename TraitsType::ParameterSpaceType ParameterSpaceType;
92 typedef typename ParameterSpaceType::ScalarParameterSpaceType ScalarParameterSpaceType;
93 enum { dimension = ParameterSpaceType::dimension };
94 typedef typename ParameterSpaceType::FieldType FieldType;
95 typedef typename ParameterSpaceType::ValueType ValueType;
106 template<
class ParameterImpl>
111 typedef ParameterTraits<ParameterImpl> TraitsType;
117 typedef typename TraitsType::ParameterSpaceType ParameterSpaceType;
118 typedef typename ParameterSpaceType::ScalarParameterSpaceType ScalarParameterSpaceType;
119 enum { dimension = ParameterSpaceType::dimension };
120 typedef typename ParameterSpaceType::FieldType FieldType;
121 typedef typename ParameterSpaceType::ValueType ValueType;
142 template<
class Field,
int dim>
145 typedef Field FieldType;
146 enum { dimension = dim };
154 template<
class Value>
163 enum { dimension = ParameterSpaceType::dimension };
164 typedef typename ParameterSpaceType::FieldType FieldType;
165 typedef typename ParameterSpaceType::ValueType ValueType;
172 : value_(Fem::Parameter::getValue<ValueType>(configKey))
177 : value_(Fem::Parameter::getValue<ValueType>(configKey, defaultValue))
180 ValueType value()
const {
return value_; }
186 template<
class Value>
187 struct ParameterTraits<TrivialParameter<Value> >
189 typedef typename ParameterSpaceTraits<Value>::ParameterSpaceType ParameterSpaceType;
192 template<
class Value>
193 TrivialParameter<Value> P(
const Value& s)
195 return TrivialParameter<Value>(s);
199 template<
class Value>
208 enum { dimension = ParameterSpaceType::dimension };
209 typedef typename ParameterSpaceType::FieldType FieldType;
210 typedef typename ParameterSpaceType::ValueType ValueType;
213 ValueType
value()
const { ValueType(0); }
216 template<
class Value>
217 struct ParameterTraits<ZeroParameter<Value> >
219 typedef typename ParameterSpaceTraits<Value>::ParameterSpaceType ParameterSpaceType;
224 struct ParameterValue
226 enum { isParameter = std::is_base_of<ParameterInterface<Type>, Type>::value };
228 template<
class Value,
bool isParameter>
229 struct ParameterValueHelper;
231 template<
class Value>
232 struct ParameterValueHelper<Value, false>
234 typedef Value ValueType;
235 typedef const Value& ResultType;
236 static ResultType value(
const Value& arg) {
return arg; }
239 template<
class Parameter>
240 struct ParameterValueHelper<Parameter, true>
242 typedef typename Parameter::ValueType ValueType;
243 typedef ValueType ResultType;
244 static ResultType value(
const Parameter& arg) {
return arg.value(); }
247 typedef typename ParameterValueHelper<Type, isParameter>::ResultType ResultType;
248 typedef typename ParameterValueHelper<Type, isParameter>::ValueType ValueType;
250 static ResultType value(
const Type& arg) {
251 return ParameterValueHelper<Type, isParameter>::value(arg);
262 template<
class Value>
265 return ParameterValue<Value>::value(value);
Just for completeness, there is no default implementation.
Definition: parameterinterface.hh:109
Parameters are quasi-constant quantities, like the time-step size in one time-step when solving trans...
Definition: parameterinterface.hh:80
ValueType value() const
Return the current value of the parameter.
Definition: parameterinterface.hh:102
A simple wrapper: a really constant parameter.
Definition: parameterinterface.hh:158
TrivialParameter(const ValueType &value)
Construct the parameter from a verbatim value.
Definition: parameterinterface.hh:168
TrivialParameter(const std::string &configKey)
Construct the parameter from Fem::Parameter.
Definition: parameterinterface.hh:171
TrivialParameter(const std::string &configKey, const ValueType &defaultValue)
Construct the parameter from Fem::Parameter.
Definition: parameterinterface.hh:176
The zero parameter, unconditionally evalute to zero.
Definition: parameterinterface.hh:203
ValueType value() const
I AM ZERO. PERIOD.
Definition: parameterinterface.hh:213
const Implementation & asImp(const Fem::BartonNackmanInterface< Interface, Implementation > &arg)
Up-cast to the implementation for any Fem::BartonNackmanInterface.
Definition: expressionoperations.hh:71
ParameterValue< Value >::ResultType parameterValue(const Value &value)
Return the unaltered argument for non-parameters and otherwise the parameter value.
Definition: parameterinterface.hh:263
Provide up-cast functionality for expression templates.
Definition: expressionoperations.hh:37
The default template definition for this struct constructs a 1-dimensional parameter-value space (i....
Definition: parameterinterface.hh:137
A model for the vector space a parameter value lives in.
Definition: parameterinterface.hh:50
A tag structure which can be attached as base class to zero-expressions like the ZeroGridFunction,...
Definition: expressionoperations.hh:430