3 # include "MEDMEM_MedMedDriver.hxx"
4 # include "MEDMEM_MedMeshDriver.hxx"
5 # include "MEDMEM_DriversDef.hxx"
7 # include "MEDMEM_Mesh.hxx"
8 # include "MEDMEM_Grid.hxx"
9 # include "MEDMEM_Field.hxx"
10 // EN ATTENDANT L'utilisation de MedFieldDriver.hxx ds Field.hxx
11 # include "MEDMEM_MedFieldDriver.hxx"
12 # include "MEDMEM_Med.hxx"
14 # include "MEDMEM_define.hxx"
17 using namespace MED_EN;
18 using namespace MEDMEM;
20 MED_MED_DRIVER::MED_MED_DRIVER(): GENDRIVER(),
21 _ptrMed((MED * const)MED_NULL),_medIdt(MED_INVALID)
24 MED_MED_DRIVER::MED_MED_DRIVER(const string & fileName, MED * const ptrMed):
25 GENDRIVER(fileName,MED_EN::MED_RDWR), _ptrMed(ptrMed), _medIdt(MED_INVALID)
27 //_ptrMed->addDriver(*this); // The specific MED driver id is set within the addDriver method.
30 MED_MED_DRIVER::MED_MED_DRIVER(const string & fileName,
32 MED_EN::med_mode_acces accessMode):
33 GENDRIVER(fileName,accessMode), _ptrMed(ptrMed), _medIdt(MED_INVALID)
36 //REM : As t'on besoin du champ _status : _medIdt <-> _status ? Oui
38 MED_MED_DRIVER::MED_MED_DRIVER(const MED_MED_DRIVER & driver):
40 _ptrMed(driver._ptrMed),
45 MED_MED_DRIVER::~MED_MED_DRIVER()
47 MESSAGE("MED_MED_DRIVER::~MED_MED_DRIVER() has been destroyed");
50 // GENDRIVER * MED_MED_DRIVER::copy(void) const
52 // return new MED_MED_DRIVER(*this) ;
54 void MED_MED_DRIVER::read()
57 void MED_MED_DRIVER::readFileStruct()
60 void MED_MED_DRIVER::write() const
63 GENDRIVER * MED_MED_DRIVER::copy(void) const
65 return new MED_MED_DRIVER(*this) ;
67 void MED_MED_DRIVER::writeFrom() const
73 void MED_MED_DRIVER::open()
77 const char * LOC ="MED_MED_DRIVER::open() : ";
80 // REFLECHIR SUR CE TEST PAR RAPPORT A L'OUVERTURE/FERMETURE
81 // if ( _medIdt != MED_INVALID )
82 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
83 // << "_medIdt is already in use, please close the file |"
84 // << _fileName << "| before calling open()"
88 // if ( _status != MED_CLOSED )
89 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
90 // << "_status is closed, please close the file |"
91 // << _fileName << "| before calling open()"
95 if ( _fileName == "" )
96 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
97 << "_fileName is |\"\"|, please set a correct fileName before calling open()"
101 MESSAGE(LOC<<"_fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode);
102 _medIdt = MEDouvrir( (const_cast <char *> (_fileName.c_str())), (med_2_1::med_mode_acces) _accessMode);
103 MESSAGE(LOC<<" _medIdt = "<<_medIdt);
108 _status = MED_CLOSED;
109 _medIdt = MED_INVALID;
110 throw MED_EXCEPTION (LOCALIZED( STRING(LOC)
111 << "Can't open |" << _fileName
112 << "|, _medIdt : " << _medIdt
121 void MED_MED_DRIVER::close()
123 med_2_1::med_int err = 0;
124 const char * LOC = "MED_MED_DRIVER::close() : ";
127 // if ( _status == MED_CLOSED)
128 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": the file |"
129 // << _fileName << "| is already closed"
133 // if ( _medIdt == MED_INVALID )
134 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "_medIdt invalid, but the file |"
135 // << _fileName << "| seems to be openned !"
139 if ( _medIdt != MED_INVALID )
140 err=med_2_1::MEDfermer(_medIdt);
142 // if (err != MED_VALID)
143 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "the file |"
144 // << _fileName << "| couldn't be closed"
148 _status = MED_CLOSED;
149 _medIdt = MED_INVALID;
155 // ------------- Read Only Part --------------
157 MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER():MED_MED_DRIVER()
161 MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const string & fileName, MED * const ptrMed):
162 MED_MED_DRIVER(fileName,ptrMed,MED_EN::MED_RDONLY)
164 MESSAGE("MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const string & fileName, MED * const ptrMed) Constructeur read only");
167 MED_MED_RDONLY_DRIVER::MED_MED_RDONLY_DRIVER(const MED_MED_RDONLY_DRIVER & driver):
168 MED_MED_DRIVER(driver)
172 MED_MED_RDONLY_DRIVER::~MED_MED_RDONLY_DRIVER()
174 MESSAGE("MED_MED_RDONLY_DRIVER::~MED_MED_RDONLY_DRIVER() has been destroyed");
177 GENDRIVER * MED_MED_RDONLY_DRIVER::copy(void) const
179 return new MED_MED_RDONLY_DRIVER(*this) ;
182 void MED_MED_RDONLY_DRIVER::readFileStruct( void )
185 const char * LOC = "MED_MED_DRIVER::readFileStruct() : ";
190 if ( _medIdt == MED_INVALID )
191 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
192 << "_medIdt is invalid, please open the file |"
193 << _fileName << "| before calling readFileStruct()"
196 // Read number of meshes and their associated name
199 char meshName[MED_TAILLE_NOM+1]="";
200 med_2_1::med_int meshDim;
202 // MED_MESH_RDWR_DRIVER * ptrDriver; !! UNUSED VARIABLE !!
204 numberOfMeshes = med_2_1::MEDnMaa(_medIdt) ;
205 if ( numberOfMeshes <= 0 )
206 MESSAGE(LOC << "Be careful there is no mesh in file |"<<_fileName<<"| !");
208 MESH_ENTITIES::const_iterator currentEntity;
209 for (i=1;i<=numberOfMeshes;i++) {
211 // find out if the mesh is a Grid
213 med_2_1::med_int isAGrid = false;
214 med_2_1::med_grid_type type;
216 err = MEDgridInfo (_medIdt, i, &isAGrid, &type);
217 if (err != MED_VALID)
218 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "error in MEDgridInfo()") );
220 err = med_2_1::MEDmaaInfo(_medIdt, i ,meshName, &meshDim) ;
221 if (err != MED_VALID)
222 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": can't get information about the mesh n°"
223 << i <<" of the file |" << _fileName << "| !"
226 MESSAGE(LOC<<": Mesh n°"<<i<<" nammed "<<meshName);
229 ptrMesh = new GRID((MED_EN::med_grid_type) type);
231 ptrMesh = new MESH();
233 //MED_MESH_RDWR_DRIVER * _ptrDriver = new MED_MESH_RDWR_DRIVER(_fileName, ptrMesh);
234 MED_EN::med_mode_acces myMode = getAccessMode();
235 MED_MESH_DRIVER * ptrDriver ;
237 case MED_EN::MED_LECT:
238 ptrDriver = new MED_MESH_RDONLY_DRIVER(_fileName, ptrMesh);
240 case MED_EN::MED_REMP:
241 ptrDriver = new MED_MESH_RDWR_DRIVER(_fileName, ptrMesh);
243 case MED_EN::MED_ECRI: // should never append !!
244 ptrDriver = new MED_MESH_RDONLY_DRIVER(_fileName, ptrMesh);
247 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
249 ptrDriver->setId ( getId() );
250 ptrDriver->setMeshName ( meshName );
251 ptrMesh->addDriver(*ptrDriver);
255 _ptrMed->_meshes[meshName] = (MESH *) ptrMesh;
257 _ptrMed->_meshes[meshName] = ptrMesh;
259 ptrMesh->setName(meshName);
263 MESSAGE(LOC<<"is" << (isAGrid ? "" : " NOT") << " a GRID and its name is "<<ptrMesh->getName());
265 // we create all global support (for each entity type :
267 for (currentEntity=meshEntities.begin();currentEntity != meshEntities.end(); currentEntity++) {
268 string supportName="SupportOnAll_" ;
269 supportName+=entNames[(*currentEntity).first] ;
270 //(_ptrMed->_support)[meshName][(MED_EN::medEntityMesh)(*currentEntity).first]=new SUPPORT(ptrMesh,supportName,(MED_EN::medEntityMesh) (*currentEntity).first) ;
271 SUPPORT* mySupport = new SUPPORT() ;
272 mySupport->setName(supportName);
273 mySupport->setMesh(ptrMesh);
274 mySupport->setEntity((MED_EN::medEntityMesh) (*currentEntity).first);
275 mySupport->setAll(true);
276 (_ptrMed->_support)[meshName][(MED_EN::medEntityMesh)(*currentEntity).first] = mySupport ;
277 MESSAGE(LOC<< "The support " << supportName.c_str() << " on entity " << (*currentEntity).first << " is built");
280 MESSAGE(LOC <<"The mesh " <<ptrMesh->getName() << " has " << index << " support(s)");
283 map<MESH_NAME_, map<MED_EN::medEntityMesh,SUPPORT *> >::const_iterator const_itSupportOnMesh ;
287 vector<SUPPORT *> vectSupp;
288 for (const_itSupportOnMesh=_ptrMed->_support.begin(); const_itSupportOnMesh != _ptrMed->_support.end();
289 const_itSupportOnMesh++ )
291 map<MED_EN::medEntityMesh,SUPPORT *>::const_iterator const_itSupport ;
292 for (const_itSupport=(*const_itSupportOnMesh).second.begin();
293 const_itSupport!=(*const_itSupportOnMesh).second.end();const_itSupport++) index++;
296 MESSAGE(LOC << "In this MED object there is(are) " << index << " support(s):");
298 vectSupp.resize(index);
301 for (const_itSupportOnMesh=_ptrMed->_support.begin(); const_itSupportOnMesh != _ptrMed->_support.end();
302 const_itSupportOnMesh++ )
304 map<MED_EN::medEntityMesh,SUPPORT *>::const_iterator const_itSupport ;
305 for (const_itSupport=(*const_itSupportOnMesh).second.begin();
306 const_itSupport!=(*const_itSupportOnMesh).second.end();const_itSupport++)
308 vectSupp[index] = (*const_itSupport).second;
309 SCRUTE(vectSupp[index]);
310 MESSAGE(LOC << "Support number " << index << " is "<< *vectSupp[index]);
318 // Read number of fields, their associated name and their list of (timeStepNumber,iterationNumber)
320 int numberOfFields = 0; //MED_INVALID
321 // char fieldName[MED_TAILLE_NOM+1] = "";
322 char fieldName[MED_TAILLE_NOM+1] ;
323 int numberOfComponents = 0;
324 char * componentName = (char *) MED_NULL;
325 char * unitName = (char *) MED_NULL;
326 // char meshName[MED_TAILLE_NOM+1] = "";
327 char meshName[MED_TAILLE_NOM+1] ;
328 med_2_1::med_type_champ type;
329 MESH * ptrMesh = (MESH *) MED_NULL;
330 FIELD_ * ptrField = (FIELD_ *) MED_NULL;
331 //MED_FIELD_RDWR_DRIVER * ptrDriver = (MED_FIELD_RDWR_DRIVER * ) MED_NULL;
332 GENDRIVER * ptrDriver = (GENDRIVER * ) MED_NULL;
333 SUPPORT * ptrSupport = (SUPPORT * ) MED_NULL;
334 MESH_ENTITIES::const_iterator currentEntity;
335 list<MED_EN::medGeometryElement>::const_iterator currentGeometry;
336 med_2_1::med_int NbOfGaussPts = 0;
337 int numberOfTimeSteps = -1;
338 med_2_1::med_int timeStepNumber = -1;
339 // char timeStepUnit[MED_TAILLE_PNOM]= "";
340 char timeStepUnit[MED_TAILLE_PNOM+1] ;
341 double timeStep = 0.0;
342 med_2_1::med_int orderNumber = -1; //???init?????
343 map<MESH_NAME_,MESH*> & _meshes = _ptrMed->_meshes;
344 map<FIELD_NAME_,MAP_DT_IT_> & _fields = _ptrMed->_fields;
345 map<FIELD_ *, MESH_NAME_> & _meshName = _ptrMed->_meshName;
346 map<MESH_NAME_, map<MED_EN::medEntityMesh,SUPPORT *> > & _support = _ptrMed->_support;
349 numberOfFields = med_2_1::MEDnChamp(_medIdt,0) ;
350 if ( numberOfFields <= 0 )
351 MESSAGE(LOC << "Be careful there is no field in file |"<<_fileName<<"| !");
353 for (i=1;i<=numberOfFields;i++) {
355 numberOfComponents = med_2_1::MEDnChamp(_medIdt,i) ;
356 if ( numberOfComponents <= 0 )
357 if (err != MED_VALID)
358 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "Be careful there is no compound for field n°"
359 << i << "in file |"<<_fileName<<"| !"));
361 componentName = new char[numberOfComponents*MED_TAILLE_PNOM+1] ;
362 unitName = new char[numberOfComponents*MED_TAILLE_PNOM+1] ;
364 err = MEDchampInfo(_medIdt, i, fieldName, &type, componentName,
365 unitName, numberOfComponents) ;
367 if (err != MED_VALID)
368 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
369 << ": can't get information about the field n°"
370 << i <<" of the file |" << _fileName << "| !"));
372 MESSAGE(LOC << "Field n°"<<i<<" nammed "<< fieldName
373 << " ,component(s) : " << componentName
374 <<" ,unit(s) : " << unitName);
377 // Loop on all (entity type,geometry type) until you find an existing one then
378 // get the (n°dt,n°it) pairs list for the current (field,entity type,geometry type)
379 // We suppose there is the same list whatever the existing (entity type,geometry type) pair
381 for (currentEntity=meshEntities.begin();currentEntity != meshEntities.end(); currentEntity++) {
382 // numberOfTimeSteps MUST be given by MEDchampInfo !!!!!
383 for (currentGeometry = (*currentEntity).second.begin();currentGeometry != (*currentEntity).second.end(); currentGeometry++) {
384 MESSAGE("Field information with Entity,Geom = "<<(*currentEntity).first<<","<<(*currentGeometry));
385 numberOfTimeSteps = MEDnPasdetemps(_medIdt, fieldName,
386 (med_2_1::med_entite_maillage)(*currentEntity).first,
387 (med_2_1::med_geometrie_element) (*currentGeometry) );
388 MESSAGE("Field information 2 : NumberOfTimeStep :"<<numberOfTimeSteps);
389 if ( numberOfTimeSteps > MED_VALID )
390 break ; // There are value for some med_geometrie_element of this med_entite_maillage.
392 if (numberOfTimeSteps>0) // we have at least one
394 for (currentGeometry = (*currentEntity).second.begin();currentGeometry != (*currentEntity).second.end(); currentGeometry++) {
396 MESSAGE("Field information 3 : Geom : "<<(*currentGeometry));
397 for (j=1;j <= numberOfTimeSteps; j++) {
399 MESSAGE("Field information 4 : time step j = "<<j);
400 err = MEDpasdetempsInfo( _medIdt, fieldName,
401 (med_2_1::med_entite_maillage) (*currentEntity).first,
402 (med_2_1::med_geometrie_element) (*currentGeometry),j,
403 meshName, &NbOfGaussPts,
404 &timeStepNumber, timeStepUnit, &timeStep,
406 if (err == MED_VALID) { // we have found for (*currentEntity).first and (*currentGeometry)
408 MESSAGE("Field information 5 ;: NumberOfGaussPoint : "<<NbOfGaussPts<<", timeStepNumber : "<<timeStepNumber);
409 // CORRECT a bug in MEDpasdetempsInfo :
410 // we get a value n'importe quoi in NbOfGaussPts !!!!
412 if (NbOfGaussPts>100)
414 if (timeStepNumber<0)
418 // ATTENTION TRAITER L'EXCEPTION !!!!!!!!!!!!
420 // Il faudra traiter le cas d'un champ qui utilise +sieurs (entity,geom) voir le travail de patrick
421 // Il faudra traiter le cas des profils...
422 // ptrField = new FIELD();
423 // _ptrDriver = new MED_FIELD_RDWR_DRIVER(_fileName, ptrField);
424 // ptrField->addDriver(_ptrDriver);
425 // _fields[fieldName]=ptrField;
427 // Verify meshName is already known
429 map<MESH_NAME_,MESH*>::iterator _meshesIt = _meshes.find(meshName);
430 if ( _meshesIt == _meshes.end() ) {
431 MESSAGE(LOC << "There is no mesh |"
432 << meshName <<"| in the file |"
433 << _fileName <<"|, but |" << meshName <<"| is referenced by field |"
434 << fieldName <<"|, entity : |"
435 << entNames [(*currentEntity).first] <<"|, geometric element of type |"
436 << geoNames [(*currentGeometry)] <<"|"
438 } // POURQUOI SI JE NE MET PAS DE BLOCK J'AI UN PARSE ERROR : PG : c'est la macro MESSAGE qui fait ca !
440 ptrMesh = _meshes[meshName];
442 ptrSupport = _support[meshName][(med_2_1::med_entite_maillage) (*currentEntity).first];
443 if (NbOfGaussPts != 1)
444 throw MEDEXCEPTION(LOCALIZED( STRING(LOC) <<"Number of Gauss Point must be equal to 1 for instance")) ;
446 // init to null to prevent some error if not correctly allocated !
447 ptrField = (FIELD_*)NULL ;
448 ptrDriver = (GENDRIVER*)NULL ;
451 case med_2_1::MED_INT64 :
452 if ( sizeof(med_2_1::med_int) != 8 )
453 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) <<
454 " The Field type of |"
455 << fieldName <<"|, entity : |"
456 << entNames [(*currentEntity).first] <<"|, geometric element of type |"
457 << geoNames [(*currentGeometry) ] <<
458 "| is MED_INT64 but size of med_int is not equal to 8 bytes !"
462 case med_2_1::MED_INT32 : {
463 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) <<
464 // "NOT IMPLEMENTED : BUG IN STL !")
466 // ptrField = new FIELD<med_2_1::med_int> ( ptrSupport,numberOfComponents ); // Les valeurs du champ ne doivent pas être lue pour l'instant
468 ptrField = new FIELD<int> ( ); // Les valeurs du champ ne doivent pas être lue pour l'instant
469 ((FIELD<int>*) ptrField)->setSupport(ptrSupport);
470 ((FIELD<int>*) ptrField)->setNumberOfComponents(numberOfComponents);
471 ((FIELD<int>*) ptrField)->setName(fieldName) ; //provisoire, pour debug
472 MESSAGE("#### SET NAME in FIELD : "<<fieldName);
474 MED_EN::med_mode_acces myMode = getAccessMode();
476 case MED_EN::MED_LECT:
477 ptrDriver = new MED_FIELD_RDONLY_DRIVER<int>(_fileName, (FIELD<int> *)ptrField);
479 case MED_EN::MED_REMP:
480 ptrDriver = new MED_FIELD_RDWR_DRIVER<int>(_fileName, (FIELD<int> *)ptrField);
482 case MED_EN::MED_ECRI: // should never append !!
483 ptrDriver = new MED_FIELD_RDONLY_DRIVER<int>(_fileName, (FIELD<int> *)ptrField);
486 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
490 case med_2_1::MED_REEL64 : {
491 // ptrField = new FIELD<med_2_1::med_float> ( ptrSupport,numberOfComponents ); // Les valeurs du champ ne doivent pas être lue pour l'instant
492 ptrField = new FIELD<med_2_1::med_float> ( ); // Les valeurs du champ ne doivent pas être lue pour l'instant
493 ((FIELD<med_2_1::med_float>*) ptrField)->setSupport(ptrSupport);
494 ((FIELD<med_2_1::med_float>*) ptrField)->setNumberOfComponents(numberOfComponents);
495 ((FIELD<med_2_1::med_float>*) ptrField)->setName(fieldName) ; //provisoire, pour debug
496 MESSAGE("#### SET NAME in FIELD : "<<fieldName);
498 MED_EN::med_mode_acces myMode = getAccessMode();
500 case MED_EN::MED_LECT:
501 ptrDriver = new MED_FIELD_RDONLY_DRIVER<med_2_1::med_float>(_fileName, (FIELD<med_2_1::med_float> *)ptrField);
503 case MED_EN::MED_REMP:
504 ptrDriver = new MED_FIELD_RDWR_DRIVER<med_2_1::med_float>(_fileName, (FIELD<med_2_1::med_float> *)ptrField);
506 case MED_EN::MED_ECRI: // should never append !!
507 ptrDriver = new MED_FIELD_RDONLY_DRIVER<med_2_1::med_float>(_fileName, (FIELD<med_2_1::med_float> *)ptrField);
510 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
515 if ( numberOfTimeSteps > 1)
516 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) <<
517 " The Field type of |"
518 << fieldName <<"|, entity : |"
519 << entNames [(*currentEntity).first]
520 <<"|, geometric element of type |"
521 << geoNames [(*currentGeometry)]
522 <<"| is neither MED_INT, MED_INT32, MED_INT64 nor MED_REEL64 !"
528 ptrField->setValueType((MED_EN::med_type_champ) type) ; // need to write field !
530 MESSAGE("timeStepNumber :"<<timeStepNumber<<",orderNumber :"<<orderNumber);
531 ptrField->setIterationNumber ( timeStepNumber); // A ajouter dans la classe FIELD
532 ptrField->setOrderNumber ( orderNumber);
533 ptrField->setTime ( timeStep);
535 // Create a driver for this (field n°dt,n°it)
536 ptrDriver->setId ( getId() );
537 MESSAGE("###### ptrDriver->setFieldName : #"<<fieldName<<"#");
538 ptrDriver->setFieldName(fieldName);
539 ptrField->addDriver(*ptrDriver);
540 // driver is duplicated : remove it
544 dtIt.dt = timeStepNumber;
545 dtIt.it = orderNumber;
547 (_fields [fieldName])[dtIt] = ptrField;
548 _meshName[ptrField ] = meshName;
553 delete[] componentName ;
558 // read profil count and their names
559 // int support_count_= 0 ; !! UNUSED VARIABLE !!
560 // il faut lire les champs pour avoir les profils stockes !!!
561 // il faudrait implémenter la lecture des profils dans med !!!
567 // This method ask the drivers of all MESH/FIELD objects created from this MED driver
568 // to read themselves
569 void MED_MED_RDONLY_DRIVER::read( void )
570 throw (MEDEXCEPTION) // from objects method read !
572 const char * LOC = "MED_MED_DRIVER::read() : ";
576 const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
577 map<MESH_NAME_,MESH*>::const_iterator currentMesh;
579 const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
580 map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
582 for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ )
583 (*currentMesh).second->read(*this);
584 //(*currentMesh).second->read(); // default reader, from readFileStruct
587 _ptrMed->updateSupport() ;
589 for ( currentField =_meshName.begin(); currentField != _meshName.end(); currentField++ )
590 (*currentField).first->read(*this);
591 //(*currentField).first->read(); // default reader, from readFileStruct
596 void MED_MED_RDONLY_DRIVER::write(void) const
599 throw MEDEXCEPTION("MED_MED_RDONLY_DRIVER::write : Can't write with a RDONLY driver !");
602 void MED_MED_RDONLY_DRIVER::writeFrom(void) const
605 throw MEDEXCEPTION("MED_MED_RDONLY_DRIVER::writeFrom : Can't write with a RDONLY driver !");
608 // ------------- Write Only Part --------------
610 MED_MED_WRONLY_DRIVER::MED_MED_WRONLY_DRIVER():MED_MED_DRIVER()
614 MED_MED_WRONLY_DRIVER::MED_MED_WRONLY_DRIVER(const string & fileName, MED * const ptrMed):
615 MED_MED_DRIVER(fileName,ptrMed)
618 MED_MED_WRONLY_DRIVER::MED_MED_WRONLY_DRIVER(const MED_MED_WRONLY_DRIVER & driver):
619 MED_MED_DRIVER(driver)
622 MED_MED_WRONLY_DRIVER::~MED_MED_WRONLY_DRIVER()
624 MESSAGE("MED_MED_WRONLY_DRIVER::~MED_MED_WRONLY_DRIVER() has been destroyed");
627 GENDRIVER * MED_MED_WRONLY_DRIVER::copy(void) const
629 return new MED_MED_WRONLY_DRIVER(*this) ;
632 void MED_MED_WRONLY_DRIVER::read(void)
635 throw MEDEXCEPTION("MED_MED_WRONLY_DRIVER::read : Can't read with a WRONLY driver !");
638 void MED_MED_WRONLY_DRIVER::readFileStruct(void)
641 throw MEDEXCEPTION("MED_MED_WRONLY_DRIVER::read : Can't read with a WRONLY driver !");
644 // This method ask the drivers of all MESH/FIELD objects created from this MED driver
645 // to write themselves
646 void MED_MED_WRONLY_DRIVER::writeFrom( void) const
647 throw (MEDEXCEPTION) //from object method write !
649 const char * LOC = "MED_MED_DRIVER::writeFrom() : ";
653 const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
654 map<MESH_NAME_,MESH*>::const_iterator currentMesh;
656 const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
657 map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
659 for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
661 (*currentMesh).second->write(*this);
662 // On utilise pour les objects MESH ET FIELD le write(GENDRIVER *) et le == ds GENDRIVER avec eventuellement 1 id
664 catch ( const MED_DRIVER_NOT_FOUND_EXCEPTION & ex ) {
669 for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
671 (*currentField).first->write(*this);
673 catch ( const MED_DRIVER_NOT_FOUND_EXCEPTION & ex ) {
682 void MED_MED_WRONLY_DRIVER::write(void ) const
683 throw (MEDEXCEPTION) // from object method write !
685 const char * LOC = "MED_MED_DRIVER::write() : ";
690 // BCLE SUR LES OBJETS AVEC AJOUT DE DRIVER ET APPELS write
692 const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
693 map<MESH_NAME_,MESH*>::const_iterator currentMesh;
695 const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
696 map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
698 for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
699 //current = (*currentMesh).second->addDriver(MED_DRIVER,_fileName);
700 current = (*currentMesh).second->addDriver(MED_DRIVER,_fileName,(*currentMesh).second->getName());
701 // put right _id in Mesh driver (same as this._id)
702 (*currentMesh).second->_drivers[current]->setId( getId() );
703 //(*currentMesh).second->write(current) ;
706 for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
707 //current = (*currentField).first->addDriver(MED_DRIVER,_fileName);
708 current = (*currentField).first->addDriver(MED_DRIVER,_fileName,(*currentField).first->getName());
709 // put right _id in Field driver (same as this._id)
710 (*currentField).first->_drivers[current]->setId( getId() );
711 //(*currentField).first->write(current) ;
714 // that's work, but it is more efficenty to write directly when we had driver, no ?
721 // ------------- Read Write Part --------------
723 MED_MED_RDWR_DRIVER::MED_MED_RDWR_DRIVER()
726 MED_MED_RDWR_DRIVER::MED_MED_RDWR_DRIVER(const string & fileName, MED * const ptrMed):
727 MED_MED_DRIVER(fileName,ptrMed)
730 MED_MED_RDWR_DRIVER::MED_MED_RDWR_DRIVER(const MED_MED_RDWR_DRIVER & driver):
731 MED_MED_DRIVER(driver)
734 MED_MED_RDWR_DRIVER::~MED_MED_RDWR_DRIVER() {
735 MESSAGE("MED_MED_RDWR_DRIVER::~MED_MED_RDWR_DRIVER() has been destroyed");
738 GENDRIVER * MED_MED_RDWR_DRIVER::copy(void) const
740 return new MED_MED_RDWR_DRIVER(*this) ;
743 void MED_MED_RDWR_DRIVER::read(void)
744 throw (MEDEXCEPTION) // from MED_MED_RDONLY_DRIVER::read()
746 BEGIN_OF("MED_MED_RDWR_DRIVER::read(void)");
747 MED_MED_RDONLY_DRIVER::read();
748 END_OF("MED_MED_RDWR_DRIVER::read(void)");
751 void MED_MED_RDWR_DRIVER::readFileStruct(void)
752 throw (MEDEXCEPTION) // from MED_MED_RDONLY_DRIVER::readFileStruct()
754 BEGIN_OF("MED_MED_RDWR_DRIVER::readFileStruct(void)");
755 MED_MED_RDONLY_DRIVER::readFileStruct();
756 END_OF("MED_MED_RDWR_DRIVER::readFileStruct(void)");
759 void MED_MED_RDWR_DRIVER::write(void) const
760 throw (MEDEXCEPTION) // from MED_MED_WRONLY_DRIVER::write()
762 BEGIN_OF("MED_MED_RDWR_DRIVER::write(void) const");
763 MED_MED_WRONLY_DRIVER::write();
764 END_OF("MED_MED_RDWR_DRIVER::write(void) const");
767 void MED_MED_RDWR_DRIVER::writeFrom(void) const
768 throw (MEDEXCEPTION) // from MED_MED_WRONLY_DRIVER::writeFrom();
770 BEGIN_OF("MED_MED_RDWR_DRIVER::writeFrom(void) const");
771 MED_MED_WRONLY_DRIVER::writeFrom();
772 END_OF("MED_MED_RDWR_DRIVER::writeFrom(void) const");