Commit abdf92ce authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#1193 Test test function may not run without a full-fledged Solid in the input...

#1193 Test test function may not run without a full-fledged Solid in the input parameter (here the Mu_i and C_i aren't provided). For this prototype to work I had to deactivate some code; I will put it back properly and add comments in the next commits. Likewise, currently only Mu_i and C_i are optional; I will mimic that for all relevant Solid parameters.

[WARNING] The models with a Solid involve might not compile!
parent 83d5cda9
......@@ -66,11 +66,11 @@
<CommandLineArguments>
<CommandLineArgument
argument = "-i ${HOME}/Codes/HappyHeart/Sources/Test/Operators/TestFunctions/demo_input_parameter_test_functions_1D.lua"
isEnabled = "YES">
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "-i ${HOME}/Codes/HappyHeart/Sources/Test/Operators/TestFunctions/demo_input_parameter_test_functions_2D.lua"
isEnabled = "NO">
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "-i ${HOME}/Codes/HappyHeart/Sources/Test/Operators/TestFunctions/demo_input_parameter_test_functions_3D.lua"
......
......@@ -44,9 +44,9 @@ namespace HappyHeart
CiarletGeymonat::CiarletGeymonat(const Solid& solid)
: kappa1_(solid.template GetParameter<Solid::param::kappa_1>()),
kappa2_(solid.GetParameter<Solid::param::kappa_2>()),
bulk_(solid.GetParameter<Solid::param::hyperelastic_bulk>())
: kappa1_(solid.GetKappa1()),
kappa2_(solid.GetKappa2()),
bulk_(solid.GetHyperelasticBulk())
{ }
......
......@@ -45,13 +45,13 @@ namespace HappyHeart
ExponentialJ1J4::ExponentialJ1J4(const Solid& solid,
const FiberList<ParameterNS::Type::vector>* fibers)
: mu_1_(solid.template GetParameter<Solid::param::mu_1>()),
mu_2_(solid.GetParameter<Solid::param::mu_2>()),
c_0_(solid.GetParameter<Solid::param::c_0>()),
c_1_(solid.GetParameter<Solid::param::c_1>()),
c_2_(solid.GetParameter<Solid::param::c_2>()),
c_3_(solid.GetParameter<Solid::param::c_3>()),
bulk_(solid.GetParameter<Solid::param::hyperelastic_bulk>()),
: mu_1_(solid.GetMu1()),
mu_2_(solid.GetMu2()),
c_0_(solid.GetC0()),
c_1_(solid.GetC1()),
c_2_(solid.GetC2()),
c_3_(solid.GetC3()),
bulk_(solid.GetHyperelasticBulk()),
fibers_(fibers)
{ }
......
......@@ -37,9 +37,9 @@ namespace HappyHeart
MooneyRivlin::MooneyRivlin(const Solid& solid)
: kappa1_(solid.GetParameter<Solid::param::kappa_1>()),
kappa2_(solid.GetParameter<Solid::param::kappa_2>()),
bulk_(solid.GetParameter<Solid::param::hyperelastic_bulk>())
: kappa1_(solid.GetKappa1()),
kappa2_(solid.GetKappa2()),
bulk_(solid.GetHyperelasticBulk())
{ }
double MooneyRivlin::W(const invariant_holder_type& invariant_holder,
......
......@@ -43,9 +43,9 @@ namespace HappyHeart
StVenantKirchhoff::StVenantKirchhoff(const Solid& solid)
: lame_lambda_(solid.GetParameter<Solid::param::lame_lambda>()),
lame_mu_(solid.GetParameter<Solid::param::lame_mu>()),
bulk_(solid.GetParameter<Solid::param::hyperelastic_bulk>())
: lame_lambda_(solid.GetLameLambda()),
lame_mu_(solid.GetLameMu()),
bulk_(solid.GetHyperelasticBulk())
{ }
......
......@@ -114,53 +114,46 @@ namespace HappyHeart
///@}
public:
/*!
* \brief Enum to tag each scalar parameter encompassed by the class.
*
* \internal <b><tt>[internal]</tt></b> Underlying values must be 0 to Nparam - 1, with 'size' closing the enum.
*/
enum class param : std::size_t
{
volumic_mass = 0,
young_modulus,
poisson_ratio,
lame_lambda,
lame_mu,
kappa_1,
kappa_2,
hyperelastic_bulk,
viscosity,
mu_1,
mu_2,
c_0,
c_1,
c_2,
c_3,
size
};
public:
//! Get access to one of the parameter.
template<param ParamT>
const scalar_parameter& GetParameter() const noexcept;
/*!
* \brief Print the content of \a Solid assuming all parameters are spatially constant.
*
* \param[in] stream Stream onto which content is written.
*/
void Print(std::ostream& stream) const;
const scalar_parameter& GetVolumicMass() const noexcept;
const scalar_parameter& GetHyperelasticBulk() const noexcept;
const scalar_parameter& GetKappa1() const noexcept;
const scalar_parameter& GetKappa2() const noexcept;
const scalar_parameter& GetYoungModulus() const noexcept;
const scalar_parameter& GetPoissonRatio() const noexcept;
const scalar_parameter& GetLameLambda() const noexcept;
const scalar_parameter& GetLameMu() const noexcept;
const scalar_parameter& GetMu1() const noexcept;
const scalar_parameter& GetMu2() const noexcept;
const scalar_parameter& GetC0() const noexcept;
const scalar_parameter& GetC1() const noexcept;
const scalar_parameter& GetC2() const noexcept;
const scalar_parameter& GetC3() const noexcept;
/*!
* \brief Whether the parameter has been initialized or not.
*
* \return True if it is defined, false otherwise.
*/
template<param ParamT>
bool IsActivated() const noexcept;
const scalar_parameter& GetViscosity() const noexcept;
private:
......@@ -176,10 +169,6 @@ namespace HappyHeart
//! Domain upon which the solid is described.
const Domain& GetDomain() const noexcept;
//! Get access to the unique_ptr that may (or not) store a parameter.
template<param ParamT>
const scalar_parameter::unique_ptr& GetParameterPtr() const noexcept;
//! Quadrature rule to use for each type of topology.
const QuadratureRulePerTopology& GetQuadratureRulePerTopology() const noexcept;
......@@ -188,11 +177,25 @@ namespace HappyHeart
//! Domain upon which the solid is described.
const Domain& domain_;
//! Storage for all scalar parameters encompassed by the class.
scalar_parameter::array_unique_ptr<EnumUnderlyingType(param::size)> parameter_list_;
//! Quadrature rule to use for each type of topology.
const QuadratureRulePerTopology& quadrature_rule_per_topology_;
scalar_parameter::unique_ptr volumic_mass_ = nullptr;
scalar_parameter::unique_ptr hyperelastic_bulk_ = nullptr;
scalar_parameter::array_unique_ptr<2> kappa_list_ { { nullptr, nullptr } };
scalar_parameter::array_unique_ptr<2> young_poisson_ { { nullptr, nullptr } };
scalar_parameter::array_unique_ptr<2> lame_coeff_ { { nullptr, nullptr } };
scalar_parameter::array_unique_ptr<6> mu_i_C_i_ { { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr } };
scalar_parameter::unique_ptr viscosity_ = nullptr;
};
......
......@@ -26,128 +26,206 @@ namespace HappyHeart
quadrature_rule_per_topology_(quadrature_rule_per_topology)
{
static_assert(std::tuple_size<InputParameter::Solid::section_content_type>::value
== EnumUnderlyingType(param::size),
"All input parameters must be properly initialized here!");
parameter_list_[EnumUnderlyingType(param::volumic_mass)] =
volumic_mass_ =
InitScalarParameterFromInputData<InputParameter::Solid::VolumicMass>("Volumic mass",
domain,
input_parameter_data);
parameter_list_[EnumUnderlyingType(param::lame_lambda)] =
std::get<0>(lame_coeff_) =
InitScalarParameterFromInputData<InputParameter::Solid::LameLambda>("Lame lambda",
domain,
input_parameter_data);
parameter_list_[EnumUnderlyingType(param::lame_mu)] =
std::get<1>(lame_coeff_) =
InitScalarParameterFromInputData<InputParameter::Solid::LameMu>("Lame mu",
domain,
input_parameter_data);
parameter_list_[EnumUnderlyingType(param::young_modulus)] =
std::get<0>(young_poisson_) =
InitScalarParameterFromInputData<InputParameter::Solid::YoungModulus>("Young modulus",
domain,
input_parameter_data);
parameter_list_[EnumUnderlyingType(param::poisson_ratio)] =
std::get<1>(young_poisson_) =
InitScalarParameterFromInputData<InputParameter::Solid::PoissonRatio>("Poisson ratio",
domain,
input_parameter_data);
parameter_list_[EnumUnderlyingType(param::kappa_1)] =
std::get<0>(kappa_list_) =
InitScalarParameterFromInputData<InputParameter::Solid::Kappa1>("Kappa_1",
domain,
input_parameter_data);
parameter_list_[EnumUnderlyingType(param::kappa_2)] =
std::get<1>(kappa_list_) =
InitScalarParameterFromInputData<InputParameter::Solid::Kappa2>("Kappa_2",
domain,
input_parameter_data);
parameter_list_[EnumUnderlyingType(param::hyperelastic_bulk)] =
hyperelastic_bulk_ =
InitScalarParameterFromInputData<InputParameter::Solid::HyperelasticBulk>("Hyperelastic bulk",
domain,
input_parameter_data);
parameter_list_[EnumUnderlyingType(param::viscosity)] =
viscosity_ =
InitScalarParameterFromInputData<InputParameter::Solid::Viscosity>("Viscosity",
domain,
input_parameter_data);
parameter_list_[EnumUnderlyingType(param::mu_1)] =
InitScalarParameterFromInputData<InputParameter::Solid::Mu1>("Mu1",
domain,
input_parameter_data);
parameter_list_[EnumUnderlyingType(param::mu_2)] =
InitScalarParameterFromInputData<InputParameter::Solid::Mu2>("Mu2",
domain,
input_parameter_data);
parameter_list_[EnumUnderlyingType(param::c_0)] =
InitScalarParameterFromInputData<InputParameter::Solid::C0>("C0",
domain,
input_parameter_data);
parameter_list_[EnumUnderlyingType(param::c_1)] =
InitScalarParameterFromInputData<InputParameter::Solid::C1>("C1",
domain,
input_parameter_data);
// Here only Mu1 is checked: all Mu_i and C_i are assumed to get the same status (i.e. defined or not
// defined).
if constexpr (Utilities::Tuple::IndexOf<InputParameter::Solid::Mu1, typename InputParameterDataT::Tuple>::value != NumericNS::UninitializedIndex<unsigned int>())
{
std::get<0>(mu_i_C_i_) =
InitScalarParameterFromInputData<InputParameter::Solid::Mu1>("Mu1",
domain,
input_parameter_data);
std::get<1>(mu_i_C_i_) =
InitScalarParameterFromInputData<InputParameter::Solid::Mu2>("Mu2",
domain,
input_parameter_data);
std::get<2>(mu_i_C_i_) =
InitScalarParameterFromInputData<InputParameter::Solid::C0>("C0",
domain,
input_parameter_data);
parameter_list_[EnumUnderlyingType(param::c_2)] =
InitScalarParameterFromInputData<InputParameter::Solid::C2>("C2",
domain,
input_parameter_data);
std::get<3>(mu_i_C_i_) =
InitScalarParameterFromInputData<InputParameter::Solid::C1>("C1",
domain,
input_parameter_data);
parameter_list_[EnumUnderlyingType(param::c_3)] =
InitScalarParameterFromInputData<InputParameter::Solid::C3>("C3",
domain,
input_parameter_data);
std::get<4>(mu_i_C_i_) =
InitScalarParameterFromInputData<InputParameter::Solid::C2>("C2",
domain,
input_parameter_data);
std::get<5>(mu_i_C_i_) =
InitScalarParameterFromInputData<InputParameter::Solid::C3>("C3",
domain,
input_parameter_data);
}
CheckConsistency(relative_tolerance);
}
template<Solid::param ParamT>
const Solid::scalar_parameter& Solid::GetParameter() const noexcept
{
decltype(auto) ptr = GetParameterPtr<ParamT>();
assert(!(!ptr)&& "Check this parameter is not set to 'ignore' in "
"input parameter file.");
return *ptr;
inline const Domain& Solid::GetDomain() const noexcept
{
return domain_;
}
template<Solid::param ParamT>
const Solid::scalar_parameter::unique_ptr& Solid::GetParameterPtr() const noexcept
inline const QuadratureRulePerTopology& Solid::GetQuadratureRulePerTopology() const noexcept
{
static_assert(ParamT < param::size, "");
return parameter_list_[EnumUnderlyingType(ParamT)];
return quadrature_rule_per_topology_;
}
template<Solid::param ParamT>
bool Solid::IsActivated() const noexcept
inline const Solid::scalar_parameter& Solid::GetVolumicMass() const noexcept
{
static_assert(ParamT < param::size, "");
return GetParameterPtr<ParamT>() != nullptr;
assert(!(!volumic_mass_));
return *volumic_mass_;
}
inline const Domain& Solid::GetDomain() const noexcept
inline const Solid::scalar_parameter& Solid::GetHyperelasticBulk() const noexcept
{
return domain_;
assert(!(!hyperelastic_bulk_));
return *hyperelastic_bulk_;
}
inline const QuadratureRulePerTopology& Solid::GetQuadratureRulePerTopology() const noexcept
inline const Solid::scalar_parameter& Solid::GetKappa1() const noexcept
{
return quadrature_rule_per_topology_;
decltype(auto) ptr = std::get<0>(kappa_list_);
assert(!(!ptr));
return *ptr;
}
inline const Solid::scalar_parameter& Solid::GetKappa2() const noexcept
{
decltype(auto) ptr = std::get<1>(kappa_list_);
assert(!(!ptr));
return *ptr;
}
inline const Solid::scalar_parameter& Solid::GetYoungModulus() const noexcept
{
decltype(auto) ptr = std::get<0>(young_poisson_);
assert(!(!ptr));
return *ptr;
}
inline const Solid::scalar_parameter& Solid::GetPoissonRatio() const noexcept
{
decltype(auto) ptr = std::get<1>(young_poisson_);
assert(!(!ptr));
return *ptr;
}
inline const Solid::scalar_parameter& Solid::GetLameLambda() const noexcept
{
decltype(auto) ptr = std::get<0>(lame_coeff_);
assert(!(!ptr));
return *ptr;
}
inline const Solid::scalar_parameter& Solid::GetLameMu() const noexcept
{
decltype(auto) ptr = std::get<1>(lame_coeff_);
assert(!(!ptr));
return *ptr;
}
inline const Solid::scalar_parameter& Solid::GetMu1() const noexcept
{
decltype(auto) ptr = std::get<0>(mu_i_C_i_);
assert(!(!ptr));
return *ptr;
}
inline const Solid::scalar_parameter& Solid::GetMu2() const noexcept
{
decltype(auto) ptr = std::get<1>(mu_i_C_i_);
assert(!(!ptr));
return *ptr;
}
inline const Solid::scalar_parameter& Solid::GetC0() const noexcept
{
decltype(auto) ptr = std::get<2>(mu_i_C_i_);
assert(!(!ptr));
return *ptr;
}
inline const Solid::scalar_parameter& Solid::GetC1() const noexcept
{
decltype(auto) ptr = std::get<3>(mu_i_C_i_);
assert(!(!ptr));
return *ptr;
}
inline const Solid::scalar_parameter& Solid::GetC2() const noexcept
{
decltype(auto) ptr = std::get<4>(mu_i_C_i_);
assert(!(!ptr));
return *ptr;
}
inline const Solid::scalar_parameter& Solid::GetC3() const noexcept
{
decltype(auto) ptr = std::get<5>(mu_i_C_i_);
assert(!(!ptr));
return *ptr;
}
inline const Solid::scalar_parameter& Solid::GetViscosity() const noexcept
{
assert(!(!viscosity_));
return *viscosity_;
}
} // namespace HappyHeart
......
......@@ -144,7 +144,15 @@ namespace HappyHeart
InputParameter::ScalarTransientSource<EnumUnderlyingType(ForceIndexList::source)>,
InputParameter::Solid,
InputParameter::Solid::VolumicMass,
InputParameter::Solid::HyperelasticBulk,
InputParameter::Solid::Kappa1,
InputParameter::Solid::Kappa2,
InputParameter::Solid::PoissonRatio,
InputParameter::Solid::YoungModulus,
InputParameter::Solid::LameLambda,
InputParameter::Solid::LameMu,
InputParameter::Solid::Viscosity,
InputParameter::Solid::PlaneStressStrain,
InputParameter::Fluid::Viscosity,
......
......@@ -12,6 +12,8 @@
#ifndef HAPPY_HEART_x_UTILITIES_x_CONTAINERS_x_INTERNAL_x_TUPLE_HELPER_HPP_
# define HAPPY_HEART_x_UTILITIES_x_CONTAINERS_x_INTERNAL_x_TUPLE_HELPER_HPP_
#include "Utilities/Numeric/Numeric.hpp"
namespace HappyHeart
{
......@@ -59,7 +61,7 @@ namespace HappyHeart
struct IndexOfHelper<T, TupleT, 0>
{
using type = typename std::tuple_element<0, TupleT>::type;
enum { value = (std::is_same<T, type>::value == 1 ? 0 : -1) };
enum { value = (std::is_same<T, type>::value == 1 ? 0u : NumericNS::UninitializedIndex<unsigned int>()) };
};
//! \endcond IGNORE_BLOCK_IN_DOXYGEN
......
......@@ -36,7 +36,7 @@ namespace HappyHeart
/*!
** \brief Find the index of a given type in a tuple (used here as a typelist)
**
** If none found, value is -1, otherwise the index is returned
** If none found, value is NumericNS::UninitializedIndex<unsigned int>, otherwise the index is returned.
**
**
** If a same structure appears several time in the tuple (which doesn't make
......@@ -46,9 +46,13 @@ namespace HappyHeart
** \tparam T Class looked at in the tuple
** \tparam TupleT std::tuple which is investigated
*
* NOTE: C++ 14 will provide this functionality natively, with the restriction that the type given
* must be given only once. However, IndexOf is always used in that context, so the native functionality should
* be used when available.
* NOTE: Since C++ 14, std::get provides basically the same functionality. However, there are two
* restrictions current class doesn't have, the second of which is problematic for our use:
* - std::get<> fails to compile if a same type appears twice in the tuple, whereas here the first
* instance is returned with IndexOf. In our use std::get<> behavior would be as good (if not better)
* than our current implementation.
* - std::get<> fails to compile if T doesn't exist in the tuple. In some cases we would like to handle
* it more smoothly hence IndexOf that in this case just returns -1.
*/
template<class T, class TupleT>
class IndexOf
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment