47 #if !defined(KRATOS_PFEM_GID_IO_BASE_H_INCLUDED)
48 #define KRATOS_PFEM_GID_IO_BASE_H_INCLUDED
59 #include <pybind11/pybind11.h>
81 class PfemGidGaussPointsContainer
86 GiD_ElementType gid_element_type,
87 unsigned int number_of_integration_points,
88 std::vector<int> index_container )
93 bool AddElement(
const ModelPart::ElementsContainerType::iterator pElemIt )
97 && pElemIt->GetGeometry().IntegrationPoints(
98 pElemIt->GetIntegrationMethod() ).size() ==
mSize )
107 bool AddCondition(
const ModelPart::ConditionsContainerType::iterator pCondIt )
111 && pCondIt->GetGeometry().IntegrationPoints().size() ==
mSize )
121 double SolutionTag,
unsigned int value_index = 0 )
126 GiD_fBeginResult(ResultFile, (
char*)(rVariable.
Name()).c_str(),
"Kratos", SolutionTag,
127 GiD_Scalar, GiD_OnGaussPoints,
mGPTitle, NULL, 0, NULL );
128 std::vector<double> ValuesOnIntPoint(
mSize);
131 for( ModelPart::ElementsContainerType::iterator it =
mMeshElements.begin();
134 it->GetValueOnIntegrationPoints( rVariable, ValuesOnIntPoint,
139 GiD_fWriteScalar(ResultFile, it->Id(), ValuesOnIntPoint[index] );
145 for( ModelPart::ConditionsContainerType::iterator it =
mMeshConditions.begin();
148 it->GetValueOnIntegrationPoints( rVariable, ValuesOnIntPoint,
153 GiD_fWriteScalar(ResultFile, it->Id(), ValuesOnIntPoint[index] );
157 GiD_fEndResult(ResultFile);
162 double SolutionTag,
unsigned int value_index = 0 )
167 GiD_fBeginResult(ResultFile, (
char *)(rVariable.
Name()).c_str(),
"Kratos", SolutionTag,
168 GiD_Vector, GiD_OnGaussPoints,
mGPTitle, NULL, 0, NULL );
169 std::vector<Vector> ValuesOnIntPoint(
mSize);
172 for( ModelPart::ElementsContainerType::iterator it =
mMeshElements.begin();
175 it->GetValueOnIntegrationPoints( rVariable, ValuesOnIntPoint,
180 if( ValuesOnIntPoint[0].size() == 3 )
181 GiD_fWriteVector(ResultFile, it->Id(), ValuesOnIntPoint[index][0],
182 ValuesOnIntPoint[index][1], ValuesOnIntPoint[index][2] );
188 for( ModelPart::ConditionsContainerType::iterator it =
mMeshConditions.begin();
191 it->GetValueOnIntegrationPoints( rVariable, ValuesOnIntPoint,
196 if( ValuesOnIntPoint[0].size() == 3 )
197 GiD_fWriteVector(ResultFile, it->Id(), ValuesOnIntPoint[index][0],
198 ValuesOnIntPoint[index][1], ValuesOnIntPoint[index][2] );
202 GiD_fEndResult(ResultFile);
207 double SolutionTag,
unsigned int value_index = 0 )
212 GiD_fBeginResult( ResultFile, (
char *)(rVariable.
Name()).c_str(),
"Kratos", SolutionTag,
213 GiD_Matrix, GiD_OnGaussPoints,
mGPTitle, NULL, 0, NULL );
214 std::vector<Matrix> ValuesOnIntPoint(
mSize);
217 for( ModelPart::ElementsContainerType::iterator it =
mMeshElements.begin();
220 it->GetValueOnIntegrationPoints( rVariable, ValuesOnIntPoint,
225 if(ValuesOnIntPoint[index].size1() ==3
226 && ValuesOnIntPoint[index].size2() ==3)
227 GiD_fWrite3DMatrix( ResultFile, it->Id(), ValuesOnIntPoint[index](0,0),
228 ValuesOnIntPoint[index](1,1), ValuesOnIntPoint[index](2,2),
229 ValuesOnIntPoint[index](0,1), ValuesOnIntPoint[index](1,2),
230 ValuesOnIntPoint[index](0,2) );
231 if(ValuesOnIntPoint[index].size1() ==1
232 && ValuesOnIntPoint[index].size2() ==6)
233 GiD_fWrite3DMatrix( ResultFile, it->Id(), ValuesOnIntPoint[index](0,0),
234 ValuesOnIntPoint[index](0,1), ValuesOnIntPoint[index](0,2),
235 ValuesOnIntPoint[index](0,3), ValuesOnIntPoint[index](0,4),
236 ValuesOnIntPoint[index](0,5) );
242 for( ModelPart::ConditionsContainerType::iterator it =
mMeshConditions.begin();
245 it->GetValueOnIntegrationPoints( rVariable, ValuesOnIntPoint,
250 if(ValuesOnIntPoint[index].size1() ==3
251 && ValuesOnIntPoint[index].size2() ==3)
252 GiD_fWrite3DMatrix( ResultFile, it->Id(), ValuesOnIntPoint[index](0,0),
253 ValuesOnIntPoint[index](1,1), ValuesOnIntPoint[index](2,2),
254 ValuesOnIntPoint[index](0,1), ValuesOnIntPoint[index](1,2),
255 ValuesOnIntPoint[index](0,2) );
256 if(ValuesOnIntPoint[index].size1() ==1
257 && ValuesOnIntPoint[index].size2() ==6)
258 GiD_fWrite3DMatrix( ResultFile, it->Id(), ValuesOnIntPoint[index](0,0),
259 ValuesOnIntPoint[index](0,1), ValuesOnIntPoint[index](0,2),
260 ValuesOnIntPoint[index](0,3), ValuesOnIntPoint[index](0,4),
261 ValuesOnIntPoint[index](0,5) );
265 GiD_fEndResult(ResultFile);
270 double SolutionTag,
int value_index = 0 )
279 GiD_fBeginGaussPoint( ResultFile,
mGPTitle, GiD_Tetrahedra, NULL, 4, 0, 0 );
280 GiD_fWriteGaussPoint3D( ResultFile, 1.0/6.0, 1.0/6.0, 1.0/6.0 );
281 GiD_fWriteGaussPoint3D( ResultFile, 1.0/2.0, 1.0/6.0, 1.0/6.0 );
282 GiD_fWriteGaussPoint3D( ResultFile, 1.0/6.0, 1.0/2.0, 1.0/6.0 );
283 GiD_fWriteGaussPoint3D( ResultFile, 1.0/6.0, 1.0/6.0, 1.0/2.0 );
284 GiD_fEndGaussPoint(ResultFile);
288 GiD_fBeginGaussPoint(ResultFile,
"tet10_element_gp", GiD_Tetrahedra, NULL, 4, 0, 0);
289 GiD_fWriteGaussPoint3D( ResultFile, 1.0/14.0, 1.0/14.0, 1.0/14.0 );
290 GiD_fWriteGaussPoint3D( ResultFile, 11.0/14.0, 1.0/14.0, 1.0/14.0 );
291 GiD_fWriteGaussPoint3D( ResultFile, 1.0/14.0, 11.0/14.0, 1.0/14.0 );
292 GiD_fWriteGaussPoint3D( ResultFile, 1.0/14.0, 1.0/14.0, 11.0/14.0 );
293 GiD_fEndGaussPoint(ResultFile);
299 GiD_fEndGaussPoint(ResultFile);
329 GiD_ElementType elementType,
const char* mesh_title )
330 :mGeometryType(geometryType), mGidElementType(elementType), mMeshTitle(mesh_title) {}
332 bool AddElement(
const ModelPart::ElementsContainerType::iterator pElemIt )
335 if( pElemIt->GetGeometry().GetGeometryType() == mGeometryType )
337 mMeshElements.push_back( *(pElemIt.base() ) );
341 mMeshNodes.push_back( *(it.base() ) );
350 bool AddCondition(
const ModelPart::ConditionsContainerType::iterator pCondIt)
353 if( pCondIt->GetGeometry().GetGeometryType() == mGeometryType )
355 mMeshConditions.push_back( *(pCondIt.base() ) );
359 mMeshNodes.push_back( *(it.base() ) );
370 if( mMeshElements.size() != 0 )
379 if( mMeshElements.size() != 0 )
381 if( mMeshElements.begin()->GetGeometry().WorkingSpaceDimension() == 2 )
383 std::cout <<
"writing a 2D mesh" << std::endl;
384 GiD_fBeginMesh(MeshFile,
"Volume mesh", GiD_2D, mGidElementType,
385 mMeshElements.begin()->GetGeometry().size() );
387 else if( mMeshElements.begin()->GetGeometry().WorkingSpaceDimension() == 3 )
389 std::cout <<
"writing a 3D mesh" << std::endl;
390 GiD_fBeginMesh(MeshFile,
"Volume mesh", GiD_3D, mGidElementType,
391 mMeshElements.begin()->GetGeometry().size() );
396 GiD_fBeginCoordinates(MeshFile);
397 for( ModelPart::NodesContainerType::iterator it = mMeshNodes.begin();
398 it != mMeshNodes.end(); ++it )
401 GiD_fWriteCoordinates(MeshFile, (it)->Id(), (it)->
X(),
402 (it)->
Y(), (it)->
Z());
404 GiD_fWriteCoordinates(MeshFile, (it)->Id(), (it)->X0(),
405 (it)->Y0(), (it)->Z0());
407 GiD_fEndCoordinates(MeshFile);
409 GiD_fBeginElements(MeshFile);
410 int* nodes_id =
new int[mMeshElements.begin()->GetGeometry().size()+1];
411 for( ModelPart::ElementsContainerType::iterator it = mMeshElements.begin();
412 it != mMeshElements.end(); ++it )
414 for(
unsigned int i=0;
i<(it)->GetGeometry().size();
i++ )
415 nodes_id[
i] = (it)->GetGeometry()[
i].Id();
422 for (
unsigned int i=0;
i<(it)->GetGeometry().size();
i++ )
424 n_fl +=
int(it->GetGeometry()[
i].FastGetSolutionStepValue(IS_FLUID));
425 n_str+=
int(it->GetGeometry()[
i].FastGetSolutionStepValue(IS_STRUCTURE));
426 n_interf+=
int(it->GetGeometry()[
i].FastGetSolutionStepValue(IS_INTERFACE));
428 if (n_fl==
int((it)->GetGeometry().size()) && n_interf!=30)
432 if (n_str==
int((it)->GetGeometry().size()))
442 nodes_id[(it)->GetGeometry().size()]=
color;
444 GiD_fWriteElementMat(MeshFile, (it)->Id(), nodes_id);
447 GiD_fEndElements(MeshFile);
448 GiD_fEndMesh(MeshFile);
450 if( mMeshConditions.size() != 0 )
452 KRATOS_WATCH( mMeshConditions.begin()->GetGeometry().WorkingSpaceDimension() )
454 if( mMeshConditions.begin()->GetGeometry().WorkingSpaceDimension() == 3 )
456 std::cout <<
"writing a 3D mesh of the faces" << std::endl;
457 GiD_fBeginMesh(MeshFile,
"Surface Structure Mesh", GiD_3D, GiD_Triangle, 3);
462 GiD_fBeginCoordinates(MeshFile);
464 GiD_fEndCoordinates(MeshFile);
466 GiD_fBeginElements(MeshFile);
468 int* nodes_id =
new int[4];
471 for( ModelPart::ConditionsContainerType::iterator it = mMeshConditions.begin();
472 it != mMeshConditions.end(); ++it )
474 for(
unsigned int i=0;
i<(it)->GetGeometry().size();
i++ )
475 nodes_id[
i] = (it)->GetGeometry()[
i].Id();
480 for (
unsigned int i=0;
i<3;
i++)
482 n_free_surf+=
int((it)->GetGeometry()[
i].FastGetSolutionStepValue(IS_FREE_SURFACE));
483 n_str+=
int((it)->GetGeometry()[
i].FastGetSolutionStepValue(IS_STRUCTURE));
485 if (n_str==
int(it->GetGeometry().size()))
488 GiD_fWriteElementMat(MeshFile, (it)->Id(), nodes_id);
493 GiD_fEndElements(MeshFile);
494 GiD_fEndMesh(MeshFile);
496 if( mMeshConditions.size() != 0 )
498 KRATOS_WATCH( mMeshConditions.begin()->GetGeometry().WorkingSpaceDimension() )
499 if( mMeshConditions.begin()->GetGeometry().WorkingSpaceDimension() == 3 )
501 std::cout <<
"writing a 3D mesh of the faces" << std::endl;
502 GiD_fBeginMesh(MeshFile,
"Surface Fluid Mesh", GiD_3D, GiD_Triangle, 3);
509 GiD_fBeginCoordinates(MeshFile);
511 GiD_fEndCoordinates(MeshFile);
513 GiD_fBeginElements(MeshFile);
518 int* nodes_id =
new int[4];
522 for( ModelPart::ConditionsContainerType::iterator it = mMeshConditions.begin();
523 it != mMeshConditions.end(); ++it )
525 for(
unsigned int i=0;
i<(it)->GetGeometry().size();
i++ )
526 nodes_id[
i] = (it)->GetGeometry()[
i].Id();
530 for (
int i=0;
i<3;
i++)
532 n_str+=
int((it)->GetGeometry()[
i].FastGetSolutionStepValue(IS_STRUCTURE));
533 n_fl+=
int((it)->GetGeometry()[
i].FastGetSolutionStepValue(IS_FLUID));
538 if (n_fl==
int(it->GetGeometry().size()))
542 GiD_fWriteElementMat(MeshFile, (it)->Id(), nodes_id);
547 GiD_fEndElements(MeshFile);
548 GiD_fEndMesh(MeshFile);
557 mMeshElements.clear();
558 mMeshConditions.clear();
570 GiD_ElementType mGidElementType;
574 const char* mMeshTitle;
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
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
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
ProcessInfo & GetProcessInfo()
Definition: model_part.h:1746
MeshType::NodesContainerType NodesContainerType
Nodes container. Which is a vector set of nodes with their Id's as key.
Definition: model_part.h:128
int mSize
Definition: pfem_gid_io.h:306
void PrintResults(GiD_FILE ResultFile, Variable< Matrix > rVariable, ModelPart &r_model_part, double SolutionTag, unsigned int value_index=0)
Definition: pfem_gid_io.h:206
ModelPart::ConditionsContainerType mMeshConditions
Definition: pfem_gid_io.h:309
GiD_ElementType mGidElementFamily
Definition: pfem_gid_io.h:304
void PrintResults(GiD_FILE ResultFile, Variable< array_1d< double, 3 > > rVariable, ModelPart &r_model_part, double SolutionTag, int value_index=0)
Definition: pfem_gid_io.h:269
const char * mGPTitle
member variables
Definition: pfem_gid_io.h:311
KratosGeometryFamily mKratosElementFamily
member variables
Definition: pfem_gid_io.h:303
void Reset()
Definition: pfem_gid_io.h:303
char * mGPTitle
Definition: pfem_gid_io.h:307
bool AddCondition(const ModelPart::ConditionsContainerType::iterator pCondIt)
Definition: pfem_gid_io.h:107
void WriteGaussPoints()
Definition: pfem_gid_io.h:273
bool AddElement(const ModelPart::ElementsContainerType::iterator pElemIt)
Definition: pfem_gid_io.h:93
unsigned int mSize
Definition: pfem_gid_io.h:314
void PrintResults(GiD_FILE ResultFile, Variable< double > rVariable, ModelPart &r_model_part, double SolutionTag, unsigned int value_index=0)
Definition: pfem_gid_io.h:120
std::vector< int > mIndexContainer
Definition: pfem_gid_io.h:305
ModelPart::ElementsContainerType mMeshElements
Definition: pfem_gid_io.h:308
void PrintResults(GiD_FILE ResultFile, Variable< Vector > rVariable, ModelPart &r_model_part, double SolutionTag, unsigned int value_index=0)
Definition: pfem_gid_io.h:161
PfemGidGaussPointsContainer(const char *gp_title, KratosGeometryFamily geometryFamily, GiD_ElementType gid_element_type, unsigned int number_of_integration_points, std::vector< int > index_container)
Constructor.
Definition: pfem_gid_io.h:85
void WriteGaussPoints(GiD_FILE ResultFile)
Definition: pfem_gid_io.h:274
Definition: pfem_gid_io.h:317
void FinalizeMeshCreation()
Definition: pfem_gid_io.h:368
bool AddElement(const ModelPart::ElementsContainerType::iterator pElemIt)
Definition: pfem_gid_io.h:332
ModelPart::NodesContainerType GetMeshNodes()
Definition: pfem_gid_io.h:561
PfemGidMeshContainer(GeometryData::KratosGeometryType geometryType, GiD_ElementType elementType, const char *mesh_title)
Constructor.
Definition: pfem_gid_io.h:328
void Reset()
Definition: pfem_gid_io.h:554
bool AddCondition(const ModelPart::ConditionsContainerType::iterator pCondIt)
Definition: pfem_gid_io.h:350
void WriteMesh(GiD_FILE MeshFile, bool deformed)
Definition: pfem_gid_io.h:376
const std::string & Name() const
Definition: variable_data.h:201
#define KRATOS_THROW_ERROR(ExceptionType, ErrorMessage, MoreInfo)
Definition: define.h:77
#define KRATOS_CATCH(MoreInfo)
Definition: define.h:110
#define KRATOS_WATCH(variable)
Definition: define.h:806
#define KRATOS_TRY
Definition: define.h:109
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
REACTION_CHECK_STIFFNESS_FACTOR int
Definition: contact_structural_mechanics_application_variables.h:75
GeometryData::KratosGeometryFamily KratosGeometryFamily
Definition: gid_gauss_point_container.h:45
color
Definition: all_t_win_vs_m_fixed_error.py:230
integer i
Definition: TensorModule.f:17