diff --git a/kratos/includes/mesh.h b/kratos/includes/mesh.h index 691ed62a0862..44defa7fc017 100644 --- a/kratos/includes/mesh.h +++ b/kratos/includes/mesh.h @@ -4,18 +4,14 @@ // _|\_\_| \__,_|\__|\___/ ____/ // Multi-Physics // -// License: BSD License -// Kratos default license: kratos/license.txt +// License: BSD License +// Kratos default license: kratos/license.txt // // Main authors: Pooyan Dadvand // // - -#if !defined(KRATOS_MESH_H_INCLUDED ) -#define KRATOS_MESH_H_INCLUDED - - +#pragma once // System includes #include @@ -23,10 +19,8 @@ #include #include - // External includes - // Project includes #include "includes/define.h" #include "containers/pointer_vector_set.h" @@ -37,7 +31,6 @@ #include "containers/data_value_container.h" #include "includes/master_slave_constraint.h" - namespace Kratos { @@ -60,143 +53,116 @@ namespace Kratos ///@name Kratos Classes ///@{ -/// Mesh is the second level of abstraction in the data structure which hold Nodes, Elements and Conditions and their Properties. /** - * Mesh is the second level of abstraction in the data structure which hold Nodes, Elements and Conditions and their Properties. + * @class Mesh + * @ingroup KratosCore + * @brief Mesh is the second level of abstraction in the data structure which hold Nodes, Elements and Conditions and their Properties. + * @details Mesh is the second level of abstraction in the data structure which hold Nodes, Elements and Conditions and their Properties. * In other words, Mesh is a complete pack of all type of entities without any additional data associated with them. * So a set of Elements and Conditions with their Nodes and Properties can be grouped together as a Mesh and send to * procedures like mesh refinement, material optimization, mesh movement or any other procedure which works on entities * without needing additional data for their processes. + * @author Pooyan Dadvand */ template class Mesh : public DataValueContainer, public Flags { public: - - ///@name Type Definitions ///@{ /// Pointer definition of Mesh KRATOS_CLASS_POINTER_DEFINITION(Mesh); - typedef std::size_t IndexType; - - typedef std::size_t SizeType; - - typedef TNodeType NodeType; - - typedef TPropertiesType PropertiesType; - - typedef Geometry GeometryType; - - typedef TElementType ElementType; - - typedef TConditionType ConditionType; - - typedef MasterSlaveConstraint MasterSlaveConstraintType; - - typedef Mesh MeshType; + // Alias for representing indices, typically used for indexing arrays or collections. + using IndexType = std::size_t; + + // Alias for representing sizes or counts, commonly used to indicate the size of data structures. + using SizeType = std::size_t; + + // Alias for representing node types in a mesh data structure. + using NodeType = TNodeType; + + // Alias for representing properties associated with nodes or elements in a mesh. + using PropertiesType = TPropertiesType; - /// Nodes container. Which is a vector set of nodes with their Id's as key. - typedef PointerVectorSet, - std::equal_to, - typename NodeType::Pointer, - std::vector< typename NodeType::Pointer > - > NodesContainerType; + // Alias for representing the geometry associated with a specific node type. + using GeometryType = Geometry; - /** Iterator over the nodes. This iterator is an indirect - iterator over Node::Pointer which turn back a reference to - node by * operator and not a pointer for more convenient - usage. */ - typedef typename NodesContainerType::iterator NodeIterator; + // Alias for representing element types in a mesh data structure. + using ElementType = TElementType; - /** Const iterator over the nodes. This iterator is an indirect - iterator over Node::Pointer which turn back a reference to - node by * operator and not a pointer for more convenient - usage. */ - typedef typename NodesContainerType::const_iterator NodeConstantIterator; + // Alias for representing condition types in a mesh data structure. + using ConditionType = TConditionType; - /// Properties container. A vector set of properties with their Id's as key. - typedef PointerVectorSet PropertiesContainerType; + // Alias for representing master-slave constraints that can be applied in the mesh. + using MasterSlaveConstraintType = MasterSlaveConstraint; - /** Iterator over the properties. This iterator is an indirect - iterator over Properties::Pointer which turn back a reference to - properties by * operator and not a pointer for more convenient - usage. */ - typedef typename PropertiesContainerType::iterator PropertiesIterator; + // Alias for the complete mesh data structure, including nodes, properties, elements, and conditions. + using MeshType = Mesh; - /** Const iterator over the properties. This iterator is an indirect - iterator over Properties::Pointer which turn back a reference to - properties by * operator and not a pointer for more convenient - usage. */ - typedef typename PropertiesContainerType::const_iterator PropertiesConstantIterator; + /// Type alias for the container of nodes. + using NodesContainerType = PointerVectorSet, + std::equal_to, + typename NodeType::Pointer, + std::vector + >; - /// Geometries container. A vector map of Geometries with given Id's as key. - /* typedef PointerVectorMap GeometriesContainerType; */ + /// Iterator for nodes in the container. Provides direct references to nodes. + using NodeIterator = typename NodesContainerType::iterator; - /// Element container. A vector set of Elements with their Id's as key. - typedef PointerVectorSet, - std::equal_to, - typename ElementType::Pointer, - std::vector< typename ElementType::Pointer > - > ElementsContainerType; + /// Const iterator for nodes in the container. Provides direct references to nodes. + using NodeConstantIterator = typename NodesContainerType::const_iterator; - /** Iterator over the Elements. This iterator is an indirect - iterator over Elements::Pointer which turn back a reference to - Element by * operator and not a pointer for more convenient - usage. */ - typedef typename ElementsContainerType::iterator ElementIterator; + /// Type alias for the container of properties. + using PropertiesContainerType = PointerVectorSet; - /** Const iterator over the Elements. This iterator is an indirect - iterator over Elements::Pointer which turn back a reference to - Element by * operator and not a pointer for more convenient - usage. */ - typedef typename ElementsContainerType::const_iterator ElementConstantIterator; + /// Iterator for properties in the container. Provides direct references to properties. + using PropertiesIterator = typename PropertiesContainerType::iterator; - /// Conditions container. A vector set of Conditions with their Id's as key. - typedef PointerVectorSet, - std::equal_to, - typename ConditionType::Pointer, - std::vector< typename ConditionType::Pointer > - > ConditionsContainerType; + /// Const iterator for properties in the container. Provides direct references to properties. + using PropertiesConstantIterator = typename PropertiesContainerType::const_iterator; - /** Iterator over the Conditions. This iterator is an indirect - iterator over Conditions::Pointer which turn back a reference to - Condition by * operator and not a pointer for more convenient - usage. */ - typedef typename ConditionsContainerType::iterator ConditionIterator; + /// Type alias for the container of elements. + using ElementsContainerType = PointerVectorSet, + std::equal_to, + typename ElementType::Pointer, + std::vector + >; - /** Const iterator over the Conditions. This iterator is an indirect - iterator over Conditions::Pointer which turn back a reference to - Condition by * operator and not a pointer for more convenient - usage. */ - typedef typename ConditionsContainerType::const_iterator ConditionConstantIterator; + /// Iterator for elements in the container. Provides direct references to elements. + using ElementIterator = typename ElementsContainerType::iterator; - // Defining the constraint base type - - /// The container of the constraints - typedef PointerVectorSet MasterSlaveConstraintContainerType; - - /** Iterator over the constraints. This iterator is an indirect - iterator over MasterSlaveConstraint::Pointer which turn back a reference to - MasterSlaveConstraint by * operator and not a pointer for more convenient - usage. */ - typedef typename MasterSlaveConstraintContainerType::iterator MasterSlaveConstraintIteratorType; - - /** Const iterator over the constraints. This iterator is an indirect - iterator over MasterSlaveConstraint::Pointer which turn back a reference to - Table by * operator and not a pointer for more convenient - usage. */ - typedef typename MasterSlaveConstraintContainerType::const_iterator MasterSlaveConstraintConstantIteratorType; + /// Const iterator for elements in the container. Provides direct references to elements. + using ElementConstantIterator = typename ElementsContainerType::const_iterator; + /// Type alias for the container of conditions. + using ConditionsContainerType = PointerVectorSet, + std::equal_to, + typename ConditionType::Pointer, + std::vector + >; + /// Iterator for conditions in the container. Provides direct references to conditions. + using ConditionIterator = typename ConditionsContainerType::iterator; + + /// Const iterator for conditions in the container. Provides direct references to conditions. + using ConditionConstantIterator = typename ConditionsContainerType::const_iterator; + + /// Type alias for the container of master-slave constraints. + using MasterSlaveConstraintContainerType = PointerVectorSet; + + /// Iterator for master-slave constraints in the container. Provides direct references to constraints. + using MasterSlaveConstraintIteratorType = typename MasterSlaveConstraintContainerType::iterator; + + /// Const iterator for master-slave constraints in the container. Provides direct references to constraints. + using MasterSlaveConstraintConstantIteratorType = typename MasterSlaveConstraintContainerType::const_iterator; ///@} ///@name Life Cycle @@ -230,12 +196,10 @@ class Mesh : public DataValueContainer, public Flags /// Destructor. ~Mesh() override {} - ///@} ///@name Operators ///@{ - ///@} ///@name Operations ///@{ @@ -272,19 +236,20 @@ class Mesh : public DataValueContainer, public Flags SizeType WorkingSpaceDimension() const { - SizeType dimension = 3; + SizeType dimension = 3; - // NOTE: possible segmentacion fault if a Element or Condition - // is created using the base class of geometry, then the mpGeometryData - // of the geometry is a null pointer and has not any mWorkingSpaceDimension - if(NumberOfElements()!=0) - dimension = (mpElements->begin())->GetGeometry().WorkingSpaceDimension(); - else if(NumberOfConditions()!=0) - dimension = (mpConditions->begin())->GetGeometry().WorkingSpaceDimension(); - else if(NumberOfNodes()!=0) - dimension = (mpNodes->begin())->Dimension(); + // NOTE: possible segmentation fault if a Element or Condition + // is created using the base class of geometry, then the mpGeometryData + // of the geometry is a null pointer and has not any mWorkingSpaceDimension + if (NumberOfElements()!=0) { + dimension = (mpElements->begin())->GetGeometry().WorkingSpaceDimension(); + } else if(NumberOfConditions()!=0) { + dimension = (mpConditions->begin())->GetGeometry().WorkingSpaceDimension(); + } else if(NumberOfNodes()!=0) { + dimension = (mpNodes->begin())->Dimension(); + } - return dimension; + return dimension; } ///@} @@ -859,17 +824,14 @@ class Mesh : public DataValueContainer, public Flags return (mpMasterSlaveConstraints->find(MasterSlaveConstraintId) != mpMasterSlaveConstraints->end()); } - ///@} ///@name Access ///@{ - ///@} ///@name Inquiry ///@{ - ///@} ///@name Input and output ///@{ @@ -912,56 +874,44 @@ class Mesh : public DataValueContainer, public Flags rOStream << PrefixString << " Number of Constraints : " << mpMasterSlaveConstraints->size() << std::endl; } - ///@} ///@name Friends ///@{ - ///@} - protected: ///@name Protected static Member Variables ///@{ - ///@} ///@name Protected member Variables ///@{ - ///@} ///@name Protected Operators ///@{ - ///@} ///@name Protected Operations ///@{ - ///@} ///@name Protected Access ///@{ - ///@} ///@name Protected Inquiry ///@{ - ///@} ///@name Protected LifeCycle ///@{ - ///@} - private: ///@name Static Member Variables ///@{ - ///@} ///@name Member Variables ///@{ @@ -981,7 +931,6 @@ class Mesh : public DataValueContainer, public Flags ///@name Private Operators ///@{ - ///@} ///@name Private Operations ///@{ @@ -990,10 +939,8 @@ class Mesh : public DataValueContainer, public Flags ///@name Serialization ///@{ - friend class Serializer; - void save(Serializer& rSerializer) const override { KRATOS_SERIALIZE_SAVE_BASE_CLASS(rSerializer, DataValueContainer ); @@ -1021,12 +968,10 @@ class Mesh : public DataValueContainer, public Flags ///@name Private Access ///@{ - ///@} ///@name Private Inquiry ///@{ - ///@} ///@name Un accessible methods ///@{ @@ -1048,16 +993,13 @@ class Mesh : public DataValueContainer, public Flags }; // Class Mesh ///@} - ///@name Type Definitions ///@{ - ///@} ///@name Input and output ///@{ - /// input stream function template inline std::istream& operator >> (std::istream& rIStream, @@ -1079,6 +1021,4 @@ inline std::ostream& operator << (std::ostream& rOStream, } // namespace Kratos. -#endif // KRATOS_MESH_H_INCLUDED defined -