47 #if !defined(KRATOS_PFEM_GID_IO_BASE_H_INCLUDED)
48 #define KRATOS_PFEM_GID_IO_BASE_H_INCLUDED
83 GiD_ElementType gid_element_type,
84 int number_of_integration_points,
85 std::vector<int> index_container )
90 bool AddElement(
const ModelPart::ElementsContainerType::iterator pElemIt )
94 && pElemIt->GetGeometry().IntegrationPoints(
95 pElemIt->GetIntegrationMethod() ).size() ==
mSize )
104 bool AddCondition(
const ModelPart::ConditionsContainerType::iterator pCondIt )
108 && pCondIt->GetGeometry().IntegrationPoints().size() ==
mSize )
118 double SolutionTag,
int value_index = 0 )
123 GiD_BeginResult( (
char *)(rVariable.
Name()).c_str(),
"Kratos", SolutionTag,
124 GiD_Scalar, GiD_OnGaussPoints,
mGPTitle, NULL, 0, NULL );
125 std::vector<double> ValuesOnIntPoint(
mSize);
128 for( ModelPart::ElementsContainerType::iterator it =
mMeshElements.begin();
131 it->CalculateOnIntegrationPoints( rVariable, ValuesOnIntPoint,
136 GiD_WriteScalar( it->Id(), ValuesOnIntPoint[index] );
142 for( ModelPart::ConditionsContainerType::iterator it =
mMeshConditions.begin();
145 it->CalculateOnIntegrationPoints( rVariable, ValuesOnIntPoint,
150 GiD_WriteScalar( it->Id(), ValuesOnIntPoint[index] );
159 double SolutionTag,
int value_index = 0 )
164 GiD_BeginResult( (
char *)(rVariable.
Name()).c_str(),
"Kratos", SolutionTag,
165 GiD_Vector, GiD_OnGaussPoints,
mGPTitle, NULL, 0, NULL );
166 std::vector<Vector> ValuesOnIntPoint(
mSize);
169 for( ModelPart::ElementsContainerType::iterator it =
mMeshElements.begin();
172 it->CalculateOnIntegrationPoints( rVariable, ValuesOnIntPoint,
177 if( ValuesOnIntPoint[0].size() == 3 )
178 GiD_WriteVector( it->Id(), ValuesOnIntPoint[index][0],
179 ValuesOnIntPoint[index][1], ValuesOnIntPoint[index][2] );
185 for( ModelPart::ConditionsContainerType::iterator it =
mMeshConditions.begin();
188 it->CalculateOnIntegrationPoints( rVariable, ValuesOnIntPoint,
193 if( ValuesOnIntPoint[0].size() == 3 )
194 GiD_WriteVector( it->Id(), ValuesOnIntPoint[index][0],
195 ValuesOnIntPoint[index][1], ValuesOnIntPoint[index][2] );
204 double SolutionTag,
int value_index = 0 )
209 GiD_BeginResult( (
char *)(rVariable.
Name()).c_str(),
"Kratos", SolutionTag,
210 GiD_Matrix, GiD_OnGaussPoints,
mGPTitle, NULL, 0, NULL );
211 std::vector<Matrix> ValuesOnIntPoint(
mSize);
214 for( ModelPart::ElementsContainerType::iterator it =
mMeshElements.begin();
217 it->CalculateOnIntegrationPoints( rVariable, ValuesOnIntPoint,
222 if(ValuesOnIntPoint[index].size1() ==3
223 && ValuesOnIntPoint[index].size2() ==3)
224 GiD_Write3DMatrix( it->Id(), ValuesOnIntPoint[index](0,0),
225 ValuesOnIntPoint[index](1,1), ValuesOnIntPoint[index](2,2),
226 ValuesOnIntPoint[index](0,1), ValuesOnIntPoint[index](1,2),
227 ValuesOnIntPoint[index](0,2) );
228 if(ValuesOnIntPoint[index].size1() ==1
229 && ValuesOnIntPoint[index].size2() ==6)
230 GiD_Write3DMatrix( it->Id(), ValuesOnIntPoint[index](0,0),
231 ValuesOnIntPoint[index](0,1), ValuesOnIntPoint[index](0,2),
232 ValuesOnIntPoint[index](0,3), ValuesOnIntPoint[index](0,4),
233 ValuesOnIntPoint[index](0,5) );
239 for( ModelPart::ConditionsContainerType::iterator it =
mMeshConditions.begin();
242 it->CalculateOnIntegrationPoints( rVariable, ValuesOnIntPoint,
247 if(ValuesOnIntPoint[index].size1() ==3
248 && ValuesOnIntPoint[index].size2() ==3)
249 GiD_Write3DMatrix( it->Id(), ValuesOnIntPoint[index](0,0),
250 ValuesOnIntPoint[index](1,1), ValuesOnIntPoint[index](2,2),
251 ValuesOnIntPoint[index](0,1), ValuesOnIntPoint[index](1,2),
252 ValuesOnIntPoint[index](0,2) );
253 if(ValuesOnIntPoint[index].size1() ==1
254 && ValuesOnIntPoint[index].size2() ==6)
255 GiD_Write3DMatrix( it->Id(), ValuesOnIntPoint[index](0,0),
256 ValuesOnIntPoint[index](0,1), ValuesOnIntPoint[index](0,2),
257 ValuesOnIntPoint[index](0,3), ValuesOnIntPoint[index](0,4),
258 ValuesOnIntPoint[index](0,5) );
278 GiD_BeginGaussPoint(
mGPTitle, GiD_Tetrahedra, NULL, 4, 0, 0 );
279 GiD_WriteGaussPoint3D( 1.0/6.0, 1.0/6.0, 1.0/6.0 );
280 GiD_WriteGaussPoint3D( 1.0/2.0, 1.0/6.0, 1.0/6.0 );
281 GiD_WriteGaussPoint3D( 1.0/6.0, 1.0/2.0, 1.0/6.0 );
282 GiD_WriteGaussPoint3D( 1.0/6.0, 1.0/6.0, 1.0/2.0 );
287 GiD_BeginGaussPoint(
"tet10_element_gp", GiD_Tetrahedra, NULL, 4, 0, 0);
288 GiD_WriteGaussPoint3D( 1.0/14.0, 1.0/14.0, 1.0/14.0 );
289 GiD_WriteGaussPoint3D( 11.0/14.0, 1.0/14.0, 1.0/14.0 );
290 GiD_WriteGaussPoint3D( 1.0/14.0, 11.0/14.0, 1.0/14.0 );
291 GiD_WriteGaussPoint3D( 1.0/14.0, 1.0/14.0, 11.0/14.0 );
321 GiD_ElementType elementType,
char* mesh_title )
322 :mGeometryType(geometryType), mGidElementType(elementType), mMeshTitle(mesh_title) {}
324 bool AddElement(
const ModelPart::ElementsContainerType::iterator pElemIt )
327 if( pElemIt->GetGeometry().GetGeometryType() == mGeometryType )
329 mMeshElements.push_back( *(pElemIt.base() ) );
333 mMeshNodes.push_back( *(it.base() ) );
342 bool AddCondition(
const ModelPart::ConditionsContainerType::iterator pCondIt)
345 if( pCondIt->GetGeometry().GetGeometryType() == mGeometryType )
347 mMeshConditions.push_back( *(pCondIt.base() ) );
351 mMeshNodes.push_back( *(it.base() ) );
362 if( mMeshElements.size() != 0 )
371 if( mMeshElements.size() != 0 )
373 if( mMeshElements.begin()->GetGeometry().WorkingSpaceDimension() == 2 )
375 std::cout <<
"writing a 2D mesh" << std::endl;
376 GiD_BeginMesh(
"Volume mesh", GiD_2D, mGidElementType,
377 mMeshElements.begin()->GetGeometry().size() );
379 else if( mMeshElements.begin()->GetGeometry().WorkingSpaceDimension() == 3 )
381 std::cout <<
"writing a 3D mesh" << std::endl;
382 GiD_BeginMesh(
"Volume mesh", GiD_3D, mGidElementType,
383 mMeshElements.begin()->GetGeometry().size() );
388 GiD_BeginCoordinates();
389 for( ModelPart::NodesContainerType::iterator it = mMeshNodes.begin();
390 it != mMeshNodes.end(); ++it )
393 GiD_WriteCoordinates( (it)->Id(), (it)->
X(),
394 (it)->
Y(), (it)->
Z());
396 GiD_WriteCoordinates( (it)->Id(), (it)->X0(),
397 (it)->Y0(), (it)->Z0());
399 GiD_EndCoordinates();
402 int* nodes_id =
new int[mMeshElements.begin()->GetGeometry().size()+1];
403 for( ModelPart::ElementsContainerType::iterator it = mMeshElements.begin();
404 it != mMeshElements.end(); ++it )
406 for(
unsigned int i=0;
i<(it)->GetGeometry().size();
i++ )
407 nodes_id[
i] = (it)->GetGeometry()[
i].Id();
411 unsigned int n_str=0;
412 unsigned int n_intf=0;
413 unsigned int color=13;
414 for (
unsigned int i=0;
i<(it)->GetGeometry().size();
i++ )
416 n_fl += it->GetGeometry()[
i].FastGetSolutionStepValue(IS_FLUID);
417 n_str+= it->GetGeometry()[
i].FastGetSolutionStepValue(IS_STRUCTURE);
418 n_intf+= it->GetGeometry()[
i].FastGetSolutionStepValue(IS_INTERFACE);
420 if (n_fl==(it)->GetGeometry().size() && n_intf!=30)
424 if (n_str==(it)->GetGeometry().size())
432 nodes_id[(it)->GetGeometry().size()]=
color;
434 GiD_WriteElementMat((it)->Id(), nodes_id);
440 if( mMeshConditions.size() != 0 )
442 KRATOS_WATCH( mMeshConditions.begin()->GetGeometry().WorkingSpaceDimension() )
444 if( mMeshConditions.begin()->GetGeometry().WorkingSpaceDimension() == 3 )
446 std::cout <<
"writing a 3D mesh of the faces" << std::endl;
447 GiD_BeginMesh(
"Surface Structure Mesh", GiD_3D, GiD_Triangle, 3);
452 GiD_BeginCoordinates();
454 GiD_EndCoordinates();
458 int* nodes_id =
new int[4];
461 for( ModelPart::ConditionsContainerType::iterator it = mMeshConditions.begin();
462 it != mMeshConditions.end(); ++it )
464 for(
unsigned int i=0;
i<(it)->GetGeometry().size();
i++ )
465 nodes_id[
i] = (it)->GetGeometry()[
i].Id();
467 unsigned int n_str=0;
469 unsigned int n_free_surf=0;
471 for (
int i=0;
i<3;
i++)
473 n_free_surf+=(it)->GetGeometry()[
i].FastGetSolutionStepValue(IS_FREE_SURFACE);
474 n_str+=(it)->GetGeometry()[
i].FastGetSolutionStepValue(IS_STRUCTURE);
476 if (n_str==it->GetGeometry().size())
479 GiD_WriteElementMat((it)->Id(), nodes_id);
487 if( mMeshConditions.size() != 0 )
489 KRATOS_WATCH( mMeshConditions.begin()->GetGeometry().WorkingSpaceDimension() )
490 if( mMeshConditions.begin()->GetGeometry().WorkingSpaceDimension() == 3 )
492 std::cout <<
"writing a 3D mesh of the faces" << std::endl;
493 GiD_BeginMesh(
"Surface Fluid Mesh", GiD_3D, GiD_Triangle, 3);
500 GiD_BeginCoordinates();
502 GiD_EndCoordinates();
509 int* nodes_id =
new int[4];
513 for( ModelPart::ConditionsContainerType::iterator it = mMeshConditions.begin();
514 it != mMeshConditions.end(); ++it )
516 for(
unsigned int i=0;
i<(it)->GetGeometry().size();
i++ )
517 nodes_id[
i] = (it)->GetGeometry()[
i].Id();
519 unsigned int n_str=0;
521 for (
int i=0;
i<3;
i++)
523 n_str+=(it)->GetGeometry()[
i].FastGetSolutionStepValue(IS_STRUCTURE);
524 n_fl+=(it)->GetGeometry()[
i].FastGetSolutionStepValue(IS_FLUID);
529 if (n_fl==it->GetGeometry().size())
533 GiD_WriteElementMat((it)->Id(), nodes_id);
548 mMeshElements.clear();
549 mMeshConditions.clear();
555 GiD_ElementType mGidElementType;
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
Definition: pfem_gid_io.h:79
int mSize
Definition: pfem_gid_io.h:306
void PrintResults(Variable< double > rVariable, ModelPart &r_model_part, double SolutionTag, int value_index=0)
Definition: pfem_gid_io.h:117
ModelPart::ConditionsContainerType mMeshConditions
Definition: pfem_gid_io.h:309
GiD_ElementType mGidElementFamily
Definition: pfem_gid_io.h:304
void PrintResults(Variable< Vector > rVariable, ModelPart &r_model_part, double SolutionTag, int value_index=0)
Definition: pfem_gid_io.h:158
KratosGeometryFamily mKratosElementFamily
member variables
Definition: pfem_gid_io.h:303
void Reset()
Definition: pfem_gid_io.h:266
char * mGPTitle
Definition: pfem_gid_io.h:307
bool AddCondition(const ModelPart::ConditionsContainerType::iterator pCondIt)
Definition: pfem_gid_io.h:104
void WriteGaussPoints()
Definition: pfem_gid_io.h:273
bool AddElement(const ModelPart::ElementsContainerType::iterator pElemIt)
Definition: pfem_gid_io.h:90
std::vector< int > mIndexContainer
Definition: pfem_gid_io.h:305
ModelPart::ElementsContainerType mMeshElements
Definition: pfem_gid_io.h:308
void PrintResults(Variable< Matrix > rVariable, ModelPart &r_model_part, double SolutionTag, int value_index=0)
Definition: pfem_gid_io.h:203
PfemGidGaussPointsContainer(char *gp_title, KratosGeometryFamily geometryFamily, GiD_ElementType gid_element_type, int number_of_integration_points, std::vector< int > index_container)
Constructor.
Definition: pfem_gid_io.h:82
Definition: pfem_gid_io.h:317
PfemGidMeshContainer(GeometryData::KratosGeometryType geometryType, GiD_ElementType elementType, char *mesh_title)
Constructor.
Definition: pfem_gid_io.h:320
void FinalizeMeshCreation()
Definition: pfem_gid_io.h:360
bool AddElement(const ModelPart::ElementsContainerType::iterator pElemIt)
Definition: pfem_gid_io.h:324
void WriteMesh(bool deformed)
Definition: pfem_gid_io.h:368
void Reset()
Definition: pfem_gid_io.h:545
bool AddCondition(const ModelPart::ConditionsContainerType::iterator pCondIt)
Definition: pfem_gid_io.h:342
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
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