13 #if !defined(KRATOS_MMG_UTILITIES)
14 #define KRATOS_MMG_UTILITIES
29 #ifndef MMG_VERSION_GT
30 #define MMG_VERSION_GT(MAJOR,MINOR) false
32 #ifndef MMG_VERSION_GE
33 #define MMG_VERSION_GE(MAJOR,MINOR) false
35 #ifndef MMG_VERSION_LT
36 #define MMG_VERSION_LT(MAJOR,MINOR) false
38 #ifndef MMG_VERSION_LE
39 #define MMG_VERSION_LE(MAJOR,MINOR) false
41 #ifndef MMG_VERSION_MAJOR
42 #define MMG_VERSION_MAJOR 5
44 #ifndef MMG_VERSION_MINOR
45 #define MMG_VERSION_MINOR 5
47 #ifndef MMG_VERSION_PATCH
48 #define MMG_VERSION_PATCH 0
51 #if MMG_VERSION_LT(5,5)
52 #error "ERROR:: The minimal MMG compatible version is 5.5.0. Please update your MMG library"
113 template<MMGLibrary TMMGLibrary>
151 template<MMGLibrary TMMGLibrary>
192 static constexpr
double ZeroTolerance = std::numeric_limits<double>::epsilon();
230 std::string GetMmgVersion();
260 void SetRemoveRegions(
const bool RemoveRegions);
266 bool GetRemoveRegions();
351 std::unordered_map<IndexType,Condition::Pointer>& rMapPointersRefCondition,
369 std::unordered_map<IndexType,Condition::Pointer>& rMapPointersRefCondition,
387 std::unordered_map<IndexType,Element::Pointer>& rMapPointersRefElement,
405 std::unordered_map<IndexType,Element::Pointer>& rMapPointersRefElement,
426 virtual void InitVerbosity();
486 virtual void InputSol(
const std::string& rInputName);
512 virtual void OutputReferenceEntitities(
513 const std::string& rOutputName,
514 const std::unordered_map<IndexType,Condition::Pointer>& rRefCondition,
515 const std::unordered_map<IndexType,Element::Pointer>& rRefElement
641 void ReorderAllIds(
ModelPart& rModelPart);
652 virtual void GenerateMeshDataFromModelPart(
654 std::unordered_map<
IndexType,std::vector<std::string>>& rColors,
658 const bool CollapsePrismElements =
false
669 virtual void GenerateReferenceMaps(
673 std::unordered_map<IndexType,Condition::Pointer>& rRefCondition,
674 std::unordered_map<IndexType,Element::Pointer>& rRefElement
681 virtual void GenerateSolDataFromModelPart(
ModelPart& rModelPart);
688 virtual void GenerateIsosurfaceMetricDataFromModelPart(
ModelPart& rModelPart);
694 virtual void GenerateDisplacementDataFromModelPart(
ModelPart& rModelPart);
705 void WriteMeshDataToModelPart(
707 const std::unordered_map<
IndexType,std::vector<std::string>>& rColors,
710 std::unordered_map<IndexType,Condition::Pointer>& rMapPointersRefCondition,
711 std::unordered_map<IndexType,Element::Pointer>& rMapPointersRefElement
718 void WriteSolDataToModelPart(
ModelPart& rModelPart);
727 virtual void WriteReferenceEntitities(
729 const std::string& rFilename,
730 std::unordered_map<IndexType,Condition::Pointer>& rRefCondition,
731 std::unordered_map<IndexType,Element::Pointer>& rRefElement
738 virtual void CreateAuxiliarSubModelPartForFlags(
ModelPart& rModelPart);
744 virtual void AssignAndClearAuxiliarSubModelPartForFlags(
ModelPart& rModelPart);
775 return "MmgUtilities";
781 rOStream <<
"MmgUtilities";
829 bool mRemoveRegions =
false;
831 bool mUsingMetricTensor =
true;
846 void ResursivelyAssignFlagEntities(
856 ResursivelyAssignFlagEntities(r_sub_model_part, rFlag, FlagValue);
894 template<MMGLibrary TMMGLibrary>
899 template<MMGLibrary TMMGLibrary>
904 rOStream << std::endl;
Geometry base class.
Definition: geometry.h:71
Provides the Kratos interface to the MMG library API.
Definition: mmg_utilities.h:153
virtual void SetNodes(const double X, const double Y, const double Z, const IndexType Color, const IndexType Index)
This sets the nodes of the mesh.
virtual void InputSol(const std::string &rInputName)
This sets the output sol.
virtual void BlockNode(const IndexType iNode)
It blocks certain nodes before remesh the model.
std::pair< IndexType, IndexType > IndexPairType
Index pair.
Definition: mmg_utilities.h:186
virtual void OutputSol(const std::string &rOutputName)
This sets the output sol.
virtual void SetDisplacementVector(const array_1d< double, 3 > &rDisplacement, const IndexType NodeId)
This function is used to set the displacement vector (x, y, z)
virtual void SetMetricTensor(const TensorArrayType &rMetric, const IndexType NodeId)
This function is used to set the Hessian metric tensor, note that when using the Hessian,...
Condition::Pointer CreateSecondTypeCondition(ModelPart &rModelPart, std::unordered_map< IndexType, Condition::Pointer > &rMapPointersRefCondition, const IndexType CondId, int &Ref, int &IsRequired, bool SkipCreation)
It creates the new condition (second type, depends if the library work in 2D/3D/Surfaces)
KRATOS_CLASS_POINTER_DEFINITION(MmgUtilities)
Pointer definition of MmgUtilities.
virtual void SetMeshOptimizationModeParameter(const bool EnableMeshOptimization)
This sets the optimization mode using the API where edge lengths are preserved, ignoring the metric v...
virtual void SetElements(GeometryType &rGeometry, const IndexType Color, const IndexType Index)
This sets elements of the mesh.
virtual void SetSolSizeScalar(const SizeType NumNodes)
This sets the size of the solution for the scalar case.
virtual void SetDispSizeVector(const SizeType NumNodes)
This sets the size of the displacement for lagrangian movement.
void PrintData(std::ostream &rOStream) const
Print object's data.
Definition: mmg_utilities.h:785
virtual void SetConditions(GeometryType &rGeometry, const IndexType Color, const IndexType Index)
This sets the conditions of the mesh.
virtual void GetMetricTensor(TensorArrayType &rMetric)
This function is used to retrieve the Hessian metric tensor, note that when using the Hessian,...
void SetMeshSize(MMGMeshInfo< TMMGLibrary > &rMMGMeshInfo)
This sets the size of the mesh.
std::string Info() const
Turn back information as a string.
Definition: mmg_utilities.h:773
virtual void GetMetricScalar(double &rMetric)
This function is used to retrieve the metric scalar.
Geometry< NodeType > GeometryType
Definition: mmg_utilities.h:165
virtual void SetSolSizeVector(const SizeType NumNodes)
This sets the size of the solution for the vector case.
virtual void InitVerbosityParameter(const IndexType VerbosityMMG)
Here the verbosity is set using the API.
Node NodeType
Node definition.
Definition: mmg_utilities.h:163
virtual void InitMesh()
Initialisation of mesh and sol structures.
virtual NodeType::Pointer CreateNode(ModelPart &rModelPart, IndexType iNode, int &Ref, int &IsRequired)
It creates the new node.
Element::Pointer CreateSecondTypeElement(ModelPart &rModelPart, std::unordered_map< IndexType, Element::Pointer > &rMapPointersRefElement, const IndexType ElemId, int &Ref, int &IsRequired, bool SkipCreation)
It creates the new element (second type, depends if the library work in 2D/3D/Surfaces)
std::unordered_map< IndexVectorType, IndexType, KeyHasherRange< IndexVectorType >, KeyComparorRange< IndexVectorType > > IndexVectorMapType
Index vector map.
Definition: mmg_utilities.h:180
virtual void GetMetricVector(array_1d< double, Dimension > &rMetric)
This function is used to retrieve the metric vector (x, y, z)
virtual void OutputDisplacement(const std::string &rOutputName)
This sets the output displacement.
virtual Condition::Pointer CreateFirstTypeCondition(ModelPart &rModelPart, std::unordered_map< IndexType, Condition::Pointer > &rMapPointersRefCondition, const IndexType CondId, int &Ref, int &IsRequired, bool SkipCreation)
It creates the new condition (first type, depends if the library work in 2D/3D/Surfaces)
virtual void OutputMesh(const std::string &rOutputName)
This sets the output mesh.
virtual void BlockCondition(const IndexType iCondition)
It blocks certain conditions before remesh the model.
virtual void CheckMeshData()
This checks the mesh data and prints if it is OK.
virtual IndexVectorType CheckSecondTypeConditions()
Returns a vector of ids of repeated conditions.
virtual void SetMetricScalar(const double Metric, const IndexType NodeId)
This function is used to set the metric scalar.
void SetNumberOfLocalParameters(IndexType NumberOfLocalParameter)
Sets the number of parameters to be defined locally at each reference color. Required by the library.
void PrintInfo(std::ostream &rOStream) const
Print information about this object.
Definition: mmg_utilities.h:779
virtual void InputMesh(const std::string &rInputName)
This sets the output mesh.
virtual void SetSolSizeTensor(const SizeType NumNodes)
This sets the size of the solution for the tensor case.
std::unordered_map< IndexType, IndexType > ColorsMapType
Colors map.
Definition: mmg_utilities.h:183
virtual void SetMetricVector(const array_1d< double, Dimension > &rMetric, const IndexType NodeId)
This function is used to set the metric vector (x, y, z)
virtual IndexVectorType CheckFirstTypeConditions()
Returns a vector of ids of repeated conditions.
virtual void FreeAll()
This frees the MMG structures.
virtual void GetDisplacementVector(array_1d< double, 3 > &rDisplacement)
This function is used to retrieve the displacement vector (x, y, z)
virtual IndexVectorType CheckFirstTypeElements()
Returns a vector of ids of repeated elements.
void SetLocalParameter(IndexType rColor, double HMin, double HMax, double HausdorffValue)
Sets the local hmin, hmax and hausdorff value for all entities with the given color reference.
void MMGLibCallIsoSurface(Parameters ConfigurationParameters)
This loads the solution.
virtual Element::Pointer CreateFirstTypeElement(ModelPart &rModelPart, std::unordered_map< IndexType, Element::Pointer > &rMapPointersRefElement, const IndexType ElemId, int &Ref, int &IsRequired, bool SkipCreation)
It creates the new element (first type, depends if the library work in 2D/3D/Surfaces)
std::vector< double > DoubleVectorType
Double vector.
Definition: mmg_utilities.h:174
virtual void BlockElement(const IndexType iElement)
It blocks certain elements before remesh the model.
virtual IndexVectorType CheckSecondTypeElements()
Returns a vector of ids of repeated elements.
std::conditional< Dimension==2, array_1d< double, 3 >, array_1d< double, 6 > >::type TensorArrayType
The type of array considered for the tensor.
Definition: mmg_utilities.h:171
std::unordered_map< DoubleVectorType, IndexType, KeyHasherRange< DoubleVectorType >, KeyComparorRange< DoubleVectorType > > DoubleVectorMapType
Double vector map.
Definition: mmg_utilities.h:177
void MMGLibCallMetric(Parameters ConfigurationParameters)
This loads the solution.
std::pair< IndexType, std::vector< std::string > > IndexStringVectorPairType
Index and string vector pair.
Definition: mmg_utilities.h:189
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
SubModelPartsContainerType & SubModelParts()
Definition: model_part.h:1718
This class defines the node.
Definition: node.h:65
std::vector< std::unique_ptr< Dof< double > >> DofsContainerType
The DoF container type definition.
Definition: node.h:92
This class provides to Kratos a data structure for I/O based on the standard of JSON.
Definition: kratos_parameters.h:59
This class implements a set of auxiliar, already parallelized, methods to perform some common tasks r...
Definition: variable_utils.h:63
void SetFlag(const Flags &rFlag, const bool FlagValue, TContainerType &rContainer)
Sets a flag according to a given status over a given container.
Definition: variable_utils.h:900
std::size_t IndexType
The definition of the index type.
Definition: key_hash.h:35
static int EchoLevel
Definition: co_sim_EMPIRE_API.h:42
void SetEchoLevel(const int EchoLevel)
Definition: add_custom_io_to_python.cpp:344
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
FrameworkEulerLagrange
This enums allows to differentiate the working framework.
Definition: meshing_application.h:66
DiscretizationOption
This enums allows to differentiate the discretization options.
Definition: meshing_application.h:71
std::size_t SizeType
The definition of the size type.
Definition: mortar_classes.h:43
std::istream & operator>>(std::istream &rIStream, LinearMasterSlaveConstraint &rThis)
input stream function
std::vector< IndexType > IndexVectorType
Index vector.
Definition: mmg_io.h:63
std::ostream & operator<<(std::ostream &rOStream, const LinearMasterSlaveConstraint &rThis)
output stream function
Definition: linear_master_slave_constraint.h:432
type
Definition: generate_gid_list_file.py:35
tuple const
Definition: ode_solve.py:403
This is a key comparer of general pourpose between two classes.
Definition: key_hash.h:100
Stores the Mmg mesh information.
Definition: mmg_utilities.h:115
SizeType NumberOfTriangles
Definition: mmg_utilities.h:119
SizeType NumberFirstTypeConditions() const
It returns the number of the first type of conditions.
SizeType NumberOfTetrahedra
Definition: mmg_utilities.h:122
SizeType NumberSecondTypeConditions() const
It returns the number of the second type of conditions.
SizeType NumberOfLines
Definition: mmg_utilities.h:118
SizeType NumberOfPrism
Definition: mmg_utilities.h:121
SizeType NumberFirstTypeElements() const
It returns the number of the first type of elements.
SizeType NumberSecondTypeElements() const
It returns the number of the second type of elements.
SizeType NumberOfNodes
Definition: mmg_utilities.h:117
SizeType NumberOfQuadrilaterals
Definition: mmg_utilities.h:120