26 : mbImpl( impl ), fileName( NULL ), IndexFile( 0 ), BaseName( NULL ), IndexBase( 0 ), ZoneName( NULL ),
27 IndexZone( 0 ), IndexSection( 0 ), celldim( 0 ), physdim( 0 ), VrtSize( 0 ), EdgeSize( 0 ), FaceSize( 0 ),
46 const std::vector< std::string >&,
58 std::cout <<
"THE CGNS CONVERSION ONLY WORKS FOR ENTITIES CITED BELOW:";
59 std::cout <<
"\n -MBVERTEX\n -MBEDGE\n -MBTRI\n -MBQUAD";
60 std::cout <<
"\n -MBTET\n -MBPYRAMID\n -MBHEX\n";
87 std::cout <<
"\nThe Number of Vertex is " <<
VrtSize <<
".\n";
88 std::cout <<
"The Number of Edges is " <<
EdgeSize <<
".\n";
89 std::cout <<
"The Number of Faces is " <<
FaceSize <<
".\n";
90 std::cout <<
"The Number of Cells is " <<
CellSize <<
".\n\n";
110 std::cout <<
"Error opening file\n";
117 std::cout <<
"Error creating CGNS base";
131 std::cout <<
"Error creating CGNS zone\n";
142 std::vector< moab::Tag > TagHandles;
150 int NbTags = TagHandles.size();
151 std::cout <<
"\nThe mesh has " << NbTags <<
" Tags.\n";
155 std::vector< SetStruct > Sets;
156 Sets.reserve( NbTags );
161 std::cout <<
"Problem to set tag values\n";
166 std::vector< std::vector< cgsize_t > > ConnTable;
167 ConnTable.resize( NbTags );
169 std::vector< int > Begin( NbTags, 0 );
170 std::vector< int > End( NbTags, 0 );
181 std::cout <<
"Problem to fill the connectivity table for 1-D entities\n";
184 for(
int i = 0; i < NbTags; ++i )
186 if( Sets[i].IdSet != -1 )
188 const char* SectionName = Sets[i].TagName.c_str();
189 EndSetsIndex = BeginSetsIndex + Sets[i].NbEdges - 1;
192 BeginSetsIndex, EndSetsIndex, 0, &ConnTable[i][0], &
IndexSection ) )
194 std::cout <<
"Issue on writing connectivity - 3-D\n";
197 BeginSetsIndex = EndSetsIndex + 1;
205 std::cout <<
"Problem to fill the connectivity table for 1-D entities\n";
211 std::cout <<
"Problem to fill the connectivity table for 2-D entities\n";
214 for(
int i = 0; i < NbTags; ++i )
216 if( Sets[i].IdSet != -1 )
218 const char* SectionName = Sets[i].TagName.c_str();
219 EndSetsIndex = BeginSetsIndex + Sets[i].NbEdges + Sets[i].NbFaces - 1;
222 BeginSetsIndex, EndSetsIndex, 0, &ConnTable[i][0], &
IndexSection ) )
224 std::cout <<
"Issue on writing connectivity -- 2-D\n";
227 BeginSetsIndex = EndSetsIndex + 1;
235 std::cout <<
"Problem to fill the connectivity table for 2-D entities\n";
241 std::cout <<
"Problem to fill the connectivity table for 3-D entities\n";
244 for(
int i = 0; i < NbTags; ++i )
246 if( Sets[i].IdSet != -1 )
248 const char* SectionName = Sets[i].TagName.c_str();
249 EndSetsIndex = BeginSetsIndex + Sets[i].NbFaces + Sets[i].NbCells - 1;
250 std::cout <<
"BeginSetsIndex = " << BeginSetsIndex <<
"\tEndSetsIndex = " << EndSetsIndex <<
"\n";
253 BeginSetsIndex, EndSetsIndex, 0, &ConnTable[i][0], &
IndexSection ) )
255 std::cout <<
"Issue on writing connectivity -- 3-D\n";
258 BeginSetsIndex = EndSetsIndex + 1;
263 std::cout <<
"Issue on Physical dimension\n";
270 std::cout <<
"Error closing file\n";
285 if(
Nodes.size() > 0 )
290 VrtSize_ = Nodes_.size();
294 std::cout <<
"The mesh has not node points.\n";
307 if( Edges_.size() > 0 )
312 EdgeSize_ = Edges_.size();
330 FaceSize_ = Faces_.size();
348 CellSize_ = Cells_.size();
358 const int num_entities = (int)Nodes_.size();
361 std::vector< double > Coords( 3 * num_entities );
362 std::vector< double >::iterator c = Coords.begin();
365 std::vector< double > CoordX;
366 std::vector< double > CoordY;
367 std::vector< double > CoordZ;
378 std::cout <<
"Error getting coordinates from nodes.\n";
383 CoordX.reserve( Nodes_.size() );
384 CoordY.reserve( Nodes_.size() );
385 CoordZ.reserve( Nodes_.size() );
387 for( std::vector< moab::EntityHandle >::iterator i = Nodes_.begin(); i != Nodes_.end(); ++i )
389 CoordX.push_back( *c );
392 CoordY.push_back( *c );
395 CoordZ.push_back( *c );
405 std::cout <<
" Error writing X coordinates.\n";
414 std::cout <<
" Error writing Y coordinates.\n";
423 std::cout <<
" Error writing Z coordinates.\n";
439 std::vector< moab::EntityHandle >& Edges_,
440 std::vector< moab::EntityHandle >& Faces_,
441 std::vector< moab::EntityHandle >& Cells_,
442 std::vector< WriteCGNS::SetStruct >& Sets )
447 int NbTags = TagHandles.size();
450 for(
int i = 0; i < NbTags; ++i )
460 std::cout <<
"Problem to get Tag Name\n";
463 std::cout <<
"Tag name= " << Sets[i].TagName <<
"\n";
469 std::cout <<
"Problem to get Set entities\n";
477 std::cout <<
"Problem to get CGNSType\n";
480 std::cout <<
"\tSets[" << i <<
"].CGNSType= " << Sets[i].CGNSType <<
"\n";
485 if( Sets[i].CGNSType == BAR_2 || Sets[i].CGNSType == TRI_3 || Sets[i].CGNSType == QUAD_4 ||
486 Sets[i].CGNSType == TETRA_4 || Sets[i].CGNSType == PYRA_5 || Sets[i].CGNSType == PENTA_6 ||
487 Sets[i].CGNSType == HEXA_8 || Sets[i].CGNSType == MIXED )
490 if( Sets[i].NbEdges > 0 &&
physdim < 3 )
493 const std::vector< int > tag_values( Edges_.size(), i );
494 rval =
mbImpl->
tag_set_data( TagHandles[i], &Edges_[0], Edges_.size(), &tag_values[0] );
497 std::cout <<
"Problem to set data for 1-D entities\n";
501 if( Sets[i].NbFaces > 0 &&
physdim > 1 )
504 const std::vector< int > tag_values(
Faces.size(), i );
505 rval =
mbImpl->
tag_set_data( TagHandles[i], &Faces_[0], Faces_.size(), &tag_values[0] );
508 std::cout <<
"Problem to set data for 2-D entities\n";
512 if( Sets[i].NbCells > 0 &&
physdim > 2 )
515 const std::vector< int > tag_values(
Cells.size(), i );
516 rval =
mbImpl->
tag_set_data( TagHandles[i], &Cells_[0], Cells_.size(), &tag_values[0] );
519 std::cout <<
"Problem to set data for 3-D entities\n";
526 std::cout <<
"\tSets[" << i <<
"].IdSet = " << Sets[i].IdSet <<
"\n\n";
533 std::vector< Tag >& TagHandles,
534 std::vector< WriteCGNS::SetStruct >& Sets )
544 std::cout <<
"Problem to get the number of entities by type and tag\n";
547 Sets[i].NbEntities.push_back( Number );
548 Sets[i].NbEdges += Number;
549 std::cout <<
"\tNumber of MBEDGE = " << Number <<
"\n";
557 std::cout <<
"Problem to get the number of entities by type and tag\n";
560 Sets[i].NbEntities.push_back( Number );
561 Sets[i].NbFaces += Number;
562 std::cout <<
"\tNumber of MBTRI = " << Number <<
"\n";
570 std::cout <<
"Problem to get the number of entities by type and tag\n";
573 Sets[i].NbEntities.push_back( Number );
574 Sets[i].NbFaces += Number;
575 std::cout <<
"\tNumber of MBQUAD = " << Number <<
"\n";
583 std::cout <<
"Problem to get the number of entities by type and tag\n";
586 Sets[i].NbEntities.push_back( Number );
587 Sets[i].NbCells += Number;
588 std::cout <<
"\tNumber of MBTET = " << Number <<
"\n";
596 std::cout <<
"Problem to get the number of entities by type and tag\n";
599 Sets[i].NbEntities.push_back( Number );
600 Sets[i].NbCells += Number;
601 std::cout <<
"\tNumber of MBPYRAMID = " << Number <<
"\n";
609 std::cout <<
"Problem to get the number of entities by type and tag\n";
612 Sets[i].NbEntities.push_back( Number );
613 Sets[i].NbCells += Number;
614 std::cout <<
"\tNumber of MBPRISM = " << Number <<
"\n";
622 std::cout <<
"Problem to get the number of entities by type and tag\n";
625 Sets[i].NbEntities.push_back( Number );
626 Sets[i].NbCells += Number;
627 std::cout <<
"\tNumber of MBHEX = " << Number <<
"\n";
629 std::cout <<
"\tTotal number of Edges = " << Sets[i].NbEdges <<
"\n";
630 std::cout <<
"\tTotal number of Faces = " << Sets[i].NbFaces <<
"\n";
631 std::cout <<
"\tTotal number of Cells = " << Sets[i].NbCells <<
"\n";
639 std::vector< int > Test;
646 for(
int j = 0; j < (int)Sets[i].NbEntities.size(); ++j )
648 if( Sets[i].NbEntities[j] > 0 )
665 Sets[i].CGNSType = MIXED;
670 std::cout <<
"Homogeneous Type\n";
671 while( j < (
int)Sets[i].NbEntities.size() && Sets[i].NbEntities[j] != 1 )
678 Sets[i].CGNSType = BAR_2;
681 Sets[i].CGNSType = TRI_3;
684 Sets[i].CGNSType = QUAD_4;
687 Sets[i].CGNSType = TETRA_4;
690 Sets[i].CGNSType = PYRA_5;
693 Sets[i].CGNSType = PENTA_6;
696 Sets[i].CGNSType = HEXA_8;
699 std::cout <<
"It was not possible to identify the CGNSType\n";
705 Sets[i].CGNSType = ElementTypeNull;
716 std::vector< int >& Begin,
717 std::vector< int >& End,
718 std::vector< moab::Tag >& TagHandles,
719 std::vector< WriteCGNS::SetStruct >& Sets,
720 std::vector< std::vector< cgsize_t > >& ConnTable )
728 int NbTags = TagHandles.size();
732 for( std::vector< moab::EntityHandle >::iterator i = Elements.begin(); i != Elements.end(); ++i )
736 for(
int j = 0; j < NbTags; ++j )
739 if( Sets[j].IdSet != -1 )
762 if( Sets[j].CGNSType == MIXED )
768 End[j] = Begin[j] + num_vtx;
770 for(
int k = Begin[j]; k < End[j]; ++k )
772 ConnTable[j].push_back( (
cgsize_t)conn[k - Begin[j]] );
803 std::cout <<
"It was not possible to identify the CGNSType\n";