15 #if !defined(KRATOS_GID_MESH_CONTAINER_H_INCLUDED)
16 #define KRATOS_GID_MESH_CONTAINER_H_INCLUDED
24 #include "gidpost/source/gidpost.h"
50 GiD_ElementType elementType,
const char* mesh_title )
55 if ( pElemIt->GetGeometry().GetGeometryType() ==
mGeometryType )
72 if ( pCondIt->GetGeometry().GetGeometryType() ==
mGeometryType )
101 bool nodes_written =
false;
106 for ( ModelPart::ElementsContainerType::iterator it =
mMeshElements.begin();
110 << (it)->Id() <<
" does not have Properties and hence cannot "
111 <<
"be used with the GiD-Output" << std::endl;
113 int prop_id = (it)->GetProperties().Id();
114 if (max_id < prop_id) max_id = prop_id;
117 std::cout<<
"a property Id > 10000 found. Are u sure you need so many properties?" << std::endl;
118 std::vector<int> elements_per_layer (max_id+1,0);
122 for ( ModelPart::ElementsContainerType::iterator it =
mMeshElements.begin();
125 int prop_id = (it)->GetProperties().Id();
126 elements_per_layer[prop_id] += 1;
129 for (
unsigned int current_layer = 0; current_layer < elements_per_layer.size(); current_layer++)
131 if (elements_per_layer[current_layer] > 0)
135 current_layer_name <<
mMeshTitle <<
"_" << current_layer ;
136 if (
mMeshElements.begin()->GetGeometry().WorkingSpaceDimension() == 2 )
139 GiD_fBeginMesh ( MeshFile, (
char *) (current_layer_name.str() ).c_str(), GiD_2D,
mGidElementType,
mMeshElements.begin()->GetGeometry().size() );
141 else if (
mMeshElements.begin()->GetGeometry().WorkingSpaceDimension() == 3 )
144 GiD_fBeginMesh ( MeshFile, (
char *) (current_layer_name.str() ).c_str(), GiD_3D,
mGidElementType,
mMeshElements.begin()->GetGeometry().size() );
149 if(nodes_written ==
false)
151 GiD_fBeginCoordinates(MeshFile);
152 for ( ModelPart::NodesContainerType::iterator it =
mMeshNodes.begin();
156 GiD_fWriteCoordinates ( MeshFile, (it)->Id(), (it)->
X(),
157 (it)->
Y(), (it)->
Z() );
159 GiD_fWriteCoordinates ( MeshFile, (it)->Id(), (it)->X0(),
160 (it)->Y0(), (it)->Z0() );
162 GiD_fEndCoordinates(MeshFile);
164 nodes_written =
true;
167 GiD_fBeginElements(MeshFile);
168 int* nodes_id =
new int[
mMeshElements.begin()->GetGeometry().size() + 1];
169 for ( ModelPart::ElementsContainerType::iterator it =
mMeshElements.begin();
172 for (
unsigned int i=0;
i< (it)->GetGeometry().size();
i++ )
173 nodes_id[
i] = (it)->GetGeometry() [
i].Id();
177 nodes_id[0] = (it)->GetGeometry() [0].Id();
178 nodes_id[1] = (it)->GetGeometry() [1].Id();
179 nodes_id[2] = (it)->GetGeometry() [2].Id();
181 nodes_id[ (it)->GetGeometry().size()]= (it)->GetProperties().Id()+1;
184 if ((it)->GetProperties().Id()==current_layer)
185 GiD_fWriteElementMat ( MeshFile, (it)->Id(), nodes_id);
189 GiD_fEndElements(MeshFile);
190 GiD_fEndMesh(MeshFile);
199 for ( ModelPart::ConditionsContainerType::iterator it =
mMeshConditions.begin();
202 int prop_id = (it)->GetProperties().Id();
203 if (max_id < prop_id) max_id = prop_id;
206 std::cout<<
"a property Id > 10000 found. Are u sure you need so many properties?" << std::endl;
207 std::vector<int> conditions_per_layer (max_id+1,0);
209 for ( ModelPart::ConditionsContainerType::iterator it =
mMeshConditions.begin();
213 << (it)->Id() <<
" does not have Properties and hence cannot "
214 <<
"be used with the GiD-Output" << std::endl;
216 int prop_id = (it)->GetProperties().Id();
217 conditions_per_layer[prop_id] += 1;
220 for (
unsigned int current_layer = 0; current_layer < conditions_per_layer.size(); current_layer++)
222 if (conditions_per_layer[current_layer] > 0)
225 current_layer_name <<
mMeshTitle <<
"_" << current_layer ;
227 if (
mMeshConditions.begin()->GetGeometry().WorkingSpaceDimension() == 2 )
230 GiD_fBeginMesh ( MeshFile, (
char *) (current_layer_name.str() ).c_str(), GiD_2D,
mGidElementType,
233 else if (
mMeshConditions.begin()->GetGeometry().WorkingSpaceDimension() == 3 )
236 GiD_fBeginMesh ( MeshFile, (
char *) (current_layer_name.str() ).c_str(), GiD_3D,
mGidElementType,
242 if(nodes_written ==
false)
244 GiD_fBeginCoordinates(MeshFile);
245 for ( ModelPart::NodesContainerType::iterator it =
mMeshNodes.begin();
249 GiD_fWriteCoordinates ( MeshFile, (it)->Id(), (it)->
X(),
250 (it)->
Y(), (it)->
Z() );
252 GiD_fWriteCoordinates ( MeshFile, (it)->Id(), (it)->X0(),
253 (it)->Y0(), (it)->Z0() );
255 GiD_fEndCoordinates(MeshFile);
256 nodes_written =
true;
260 GiD_fBeginCoordinates(MeshFile);
261 GiD_fEndCoordinates(MeshFile);
264 GiD_fBeginElements(MeshFile);
265 int* nodes_id =
new int[
mMeshConditions.begin()->GetGeometry().size() + 1];
266 for ( ModelPart::ConditionsContainerType::iterator it =
mMeshConditions.begin( );
269 for (
unsigned int i=0;
i< (it)->GetGeometry().size();
i++ )
270 nodes_id[
i] = (it)->GetGeometry() [
i].Id();
274 nodes_id[12] = (it)->GetGeometry() [16].Id();
275 nodes_id[13] = (it)->GetGeometry() [17].Id();
276 nodes_id[14] = (it)->GetGeometry() [18].Id();
277 nodes_id[15] = (it)->GetGeometry() [19].Id();
278 nodes_id[16] = (it)->GetGeometry() [12].Id();
279 nodes_id[17] = (it)->GetGeometry() [13].Id();
280 nodes_id[18] = (it)->GetGeometry() [14].Id();
281 nodes_id[19] = (it)->GetGeometry() [15].Id();
283 nodes_id[ (it)->GetGeometry().size()]= (it)->GetProperties().Id()+1;
286 if ((it)->GetProperties().Id()==current_layer)
287 GiD_fWriteElementMat ( MeshFile, (it)->Id(), nodes_id);
290 GiD_fEndElements(MeshFile);
291 GiD_fEndMesh(MeshFile);
KratosGeometryType
Definition: geometry_data.h:110
IntegrationMethod
Definition: geometry_data.h:76
KratosGeometryFamily
Definition: geometry_data.h:91
Geometry base class.
Definition: geometry.h:71
PointsArrayType::iterator iterator
PointsArrayType typedefs.
Definition: geometry.h:213
iterator begin()
Definition: geometry.h:465
iterator end()
Definition: geometry.h:473
Definition: gid_mesh_container.h:46
void WriteMesh(GiD_FILE MeshFile, bool deformed)
Definition: gid_mesh_container.h:97
ModelPart::NodesContainerType GetMeshNodes()
Definition: gid_mesh_container.h:304
GeometryData::KratosGeometryType mGeometryType
member variables
Definition: gid_mesh_container.h:310
ModelPart::ConditionsContainerType mMeshConditions
Definition: gid_mesh_container.h:314
GiD_ElementType mGidElementType
Definition: gid_mesh_container.h:311
ModelPart::ElementsContainerType mMeshElements
Definition: gid_mesh_container.h:313
bool AddElement(const ModelPart::ElementConstantIterator pElemIt)
Definition: gid_mesh_container.h:52
const char * mMeshTitle
Definition: gid_mesh_container.h:315
ModelPart::NodesContainerType mMeshNodes
Definition: gid_mesh_container.h:312
void Reset()
Definition: gid_mesh_container.h:298
void FinalizeMeshCreation()
Definition: gid_mesh_container.h:86
bool AddCondition(const ModelPart::ConditionConstantIterator pCondIt)
Definition: gid_mesh_container.h:69
GidMeshContainer(GeometryData::KratosGeometryType geometryType, GiD_ElementType elementType, const char *mesh_title)
Constructor.
Definition: gid_mesh_container.h:49
MeshType::ConditionsContainerType ConditionsContainerType
Condintions container. A vector set of Conditions with their Id's as key.
Definition: model_part.h:183
MeshType::ElementsContainerType ElementsContainerType
Element container. A vector set of Elements with their Id's as key.
Definition: model_part.h:168
MeshType::ConditionConstantIterator ConditionConstantIterator
Definition: model_part.h:195
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
MeshType::ElementConstantIterator ElementConstantIterator
Definition: model_part.h:180
#define KRATOS_THROW_ERROR(ExceptionType, ErrorMessage, MoreInfo)
Definition: define.h:77
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_TRY
Definition: define.h:109
#define KRATOS_DEBUG_ERROR_IF_NOT(conditional)
Definition: exception.h:172
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
GeometryData::IntegrationMethod IntegrationMethodType
Definition: gid_gauss_point_container.h:44
ModelPart::ConditionsContainerType ConditionsArrayType
Definition: gid_gauss_point_container.h:43
ModelPart::NodesContainerType NodesArrayType
Definition: gid_gauss_point_container.h:42
ModelPart::ElementsContainerType ElementsArrayType
Definition: gid_gauss_point_container.h:41
GeometryData::KratosGeometryFamily KratosGeometryFamily
Definition: gid_gauss_point_container.h:45
out
Definition: isotropic_damage_automatic_differentiation.py:200
integer i
Definition: TensorModule.f:17