Commit 1775fafd authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#859 Solid: introduce a Print() method that may give the constant values of...

#859 Solid: introduce a Print() method that may give the constant values of parameters. It is intended for debug usage, as it won't work if a parameter is not constant.
parent 1a337321
......@@ -62,6 +62,8 @@ namespace HappyHeart
// Ordering is extremely important here!
InitParameters(input_parameter_data);
this->GetVariableHolder().GetSolid().Print(std::cout);
{
decltype(auto) numbering_subset =
solid_god_of_dof.GetNumberingSubset(EnumUnderlyingType(NumberingSubsetIndex::solid_displacement));
......
......@@ -78,6 +78,13 @@ namespace HappyHeart
};
/*!
* \brief Convenient helper to handle properly one parameter without triggering an assert if not initialized.
*/
template<Solid::param ParamT>
void PrintHelper(const Solid& solid,
const std::string& param_name,
std::ostream& out);
} // namespace anonymous
......@@ -281,6 +288,22 @@ namespace HappyHeart
}
void Solid::Print(std::ostream& out) const
{
out << "Values of parameters (assumed constant to be able to call the current method) are:" << std::endl;
PrintHelper<param::volumic_mass>(*this, "Volumic mass", out);
PrintHelper<param::young_modulus>(*this, "Young modulus", out);
PrintHelper<param::poisson_ratio>(*this, "Poisson ratio", out);
PrintHelper<param::lame_lambda>(*this, "Lame lambda", out);
PrintHelper<param::lame_mu>(*this, "Lame mu", out);
PrintHelper<param::kappa_1>(*this, "Kappa 1", out);
PrintHelper<param::kappa_2>(*this, "Kappa 2", out);
PrintHelper<param::hyperelastic_bulk>(*this, "Hyperelastic bulk", out);
PrintHelper<param::viscosity>(*this, "Viscosity", out);
}
namespace // anonymous
{
......@@ -343,6 +366,16 @@ namespace HappyHeart
}
template<Solid::param ParamT>
void PrintHelper(const Solid& solid,
const std::string& param_name,
std::ostream& out)
{
if (solid.IsActivated<ParamT>())
out << "\t- " << param_name << " = " << solid.GetParameter<ParamT>().GetConstantValue() << std::endl;
}
} // namespace anonymous
......
......@@ -125,6 +125,21 @@ namespace HappyHeart
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;
/*!
* \brief Whether the parameter has been initialized or not.
*
* \return True if it is defined, false otherwise.
*/
template<param ParamT>
bool IsActivated() const noexcept;
private:
/*!
......
......@@ -93,10 +93,18 @@ namespace HappyHeart
template<Solid::param ParamT>
const Solid::scalar_parameter::unique_ptr& Solid::GetParameterPtr() const noexcept
{
assert(ParamT < param::size);
static_assert(ParamT < param::size, "");
return parameter_list_[EnumUnderlyingType(ParamT)];
}
template<Solid::param ParamT>
bool Solid::IsActivated() const noexcept
{
static_assert(ParamT < param::size, "");
return GetParameterPtr<ParamT>() != nullptr;
}
inline const GeometricMeshRegion& Solid::GetGeometricMeshRegion() const noexcept
{
......
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