Attention une mise à jour du service Gitlab va être effectuée le mardi 18 janvier (et non lundi 17 comme annoncé précédemment) entre 18h00 et 18h30. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes.

Commit 9f954991 authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#1193 Document the new methods in Solid and make all options save volumic mass optional.

[WARNING] The models with a Solid involve might not compile!
parent abdf92ce
......@@ -175,8 +175,8 @@ class CreateAccessors:
else:
print("template\n<")
for arg in self._template_args[:-1]:
print "\t{0},".format(arg)
print "\t{0}\n>".format(self._template_args[-1])
print("\t{0},".format(arg))
print("\t{0}\n>".format(self._template_args[-1]))
......
......@@ -122,38 +122,183 @@ namespace HappyHeart
*
* \param[in] stream Stream onto which content is written.
*/
void Print(std::ostream& stream) const;
void Print(std::ostream& stream) const;
//! Constant accessor to the volumic mass.
const scalar_parameter& GetVolumicMass() const noexcept;
/*!
* \class doxygen_hide_solid_optional_for_accessor
*
* \attention This method assumes the parameter is relevant for your model (i.e. it was addressed in the
* input parameter file). If not, it should not be called at all!
*
* You may check existence priori to the call with IsXXX() methods, for
* instance:
* \code
if (solid.IsKappa1())
{
decltype(auto) kappa1 = solid.GetKappa1();
...
}
* \endcode
*
* \return The \a Parameter object.
*/
/*!
* \brief Constant accessor to the hyperelastic bulk.
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetHyperelasticBulk() const noexcept;
/*!
* \brief Constant accessor to Kappa1.
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetKappa1() const noexcept;
/*!
* \brief Constant accessor to Kappa2.
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetKappa2() const noexcept;
/*!
* \brief Constant accessor to the Young modulus.
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetYoungModulus() const noexcept;
/*!
* \brief Constant accessor to the Poisson ratio.
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetPoissonRatio() const noexcept;
/*!
* \brief Constant accessor to Lame lambda.
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetLameLambda() const noexcept;
/*!
* \brief Constant accessor to Lame mu.
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetLameMu() const noexcept;
/*!
* \brief Constant accessor to mu1.
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetMu1() const noexcept;
/*!
* \brief Constant accessor to mu2.
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetMu2() const noexcept;
/*!
* \brief Constant accessor to C0.
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetC0() const noexcept;
/*!
* \brief Constant accessor to C1.
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetC1() const noexcept;
/*!
* \brief Constant accessor to C2.
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetC2() const noexcept;
/*!
* \brief Constant accessor to C3.
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetC3() const noexcept;
/*!
* \brief Constant accessor to the viscosity.
*
* \copydoc doxygen_hide_solid_optional_for_accessor
*/
const scalar_parameter& GetViscosity() const noexcept;
public:
/*!
* \class doxygen_hide_solid_is_method
*
* \brief Whether the parameter is relevant for the \a Model considered.
*
* It might be irrelevant in two ways:
* - Either it's truly pointless for the \a Model, and it's not even present in the \a InputParameterData.
* - Or it's present but the user chose the value 'ignore' as the nature of the parameter.
*
* \return True if the related accessor may be used safely.
*/
//! \copydoc doxygen_hide_solid_is_method
bool IsHyperelasticBulk() const noexcept;
//! \copydoc doxygen_hide_solid_is_method
bool IsKappa1() const noexcept;
//! \copydoc doxygen_hide_solid_is_method
bool IsKappa2() const noexcept;
//! \copydoc doxygen_hide_solid_is_method
bool IsYoungModulus() const noexcept;
//! \copydoc doxygen_hide_solid_is_method
bool IsPoissonRatio() const noexcept;
//! \copydoc doxygen_hide_solid_is_method
bool IsLameLambda() const noexcept;
//! \copydoc doxygen_hide_solid_is_method
bool IsLameMu() const noexcept;
//! \copydoc doxygen_hide_solid_is_method
bool IsMu1() const noexcept;
//! \copydoc doxygen_hide_solid_is_method
bool IsMu2() const noexcept;
//! \copydoc doxygen_hide_solid_is_method
bool IsC0() const noexcept;
//! \copydoc doxygen_hide_solid_is_method
bool IsC1() const noexcept;
//! \copydoc doxygen_hide_solid_is_method
bool IsC2() const noexcept;
//! \copydoc doxygen_hide_solid_is_method
bool IsC3() const noexcept;
//! \copydoc doxygen_hide_solid_is_method
bool IsViscosity() const noexcept;
private:
......@@ -180,19 +325,63 @@ namespace HappyHeart
//! Quadrature rule to use for each type of topology.
const QuadratureRulePerTopology& quadrature_rule_per_topology_;
//! Volumic mass.
scalar_parameter::unique_ptr volumic_mass_ = nullptr;
/*!
* \class doxygen_hide_solid_optional_singular
*
* Might stay nullptr if this solid parameter is not relevant for the current \a Model (i.e. it is not
* an entry in the input parameter file).
*/
/*!
* \class doxygen_hide_solid_optional_plural
*
* Might stay nullptr if these solid parameters are not relevant for the current \a Model (i.e. it is not
* entries in the input parameter file).
*/
/*!
* \brief Hyperelastic bulk.
*
* \copydoc doxygen_hide_solid_optional_singular
*/
scalar_parameter::unique_ptr hyperelastic_bulk_ = nullptr;
/*!
* \brief Kappa1 and kappa2.
*
* \copydoc doxygen_hide_solid_optional_plural
*/
scalar_parameter::array_unique_ptr<2> kappa_list_ { { nullptr, nullptr } };
/*!
* \brief Young modulus and poisson ratio.
*
* \copydoc doxygen_hide_solid_optional_plural
*/
scalar_parameter::array_unique_ptr<2> young_poisson_ { { nullptr, nullptr } };
/*!
* \brief Lame coefficients (lambda first then mu).
*
* \copydoc doxygen_hide_solid_optional_plural
*/
scalar_parameter::array_unique_ptr<2> lame_coeff_ { { nullptr, nullptr } };
/*!
* \brief Mu1, Mu2, C0 to C3.
*
* \copydoc doxygen_hide_solid_optional_plural
*/
scalar_parameter::array_unique_ptr<6> mu_i_C_i_ { { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr } };
/*!
* \brief Viscosity.
*
* \copydoc doxygen_hide_solid_optional_singular
*/
scalar_parameter::unique_ptr viscosity_ = nullptr;
......
......@@ -15,6 +15,20 @@
namespace HappyHeart
{
namespace // anonymous
{
template<class InputParameterDataT, class T>
constexpr bool IsDefined()
{
return (Utilities::Tuple::IndexOf<T, typename InputParameterDataT::Tuple>::value != NumericNS::UninitializedIndex<unsigned int>());
}
} // namespace anonymous
template<class InputParameterDataT>
......@@ -26,57 +40,86 @@ namespace HappyHeart
quadrature_rule_per_topology_(quadrature_rule_per_topology)
{
using SolidIP = InputParameter::Solid;
volumic_mass_ =
InitScalarParameterFromInputData<InputParameter::Solid::VolumicMass>("Volumic mass",
domain,
input_parameter_data);
std::get<0>(lame_coeff_) =
InitScalarParameterFromInputData<InputParameter::Solid::LameLambda>("Lame lambda",
if constexpr (IsDefined<InputParameterDataT, SolidIP::LameLambda>())
{
static_assert(IsDefined<InputParameterDataT, SolidIP::LameMu>(),
"It makes no sense to define one and not the other");
std::get<0>(lame_coeff_) =
InitScalarParameterFromInputData<InputParameter::Solid::LameLambda>("Lame lambda",
domain,
input_parameter_data);
std::get<1>(lame_coeff_) =
InitScalarParameterFromInputData<InputParameter::Solid::LameMu>("Lame mu",
domain,
input_parameter_data);
}
std::get<1>(lame_coeff_) =
InitScalarParameterFromInputData<InputParameter::Solid::LameMu>("Lame mu",
domain,
input_parameter_data);
std::get<0>(young_poisson_) =
InitScalarParameterFromInputData<InputParameter::Solid::YoungModulus>("Young modulus",
domain,
input_parameter_data);
if constexpr (IsDefined<InputParameterDataT, SolidIP::YoungModulus>())
{
static_assert(IsDefined<InputParameterDataT, SolidIP::PoissonRatio>(),
"It makes no sense to define one and not the other");
std::get<0>(young_poisson_) =
InitScalarParameterFromInputData<InputParameter::Solid::YoungModulus>("Young modulus",
domain,
input_parameter_data);
std::get<1>(young_poisson_) =
InitScalarParameterFromInputData<InputParameter::Solid::PoissonRatio>("Poisson ratio",
domain,
input_parameter_data);
std::get<1>(young_poisson_) =
InitScalarParameterFromInputData<InputParameter::Solid::PoissonRatio>("Poisson ratio",
domain,
input_parameter_data);
}
std::get<0>(kappa_list_) =
InitScalarParameterFromInputData<InputParameter::Solid::Kappa1>("Kappa_1",
domain,
input_parameter_data);
if constexpr (IsDefined<InputParameterDataT, SolidIP::Kappa1>())
{
static_assert(IsDefined<InputParameterDataT, SolidIP::Kappa2>(),
"It makes no sense to define one and not the other");
std::get<0>(kappa_list_) =
InitScalarParameterFromInputData<InputParameter::Solid::Kappa1>("Kappa_1",
domain,
input_parameter_data);
std::get<1>(kappa_list_) =
InitScalarParameterFromInputData<InputParameter::Solid::Kappa2>("Kappa_2",
domain,
input_parameter_data);
std::get<1>(kappa_list_) =
InitScalarParameterFromInputData<InputParameter::Solid::Kappa2>("Kappa_2",
domain,
input_parameter_data);
}
hyperelastic_bulk_ =
InitScalarParameterFromInputData<InputParameter::Solid::HyperelasticBulk>("Hyperelastic bulk",
domain,
input_parameter_data);
if constexpr (IsDefined<InputParameterDataT, SolidIP::HyperelasticBulk>())
{
hyperelastic_bulk_ =
InitScalarParameterFromInputData<InputParameter::Solid::HyperelasticBulk>("Hyperelastic bulk",
domain,
input_parameter_data);
}
viscosity_ =
InitScalarParameterFromInputData<InputParameter::Solid::Viscosity>("Viscosity",
domain,
input_parameter_data);
if constexpr (IsDefined<InputParameterDataT, SolidIP::Viscosity>())
{
viscosity_ =
InitScalarParameterFromInputData<InputParameter::Solid::Viscosity>("Viscosity",
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>())
if constexpr (IsDefined<InputParameterDataT, SolidIP::Mu1>())
{
static_assert(IsDefined<InputParameterDataT, SolidIP::Mu2>()
&& IsDefined<InputParameterDataT, SolidIP::C0>()
&& IsDefined<InputParameterDataT, SolidIP::C1>()
&& IsDefined<InputParameterDataT, SolidIP::C2>()
&& IsDefined<InputParameterDataT, SolidIP::C3>(),
"It makes no sense to define one and not the others");
std::get<0>(mu_i_C_i_) =
InitScalarParameterFromInputData<InputParameter::Solid::Mu1>("Mu1",
domain,
......@@ -91,19 +134,19 @@ namespace HappyHeart
input_parameter_data);
std::get<3>(mu_i_C_i_) =
InitScalarParameterFromInputData<InputParameter::Solid::C1>("C1",
domain,
input_parameter_data);
InitScalarParameterFromInputData<InputParameter::Solid::C1>("C1",
domain,
input_parameter_data);
std::get<4>(mu_i_C_i_) =
InitScalarParameterFromInputData<InputParameter::Solid::C2>("C2",
domain,
input_parameter_data);
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);
InitScalarParameterFromInputData<InputParameter::Solid::C3>("C3",
domain,
input_parameter_data);
}
CheckConsistency(relative_tolerance);
......@@ -226,6 +269,90 @@ namespace HappyHeart
return *viscosity_;
}
inline bool Solid::IsHyperelasticBulk() const noexcept
{
return hyperelastic_bulk_ != nullptr;
}
inline bool Solid::IsKappa1() const noexcept
{
return std::get<0>(kappa_list_) != nullptr;
}
inline bool Solid::IsKappa2() const noexcept
{
return std::get<1>(kappa_list_) != nullptr;
}
inline bool Solid::IsYoungModulus() const noexcept
{
return std::get<0>(young_poisson_) != nullptr;
}
inline bool Solid::IsPoissonRatio() const noexcept
{
return std::get<1>(young_poisson_) != nullptr;
}
inline bool Solid::IsLameLambda() const noexcept
{
return std::get<0>(lame_coeff_) != nullptr;
}
inline bool Solid::IsLameMu() const noexcept
{
return std::get<1>(lame_coeff_) != nullptr;
}
inline bool Solid::IsMu1() const noexcept
{
return std::get<0>(mu_i_C_i_) != nullptr;
}
inline bool Solid::IsMu2() const noexcept
{
return std::get<1>(mu_i_C_i_) != nullptr;
}
inline bool Solid::IsC0() const noexcept
{
return std::get<2>(mu_i_C_i_) != nullptr;
}
inline bool Solid::IsC1() const noexcept
{
return std::get<3>(mu_i_C_i_) != nullptr;
}
inline bool Solid::IsC2() const noexcept
{
return std::get<4>(mu_i_C_i_) != nullptr;
}
inline bool Solid::IsC3() const noexcept
{
return std::get<5>(mu_i_C_i_) != nullptr;
}
inline bool Solid::IsViscosity() const noexcept
{
return viscosity_ != nullptr;
}
} // namespace HappyHeart
......
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