Skip to content
Snippets Groups Projects
Commit a08bb842 authored by Dr. Felix Tobias Schindler's avatar Dr. Felix Tobias Schindler
Browse files

[stuff.function] major renaming

in general: Stuff::Function::Foo -> Stuff::FunctionFoo
Function::Separable::Foo -> FunctionAffineSeparableFoo
parent 294103d9
No related branches found
No related tags found
No related merge requests found
...@@ -15,81 +15,80 @@ ...@@ -15,81 +15,80 @@
#include <dune/common/exceptions.hh> #include <dune/common/exceptions.hh>
#include <dune/stuff/common/color.hh> #include <dune/stuff/common/color.hh>
#include <dune/stuff/aliases.hh>
namespace Dune { namespace Dune {
namespace Stuff { namespace Stuff {
namespace Function {
std::vector<std::string> types()
{
return {
"function.checkerboard", "function.expression", "function.separable.default", "function.separable.checkerboard"};
} // std::vector< std::string > types()
// some forwards, includes are below // some forwards, includes are below
template <class D, int d, class R, int r> template <class D, int d, class R, int r>
class Interface; class FunctionInterface;
template <class D, int d, class R, int r> template <class D, int d, class R, int r>
class Checkerboard; class FunctionCheckerboard;
template <class D, int d, class R, int r> template <class D, int d, class R, int r>
class Expression; class FunctionExpression;
template <class D, int d, class R, int r> template <class D, int d, class R, int r>
class SeparableDefault; class FunctionAffineParametricDefault;
template <class D, int d, class R, int r> template <class D, int d, class R, int r>
class SeparableCheckerboard; class FunctionAffineParametricCheckerboard;
std::vector<std::string> availableFunctions()
{
return {"function.expression",
"function.checkerboard",
"function.affineparametric.default",
"function.affineparametric.checkerboard"};
} // std::vector< std::string > types()
template <class D, int d, class R, int r> template <class D, int d, class R, int r>
Dune::ParameterTree createSampleDescription(const std::string type) Dune::ParameterTree createSampleFunctionDescription(const std::string type)
{ {
if (type == "function.checkerboard") { if (type == "function.checkerboard") {
typedef Stuff::Function::Checkerboard<D, d, R, r> FunctionType; typedef FunctionCheckerboard<D, d, R, r> FunctionType;
return FunctionType::createSampleDescription(); return FunctionType::createSampleDescription();
} else if (type == "function.expression") { } else if (type == "function.expression") {
typedef Stuff::Function::Expression<D, d, R, r> FunctionType; typedef FunctionExpression<D, d, R, r> FunctionType;
return FunctionType::createSampleDescription(); return FunctionType::createSampleDescription();
} else if (type == "function.separable.default") { } else if (type == "function.affineparametric.default") {
typedef Stuff::Function::SeparableDefault<D, d, R, r> FunctionType; typedef FunctionAffineParametricDefault<D, d, R, r> FunctionType;
return FunctionType::createSampleDescription(); return FunctionType::createSampleDescription();
} else if (type == "function.separable.checkerboard") { } else if (type == "function.affineparametric.checkerboard") {
typedef Stuff::Function::SeparableCheckerboard<D, d, R, r> FunctionType; typedef FunctionAffineParametricCheckerboard<D, d, R, r> FunctionType;
return FunctionType::createSampleDescription(); return FunctionType::createSampleDescription();
} else } else
DUNE_THROW(Dune::RangeError, DUNE_THROW(Dune::RangeError,
"\n" << Dune::Stuff::Common::colorStringRed("ERROR:") << " unknown function '" << type "\n" << Dune::Stuff::Common::colorStringRed("ERROR:") << " unknown function '" << type
<< "' requested!"); << "' requested!");
} // ... create(...) } // ... createSampleFunctionDescription(...)
template <class D, int d, class R, int r> template <class D, int d, class R, int r>
Interface<D, d, R, r>* create(const std::string type, const Dune::ParameterTree description = Dune::ParameterTree()) FunctionInterface<D, d, R, r>* createFunction(const std::string type,
const Dune::ParameterTree description = Dune::ParameterTree())
{ {
using namespace DSFu;
if (type == "function.checkerboard") { if (type == "function.checkerboard") {
return Checkerboard<D, d, R, r>::createFromDescription(description); return FunctionCheckerboard<D, d, R, r>::create(description);
} else if (type == "function.expression") { } else if (type == "function.expression") {
return Expression<D, d, R, r>::createFromDescription(description); return FunctionExpression<D, d, R, r>::create(description);
} else if (type == "function.separable.default") { } else if (type == "function.affineparametric.default") {
return SeparableDefault<D, d, R, r>::createFromDescription(description); return FunctionAffineParametricDefault<D, d, R, r>::create(description);
} else if (type == "function.separable.checkerboard") { } else if (type == "function.affineparametric.checkerboard") {
return SeparableCheckerboard<D, d, R, r>::createFromDescription(description); return FunctionAffineParametricCheckerboard<D, d, R, r>::create(description);
} else } else
DUNE_THROW(Dune::RangeError, DUNE_THROW(Dune::RangeError,
"\n" << Dune::Stuff::Common::colorStringRed("ERROR:") << " unknown function '" << type "\n" << Dune::Stuff::Common::colorStringRed("ERROR:") << " unknown function '" << type
<< "' requested!"); << "' requested!");
} // ... create(...) } // ... createFunction(...)
} // namespace Function
} // namespace Stuff } // namespace Stuff
} // namespace Dune } // namespace Dune
#include "function/interface.hh" #include "function/interface.hh"
#include "function/checkerboard.hh" #include "function/checkerboard.hh"
#include "function/expression.hh" #include "function/expression.hh"
#include "function/parametric/separable/default.hh" #include "function/affineparametric/default.hh"
#include "function/parametric/separable/checkerboard.hh" #include "function/affineparametric/checkerboard.hh"
#endif // DUNE_STUFF_FUNCTION_HH #endif // DUNE_STUFF_FUNCTION_HH
...@@ -12,20 +12,20 @@ ...@@ -12,20 +12,20 @@
namespace Dune { namespace Dune {
namespace Stuff { namespace Stuff {
namespace Function {
// forward, to allow for specialization
template <class DomainFieldImp, int domainDim, class RangeFieldImp, int rangeDim> template <class DomainFieldImp, int domainDim, class RangeFieldImp, int rangeDim>
class Checkerboard; class FunctionCheckerboard;
template <class DomainFieldImp, int domainDim, class RangeFieldImp> template <class DomainFieldImp, int domainDim, class RangeFieldImp>
class Checkerboard<DomainFieldImp, domainDim, RangeFieldImp, 1> class FunctionCheckerboard<DomainFieldImp, domainDim, RangeFieldImp, 1>
: public Interface<DomainFieldImp, domainDim, RangeFieldImp, 1> : public FunctionInterface<DomainFieldImp, domainDim, RangeFieldImp, 1>
{ {
public: public:
typedef Checkerboard<DomainFieldImp, domainDim, RangeFieldImp, 1> ThisType; typedef FunctionCheckerboard<DomainFieldImp, domainDim, RangeFieldImp, 1> ThisType;
typedef Interface<DomainFieldImp, domainDim, RangeFieldImp, 1> BaseType; typedef FunctionInterface<DomainFieldImp, domainDim, RangeFieldImp, 1> BaseType;
typedef typename BaseType::DomainFieldType DomainFieldType; typedef typename BaseType::DomainFieldType DomainFieldType;
static const int dimDomain = BaseType::dimDomain; static const int dimDomain = BaseType::dimDomain;
...@@ -36,11 +36,12 @@ public: ...@@ -36,11 +36,12 @@ public:
static const std::string id() static const std::string id()
{ {
return "function.checkerboard"; return BaseType::id() + ".checkerboard";
} }
Checkerboard(const DomainType _lowerLeft, const DomainType _upperRight, const std::vector<size_t> _numElements, FunctionCheckerboard(const DomainType _lowerLeft, const DomainType _upperRight,
const std::vector<RangeFieldType> _values, const std::string _name = id()) const std::vector<size_t> _numElements, const std::vector<RangeFieldType> _values,
const std::string _name = id())
: lowerLeft_(_lowerLeft) : lowerLeft_(_lowerLeft)
, upperRight_(_upperRight) , upperRight_(_upperRight)
, numElements_(_numElements) , numElements_(_numElements)
...@@ -60,7 +61,7 @@ public: ...@@ -60,7 +61,7 @@ public:
DUNE_THROW(Dune::InvalidStateException, DUNE_THROW(Dune::InvalidStateException,
"\n" << Dune::Stuff::Common::colorStringRed("ERROR:") "\n" << Dune::Stuff::Common::colorStringRed("ERROR:")
<< " please provide at least as many '_values' as subdomains given by '_numElements'!"); << " please provide at least as many '_values' as subdomains given by '_numElements'!");
} } // FunctionCheckerboard(...)
static Dune::ParameterTree createSampleDescription(const std::string subName = "") static Dune::ParameterTree createSampleDescription(const std::string subName = "")
{ {
...@@ -77,9 +78,9 @@ public: ...@@ -77,9 +78,9 @@ public:
extendedDescription.add(description, subName); extendedDescription.add(description, subName);
return extendedDescription; return extendedDescription;
} }
} } // ... createSampleDescription(...)
static ThisType* createFromDescription(const DSC::ExtendedParameterTree description) static ThisType* create(const DSC::ExtendedParameterTree description)
{ {
// get data // get data
const std::vector<DomainFieldType> lowerLefts = description.getVector("lowerLeft", DomainFieldType(0), dimDomain); const std::vector<DomainFieldType> lowerLefts = description.getVector("lowerLeft", DomainFieldType(0), dimDomain);
...@@ -98,7 +99,7 @@ public: ...@@ -98,7 +99,7 @@ public:
} }
// create and return // create and return
return new ThisType(lowerLeft, upperRight, numElements, values); return new ThisType(lowerLeft, upperRight, numElements, values);
} // static ThisType createFromParamTree(const Dune::ParameterTree paramTree) } // ... create(...)
const DomainType& lowerLeft() const const DomainType& lowerLeft() const
...@@ -157,9 +158,8 @@ private: ...@@ -157,9 +158,8 @@ private:
std::vector<size_t> numElements_; std::vector<size_t> numElements_;
std::vector<RangeFieldType> values_; std::vector<RangeFieldType> values_;
std::string name_; std::string name_;
}; // class Checkerboard }; // class FunctionCheckerboard
} // namespace Function
} // namespace Stuff } // namespace Stuff
} // namespace Dune } // namespace Dune
......
...@@ -29,22 +29,23 @@ ...@@ -29,22 +29,23 @@
namespace Dune { namespace Dune {
namespace Stuff { namespace Stuff {
namespace Function {
template <class DomainFieldImp, int domainDim, class RangeFieldImp, int rangeDim> template <class DomainFieldImp, int domainDim, class RangeFieldImp, int rangeDim>
class Expression : public ExpressionBase<DomainFieldImp, domainDim, RangeFieldImp, rangeDim> class FunctionExpression
: public FunctionExpressionBase<DomainFieldImp, domainDim, RangeFieldImp, rangeDim>
#if HAVE_DUNE_FEM #if HAVE_DUNE_FEM
, ,
public Dune::Fem::Function<Dune::FunctionSpace<DomainFieldImp, RangeFieldImp, domainDim, rangeDim>, public Dune::Fem::Function<Dune::FunctionSpace<DomainFieldImp, RangeFieldImp, domainDim, rangeDim>,
Expression<DomainFieldImp, domainDim, RangeFieldImp, rangeDim>> FunctionExpression<DomainFieldImp, domainDim, RangeFieldImp, rangeDim>>
#endif #endif
, ,
public Interface<DomainFieldImp, domainDim, RangeFieldImp, rangeDim> public FunctionInterface<DomainFieldImp, domainDim, RangeFieldImp, rangeDim>
{ {
public: public:
typedef Expression<DomainFieldImp, domainDim, RangeFieldImp, rangeDim> ThisType; typedef FunctionExpression<DomainFieldImp, domainDim, RangeFieldImp, rangeDim> ThisType;
typedef ExpressionBase<DomainFieldImp, domainDim, RangeFieldImp, rangeDim> BaseType; typedef FunctionExpressionBase<DomainFieldImp, domainDim, RangeFieldImp, rangeDim> BaseType;
typedef Interface<DomainFieldImp, domainDim, RangeFieldImp, rangeDim> InterfaceType; typedef FunctionInterface<DomainFieldImp, domainDim, RangeFieldImp, rangeDim> InterfaceType;
using typename InterfaceType::DomainFieldType; using typename InterfaceType::DomainFieldType;
using InterfaceType::dimDomain; using InterfaceType::dimDomain;
...@@ -58,23 +59,23 @@ public: ...@@ -58,23 +59,23 @@ public:
return InterfaceType::id() + ".expression"; return InterfaceType::id() + ".expression";
} }
Expression(const std::string _variable, const std::string _expression, const int _order = -1, FunctionExpression(const std::string _variable, const std::string _expression, const int _order = -1,
const std::string _name = "function.expression") const std::string _name = id())
: BaseType(_variable, _expression) : BaseType(_variable, _expression)
, order_(_order) , order_(_order)
, name_(_name) , name_(_name)
{ {
} }
Expression(const std::string _variable, const std::vector<std::string> _expressions, const int _order = -1, FunctionExpression(const std::string _variable, const std::vector<std::string> _expressions, const int _order = -1,
const std::string _name = "function.expression") const std::string _name = id())
: BaseType(_variable, _expressions) : BaseType(_variable, _expressions)
, order_(_order) , order_(_order)
, name_(_name) , name_(_name)
{ {
} }
Expression(const ThisType& other) FunctionExpression(const ThisType& other)
: BaseType(other) : BaseType(other)
, order_(other.order()) , order_(other.order())
, name_(other.name()) , name_(other.name())
...@@ -105,9 +106,9 @@ public: ...@@ -105,9 +106,9 @@ public:
extendedDescription.add(description, subName); extendedDescription.add(description, subName);
return extendedDescription; return extendedDescription;
} }
} } // ... createSampleDescription(...)
static ThisType* createFromDescription(const DSC::ExtendedParameterTree description) static ThisType* create(const DSC::ExtendedParameterTree description)
{ {
// get necessary // get necessary
const std::string _variable = description.get<std::string>("variable", "x"); const std::string _variable = description.get<std::string>("variable", "x");
...@@ -130,7 +131,7 @@ public: ...@@ -130,7 +131,7 @@ public:
const std::string _name = description.get<std::string>("name", "function.expression"); const std::string _name = description.get<std::string>("name", "function.expression");
// create and return // create and return
return new ThisType(_variable, _expressions, _order, _name); return new ThisType(_variable, _expressions, _order, _name);
} // static ThisType createFromDescription(const Dune::ParameterTree& _description) } // ... create(...)
virtual int order() const virtual int order() const
{ {
...@@ -150,10 +151,9 @@ public: ...@@ -150,10 +151,9 @@ public:
private: private:
int order_; int order_;
std::string name_; std::string name_;
}; // class Expression }; // class FunctionExpression
} // namespace Function
} // namespace Stuff } // namespace Stuff
} // namespace Dune } // namespace Dune
......
...@@ -27,12 +27,11 @@ ...@@ -27,12 +27,11 @@
namespace Dune { namespace Dune {
namespace Stuff { namespace Stuff {
namespace Function {
// forward // forward, to be friends
template <class RangeFieldImp> template <class RangeFieldImp>
class Coefficient; class FunctionAffineSeparablCoefficient;
///** ///**
...@@ -59,10 +58,10 @@ class Coefficient; ...@@ -59,10 +58,10 @@ class Coefficient;
* \attention Most surely you do not want to use this class directly! * \attention Most surely you do not want to use this class directly!
*/ */
template <class DomainFieldImp, int domainDim, class RangeFieldImp, int rangeDim> template <class DomainFieldImp, int domainDim, class RangeFieldImp, int rangeDim>
class ExpressionBase class FunctionExpressionBase
{ {
public: public:
typedef ExpressionBase<DomainFieldImp, domainDim, RangeFieldImp, rangeDim> ThisType; typedef FunctionExpressionBase<DomainFieldImp, domainDim, RangeFieldImp, rangeDim> ThisType;
typedef DomainFieldImp DomainFieldType; typedef DomainFieldImp DomainFieldType;
static const int dimDomain = domainDim; static const int dimDomain = domainDim;
...@@ -70,18 +69,18 @@ public: ...@@ -70,18 +69,18 @@ public:
typedef RangeFieldImp RangeFieldType; typedef RangeFieldImp RangeFieldType;
static const int dimRange = rangeDim; static const int dimRange = rangeDim;
ExpressionBase(const std::string _variable, const std::string _expression) FunctionExpressionBase(const std::string _variable, const std::string _expression)
{ {
const std::vector<std::string> expressions(1, _expression); const std::vector<std::string> expressions(1, _expression);
setup(_variable, expressions); setup(_variable, expressions);
} // NonparametricExpression(const std::string variable, const std::string expression) } // NonparametricExpression(const std::string variable, const std::string expression)
ExpressionBase(const std::string _variable, const std::vector<std::string> _expressions) FunctionExpressionBase(const std::string _variable, const std::vector<std::string> _expressions)
{ {
setup(_variable, _expressions); setup(_variable, _expressions);
} // NonparametricExpression(const std::string variable, const std::vector< std::string >& expressions) } // NonparametricExpression(const std::string variable, const std::vector< std::string >& expressions)
ExpressionBase(const ThisType& _other) FunctionExpressionBase(const ThisType& _other)
{ {
setup(_other.variable(), _other.expression()); setup(_other.variable(), _other.expression());
} // NonparametricExpression(const ThisType& other) } // NonparametricExpression(const ThisType& other)
...@@ -98,7 +97,7 @@ public: ...@@ -98,7 +97,7 @@ public:
return this; return this;
} // ThisType& operator=(const ThisType& other) } // ThisType& operator=(const ThisType& other)
~ExpressionBase() ~FunctionExpressionBase()
{ {
cleanup(); cleanup();
} // ~NonparametricExpression() } // ~NonparametricExpression()
...@@ -203,7 +202,7 @@ public: ...@@ -203,7 +202,7 @@ public:
} // void report(const std::string, std::ostream&, const std::string&) const } // void report(const std::string, std::ostream&, const std::string&) const
private: private:
friend class Coefficient<RangeFieldType>; friend class FunctionAffineSeparablCoefficient<RangeFieldType>;
void evaluate(const Dune::DynamicVector<DomainFieldType>& arg, RangeFieldType& ret) const void evaluate(const Dune::DynamicVector<DomainFieldType>& arg, RangeFieldType& ret) const
{ {
...@@ -267,9 +266,8 @@ private: ...@@ -267,9 +266,8 @@ private:
RVar* var_arg_[dimDomain]; RVar* var_arg_[dimDomain];
RVar* vararray_[dimDomain]; RVar* vararray_[dimDomain];
ROperation* op_[dimRange]; ROperation* op_[dimRange];
}; // class ExpressionBase }; // class FunctionExpressionBase
} // namespace Function
} // namespace Stuff } // namespace Stuff
} // namespace Dune } // namespace Dune
......
...@@ -19,19 +19,18 @@ ...@@ -19,19 +19,18 @@
namespace Dune { namespace Dune {
namespace Stuff { namespace Stuff {
namespace Function {
//! forward //! forward
template <class RangeFieldImp> template <class RangeFieldImp>
class Coefficient; class FunctionAffineSeparablCoefficient;
template <class DomainFieldImp, int domainDim, class RangeFieldImp, int rangeDim> template <class DomainFieldImp, int domainDim, class RangeFieldImp, int rangeDim>
class Interface class FunctionInterface
{ {
public: public:
typedef Interface<DomainFieldImp, domainDim, RangeFieldImp, rangeDim> ThisType; typedef FunctionInterface<DomainFieldImp, domainDim, RangeFieldImp, rangeDim> ThisType;
typedef DomainFieldImp DomainFieldType; typedef DomainFieldImp DomainFieldType;
static const int dimDomain = domainDim; static const int dimDomain = domainDim;
...@@ -46,9 +45,9 @@ public: ...@@ -46,9 +45,9 @@ public:
typedef Common::Parameter::Type ParamType; typedef Common::Parameter::Type ParamType;
typedef ThisType ComponentType; typedef ThisType ComponentType;
typedef Coefficient<RangeFieldType> CoefficientType; typedef FunctionAffineSeparablCoefficient<RangeFieldType> CoefficientType;
virtual ~Interface() virtual ~FunctionInterface()
{ {
} }
...@@ -160,74 +159,9 @@ public: ...@@ -160,74 +159,9 @@ public:
evaluate(_x, ret); evaluate(_x, ret);
return ret; return ret;
} }
}; // class FunctionInterface
// virtual RangeType evaluate(const DomainType& x, const ParamType& mu) const
// {
// RangeType ret;
// evaluate(x, mu, ret);
// return ret;
// }
// virtual void evaluate(const ParamType& x, const ParamType& mu, RangeType& ret) const
// {
// // process input
// assert(x.size() == dimDomain);
// DomainType x_fvector;
// for (int i = 0; i < dimDomain; ++i)
// x_fvector[i] = x(i);
// // evaluate
// evaluate(x_fvector, mu, ret);
// }
// virtual void evaluate(const DomainType& x, const ParamType& mu, ParamType& ret) const
// {
// // evaluate
// RangeType ret_fvector;
// evaluate(x, mu, ret_fvector);
// // process output
// assert(ret.size() == dimRange);
// for (int i = 0; i < dimRange; ++i)
// ret(i) = ret_fvector[i];
// }
// virtual void evaluate(const ParamType& x, const ParamType& mu, ParamType& ret) const
// {
// // process input
// assert(x.size() == dimDomain);
// DomainType x_fvector;
// for (int i = 0; i < dimDomain; ++i)
// x_fvector[i] = x(i);
// // evaluate
// RangeType ret_fvector;
// evaluate(x_fvector, mu, ret_fvector);
// // process output
// assert(ret.size() == dimRange);
// for (int i = 0; i < dimRange; ++i)
// ret(i) = ret_fvector[i];
// }
// virtual ParamType evaluate(const ParamType& x, const ParamType& mu) const
// {
// ParamType ret;
// evaluate(x, mu, ret);
// return ret;
// }
// void report(std::ostream& out = std::cout, std::string prefix = "") const
// {
// out << prefix << "parameter explanation:" << std::endl;
// assert(paramExplanation().size() == paramSize());
// assert(paramRange().size() == 2);
// assert(paramRange()[0].size() == paramSize());
// assert(paramRange()[1].size() == paramSize());
// for (unsigned int pp = 0; pp < paramSize(); ++pp)
// out << prefix << " " << paramExplanation()[pp] << ", between " << paramRange()[0](pp) << " and " <<
// paramRange()[1](pp) << std::endl;
// }
/* @} */
}; // class Interface
} // namespace Function
} // namespace Stuff } // namespace Stuff
} // namespace Dune } // namespace Dune
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment