Commit 025749d0 authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#873 Parameter: make the time dependency parameter a template template one....

#873 Parameter: make the time dependency parameter a template template one. The type is hence known, and the additional storage required to store the value with the time scale factor might be handled directly in the base class rather than in each policy.
parent 4e98061b
......@@ -14787,6 +14787,7 @@
"-lyuni-static-core",
"-lmpi",
"-lpetsc",
"-lmpi_cxx",
);
PRODUCT_NAME = "$(TARGET_NAME)";
};
......@@ -14809,6 +14810,7 @@
"-lyuni-static-core",
"-lmpi",
"-lpetsc",
"-lmpi_cxx",
);
PRODUCT_NAME = "$(TARGET_NAME)";
};
......@@ -47,7 +47,7 @@ namespace HappyHeart
class DerivedT,
unsigned int VolumicIndexT,
unsigned int SurfacicIndexT,
class TimeDependencyT
template<ParameterNS::Type> class TimeDependencyT
>
class VolumicAndSurfacicSource
{
......
......@@ -25,7 +25,7 @@ namespace HappyHeart
class DerivedT,
unsigned int VolumicIndexT,
unsigned int SurfacicIndexT,
class TimeDependencyT
template<ParameterNS::Type> class TimeDependencyT
>
template<SourceType SourceTypeT, class T, class InputParameterDataT>
void VolumicAndSurfacicSource<DerivedT, VolumicIndexT, SurfacicIndexT, TimeDependencyT>
......@@ -90,8 +90,9 @@ namespace HappyHeart
class DerivedT,
unsigned int VolumicIndexT,
unsigned int SurfacicIndexT,
class TimeDependencyT
> template<SourceType SourceTypeT>
template<ParameterNS::Type> class TimeDependencyT
>
template<SourceType SourceTypeT>
bool VolumicAndSurfacicSource<DerivedT, VolumicIndexT, SurfacicIndexT, TimeDependencyT>::IsOperatorActivated() const noexcept
{
switch (SourceTypeT)
......@@ -111,7 +112,7 @@ namespace HappyHeart
class DerivedT,
unsigned int VolumicIndexT,
unsigned int SurfacicIndexT,
class TimeDependencyT
template<ParameterNS::Type> class TimeDependencyT
>
template<SourceType SourceTypeT>
inline const GlobalVariationalOperatorNS::TransientSource<TimeDependencyT>&
......@@ -143,7 +144,7 @@ namespace HappyHeart
class DerivedT,
unsigned int VolumicIndexT,
unsigned int SurfacicIndexT,
class TimeDependencyT
template<ParameterNS::Type> class TimeDependencyT
>
const Parameter<ParameterNS::Type::vector, TimeDependencyT>&
VolumicAndSurfacicSource<DerivedT, VolumicIndexT, SurfacicIndexT, TimeDependencyT>
......@@ -159,7 +160,7 @@ namespace HappyHeart
class DerivedT,
unsigned int VolumicIndexT,
unsigned int SurfacicIndexT,
class TimeDependencyT
template<ParameterNS::Type> class TimeDependencyT
>
const Parameter<ParameterNS::Type::vector, TimeDependencyT>&
VolumicAndSurfacicSource<DerivedT, VolumicIndexT, SurfacicIndexT, TimeDependencyT>
......
......@@ -198,10 +198,10 @@ namespace HappyHeart
if (transcellular_current_applied_on_square_parameter_ != nullptr)
{
using no_time_dep = ParameterNS::TimeDependencyNS::None;
transcellular_current_applied_on_square_operator_ =
std::make_unique<GVO::TransientSource<no_time_dep>>(felt_space_highest_dimension,
std::make_unique<GVO::TransientSource<>>(felt_space_highest_dimension,
transcellular_potential,
mesh_dimension,
default_quadrature_rule_set,
......
......@@ -25,16 +25,14 @@ namespace HappyHeart
const auto& god_of_dof = this->GetGodOfDof();
const auto& mesh = god_of_dof.GetGeometricMeshRegion();
using no_time_dep = ParameterNS::TimeDependencyNS::None;
volumic_mass_ = InitScalarParameter<InputParameter::Solid::VolumicMass, no_time_dep>("Volumic mass",
volumic_mass_ = InitScalarParameter<InputParameter::Solid::VolumicMass>("Volumic mass",
mesh,
input_parameter_data);
if (!GetVolumicMass().IsConstant())
throw Exception("Current elastic model is restricted to a constant volumic mass!", __FILE__, __LINE__);
young_modulus_ = InitScalarParameter<InputParameter::Solid::YoungModulus, no_time_dep>("Young modulus",
young_modulus_ = InitScalarParameter<InputParameter::Solid::YoungModulus>("Young modulus",
mesh,
input_parameter_data);
......
......@@ -34,7 +34,7 @@ namespace HappyHeart
*/
template
<
class TimeDependencyT = ParameterNS::TimeDependencyNS::None
template<ParameterNS::Type> class TimeDependencyT = ParameterNS::TimeDependencyNS::None
>
class TransientSource final
: public GlobalVariationalOperator
......
......@@ -20,7 +20,10 @@ namespace HappyHeart
{
template<class TimeDependencyT>
template
<
template<ParameterNS::Type> class TimeDependencyT
>
TransientSource<TimeDependencyT>::TransientSource(const FEltSpace& felt_space,
const Unknown& unknown,
const unsigned int geom_mesh_region_dimension,
......@@ -37,7 +40,10 @@ namespace HappyHeart
{ }
template<class TimeDependencyT>
template
<
template<ParameterNS::Type> class TimeDependencyT
>
const std::string& TransientSource<TimeDependencyT>::ClassName()
{
static std::string name("Transient source");
......@@ -45,7 +51,10 @@ namespace HappyHeart
}
template<class TimeDependencyT>
template
<
template<ParameterNS::Type> class TimeDependencyT
>
template<class LinearAlgebraTupleT>
inline void TransientSource<TimeDependencyT>::Assemble(LinearAlgebraTupleT&& global_vector_with_coeff_tuple,
double time,
......@@ -58,7 +67,10 @@ namespace HappyHeart
template<class TimeDependencyT>
template
<
template<ParameterNS::Type> class TimeDependencyT
>
inline void
TransientSource<TimeDependencyT>
::SetComputeEltArrayArguments(const LocalFEltSpace& local_felt_space,
......
......@@ -35,7 +35,10 @@ namespace HappyHeart
* \todo Improve the comment by writing its mathematical definition!
* \todo #559 Time dependency has been momentarily dropped.
*/
template<class TimeDependencyT>
template
<
template<ParameterNS::Type> class TimeDependencyT
>
class TransientSource final : public LinearLocalVariationalOperator<LocalVector>
{
......
......@@ -20,7 +20,10 @@ namespace HappyHeart
{
template<class TimeDependencyT>
template
<
template<ParameterNS::Type> class TimeDependencyT
>
TransientSource<TimeDependencyT>::TransientSource(const ExtendedUnknown::vector_const_shared_ptr& unknown_list,
typename parent::elementary_data_type&& a_elementary_data,
const Parameter<ParameterNS::Type::vector, TimeDependencyT>& source)
......@@ -29,7 +32,10 @@ namespace HappyHeart
{ }
template<class TimeDependencyT>
template
<
template<ParameterNS::Type> class TimeDependencyT
>
const std::string& TransientSource<TimeDependencyT>::ClassName()
{
static std::string name("TransientSource");
......@@ -37,7 +43,10 @@ namespace HappyHeart
}
template<class TimeDependencyT>
template
<
template<ParameterNS::Type> class TimeDependencyT
>
void TransientSource<TimeDependencyT>::ComputeEltArray() // \todo #559 Reintroduce time dependancy (time_ argument for that...)!
{
auto& elementary_data = GetNonCstElementaryData();
......@@ -80,7 +89,10 @@ namespace HappyHeart
}
template<class TimeDependencyT>
template
<
template<ParameterNS::Type> class TimeDependencyT
>
inline const Parameter<ParameterNS::Type::vector, TimeDependencyT>& TransientSource<TimeDependencyT>
::GetSource() const
{
......@@ -88,7 +100,10 @@ namespace HappyHeart
}
template<class TimeDependencyT>
template
<
template<ParameterNS::Type> class TimeDependencyT
>
inline void TransientSource<TimeDependencyT>::SetTime(double time) noexcept
{
time_ = time;
......
......@@ -27,50 +27,48 @@ namespace HappyHeart
== EnumUnderlyingType(param::size),
"All input parameters must be properly initialized here!");
using no_time_dep = ParameterNS::TimeDependencyNS::None;
parameter_list_[EnumUnderlyingType(param::volumic_mass)] =
InitScalarParameter<InputParameter::Solid::VolumicMass, no_time_dep>("Volumic mass",
InitScalarParameter<InputParameter::Solid::VolumicMass>("Volumic mass",
geometric_mesh_region,
input_parameter_data);
parameter_list_[EnumUnderlyingType(param::lame_lambda)] =
InitScalarParameter<InputParameter::Solid::LameLambda, no_time_dep>("Lame lambda",
InitScalarParameter<InputParameter::Solid::LameLambda>("Lame lambda",
geometric_mesh_region,
input_parameter_data);
parameter_list_[EnumUnderlyingType(param::lame_mu)] =
InitScalarParameter<InputParameter::Solid::LameMu, no_time_dep>("Lame mu",
InitScalarParameter<InputParameter::Solid::LameMu>("Lame mu",
geometric_mesh_region,
input_parameter_data);
parameter_list_[EnumUnderlyingType(param::young_modulus)] =
InitScalarParameter<InputParameter::Solid::YoungModulus, no_time_dep>("Young modulus",
InitScalarParameter<InputParameter::Solid::YoungModulus>("Young modulus",
geometric_mesh_region,
input_parameter_data);
parameter_list_[EnumUnderlyingType(param::poisson_ratio)] =
InitScalarParameter<InputParameter::Solid::PoissonRatio, no_time_dep>("Poisson ratio",
InitScalarParameter<InputParameter::Solid::PoissonRatio>("Poisson ratio",
geometric_mesh_region,
input_parameter_data);
parameter_list_[EnumUnderlyingType(param::kappa_1)] =
InitScalarParameter<InputParameter::Solid::Kappa1, no_time_dep>("Kappa_1",
InitScalarParameter<InputParameter::Solid::Kappa1>("Kappa_1",
geometric_mesh_region,
input_parameter_data);
parameter_list_[EnumUnderlyingType(param::kappa_2)] =
InitScalarParameter<InputParameter::Solid::Kappa2, no_time_dep>("Kappa_2",
InitScalarParameter<InputParameter::Solid::Kappa2>("Kappa_2",
geometric_mesh_region,
input_parameter_data);
parameter_list_[EnumUnderlyingType(param::hyperelastic_bulk)] =
InitScalarParameter<InputParameter::Solid::HyperelasticBulk, no_time_dep>("Hyperelastic bulk",
InitScalarParameter<InputParameter::Solid::HyperelasticBulk>("Hyperelastic bulk",
geometric_mesh_region,
input_parameter_data);
parameter_list_[EnumUnderlyingType(param::viscosity)] =
InitScalarParameter<InputParameter::Solid::Viscosity, no_time_dep>("Viscosity",
InitScalarParameter<InputParameter::Solid::Viscosity>("Viscosity",
geometric_mesh_region,
input_parameter_data);
......
......@@ -55,7 +55,7 @@ namespace HappyHeart
template
<
class ParameterT,
class TimeDependencyT = ParameterNS::TimeDependencyNS::None,
template<ParameterNS::Type> class TimeDependencyT = ParameterNS::TimeDependencyNS::None,
class StringT,
class InputParameterDataT
>
......@@ -67,7 +67,7 @@ namespace HappyHeart
template
<
class ParameterT,
class TimeDependencyT = ParameterNS::TimeDependencyNS::None,
template<ParameterNS::Type> class TimeDependencyT = ParameterNS::TimeDependencyNS::None,
class StringT,
class InputParameterDataT
>
......
......@@ -21,7 +21,7 @@ namespace HappyHeart
template
<
class ParameterT,
class TimeDependencyT,
template<ParameterNS::Type> class TimeDependencyT,
class T,
class InputParameterDataT
>
......@@ -69,7 +69,7 @@ namespace HappyHeart
template
<
class ParameterT,
class TimeDependencyT,
template<ParameterNS::Type> class TimeDependencyT,
class T,
class InputParameterDataT
>
......
......@@ -25,13 +25,16 @@ namespace HappyHeart
namespace ParameterNS
{
/*!
* \brief Class to handle a 3D parameter (for instance a force).
*
* Such objects should in most if not all cases be initialized with InitThreeDimensionalParameter() free function.
*/
template<class TimeDependencyT>
template
<
template<ParameterNS::Type> class TimeDependencyT
>
class ThreeDimensionalParameter final
: public Parameter
<
......@@ -46,7 +49,11 @@ namespace HappyHeart
using self = ThreeDimensionalParameter;
//! Alias to base class.
using parent = Parameter<ParameterNS::Type::vector, TimeDependencyT>;
using parent = Parameter
<
ParameterNS::Type::vector,
TimeDependencyT
>;
//! Alias to return type.
using return_type = typename parent::return_type;
......
......@@ -19,8 +19,10 @@ namespace HappyHeart
namespace ParameterNS
{
template<class TimeDependencyT>
template
<
template<ParameterNS::Type> class TimeDependencyT
>
void ThreeDimensionalParameter<TimeDependencyT>::SupplWrite(std::ostream& out) const
{
out << "# This parameter is defined from three scalar parameters:" << std::endl;
......@@ -33,7 +35,10 @@ namespace HappyHeart
}
template<class TimeDependencyT>
template
<
template<ParameterNS::Type> class TimeDependencyT
>
template<class T>
ThreeDimensionalParameter<TimeDependencyT>
::ThreeDimensionalParameter(T&& name,
......@@ -62,7 +67,10 @@ namespace HappyHeart
}
template<class TimeDependencyT>
template
<
template<ParameterNS::Type> class TimeDependencyT
>
inline typename ThreeDimensionalParameter<TimeDependencyT>::scalar_parameter&
ThreeDimensionalParameter<TimeDependencyT>
::GetScalarParameterX() const
......@@ -72,7 +80,10 @@ namespace HappyHeart
}
template<class TimeDependencyT>
template
<
template<ParameterNS::Type> class TimeDependencyT
>
inline typename ThreeDimensionalParameter<TimeDependencyT>::scalar_parameter&
ThreeDimensionalParameter<TimeDependencyT>
::GetScalarParameterY() const
......@@ -82,7 +93,10 @@ namespace HappyHeart
}
template<class TimeDependencyT>
template
<
template<ParameterNS::Type> class TimeDependencyT
>
inline typename ThreeDimensionalParameter<TimeDependencyT>::scalar_parameter&
ThreeDimensionalParameter<TimeDependencyT>
::GetScalarParameterZ() const
......@@ -92,7 +106,10 @@ namespace HappyHeart
}
template<class TimeDependencyT>
template
<
template<ParameterNS::Type> class TimeDependencyT
>
inline bool ThreeDimensionalParameter<TimeDependencyT>::IsConstant() const
{
return GetScalarParameterX().IsConstant()
......@@ -101,7 +118,10 @@ namespace HappyHeart
}
template<class TimeDependencyT>
template
<
template<ParameterNS::Type> class TimeDependencyT
>
inline typename ThreeDimensionalParameter<TimeDependencyT>::return_type
ThreeDimensionalParameter<TimeDependencyT>
::SupplGetConstantValue() const
......@@ -110,7 +130,10 @@ namespace HappyHeart
}
template<class TimeDependencyT>
template
<
template<ParameterNS::Type> class TimeDependencyT
>
inline typename ThreeDimensionalParameter<TimeDependencyT>::return_type
ThreeDimensionalParameter<TimeDependencyT>
::SupplGetValue(const QuadraturePoint& quad_pt,
......
......@@ -76,7 +76,7 @@ namespace HappyHeart
template
<
ParameterNS::Type TypeT,
class TimeDependencyT
template<ParameterNS::Type> class TimeDependencyT = ParameterNS::TimeDependencyNS::None
>
class Parameter
{
......@@ -155,7 +155,7 @@ namespace HappyHeart
*
* \param[in] time_dependency Unique pointer to the time dependency object to set.
*/
void SetTimeDependency(typename TimeDependencyT::unique_ptr&& time_dependency);
void SetTimeDependency(typename TimeDependencyT<TypeT>::unique_ptr&& time_dependency);
/*!
......@@ -244,14 +244,14 @@ namespace HappyHeart
const GeometricMeshRegion& geometric_mesh_region_;
//!
typename TimeDependencyT::unique_ptr time_dependency_ = nullptr;
typename TimeDependencyT<TypeT>::unique_ptr time_dependency_ = nullptr;
};
//! Convenient alias to define a scalar parameter.
template
<
class TimeDependencyT = ParameterNS::TimeDependencyNS::None
template<ParameterNS::Type> class TimeDependencyT = ParameterNS::TimeDependencyNS::None
>
using ScalarParameter = Parameter<ParameterNS::Type::scalar, TimeDependencyT>;
......
......@@ -19,7 +19,7 @@ namespace HappyHeart
template
<
ParameterNS::Type TypeT,
class TimeDependencyT
template<ParameterNS::Type> class TimeDependencyT
>
template<class T>
Parameter<TypeT, TimeDependencyT>::Parameter(T&& name,
......@@ -32,12 +32,12 @@ namespace HappyHeart
template
<
ParameterNS::Type TypeT,
class TimeDependencyT
template<ParameterNS::Type> class TimeDependencyT
>
void Parameter<TypeT, TimeDependencyT>
::SetTimeDependency(typename TimeDependencyT::unique_ptr&& time_dependency)
::SetTimeDependency(typename TimeDependencyT<TypeT>::unique_ptr&& time_dependency)
{
static_assert(!std::is_same<TimeDependencyT, ParameterNS::TimeDependencyNS::None>::value,
static_assert(!std::is_same<TimeDependencyT<TypeT>, ParameterNS::TimeDependencyNS::None<TypeT>>::value,
"Should not be called for Parameters without time dependency!");
assert(time_dependency_ == nullptr && "Should be assigned only once!");
......@@ -49,7 +49,7 @@ namespace HappyHeart
template
<
ParameterNS::Type TypeT,
class TimeDependencyT
template<ParameterNS::Type> class TimeDependencyT
>
inline typename Parameter<TypeT, TimeDependencyT>::return_type Parameter<TypeT, TimeDependencyT>
::GetConstantValue() const
......@@ -63,7 +63,7 @@ namespace HappyHeart
template
<
ParameterNS::Type TypeT,
class TimeDependencyT
template<ParameterNS::Type> class TimeDependencyT
>
inline typename Parameter<TypeT, TimeDependencyT>::return_type Parameter<TypeT, TimeDependencyT>
::GetValue(const QuadraturePoint& quad_pt, const GeometricElt& geom_elt) const
......@@ -78,7 +78,7 @@ namespace HappyHeart
template
<
ParameterNS::Type TypeT,
class TimeDependencyT
template<ParameterNS::Type> class TimeDependencyT
>
inline void Parameter<TypeT, TimeDependencyT>::Write(const std::string& filename) const
{
......@@ -91,7 +91,7 @@ namespace HappyHeart
template
<
ParameterNS::Type TypeT,
class TimeDependencyT
template<ParameterNS::Type> class TimeDependencyT
>
inline void Parameter<TypeT, TimeDependencyT>::Write(std::ostream& out) const
{
......@@ -103,7 +103,7 @@ namespace HappyHeart
template
<
ParameterNS::Type TypeT,
class TimeDependencyT
template<ParameterNS::Type> class TimeDependencyT
>
inline const std::string& Parameter<TypeT, TimeDependencyT>::GetName() const
{
......@@ -114,7 +114,7 @@ namespace HappyHeart
template
<
ParameterNS::Type TypeT,
class TimeDependencyT
template<ParameterNS::Type> class TimeDependencyT
>
inline const GeometricMeshRegion& Parameter<TypeT, TimeDependencyT>::GetGeometricMeshRegion() const noexcept
{
......
......@@ -47,7 +47,7 @@ namespace HappyHeart
template
<
ParameterNS::Type TypeT,
class TimeDependencyT = ParameterNS::TimeDependencyNS::None,
template<ParameterNS::Type> class TimeDependencyT = ParameterNS::TimeDependencyNS::None,
unsigned int NfeltSpace = 1
>
struct ParameterAtDof
......
......@@ -41,7 +41,7 @@ namespace HappyHeart
template
<
ParameterNS::Type TypeT,
class TimeDependencyT = ParameterNS::TimeDependencyNS::None
template<ParameterNS::Type> class TimeDependencyT = ParameterNS::TimeDependencyNS::None
>
using ParameterAtQuadraturePoint =
Private::ParameterInstance
......
......@@ -67,7 +67,7 @@ namespace HappyHeart
template