1 #include "MEDMEM_Compatibility21_22.hxx"
2 #include "MEDMEM_MedMedDriver21.hxx"
3 #include "MEDMEM_MedMeshDriver.hxx"
4 #include "MEDMEM_DriversDef.hxx"
6 #include "MEDMEM_Mesh.hxx"
7 #include "MEDMEM_Grid.hxx"
8 #include "MEDMEM_Field.hxx"
9 // EN ATTENDANT L'utilisation de MedFieldDriver.hxx ds Field.hxx
10 #include "MEDMEM_MedFieldDriver.hxx"
11 #include "MEDMEM_Med.hxx"
12 #include "MEDMEM_define.hxx"
17 using namespace MED_EN;
18 using namespace MEDMEM;
20 MED_MED_DRIVER21::MED_MED_DRIVER21(): _medIdt(MED_INVALID)
23 MED_MED_DRIVER21::MED_MED_DRIVER21(const string & fileName, MED * const ptrMed):
24 MED_MED_DRIVER(fileName,ptrMed), _medIdt(MED_INVALID)
26 //_ptrMed->addDriver(*this); // The specific MED driver id is set within the addDriver method.
29 MED_MED_DRIVER21::MED_MED_DRIVER21(const string & fileName,
31 MED_EN::med_mode_acces accessMode):
32 MED_MED_DRIVER(fileName,ptrMed,accessMode), _medIdt(MED_INVALID)
35 //REM : As t'on besoin du champ _status : _medIdt <-> _status ? Oui
37 MED_MED_DRIVER21::MED_MED_DRIVER21(const MED_MED_DRIVER21 & driver):
38 MED_MED_DRIVER(driver),_medIdt(driver._medIdt)
42 MED_MED_DRIVER21::~MED_MED_DRIVER21()
44 MESSAGE("MED_MED_DRIVER21::~MED_MED_DRIVER21() has been destroyed");
47 void MED_MED_DRIVER21::read()
50 void MED_MED_DRIVER21::readFileStruct()
53 void MED_MED_DRIVER21::write() const
56 GENDRIVER * MED_MED_DRIVER21::copy(void) const
58 return new MED_MED_DRIVER21(*this) ;
60 void MED_MED_DRIVER21::writeFrom() const
64 void MED_MED_DRIVER21::open()
68 const char * LOC ="MED_MED_DRIVER21::open() : ";
71 // REFLECHIR SUR CE TEST PAR RAPPORT A L'OUVERTURE/FERMETURE
72 // if ( _medIdt != MED_INVALID )
73 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
74 // << "_medIdt is already in use, please close the file |"
75 // << _fileName << "| before calling open()"
79 // if ( _status != MED_CLOSED )
80 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
81 // << "_status is closed, please close the file |"
82 // << _fileName << "| before calling open()"
86 if ( _fileName == "" )
87 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
88 << "_fileName is |\"\"|, please set a correct fileName before calling open()"
92 MESSAGE(LOC<<"_fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode);
93 _medIdt = med_2_1::MEDouvrir( (const_cast <char *> (_fileName.c_str())), (med_2_1::med_mode_acces) _accessMode);
94 MESSAGE(LOC<<" _medIdt = "<<_medIdt);
100 _medIdt = MED_INVALID;
101 throw MED_EXCEPTION (LOCALIZED( STRING(LOC)
102 << "Can't open |" << _fileName
103 << "|, _medIdt : " << _medIdt
112 void MED_MED_DRIVER21::close()
114 med_2_1::med_int err = 0;
115 const char * LOC = "MED_MED_DRIVER21::close() : ";
118 // if ( _status == MED_CLOSED)
119 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": the file |"
120 // << _fileName << "| is already closed"
124 // if ( _medIdt == MED_INVALID )
125 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "_medIdt invalid, but the file |"
126 // << _fileName << "| seems to be openned !"
130 if ( _medIdt != MED_INVALID )
131 err=med_2_1::MEDfermer(_medIdt);
133 // if (err != MED_VALID)
134 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "the file |"
135 // << _fileName << "| couldn't be closed"
139 _status = MED_CLOSED;
140 _medIdt = MED_INVALID;
146 // ------------- Read Only Part --------------
148 MED_MED_RDONLY_DRIVER21::MED_MED_RDONLY_DRIVER21()
152 MED_MED_RDONLY_DRIVER21::MED_MED_RDONLY_DRIVER21(const string & fileName, MED * const ptrMed):
153 IMED_MED_RDONLY_DRIVER(fileName,ptrMed),MED_MED_DRIVER21(fileName,ptrMed,MED_EN::MED_RDONLY),MED_MED_DRIVER(fileName,ptrMed,MED_EN::MED_RDONLY)
155 MESSAGE("MED_MED_RDONLY_DRIVER21::MED_MED_RDONLY_DRIVER21(const string & fileName, MED * const ptrMed) Constructeur read only");
158 MED_MED_RDONLY_DRIVER21::MED_MED_RDONLY_DRIVER21(const MED_MED_RDONLY_DRIVER21 & driver):
159 IMED_MED_RDONLY_DRIVER(driver) ,MED_MED_DRIVER21(driver),MED_MED_DRIVER(driver)
163 MED_MED_RDONLY_DRIVER21::~MED_MED_RDONLY_DRIVER21()
165 MESSAGE("MED_MED_RDONLY_DRIVER21::~MED_MED_RDONLY_DRIVER21() has been destroyed");
168 GENDRIVER * MED_MED_RDONLY_DRIVER21::copy(void) const
170 return new MED_MED_RDONLY_DRIVER21(*this) ;
173 void MED_MED_RDONLY_DRIVER21::write ( void ) const throw (MEDEXCEPTION)
175 IMED_MED_RDONLY_DRIVER::write();
178 void MED_MED_RDONLY_DRIVER21::writeFrom ( void ) const throw (MEDEXCEPTION)
180 IMED_MED_RDONLY_DRIVER::writeFrom();
183 void MED_MED_RDONLY_DRIVER21::readFileStruct( void )
186 const char * LOC = "MED_MED_DRIVER21::readFileStruct() : ";
191 if ( _medIdt == MED_INVALID )
192 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
193 << "_medIdt is invalid, please open the file |"
194 << _fileName << "| before calling readFileStruct()"
197 // Read number of meshes and their associated name
200 char meshName[MED_TAILLE_NOM+1]="";
201 char meshDescription[MED_TAILLE_DESC+1]="";
202 med_2_1::med_int meshDim;
204 // MED_MESH_RDWR_DRIVER * ptrDriver; !! UNUSED VARIABLE !!
206 numberOfMeshes = med_2_1::MEDnMaa(_medIdt) ;
207 if ( numberOfMeshes <= 0 )
208 MESSAGE(LOC << "Be careful there is no mesh in file |"<<_fileName<<"| !");
210 MESH_ENTITIES::const_iterator currentEntity;
211 for (i=1;i<=numberOfMeshes;i++) {
213 // find out if the mesh is a Grid
215 med_2_1::med_int isAGrid = false;
216 med_2_1::med_grid_type type;
218 err = MEDgridInfo (_medIdt, i, &isAGrid, &type);
219 if (err != MED_VALID)
220 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "error in MEDgridInfo()") );
222 err = med_2_1::MEDmaaInfo(_medIdt, i ,meshName, &meshDim) ;
224 strcpy(meshDescription,"Mesh from Med 2.2 format");
226 if (err != MED_VALID)
227 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": can't get information about the mesh n°"
228 << i <<" of the file |" << _fileName << "| !"
231 MESSAGE(LOC<<": Mesh n°"<<i<<" nammed "<<meshName);
234 ptrMesh = new GRID((MED_EN::med_grid_type) type);
236 ptrMesh = new MESH();
238 //MED_MESH_RDWR_DRIVER * _ptrDriver = new MED_MESH_RDWR_DRIVER(_fileName, ptrMesh);
239 MED_EN::med_mode_acces myMode = getAccessMode();
240 // MED_MESH_DRIVER * ptrDriver ;
242 // case MED_EN::MED_LECT:
243 // ptrDriver = new MED_MESH_RDONLY_DRIVER(_fileName, ptrMesh);
245 // case MED_EN::MED_REMP:
246 // ptrDriver = new MED_MESH_RDWR_DRIVER(_fileName, ptrMesh);
248 // case MED_EN::MED_ECRI: // should never append !!
249 // ptrDriver = new MED_MESH_RDONLY_DRIVER(_fileName, ptrMesh);
252 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
255 GENDRIVER * ptrDriver =
256 DRIVERFACTORY::buildConcreteMedDriverForMesh(_fileName, ptrMesh,
257 meshName, myMode, V21);
259 ptrDriver->setId ( getId() );
260 ptrDriver->setMeshName ( meshName );
261 ptrMesh->setDescription(meshDescription);
265 ptrMesh->addDriver(*ptrDriver);
269 _ptrMed->_meshes[meshName] = (MESH *) ptrMesh;
271 _ptrMed->_meshes[meshName] = ptrMesh;
273 ptrMesh->setName(meshName);
277 MESSAGE(LOC<<"is" << (isAGrid ? "" : " NOT") << " a GRID and its name is "<<ptrMesh->getName());
279 // we create all global support (for each entity type :
281 for (currentEntity=meshEntities.begin();currentEntity != meshEntities.end(); currentEntity++) {
282 string supportName="SupportOnAll_" ;
283 supportName+=entNames[(*currentEntity).first] ;
284 //(_ptrMed->_support)[meshName][(MED_EN::medEntityMesh)(*currentEntity).first]=new SUPPORT(ptrMesh,supportName,(MED_EN::medEntityMesh) (*currentEntity).first) ;
285 SUPPORT* mySupport = new SUPPORT() ;
286 mySupport->setName(supportName);
287 mySupport->setMesh(ptrMesh);
288 mySupport->setEntity((MED_EN::medEntityMesh) (*currentEntity).first);
289 mySupport->setAll(true);
290 (_ptrMed->_support)[meshName][(MED_EN::medEntityMesh)(*currentEntity).first] = mySupport ;
291 MESSAGE(LOC<< "The support " << supportName.c_str() << " on entity " << (*currentEntity).first << " is built");
294 MESSAGE(LOC <<"The mesh " <<ptrMesh->getName() << " has " << index << " support(s)");
297 map<MESH_NAME_, map<MED_EN::medEntityMesh,SUPPORT *> >::const_iterator const_itSupportOnMesh ;
301 vector<SUPPORT *> vectSupp;
302 for (const_itSupportOnMesh=_ptrMed->_support.begin(); const_itSupportOnMesh != _ptrMed->_support.end();
303 const_itSupportOnMesh++ )
305 map<MED_EN::medEntityMesh,SUPPORT *>::const_iterator const_itSupport ;
306 for (const_itSupport=(*const_itSupportOnMesh).second.begin();
307 const_itSupport!=(*const_itSupportOnMesh).second.end();const_itSupport++) index++;
310 MESSAGE(LOC << "In this MED object there is(are) " << index << " support(s):");
312 vectSupp.resize(index);
315 for (const_itSupportOnMesh=_ptrMed->_support.begin(); const_itSupportOnMesh != _ptrMed->_support.end();
316 const_itSupportOnMesh++ )
318 map<MED_EN::medEntityMesh,SUPPORT *>::const_iterator const_itSupport ;
319 for (const_itSupport=(*const_itSupportOnMesh).second.begin();
320 const_itSupport!=(*const_itSupportOnMesh).second.end();const_itSupport++)
322 vectSupp[index] = (*const_itSupport).second;
323 SCRUTE(vectSupp[index]);
324 MESSAGE(LOC << "Support number " << index << " is "<< *vectSupp[index]);
332 // Read number of fields, their associated name and their list of (timeStepNumber,iterationNumber)
334 int numberOfFields = 0; //MED_INVALID
335 // char fieldName[MED_TAILLE_NOM+1] = "";
336 char fieldName[MED_TAILLE_NOM+1] ;
337 int numberOfComponents = 0;
338 char * componentName = (char *) MED_NULL;
339 char * unitName = (char *) MED_NULL;
340 // char meshName[MED_TAILLE_NOM+1] = "";
341 char meshName[MED_TAILLE_NOM+1] ;
342 med_2_1::med_type_champ type;
343 MESH * ptrMesh = (MESH *) MED_NULL;
344 FIELD_ * ptrField = (FIELD_ *) MED_NULL;
345 //MED_FIELD_RDWR_DRIVER * ptrDriver = (MED_FIELD_RDWR_DRIVER * ) MED_NULL;
346 GENDRIVER * ptrDriver = (GENDRIVER * ) MED_NULL;
347 SUPPORT * ptrSupport = (SUPPORT * ) MED_NULL;
348 MESH_ENTITIES::const_iterator currentEntity;
349 list<MED_EN::medGeometryElement>::const_iterator currentGeometry;
350 med_2_1::med_int NbOfGaussPts = 0;
351 int numberOfTimeSteps = -1;
352 med_2_1::med_int timeStepNumber = -1;
353 // char timeStepUnit[MED_TAILLE_PNOM]= "";
354 char timeStepUnit[MED_TAILLE_PNOM21+1] ;
355 double timeStep = 0.0;
356 med_2_1::med_int orderNumber = -1; //???init?????
357 map<MESH_NAME_,MESH*> & _meshes = _ptrMed->_meshes;
358 map<FIELD_NAME_,MAP_DT_IT_> & _fields = _ptrMed->_fields;
359 map<FIELD_ *, MESH_NAME_> & _meshName = _ptrMed->_meshName;
360 map<MESH_NAME_, map<MED_EN::medEntityMesh,SUPPORT *> > & support = _ptrMed->_support;
363 numberOfFields = med_2_1::MEDnChamp(_medIdt,0) ;
364 if ( numberOfFields <= 0 )
365 MESSAGE(LOC << "Be careful there is no field in file |"<<_fileName<<"| !");
367 for (i=1;i<=numberOfFields;i++) {
369 numberOfComponents = med_2_1::MEDnChamp(_medIdt,i) ;
370 if ( numberOfComponents <= 0 )
371 if (err != MED_VALID)
372 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "Be careful there is no compound for field n°"
373 << i << "in file |"<<_fileName<<"| !"));
375 componentName = new char[numberOfComponents*MED_TAILLE_PNOM21+1] ;
376 unitName = new char[numberOfComponents*MED_TAILLE_PNOM21+1] ;
378 err = MEDchampInfo(_medIdt, i, fieldName, &type, componentName,
379 unitName, numberOfComponents) ;
381 if (err != MED_VALID)
382 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
383 << ": can't get information about the field n°"
384 << i <<" of the file |" << _fileName << "| !"));
386 MESSAGE(LOC << "Field n°"<<i<<" nammed "<< fieldName
387 << " ,component(s) : " << componentName
388 <<" ,unit(s) : " << unitName);
391 // Loop on all (entity type,geometry type) until you find an existing one then
392 // get the (n°dt,n°it) pairs list for the current (field,entity type,geometry type)
393 // We suppose there is the same list whatever the existing (entity type,geometry type) pair
395 for (currentEntity=meshEntities.begin();currentEntity != meshEntities.end(); currentEntity++) {
396 // numberOfTimeSteps MUST be given by MEDchampInfo !!!!!
397 for (currentGeometry = (*currentEntity).second.begin();currentGeometry != (*currentEntity).second.end(); currentGeometry++) {
398 MESSAGE("Field information with Entity,Geom = "<<(*currentEntity).first<<","<<(*currentGeometry));
399 numberOfTimeSteps = MEDnPasdetemps(_medIdt, fieldName,
400 (med_2_1::med_entite_maillage)(*currentEntity).first,
401 (med_2_1::med_geometrie_element) (*currentGeometry) );
402 MESSAGE("Field information 2 : NumberOfTimeStep :"<<numberOfTimeSteps);
403 if ( numberOfTimeSteps > MED_VALID )
404 break ; // There are value for some med_geometrie_element of this med_entite_maillage.
406 if (numberOfTimeSteps>0) // we have at least one
408 for (currentGeometry = (*currentEntity).second.begin();currentGeometry != (*currentEntity).second.end(); currentGeometry++) {
410 MESSAGE("Field information 3 : Geom : "<<(*currentGeometry));
411 for (j=1;j <= numberOfTimeSteps; j++) {
413 MESSAGE("Field information 4 : time step j = "<<j);
414 err = MEDpasdetempsInfo( _medIdt, fieldName,
415 (med_2_1::med_entite_maillage) (*currentEntity).first,
416 (med_2_1::med_geometrie_element) (*currentGeometry),j,
417 meshName, &NbOfGaussPts,
418 &timeStepNumber, timeStepUnit, &timeStep,
420 if (err == MED_VALID) { // we have found for (*currentEntity).first and (*currentGeometry)
422 MESSAGE("Field information 5 ;: NumberOfGaussPoint : "<<NbOfGaussPts<<", timeStepNumber : "<<timeStepNumber);
423 // CORRECT a bug in MEDpasdetempsInfo :
424 // we get a value n'importe quoi in NbOfGaussPts !!!!
426 if (NbOfGaussPts>100)
428 if (timeStepNumber<0)
432 // ATTENTION TRAITER L'EXCEPTION !!!!!!!!!!!!
434 // Il faudra traiter le cas d'un champ qui utilise +sieurs (entity,geom) voir le travail de patrick
435 // Il faudra traiter le cas des profils...
436 // ptrField = new FIELD();
437 // _ptrDriver = new MED_FIELD_RDWR_DRIVER(_fileName, ptrField);
438 // ptrField->addDriver(_ptrDriver);
439 // _fields[fieldName]=ptrField;
441 // Verify meshName is already known
443 map<MESH_NAME_,MESH*>::iterator _meshesIt = _meshes.find(meshName);
444 if ( _meshesIt == _meshes.end() ) {
445 MESSAGE(LOC << "There is no mesh |"
446 << meshName <<"| in the file |"
447 << _fileName <<"|, but |" << meshName <<"| is referenced by field |"
448 << fieldName <<"|, entity : |"
449 << entNames [(*currentEntity).first] <<"|, geometric element of type |"
450 << geoNames [(*currentGeometry)] <<"|"
452 } // POURQUOI SI JE NE MET PAS DE BLOCK J'AI UN PARSE ERROR : PG : c'est la macro MESSAGE qui fait ca !
454 ptrMesh = _meshes[meshName];
456 ptrSupport = support[meshName][(MED_EN::medEntityMesh) (*currentEntity).first];
457 if (NbOfGaussPts != 1)
458 throw MEDEXCEPTION(LOCALIZED( STRING(LOC) <<"Number of Gauss Point must be equal to 1 for instance")) ;
460 // init to null to prevent some error if not correctly allocated !
461 ptrField = (FIELD_*)NULL ;
462 // ptrDriver = (GENDRIVER*)NULL ;
465 case med_2_1::MED_INT64 :
466 if ( sizeof(med_2_1::med_int) != 8 )
467 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) <<
468 " The Field type of |"
469 << fieldName <<"|, entity : |"
470 << entNames [(*currentEntity).first] <<"|, geometric element of type |"
471 << geoNames [(*currentGeometry) ] <<
472 "| is MED_INT64 but size of med_int is not equal to 8 bytes !"
476 case med_2_1::MED_INT32 : {
477 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) <<
478 // "NOT IMPLEMENTED : BUG IN STL !")
480 // ptrField = new FIELD<med_2_1::med_int> ( ptrSupport,numberOfComponents ); // Les valeurs du champ ne doivent pas être lue pour l'instant
482 ptrField = new FIELD<int> ( ); // Les valeurs du champ ne doivent pas être lue pour l'instant
483 ((FIELD<int>*) ptrField)->setSupport(ptrSupport);
484 ((FIELD<int>*) ptrField)->setNumberOfComponents(numberOfComponents);
485 ((FIELD<int>*) ptrField)->setName(fieldName) ; //provisoire, pour debug
486 MESSAGE("#### SET NAME in FIELD : "<<fieldName);
488 MED_EN::med_mode_acces myMode = getAccessMode();
490 // case MED_EN::MED_LECT:
491 // ptrDriver = new MED_FIELD_RDONLY_DRIVER<int>(_fileName, (FIELD<int> *)ptrField);
493 // case MED_EN::MED_REMP:
494 // ptrDriver = new MED_FIELD_RDWR_DRIVER<int>(_fileName, (FIELD<int> *)ptrField);
496 // case MED_EN::MED_ECRI: // should never append !!
497 // ptrDriver = new MED_FIELD_RDONLY_DRIVER<int>(_fileName, (FIELD<int> *)ptrField);
500 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
503 ptrDriver = DRIVERFACTORY::buildConcreteMedDriverForField<int>(_fileName, (FIELD<int> *)ptrField, myMode, V21);
509 case med_2_1::MED_REEL64 : {
510 // ptrField = new FIELD<med_2_1::med_float> ( ptrSupport,numberOfComponents ); // Les valeurs du champ ne doivent pas être lue pour l'instant
511 ptrField = new FIELD<double> ( ); // Les valeurs du champ ne doivent pas être lue pour l'instant
512 ((FIELD<med_2_1::med_float>*) ptrField)->setSupport(ptrSupport);
513 ((FIELD<med_2_1::med_float>*) ptrField)->setNumberOfComponents(numberOfComponents);
514 ((FIELD<med_2_1::med_float>*) ptrField)->setName(fieldName) ; //provisoire, pour debug
515 MESSAGE("#### SET NAME in FIELD : "<<fieldName);
517 MED_EN::med_mode_acces myMode = getAccessMode();
519 // case MED_EN::MED_LECT:
520 // ptrDriver = new MED_FIELD_RDONLY_DRIVER<med_2_1::med_float>(_fileName, (FIELD<med_2_1::med_float> *)ptrField);
522 // case MED_EN::MED_REMP:
523 // ptrDriver = new MED_FIELD_RDWR_DRIVER<med_2_1::med_float>(_fileName, (FIELD<med_2_1::med_float> *)ptrField);
525 // case MED_EN::MED_ECRI: // should never append !!
526 // ptrDriver = new MED_FIELD_RDONLY_DRIVER<med_2_1::med_float>(_fileName, (FIELD<med_2_1::med_float> *)ptrField);
529 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
532 ptrDriver = DRIVERFACTORY::buildConcreteMedDriverForField<med_2_1::med_float>(_fileName, (FIELD<med_2_1::med_float> *)ptrField, myMode, V21);
538 if ( numberOfTimeSteps > 1)
539 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) <<
540 " The Field type of |"
541 << fieldName <<"|, entity : |"
542 << entNames [(*currentEntity).first]
543 <<"|, geometric element of type |"
544 << geoNames [(*currentGeometry)]
545 <<"| is neither MED_INT, MED_INT32, MED_INT64 nor MED_REEL64 !"
551 ptrField->setValueType((MED_EN::med_type_champ) type) ; // need to write field !
553 MESSAGE("timeStepNumber :"<<timeStepNumber<<",orderNumber :"<<orderNumber);
554 ptrField->setIterationNumber ( timeStepNumber); // A ajouter dans la classe FIELD
555 ptrField->setOrderNumber ( orderNumber);
556 ptrField->setTime ( timeStep);
558 // Create a driver for this (field n°dt,n°it)
559 ptrDriver->setId ( getId() );
560 MESSAGE("###### ptrDriver->setFieldName : #"<<fieldName<<"#");
561 ptrDriver->setFieldName(fieldName);
562 ptrField->addDriver(*ptrDriver);
563 // driver is duplicated : remove it
567 dtIt.dt = timeStepNumber;
568 dtIt.it = orderNumber;
570 (_fields [fieldName])[dtIt] = ptrField;
571 _meshName[ptrField ] = meshName;
576 delete[] componentName ;
581 // read profil count and their names
582 // int support_count_= 0 ; !! UNUSED VARIABLE !!
583 // il faut lire les champs pour avoir les profils stockes !!!
584 // il faudrait implémenter la lecture des profils dans med !!!
590 // This method ask the drivers of all MESH/FIELD objects created from this MED driver
591 // to read themselves
592 void MED_MED_RDONLY_DRIVER21::read( void )
593 throw (MEDEXCEPTION) // from objects method read !
595 const char * LOC = "MED_MED_DRIVER21::read() : ";
599 const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
600 map<MESH_NAME_,MESH*>::const_iterator currentMesh;
602 const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
603 map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
605 for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ )
606 (*currentMesh).second->read(*this);
607 //(*currentMesh).second->read(); // default reader, from readFileStruct
610 _ptrMed->updateSupport() ;
612 for ( currentField =_meshName.begin(); currentField != _meshName.end(); currentField++ )
613 (*currentField).first->read(*this);
614 //(*currentField).first->read(); // default reader, from readFileStruct
619 // ------------- Write Only Part --------------
621 MED_MED_WRONLY_DRIVER21::MED_MED_WRONLY_DRIVER21()
625 MED_MED_WRONLY_DRIVER21::MED_MED_WRONLY_DRIVER21(const string & fileName, MED * const ptrMed):
626 IMED_MED_WRONLY_DRIVER(fileName,ptrMed),MED_MED_DRIVER21(fileName,ptrMed),MED_MED_DRIVER(fileName,ptrMed,MED_EN::MED_WRONLY)
629 MED_MED_WRONLY_DRIVER21::MED_MED_WRONLY_DRIVER21(const MED_MED_WRONLY_DRIVER21 & driver):
630 IMED_MED_WRONLY_DRIVER(driver),MED_MED_DRIVER(driver),MED_MED_DRIVER21(driver)
633 MED_MED_WRONLY_DRIVER21::~MED_MED_WRONLY_DRIVER21()
635 MESSAGE("MED_MED_WRONLY_DRIVER21::~MED_MED_WRONLY_DRIVER21() has been destroyed");
638 GENDRIVER * MED_MED_WRONLY_DRIVER21::copy(void) const
640 return new MED_MED_WRONLY_DRIVER21(*this) ;
643 void MED_MED_WRONLY_DRIVER21::read ( void ) throw (MEDEXCEPTION)
645 IMED_MED_WRONLY_DRIVER::read();
648 void MED_MED_WRONLY_DRIVER21::readFileStruct ( void ) throw (MEDEXCEPTION)
650 IMED_MED_WRONLY_DRIVER::readFileStruct();
653 // This method ask the drivers of all MESH/FIELD objects created from this MED driver
654 // to write themselves
655 void MED_MED_WRONLY_DRIVER21::writeFrom( void) const
656 throw (MEDEXCEPTION) //from object method write !
658 const char * LOC = "MED_MED_DRIVER21::writeFrom() : ";
662 const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
663 map<MESH_NAME_,MESH*>::const_iterator currentMesh;
665 const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
666 map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
668 for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
670 (*currentMesh).second->write(*this);
671 // On utilise pour les objects MESH ET FIELD le write(GENDRIVER *) et le == ds GENDRIVER avec eventuellement 1 id
673 catch ( const MED_DRIVER_NOT_FOUND_EXCEPTION & ex ) {
678 for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
680 (*currentField).first->write(*this);
682 catch ( const MED_DRIVER_NOT_FOUND_EXCEPTION & ex ) {
691 void MED_MED_WRONLY_DRIVER21::write(void ) const
692 throw (MEDEXCEPTION) // from object method write !
694 const char * LOC = "MED_MED_DRIVER21::write() : ";
699 // BCLE SUR LES OBJETS AVEC AJOUT DE DRIVER ET APPELS write
701 const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
702 map<MESH_NAME_,MESH*>::const_iterator currentMesh;
704 const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
705 map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
707 for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
708 //current = (*currentMesh).second->addDriver(MED_DRIVER,_fileName);
709 current = (*currentMesh).second->addDriver(MED_DRIVER,_fileName,(*currentMesh).second->getName());
710 // put right _id in Mesh driver (same as this._id)
711 (*currentMesh).second->_drivers[current]->setId( getId() );
712 //(*currentMesh).second->write(current) ;
715 for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
716 //current = (*currentField).first->addDriver(MED_DRIVER,_fileName);
717 current = (*currentField).first->addDriver(MED_DRIVER,_fileName,(*currentField).first->getName());
718 // put right _id in Field driver (same as this._id)
719 (*currentField).first->_drivers[current]->setId( getId() );
720 //(*currentField).first->write(current) ;
723 // that's work, but it is more efficenty to write directly when we had driver, no ?
730 // ------------- Read Write Part --------------
732 MED_MED_RDWR_DRIVER21::MED_MED_RDWR_DRIVER21()
735 MED_MED_RDWR_DRIVER21::MED_MED_RDWR_DRIVER21(const string & fileName, MED * const ptrMed):
736 MED_MED_RDONLY_DRIVER21(fileName,ptrMed),
737 MED_MED_WRONLY_DRIVER21(fileName,ptrMed),
738 IMED_MED_RDWR_DRIVER(fileName,ptrMed),
739 MED_MED_DRIVER21(fileName,ptrMed,MED_REMP),
740 IMED_MED_WRONLY_DRIVER(fileName,ptrMed),
741 IMED_MED_RDONLY_DRIVER(fileName,ptrMed),
742 MED_MED_DRIVER(fileName,ptrMed,MED_REMP)
745 MED_MED_RDWR_DRIVER21::MED_MED_RDWR_DRIVER21(const MED_MED_RDWR_DRIVER21 & driver):
746 MED_MED_RDONLY_DRIVER21(driver),
747 MED_MED_WRONLY_DRIVER21(driver),
748 IMED_MED_RDWR_DRIVER(driver),
749 MED_MED_DRIVER21(driver),
750 IMED_MED_WRONLY_DRIVER(driver),
751 IMED_MED_RDONLY_DRIVER(driver),
752 MED_MED_DRIVER(driver)
755 MED_MED_RDWR_DRIVER21::~MED_MED_RDWR_DRIVER21() {
756 MESSAGE("MED_MED_RDWR_DRIVER21::~MED_MED_RDWR_DRIVER21() has been destroyed");
759 GENDRIVER * MED_MED_RDWR_DRIVER21::copy(void) const
761 return new MED_MED_RDWR_DRIVER21(*this) ;
764 void MED_MED_RDWR_DRIVER21::read(void)
765 throw (MEDEXCEPTION) // from MED_MED_RDONLY_DRIVER::read()
767 BEGIN_OF("MED_MED_RDWR_DRIVER21::read(void)");
768 MED_MED_RDONLY_DRIVER21::read();
769 END_OF("MED_MED_RDWR_DRIVER21::read(void)");
772 void MED_MED_RDWR_DRIVER21::readFileStruct(void)
773 throw (MEDEXCEPTION) // from MED_MED_RDONLY_DRIVER::readFileStruct()
775 BEGIN_OF("MED_MED_RDWR_DRIVER21::readFileStruct(void)");
776 MED_MED_RDONLY_DRIVER21::readFileStruct();
777 END_OF("MED_MED_RDWR_DRIVER21::readFileStruct(void)");
780 void MED_MED_RDWR_DRIVER21::write(void) const
781 throw (MEDEXCEPTION) // from MED_MED_WRONLY_DRIVER::write()
783 BEGIN_OF("MED_MED_RDWR_DRIVER21::write(void) const");
784 MED_MED_WRONLY_DRIVER21::write();
785 END_OF("MED_MED_RDWR_DRIVER21::write(void) const");
788 void MED_MED_RDWR_DRIVER21::writeFrom(void) const
789 throw (MEDEXCEPTION) // from MED_MED_WRONLY_DRIVER::writeFrom();
791 BEGIN_OF("MED_MED_RDWR_DRIVER21::writeFrom(void) const");
792 MED_MED_WRONLY_DRIVER21::writeFrom();
793 END_OF("MED_MED_RDWR_DRIVER21::writeFrom(void) const");