Commit 7f574e3a authored by GILLES Sebastien's avatar GILLES Sebastien

#20 Extend the CheckInvertedElement to properly handle the case it was not...

#20 Extend the CheckInvertedElement to properly handle the case it was not defined in the InputData (the singleton is created but any attempt to use it will result in an exception).
parent cfbcf3e2
......@@ -25,8 +25,6 @@ namespace MoReFEM::Internal::MoReFEMDataNS
{
/*!
* \brief Enables a check for the validity of finite elements during computations. It ensures that
* the Jacobian of the mapping from the reference configuration to the deformed one remains positive.
......@@ -63,6 +61,13 @@ namespace MoReFEM::Internal::MoReFEMDataNS
*/
explicit CheckInvertedElements(bool do_check_inverted_elements);
/*!
* \brief Constructor when no Solid field in input data file.
*
* This case indicates no field was specified at all in the input data file; this probably means the model is ill-formed.
*/
explicit CheckInvertedElements() = default;
//! Destructor.
virtual ~CheckInvertedElements() override;
......@@ -79,12 +84,12 @@ namespace MoReFEM::Internal::MoReFEMDataNS
public:
//! Whether we do check for inverted elements during computation.
check_inverted_elements_policy DoCheckInvertedElements() const noexcept;
check_inverted_elements_policy DoCheckInvertedElements() const;
private:
//! Policy to define whether the test on the inverted elements is done or not.
check_inverted_elements_policy check_inverted_elements_policy_ = check_inverted_elements_policy::no_check;
check_inverted_elements_policy check_inverted_elements_policy_ = check_inverted_elements_policy::unspecified;
};
......
......@@ -9,16 +9,24 @@
#ifndef MOREFEM_x_CORE_x_MO_RE_F_E_M_DATA_x_INTERNAL_x_CHECK_INVERTED_ELEMENTS_HXX_
# define MOREFEM_x_CORE_x_MO_RE_F_E_M_DATA_x_INTERNAL_x_CHECK_INVERTED_ELEMENTS_HXX_
namespace MoReFEM::Internal::MoReFEMDataNS
{
inline check_inverted_elements_policy CheckInvertedElements::DoCheckInvertedElements() const noexcept
{
return check_inverted_elements_policy_;
}
inline check_inverted_elements_policy CheckInvertedElements::DoCheckInvertedElements() const
{
if (check_inverted_elements_policy_ == check_inverted_elements_policy::unspecified)
throw Exception("The singleton CheckInvertedElements was not initialised with a proper value "
"- check there is a dedicated field Solid::CheckInvertedElement in your "
"input data!", __FILE__, __LINE__);
return check_inverted_elements_policy_;
}
} // namepsace MoReFEM::Internal::FEltSpaceNS
#endif // MOREFEM_x_CORE_x_MO_RE_F_E_M_DATA_x_INTERNAL_x_CHECK_INVERTED_ELEMENTS_HXX_
......@@ -9,17 +9,22 @@
#ifndef MOREFEM_x_CORE_x_MO_RE_F_E_M_DATA_x_INTERNAL_x_ENUM_INVERTED_ELEMENTS_HPP_
# define MOREFEM_x_CORE_x_MO_RE_F_E_M_DATA_x_INTERNAL_x_ENUM_INVERTED_ELEMENTS_HPP_
namespace MoReFEM
{
//! Enum class to choose between doing a (relatively) expensive check on the Jacobian of the mapping from reference to deformed configuration
enum class check_inverted_elements_policy
{
from_input_data, // takes the value specified in the input data file.
do_check,
no_check
no_check,
unspecified // if there was no Solid field in the input data file.
};
}
#endif // MOREFEM_x_CORE_x_MO_RE_F_E_M_DATA_x_INTERNAL_x_ENUM_INVERTED_ELEMENTS_HPP_
......@@ -107,6 +107,13 @@ namespace MoReFEM
MoReFEM::Internal::MoReFEMDataNS::CheckInvertedElements
::CreateOrGetInstance(__FILE__, __LINE__, do_check_inverted_elements);
}
else
{
// Create it nonetheless - but will trigger an exception if the value is called.
MoReFEM::Internal::MoReFEMDataNS::CheckInvertedElements
::CreateOrGetInstance(__FILE__, __LINE__);
}
}
catch(const ExceptionNS::GracefulExit& e)
{
......
......@@ -455,7 +455,10 @@ namespace MoReFEM
const auto& De = derivative_green_lagrange.Update(gradient_displacement);
const auto& transposed_De = derivative_green_lagrange.GetTransposed();
switch (MoReFEM::Internal::MoReFEMDataNS::CheckInvertedElements::GetInstance(__FILE__, __LINE__).DoCheckInvertedElements())
decltype(auto) check_inverted =
MoReFEM::Internal::MoReFEMDataNS::CheckInvertedElements::GetInstance(__FILE__, __LINE__);
switch (check_inverted.DoCheckInvertedElements())
{
case check_inverted_elements_policy::do_check:
{
......@@ -480,6 +483,7 @@ namespace MoReFEM
break; // Maybe free the memory allocated for the local matrix deformation gradient?
case check_inverted_elements_policy::from_input_data:
case check_inverted_elements_policy::unspecified:
assert(false && "Should not happen");
exit(EXIT_FAILURE);
} // switch
......
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