1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "MEDMEM_PorflowMeshDriver.hxx"
24 #include "MEDMEM_DriversDef.hxx"
25 #include "MEDMEM_DriverTools.hxx"
27 #include "MEDMEM_Family.hxx"
28 #include "MEDMEM_Group.hxx"
29 #include "MEDMEM_Coordinate.hxx"
30 #include "MEDMEM_Connectivity.hxx"
31 #include "MEDMEM_Mesh.hxx"
32 #include "MEDMEM_CellModel.hxx"
33 #include "MEDMEM_define.hxx"
41 using namespace MED_EN;
42 using namespace MEDMEM;
44 // geometric types conversion from PORFLOW -> MED
45 //const size_t PORFLOW_MESH_DRIVER::nb_geometrie_porflow;
46 const medGeometryElement PORFLOW_MESH_DRIVER::geomPORFLOWtoMED[nb_geometrie_porflow] =
47 { /* 1 */ MED_TRIA3 ,/* 2 */ MED_QUAD4 ,/* 3 */ MED_TETRA4 ,/* 4 */ MED_PYRA5 ,
48 /* 5 */ MED_PENTA6 ,/* 6 */ MED_HEXA8 };
49 // indirection table from PORFLOW order to MED one for nodes numerotation in all PORFLOW geometries
50 //const size_t PORFLOW_MESH_DRIVER::nb_nodes_max;
52 // conversion from porflow connectivity to MED connectivity
53 const int PORFLOW_MESH_DRIVER::numPORFLOWtoMED[nb_geometrie_porflow] [nb_nodes_max] = {
54 /* TRI3 */ { /*1*/ 1, /*2*/ 3, /*3*/ 2 },
55 /* QUA4 */ { /*1*/ 1, /*2*/ 4, /*3*/ 3, /*4*/ 2 },
56 /* TETRA4 */ { /*1*/ 1, /*2*/ 4, /*3*/ 3, /*4*/ 2 },
57 /* PYRA5 */ { /*1*/ 1, /*2*/ 4, /*3*/ 3, /*4*/ 2, /*5*/ 5 },
58 /* PENTA6 */ { /*1*/ 1, /*2*/ 3, /*3*/ 2, /*4*/ 4, /*5*/ 6, /*6*/ 5 },
59 /* HEXA8 */ { /*1*/ 1, /*2*/ 4, /*3*/ 3, /*4*/ 2, /*5*/ 5, /*6*/ 8, /*7*/ 7, /*8*/ 6 } };
61 // Porflox nodal connectivity of faces - documented in Porflow user's manual
62 //const size_t PORFLOW_MESH_DRIVER::nb_faces_max;
63 //const size_t PORFLOW_MESH_DRIVER::nb_nodes2_max;
64 const int PORFLOW_MESH_DRIVER::connectivityPORFLOW[nb_geometrie_porflow][nb_faces_max][nb_nodes2_max]={
65 //{/* TRI3 */ {3,1,0,0}, {1,2,0,0}, {2,3,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0} },
66 //{/* QUA4 */ {1,4,0,0}, {2,3,0,0}, {1,2,0,0}, {3,4,0,0}, {0,0,0,0}, {0,0,0,0} },
67 {/* TRI3 */ {1,3,0,0}, {2,1,0,0}, {3,2,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0} },
68 {/* QUA4 */ {1,4,0,0}, {3,2,0,0}, {2,1,0,0}, {4,3,0,0}, {0,0,0,0}, {0,0,0,0} },
69 {/* TETRA4 */ {1,3,4,0}, {1,4,2,0}, {4,3,2,0}, {1,2,3,0}, {0,0,0,0}, {0,0,0,0} },
70 {/* PYRA5 */ {1,4,5,0}, {1,5,2,0}, {3,2,5,0}, {4,3,5,0}, {1,2,3,4}, {0,0,0,0} },
71 {/* PENTA6 */ {1,3,6,4}, {2,1,4,5}, {3,2,5,6}, {1,2,3,0}, {4,6,5,0}, {0,0,0,0} },
72 {/* HEXA8 */ {1,4,8,5}, {3,2,6,7}, {2,1,5,6}, {4,3,7,8}, {1,2,3,4}, {5,8,7,6} },
76 inline static bool isKeyWord(const string & line, const char * key);
77 inline static void locateFileName(const string& line, string::size_type& pos1, string::size_type& pos2);
78 inline static string getPorflowFileName(const string& line, const char * context);
79 inline static medGeometryElement get2DMedGeomType(int nbSommets);
82 // Every memory allocation made in the MedDriver members function are desallocated in the Mesh destructor
84 PORFLOW_MESH_DRIVER::PORFLOW_MESH_DRIVER():
85 GENDRIVER(PORFLOW_DRIVER),
86 _ptrMesh(( MESH *) NULL),
87 // A VOIR _medIdt(MED_INVALID),
92 PORFLOW_MESH_DRIVER::PORFLOW_MESH_DRIVER(const string & fileName,
94 MED_EN::med_mode_acces accessMode):
95 GENDRIVER(fileName, accessMode, PORFLOW_DRIVER),
99 _ptrMesh = const_cast<MESH*>( ptrMesh->convertInMESH() );
100 // mesh name construction from fileName
101 const string ext=".inp"; // expected extension
102 string::size_type pos=fileName.find(ext,0);
103 string::size_type pos1=fileName.rfind('/');
105 if (pos1 == string::npos ) pos1=fileName.rfind('\\');
107 if (pos1 != string::npos )
108 _meshName = string(fileName,pos1+1,pos-pos1-1); //get rid of directory & extension
110 _meshName = string(fileName,0,pos); //get rid of directory & extension
111 SCRUTE_MED(_meshName);
114 PORFLOW_MESH_DRIVER::PORFLOW_MESH_DRIVER(const PORFLOW_MESH_DRIVER & driver):
116 _ptrMesh(driver._ptrMesh),
117 // A VOIR _medIdt(MED_INVALID),
118 _meshName(driver._meshName)
121 _ptrMesh->addReference();
124 PORFLOW_MESH_DRIVER::~PORFLOW_MESH_DRIVER()
127 _ptrMesh->removeReference();
130 void PORFLOW_MESH_DRIVER::open()
133 const char * LOC = "PORFLOW_MESH_DRIVER::open()" ;
136 if (_status == MED_OPENED)
137 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"File "<<_fileName<<" is already open"));
139 _porflow.open(_fileName.c_str(), ios::in);
141 _status = MED_OPENED;
144 _status = MED_CLOSED;
145 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Could not open file "<<_fileName<<" in mode ios::in"));
150 void PORFLOW_MESH_DRIVER::close()
153 const char* LOC = "PORFLOW_MESH_DRIVER::close() ";
155 if ( _status == MED_OPENED) {
157 _status = MED_CLOSED;
162 void PORFLOW_MESH_DRIVER::setMeshName(const string & meshName) { _meshName = meshName; }
163 string PORFLOW_MESH_DRIVER::getMeshName() const { return _meshName; }
166 //---------------------------------- RDONLY PART -------------------------------------------------------------
168 PORFLOW_MESH_RDONLY_DRIVER::PORFLOW_MESH_RDONLY_DRIVER(): PORFLOW_MESH_DRIVER()
172 PORFLOW_MESH_RDONLY_DRIVER::PORFLOW_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh):
173 PORFLOW_MESH_DRIVER(fileName,ptrMesh,RDONLY)
175 MESSAGE_MED("PORFLOW_MESH_RDONLY_DRIVER::PORFLOW_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
178 PORFLOW_MESH_RDONLY_DRIVER::PORFLOW_MESH_RDONLY_DRIVER(const PORFLOW_MESH_RDONLY_DRIVER & driver):
179 PORFLOW_MESH_DRIVER(driver)
183 PORFLOW_MESH_RDONLY_DRIVER::~PORFLOW_MESH_RDONLY_DRIVER()
185 //MESSAGE_MED("PORFLOW_MESH_RDONLY_DRIVER::~PORFLOW_MESH_RDONLY_DRIVER() has been destroyed");
188 GENDRIVER * PORFLOW_MESH_RDONLY_DRIVER::copy(void) const
190 return new PORFLOW_MESH_RDONLY_DRIVER(*this);
193 // helper function to check if line starts with key
194 inline static bool isKeyWord(const string & line, const char * key)
196 const int SIZE_KEY=4;
197 const char * pt=line.c_str();
198 while( isspace(*pt) ) // get rid of leading blanks
200 return !strncmp(pt,key,SIZE_KEY);
203 inline static void locateFileName(const string& line, string::size_type& pos1, string::size_type& pos2)
205 pos1 = line.find('"',0);
206 if ( pos1 != string::npos ) // if we found "
207 pos2=line.find('"',pos1+1); // search a second "
208 else // we didn't succeed with double quotes, so we try single quotes
210 pos1 = line.find('\'',0);
211 if ( pos1 != string::npos ) // if we found '
212 pos2=line.find('\'',pos1+1); // search a second '
217 // helper fonction : inversion of PORFLOW_MESH_DRIVER::geomPORFLOWtoMED
218 // return the Porflow geometric type, -1 if not found
219 inline int PORFLOW_MESH_DRIVER::geomMEDtoPorflow(medGeometryElement medGeo)
221 for (int g=0; g!=nb_geometrie_porflow; ++g)
222 if( medGeo == geomPORFLOWtoMED[g] )
228 // Correspondance between the number of nodes and the Med face geometric type
229 inline static medGeometryElement get2DMedGeomType(int nbSommets)
246 // helper function to read a porflow file name (enclosed in single or double quotes) in line
247 inline static string getPorflowFileName(const string& line, const char * context)
249 string::size_type pos1=string::npos;
250 string::size_type pos2=string::npos;
252 locateFileName(line, pos1, pos2);
254 // if we found a not empty filename
255 if (pos1 != string::npos && pos2 != string::npos && pos2>pos1+1)
256 return string(line,pos1+1,pos2-pos1-1);
258 // else, we throw an exception
259 string diagnosis("PORFLOW_MESH_RDONLY_DRIVER::read() : Error after reading keyword ");
261 diagnosis+="\nNo filename was found enclosed in single or double quotes\n";
262 throw MEDEXCEPTION(diagnosis.c_str());
266 // helper function to read a porflow coordinate file ( .xyz )
267 void PORFLOW_MESH_RDONLY_DRIVER::readPorflowCoordinateFile(const string & coorFileName,_intermediateMED & medi,const int space_dimension)
270 ifstream coorFile(coorFileName.c_str(), ios::in);
273 string diagnosis("PORFLOW_MESH_RDONLY_DRIVER::read()\nError, can't open coordinates file :");
274 diagnosis+=coorFileName;
275 throw MEDEXCEPTION(diagnosis.c_str());
278 // scan of the coord file
280 node.coord.resize(space_dimension);
281 string buf_ligne; // to read a line
282 while ( getline(coorFile, buf_ligne) ) // we can't use input stream directly because some 2D files have "0.0" in third coordinate
284 istringstream buf(buf_ligne.c_str());
286 if (!buf) // for spaces at the end of the file
288 for (int i=0; i!=space_dimension; ++i)
289 buf >> node.coord[i];
290 medi.points.insert(make_pair(node.number,node));
295 // helper function to read a porflow connectivity file ( .cnc )
296 void PORFLOW_MESH_RDONLY_DRIVER::readPorflowConnectivityFile(bool hybride,const string & connecFileName,_intermediateMED & medi,std::vector<std::set<_maille>::iterator>& p_ma_table,int mesh_dimension)
299 ifstream connFile(connecFileName.c_str(), ios::in);
302 string diagnosis("PORFLOW_MESH_RDONLY_DRIVER::read()\nError, can't open connectivity file :");
303 diagnosis+=connecFileName;
304 throw MEDEXCEPTION(diagnosis.c_str());
308 unsigned int code, nodes_number, node, ordre;
309 set<_maille>::iterator p_ma;
311 if (hybride) // "HYBR" key-word
315 maille.setOrdre( ordre );
316 if (!connFile) // for spaces at the end of the file
319 connFile >> nodes_number;
320 maille.geometricType = geomPORFLOWtoMED[code-1];
321 if(maille.geometricType%100!=(int)nodes_number) // following incohenrences founded in some porflow files!
323 MESSAGE_MED("WARNING : the read node number don't seem to be compatible with geometric type!");
324 SCRUTE_MED(maille.geometricType);
325 SCRUTE_MED(nodes_number);
327 maille.sommets.resize(nodes_number);
328 for (unsigned i=0; i!=nodes_number; ++i)
331 maille.sommets[numPORFLOWtoMED[code-1][i]-1] = medi.points.find(node);
333 p_ma = medi.insert(maille);
334 if (maille.ordre() > p_ma_table.size()-1) // construction of a vector of iterators on _maille structures
335 p_ma_table.resize(2*maille.ordre());
336 p_ma_table[maille.ordre()] = p_ma;
338 else // default case (or "VERT" key-word)
340 if (mesh_dimension == 2) // we have QUA4
343 maille.geometricType = geomPORFLOWtoMED[code-1];
345 maille.sommets.resize(nodes_number);
347 else if (mesh_dimension == 3) // we have HEXA8
350 maille.geometricType = geomPORFLOWtoMED[code-1];
352 maille.sommets.resize(nodes_number);
355 throw MEDEXCEPTION("PORFLOW_MESH_RDONLY_DRIVER::read()\nError, can't determine geometric type for this VERT mesh");
358 connFile >> ordre; maille.setOrdre(ordre);
359 if (!connFile) // for spaces at the end of the file
361 for (unsigned i=0; i!=nodes_number; ++i)
364 maille.sommets[numPORFLOWtoMED[code-1][i]-1] = medi.points.find(node);
366 p_ma = medi.insert(maille);
367 if (maille.ordre() > p_ma_table.size()-1) // construction of a vector of iterators on _maille structures
368 p_ma_table.resize(2*maille.ordre());
369 p_ma_table[maille.ordre()] = p_ma;
375 void PORFLOW_MESH_RDONLY_DRIVER::read(void)
378 const char * LOC = "PORFLOW_MESH_RDONLY_DRIVER::read() : " ;
381 if (_status!=MED_OPENED)
382 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName
383 << " is : " << " (the file is not opened)." )) ;
385 // if _fileName contains a directory, extract the directory name
386 // the directory name will be used to locate the files included in _fileName.
388 string::size_type pos=_fileName.rfind('/');
390 if (pos == string::npos ) pos=_fileName.rfind('\\');
392 if (pos != string::npos )
393 dirName=string(_fileName, 0, pos+1);
395 _intermediateMED medi; // structure de données intermédiaire pour conversion porflow->med
396 string buf_ligne; // pour lire une ligne
397 unsigned numberOfGridElement=0; // number of grid elements
398 unsigned space_dimension=2; // by default, the problem is assumed to be 2D
399 string coordinateSystem="CARTESIAN";
401 _groupe currentGroup;
402 vector<bool> isGroupAList; // vector to store the type of a group (ie PAIR or LIST)
403 bool processLoca=false;
406 std::vector<std::set<_maille>::iterator> p_ma_table(10000); // store iterators for direct access by index
407 string small("abcdefghijklmnopqrstuvwxyz");
409 while ( getline(_porflow, buf_ligne) ) // scan .inp file and look for main keywords (LOCA, GRID, COOR & CONN)
413 if(buf_ligne[0]=='/')
416 // look if there is a filename
417 string::size_type pos1=string::npos;
418 string::size_type pos2=string::npos;
419 locateFileName(buf_ligne, pos1, pos2);
422 if (pos1!=string::npos && pos2!=string::npos) // if there is a file name in buf_line
423 // convert every char to upper, except those between pos1-pos2 (which correspond to a file name)
424 while ( (pos=buf_ligne.find_first_of(small,pos)) != string::npos )
425 if (pos<pos1 || pos>pos2 )
426 buf_ligne[pos]=toupper(buf_ligne[pos]);
430 // convert every char to upper
431 while ( (pos=buf_ligne.find_first_of(small,pos)) != string::npos )
432 buf_ligne[pos]=toupper(buf_ligne[pos]);
437 // - LOCA {PAIR} [ID=id] {N1,N2, ... ,Nn} : group specification by paired element & surface numbers
438 // - LOCA {LIST} [ID=id] {N1, ... ,Nn} : group specification by a list of elements
439 // the syntax corresponding to the use of input file is not implemented
440 if ( isKeyWord(buf_ligne,"LOCA") )
442 MESSAGE_MED("Mot clé LOCA détecté");
444 // if currentGroup is not empty, a group has been precessed
445 // -> we store it, clear currentGroup, and start the precessing of a new group
446 if ( !currentGroup.groupes.empty() )
447 medi.groupes.push_back(currentGroup);
448 currentGroup.groupes.clear();
449 currentGroup.nom.erase();
450 if ( buf_ligne.find("PAIR",0) != string::npos )
452 isGroupAList.push_back(false);
454 else if ( buf_ligne.find("LIST",0) != string::npos )
456 isGroupAList.push_back(true);
459 throw MEDEXCEPTION("PORFLOW_MESH_RDONLY_DRIVER::read() : Error, after keyword LOCA, LIST or PAIR is expected\n");
461 pos=buf_ligne.find("ID=",0);
462 if ( pos != string::npos )
464 istringstream buf(buf_ligne.c_str()+pos+3);
465 buf >> currentGroup.nom;
467 // avoid problem in the following processing of elements if the group's name contains a digit
468 // -> we replace group's name with blanks
469 while( pos<buf_ligne.size() && !isspace( buf_ligne[pos] ) )
470 buf_ligne[pos++]=' ';
476 // expected syntax : GRID {UNST} [THREE] {N1} [NODE] [N2]
477 // the syntax corresponding to structured grids is not implemented
478 else if ( isKeyWord(buf_ligne,"GRID") )
480 MESSAGE_MED("Mot clé GRID détecté");
482 pos=buf_ligne.find("UNST",0);
483 if ( pos != string::npos ) // unstructured grid
485 // we find the number of grid elements
486 string::size_type len=buf_ligne.size();
487 while ( pos<len && !isdigit(buf_ligne[pos]) )
490 throw MEDEXCEPTION("PORFLOW_MESH_RDONLY_DRIVER::read() : Error, number of grid elements unspecified!\n");
491 istringstream buf(buf_ligne.c_str()+pos);
492 buf >> numberOfGridElement;
494 pos=buf_ligne.find("THREE",0);
495 if ( pos != string::npos ) // if we find THREE, the problem is 3D
500 throw MEDEXCEPTION("PORFLOW_MESH_RDONLY_DRIVER::read() : Error, structured grids are not yet supported!\n");
507 // - CONN {HYBR} {filename} : vertex connectivity for mixed hybrid elements
508 // - CONN {VERT} {filename} : vertex connectivity for quad or hex elements
509 // the default option is HYBR
510 else if ( isKeyWord(buf_ligne,"CONN") )
512 MESSAGE_MED("Mot clé CONN détecté");
514 string fileCONN=getPorflowFileName(buf_ligne,"CONN");
516 if ( buf_ligne.find("HYBR",0) != string::npos )
520 if(fileCONN.rfind('/') == string::npos)
521 // no directory was specified -> we add dirName, which may be empty
523 connFileName=dirName+fileCONN;
525 connFileName=fileCONN;
530 // expected syntax : COOR {VERT} {filename}
531 else if ( isKeyWord(buf_ligne,"COOR") )
533 MESSAGE_MED("Mot clé COOR");
535 string fileCOOR=getPorflowFileName(buf_ligne,"COOR");
537 pos=buf_ligne.find("VERT",0);
538 if ( pos == string::npos )
539 throw MEDEXCEPTION("PORFLOW_MESH_RDONLY_DRIVER::read() : Error, after keyword COOR, we require VERT\n");
541 pos=buf_ligne.find("CYLI",0);
542 if ( pos != string::npos )
543 coordinateSystem="CYLINDRICAL";
545 if(fileCOOR.rfind('/') == string::npos)
546 // no directory was specified -> we add dirName, which may be empty
547 coorFileName=dirName+fileCOOR;
549 coorFileName=fileCOOR;
555 // read group specification
558 // replace non digit caracters with blanks
559 string::iterator last_non_blank=buf_ligne.end();
560 for (string::iterator it=buf_ligne.begin(); it!=buf_ligne.end(); ++it)
566 if (last_non_blank != buf_ligne.end() ) // if the line is not blank
568 buf_ligne=string(buf_ligne.begin(),++last_non_blank); // suppress trailing blanks
570 istringstream buf(buf_ligne.c_str());
572 buf >> i1; // we know the line is not blank
575 currentGroup.groupes.push_back(i1);
584 if ( !currentGroup.groupes.empty() ) // if necessary, add the last group to medi.groupes
585 medi.groupes.push_back(currentGroup);
587 readPorflowCoordinateFile(coorFileName,medi,space_dimension);
588 readPorflowConnectivityFile(hybride,connFileName,medi,p_ma_table,space_dimension);
591 // Group processing :
592 // In the scan loop, we have store in medi.groupes.groupes either :
593 // - paired list of element and surface number (keyword PAIR)
594 // - an explicit list of element numbers (keyword LIST)
595 // What we stored (pairs or list) is remembered through vector isGroupAList.
596 // For both cases, we must convert these numbers to iterators to cells inside the set medi.maillage
597 // - in the LIST case, these cells already exist.
598 // - in the PAIR case, we have to create the corresponding 2D/1D faces
600 //for( std::vector<_groupe>::iterator i=medi.groupes.begin(); i!=medi.groupes.end(); ++i)
601 for( unsigned i=0; i!=medi.groupes.size(); ++i)
603 if ( isGroupAList[i] )
605 // medi.groupes[i].groupes is a vector of element numbers; it points to it
606 medi.groupes[i].mailles.resize( medi.groupes[i].groupes.size() );
607 std::vector<int>::const_iterator it=medi.groupes[i].groupes.begin();
608 for(int j = 0 ; it!=medi.groupes[i].groupes.end(); ++it, ++j)
610 // insert the iterator to the corresponding cell we stored in p_ma_table
611 medi.groupes[i].mailles[j] = p_ma_table[*it];
621 std::set<_maille>::iterator p_ma;
624 // medi.groupes[i].groupes is a vector of paired element and surface numbers
625 // *it points to the element number, *(it+1) points to the surface number
626 std::vector<int>::const_iterator it=medi.groupes[i].groupes.begin();
627 medi.groupes[i].mailles.resize( medi.groupes[i].groupes.size() / 2 );
628 for( ; it!=medi.groupes[i].groupes.end(); ++it)
632 p_ma=p_ma_table[nelem]; // points to the cell
633 ngeom=geomMEDtoPorflow(p_ma->geometricType);
635 // create the face corresponding to nface
637 while( l<nb_nodes2_max && connectivityPORFLOW[ngeom][nface-1][l] )
639 maille2D.sommets.push_back(p_ma->sommets[ numPORFLOWtoMED[ngeom][ connectivityPORFLOW[ngeom][nface-1][l++]-1 ]-1 ]);
642 // the corresponding 2D MED geometric type depends upon the number of nodes
643 maille2D.sommets.resize(l);
644 maille2D.geometricType = get2DMedGeomType(l);
645 p_ma = medi.insert(maille2D); // we insert the face in our mesh
646 medi.groupes[i].mailles[ielem++]=p_ma; // and insert an iterator on it in our group
647 maille2D.sommets.clear();
651 medi.groupes[i].groupes.clear(); // we don't need element numbers anymore
655 p_ma_table.clear(); // we don't need it anymore
656 MESSAGE_MED(LOC << "PORFLOW_MESH_RDONLY_DRIVER::read : RESULTATS STRUCTURE INTERMEDIAIRES : ");
657 MESSAGE_MED(LOC << medi );
658 // TRANSFORMATION EN STRUCTURES MED
659 if ( ! _ptrMesh->isEmpty() )
661 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Mesh object not empty : can't fill it!"));
663 else if ( /*medi.maillage.size()==0 || */medi.groupes.size()==0 || medi.points.size()==0)
665 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << " Error while reading file " << _fileName
666 << " The data read are not completed " ) ) ;
670 _ptrMesh->_name = _meshName;
671 _ptrMesh->_spaceDimension = medi.points.begin()->second.coord.size();
672 _ptrMesh->_numberOfNodes = medi.points.size();
673 _ptrMesh->_coordinate = medi.getCoordinate();
675 //Construction des groupes
676 vector<GROUP *> groupCell, groupFace, groupEdge, groupNode;
677 medi.getGroups(groupCell, groupFace, groupEdge, groupNode, _ptrMesh);
678 _ptrMesh->_groupCell = groupCell;
679 _ptrMesh->_groupFace = groupFace;
680 _ptrMesh->_groupEdge = groupEdge;
681 _ptrMesh->_groupNode = groupNode;
683 // appele en dernier car cette fonction detruit le maillage intermediaire!
684 _ptrMesh->_connectivity = medi.getConnectivity();
685 MESSAGE_MED(LOC << "PORFLOW_MESH_RDONLY_DRIVER::read : FIN ");
687 // calcul de la connectivite d-1 complete, avec renumerotation des groupes
688 // if (_ptrMesh->_spaceDimension==3)
689 // _ptrMesh->_connectivity->updateGroup(_ptrMesh->_groupFace) ;
690 // else if (_ptrMesh->_spaceDimension==2)
691 // _ptrMesh->_connectivity->updateGroup(_ptrMesh->_groupEdge) ;
693 // Creation des familles ?artir des groupes
694 // NC : Cet appel pourra ?e diff鲩 quand la gestion de la coh鲥nce famille/groupes sera assur饊 _ptrMesh->createFamilies();
701 void PORFLOW_MESH_RDONLY_DRIVER::write( void ) const
704 throw MEDEXCEPTION("PORFLOW_MESH_RDONLY_DRIVER::write : Can't write with a RDONLY driver !");
708 /*--------------------- WRONLY PART -------------------------------*/
710 PORFLOW_MESH_WRONLY_DRIVER::PORFLOW_MESH_WRONLY_DRIVER():PORFLOW_MESH_DRIVER()
714 PORFLOW_MESH_WRONLY_DRIVER::PORFLOW_MESH_WRONLY_DRIVER(const string & fileName,
716 PORFLOW_MESH_DRIVER(fileName,ptrMesh,WRONLY)
718 MESSAGE_MED("PORFLOW_MESH_WRONLY_DRIVER::PORFLOW_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
721 PORFLOW_MESH_WRONLY_DRIVER::PORFLOW_MESH_WRONLY_DRIVER(const PORFLOW_MESH_WRONLY_DRIVER & driver):
722 PORFLOW_MESH_DRIVER(driver)
726 PORFLOW_MESH_WRONLY_DRIVER::~PORFLOW_MESH_WRONLY_DRIVER()
728 //MESSAGE_MED("PORFLOW_MESH_WRONLY_DRIVER::PORFLOW_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed");
731 GENDRIVER * PORFLOW_MESH_WRONLY_DRIVER::copy(void) const
733 return new PORFLOW_MESH_WRONLY_DRIVER(*this);
736 void PORFLOW_MESH_WRONLY_DRIVER::read (void)
739 throw MEDEXCEPTION("PORFLOW_MESH_WRONLY_DRIVER::read : Can't read with a WRONLY driver !");
742 void PORFLOW_MESH_WRONLY_DRIVER::write(void) const
745 const char * LOC = "void PORFLOW_MESH_WRONLY_DRIVER::write(void) const : ";
748 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< "Write Driver isn\'t implemented"));
755 /*--------------------- RDWR PART -------------------------------*/
757 PORFLOW_MESH_RDWR_DRIVER::PORFLOW_MESH_RDWR_DRIVER():
758 PORFLOW_MESH_DRIVER(),
759 PORFLOW_MESH_RDONLY_DRIVER(),
760 PORFLOW_MESH_WRONLY_DRIVER()
764 PORFLOW_MESH_RDWR_DRIVER::PORFLOW_MESH_RDWR_DRIVER(const string & fileName,MESH * ptrMesh):
765 PORFLOW_MESH_DRIVER(fileName,ptrMesh,RDWR),
766 PORFLOW_MESH_RDONLY_DRIVER(fileName,ptrMesh),
767 PORFLOW_MESH_WRONLY_DRIVER(fileName,ptrMesh)
769 MESSAGE_MED("PORFLOW_MESH_RDWR_DRIVER::PORFLOW_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been created");
772 PORFLOW_MESH_RDWR_DRIVER::PORFLOW_MESH_RDWR_DRIVER(const PORFLOW_MESH_RDWR_DRIVER & driver):
773 PORFLOW_MESH_DRIVER(driver),
774 PORFLOW_MESH_RDONLY_DRIVER(driver),
775 PORFLOW_MESH_WRONLY_DRIVER(driver)
779 PORFLOW_MESH_RDWR_DRIVER::~PORFLOW_MESH_RDWR_DRIVER() {
780 //MESSAGE_MED("PORFLOW_MESH_RDWR_DRIVER::PORFLOW_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) has been destroyed");
783 GENDRIVER * PORFLOW_MESH_RDWR_DRIVER::copy(void) const
785 return new PORFLOW_MESH_RDWR_DRIVER(*this);
788 void PORFLOW_MESH_RDWR_DRIVER::write(void) const
791 PORFLOW_MESH_WRONLY_DRIVER::write();
793 void PORFLOW_MESH_RDWR_DRIVER::read (void)
796 PORFLOW_MESH_RDONLY_DRIVER::read();