Skip to content
Snippets Groups Projects
Commit 8ac54e76 authored by Tobias Leibner's avatar Tobias Leibner
Browse files

bump ci, add dynamic evaluation/jacobian to generic flux function

parent 66fc48fd
No related branches found
No related tags found
No related merge requests found
Subproject commit 30e62e3a0f2a28b7ea35a1bb72632be6085d4662 Subproject commit 7090ef1f15a9be6aeac87b31bc77f549302c7820
...@@ -64,6 +64,8 @@ private: ...@@ -64,6 +64,8 @@ private:
public: public:
using typename BaseType::DomainType; using typename BaseType::DomainType;
using typename BaseType::DynamicJacobianRangeType;
using typename BaseType::DynamicRangeType;
using typename BaseType::ElementType; using typename BaseType::ElementType;
using typename BaseType::JacobianRangeReturnType; using typename BaseType::JacobianRangeReturnType;
using typename BaseType::JacobianRangeType; using typename BaseType::JacobianRangeType;
...@@ -75,22 +77,30 @@ private: ...@@ -75,22 +77,30 @@ private:
using GenericEvaluateFunctionType = using GenericEvaluateFunctionType =
std::function<RangeReturnType(const DomainType&, const StateType&, const Common::Parameter&)>; std::function<RangeReturnType(const DomainType&, const StateType&, const Common::Parameter&)>;
using GenericDynamicEvaluateFunctionType =
std::function<void(const DomainType&, const StateType&, DynamicRangeType&, const Common::Parameter&)>;
using GenericPostBindFunctionType = std::function<void(const ElementType&)>; using GenericPostBindFunctionType = std::function<void(const ElementType&)>;
using GenericOrderFunctionType = std::function<int(const Common::Parameter&)>; using GenericOrderFunctionType = std::function<int(const Common::Parameter&)>;
using GenericJacobianFunctionType = using GenericJacobianFunctionType =
std::function<JacobianRangeReturnType(const DomainType&, const StateType&, const XT::Common::Parameter&)>; std::function<JacobianRangeReturnType(const DomainType&, const StateType&, const XT::Common::Parameter&)>;
using GenericDynamicJacobianFunctionType = std::function<void(
const DomainType&, const StateType&, DynamicJacobianRangeType&, const XT::Common::Parameter&)>;
LocalGenericFluxFunction(const GenericOrderFunctionType& order_func, LocalGenericFluxFunction(const GenericOrderFunctionType& order_func,
const GenericPostBindFunctionType& post_bind_func, const GenericPostBindFunctionType& post_bind_func,
const GenericEvaluateFunctionType& evaluate_func, const GenericEvaluateFunctionType& evaluate_func,
const GenericDynamicEvaluateFunctionType& dynamic_evaluate_func,
const Common::ParameterType& param_type, const Common::ParameterType& param_type,
const GenericJacobianFunctionType& jacobian_func) const GenericJacobianFunctionType& jacobian_func,
const GenericDynamicJacobianFunctionType& dynamic_jacobian_func)
: BaseType() : BaseType()
, order_(order_func) , order_(order_func)
, post_bind_(post_bind_func) , post_bind_(post_bind_func)
, evaluate_(evaluate_func) , evaluate_(evaluate_func)
, dynamic_evaluate_(dynamic_evaluate_func)
, param_type_(param_type) , param_type_(param_type)
, jacobian_(jacobian_func) , jacobian_(jacobian_func)
, dynamic_jacobian_(dynamic_jacobian_func)
{} {}
protected: protected:
...@@ -122,6 +132,25 @@ private: ...@@ -122,6 +132,25 @@ private:
return jacobian_(point_in_local_coordinates, u, parsed_param); return jacobian_(point_in_local_coordinates, u, parsed_param);
} }
virtual void evaluate(const DomainType& point_in_local_coordinates,
const StateType& u,
DynamicRangeType& ret,
const Common::Parameter& param = {}) const override final
{
auto parsed_param = this->parse_parameter(param);
dynamic_evaluate_(point_in_local_coordinates, u, ret, parsed_param);
}
virtual void jacobian(const DomainType& point_in_local_coordinates,
const StateType& u,
DynamicJacobianRangeType& ret,
const Common::Parameter& param = {}) const override final
{
auto parsed_param = this->parse_parameter(param);
return dynamic_jacobian_(point_in_local_coordinates, u, ret, parsed_param);
}
virtual const Common::ParameterType& parameter_type() const override final virtual const Common::ParameterType& parameter_type() const override final
{ {
return param_type_; return param_type_;
...@@ -131,8 +160,10 @@ private: ...@@ -131,8 +160,10 @@ private:
const GenericOrderFunctionType& order_; const GenericOrderFunctionType& order_;
const GenericPostBindFunctionType& post_bind_; const GenericPostBindFunctionType& post_bind_;
const GenericEvaluateFunctionType& evaluate_; const GenericEvaluateFunctionType& evaluate_;
const GenericDynamicEvaluateFunctionType& dynamic_evaluate_;
const Common::ParameterType& param_type_; const Common::ParameterType& param_type_;
const GenericJacobianFunctionType& jacobian_; const GenericJacobianFunctionType& jacobian_;
const GenericDynamicJacobianFunctionType& dynamic_jacobian_;
}; // class LocalGenericFluxFunction }; // class LocalGenericFluxFunction
public: public:
...@@ -140,17 +171,23 @@ public: ...@@ -140,17 +171,23 @@ public:
using DomainType = typename LocalGenericFluxFunction::DomainType; using DomainType = typename LocalGenericFluxFunction::DomainType;
using StateType = typename LocalGenericFluxFunction::StateType; using StateType = typename LocalGenericFluxFunction::StateType;
using RangeType = typename LocalGenericFluxFunction::RangeType; using RangeType = typename LocalGenericFluxFunction::RangeType;
using DynamicRangeType = typename LocalGenericFluxFunction::DynamicRangeType;
using JacobianRangeType = typename LocalGenericFluxFunction::JacobianRangeType; using JacobianRangeType = typename LocalGenericFluxFunction::JacobianRangeType;
using RangeReturnType = typename LocalGenericFluxFunction::RangeReturnType; using RangeReturnType = typename LocalGenericFluxFunction::RangeReturnType;
using JacobianRangeReturnType = typename LocalGenericFluxFunction::JacobianRangeReturnType; using JacobianRangeReturnType = typename LocalGenericFluxFunction::JacobianRangeReturnType;
using DynamicJacobianRangeType = typename LocalGenericFluxFunction::DynamicJacobianRangeType;
// we do not use the typedef from LocalGenericFluxFunction here to document the type of the generic functions // we do not use the typedef from LocalGenericFluxFunction here to document the type of the generic functions
using GenericOrderFunctionType = std::function<int(const Common::Parameter&)>; using GenericOrderFunctionType = std::function<int(const Common::Parameter&)>;
using GenericPostBindFunctionType = std::function<void(const ElementType&)>; using GenericPostBindFunctionType = std::function<void(const ElementType&)>;
using GenericEvaluateFunctionType = using GenericEvaluateFunctionType =
std::function<RangeReturnType(const DomainType&, const StateType&, const Common::Parameter&)>; std::function<RangeReturnType(const DomainType&, const StateType&, const Common::Parameter&)>;
using GenericDynamicEvaluateFunctionType =
std::function<void(const DomainType&, const StateType&, DynamicRangeType&, const Common::Parameter&)>;
using GenericJacobianFunctionType = using GenericJacobianFunctionType =
std::function<JacobianRangeReturnType(const DomainType&, const StateType&, const Common::Parameter&)>; std::function<JacobianRangeReturnType(const DomainType&, const StateType&, const Common::Parameter&)>;
using GenericDynamicJacobianFunctionType =
std::function<void(const DomainType&, const StateType&, DynamicJacobianRangeType&, const Common::Parameter&)>;
GenericFluxFunction(const int ord, GenericFluxFunction(const int ord,
GenericPostBindFunctionType post_bind_func = default_post_bind_function(), GenericPostBindFunctionType post_bind_func = default_post_bind_function(),
...@@ -161,9 +198,11 @@ public: ...@@ -161,9 +198,11 @@ public:
: order_(default_order_lambda(ord)) : order_(default_order_lambda(ord))
, post_bind_(post_bind_func) , post_bind_(post_bind_func)
, evaluate_(evaluate_func) , evaluate_(evaluate_func)
, dynamic_evaluate_(default_dynamic_evaluate_function())
, param_type_(param_type) , param_type_(param_type)
, name_(nm) , name_(nm)
, jacobian_(jacobian_func) , jacobian_(jacobian_func)
, dynamic_jacobian_(default_dynamic_jacobian_function())
{} {}
GenericFluxFunction(GenericOrderFunctionType order_func, GenericFluxFunction(GenericOrderFunctionType order_func,
...@@ -175,9 +214,43 @@ public: ...@@ -175,9 +214,43 @@ public:
: order_(order_func) : order_(order_func)
, post_bind_(post_bind_func) , post_bind_(post_bind_func)
, evaluate_(evaluate_func) , evaluate_(evaluate_func)
, dynamic_evaluate_(default_dynamic_evaluate_function())
, param_type_(param_type) , param_type_(param_type)
, name_(nm) , name_(nm)
, jacobian_(jacobian_func) , jacobian_(jacobian_func)
, dynamic_jacobian_(default_dynamic_jacobian_function())
{}
GenericFluxFunction(const int ord,
GenericPostBindFunctionType post_bind_func,
GenericDynamicEvaluateFunctionType evaluate_func,
const Common::ParameterType& param_type = Common::ParameterType(),
const std::string nm = "GenericFluxFunction",
GenericDynamicJacobianFunctionType jacobian_func = default_dynamic_jacobian_function())
: order_(default_order_lambda(ord))
, post_bind_(post_bind_func)
, evaluate_(evaluate_func)
, dynamic_evaluate_(evaluate_from_dynamic_evaluate(evaluate_func))
, param_type_(param_type)
, name_(nm)
, jacobian_(jacobian_from_dynamic_jacobian(jacobian_func))
, dynamic_jacobian_(jacobian_func)
{}
GenericFluxFunction(GenericOrderFunctionType order_func,
GenericPostBindFunctionType post_bind_func,
GenericDynamicEvaluateFunctionType evaluate_func,
const Common::ParameterType& param_type = Common::ParameterType(),
const std::string nm = "GenericFluxFunction",
GenericDynamicJacobianFunctionType jacobian_func = default_dynamic_jacobian_function())
: order_(order_func)
, post_bind_(post_bind_func)
, evaluate_(evaluate_from_dynamic_evaluate(evaluate_func))
, dynamic_evaluate_(evaluate_func)
, param_type_(param_type)
, name_(nm)
, jacobian_(jacobian_from_dynamic_jacobian(jacobian_func))
, dynamic_jacobian_(jacobian_func)
{} {}
const Common::ParameterType& parameter_type() const override final const Common::ParameterType& parameter_type() const override final
...@@ -192,7 +265,8 @@ public: ...@@ -192,7 +265,8 @@ public:
std::unique_ptr<LocalFunctionType> local_function() const override final std::unique_ptr<LocalFunctionType> local_function() const override final
{ {
return std::make_unique<LocalGenericFluxFunction>(order_, post_bind_, evaluate_, param_type_, jacobian_); return std::make_unique<LocalGenericFluxFunction>(
order_, post_bind_, evaluate_, dynamic_evaluate_, param_type_, jacobian_, dynamic_jacobian_);
} }
/** /**
...@@ -222,6 +296,18 @@ public: ...@@ -222,6 +296,18 @@ public:
}; };
} }
static GenericDynamicEvaluateFunctionType default_dynamic_evaluate_function()
{
return [](const DomainType& /* point_in_local_coordinates*/,
const StateType& /*u*/,
DynamicRangeType& /*ret*/,
const Common::Parameter& /*param*/ = {}) {
DUNE_THROW(
NotImplemented,
"This GenericFluxFunction does not provide dynamic evaluations, provide an evaluate_lambda on construction!");
};
}
static GenericJacobianFunctionType default_jacobian_function() static GenericJacobianFunctionType default_jacobian_function()
{ {
return [](const DomainType& /* point_in_local_coordinates*/, return [](const DomainType& /* point_in_local_coordinates*/,
...@@ -234,6 +320,44 @@ public: ...@@ -234,6 +320,44 @@ public:
}; };
} }
static GenericDynamicJacobianFunctionType default_dynamic_jacobian_function()
{
return [](const DomainType& /* point_in_local_coordinates*/,
const StateType& /*u*/,
const DynamicJacobianRangeType& /*ret*/,
const Common::Parameter& /*param*/ = {}) {
DUNE_THROW(NotImplemented,
"This GenericFluxFunction does not provide dynamic jacobian evaluations, provide a "
"jacobian_lambda on construction!");
};
}
static GenericEvaluateFunctionType
evaluate_from_dynamic_evaluate(const GenericDynamicEvaluateFunctionType& dynamic_evaluate)
{
return [dynamic_evaluate](
const DomainType& point_in_local_coordinates, const StateType& u, const Common::Parameter& param = {}) {
DynamicRangeType dynamic_ret;
BaseType::LocalFunctionType::RangeSelector::ensure_size(dynamic_ret);
dynamic_evaluate(point_in_local_coordinates, u, dynamic_ret, param);
RangeReturnType ret = dynamic_ret;
return ret;
};
}
static GenericJacobianFunctionType
jacobian_from_dynamic_jacobian(const GenericDynamicJacobianFunctionType& dynamic_jacobian)
{
return [dynamic_jacobian](
const DomainType& point_in_local_coordinates, const StateType& u, const Common::Parameter& param = {}) {
DynamicJacobianRangeType dynamic_ret;
BaseType::LocalFunctionType::JacobianRangeSelector::ensure_size(dynamic_ret);
dynamic_jacobian(point_in_local_coordinates, u, dynamic_ret, param);
JacobianRangeReturnType ret = dynamic_ret;
return ret;
};
}
/** /**
* \} * \}
*/ */
...@@ -242,9 +366,11 @@ private: ...@@ -242,9 +366,11 @@ private:
const GenericOrderFunctionType order_; const GenericOrderFunctionType order_;
const GenericPostBindFunctionType post_bind_; const GenericPostBindFunctionType post_bind_;
const GenericEvaluateFunctionType evaluate_; const GenericEvaluateFunctionType evaluate_;
const GenericDynamicEvaluateFunctionType dynamic_evaluate_;
const Common::ParameterType param_type_; const Common::ParameterType param_type_;
const std::string name_; const std::string name_;
GenericJacobianFunctionType jacobian_; GenericJacobianFunctionType jacobian_;
GenericDynamicJacobianFunctionType dynamic_jacobian_;
}; // class GenericFluxFunction }; // class GenericFluxFunction
......
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