Commit ca2d92f8 authored by DIAZ Jerome's avatar DIAZ Jerome Committed by GILLES Sebastien

#20 Added singleton for the check on inverted elements.

parent 04cf6043
......@@ -851,6 +851,11 @@
BE6322D11B1852B500F787CC /* libOperators.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BECA4B941B1756DE00DC7265 /* libOperators.a */; };
BE6322D21B18548F00F787CC /* libOperators.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BECA4B941B1756DE00DC7265 /* libOperators.a */; };
BE6322D31B185E7600F787CC /* libOperators.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BECA4B941B1756DE00DC7265 /* libOperators.a */; };
BE6341EA236A361300028688 /* PlaneStressStrain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE6341E9236A361300028688 /* PlaneStressStrain.cpp */; };
BE6341EF236A363B00028688 /* CheckInvertedElements.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BE6341EB236A363A00028688 /* CheckInvertedElements.hpp */; };
BE6341F0236A363B00028688 /* CheckInvertedElements.hxx in Headers */ = {isa = PBXBuildFile; fileRef = BE6341EC236A363A00028688 /* CheckInvertedElements.hxx */; };
BE6341F1236A363B00028688 /* EnumInvertedElements.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BE6341ED236A363A00028688 /* EnumInvertedElements.hpp */; };
BE6341F2236A363B00028688 /* CheckInvertedElements.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE6341EE236A363A00028688 /* CheckInvertedElements.cpp */; };
BE63B4131F4F165700F03800 /* Factory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BE63B4101F4F165700F03800 /* Factory.cpp */; };
BE63B4141F4F165700F03800 /* Factory.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BE63B4111F4F165700F03800 /* Factory.hpp */; };
BE63B4151F4F165700F03800 /* Factory.hxx in Headers */ = {isa = PBXBuildFile; fileRef = BE63B4121F4F165700F03800 /* Factory.hxx */; };
......@@ -3627,6 +3632,11 @@
BE6322E41B1868F300F787CC /* ___FILEBASENAME___.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = "___FILEBASENAME___.hpp"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
BE6322E51B1868F300F787CC /* ___FILEBASENAME___.hxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = "___FILEBASENAME___.hxx"; sourceTree = "<group>"; };
BE6322E61B1868F300F787CC /* TemplateInfo.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = TemplateInfo.plist; sourceTree = "<group>"; };
BE6341E9236A361300028688 /* PlaneStressStrain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlaneStressStrain.cpp; sourceTree = "<group>"; };
BE6341EB236A363A00028688 /* CheckInvertedElements.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CheckInvertedElements.hpp; sourceTree = "<group>"; };
BE6341EC236A363A00028688 /* CheckInvertedElements.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CheckInvertedElements.hxx; sourceTree = "<group>"; };
BE6341ED236A363A00028688 /* EnumInvertedElements.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = EnumInvertedElements.hpp; sourceTree = "<group>"; };
BE6341EE236A363A00028688 /* CheckInvertedElements.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CheckInvertedElements.cpp; sourceTree = "<group>"; };
BE63B4101F4F165700F03800 /* Factory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Factory.cpp; sourceTree = "<group>"; };
BE63B4111F4F165700F03800 /* Factory.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Factory.hpp; sourceTree = "<group>"; };
BE63B4121F4F165700F03800 /* Factory.hxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Factory.hxx; sourceTree = "<group>"; };
......@@ -7031,6 +7041,7 @@
children = (
BE4D0CC621A2E4F900E0D4E7 /* SourceList.cmake */,
BE4D0CC721A2E4F900E0D4E7 /* C_i_Mu_i.cpp */,
BE4D0CCF21A2E4F900E0D4E7 /* Solid.cpp */,
BE4D0CC821A2E4F900E0D4E7 /* Solid.hpp */,
BE4D0CC921A2E4F900E0D4E7 /* YoungModulus.cpp */,
BE4D0CCA21A2E4F900E0D4E7 /* LameLambda.cpp */,
......@@ -7038,9 +7049,9 @@
BE4D0CCC21A2E4F900E0D4E7 /* PoissonRatio.cpp */,
BE4D0CCD21A2E4F900E0D4E7 /* LameMu.cpp */,
BE4D0CCE21A2E4F900E0D4E7 /* HyperelasticBulk.cpp */,
BE4D0CCF21A2E4F900E0D4E7 /* Solid.cpp */,
BE4D0CD021A2E4F900E0D4E7 /* Kappa2.cpp */,
BE6341E9236A361300028688 /* PlaneStressStrain.cpp */,
BE4D0CD121A2E4F900E0D4E7 /* Kappa1.cpp */,
BE4D0CD021A2E4F900E0D4E7 /* Kappa2.cpp */,
);
path = Solid;
sourceTree = "<group>";
......@@ -9368,6 +9379,10 @@
BEF4A6DD22E1BF0400CD4A6E /* OutputDirectoryStorage.cpp */,
BEF4A6DF22E1BF0400CD4A6E /* OutputDirectoryStorage.hpp */,
BEF4A6DE22E1BF0400CD4A6E /* OutputDirectoryStorage.hxx */,
BE6341EE236A363A00028688 /* CheckInvertedElements.cpp */,
BE6341EB236A363A00028688 /* CheckInvertedElements.hpp */,
BE6341EC236A363A00028688 /* CheckInvertedElements.hxx */,
BE6341ED236A363A00028688 /* EnumInvertedElements.hpp */,
BEBEB21D19C849C200E4EA1D /* Impl */,
);
path = Internal;
......@@ -10740,7 +10755,9 @@
BE5100071CCE3EB80034FE28 /* PerDegreeOfExactness.hxx in Headers */,
BEB7B1041BB4168F005E5D18 /* DirichletBoundaryConditionManager.hpp in Headers */,
BE90E1141A2491AE00CCAFDE /* QuadratureRuleList.hpp in Headers */,
BE6341EF236A363B00028688 /* CheckInvertedElements.hpp in Headers */,
BE90E1261A2491AE00CCAFDE /* NodeBearer.hxx in Headers */,
BE6341F0236A363B00028688 /* CheckInvertedElements.hxx in Headers */,
BEB917101AD3D37A0096A3D9 /* ExtendedUnknown.hpp in Headers */,
BE2ED6B21CB3DE0400D00CBF /* ComponentFactory.hpp in Headers */,
BE6128891CCE54A600318BB6 /* PerShapeFunctionOrder.hxx in Headers */,
......@@ -10850,6 +10867,7 @@
BE3221911B4686C100F27D6C /* FElt.hxx in Headers */,
BE4054051AC196480024D5F9 /* FEltSpace.hxx in Headers */,
BE2B66501A2778C700E80864 /* BasicRefFEltFactory.hpp in Headers */,
BE6341F1236A363B00028688 /* EnumInvertedElements.hpp in Headers */,
BE90E13A1A2491AE00CCAFDE /* DirichletBoundaryCondition.hxx in Headers */,
BE510D841CB3D44900E953FE /* Comp1.hpp in Headers */,
BE90E1001A2491AE00CCAFDE /* QuadratureRule.hpp in Headers */,
......@@ -12012,6 +12030,7 @@
BE4D0D7021A2E4F900E0D4E7 /* ElectricalActivation.cpp in Sources */,
BE4D0D4721A2E4F900E0D4E7 /* RectangularSourceTimeParameter.cpp in Sources */,
BE4D0D5B21A2E4F900E0D4E7 /* Viscosity.cpp in Sources */,
BE6341EA236A361300028688 /* PlaneStressStrain.cpp in Sources */,
BE7E552622EF280E00BEA053 /* Parallelism.cpp in Sources */,
BE7818791E82BD5F00FF503D /* EnsightCaseReader.cpp in Sources */,
BE4D0D4321A2E4F900E0D4E7 /* Heart.cpp in Sources */,
......@@ -12244,6 +12263,7 @@
BE2ED6B41CB3DE0400D00CBF /* ComponentManager.cpp in Sources */,
BE0170891B209A1F0058FAB1 /* TetrahedronP0.cpp in Sources */,
BE3E66451ACEB61100A3F7E2 /* Partition.cpp in Sources */,
BE6341F2236A363B00028688 /* CheckInvertedElements.cpp in Sources */,
BE2ED6AE1CB3DD7C00D00CBF /* Comp23.cpp in Sources */,
BE4A09BD1C6B46E6002799C0 /* MovemeshHelper.cpp in Sources */,
BE90E1301A2491AE00CCAFDE /* Dof.cpp in Sources */,
//
// PlaneStressStrain.cpp
// All targets
//
// Created by Jerôme Diaz on 10/10/2019.
// Copyright © 2019 Inria. All rights reserved.
//
#include "Core/InputData/Instances/Parameter/Solid/Solid.hpp"
namespace MoReFEM
{
namespace InputDataNS
{
const std::string& Solid::PlaneStressStrain::NameInFile()
{
static std::string ret("PlaneStressStrain");
return ret;
}
const std::string& Solid::PlaneStressStrain::Description()
{
static std::string ret("For 2D operators, which approximation to use.");
return ret;
}
const std::string& Solid::PlaneStressStrain::Constraint()
{
static std::string ret( "value_in(v, {'irrelevant', 'plane_strain', 'plane_stress'})");
return ret;
}
const std::string& Solid::PlaneStressStrain::DefaultValue()
{
static std::string ret("\"plane_strain\"");
return ret;
}
} // namespace InputDataNS
} // namespace MoReFEM
/// @} // addtogroup CoreGroup
......@@ -27,40 +27,9 @@ namespace MoReFEM
{
static std::string ret("Solid");
return ret;
};
const std::string& Solid::PlaneStressStrain::NameInFile()
{
static std::string ret("PlaneStressStrain");
return ret;
}
const std::string& Solid::PlaneStressStrain::Description()
{
static std::string ret("For 2D operators, which approximation to use.");
return ret;
}
const std::string& Solid::PlaneStressStrain::Constraint()
{
static std::string ret( "value_in(v, {'irrelevant', 'plane_strain', 'plane_stress'})");
return ret;
}
const std::string& Solid::PlaneStressStrain::DefaultValue()
{
static std::string ret("\"plane_strain\"");
return ret;
}
} // namespace InputDataNS
......
......@@ -16,6 +16,7 @@ target_sources(${MOREFEM_CORE}
"${CMAKE_CURRENT_LIST_DIR}/Kappa2.cpp"
"${CMAKE_CURRENT_LIST_DIR}/LameLambda.cpp"
"${CMAKE_CURRENT_LIST_DIR}/LameMu.cpp"
"${CMAKE_CURRENT_LIST_DIR}/PlaneStressStrain.cpp"
"${CMAKE_CURRENT_LIST_DIR}/PoissonRatio.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Solid.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Viscosity.cpp"
......
//
// CheckInvertedElements.cpp
// MoReFEM
//
// Created by Jerôme Diaz on 10/10/2019.
// Copyright © 2019 Inria. All rights reserved.
//
#include <cstdlib>
#include <sstream>
#include "Utilities/Containers/UnorderedMap.hpp"
#include "Utilities/InputData/Base.hpp"
#include "FiniteElement/FiniteElementSpace/Internal/CheckInvertedElements.hpp"
namespace MoReFEM::Internal::FEltSpaceNS
{
CheckInvertedElements::~CheckInvertedElements() = default;
CheckInvertedElements::CheckInvertedElements(bool do_check_inverted_elements)
: check_inverted_elements_policy_
(do_check_inverted_elements ? check_inverted_elements_policy::do_check : check_inverted_elements_policy::no_check)
{ }
const std::string& CheckInvertedElements::ClassName()
{
static std::string ret("CheckInvertedElements");
return ret;
}
} // namepsace MoReFEM::Internal::FEltSpaceNS
//
// CheckInvertedElements.hpp
// MoReFEM
//
// Created by Jerôme Diaz on 10/10/2019.
// Copyright © 2019 Inria. All rights reserved.
//
#ifndef MOREFEM_x_FINITE_ELEMENT_x_FINITE_ELEMENT_SPACE_x_INTERNAL_x_CHECK_INVERTED_ELEMENTS_HPP_
# define MOREFEM_x_FINITE_ELEMENT_x_FINITE_ELEMENT_SPACE_x_INTERNAL_x_CHECK_INVERTED_ELEMENTS_HPP_
# include <cstdlib>
# include <string>
# include "Utilities/String/String.hpp"
# include "Utilities/String/Traits.hpp"
# include "Utilities/Exceptions/Exception.hpp"
# include "Utilities/Singleton/Singleton.hpp"
# include "FiniteElement/FiniteElementSpace/Internal/EnumInvertedElements.hpp"
namespace MoReFEM::Internal::FEltSpaceNS
{
/*!
* \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.
* If it is negative at some point, an exception is raised.
*
* This singleton acts as a global variable in order to store the boolean value related to the check
* for inverted finite elements. It's only purpose is to propagate this information throughout the whole code.
* \tparam inverted_elements_check_policy_ is set to no_check by default, which makes for faster runs.
* If is set to do_check (through Solid::CheckInvertedElements) then the test for the positveness of the Jacobian is
* done at each quadrature point. One should note that this test is only a necessary condition for the validity of elements
* but it is not sufficient for elements of order higher or equal than 2.
*
*/
class CheckInvertedElements final : public Utilities::Singleton<CheckInvertedElements>
{
public:
//! \copydoc doxygen_hide_alias_self
using self = CheckInvertedElements;
//! Alias to unique pointer.
using unique_ptr = std::unique_ptr<self>;
private:
//! \name Singleton requirements.
///@{
/*!
* \brief Constructor.
*
* \param[in] do_check_inverted_elements True to enable the check for inverted elements.
*/
explicit CheckInvertedElements(bool do_check_inverted_elements);
//! Destructor.
virtual ~CheckInvertedElements() override;
//! Friendship declaration to Singleton template class (to enable call to constructor).
friend class Utilities::Singleton<CheckInvertedElements>;
//! Name of the class.
static const std::string& ClassName();
///@}
public:
//! Whether we do check for inverted elements during computation.
check_inverted_elements_policy DoCheckInvertedElements() const noexcept;
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;
};
} // namespace MoReFEM::Internal::FEltSpaceNS
/// @} // addtogroup FiniteElementGroup
# include "FiniteElement/FiniteElementSpace/Internal/CheckInvertedElements.hxx"
#endif // MOREFEM_x_FINITE_ELEMENT_x_FINITE_ELEMENT_SPACE_x_INTERNAL_x_CHECK_INVERTED_ELEMENTS_HPP_
//
// CheckInvertedElements.h
// MoReFEM
//
// Created by Jerôme Diaz on 10/10/2019.
// Copyright © 2019 Inria. All rights reserved.
//
#ifndef MOREFEM_x_FINITE_ELEMENT_x_FINITE_ELEMENT_SPACE_x_INTERNAL_x_CHECK_INVERTED_ELEMENTS_HXX_
# define MOREFEM_x_FINITE_ELEMENT_x_FINITE_ELEMENT_SPACE_x_INTERNAL_x_CHECK_INVERTED_ELEMENTS_HXX_
#endif // MOREFEM_x_FINITE_ELEMENT_x_FINITE_ELEMENT_SPACE_x_INTERNAL_x_CHECK_INVERTED_ELEMENTS_HXX_
//
// EnumInvertedElements.h
// MoReFEM
//
// Created by Jerôme Diaz on 10/10/2019.
// Copyright © 2019 Inria. All rights reserved.
//
#ifndef MOREFEM_x_FINITE_ELEMENT_x_FINITE_ELEMENT_SPACE_x_INTERNAL_x_ENUM_INVERTED_ELEMENTS_HPP_
# define MOREFEM_x_FINITE_ELEMENT_x_FINITE_ELEMENT_SPACE_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
};
}
#endif // MOREFEM_x_FINITE_ELEMENT_x_FINITE_ELEMENT_SPACE_x_INTERNAL_x_ENUM_INVERTED_ELEMENTS_HPP_
......@@ -11,6 +11,7 @@ target_sources(${MOREFEM_FELT}
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/BreakCircularDependancy.cpp"
"${CMAKE_CURRENT_LIST_DIR}/CheckInvertedElements.cpp"
"${CMAKE_CURRENT_LIST_DIR}/ComputeMatrixPattern.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Connectivity.cpp"
"${CMAKE_CURRENT_LIST_DIR}/CreateNodeListHelper.cpp"
......@@ -27,6 +28,8 @@ target_sources(${MOREFEM_FELT}
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/BreakCircularDependancy.hpp"
"${CMAKE_CURRENT_LIST_DIR}/CheckInvertedElements.hpp"
"${CMAKE_CURRENT_LIST_DIR}/CheckInvertedElements.hxx"
"${CMAKE_CURRENT_LIST_DIR}/ComputeMatrixPattern.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Connectivity.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Connectivity.hxx"
......@@ -38,6 +41,7 @@ target_sources(${MOREFEM_FELT}
"${CMAKE_CURRENT_LIST_DIR}/DofProgramWiseIndexListPerVertexCoordIndexList.hxx"
"${CMAKE_CURRENT_LIST_DIR}/DofProgramWiseIndexListPerVertexCoordIndexListManager.hpp"
"${CMAKE_CURRENT_LIST_DIR}/DofProgramWiseIndexListPerVertexCoordIndexListManager.hxx"
"${CMAKE_CURRENT_LIST_DIR}/EnumInvertedElements.hpp"
"${CMAKE_CURRENT_LIST_DIR}/FEltSpace.hpp"
"${CMAKE_CURRENT_LIST_DIR}/FEltSpace.hxx"
"${CMAKE_CURRENT_LIST_DIR}/FEltSpaceStorage.hpp"
......
......@@ -457,7 +457,8 @@ namespace MoReFEM
# ifndef NDEBUG
{
auto& deformation_gradient = this->matrix_parent::template GetLocalMatrix<EnumUnderlyingType(LocalMatrixIndex::deformation_gradient)>();
auto& deformation_gradient =
this->matrix_parent::template GetLocalMatrix<EnumUnderlyingType(LocalMatrixIndex::deformation_gradient)>();
deformation_gradient = gradient_displacement;
for (auto i = 0ul; i < DimensionT; ++i)
......
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