1 #include "MEDMEM_MedMeshDriver22.hxx"
3 #include "MEDMEM_DriversDef.hxx"
5 #include "MEDMEM_Family.hxx"
6 #include "MEDMEM_Group.hxx"
7 #include "MEDMEM_Coordinate.hxx"
8 #include "MEDMEM_Connectivity.hxx"
9 #include "MEDMEM_Mesh.hxx"
10 #include "MEDMEM_CellModel.hxx"
11 #include "MEDMEM_Grid.hxx"
14 using namespace MED_EN;
15 using namespace MEDMEM;
19 extern med_idt _MEDdatagroupOuvrir(med_idt pid, char *nom);
20 extern med_err _MEDdatagroupFermer(med_idt id);
24 // Every memory allocation made in the MedDriver members function are desallocated in the Mesh destructor
26 MED_MESH_DRIVER22::MED_MESH_DRIVER22(): _medIdt(MED_INVALID)
30 MED_MESH_DRIVER22::MED_MESH_DRIVER22(const string & fileName,
32 MED_EN::med_mode_acces accessMode):
33 _medIdt(MED_INVALID), MED_MESH_DRIVER(fileName,ptrMesh,accessMode)
37 MED_MESH_DRIVER22::MED_MESH_DRIVER22(const MED_MESH_DRIVER22 & driver):
38 MED_MESH_DRIVER(driver),_medIdt(driver._medIdt)
42 MED_MESH_DRIVER22::~MED_MESH_DRIVER22()
46 void MED_MESH_DRIVER22::open()
48 const char * LOC = "MED_MESH_DRIVER22::open()" ;
51 MESSAGE(LOC<<" : _fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode);
52 _medIdt = med_2_2::MEDouvrir( (const_cast <char *> (_fileName.c_str())),(med_2_2::med_mode_acces) _accessMode);
53 MESSAGE(LOC<<" _medIdt : "<< _medIdt );
57 _medIdt = MED_INVALID;
59 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Could not open file "<<_fileName<<" in mode "<<_accessMode));
65 void MED_MESH_DRIVER22::close()
67 const char * LOC = "MED_MESH_DRIVER22::close() " ;
70 if ( _status == MED_OPENED) {
71 err = med_2_2::MEDfermer(_medIdt);
72 // san -- MED5873 : Calling H5close() here leads to failure of SALOMEDS::StudyManager_i::_SaveAs()
73 // method during study saving process. MEDfermer() seems sufficient for closing a file.
74 //H5close(); // If we call H5close() all the files are closed.
76 throw MEDEXCEPTION( LOCALIZED(STRING(LOC)
77 <<" Error when closing file !"
80 MESSAGE(LOC <<": _medIdt= " << _medIdt );
81 MESSAGE(LOC<<": MEDfermer : err = " << err );
83 _medIdt = MED_INVALID;
88 //A FAIRE UTILISER LES MAPS...
89 const med_2_2::med_geometrie_element MED_MESH_DRIVER22::all_cell_type[MED_NBR_GEOMETRIE_MAILLE]=
90 { med_2_2::MED_POINT1,med_2_2::MED_SEG2,med_2_2::MED_SEG3,med_2_2::MED_TRIA3,med_2_2::MED_QUAD4,med_2_2::MED_TRIA6,med_2_2::MED_QUAD8,
91 med_2_2::MED_TETRA4,med_2_2::MED_PYRA5,med_2_2::MED_PENTA6,med_2_2::MED_HEXA8,med_2_2::MED_TETRA10,med_2_2::MED_PYRA13,
92 med_2_2::MED_PENTA15, med_2_2::MED_HEXA20};
94 const char * const MED_MESH_DRIVER22::all_cell_type_tab [MED_NBR_GEOMETRIE_MAILLE]=
95 { "MED_POINT1","MED_SEG2","MED_SEG3","MED_TRIA3","MED_QUAD4","MED_TRIA6","MED_QUAD8",
96 "MED_TETRA4","MED_PYRA5","MED_PENTA6","MED_HEXA8","MED_TETRA10","MED_PYRA13",
97 "MED_PENTA15","MED_HEXA20"};
100 //---------------------------------- RDONLY PART -------------------------------------------------------------
102 MED_MESH_RDONLY_DRIVER22::MED_MESH_RDONLY_DRIVER22()
106 MED_MESH_RDONLY_DRIVER22::MED_MESH_RDONLY_DRIVER22(const string & fileName,
108 IMED_MESH_RDONLY_DRIVER(fileName,ptrMesh),MED_MESH_DRIVER22(fileName,ptrMesh,MED_RDONLY),MED_MESH_DRIVER(fileName,ptrMesh,MED_RDONLY)
110 MESSAGE("MED_MESH_RDONLY_DRIVER22::MED_MESH_RDONLY_DRIVER22(const string & fileName, MESH * ptrMesh) has been created");
113 MED_MESH_RDONLY_DRIVER22::MED_MESH_RDONLY_DRIVER22(const MED_MESH_RDONLY_DRIVER22 & driver):
114 IMED_MESH_RDONLY_DRIVER(driver),MED_MESH_DRIVER22(driver),MED_MESH_DRIVER(driver)
118 MED_MESH_RDONLY_DRIVER22::~MED_MESH_RDONLY_DRIVER22()
120 //MESSAGE("MED_MESH_RDONLY_DRIVER22::~MED_MESH_RDONLY_DRIVER() has been destroyed");
123 GENDRIVER * MED_MESH_RDONLY_DRIVER22::copy(void) const
125 return new MED_MESH_RDONLY_DRIVER22(*this);
128 void MED_MESH_RDONLY_DRIVER22::read(void)
130 const char * LOC = "MED_MESH_RDONLY_DRIVER22::read() : " ;
132 if (_status!=MED_OPENED)
133 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : " << _medIdt << " (the file is not opened)." )) ;
135 _ptrMesh->_name = _meshName;
137 SCRUTE(_ptrMesh->getIsAGrid());
139 if (_ptrMesh->getIsAGrid())
143 // always call getFAMILY : families are requiered !!!!
145 // int nbFam = MEDnFam(_medIdt,
146 // const_cast <char *> (_meshName.c_str()),
148 // MED_FR::MED_FAMILLE);
153 if (getFAMILY()!=MED_VALID)
154 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getFAMILY when the mesh is a grid")) ;
156 buildAllGroups(_ptrMesh->_groupNode,_ptrMesh->_familyNode) ;
163 if (getCOORDINATE()!=MED_VALID)
164 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getCOORDINATE" )) ;
166 if (getCONNECTIVITY()!=MED_VALID)
167 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getCOONECTIVITY")) ;
169 if (getFAMILY()!=MED_VALID)
170 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERREUR in getFAMILY" )) ;
174 // we build all groups
176 buildAllGroups(_ptrMesh->_groupNode,_ptrMesh->_familyNode) ;
178 buildAllGroups(_ptrMesh->_groupCell,_ptrMesh->_familyCell) ;
180 if (_ptrMesh->_meshDimension == 3)
182 buildAllGroups(_ptrMesh->_groupFace,_ptrMesh->_familyFace) ;
183 else if (_ptrMesh->_meshDimension == 2)
185 buildAllGroups(_ptrMesh->_groupEdge,_ptrMesh->_familyEdge) ;
187 // MESSAGE(LOC<<"Checking of CellModel !!!!!!!");
189 // int nbOfTypes = _ptrMesh->_connectivity->_numberOfTypes;
190 // for(int i=0;i<nbOfTypes;i++)
192 // MESSAGE(LOC << _ptrMesh->_connectivity->_type[i]) ;
198 //=======================================================================
201 //=======================================================================
203 void MED_MESH_RDONLY_DRIVER22::getGRID()
205 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getGRID() : " ;
208 if (_status!=MED_OPENED)
209 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "med file is not opened"));
211 GRID * ptrGrid = (GRID *) _ptrMesh;
217 int numberOfMeshesInFile = med_2_2::MEDnMaa(_medIdt);
219 if (numberOfMeshesInFile == MED_INVALID)
220 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Problem in File where the mesh " << _meshName << " is supposed to be stored"));
222 for (int index = 0; index < numberOfMeshesInFile; index++)
224 char meshName[MED_TAILLE_NOM+1]="";
225 char meshDescription[MED_TAILLE_DESC+1]="";
227 med_2_2::med_maillage meshType;
229 err = med_2_2::MEDmaaInfo(_medIdt, (index+1),meshName, &meshDim,
230 &meshType, meshDescription) ;
232 MESSAGE(LOC<<": Mesh n°"<< (index+1) <<" nammed "<< meshName << " with the description " << meshDescription << " is structured");
234 if (_meshName == string(meshName))
236 _ptrMesh->_description = meshDescription;
237 _ptrMesh->_name = meshName;
241 MED_EN::med_grid_type gridType = ptrGrid->getGridType();
243 MESSAGE(LOC<<": Mesh processed is nammed "<< _ptrMesh->_name << " with the description " << _ptrMesh->_description << " is structured with the type " << gridType);
245 // Read the dimension of the mesh <_meshName>
246 int MeshDimension = med_2_2::MEDdimLire(_medIdt, const_cast <char *>
247 (_meshName.c_str())) ;
249 if (MeshDimension == MED_INVALID)
250 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The mesh dimension |" <<
251 MeshDimension << "| seems to be incorrect " <<
252 "for the mesh : |" << _meshName << "|")) ;
254 _ptrMesh->_meshDimension = MeshDimension;
256 // Read or get the dimension of the space for the mesh <_meshName>
257 int SpaceDimension = MeshDimension;
259 int SpaceDimensionRead = med_2_2::MEDdimEspaceLire(_medIdt,
261 (_meshName.c_str())) ;
263 if (SpaceDimensionRead != MED_INVALID) SpaceDimension = SpaceDimensionRead;
265 _ptrMesh->_spaceDimension = SpaceDimension;
267 med_2_2::med_repere rep ;
268 string tmp_nom_coord (MED_TAILLE_PNOM22*(_ptrMesh->_spaceDimension)+1,' ');
269 string tmp_unit_coord(MED_TAILLE_PNOM22*(_ptrMesh->_spaceDimension)+1,' ');
270 char * tmp_nom = (const_cast <char *> ( tmp_nom_coord.c_str()) ) ;
271 char * tmp_unit= (const_cast <char *> ( tmp_unit_coord.c_str()) ) ;
274 int * ArrayLen[] = { & ptrGrid->_iArrayLength,
275 & ptrGrid->_jArrayLength,
276 & ptrGrid->_kArrayLength };
278 MESSAGE(LOC << "The mesh is a " << _ptrMesh->_meshDimension << "D mesh on a " << _ptrMesh->_spaceDimension << "D space");
282 // if (gridType == MED_EN::MED_GRILLE_STANDARD)
283 if (gridType == MED_EN::MED_BODY_FITTED)
285 int * structure = new int[MeshDimension];
287 err = med_2_2::MEDstructureCoordLire(_medIdt,
289 (_ptrMesh->_name.c_str()),
290 MeshDimension,structure);
292 if (err != MED_VALID)
293 throw MEDEXCEPTION(STRING(LOC) <<"Error in reading the structure of grid : |" << _meshName << "|" ) ;
297 for (int idim = 0; idim < MeshDimension; idim++)
299 MESSAGE(LOC<<"structure dim " << idim << " " << structure[idim]);
301 ArrayLen [idim][0] = structure[idim];
302 NumberOfNodes = NumberOfNodes*structure[idim];
307 // NumberOfNodes = MED_FR::MEDnEntMaa(_medIdt,
308 // const_cast <char *>
309 // (_ptrMesh->_name.c_str()),
310 // MED_FR::MED_COOR,MED_FR::MED_NOEUD,
311 // (MED_FR::med_geometrie_element) 0,
312 // (MED_FR::med_connectivite) 0);
314 if ( NumberOfNodes == MED_INVALID )
315 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The number of nodes |" <<
317 "| seems to be incorrect "
318 << "for the mesh : |" <<
319 _meshName << "|" )) ;
321 _ptrMesh->_numberOfNodes = NumberOfNodes ;
323 // create coordinates and its structure
324 _ptrMesh->_coordinate = new COORDINATE(SpaceDimension,NumberOfNodes,
325 MED_EN::MED_FULL_INTERLACE);
327 err = MEDcoordLire(_medIdt,
328 const_cast <char *> (_ptrMesh->_name.c_str()),
329 _ptrMesh->_spaceDimension,
330 //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
331 const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
332 med_2_2::MED_FULL_INTERLACE,
333 MED_ALL, // we read all the coordinates
334 NULL, // we don't use a profile
335 0, // so the profile's size is 0
336 &rep,tmp_nom,tmp_unit);
338 if (err != MED_VALID)
339 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't read coordinates of the |" <<
340 NumberOfNodes << "| nodes for the mesh : |" <<
341 _meshName << "| of space dimension |" <<
342 SpaceDimension << "| with units names |" <<
343 tmp_nom << "| and units |" <<
346 ptrGrid->_is_coordinates_filled = true;
348 else if ((gridType == MED_EN::MED_CARTESIAN) ||
349 (gridType == MED_EN::MED_POLAR))
353 double * Array[] = { (double*) 0, (double*) 0, (double*) 0 };
355 for (int idim = 0; idim < _ptrMesh->_meshDimension; ++idim)
357 med_2_2::med_table table;
358 if (idim == 0) table = med_2_2::MED_COOR_IND1;
359 else if (idim == 1) table = med_2_2::MED_COOR_IND2;
360 else if (idim == 2) table = med_2_2::MED_COOR_IND3;
362 int length = med_2_2::MEDnEntMaa(_medIdt,
363 const_cast <char *> (_ptrMesh->_name.c_str()),
364 table,med_2_2::MED_NOEUD,
367 if ( length <= MED_VALID )
368 throw MEDEXCEPTION(STRING(LOC) <<"The number of nodes |" << length <<
369 "| seems to be incorrect "
370 << "for the mesh : |" << _meshName << "|" ) ;
372 ArrayLen [idim][0] = length;
373 NumberOfNodes *= length;
375 Array [idim] = new double [ length ];
377 err = med_2_2::MEDindicesCoordLire(_medIdt, const_cast <char *>
378 (_ptrMesh->_name.c_str()),
379 _ptrMesh->_meshDimension,
380 Array [idim], length, (idim+1),
381 tmp_nom+(idim*MED_TAILLE_PNOM22),
382 tmp_unit+(idim*MED_TAILLE_PNOM22));
384 if (err != MED_VALID)
385 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Error in reading coordinates indices " <<
386 idim << "of the grid : |" <<
387 _meshName << "|" )) ;
390 ptrGrid->_iArray = Array[0];
391 ptrGrid->_jArray = Array[1];
392 ptrGrid->_kArray = Array[2];
394 _ptrMesh->_numberOfNodes = NumberOfNodes ;
396 // create coordinates
397 _ptrMesh->_coordinate = new COORDINATE(SpaceDimension,NumberOfNodes,
398 MED_EN::MED_FULL_INTERLACE);
400 if (gridType == MED_EN::MED_CARTESIAN)
401 rep = med_2_2::MED_CART;
402 else if (gridType == MED_EN::MED_POLAR)
404 if (SpaceDimension == 2) rep = med_2_2::MED_CYL;
405 else if (SpaceDimension == 3) rep = med_2_2::MED_SPHER;
409 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<" bad grid type : " << gridType));
411 // set coordinate names
413 for (i=0; i<_ptrMesh->_spaceDimension; ++i ) {
414 string myStringName(tmp_nom_coord,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ;
415 string myStringUnit(tmp_unit_coord,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ;
416 // suppress space at the end
418 for(j=MED_TAILLE_PNOM22-1;j>=0;j--)
419 if (myStringName[j] != ' ') break ;
420 _ptrMesh->_coordinate->_coordinateName[i]=string(myStringName,0,j+1);
421 for(j=MED_TAILLE_PNOM22-1;j>=0;j--)
422 if (myStringUnit[j] != ' ') break ;
423 _ptrMesh->_coordinate->_coordinateUnit[i]=string(myStringUnit,0,j+1);
426 string coordinateSystem = "UNDEFINED";
428 if( rep == med_2_2::MED_CART) coordinateSystem = "CARTESIAN";
429 else if ( rep == med_2_2::MED_CYL) coordinateSystem = "CYLINDRICAL";
430 else if ( rep == med_2_2::MED_SPHER) coordinateSystem = "SPHERICAL";
432 _ptrMesh->_coordinate->setCoordinatesSystem(coordinateSystem);
437 //=======================================================================
438 //function : getCOORDINATE
439 // A FAIRE : RENVOYER DU VOID
440 //=======================================================================
441 int MED_MESH_RDONLY_DRIVER22::getCOORDINATE()
443 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getCOORDINATE() : " ;
447 if (_status==MED_OPENED)
451 int numberOfMeshesInFile = med_2_2::MEDnMaa(_medIdt);
453 if (numberOfMeshesInFile == MED_INVALID)
454 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Problem in File where the mesh " << _meshName << " is supposed to be stored"));
456 for (int index = 0; index < numberOfMeshesInFile; index++)
458 char meshName[MED_TAILLE_NOM+1]="";
459 char meshDescription[MED_TAILLE_DESC+1]="";
461 med_2_2::med_maillage meshType;
463 err = med_2_2::MEDmaaInfo(_medIdt, (index+1), meshName, &meshDim,
464 &meshType, meshDescription) ;
466 MESSAGE(LOC<<": Mesh n°"<< (index+1) <<" nammed "<< meshName << " with the description " << meshDescription << " is structured");
468 if (_meshName == string(meshName))
470 _ptrMesh->_description = meshDescription;
475 // Read the dimension of the mesh <_meshName>
476 int MeshDimension = med_2_2::MEDdimLire(_medIdt, const_cast <char *>
477 (_meshName.c_str())) ;
479 if ( MeshDimension == MED_INVALID )
480 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The mesh dimension |" <<
482 "| seems to be incorrect " <<
483 "for the mesh : |" << _meshName << "|")) ;
485 _ptrMesh->_meshDimension = MeshDimension;
487 // Read or get the dimension of the space for the mesh <_meshName>
488 int SpaceDimension = MeshDimension;
490 int SpaceDimensionRead = med_2_2::MEDdimEspaceLire(_medIdt,
492 (_meshName.c_str())) ;
494 if (SpaceDimensionRead != MED_INVALID)
495 SpaceDimension = SpaceDimensionRead;
497 _ptrMesh->_spaceDimension = SpaceDimension;
499 // Read the number of nodes used in the mesh <_meshName>
500 // to be able to create a COORDINATE object
501 int NumberOfNodes=MEDnEntMaa(_medIdt,
502 const_cast <char *> (_meshName.c_str()),
505 (med_2_2::med_geometrie_element) MED_NONE,
506 (med_2_2::med_connectivite) MED_NONE);
507 if ( NumberOfNodes <= MED_VALID )
508 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"The number of nodes |" << NumberOfNodes << "| seems to be incorrect "
509 << "for the mesh : |" << _meshName << "|" )) ;
510 _ptrMesh->_numberOfNodes = NumberOfNodes ;
512 // create a COORDINATE object
513 _ptrMesh->_coordinate = new COORDINATE(SpaceDimension, NumberOfNodes, MED_EN::MED_FULL_INTERLACE);
515 med_2_2::med_repere rep ; // ATTENTION ---> DOIT ETRE INTEGRE DS MESH EF: FAIT NON?
516 string tmp_nom_coord (MED_TAILLE_PNOM22*(_ptrMesh->_spaceDimension)+1,'\0');
517 string tmp_unit_coord(MED_TAILLE_PNOM22*(_ptrMesh->_spaceDimension)+1,'\0');
518 char * tmp_nom = (const_cast <char *> ( tmp_nom_coord.c_str()) ) ;
519 char * tmp_unit= (const_cast <char *> ( tmp_unit_coord.c_str()) ) ;
521 err=MEDcoordLire(_medIdt,
522 const_cast <char *> (_ptrMesh->_name.c_str()),
523 _ptrMesh->_spaceDimension,
524 //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
525 const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
526 med_2_2::MED_FULL_INTERLACE,
527 MED_ALL, // we read all the coordinates
528 NULL, // we don't use a profile
529 0, // so the profile's size is 0
530 &rep,tmp_nom,tmp_unit);
531 if (err != MED_VALID)
532 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't read coordinates of the |" << NumberOfNodes << "| nodes "
533 << "for the mesh : |" << _meshName
534 << "| of space dimension |" << SpaceDimension
535 << "| with units names |" << tmp_nom
536 << "| and units |" << tmp_unit
540 for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
541 string myStringName(tmp_nom_coord,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ;
542 string myStringUnit(tmp_unit_coord,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ;
543 // suppress space at the end
545 for(j=MED_TAILLE_PNOM22-1;j>=0;j--)
546 if (myStringName[j] != ' ') break ;
547 _ptrMesh->_coordinate->_coordinateName[i]=string(myStringName,0,j+1);
548 for(j=MED_TAILLE_PNOM22-1;j>=0;j--)
549 if (myStringUnit[j] != ' ') break ;
550 _ptrMesh->_coordinate->_coordinateUnit[i]=string(myStringUnit,0,j+1);
553 // Pourquoi le stocker sous forme de chaîne ?
556 case med_2_2::MED_CART :
558 _ptrMesh->_coordinate->_coordinateSystem = "CARTESIAN";
561 case med_2_2::MED_CYL :
563 _ptrMesh->_coordinate->_coordinateSystem = "CYLINDRICAL";
566 case med_2_2::MED_SPHER :
568 _ptrMesh->_coordinate->_coordinateSystem = "SPHERICAL";
573 _ptrMesh->_coordinate->_coordinateSystem = "UNDEFINED"; // ?Erreur ?
578 // Read the unused optional node Names
579 char * tmp_node_name = new char[NumberOfNodes*MED_TAILLE_PNOM22+1];
580 tmp_node_name[NumberOfNodes]='\0' ;
581 err=MEDnomLire(_medIdt,const_cast <char*> (_ptrMesh->_name.c_str()),
582 tmp_node_name,NumberOfNodes*MED_TAILLE_PNOM22,med_2_2::MED_NOEUD,
583 (med_2_2::med_geometrie_element) MED_NONE);
584 if (err == MED_VALID)
585 MESSAGE(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : WARNING : Nodes have names but we do not read them !");
586 delete[] tmp_node_name ;
589 // ??? Read the unused optional node Numbers ???
590 med_2_2::med_int * tmp_node_number = new med_2_2::med_int[NumberOfNodes] ;
591 err=MEDnumLire(_medIdt,const_cast <char*> (_ptrMesh->_name.c_str()),
592 tmp_node_number,NumberOfNodes,med_2_2::MED_NOEUD,(med_2_2::med_geometrie_element)0);
593 if (err == MED_VALID) {
594 // INFOS(LOC<<"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING");
595 // INFOS(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : WARNING : Nodes have numbers but we do not take care of them !");
596 // INFOS(LOC<<"WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING - WARNING");
597 MESSAGE(LOC<<"MED_MESH_RDONLY_DRIVER::getNoeuds() : Nodes have numbers, we DO TAKE care of them !");
598 _ptrMesh->_coordinate->_nodeNumber.set(NumberOfNodes) ;
599 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
600 for(med_2_2::med_int i2=0;i2<NumberOfNodes;i2++)
601 _ptrMesh->_coordinate->_nodeNumber[i2]=(int)(tmp_node_number[i2]);
603 memcpy((int*)_ptrMesh->_coordinate->_nodeNumber,tmp_node_number,sizeof(int)*NumberOfNodes) ;
606 //////////////////////////////////////////////////////////////////////////////////////
607 /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
608 //////////////////////////////////////////////////////////////////////////////////////
610 /// Calcule _optionnalToCanonicNodesNumbers de telle sorte que _optionnalToCanonicNodesNumbers[OptionnalNumber]==CanonicNumber
612 // _ptrMesh->_arePresentOptionnalNodesNumbers=1;
613 // for (int canonicNumber=1;canonicNumber<=NumberOfNodes;canonicNumber++) _ptrMesh->_optionnalToCanonicNodesNumbers[tmp_node_number[canonicNumber-1]]=canonicNumber;
614 // ICI RETOUR A LA NORMALE::: AUCUNE PRISE EN COMPTE D'UN NUMEROTATION OPTIONNEL
615 _ptrMesh->_arePresentOptionnalNodesNumbers=0;
617 else _ptrMesh->_arePresentOptionnalNodesNumbers=0;
619 //////////////////////////////////////////////////////////////////////////////////////
621 delete[] tmp_node_number ;
630 int MED_MESH_RDONLY_DRIVER22::getCONNECTIVITY()
632 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getCONNECTIVITY : " ;
635 if (_status==MED_OPENED)
639 // read MED_CELL connectivity
640 CONNECTIVITY * Connectivity = new CONNECTIVITY(MED_CELL) ;
641 Connectivity->_numberOfNodes = _ptrMesh->_numberOfNodes ; // EF : Pourquoi cet attribut est-il dans MESH et non dans COORDINATE ?
643 // Try to read nodal connectivity of the cells <Connectivity->_nodal>
644 // then try to read descending connectivity <Connectivity->_descending>
645 // if neither nodal nor descending connectivity exists
646 // throw an exception.
647 err = getNodalConnectivity(Connectivity) ;
650 Connectivity->_typeConnectivity = MED_DESCENDING ;
651 err = getDescendingConnectivity(Connectivity) ;
654 getDescendingConnectivity(Connectivity) ; // we read it if there is one
658 delete Connectivity ;
659 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "We could not read " <<
660 "any Connectivity")) ;
663 if (Connectivity->_entityDimension != _ptrMesh->_meshDimension)
664 MESSAGE(LOC << "Small mesh dimension problem on the med file mounted in memory : diim stored " << _ptrMesh->_meshDimension << " dim computed using the connectivity " << Connectivity->_entityDimension);
666 _ptrMesh->_meshDimension = Connectivity->_entityDimension ;
668 // At this point Connectivity->_typeConnectivity is either NODAL or DESCENDING
669 // If both connectivities are found Connectivity->_typeConnectivity is NODAL
670 // If space dimension is 3
671 // try to read the nodal connectivity of the faces <ConnectivityFace->_nodal> then
672 // try to read the descending connectivity <ConnectivityFace->_descending>
673 // if there is no descending connectivity and the CELLS are
674 // defined in descending mode then throw an exception
676 // PROVISOIRE : if we have some face or edge in MED_MAILLE, we don't read more. There could not be have face or edge !!!!
678 if(Connectivity->_constituent==NULL) {
680 SCRUTE(_ptrMesh->_meshDimension);
681 SCRUTE(Connectivity->_entityDimension);
682 if (_ptrMesh->_meshDimension == 3) {
683 MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES FACES..." );
684 CONNECTIVITY * ConnectivityFace = new CONNECTIVITY(MED_EN::MED_FACE) ;
685 ConnectivityFace->_typeConnectivity = Connectivity->_typeConnectivity ; // NODAL or DESCENDING
686 SCRUTE(ConnectivityFace->_typeConnectivity);
687 if (Connectivity->_typeConnectivity == MED_DESCENDING) {
688 MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE DES FACES" );
689 err = getDescendingConnectivity(ConnectivityFace) ;
691 throw MEDEXCEPTION ( LOCALIZED(STRING(LOC) << "No FACE in descending connectivity")) ;
692 getNodalConnectivity(ConnectivityFace) ; // if any !
694 MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES FACES" );
695 err = getNodalConnectivity(ConnectivityFace) ;
696 if (err!=MED_VALID) { // or error ????? we are in NODAL mode.
697 err = getDescendingConnectivity(ConnectivityFace) ;
699 getDescendingConnectivity(ConnectivityFace); // if any !
701 if (err!=MED_VALID) {
702 delete ConnectivityFace ;
703 MESSAGE(LOC<<"No FACE defined.") ;
705 MESSAGE(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES FACES DANS L'OBJET CONNECTIVITY" );
706 Connectivity->_constituent=ConnectivityFace ;
710 // read MED_EDGE connectivity
711 if (_ptrMesh->_meshDimension > 1) { // we are in 3 or 2D
712 MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES ARRETES...." );
713 CONNECTIVITY * ConnectivityEdge = new CONNECTIVITY(MED_EDGE) ;
714 ConnectivityEdge->_typeConnectivity = Connectivity->_typeConnectivity ;
715 if (Connectivity->_typeConnectivity == MED_DESCENDING) {
716 MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE DES ARRETES" );
717 err = getDescendingConnectivity(ConnectivityEdge) ;
719 throw MEDEXCEPTION ( LOCALIZED(STRING(LOC) << "No EDGE in descending connectivity")) ;
720 getNodalConnectivity(ConnectivityEdge) ; // if any !
722 MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES ARRETES" );
723 err = getNodalConnectivity(ConnectivityEdge) ;
724 if (err!=MED_VALID) { // or error ????? we are in NODAL mode.
725 err = getDescendingConnectivity(ConnectivityEdge) ;
727 getDescendingConnectivity(ConnectivityEdge) ; // if any !
729 if (err!=MED_VALID) {
730 delete ConnectivityEdge ;
731 MESSAGE(LOC<<"No EDGE defined.") ;
733 if (_ptrMesh->_meshDimension == 3)
734 if (Connectivity->_constituent != NULL)
735 Connectivity->_constituent->_constituent=ConnectivityEdge ;
737 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< "EDGE defined but there are no FACE !")) ;
739 MESSAGE(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES ARETES DANS L'OBJET CONNECTIVITY" );
740 Connectivity->_constituent=ConnectivityEdge ;
745 _ptrMesh->_connectivity = Connectivity ;
749 // we have read all connectivity in file, now we must build descending connectivity if necessary !
751 // If connectivity descending is defined, we have nothing to do, all constituent are defined !
752 // If connectivity is only nodal, we must rebuild descending if we have some contituent !
755 // if (Connectivity->_descending == NULL)
756 // if (Connectivity->_constituent != NULL){
757 // // update Connectivity->_constituent
758 // CONNECTIVITY * myConstituentOld = Connectivity->_constituent ;
759 // Connectivity->_constituent = (CONNECTIVITY *)NULL ;
760 // Connectivity->calculateDescendingConnectivity() ;
770 int MED_MESH_RDONLY_DRIVER22::getNodalConnectivity(CONNECTIVITY * Connectivity)
772 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getNodalConnectivity : " ;
775 int spaceDimension = _ptrMesh->_spaceDimension;
777 if (_status==MED_OPENED)
779 // Get the type of entity to work on (previously set in the Connectivity Object)
780 med_2_2::med_entite_maillage Entity = (med_2_2::med_entite_maillage) Connectivity->getEntity();
782 // Get the number of cells of each type & store it in <tmp_cells_count>.
783 int * tmp_cells_count = new int[MED_NBR_GEOMETRIE_MAILLE] ;
785 for (i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
786 { // EF :ON SCANNE DES GEOMETRIES INUTILES, UTILISER LES MAPS
787 tmp_cells_count[i]=MEDnEntMaa(_medIdt,(const_cast <char *> (_ptrMesh->_name.c_str())),
788 med_2_2::MED_CONN,(med_2_2::med_entite_maillage) Entity,
789 all_cell_type[i],med_2_2::MED_NOD);
792 // Get the greatest dimension of the cells : Connectivity->_entityDimension
793 // We suppose there is no cells used as faces in MED 2.2.x , this is forbidden !!!
794 // In version prior to 2.2.x, it is possible
795 if (tmp_cells_count[i]>0)
797 Connectivity->_entityDimension=all_cell_type[i]/100;
798 Connectivity->_numberOfTypes++;
804 // begin classic geometric types
805 if (Connectivity->_numberOfTypes > 0)
807 // if MED version < 2.2.x, we read only entity with dimention = Connectivity->_entityDimension. Lesser dimension are face or edge !
809 med_int major, minor, release;
811 if ( med_2_2::MEDversionLire(_medIdt, &major, &minor, &release) != 0 )
813 // error : we suppose we have not a good med file !
814 delete[] tmp_cells_count ;
818 // we get MED version number
819 // If MED version is < 2.2 then the cells which dimension
820 // is lesser than the main dimension ( Connectivity->_entityDimension )
821 // are either faces or edges
823 // string medVersion(version_med);
825 int * tmpEdgeCount = new int[MED_NBR_GEOMETRIE_MAILLE] ;
826 tmpEdgeCount[0] = 0 ;
827 int numberOfEdgesTypes = 0;
828 int * tmpFaceCount = new int[MED_NBR_GEOMETRIE_MAILLE] ;
829 tmpFaceCount[0] = 0 ;
830 int numberOfFacesTypes = 0;
832 // if ((version_med != "2.2")&(Entity==MED_FR::MED_MAILLE))
834 // Connectivity->_numberOfTypes=0;
836 // for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
838 // tmpFaceCount[i]=0;
839 // tmpEdgeCount[i]=0;
840 // if (tmp_cells_count[i]!=0)
842 // int dimension = all_cell_type[i]/100 ;
843 // if (Connectivity->_entityDimension==dimension)
844 // Connectivity->_numberOfTypes++ ;
846 // if (dimension == 2)
847 // if (Connectivity->_entityDimension==3)
849 // tmpFaceCount[i]=tmp_cells_count[i] ;
850 // tmp_cells_count[i]=0 ;
851 // numberOfFacesTypes++;
853 // if (dimension == 1)
854 // if (Connectivity->_entityDimension>dimension)
856 // tmpEdgeCount[i]=tmp_cells_count[i] ;
857 // tmp_cells_count[i]=0;
858 // numberOfEdgesTypes++ ;
864 if (Entity==med_2_2::MED_MAILLE)
866 Connectivity->_numberOfTypes=0;
868 for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
872 if (tmp_cells_count[i]!=0)
874 int dimension = all_cell_type[i]/100 ;
875 if (Connectivity->_entityDimension==dimension)
876 Connectivity->_numberOfTypes++ ;
879 if (Connectivity->_entityDimension==3)
881 tmpFaceCount[i]=tmp_cells_count[i] ;
882 //tmp_cells_count[i]=0 ;
883 //Connectivity->_numberOfTypes++ ;
884 numberOfFacesTypes++;
887 if (Connectivity->_entityDimension>dimension)
889 tmpEdgeCount[i]=tmp_cells_count[i] ;
890 //tmp_cells_count[i]=0;
891 //Connectivity->_numberOfTypes++ ;
892 numberOfEdgesTypes++ ;
898 // bloc to read CELL :
900 // Prepare an array of indexes on the different cell types to create a MEDSKYLINEARRAY
901 // We use <tmp_cells_count> to calculate <Connectivity->_count> then we release it
902 Connectivity->_geometricTypes = new MED_EN::medGeometryElement [Connectivity->_numberOfTypes] ; // Double emploi pour des raisons pratiques
903 Connectivity->_type = new CELLMODEL [Connectivity->_numberOfTypes] ; //
904 Connectivity->_count = new int [Connectivity->_numberOfTypes+1] ;
905 Connectivity->_count[0] = 1;
910 for ( i=1;i<MED_NBR_GEOMETRIE_MAILLE;i++)
911 { // no point1 cell type (?)
912 int dimension = all_cell_type[i]/100 ;
913 if ((tmp_cells_count[i]>0) && (Connectivity->_entityDimension == dimension))
915 Connectivity->_count[typeNumber]=Connectivity->_count[typeNumber-1]+tmp_cells_count[i];
917 CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i]) ;
919 Connectivity->_type[typeNumber-1] = t ;
921 Connectivity->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i] ;
923 // probleme avec les mailles de dimension < a dimension du maillage :
924 // Il faut oter le zero a la lecture est le remettre a l'ecriture : ce n'est pas fait !!!!! On interdit ce cas pour l'instant !!!
927 size+=tmp_cells_count[i]*((MED_MESH_DRIVER22::all_cell_type[i])%100) ;
930 << Connectivity->_count[typeNumber]-1 << " cells of type "
931 << all_cell_type_tab[i] );
936 // Creation of the MEDSKYLINEARRAY
937 //Connectivity->_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1,size) ;
938 //int * NodalIndex = Connectivity->_nodal->getIndex() ;
939 int * NodalValue = new int[size] ;
940 int * NodalIndex = new int[Connectivity->_count[Connectivity->_numberOfTypes]] ;
943 // Fill the MEDSKYLINEARRAY by reading the MED file.
945 for ( i=0;i<Connectivity->_numberOfTypes;i++)
948 med_2_2::med_geometrie_element med_type = (med_2_2::med_geometrie_element) Connectivity->_type[i].getType() ;
949 // if ( Connectivity->_type[i].getDimension() < Connectivity->_entityDimension)
950 // if (Connectivity->_entity == MED_CELL)
951 // if ( Connectivity->_type[i].getDimension() < _ptrMesh->_spaceDimension)
954 // int NumberOfCell = Connectivity->_count[i+1]-Connectivity->_count[i] ;
955 int NumberOfNodeByCell = Connectivity->_type[i].getNumberOfNodes() ;
958 for ( j=Connectivity->_count[i]; j<Connectivity->_count[i+1];j++)
959 NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByCell ;
961 int tmp_numberOfCells = Connectivity->_count[i+1]-Connectivity->_count[i] ;
962 int * tmp_ConnectivityArray = new int[(NumberOfNodeByCell+multi)*tmp_numberOfCells];
964 // int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
965 // Connectivity->_entityDimension,tmp_ConnectivityArray,
966 // MED_FR::MED_FULL_INTERLACE,NULL,0,Entity,med_type,MED_FR::MED_NOD);
967 int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
968 spaceDimension,tmp_ConnectivityArray,
969 med_2_2::MED_FULL_INTERLACE,NULL,0,Entity,med_type,med_2_2::MED_NOD);
971 if ( err != MED_VALID)
973 delete[] tmp_ConnectivityArray;
974 delete[] tmp_cells_count;
975 delete[] tmpFaceCount;
976 delete[] tmpEdgeCount;
977 MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
981 int * ConnectivityArray = NodalValue + NodalIndex[Connectivity->_count[i]-1]-1 ;
983 // version originale sans prise en compte des numéros optionnels
985 for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++)
986 ConnectivityArray[j*NumberOfNodeByCell+k]=tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k] ;
988 //////////////////////////////////////////////////////////////////////////////
989 // Modification pour prise en compte de la numérotation optionnelle des noeuds ///
990 //////////////////////////////////////////////////////////////////////////////
992 // Rénumérote le tableau temporaire tmp_ConnectivityArray en utilisant _optionnalToCanonicNodesNumbers
993 // Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
995 // if (_ptrMesh->_arePresentOptionnalNodesNumbers==1)
997 // for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++)
998 // ConnectivityArray[j*NumberOfNodeByCell+k]=_ptrMesh->_optionnalToCanonicNodesNumbers[tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k]] ;
1002 // for ( j=0; j<tmp_numberOfCells; j++) for (int k=0; k<NumberOfNodeByCell; k++)
1003 // ConnectivityArray[j*NumberOfNodeByCell+k]=tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k] ;
1005 ////////////////////////////////////////////////////////////////////////////
1007 delete[] tmp_ConnectivityArray;
1011 Connectivity->_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1,
1016 delete[] NodalIndex;
1017 delete[] NodalValue;
1019 } // end of bloc to read CELL
1025 if (numberOfFacesTypes!=0)
1028 // Create a CONNECTIVITY constituent to put in the top level CONNECTIVITY recursive class
1029 CONNECTIVITY * constituent = new CONNECTIVITY(numberOfFacesTypes,MED_EN::MED_FACE) ;
1030 constituent->_entityDimension = 2 ;
1031 constituent->_count[0]=1 ;
1033 // In order to create the MEDSKYLINEARRAY of the constituent object we need :
1035 // To initialize the _count array of the constituent object (containning cumulated face count by geometric type)
1036 // _count[0]=1 and _count[_numberOfTypes] give the size of NodalIndex
1038 // To calculate the total number of face nodes whatever the geometric type is.
1039 // The result is the size of the array containning all the nodes : NodalValue
1041 // To calculate the starting indexes of the different face types in NodalValue,
1042 // this is the NodalIndex array.
1045 int typeNumber = 1 ;
1047 for ( i=1; i < MED_NBR_GEOMETRIE_MAILLE; i++)
1048 { // no point1 cell type (?)
1049 if (tmpFaceCount[i]>0)
1051 constituent->_count[typeNumber] = constituent->_count[typeNumber-1] + tmpFaceCount[i];
1052 CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i]) ;
1053 constituent->_type[typeNumber-1]=t ;
1055 constituent->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i] ;
1057 size+=tmpFaceCount[i]*((MED_MESH_DRIVER22::all_cell_type[i])%100) ;
1062 // Creation of the MEDSKYLINEARRAY
1063 //constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,size) ;
1064 //int * NodalIndex = constituent->_nodal->getIndex() ;
1065 int * NodalValue = new int[size] ;
1066 int * NodalIndex = new int[constituent->_count[constituent->_numberOfTypes]] ;
1069 // Fill the MEDSKYLINEARRAY by reading the MED file.
1070 for ( i=0; i<constituent->_numberOfTypes; i++)
1072 med_2_2::med_geometrie_element med_type = (med_2_2::med_geometrie_element) constituent->_type[i].getType() ;
1074 int NumberOfNodeByFace = constituent->_type[i].getNumberOfNodes() ;
1076 // initialise NodalIndex
1077 for (int j=constituent->_count[i]; j<constituent->_count[i+1];j++)
1078 NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByFace ;
1080 int tmp_numberOfFaces = constituent->_count[i+1]-constituent->_count[i] ;
1081 // Il faut ajouter 1 pour le zero a la lecture !!!
1082 // ATTENTION UNIQUEMENT POUR MED < 2.2.x
1083 int * tmp_constituentArray = NULL;
1085 MESSAGE(LOC << "Med file version used here " << major << " " << minor << " " << release);
1087 if ((major == 2) && (minor <= 1))
1088 tmp_constituentArray = new int[(NumberOfNodeByFace+1)*tmp_numberOfFaces] ;
1089 else if ((major == 2) && (minor >= 2))
1091 tmp_constituentArray = new int[NumberOfNodeByFace*tmp_numberOfFaces] ;
1092 MESSAGE(LOC<<": WE ARE USING MED2.2 so there is no +1 for calculating the size of tmp_constituentArray !") ;
1095 int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
1096 Connectivity->_entityDimension,tmp_constituentArray,
1097 med_2_2::MED_FULL_INTERLACE,NULL,0,med_2_2::MED_MAILLE,med_type,med_2_2::MED_NOD);
1099 if ( err != MED_VALID)
1101 MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
1102 delete constituent ;
1103 delete[] tmp_constituentArray;
1104 delete[] tmpFaceCount;
1105 delete[] tmpEdgeCount;
1109 int * constituentArray = NodalValue + NodalIndex[constituent->_count[i]-1]-1 ;
1111 // version originale sans prise en compte des numéros optionnels
1113 int multi = 0; // quand est-ce que multi vaut 1 ?? en MED-fichier < 2.2 ??
1114 MESSAGE(LOC << "Med file version used here " << major << " " << minor << " " << release);
1116 if ((major == 2) && (minor <= 1))
1117 for (int j=0; j<tmp_numberOfFaces; j++)
1118 for (int k=0; k<NumberOfNodeByFace; k++)
1119 constituentArray[j*NumberOfNodeByFace+k]=tmp_constituentArray[j*(NumberOfNodeByFace+1)+k] ;
1120 else if ((major == 2) && (minor >= 2))
1121 for (int j=0; j<tmp_numberOfFaces; j++)
1122 for (int k=0; k<NumberOfNodeByFace; k++)
1123 constituentArray[j*NumberOfNodeByFace+k]=tmp_constituentArray[j*(NumberOfNodeByFace+multi)+k] ;
1125 //////////////////////////////////////////////////////////////////////////////////////
1126 /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
1127 //////////////////////////////////////////////////////////////////////////////////////
1129 /// Rénumérote le tableau temporaire tmp_constituentArray en utilisant _optionnalToCanonicNodesNumbers
1130 /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
1132 // if (_ptrMesh->_arePresentOptionnalNodesNumbers)
1134 // for (int j=0; j<tmp_numberOfFaces; j++) for (int k=0; k<NumberOfNodeByFace; k++)
1135 // constituentArray[j*NumberOfNodeByFace+k]=_ptrMesh->_optionnalToCanonicNodesNumbers[tmp_constituentArray[j*(NumberOfNodeByFace+1)+k]] ;
1139 // for (int j=0; j<tmp_numberOfFaces; j++) for (int k=0; k<NumberOfNodeByFace; k++)
1140 // constituentArray[j*NumberOfNodeByFace+k]=tmp_constituentArray[j*(NumberOfNodeByFace+1)+k] ;
1143 //////////////////////////////////////////////////////////////////////////////////////
1145 delete[] tmp_constituentArray;
1148 constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,
1152 delete[] NodalIndex ;
1153 delete[] NodalValue ;
1156 Connectivity->_constituent = constituent ;
1159 delete[] tmpFaceCount;
1164 if (numberOfEdgesTypes!=0)
1166 CONNECTIVITY * constituent = new CONNECTIVITY(numberOfEdgesTypes,MED_EDGE) ;
1167 constituent->_entityDimension = 1 ;
1168 constituent->_count[0]=1 ;
1172 // if you declare a variable <i> in two <for> initialization statement,
1173 // compiler gcc2.95.3 says nothing but there are two <i> variables in the same block
1174 //and the value you get in the common block seems to be the value of the first variable !
1177 for ( i=1; i<MED_NBR_GEOMETRIE_MAILLE; i++)
1178 { // no point1 cell type (?)
1179 if (tmpEdgeCount[i]>0)
1182 constituent->_count[typeNumber]=constituent->_count[typeNumber-1]+tmpEdgeCount[i];
1183 CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i]) ;
1184 constituent->_type[typeNumber-1]=t ;
1186 constituent->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER22::all_cell_type[i] ;
1188 size+=tmpEdgeCount[i]*((MED_MESH_DRIVER22::all_cell_type[i])%100) ;
1193 // Creation of the MEDSKYLINEARRAY
1194 //constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,size) ;
1195 //int * NodalIndex = constituent->_nodal->getIndex() ;
1196 int * NodalValue = new int[size] ;
1197 int * NodalIndex = new int[constituent->_count[constituent->_numberOfTypes]] ;
1200 // Fill the MEDSKYLINEARRAY by reading the MED file.
1201 for ( i=0; i<constituent->_numberOfTypes; i++)
1203 med_2_2::med_geometrie_element med_type = (med_2_2::med_geometrie_element) constituent->_type[i].getType() ;
1205 int NumberOfNodeByEdge = constituent->_type[i].getNumberOfNodes() ;
1208 for (int j=constituent->_count[i]; j<constituent->_count[i+1];j++)
1209 NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByEdge ;
1211 int tmp_numberOfEdges = constituent->_count[i+1]-constituent->_count[i] ;
1212 // Il faut ajouter 1 pour le zero a la lecture !!!
1214 // ATTENTION UNIQUEMENT POUR MED < 2.2.x
1215 int * tmp_constituentArray = NULL;
1217 MESSAGE(LOC << "Med file version used here " << major << " " << minor << " " << release);
1219 if ((major == 2) && (minor <= 1))
1220 tmp_constituentArray = new int[(NumberOfNodeByEdge+1)*tmp_numberOfEdges] ;
1221 else if ((major == 2) && (minor >= 2))
1223 tmp_constituentArray = new int[NumberOfNodeByEdge*tmp_numberOfEdges] ;
1224 MESSAGE(LOC<<": WE ARE USING MED2.2 so there is no +1 for calculating the size of tmp_constituentArray !") ;
1227 int err=MEDconnLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
1228 spaceDimension,tmp_constituentArray,
1229 med_2_2::MED_FULL_INTERLACE,NULL,0,med_2_2::MED_MAILLE,med_type,med_2_2::MED_NOD);
1230 if ( err != MED_VALID)
1232 MESSAGE(LOC<<": MEDconnLire returns "<<err) ;
1233 delete constituent ;
1234 delete[] tmp_constituentArray;
1235 delete[] tmpEdgeCount;
1239 int * constituentArray = NodalValue + NodalIndex[constituent->_count[i]-1]-1 ;
1241 // version originale sans prise en compte des numéros optionnels
1243 int multi = 0; // quand est-ce que multi vaut 1 ?? en MED-fichier < 2.2 ??
1244 MESSAGE(LOC << "Med file version used here " << major << " " << minor << " " << release);
1246 if ((major == 2) && (minor <= 1))
1247 for (int j=0; j<tmp_numberOfEdges; j++)
1248 for (int k=0; k<NumberOfNodeByEdge; k++)
1249 constituentArray[j*NumberOfNodeByEdge+k]=tmp_constituentArray[j*(NumberOfNodeByEdge+multi)+k] ;
1250 else if ((major == 2) && (minor >= 2))
1251 for (int j=0; j<tmp_numberOfEdges; j++)
1252 for (int k=0; k<NumberOfNodeByEdge; k++)
1253 constituentArray[j*NumberOfNodeByEdge+k]=tmp_constituentArray[j*(NumberOfNodeByEdge)+k] ;
1255 //////////////////////////////////////////////////////////////////////////////////////
1256 /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
1257 //////////////////////////////////////////////////////////////////////////////////////
1259 /// Rénumérote le tableau temporaire tmp_constituentArray en utilisant _optionnalToCanonicNodesNumbers
1260 /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
1262 // if (_ptrMesh->_arePresentOptionnalNodesNumbers)
1264 // for (int j=0; j<tmp_numberOfEdges; j++) for (int k=0; k<NumberOfNodeByEdge; k++)
1265 // constituentArray[j*NumberOfNodeByEdge+k]=_ptrMesh->_optionnalToCanonicNodesNumbers[tmp_constituentArray[j*(NumberOfNodeByEdge+1)+k]] ;
1269 // for (int j=0; j<tmp_numberOfEdges; j++) for (int k=0; k<NumberOfNodeByEdge; k++)
1270 // constituentArray[j*NumberOfNodeByEdge+k]=tmp_constituentArray[j*(NumberOfNodeByEdge+1)+k] ;
1273 //////////////////////////////////////////////////////////////////////////////////////
1275 delete[] tmp_constituentArray;
1278 constituent->_nodal = new MEDSKYLINEARRAY(constituent->_count[constituent->_numberOfTypes]-1,
1283 delete[] NodalIndex ;
1284 delete[] NodalValue ;
1286 if (Connectivity->_entityDimension == 3)
1288 if (Connectivity->_constituent==NULL)
1289 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Edges are defined but there are no Faces !"));
1290 Connectivity->_constituent->_constituent = constituent ;
1292 Connectivity->_constituent = constituent ;
1295 delete[] tmpEdgeCount;
1298 } // end classic geometric types
1299 delete[] tmp_cells_count;
1303 // Lecture des polygones MED_CELL
1304 int NumberOfPolygons = MEDnEntMaa(_medIdt,
1305 const_cast <char *> (_ptrMesh->_name.c_str()),
1308 med_2_2::MED_POLYGONE,
1310 if (NumberOfPolygons > 0)
1312 if (Connectivity->_entityDimension == 1)
1313 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"In a 2D mesh, polygons need at least one 2D cell of a classic geometric type !"));
1314 med_int ConnectivitySize;
1315 med_err err1 = MEDpolygoneInfo(_medIdt,
1316 const_cast <char *> (_ptrMesh->_name.c_str()),
1320 if (err1 != MED_VALID)
1322 MESSAGE(LOC<<": MEDpolygoneInfo returns "<<err1);
1326 med_int* PolygonsConnectivity = new med_int[ConnectivitySize];
1327 med_int* PolygonsConnectivityIndex = new med_int[NumberOfPolygons+1];
1329 med_err err2 = MEDpolygoneConnLire(_medIdt,
1330 const_cast <char *> (_ptrMesh->_name.c_str()),
1331 PolygonsConnectivityIndex,
1333 PolygonsConnectivity,
1336 if (err2 != MED_VALID)
1338 MESSAGE(LOC<<": MEDpolygoneConnLire returns "<<err2);
1342 if (Connectivity->_entityDimension == 2) // 2D mesh : polygons in Connectivity
1343 Connectivity->setPolygonsConnectivity(MED_NODAL,(medEntityMesh) Entity,PolygonsConnectivity,PolygonsConnectivityIndex,ConnectivitySize,NumberOfPolygons);
1344 else if (Connectivity->_entityDimension == 3)
1346 if (Connectivity->_constituent == NULL) // 3D mesh : polygons in Connectivity->_constituent
1347 Connectivity->_constituent = new CONNECTIVITY(MED_FACE);
1348 Connectivity->_constituent->setPolygonsConnectivity(MED_NODAL,MED_FACE,PolygonsConnectivity,PolygonsConnectivityIndex,ConnectivitySize,NumberOfPolygons);
1351 delete[] PolygonsConnectivity;
1352 delete[] PolygonsConnectivityIndex;
1357 // Lecture des polyedres MED_CELL
1358 med_int NumberOfPolyhedron = MEDnEntMaa(_medIdt,
1359 const_cast <char *> (_ptrMesh->_name.c_str()),
1362 med_2_2::MED_POLYEDRE,
1364 if (NumberOfPolyhedron > 0)
1366 if (Connectivity->_entityDimension == 2 || Connectivity->_entityDimension == 1)
1367 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"In a 3D mesh, polyhedron need at least one 3D cell of a classic geometric type !"));
1368 med_int FacesIndexSize, NumberOfNodes, NumberOfFaces;
1369 med_err err3 = MEDpolyedreInfo(_medIdt,
1370 const_cast <char *> (_ptrMesh->_name.c_str()),
1374 NumberOfFaces = FacesIndexSize-1;
1375 if (err3 != MED_VALID)
1377 MESSAGE(LOC<<": MEDpolyhedreInfo returns "<<err3);
1381 med_int* Nodes = new med_int[NumberOfNodes];
1382 med_int* FacesIndex = new med_int[NumberOfFaces+1];
1383 med_int* PolyhedronIndex = new med_int[NumberOfPolyhedron+1];
1385 med_err err4 = MEDpolyedreConnLire(_medIdt,
1386 const_cast <char *> (_ptrMesh->_name.c_str()),
1388 NumberOfPolyhedron+1,
1393 if (err4 != MED_VALID)
1395 MESSAGE(LOC<<": MEDpolyedreConnLire returns "<<err4);
1399 Connectivity->setPolyhedronConnectivity(MED_NODAL,Nodes,PolyhedronIndex,NumberOfNodes,NumberOfPolyhedron,FacesIndex,NumberOfFaces);
1402 delete[] FacesIndex;
1403 delete[] PolyhedronIndex;
1408 // If there is no nodal connectivity, we return MED_ERROR !
1409 if (Connectivity->_numberOfTypes == 0 && NumberOfPolygons == 0 && NumberOfPolyhedron == 0)
1418 int MED_MESH_RDONLY_DRIVER22::getFAMILY()
1420 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getFAMILY() : " ;
1423 if (_status==MED_OPENED)
1427 int * MEDArrayNodeFamily = NULL ;
1428 int ** MEDArrayCellFamily = NULL ;
1429 int ** MEDArrayFaceFamily = NULL ;
1430 int ** MEDArrayEdgeFamily = NULL ;
1433 MEDArrayNodeFamily = new int[_ptrMesh->getNumberOfNodes()] ;
1435 err = getNodesFamiliesNumber(MEDArrayNodeFamily) ;
1436 // error only if (_status!=MED_OPENED), other case exeception !
1439 MESSAGE(LOC << "error returned from getNodesFamiliesNumber " << err);
1441 MEDArrayCellFamily = new int* [_ptrMesh->getNumberOfTypesWithPoly(MED_CELL)] ;
1442 // ET SI IL N'Y A PAS DE CELLS ?
1444 medGeometryElement * myTypes = _ptrMesh->getTypesWithPoly(MED_CELL);
1445 for (int i=0;i<_ptrMesh->getNumberOfTypesWithPoly(MED_CELL);i++)
1446 MEDArrayCellFamily[i] = new
1447 int[_ptrMesh->getNumberOfElementsWithPoly(MED_CELL,myTypes[i])] ;
1449 err = getCellsFamiliesNumber(MEDArrayCellFamily,
1450 _ptrMesh->_connectivity,MED_CELL) ;
1453 MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Cells " << err);
1455 if (_ptrMesh->_connectivity->_constituent != NULL)
1457 if (_ptrMesh->_connectivity->_constituent->_entity == MED_EN::MED_FACE)
1460 MEDArrayFaceFamily = new
1461 int* [_ptrMesh->getNumberOfTypesWithPoly(MED_FACE)] ;
1463 myTypes = _ptrMesh->getTypesWithPoly(MED_FACE);
1464 for (int i=0;i<_ptrMesh->getNumberOfTypesWithPoly(MED_FACE);i++)
1465 MEDArrayFaceFamily[i] = new
1466 int[_ptrMesh->getNumberOfElementsWithPoly(MED_FACE,myTypes[i])] ;
1469 getCellsFamiliesNumber(MEDArrayFaceFamily,
1470 _ptrMesh->_connectivity->_constituent,MED_FACE) ;
1472 MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Faces " << err);
1477 MEDArrayEdgeFamily = new
1478 int* [_ptrMesh->getNumberOfTypes(MED_EDGE)] ;
1480 const medGeometryElement *myTypes2 = _ptrMesh->getTypes(MED_EDGE);
1481 for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
1482 MEDArrayEdgeFamily[i] = new
1483 int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes2[i])] ;
1486 getCellsFamiliesNumber(MEDArrayEdgeFamily,
1487 _ptrMesh->_connectivity->_constituent,MED_FACE) ;
1489 MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Edges in 2D " << err);
1492 if (_ptrMesh->_connectivity->_constituent->_constituent != NULL)
1494 MEDArrayEdgeFamily = new
1495 int* [_ptrMesh->getNumberOfTypes(MED_EDGE)] ;
1497 const medGeometryElement *myTypes2 = _ptrMesh->getTypes(MED_EDGE);
1498 for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
1499 MEDArrayEdgeFamily[i] = new
1500 int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes2[i])] ;
1503 getCellsFamiliesNumber(MEDArrayEdgeFamily,
1504 _ptrMesh->_connectivity->_constituent->_constituent,MED_EDGE);
1507 MESSAGE(LOC << "error returned from getCellsFamiliesNumber for Edges in 3D " << err);
1512 int NumberOfFamilies = med_2_2::MEDnFam(_medIdt, const_cast <char *>
1513 (_meshName.c_str())) ;
1515 if ( NumberOfFamilies < 1 ) // at least family 0 must exist
1516 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"There is no FAMILY, FAMILY 0 must exists" ));
1518 SCRUTE(NumberOfFamilies);
1520 vector<FAMILY*> &NodeFamilyVector = _ptrMesh->_familyNode ;
1521 vector<FAMILY*> &CellFamilyVector = _ptrMesh->_familyCell ;
1522 vector<FAMILY*> &FaceFamilyVector = _ptrMesh->_familyFace ;
1523 vector<FAMILY*> &EdgeFamilyVector = _ptrMesh->_familyEdge ;
1525 int numberOfNodesFamilies = 0 ;
1526 int numberOfCellsFamilies = 0 ;
1527 int numberOfFacesFamilies = 0 ;
1528 int numberOfEdgesFamilies = 0 ;
1530 for (int i=0;i<NumberOfFamilies;i++)
1532 int NumberOfAttributes = med_2_2::MEDnAttribut(_medIdt,
1534 (_meshName.c_str()),
1537 if (NumberOfAttributes < 0)
1538 throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER22::getFAMILY() : NumberOfAttributes" );
1540 int NumberOfGroups = med_2_2::MEDnGroupe(_medIdt, const_cast <char *>
1541 (_meshName.c_str()),(i+1)) ;
1543 if (NumberOfGroups < 0)
1544 throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER22::getFAMILY() : NumberOfGroups" );
1546 int FamilyIdentifier ;
1547 string FamilyName(MED_TAILLE_NOM,'\0');
1548 int * AttributesIdentifier = new int[NumberOfAttributes] ;
1549 int * AttributesValues = new int[NumberOfAttributes] ;
1550 string AttributesDescription(MED_TAILLE_DESC*NumberOfAttributes,' ') ;
1551 string GroupsNames(MED_TAILLE_LNOM*NumberOfGroups+1,'\0') ;
1552 err = med_2_2::MEDfamInfo(_medIdt,const_cast <char *>
1553 (_meshName.c_str()),
1554 (i+1),const_cast <char *>
1555 (FamilyName.c_str()), &FamilyIdentifier,
1556 AttributesIdentifier,AttributesValues,
1558 (AttributesDescription.c_str()),
1559 &NumberOfAttributes, const_cast <char *>
1560 (GroupsNames.c_str()),&NumberOfGroups);
1563 SCRUTE(GroupsNames);
1568 if (err != MED_VALID)
1569 throw MEDEXCEPTION("MED_MESH_RDONLY_DRIVER22::getFAMILY() : ERROR when get FAMILY informations" );
1571 if (FamilyIdentifier != 0 )
1573 FAMILY * Family = new FAMILY(_ptrMesh,FamilyIdentifier,FamilyName,
1575 AttributesIdentifier,
1577 AttributesDescription,
1578 NumberOfGroups,GroupsNames,
1582 MEDArrayEdgeFamily) ;
1585 // if nothing found, delete Family
1587 if (Family->getNumberOfTypes() == 0)
1589 MESSAGE(LOC<<"Nothing found for family "<<FamilyName<<
1594 switch (Family->getEntity())
1596 case MED_EN::MED_NODE :
1597 NodeFamilyVector.push_back(Family) ;
1598 numberOfNodesFamilies++ ;
1600 case MED_EN::MED_CELL :
1601 CellFamilyVector.push_back(Family) ;
1602 numberOfCellsFamilies++ ;
1604 case MED_EN::MED_FACE :
1605 FaceFamilyVector.push_back(Family) ;
1606 numberOfFacesFamilies++ ;
1608 case MED_EN::MED_EDGE :
1609 EdgeFamilyVector.push_back(Family) ;
1610 numberOfEdgesFamilies++ ;
1613 // MESSAGE(LOC << (*Family));
1616 delete [] AttributesIdentifier ;
1617 delete [] AttributesValues ;
1620 if (MEDArrayNodeFamily != NULL)
1621 delete[] MEDArrayNodeFamily ;
1623 if (MEDArrayCellFamily != NULL)
1625 for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_CELL);i++)
1626 delete[] MEDArrayCellFamily[i] ;
1627 delete[] MEDArrayCellFamily ;
1630 if (MEDArrayFaceFamily != NULL)
1632 for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_FACE);i++)
1633 delete[] MEDArrayFaceFamily[i] ;
1634 delete[] MEDArrayFaceFamily ;
1637 if (MEDArrayEdgeFamily != NULL)
1639 for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++)
1640 delete[] MEDArrayEdgeFamily[i] ;
1641 delete[] MEDArrayEdgeFamily ;
1651 int MED_MESH_RDONLY_DRIVER22::getNodesFamiliesNumber(int * MEDArrayNodeFamily)
1653 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getNodesFamiliesNumber() : " ;
1657 if (_status==MED_OPENED)
1661 err = MEDfamLire(_medIdt, const_cast <char *>
1662 (_ptrMesh->_name.c_str()), MEDArrayNodeFamily,
1663 _ptrMesh->getNumberOfNodes(), med_2_2::MED_NOEUD,
1664 (med_2_2::med_geometrie_element) MED_NONE);
1666 if ( err != MED_VALID)
1667 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "There is no family for the |"<< _ptrMesh->getNumberOfNodes() << "| nodes in mesh |" << _ptrMesh->_name.c_str() << "|"));
1676 int MED_MESH_RDONLY_DRIVER22::getCellsFamiliesNumber(int **MEDArrayFamily,
1677 CONNECTIVITY *Connectivity,
1678 MED_EN::medEntityMesh entity)
1680 const char * LOC = "MED_MESH_RDONLY_DRIVER22::getCellsFamiliesNumber " ;
1684 if (_status==MED_OPENED)
1687 MED_EN::medGeometryElement *types=Connectivity->getGeometricTypesWithPoly(Connectivity->_entity);
1688 for (i=0;i<Connectivity->getNumberOfTypesWithPoly(Connectivity->_entity);i++)
1690 int NumberOfCell=Connectivity->getNumberOfElementsWithPoly(Connectivity->_entity,types[i]);
1691 err=MEDfamLire(_medIdt,const_cast <char *> (_ptrMesh->_name.c_str()),
1692 MEDArrayFamily[i],NumberOfCell,
1693 (med_2_2::med_entite_maillage) Connectivity->_entity,
1694 (med_2_2::med_geometrie_element)types[i]);
1695 if (err != MED_VALID)
1697 err=MEDfamLire(_medIdt,const_cast <char *>
1698 (_ptrMesh->_name.c_str()),
1699 MEDArrayFamily[i],NumberOfCell,
1700 med_2_2::MED_MAILLE,
1701 (med_2_2::med_geometrie_element)types[i]);
1702 if (err != MED_VALID)
1703 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Family not found for entity "<<Connectivity->_entity<<" and geometric type "<<Connectivity->_geometricTypes[i]));
1712 /*--------------------- WRONLY PART -------------------------------*/
1714 MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22()
1718 MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const string & fileName,
1720 MED_MESH_DRIVER22(fileName,ptrMesh,MED_WRONLY),IMED_MESH_WRONLY_DRIVER(fileName,ptrMesh),MED_MESH_DRIVER(fileName,ptrMesh,MED_WRONLY)
1722 MESSAGE("MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const string & fileName, MESH * ptrMesh) has been created");
1725 MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const MED_MESH_WRONLY_DRIVER22 & driver):
1726 IMED_MESH_WRONLY_DRIVER(driver),MED_MESH_DRIVER22(driver),MED_MESH_DRIVER(driver)
1730 MED_MESH_WRONLY_DRIVER22::~MED_MESH_WRONLY_DRIVER22()
1732 //MESSAGE("MED_MESH_WRONLY_DRIVER22::MED_MESH_WRONLY_DRIVER22(const string & fileName, MESH * ptrMesh) has been destroyed");
1735 GENDRIVER * MED_MESH_WRONLY_DRIVER22::copy(void) const
1737 return new MED_MESH_WRONLY_DRIVER22(*this);
1740 void MED_MESH_WRONLY_DRIVER22::write(void) const
1742 const char * LOC = "void MED_MESH_WRONLY_DRIVER22::write(void) const : ";
1745 // we must first create mesh !!
1746 MESSAGE(LOC << "MeshName : |" << _meshName << "| FileName : |"<<_fileName<<"| MedIdt : | "<< _medIdt << "|");
1748 if (_status!=MED_OPENED)
1749 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "File "<<_fileName<<" is not open. Open it before write !"));
1751 if (_ptrMesh->getIsAGrid())
1753 if ( writeGRID() != MED_VALID )
1754 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeGRID()" )) ;
1758 if (writeCoordinates()!=MED_VALID)
1759 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeCoordinates()" )) ;
1761 if (writeConnectivities(MED_EN::MED_CELL)!=MED_VALID)
1762 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_CELL)" )) ;
1763 if (writeConnectivities(MED_EN::MED_FACE)!=MED_VALID)
1764 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_FACE)" )) ;
1765 if (writeConnectivities(MED_EN::MED_EDGE)!=MED_VALID)
1766 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeConnectivities(MED_EDGE)" )) ;
1769 if (writeFamilyNumbers() !=MED_VALID)
1770 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilyNumbers()" )) ;
1773 // well we must first write zero family :
1774 if (_status==MED_OPENED) {
1776 // test if the family already exists (HDF trick waiting a MED evolution to be replaced)
1777 string dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/FAMILLE_ZERO/";
1778 MESSAGE("|"<<dataGroupFam<<"|");
1779 err =med_2_2::_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) );
1780 if ( err < MED_VALID ) {
1783 char familyName[MED_TAILLE_NOM+1];
1784 // strcpy(familyName,"FAMILLE_ZERO");
1785 err = med_2_2::MEDfamCr( _medIdt,
1786 const_cast <char *> ( _meshName.c_str() ),
1788 (int*)NULL, (int*)NULL, (char*)NULL, 0,
1793 if ( err != MED_VALID)
1794 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |FAMILLE_ZERO| with identifier |0| groups names || and attributes descriptions ||")) ;
1797 med_2_2::_MEDdatagroupFermer(_medIdt);
1801 MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyNode)");
1802 if (writeFamilies(_ptrMesh->_familyNode) !=MED_VALID)
1803 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyNode)" )) ;
1805 MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyCell)");
1806 if (writeFamilies(_ptrMesh->_familyCell) !=MED_VALID)
1807 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyCell)" )) ;
1809 MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyFace)");
1810 if (writeFamilies(_ptrMesh->_familyFace) !=MED_VALID)
1811 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyFace)" )) ;
1813 MESSAGE(LOC<<"writeFamilies(_ptrMesh->_familyEdge)");
1814 if (writeFamilies(_ptrMesh->_familyEdge) !=MED_VALID)
1815 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "ERROR in writeFamilies(_ptrMesh->_familyEdge)" )) ;
1820 //=======================================================================
1821 //function : writeGRID
1823 //=======================================================================
1825 int MED_MESH_WRONLY_DRIVER22::writeGRID() const
1827 const char * LOC = "MED_MESH_WRONLY_DRIVER22::writeGRID() : " ;
1830 if (_status!=MED_OPENED)
1832 MESSAGE (LOC<<" Not open !!!");
1835 GRID * ptrGrid = (GRID*) _ptrMesh;
1837 med_2_2::med_err err = MED_ERROR;
1838 med_2_2::med_repere rep;
1839 string tmp_name(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
1840 string tmp_unit(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
1842 // Test if the mesh <_meshName> already exists
1843 // If it doesn't exists create it
1844 // If it already exists verify if its space and mesh dimensions are the same
1845 // as <_ptrMesh->_spaceDimension>, <_ptrMesh->_meshDimension> respectively
1846 // rem : <_meshName> is the driver meshName not <ptrMesh->_meshName>
1848 int spaceDimension = med_2_2::MEDdimEspaceLire(_medIdt, const_cast <char *>
1849 (_meshName.c_str()) );
1851 int meshDimension = med_2_2::MEDdimLire(_medIdt, const_cast <char *>
1852 (_meshName.c_str()) );
1855 MESSAGE(LOC << "spacedim " << spaceDimension << " meshdim " << meshDimension);
1857 MESSAGE(LOC << "From the mesh spacedim " << _ptrMesh->_spaceDimension << " meshdim " << _ptrMesh->_meshDimension);
1859 if ((spaceDimension <= MED_VALID) && (meshDimension <= MED_VALID))
1861 err = MEDmaaCr(_medIdt,
1862 const_cast <char *> (_meshName.c_str()),
1863 _ptrMesh->_meshDimension,med_2_2::MED_STRUCTURE,
1864 const_cast <char *> (_ptrMesh->_description.c_str()));
1866 meshDimension = _ptrMesh->_meshDimension;
1868 if (err != MED_VALID)
1869 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Grid"));
1871 MESSAGE(LOC<<"Grid "<<_meshName<<" created in file "<<_fileName<<" !");
1873 else if ((spaceDimension != _ptrMesh->_spaceDimension) &&
1874 (meshDimension != _ptrMesh->_meshDimension))
1875 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Grid |" << _meshName.c_str() <<
1876 "| already exists in file |" << _fileName <<
1877 "| with space dimension |" << spaceDimension <<
1878 "| and mesh dimension |" << meshDimension <<
1879 "| but the space dimension and the mesh dimension of the mesh we want to write are respectively |"
1880 << _ptrMesh->_spaceDimension <<"|" <<
1881 _ptrMesh->_meshDimension <<"|" )) ;
1883 MED_EN::med_grid_type gridType = ptrGrid->getGridType();
1885 err = med_2_2::MEDnatureGrilleEcr(_medIdt,
1886 const_cast <char *> (_meshName.c_str()),
1887 (med_2_2::med_type_grille) gridType);
1889 if (err != MED_VALID)
1890 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to write the type of the Grid"));
1892 // Recompose the <_spaceDimension> strings in 1 string
1894 string valueString ;
1895 for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
1897 valueString = _ptrMesh->_coordinate->_coordinateName[i] ;
1898 lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
1899 tmp_name.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
1900 valueString = _ptrMesh->_coordinate->_coordinateUnit[i];
1901 lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
1902 tmp_unit.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
1905 // Pourquoi le stocker sous forme de chaîne ?
1906 const string & coordinateSystem = _ptrMesh->_coordinate->_coordinateSystem;
1907 if (coordinateSystem == "CARTESIAN")
1908 rep = med_2_2::MED_CART;
1909 else if ( coordinateSystem == "CYLINDRICAL")
1910 rep = med_2_2::MED_CYL;
1911 else if ( coordinateSystem == "SPHERICAL" )
1912 rep = med_2_2::MED_SPHER;
1914 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Grid |" << _meshName.c_str() <<
1915 "| doesn't have a valid coordinate system : |"
1916 << _ptrMesh->_coordinate->_coordinateSystem
1919 med_2_2::med_int ArrayLen[] = { (med_2_2::med_int) ptrGrid->_iArrayLength,
1920 (med_2_2::med_int) ptrGrid->_jArrayLength,
1921 (med_2_2::med_int) ptrGrid->_kArrayLength };
1923 // Write node coordinates for MED_BODY_FITTED grid
1924 if (gridType == MED_EN::MED_BODY_FITTED)
1926 // Write Coordinates and families
1927 // double * coo = const_cast <double *>
1928 // (_ptrMesh->_coordinate->getCoordinates(MED_EN::MED_FULL_INTERLACE));
1930 err = MEDcoordEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
1931 _ptrMesh->_spaceDimension,
1932 //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
1933 const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
1934 med_2_2::MED_FULL_INTERLACE, _ptrMesh->_numberOfNodes,
1935 // _ptrMesh->_coordinate->_numberOfNodes
1936 rep, const_cast <char *> (tmp_name.c_str()),
1937 const_cast <char *> (tmp_unit.c_str()));
1939 if (err != MED_VALID)
1940 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write coordinates of the grid |" << _meshName.c_str() << "| in file |" << _fileName
1941 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
1942 << " with units names |" << tmp_name
1943 << "| and units |" << tmp_unit
1946 int* structure = new int [meshDimension];
1948 for (int idim = 0; idim < meshDimension; ++idim)
1949 structure[idim] = ArrayLen [idim];
1952 err = med_2_2::MEDstructureCoordEcr(_medIdt, const_cast <char *>
1953 (_meshName.c_str()), meshDimension,
1956 if (err != MED_VALID)
1957 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"error in writing the structure of the grid |" << _meshName.c_str()));
1961 else if ((gridType == MED_EN::MED_CARTESIAN) ||
1962 (gridType == MED_EN::MED_POLAR))
1964 // Write Arrays of Cartesian or Polar Grid
1966 double * Array[] = { ptrGrid->_iArray,
1970 for (int idim = 0; idim < _ptrMesh->_meshDimension; ++idim)
1972 string str_name = string (tmp_name,idim*MED_TAILLE_PNOM22,
1974 string str_unit = string (tmp_unit,idim*MED_TAILLE_PNOM22,
1977 err = med_2_2::MEDindicesCoordEcr(_medIdt, const_cast <char *>
1978 (_ptrMesh->_name.c_str()),
1979 _ptrMesh->_meshDimension,
1980 Array[idim], ArrayLen[idim],
1981 (idim+1), const_cast <char *>
1984 (str_unit.c_str()));
1986 if (err != MED_VALID)
1987 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<
1988 "Can't write grid coordinates for " <<
1989 idim << "-th dimention"));
1991 } // end Write Cartesian or Polar Grid
1997 //=======================================================================
1998 //function : writeCoordinates
2000 //=======================================================================
2002 int MED_MESH_WRONLY_DRIVER22::writeCoordinates() const {
2004 const char * LOC = "int MED_MESH_WRONLY_DRIVER22::writeCoordinates() const : ";
2007 med_2_2::med_err err = MED_ERROR;
2008 med_2_2::med_repere rep;
2009 string tmp_name(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
2010 string tmp_unit(_ptrMesh->_spaceDimension*MED_TAILLE_PNOM22,' ');
2012 // Recompose the <_spaceDimension> strings in 1 string
2014 string valueString ;
2015 for (int i=0;i<_ptrMesh->_spaceDimension;i++) {
2016 valueString = _ptrMesh->_coordinate->_coordinateName[i] ;
2017 lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
2018 tmp_name.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
2019 valueString = _ptrMesh->_coordinate->_coordinateUnit[i];
2020 lengthString = (MED_TAILLE_PNOM22<valueString.size())?MED_TAILLE_PNOM22:valueString.size() ;
2021 tmp_unit.replace(i*MED_TAILLE_PNOM22,i*MED_TAILLE_PNOM22+lengthString,valueString,0,lengthString);
2024 // Test if the mesh <_meshName> already exists
2025 // If it doesn't exists create it
2026 // If it already exists verify if its space and mesh dimensions are the same
2027 // as <_ptrMesh->_spaceDimension>, <_ptrMesh->_meshDimension> respectively
2028 // rem : <_meshName> is the driver meshName not <ptrMesh->_meshName>
2030 int spaceDimension = med_2_2::MEDdimEspaceLire(_medIdt, const_cast <char *>
2031 (_meshName.c_str()));
2033 int meshDimension = med_2_2::MEDdimLire(_medIdt, const_cast <char *>
2034 (_meshName.c_str()) );
2036 if ((spaceDimension != MED_VALID) && (meshDimension != MED_VALID))
2038 err = MEDmaaCr(_medIdt, const_cast <char *> (_meshName.c_str()),
2039 _ptrMesh->_meshDimension, med_2_2::MED_NON_STRUCTURE,
2040 const_cast <char *> (_ptrMesh->_description.c_str()));
2042 if (err != MED_VALID)
2043 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Mesh : |" << _meshName << "|"));
2045 MESSAGE(LOC<<"Mesh "<<_meshName<<" created in file "<<_fileName<<" !");
2047 else if ((spaceDimension != _ptrMesh->_spaceDimension) &&
2048 (meshDimension != _ptrMesh->_meshDimension))
2049 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() <<
2050 "| already exists in file |" << _fileName <<
2051 "| with space dimension |" << spaceDimension <<
2052 "| and mesh dimension |" << meshDimension <<
2053 "| but the space dimension and the mesh dimension of the mesh we want to write are respectively |"
2054 << _ptrMesh->_spaceDimension <<"|" <<
2055 _ptrMesh->_meshDimension << "|")) ;
2057 // Pourquoi le stocker sous forme de chaîne ?
2058 const string & coordinateSystem = _ptrMesh->_coordinate->_coordinateSystem;
2059 if (coordinateSystem == "CARTESIAN")
2060 rep = med_2_2::MED_CART;
2061 else if ( coordinateSystem == "CYLINDRICAL")
2062 rep = med_2_2::MED_CYL;
2063 else if ( coordinateSystem == "SPHERICAL" )
2064 rep = med_2_2::MED_SPHER;
2066 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Mesh |" << _meshName.c_str() << "| doesn't have a valid coordinate system : |"
2067 << _ptrMesh->_coordinate->_coordinateSystem
2070 // err = MEDcoordEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
2071 // _ptrMesh->_spaceDimension,
2072 // //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
2073 // const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
2074 // MED_FR::MED_FULL_INTERLACE,
2075 // _ptrMesh->_numberOfNodes, // _ptrMesh->_coordinate->_numberOfNodes
2076 // MED_FR::MED_LECTURE_ECRITURE,
2078 // const_cast <char *> (tmp_name.c_str()),
2079 // const_cast <char *> (tmp_unit.c_str())
2082 err = MEDcoordEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
2083 _ptrMesh->_spaceDimension,
2084 //const_cast <double *> ( _ptrMesh->_coordinate->_coordinate->get(MED_EN::MED_FULL_INTERLACE) ),
2085 const_cast <double *> ( _ptrMesh->_coordinate->_coordinate.get(MED_EN::MED_FULL_INTERLACE) ),
2086 med_2_2::MED_FULL_INTERLACE, _ptrMesh->_numberOfNodes,
2087 // _ptrMesh->_coordinate->_numberOfNodes
2088 rep, const_cast <char *> (tmp_name.c_str()),
2089 const_cast <char *> (tmp_unit.c_str()));
2092 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write coordinates of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2093 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2094 << " with units names |" << tmp_name
2095 << "| and units |" << tmp_unit
2099 //////////////////////////////////////////////////////////////////////////////////////
2100 /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
2101 //////////////////////////////////////////////////////////////////////////////////////
2103 /// Ecrit les numéros optionnels des noeuds
2104 /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
2107 if (_ptrMesh->_arePresentOptionnalNodesNumbers==1) {
2109 err = MEDnumEcr(_medIdt, const_cast <char *> (_meshName.c_str()),
2110 const_cast <med_int *> (_ptrMesh->_coordinate->getNodesNumbers() ),
2111 _ptrMesh->_numberOfNodes, med_2_2::MED_NOEUD,
2112 med_2_2::med_geometrie_element(0) );
2114 if (err != MED_VALID)
2115 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write optionnal numbers of mesh |" <<
2116 _meshName.c_str() << "| in file |" <<
2117 _fileName << " |")) ;
2119 //////////////////////////////////////////////////////////////////////////////////////
2129 int MED_MESH_WRONLY_DRIVER22::writeConnectivities(medEntityMesh entity) const
2131 const char * LOC="int MED_MESH_WRONLY_DRIVER22::writeConnectivities() const : ";
2134 med_2_2::med_err err;
2136 // REM SI LA METHODE EST APPELEE DIRECTEMENT ET QUE LE MAILLAGE N'EST PAS CREE IL Y A PB !
2137 // PG : IMPOSSIBLE : LA METHODE EST PRIVEE !
2139 // A FAIRE : A tester surtout dans les methodes de MESH.
2140 // if ( _ptrMesh->_connectivity == (CONNECTIVITY *) MED_INVALID )
2141 if ( _ptrMesh->_connectivity == (CONNECTIVITY *) NULL )
2142 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The connectivity is not defined in the MESH object ")) ;
2145 // Nodal connectivity for classic geometric types
2146 if ( _ptrMesh->existConnectivity(MED_NODAL,entity) )
2149 int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
2150 const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
2152 for (int i=0; i<numberOfTypes; i++)
2155 int numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]);
2156 const int * connectivity = _ptrMesh->getConnectivity (MED_EN::MED_FULL_INTERLACE,
2157 MED_NODAL, entity, types[i]); // ?? et SI MED_NODAL n'existe pas, recalcul auto ??
2159 // Pour l'instant la class utilise le multi.....
2161 // if (entity==MED_EN::MED_CELL)
2162 // if ( (types[i]/ 100) < _ptrMesh->_spaceDimension)
2164 int numberOfNodes = types[i]%100 ;
2165 int * connectivityArray = new int[numberOfElements*(numberOfNodes+multi)];
2167 // version originale sans prise en compte des numéros optionnels
2169 for (int j=0 ; j<numberOfElements; j++)
2171 for (int k=0; k<numberOfNodes; k++)
2172 connectivityArray[j*(numberOfNodes+multi)+k]=connectivity[j*numberOfNodes+k] ;
2174 if (multi>0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
2177 //////////////////////////////////////////////////////////////////////////////////////
2178 /// Modification pour prise en compte de la numérotation optionnelle des noeuds ///
2179 //////////////////////////////////////////////////////////////////////////////////////
2181 /// Dénumérote les sommets des mailles pour leur rendre leurs numéros optionnels
2182 /// Le traitement est identique à la version originelle s'il n'y a pas de numérotation optionnelle
2184 // if (_ptrMesh->_arePresentOptionnalNodesNumbers==1)
2186 // const int * nodesNumbers = _ptrMesh->_coordinate->getNodesNumbers();
2187 // for (int j=0 ; j<numberOfElements; j++)
2189 // for (int k=0; k<numberOfNodes; k++) connectivityArray[j*(numberOfNodes+multi)+k]=nodesNumbers[connectivity[j*numberOfNodes+k]-1] ;
2190 // if (multi>0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
2195 // for (int j=0 ; j<numberOfElements; j++)
2197 // for (int k=0; k<numberOfNodes; k++) connectivityArray[j*(numberOfNodes+multi)+k]=connectivity[j*numberOfNodes+k] ;
2198 // if (multi>0) connectivityArray[j*(numberOfNodes+multi)+numberOfNodes]=0;
2202 //////////////////////////////////////////////////////////////////////////////////////
2204 // err = MEDconnEcr( _medIdt, const_cast <char *> ( _meshName.c_str()), _ptrMesh->_spaceDimension,
2205 // connectivityArray, MED_FR::MED_FULL_INTERLACE , numberOfElements,
2206 // MED_FR::MED_LECTURE_ECRITURE,
2207 // (MED_FR::med_entite_maillage ) entity,
2208 // (MED_FR::med_geometrie_element) types[i], MED_FR::MED_NOD );
2210 // err = MEDconnEcr(_medIdt, const_cast <char *> ( _meshName.c_str()),
2211 // _ptrMesh->_spaceDimension, connectivityArray,
2212 // MED_FR::MED_FULL_INTERLACE , numberOfElements,
2213 // (MED_FR::med_entite_maillage ) entity,
2214 // (MED_FR::med_geometrie_element) types[i],
2215 // med_2_2::MED_NOD);
2217 err = MEDconnEcr(_medIdt, const_cast <char *> ( _meshName.c_str()),
2218 _ptrMesh->_spaceDimension, connectivityArray,
2219 med_2_2::MED_FULL_INTERLACE , numberOfElements,
2220 (med_2_2::med_entite_maillage ) MED_CELL,
2221 (med_2_2::med_geometrie_element) types[i],
2224 delete[] connectivityArray ;
2226 if (err<0) // ETENDRE LES EXPLICATIONS
2227 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2228 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2236 if (_ptrMesh->existPolygonsConnectivity(MED_NODAL,entity))
2238 err = MEDpolygoneConnEcr(_medIdt,
2239 const_cast <char *> (_meshName.c_str()),
2240 const_cast <med_int*> (_ptrMesh->getPolygonsConnectivityIndex(MED_NODAL,entity)),
2241 _ptrMesh->getNumberOfPolygons()+1,
2242 const_cast <med_int*> (_ptrMesh->getPolygonsConnectivity(MED_NODAL,entity)),
2243 (med_2_2::med_entite_maillage) entity,
2247 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polygons nodal connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2248 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2253 // Polyhedron writing
2254 if (_ptrMesh->existPolyhedronConnectivity(MED_NODAL,entity))
2256 err = MEDpolyedreConnEcr(_medIdt,
2257 const_cast <char *> (_meshName.c_str()),
2258 const_cast <med_int*> (_ptrMesh->getPolyhedronIndex(MED_NODAL)),
2259 _ptrMesh->getNumberOfPolyhedron()+1,
2260 const_cast <med_int*> (_ptrMesh->getPolyhedronFacesIndex()),
2261 _ptrMesh->getNumberOfPolyhedronFaces()+1,
2262 const_cast <med_int*> (_ptrMesh->getPolyhedronConnectivity(MED_NODAL)),
2266 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polyhedron nodal connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2267 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2272 // Descending connectivity for classic geometric types
2273 if ( _ptrMesh->existConnectivity(MED_DESCENDING,entity) )
2276 int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
2277 const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
2279 for (int i=0; i<numberOfTypes; i++)
2282 int numberOfElements = _ptrMesh->getNumberOfElements (entity,types[i]);
2283 const int * connectivity = _ptrMesh->getConnectivity(MED_EN::MED_FULL_INTERLACE, MED_DESCENDING, entity, types[i]);
2285 // Pour l'instant la class utilise le multi.....
2286 // err = MED_FR::MEDconnEcr( _medIdt,
2287 // const_cast <char *> ( _meshName.c_str()),
2288 // _ptrMesh->_spaceDimension,
2289 // const_cast <int *> (connectivity),
2290 // MED_FR::MED_FULL_INTERLACE,
2291 // numberOfElements,
2292 // MED_FR::MED_LECTURE_ECRITURE,
2293 // (MED_FR::med_entite_maillage ) entity,
2294 // (MED_FR::med_geometrie_element) types[i],
2295 // MED_FR::MED_DESC );
2297 err = med_2_2::MEDconnEcr(_medIdt,
2298 const_cast <char *> ( _meshName.c_str()),
2299 _ptrMesh->_spaceDimension,
2300 const_cast <int *> (connectivity),
2301 med_2_2::MED_FULL_INTERLACE,
2303 (med_2_2::med_entite_maillage ) entity,
2304 (med_2_2::med_geometrie_element) types[i],
2305 med_2_2::MED_DESC );
2307 if (err<0) // ETENDRE LES EXPLICATIONS
2308 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2309 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2317 if (_ptrMesh->existPolygonsConnectivity(MED_DESCENDING,entity))
2319 err = MEDpolygoneConnEcr(_medIdt,
2320 const_cast <char *> (_meshName.c_str()),
2321 const_cast <med_int*> (_ptrMesh->getPolygonsConnectivityIndex(MED_DESCENDING,entity)),
2322 _ptrMesh->getNumberOfPolygons()+1,
2323 const_cast <med_int*> (_ptrMesh->getPolygonsConnectivity(MED_DESCENDING,entity)),
2324 (med_2_2::med_entite_maillage) entity,
2328 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polygons descending connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2329 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2334 // Polyhedron writing
2335 if (_ptrMesh->existPolyhedronConnectivity(MED_DESCENDING,entity))
2337 med_int NumberOfFaces = _ptrMesh->getPolyhedronIndex(MED_DESCENDING)[_ptrMesh->getNumberOfPolyhedron()]-1;
2338 vector<med_int> FacesGeometricTypes(NumberOfFaces,MED_POLYGON); // by default all polyhedron faces are polygons
2340 err = MEDpolyedreConnEcr(_medIdt,
2341 const_cast <char *> (_meshName.c_str()),
2342 const_cast <med_int*> (_ptrMesh->getPolyhedronIndex(MED_DESCENDING)),
2343 _ptrMesh->getNumberOfPolyhedron()+1,
2344 &FacesGeometricTypes[0],
2346 const_cast <med_int*> (_ptrMesh->getPolyhedronConnectivity(MED_DESCENDING)),
2350 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Can't write polyhedron descending connectivities of mesh |" << _meshName.c_str() << "| in file |" << _fileName
2351 << "| with dimension |" << _ptrMesh->_spaceDimension <<"| and"
2360 int MED_MESH_WRONLY_DRIVER22::writeFamilyNumbers() const {
2362 const char * LOC="int MED_MESH_WRONLY_DRIVER22::writeFamilyNumbers() const : ";
2365 med_2_2::med_err err;
2367 // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArrayNodeFamily DOIT ETRE ENLEVER DE LA CLASSE MESH
2369 { // Node related block
2371 // We build the array from the families list objects :
2372 int NumberOfNodes = _ptrMesh->getNumberOfNodes() ;
2373 int * MEDArrayNodeFamily = new int[NumberOfNodes] ;
2374 // family 0 by default
2375 for (int i=0; i<NumberOfNodes; i++)
2376 MEDArrayNodeFamily[i]=0;
2377 //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(MED_NODE);
2378 vector<FAMILY*> * myFamilies = &_ptrMesh->_familyNode;
2379 int NumberOfNodesFamilies = myFamilies->size() ;
2380 //bool ToDestroy = false;
2381 if (0 == NumberOfNodesFamilies) {
2382 //ToDestroy = true ;
2383 vector<GROUP*> myGroups = _ptrMesh->getGroups(MED_NODE);
2384 int NumberOfGroups = myGroups.size() ;
2385 // build families from groups
2386 for (int i=0; i<NumberOfGroups; i++) {
2387 SUPPORT * mySupport = myGroups[i] ;
2388 FAMILY* myFamily = new FAMILY(*mySupport);
2389 myFamily->setIdentifier(i+1);
2390 myFamilies->push_back(myFamily);
2392 NumberOfNodesFamilies=myFamilies->size() ;
2394 for (int i=0 ; i<NumberOfNodesFamilies; i++) {
2396 //SCRUTE(myFamilies[i]->getName());
2397 int FamilyIdentifier = (*myFamilies)[i]->getIdentifier() ;
2398 int TotalNumber = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
2399 if ((*myFamilies)[i]->isOnAllElements())
2400 for (int j=0; j<TotalNumber; j++)
2401 MEDArrayNodeFamily[j]=FamilyIdentifier;
2403 const int * Number = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
2404 for (int j=0; j<TotalNumber; j++)
2405 MEDArrayNodeFamily[Number[j]-1]=FamilyIdentifier ;
2409 for(int j=0; j<NumberOfNodes; j++) {
2410 SCRUTE(MEDArrayNodeFamily[j]);
2413 // if ( !_ptrMesh->getIsAGrid() )
2415 err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2416 MEDArrayNodeFamily, NumberOfNodes, med_2_2::MED_NOEUD,
2417 (med_2_2::med_geometrie_element) MED_NONE);
2420 // err = MEDfamGridEcr(_medIdt,
2421 // const_cast <char *> (_ptrMesh->_name.c_str()),
2422 // MEDArrayNodeFamily,
2424 // MED_FR::MED_LECTURE_ECRITURE,
2425 // MED_FR::MED_NOEUD);
2427 if ( err != MED_VALID)
2428 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write node family for the |"<< NumberOfNodes
2429 << "| nodes in mesh |"
2430 << _ptrMesh->_name.c_str() << "|" ));
2431 delete[] MEDArrayNodeFamily;
2432 //if (true == ToDestroy)
2433 // for (int i=0; i<NumberOfNodesFamilies; i++)
2434 // delete myFamilies[i];
2437 { // CELLS RELATED BLOCK
2438 medEntityMesh entity=MED_EN::MED_CELL;
2439 // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
2440 if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
2442 int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
2443 const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
2445 // We build the array from the families list objects :
2446 int NumberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS);
2447 int * MEDArrayFamily = new int[NumberOfElements] ;
2448 // family 0 by default
2449 for (int i=0; i<NumberOfElements; i++)
2450 MEDArrayFamily[i]=0;
2451 //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity);
2452 vector<FAMILY*> * myFamilies = &_ptrMesh->_familyCell ;
2453 int NumberOfFamilies = myFamilies->size() ;
2454 //bool ToDestroy = false;
2455 if (0 == NumberOfFamilies) {
2456 //ToDestroy = true ;
2457 vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
2458 int NumberOfGroups = myGroups.size() ;
2459 // build families from groups
2460 for (int i=0; i<NumberOfGroups; i++) {
2461 SCRUTE( myGroups[i]->getName() );
2462 SUPPORT * mySupport = myGroups[i] ;
2463 FAMILY* myFamily = new FAMILY(*mySupport);
2464 myFamily->setIdentifier(-i-1);
2465 myFamilies->push_back(myFamily);
2467 NumberOfFamilies=myFamilies->size() ;
2469 for (int i=0 ; i<NumberOfFamilies; i++) {
2470 int FamilyIdentifier = (*myFamilies)[i]->getIdentifier() ;
2471 int TotalNumber = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
2472 if ((*myFamilies)[i]->isOnAllElements())
2473 for (int ii=0; ii<TotalNumber; ii++)
2474 MEDArrayFamily[ii]=FamilyIdentifier;
2476 const int * Number = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
2477 for (int ii=0; ii<TotalNumber; ii++)
2478 MEDArrayFamily[Number[ii]-1]=FamilyIdentifier ;
2482 const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
2483 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2484 int lgth=NumberOfElements;
2485 med_2_2::med_int *temp=new med_2_2::med_int[lgth];
2486 for(int i2=0;i2<lgth;i2++)
2487 temp[i2]=(med_2_2::med_int) (MEDArrayFamily[i2]);
2489 for (int i=0; i<numberOfTypes; i++) {
2490 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2491 err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2492 temp+typeCount[i]-1,typeCount[i+1]-typeCount[i],
2494 (med_2_2::med_entite_maillage) entity,
2495 (med_2_2::med_geometrie_element) types[i]
2498 err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2499 (MEDArrayFamily+typeCount[i]-1),
2500 (typeCount[i+1]-typeCount[i]),
2501 (med_2_2::med_entite_maillage) entity,
2502 (med_2_2::med_geometrie_element) types[i]);
2505 if ( err != MED_VALID)
2506 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
2507 << "| cells of geometric type |" << geoNames[types[i]] <<"|in mesh |"
2508 << _ptrMesh->_name.c_str() << "|" ));
2510 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2513 delete[] MEDArrayFamily ;
2514 //if (true == ToDestroy) {
2515 // int NumberOfFamilies = myFamilies->size();
2516 // for (int i=0; i<NumberOfFamilies; i++)
2517 // delete myFamilies[i];
2522 { // FACE RELATED BLOCK
2523 medEntityMesh entity=MED_EN::MED_FACE;
2524 // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
2525 if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
2527 int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
2528 const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
2529 SCRUTE(numberOfTypes);
2531 int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS) ;
2532 int * familyArray = new int[numberOfElements] ;
2533 for (int i=0;i<numberOfElements;i++)
2536 int numberOfFamilies = _ptrMesh->getNumberOfFamilies(entity) ;
2537 //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity) ;
2538 vector<FAMILY*> * myFamilies = &_ptrMesh->_familyFace ;
2539 //bool ToDestroy = false;
2540 if (0 == numberOfFamilies) {
2541 //ToDestroy = true ;
2542 vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
2543 int NumberOfGroups = myGroups.size() ;
2544 // build families from groups
2545 for (int i=0; i<NumberOfGroups; i++) {
2546 SCRUTE( myGroups[i]->getName() );
2547 SUPPORT * mySupport = myGroups[i] ;
2548 FAMILY* myFamily = new FAMILY(*mySupport);
2549 myFamily->setIdentifier(-i-1000);
2550 myFamilies->push_back(myFamily);
2552 numberOfFamilies=myFamilies->size() ;
2554 for (int i=0;i<numberOfFamilies;i++) {
2555 int familyNumber = (*myFamilies)[i]->getIdentifier() ;
2556 int numberOfFamilyElements = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
2557 if ((*myFamilies)[i]->isOnAllElements())
2558 for (int ii=0; ii<numberOfFamilyElements; ii++)
2559 familyArray[ii]=familyNumber;
2561 const int * myFamilyElements = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
2562 for (int ii=0;ii<numberOfFamilyElements;ii++)
2563 familyArray[myFamilyElements[ii]-1]=familyNumber;
2567 const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
2568 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2569 int lgth=numberOfElements;
2570 med_2_2::med_int *temp=new med_2_2::med_int[lgth];
2571 for(int i2=0;i2<lgth;i2++)
2572 temp[i2]=(med_2_2::med_int) (familyArray[i2]);
2574 for (int i=0; i<numberOfTypes; i++) {
2575 int typeNumberOfElements = typeCount[i+1] - typeCount[i] ;
2577 err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2578 familyArray+typeCount[i]-1, typeNumberOfElements,
2579 (med_2_2::med_entite_maillage) entity,
2580 (med_2_2::med_geometrie_element) types[i]);
2582 if ( err != MED_VALID)
2583 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
2584 << "| faces of geometric type |" << geoNames[types[i]] <<"|in mesh |"
2585 << _ptrMesh->_name.c_str() << "|" ));
2587 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2590 delete[] familyArray ;
2591 //if (true == ToDestroy) {
2592 // int NumberOfFamilies = myFamilies->size();
2593 // for (int i=0; i<NumberOfFamilies; i++)
2594 // delete myFamilies[i];
2599 { // EDGE RELATED BLOCK
2600 //medEntityMesh entity=MED_EN::MED_FACE;
2601 medEntityMesh entity=MED_EN::MED_EDGE;
2602 // SOLUTION TEMPORAIRE CAR _ptrMesh->_MEDArray____Family DOIT ETRE ENLEVER DE LA CLASSE MESH
2603 if ( ( _ptrMesh->existConnectivity(MED_NODAL,entity) )|( _ptrMesh->existConnectivity(MED_DESCENDING,entity) ) ) {
2605 int numberOfTypes = _ptrMesh->getNumberOfTypes (entity) ;
2606 const medGeometryElement * types = _ptrMesh->getTypes (entity) ;
2608 int numberOfElements = _ptrMesh->getNumberOfElements(entity, MED_ALL_ELEMENTS) ;
2609 int * familyArray = new int[numberOfElements] ;
2610 for (int i=0;i<numberOfElements;i++)
2613 int numberOfFamilies = _ptrMesh->getNumberOfFamilies(entity) ;
2614 //vector<FAMILY*> myFamilies = _ptrMesh->getFamilies(entity) ;
2615 vector<FAMILY*> * myFamilies = &_ptrMesh->_familyEdge ;
2616 //bool ToDestroy = false;
2617 if (0 == numberOfFamilies) {
2618 //ToDestroy = true ;
2619 vector<GROUP*> myGroups = _ptrMesh->getGroups(entity);
2620 int NumberOfGroups = myGroups.size() ;
2621 // build families from groups
2622 for (int i=0; i<NumberOfGroups; i++) {
2623 SCRUTE( myGroups[i]->getName() );
2624 SUPPORT * mySupport = myGroups[i] ;
2625 FAMILY* myFamily = new FAMILY(*mySupport);
2626 myFamily->setIdentifier(-i-2000);
2627 myFamilies->push_back(myFamily);
2629 numberOfFamilies=myFamilies->size() ;
2631 for (int i=0;i<numberOfFamilies;i++) {
2632 int familyNumber = (*myFamilies)[i]->getIdentifier() ;
2633 int numberOfFamilyElements = (*myFamilies)[i]->getNumberOfElements(MED_ALL_ELEMENTS) ;
2634 if ((*myFamilies)[i]->isOnAllElements())
2635 for (int ii=0; ii<numberOfFamilyElements; ii++)
2636 familyArray[ii]=familyNumber;
2638 const int * myFamilyElements = (*myFamilies)[i]->getNumber(MED_ALL_ELEMENTS) ;
2639 for (int ii=0;ii<numberOfFamilyElements;ii++)
2640 familyArray[myFamilyElements[ii]-1]=familyNumber;
2644 const int * typeCount = _ptrMesh->getGlobalNumberingIndex(entity) ;
2645 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2646 int lgth=numberOfElements;
2647 med_2_2::med_int *temp=new med_2_2::med_int[lgth];
2648 for(int i2=0;i2<lgth;i2++)
2649 temp[i2]=(med_2_2::med_int) (familyArray[i2]);
2651 for (int i=0; i<numberOfTypes; i++) {
2652 int typeNumberOfElements = typeCount[i+1] - typeCount[i] ;
2654 err = MEDfamEcr(_medIdt, const_cast <char *> ( _meshName.c_str() ),
2655 familyArray+typeCount[i]-1, typeNumberOfElements,
2656 (med_2_2::med_entite_maillage) entity,
2657 (med_2_2::med_geometrie_element) types[i]);
2659 if ( err != MED_VALID)
2660 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't write family for the |"<< _ptrMesh->getNumberOfElements(entity, types[i])
2661 << "| edges of geometric type |" << geoNames[types[i]] <<"|in mesh |"
2662 << _ptrMesh->_name.c_str() << "|" ));
2664 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2667 delete[] familyArray ;
2668 //if (true == ToDestroy) {
2669 // int NumberOfFamilies = myFamilies->size();
2670 // for (int i=0; i<NumberOfFamilies; i++)
2671 // delete myFamilies[i];
2680 int MED_MESH_WRONLY_DRIVER22::writeFamilies(vector<FAMILY*> & families ) const
2683 const char * LOC="int MED_MESH_WRONLY_DRIVER22::writeFamilies(vector<FAMILY*> families) const : ";
2686 med_2_2::med_err err;
2688 MESSAGE(LOC<<" families.size() :"<<families.size());
2690 for (unsigned int i=0; i< families.size(); i++) {
2692 int numberOfAttributes = families[i]->getNumberOfAttributes ();
2693 string attributesDescriptions = "";
2695 // Recompose the attributes descriptions arg for MED
2696 for (int j=0; j < numberOfAttributes; j++) {
2698 string attributeDescription = families[i]->getAttributeDescription(j+1);
2700 if ( attributeDescription.size() > MED_TAILLE_DESC )
2701 throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the attribute description n° |" << j+1 << "| of the family |" << families[i]->getName()
2702 << "| with identifier |" << families[i]->getIdentifier() << "| is |"
2703 << attributeDescription.size() <<"| and is more than |" << MED_TAILLE_DESC << "|")) ;
2705 attributesDescriptions += attributeDescription;
2709 int numberOfGroups = families[i]->getNumberOfGroups();
2710 string groupsNames(numberOfGroups*MED_TAILLE_LNOM,'\0') ;
2711 // Recompose the groups names arg for MED
2712 for (int j=0; j < numberOfGroups; j++) {
2714 string groupName = families[i]->getGroupName(j+1);
2716 if ( groupName.size() > MED_TAILLE_LNOM )
2717 throw MEDEXCEPTION( LOCALIZED(STRING(LOC) << "The size of the group name n° |" << j+1 << "| of the family |" << families[i]->getName()
2718 << "| with identifier |" << families[i]->getIdentifier() << "| is |"
2719 << groupName.size() <<"| and is more than |" << MED_TAILLE_LNOM << "|")) ;
2722 int length = min(MED_TAILLE_LNOM,(int)groupName.size());
2723 groupsNames.replace(j*MED_TAILLE_LNOM,length, groupName,0,length);
2727 // test if the family already exists (HDF trick waiting a MED evolution to be replaced)
2729 string dataGroupFam;
2730 if (families[i]->getEntity() == MED_NODE)
2731 dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/NOEUD/"+families[i]->getName()+"/";
2733 dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/ELEM/"+families[i]->getName()+"/";
2735 SCRUTE("|"<<dataGroupFam<<"|");
2736 err = med_2_2::_MEDdatagroupOuvrir(_medIdt,const_cast <char *> (dataGroupFam.c_str()) ) ;
2737 if ( err < MED_VALID ) {
2740 MESSAGE(LOC<<"families[i]->getName().c_str() : "<<families[i]->getName().c_str());
2741 MESSAGE(LOC<<"_meshName.c_str() : "<<_meshName.c_str());
2742 MESSAGE(LOC<<"families[i]->getIdentifier() : "<<families[i]->getIdentifier());
2743 MESSAGE(LOC<<"numberOfAttributes : "<<numberOfAttributes);
2745 //MESSAGE(LOC<<"families[i]->getAttributesIdentifiers() : "<<families[i]->getAttributesIdentifiers()[0]);
2746 //MESSAGE(LOC<<"families[i]->getAttributesValues() : "<<families[i]->getAttributesValues()[0]);
2747 MESSAGE(LOC<<"attributesDescriptions.c_str() : "<<attributesDescriptions.c_str());
2748 MESSAGE(LOC<<"numberOfGroups : "<<numberOfGroups);
2749 MESSAGE(LOC<<"groupsNames.c_str() : "<<groupsNames.c_str());
2750 #if defined(IRIX64) || defined(OSF1) || defined(VPP5000)
2751 int lgth=families[i]->getNumberOfAttributes();
2752 med_2_2::med_int * AttributesIdentifier2 = new med_2_2::med_int[lgth] ;
2753 med_2_2::med_int * AttributesValues2 = new med_2_2::med_int[lgth] ;
2754 for(med_2_2::med_int i2=0;i2<lgth;i2++)
2756 AttributesIdentifier2[i2]=(med_2_2::med_int)(families[i]->getAttributesIdentifiers()[i2]);
2757 AttributesValues2[i2]=(med_2_2::med_int)(families[i]->getAttributesValues()[i2]);
2759 err = med_2_2::MEDfamCr( _medIdt,
2760 const_cast <char *> ( _meshName.c_str() ),
2761 const_cast <char *> ( families[i]->getName().c_str() ),
2762 families[i]->getIdentifier(),
2763 AttributesIdentifier2,
2765 const_cast <char *> (attributesDescriptions.c_str()),
2767 const_cast <char *> (groupsNames.c_str()),
2769 delete [] AttributesIdentifier2;
2770 delete [] AttributesValues2;
2772 err = med_2_2::MEDfamCr( _medIdt,
2773 const_cast <char *> ( _meshName.c_str() ),
2774 const_cast <char *> ( families[i]->getName().c_str() ),
2775 families[i]->getIdentifier(),
2776 families[i]->getAttributesIdentifiers(),
2777 families[i]->getAttributesValues(),
2778 const_cast <char *> (attributesDescriptions.c_str()),
2780 const_cast <char *> (groupsNames.c_str()),
2784 if ( err != MED_VALID)
2785 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Can't create family |" << families[i]->getName()
2786 << "| with identifier |" << families[i]->getIdentifier() << "| groups names |"
2787 << groupsNames <<"| and attributes descriptions |" << attributesDescriptions << "|")) ;
2790 med_2_2::_MEDdatagroupFermer(_medIdt);
2801 // A FAIRE POUR LES NOEUDS ET LES ELEMENTS ret = MEDfamEcr(
2805 /*--------------------- RDWR PART -------------------------------*/
2807 MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22()
2811 MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const string & fileName,
2813 MED_MESH_DRIVER(fileName,ptrMesh,MED_RDWR),
2814 IMED_MESH_RDONLY_DRIVER(fileName,ptrMesh),
2815 IMED_MESH_WRONLY_DRIVER(fileName,ptrMesh),
2816 IMED_MESH_RDWR_DRIVER(fileName,ptrMesh),
2817 MED_MESH_DRIVER22(fileName,ptrMesh,MED_RDWR),
2818 MED_MESH_RDONLY_DRIVER22(fileName,ptrMesh),
2819 MED_MESH_WRONLY_DRIVER22(fileName,ptrMesh)
2821 MESSAGE("MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const string & fileName, MESH * ptrMesh) has been created");
2824 MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const MED_MESH_RDWR_DRIVER22 & driver):
2825 MED_MESH_DRIVER(driver),
2826 IMED_MESH_RDONLY_DRIVER(driver),
2827 IMED_MESH_WRONLY_DRIVER(driver),
2828 IMED_MESH_RDWR_DRIVER(driver),
2829 MED_MESH_DRIVER22(driver),
2830 MED_MESH_RDONLY_DRIVER22(driver),
2831 MED_MESH_WRONLY_DRIVER22(driver)
2835 MED_MESH_RDWR_DRIVER22::~MED_MESH_RDWR_DRIVER22() {
2836 //MESSAGE("MED_MESH_RDWR_DRIVER22::MED_MESH_RDWR_DRIVER22(const string & fileName, MESH * ptrMesh) has been destroyed");
2839 GENDRIVER * MED_MESH_RDWR_DRIVER22::copy(void) const
2841 return new MED_MESH_RDWR_DRIVER22(*this);
2844 void MED_MESH_RDWR_DRIVER22::write(void) const
2846 MED_MESH_WRONLY_DRIVER22::write();
2848 void MED_MESH_RDWR_DRIVER22::read (void)
2850 MED_MESH_RDONLY_DRIVER22::read();