1 #include "MEDMEM_Compatibility21_22.hxx"
2 # include "MEDMEM_MedMedDriver22.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"
15 using namespace MED_EN;
16 using namespace MEDMEM;
18 MED_MED_DRIVER22::MED_MED_DRIVER22(): _medIdt(MED_INVALID)
21 MED_MED_DRIVER22::MED_MED_DRIVER22(const string & fileName, MED * const ptrMed):
22 MED_MED_DRIVER(fileName,ptrMed), _medIdt(MED_INVALID)
24 //_ptrMed->addDriver(*this); // The specific MED driver id is set within the addDriver method.
27 MED_MED_DRIVER22::MED_MED_DRIVER22(const string & fileName,
29 MED_EN::med_mode_acces accessMode):
30 MED_MED_DRIVER(fileName,ptrMed,accessMode), _medIdt(MED_INVALID)
33 //REM : As t'on besoin du champ _status : _medIdt <-> _status ? Oui
35 MED_MED_DRIVER22::MED_MED_DRIVER22(const MED_MED_DRIVER22 & driver):
36 MED_MED_DRIVER(driver), _medIdt(MED_INVALID)
40 MED_MED_DRIVER22::~MED_MED_DRIVER22()
42 MESSAGE("MED_MED_DRIVER22::~MED_MED_DRIVER22() has been destroyed");
45 // GENDRIVER * MED_MED_DRIVER::copy(void) const
47 // return new MED_MED_DRIVER(*this) ;
49 void MED_MED_DRIVER22::read()
52 void MED_MED_DRIVER22::readFileStruct()
55 void MED_MED_DRIVER22::write() const
58 GENDRIVER * MED_MED_DRIVER22::copy(void) const
60 return new MED_MED_DRIVER22(*this) ;
62 void MED_MED_DRIVER22::writeFrom() const
68 void MED_MED_DRIVER22::open()
72 const char * LOC ="MED_MED_DRIVER22::open() : ";
75 // REFLECHIR SUR CE TEST PAR RAPPORT A L'OUVERTURE/FERMETURE
76 // if ( _medIdt != MED_INVALID )
77 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
78 // << "_medIdt is already in use, please close the file |"
79 // << _fileName << "| before calling open()"
83 // if ( _status != MED_CLOSED )
84 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
85 // << "_status is closed, please close the file |"
86 // << _fileName << "| before calling open()"
90 if ( _fileName == "" )
91 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
92 << "_fileName is |\"\"|, please set a correct fileName before calling open()"
96 MESSAGE(LOC<<"_fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode);
98 _medIdt = med_2_2::MEDouvrir( (const_cast <char *> (_fileName.c_str())), (med_2_2::med_mode_acces) _accessMode);
99 MESSAGE(LOC<<" _medIdt = "<<_medIdt);
104 _status = MED_CLOSED;
105 _medIdt = MED_INVALID;
106 throw MED_EXCEPTION (LOCALIZED( STRING(LOC)
107 << "Can't open |" << _fileName
108 << "|, _medIdt : " << _medIdt
117 void MED_MED_DRIVER22::close()
119 med_2_2::med_int err = 0;
120 const char * LOC = "MED_MED_DRIVER22::close() : ";
123 // if ( _status == MED_CLOSED)
124 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": the file |"
125 // << _fileName << "| is already closed"
129 // if ( _medIdt == MED_INVALID )
130 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "_medIdt invalid, but the file |"
131 // << _fileName << "| seems to be openned !"
135 if ( _medIdt != MED_INVALID )
136 err=med_2_2::MEDfermer(_medIdt);
138 // if (err != MED_VALID)
139 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "the file |"
140 // << _fileName << "| couldn't be closed"
144 _status = MED_CLOSED;
145 _medIdt = MED_INVALID;
151 // ------------- Read Only Part --------------
153 MED_MED_RDONLY_DRIVER22::MED_MED_RDONLY_DRIVER22()
157 MED_MED_RDONLY_DRIVER22::MED_MED_RDONLY_DRIVER22(const string & fileName, MED * const ptrMed):
158 IMED_MED_RDONLY_DRIVER(fileName,ptrMed),MED_MED_DRIVER22(fileName,ptrMed,MED_EN::MED_RDONLY),MED_MED_DRIVER(fileName,ptrMed,MED_EN::MED_RDONLY)
160 MESSAGE("MED_MED_RDONLY_DRIVER22::MED_MED_RDONLY_DRIVER22(const string & fileName, MED * const ptrMed) Constructeur read only");
163 MED_MED_RDONLY_DRIVER22::MED_MED_RDONLY_DRIVER22(const MED_MED_RDONLY_DRIVER22 & driver):
164 IMED_MED_RDONLY_DRIVER(driver) ,MED_MED_DRIVER22(driver),MED_MED_DRIVER(driver)
168 MED_MED_RDONLY_DRIVER22::~MED_MED_RDONLY_DRIVER22()
170 MESSAGE("MED_MED_RDONLY_DRIVER22::~MED_MED_RDONLY_DRIVER22() has been destroyed");
173 GENDRIVER * MED_MED_RDONLY_DRIVER22::copy(void) const
175 return new MED_MED_RDONLY_DRIVER22(*this) ;
178 void MED_MED_RDONLY_DRIVER22::write ( void ) const throw (MEDEXCEPTION)
180 IMED_MED_RDONLY_DRIVER::write();
183 void MED_MED_RDONLY_DRIVER22::writeFrom ( void ) const throw (MEDEXCEPTION)
185 IMED_MED_RDONLY_DRIVER::writeFrom();
188 void MED_MED_RDONLY_DRIVER22::readFileStruct( void )
191 const char * LOC = "MED_MED_DRIVER22::readFileStruct() : ";
196 if ( _medIdt == MED_INVALID )
197 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
198 << "_medIdt is invalid, please open the file |"
199 << _fileName << "| before calling readFileStruct()"
202 // Read number of meshes and their associated name
205 char meshName[MED_TAILLE_NOM+1]="";
206 char meshDescription[MED_TAILLE_DESC+1]="";
208 med_2_2::med_maillage meshType;
211 // MED_MESH_RDWR_DRIVER * ptrDriver; !! UNUSED VARIABLE !!
213 numberOfMeshes = med_2_2::MEDnMaa(_medIdt) ;
214 if ( numberOfMeshes <= 0 )
215 MESSAGE(LOC << "Be careful there is no mesh in file |"<<_fileName<<"| !");
217 MESH_ENTITIES::const_iterator currentEntity;
218 for (i=1;i<=numberOfMeshes;i++)
220 //get infoamation on the i^th mesh
222 err = MEDmaaInfo(_medIdt, i ,meshName, &meshDim, &meshType,
225 if (err != MED_VALID)
226 throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << ": can't get information about the mesh n°" << i << " of the file |" << _fileName << "| !"));
230 case med_2_2::MED_STRUCTURE:
231 MESSAGE(LOC<<": Mesh n°"<< i <<" nammed "<< meshName << " with the description " << meshDescription << " is structured");
233 med_2_2::med_type_grille type;
235 err = MEDnatureGrilleLire(_medIdt, meshName, &type);
237 if (err != MED_VALID)
238 throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << ": can't get the nature of the grid which is the mesh n°" << i << " of the file |" << _fileName << "| !"));
240 ptrMesh = new GRID((MED_EN::med_grid_type) type);
242 case med_2_2::MED_NON_STRUCTURE:
243 MESSAGE(LOC<<": Mesh n°"<< i <<" nammed "<< meshName << " with the description " << meshDescription << " is not structured");
245 ptrMesh = new MESH();
248 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mesh type !"));
251 bool isAGrid = ptrMesh->getIsAGrid();
254 MED_EN::med_mode_acces myMode = getAccessMode();
255 // MED_MESH_DRIVER * ptrDriver ;
257 // case MED_EN::MED_LECT: // V2_1->V2_2
258 // ptrDriver = new MED_MESH_RDONLY_DRIVER(_fileName, ptrMesh);
260 // case MED_EN::MED_REMP: // V2_1->V2_2
261 // ptrDriver = new MED_MESH_RDWR_DRIVER(_fileName, ptrMesh);
263 // case MED_EN::MED_ECRI: // should never append !! V2_1->V2_2
264 // ptrDriver = new MED_MESH_WRONLY_DRIVER(_fileName, ptrMesh);
267 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
270 GENDRIVER * ptrDriver =
271 DRIVERFACTORY::buildConcreteMedDriverForMesh(_fileName, ptrMesh,
272 meshName, myMode, V22);
274 ptrDriver->setId ( getId() );
275 ptrDriver->setMeshName ( meshName );
276 ptrMesh->addDriver(*ptrDriver);
280 _ptrMed->_meshes[meshName] = (MESH *) ptrMesh;
282 _ptrMed->_meshes[meshName] = ptrMesh;
284 // _ptrMed->_meshes[meshName] = ptrMesh;
286 ptrMesh->setName(meshName);
288 ptrMesh->setDescription(meshDescription);
292 MESSAGE(LOC<<"is" << (isAGrid ? "" : " NOT") << " a GRID and its name is "<<ptrMesh->getName());
294 // we create all global support (for each entity type :
296 for (currentEntity=meshEntities.begin();currentEntity != meshEntities.end(); currentEntity++) {
297 string supportName="SupportOnAll_" ;
298 supportName+=entNames[(MED_EN::medEntityMesh)(*currentEntity).first] ;
299 SUPPORT* mySupport = new SUPPORT() ;
300 mySupport->setName(supportName);
301 mySupport->setMesh(ptrMesh);
302 mySupport->setEntity((MED_EN::medEntityMesh) (*currentEntity).first);
303 mySupport->setAll(true);
304 (_ptrMed->_support)[meshName][(MED_EN::medEntityMesh)(*currentEntity).first] = mySupport ;
305 MESSAGE(LOC<< "The support " << supportName.c_str() << " on entity " << (*currentEntity).first << " is built");
308 MESSAGE(LOC <<"The mesh " <<ptrMesh->getName() << " has " << index << " support(s)");
311 map<MESH_NAME_, map<MED_EN::medEntityMesh,SUPPORT *> >::iterator itSupportOnMesh ;
315 vector<SUPPORT *> vectSupp;
316 for (itSupportOnMesh=_ptrMed->_support.begin();
317 itSupportOnMesh != _ptrMed->_support.end();
320 map<MED_EN::medEntityMesh,SUPPORT *>::iterator itSupport ;
321 for (itSupport=(*itSupportOnMesh).second.begin();
322 itSupport!=(*itSupportOnMesh).second.end();
329 MESSAGE(LOC << "In this MED object there is(are) " << index << " support(s):");
331 vectSupp.resize(index);
333 map<MESH_NAME_, map<MED_EN::medEntityMesh,SUPPORT *> >::const_iterator const_itSupportOnMesh ;
336 for (const_itSupportOnMesh=_ptrMed->_support.begin(); const_itSupportOnMesh != _ptrMed->_support.end();
337 const_itSupportOnMesh++ )
339 map<MED_EN::medEntityMesh,SUPPORT *>::const_iterator const_itSupport ;
340 for (const_itSupport=(*const_itSupportOnMesh).second.begin();
341 const_itSupport!=(*const_itSupportOnMesh).second.end();const_itSupport++)
343 vectSupp[index] = (*const_itSupport).second;
344 SCRUTE(vectSupp[index]);
345 MESSAGE(LOC << "Support number " << index << " is "<< *vectSupp[index]);
353 // Read number of fields, their associated name and their list of (timeStepNumber,iterationNumber)
355 int numberOfFields = 0; //MED_INVALID
356 // char fieldName[MED_TAILLE_NOM+1] = "";
357 char fieldName[MED_TAILLE_NOM+1] ;
358 int numberOfComponents = 0;
359 char * componentName = (char *) MED_NULL;
360 char * unitName = (char *) MED_NULL;
361 // char meshName[MED_TAILLE_NOM+1] = "";
362 char meshName[MED_TAILLE_NOM+1] ;
363 med_2_2::med_type_champ type;
364 MESH * ptrMesh = (MESH *) MED_NULL;
365 FIELD_ * ptrField = (FIELD_ *) MED_NULL;
366 //MED_FIELD_RDWR_DRIVER * ptrDriver = (MED_FIELD_RDWR_DRIVER * ) MED_NULL;
367 GENDRIVER * ptrDriver = (GENDRIVER * ) MED_NULL;
368 SUPPORT * ptrSupport = (SUPPORT * ) MED_NULL;
369 MESH_ENTITIES::const_iterator currentEntity;
370 list<MED_EN::medGeometryElement>::const_iterator currentGeometry;
371 med_2_2::med_int NbOfGaussPts = 0;
372 int numberOfTimeSteps = -1;
373 med_2_2::med_int timeStepNumber = -1;
374 // char timeStepUnit[MED_TAILLE_PNOM]= "";
375 char timeStepUnit[MED_TAILLE_PNOM22+1] ;
376 double timeStep = 0.0;
377 int orderNumber = -1; //???init?????
378 int numberOfRefMesh = 0;
379 med_2_2::med_booleen meshLink;
380 map<MESH_NAME_,MESH*> & _meshes = _ptrMed->_meshes;
381 map<FIELD_NAME_,MAP_DT_IT_> & _fields = _ptrMed->_fields;
382 map<FIELD_ *, MESH_NAME_> & _meshName = _ptrMed->_meshName;
383 map<MESH_NAME_, map<MED_EN::medEntityMesh,SUPPORT *> > & support = _ptrMed->_support;
385 numberOfFields = med_2_2::MEDnChamp(_medIdt,0) ;
386 if ( numberOfFields <= 0 )
387 MESSAGE(LOC << "Be careful there is no field in file |"<<
390 for (i=1;i<=numberOfFields;i++)
392 numberOfComponents = med_2_2::MEDnChamp(_medIdt,i) ;
394 if ( numberOfComponents <= 0 )
395 if (err != MED_VALID)
396 throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Be careful there is no compound for field n°" << i << "in file |"<<_fileName<<"| !"));
398 componentName = new char[numberOfComponents*MED_TAILLE_PNOM22+1] ;
399 unitName = new char[numberOfComponents*MED_TAILLE_PNOM22+1] ;
401 err = MEDchampInfo(_medIdt, i, fieldName, &type, componentName,
402 unitName, numberOfComponents) ;
404 if (err != MED_VALID)
405 throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << ": can't get information about the field n°" << i <<" of the file |" << _fileName << "| !"));
407 MESSAGE(LOC << "Field n°"<<i<<" nammed "<< fieldName
408 << " ,component(s) : " << componentName
409 <<" ,unit(s) : " << unitName);
411 // Loop on all (entity type,geometry type) until you find an existing
412 // one then get the (n°dt,n°it) pairs list for the current
413 // (field,entity type,geometry type) We suppose there is the same list
414 // whatever the existing (entity type,geometry type) pair
418 for (currentEntity=meshEntities.begin();currentEntity != meshEntities.end(); currentEntity++)
420 // numberOfTimeSteps MUST be given by MEDchampInfo !!!!!
421 for (currentGeometry = (*currentEntity).second.begin();
422 currentGeometry != (*currentEntity).second.end();
425 MESSAGE("Field information with Entity,Geom = "<<
426 (*currentEntity).first<<","<<(*currentGeometry));
429 MEDnPasdetemps(_medIdt, fieldName,
430 (med_2_2::med_entite_maillage)(*currentEntity).first,
431 (med_2_2::med_geometrie_element) (*currentGeometry) );
433 MESSAGE("Field information 2 : NumberOfTimeStep :"<<
436 if ( numberOfTimeSteps > MED_VALID )
438 // There are value for some med_geometrie_element of this
439 // med_entite_maillage.
441 if (numberOfTimeSteps>0) // we have at least one
443 for (currentGeometry = (*currentEntity).second.begin();
444 currentGeometry != (*currentEntity).second.end();
447 MESSAGE("Field information 3 : Geom : "<<(*currentGeometry));
449 for (j=1;j <= numberOfTimeSteps; j++)
451 MESSAGE("Field information 4 : time step j = "<<j);
453 // err = MEDpasdetempsInfo( _medIdt, fieldName,
454 // (med_2_2::med_entite_maillage) (*currentEntity).first,
455 // (*currentGeometry),j, meshName,
456 // &NbOfGaussPts, &timeStepNumber,
457 // timeStepUnit, &timeStep, &orderNumber);
459 err = MEDpasdetempsInfo(_medIdt, fieldName,
460 (med_2_2::med_entite_maillage)
461 (*currentEntity).first,
462 (med_2_2::med_geometrie_element)
463 (*currentGeometry),j,
464 &NbOfGaussPts, &timeStepNumber,
465 &orderNumber, timeStepUnit,
466 &timeStep, meshName, &meshLink,
469 if (err == MED_VALID)
470 { // we have found for (*currentEntity).first and
471 // (*currentGeometry)
472 MESSAGE("Field information 5 ;: NumberOfGaussPoint : " << NbOfGaussPts << ", timeStepNumber : " << timeStepNumber << ", orderNumber : " << orderNumber);
473 // CORRECT a bug in MEDpasdetempsInfo :
474 // we get a value n'importe quoi in NbOfGaussPts !!!!
476 if (timeStepNumber<0) timeStepNumber=-1 ;
477 if ((numberOfRefMesh != 1) ||
478 (meshLink != med_2_2::MED_VRAI) ||
483 MESSAGE("This field is Med Memory compliant because NumberOfGaussPoint : " << NbOfGaussPts << ", or numberOfRefMesh : " << numberOfRefMesh << ", or meshLink : " << meshLink);
486 // ATTENTION TRAITER L'EXCEPTION CI DESSUS !!!!!!!!
488 // Il faudra traiter le cas d'un champ qui utilise
489 // +sieurs (entity,geom) voir le travail de patrick
490 // Il faudra traiter le cas des profils...
491 // ptrField = new FIELD();
492 // _ptrDriver = new MED_FIELD_RDWR_DRIVER(_fileName,
494 // ptrField->addDriver(_ptrDriver);
495 // _fields[fieldName]=ptrField;
497 map<MESH_NAME_,MESH*>::iterator _meshesIt =
498 _meshes.find(meshName);
500 if ( _meshesIt == _meshes.end() ) {
501 MESSAGE(LOC << "There is no mesh |" << meshName <<
502 "| in the file |" << _fileName <<
503 "|, but |" << meshName <<
504 "| is referenced by field |" <<
505 fieldName <<"|, entity : |" <<
506 entNames[ (med_2_2::med_entite_maillage)
507 (*currentEntity).first] <<
508 "|, geometric element of type |" <<
509 geoNames [(*currentGeometry)] <<"|");
511 // POURQUOI SI JE NE MET PAS DE BLOCK J'AI UN PARSE
512 // ERROR : PG : c'est la macro MESSAGE qui fait ca !
514 ptrMesh = _meshes[meshName];
516 ptrSupport = support[meshName][(MED_EN::medEntityMesh) (*currentEntity).first];
517 if (NbOfGaussPts != 1)
518 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Number of Gauss Point must be equal to 1 for instance")) ;
520 // init to null to prevent some error if not
521 // correctly allocated !
523 ptrField = (FIELD_*)NULL ;
524 ptrDriver = (GENDRIVER*)NULL ;
527 case med_2_2::MED_INT64 :
528 if ( sizeof(med_2_2::med_int) != 8 )
529 throw MED_EXCEPTION(LOCALIZED(STRING(LOC) <<" The Field type of |" << fieldName <<"|, entity : |" << entNames[(med_2_2::med_entite_maillage) (*currentEntity).first] <<"|, geometric element of type |" << geoNames [(*currentGeometry)] << "| is MED_INT64 but size of med_int is not equal to 8 bytes !"));
531 case med_2_2::MED_INT32 : {
532 ptrField = new FIELD<int> ( );
533 // Les valeurs du champ ne doivent pas être lue
536 ptrField)->setSupport(ptrSupport);
538 ptrField)->setNumberOfComponents(numberOfComponents);
540 ptrField)->setName(fieldName) ;
541 //provisoire, pour debug
542 MESSAGE("#### SET NAME in FIELD : "<<fieldName);
544 MED_EN::med_mode_acces myMode = getAccessMode();
546 // case MED_EN::MED_LECT: // V2_1->V2_2
548 // MED_FIELD_RDONLY_DRIVER<int>
549 // (_fileName, (FIELD<int> *)
552 // case MED_EN::MED_REMP: // V2_1->V2_2
554 // MED_FIELD_RDWR_DRIVER<int>
555 // (_fileName, (FIELD<int> *)
558 // case MED_EN::MED_ECRI: // should never append !! V2_1->V2_2
560 // MED_FIELD_WRONLY_DRIVER<int>
561 // (_fileName, (FIELD<int> *)
565 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
568 ptrDriver = DRIVERFACTORY::buildConcreteMedDriverForField<int>(_fileName, (FIELD<int> *)ptrField, myMode, V22);
575 case MED_EN::MED_REEL64 : {
576 ptrField = new FIELD<double> ( );
577 // Les valeurs du champ ne doivent pas être lue
580 ptrField)->setSupport(ptrSupport);
582 ptrField)->setNumberOfComponents(numberOfComponents);
584 ptrField)->setName(fieldName) ;
585 //provisoire, pour debug
586 MESSAGE("#### SET NAME in FIELD : "<<fieldName);
588 MED_EN::med_mode_acces myMode = getAccessMode();
590 // case MED_EN::MED_LECT: // V2_1->V2_2
592 // MED_FIELD_RDONLY_DRIVER<double>
593 // (_fileName, (FIELD<double> *)
596 // case MED_EN::MED_REMP: // V2_1->V2_2
598 // MED_FIELD_RDWR_DRIVER<double>
599 // (_fileName, (FIELD<double> *)
602 // case MED_EN::MED_ECRI: // should never append !! V2_1->V2_2
604 // MED_FIELD_WRONLY_DRIVER<double>
605 // (_fileName, (FIELD<double> *)
609 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
612 ptrDriver = DRIVERFACTORY::buildConcreteMedDriverForField<double>(_fileName, (FIELD<double> *)ptrField, myMode, V22);
618 if ( numberOfTimeSteps > 1)
619 throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << " The Field type of |" << fieldName <<"|, entity : |" << entNames[(med_2_2::med_entite_maillage) (*currentEntity).first] <<"|, geometric element of type |" << geoNames [(*currentGeometry)] <<"| is neither MED_INT, MED_INT32, MED_INT64 nor MED_REEL64 !"));
623 ptrField->setValueType((MED_EN::med_type_champ)
625 // need to write field !
627 MESSAGE("timeStepNumber :"<<timeStepNumber<<
628 ",orderNumber :"<<orderNumber);
629 ptrField->setIterationNumber ( timeStepNumber);
630 // A ajouter dans la classe FIELD
631 ptrField->setOrderNumber ( orderNumber);
632 ptrField->setTime ( timeStep);
634 // Create a driver for this (field n°dt,n°it)
635 ptrDriver->setId ( getId() );
636 MESSAGE("###### ptrDriver->setFieldName : #"<<
638 ptrDriver->setFieldName(fieldName);
639 ptrField->addDriver(*ptrDriver);
640 // driver is duplicated : remove it
644 dtIt.dt = timeStepNumber;
645 dtIt.it = orderNumber;
647 (_fields [fieldName])[dtIt] = ptrField;
648 _meshName[ptrField ] = meshName;
653 delete[] componentName ;
658 // read profil count and their names
659 // int support_count_= 0 ; !! UNUSED VARIABLE !!
660 // il faut lire les champs pour avoir les profils stockes !!!
661 // il faudrait implémenter la lecture des profils dans med !!!
667 // This method ask the drivers of all MESH/FIELD objects created from this MED driver
668 // to read themselves
669 void MED_MED_RDONLY_DRIVER22::read( void )
670 throw (MEDEXCEPTION) // from objects method read !
672 const char * LOC = "MED_MED_DRIVER22::read() : ";
676 const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
677 map<MESH_NAME_,MESH*>::const_iterator currentMesh;
679 const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
680 map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
682 for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ )
683 (*currentMesh).second->read(*this);
684 //(*currentMesh).second->read(); // default reader, from readFileStruct
687 _ptrMed->updateSupport() ;
689 for ( currentField =_meshName.begin(); currentField != _meshName.end(); currentField++ )
690 (*currentField).first->read(*this);
691 //(*currentField).first->read(); // default reader, from readFileStruct
696 // ------------- Write Only Part --------------
698 MED_MED_WRONLY_DRIVER22::MED_MED_WRONLY_DRIVER22()
702 MED_MED_WRONLY_DRIVER22::MED_MED_WRONLY_DRIVER22(const string & fileName, MED * const ptrMed):
703 IMED_MED_WRONLY_DRIVER(fileName,ptrMed),MED_MED_DRIVER22(fileName,ptrMed),MED_MED_DRIVER(fileName,ptrMed,MED_EN::MED_WRONLY)
706 MED_MED_WRONLY_DRIVER22::MED_MED_WRONLY_DRIVER22(const MED_MED_WRONLY_DRIVER22 & driver):
707 IMED_MED_WRONLY_DRIVER(driver),MED_MED_DRIVER(driver),MED_MED_DRIVER22(driver)
710 MED_MED_WRONLY_DRIVER22::~MED_MED_WRONLY_DRIVER22()
712 MESSAGE("MED_MED_WRONLY_DRIVER22::~MED_MED_WRONLY_DRIVER22() has been destroyed");
715 GENDRIVER * MED_MED_WRONLY_DRIVER22::copy(void) const
717 return new MED_MED_WRONLY_DRIVER22(*this) ;
720 void MED_MED_WRONLY_DRIVER22::read(void)
723 IMED_MED_WRONLY_DRIVER::read();
726 void MED_MED_WRONLY_DRIVER22::readFileStruct(void)
729 IMED_MED_WRONLY_DRIVER::readFileStruct();
732 // This method ask the drivers of all MESH/FIELD objects created from this MED driver
733 // to write themselves
734 void MED_MED_WRONLY_DRIVER22::writeFrom( void) const
735 throw (MEDEXCEPTION) //from object method write !
737 const char * LOC = "MED_MED_DRIVER22::writeFrom() : ";
741 const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
742 map<MESH_NAME_,MESH*>::const_iterator currentMesh;
744 const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
745 map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
747 for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
749 (*currentMesh).second->write(*this);
750 // On utilise pour les objects MESH ET FIELD le write(GENDRIVER *) et le == ds GENDRIVER avec eventuellement 1 id
752 catch ( const MED_DRIVER_NOT_FOUND_EXCEPTION & ex ) {
757 for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
759 (*currentField).first->write(*this);
761 catch ( const MED_DRIVER_NOT_FOUND_EXCEPTION & ex ) {
770 void MED_MED_WRONLY_DRIVER22::write(void ) const
771 throw (MEDEXCEPTION) // from object method write !
773 const char * LOC = "MED_MED_DRIVER22::write() : ";
778 // BCLE SUR LES OBJETS AVEC AJOUT DE DRIVER ET APPELS write
780 const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
781 map<MESH_NAME_,MESH*>::const_iterator currentMesh;
783 const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
784 map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
786 for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
787 //current = (*currentMesh).second->addDriver(MED_DRIVER,_fileName);
788 current = (*currentMesh).second->addDriver(MED_DRIVER,_fileName,(*currentMesh).second->getName());
789 // put right _id in Mesh driver (same as this._id)
790 (*currentMesh).second->_drivers[current]->setId( getId() );
791 //(*currentMesh).second->write(current) ;
794 for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
795 //current = (*currentField).first->addDriver(MED_DRIVER,_fileName);
796 current = (*currentField).first->addDriver(MED_DRIVER,_fileName,(*currentField).first->getName());
797 // put right _id in Field driver (same as this._id)
798 (*currentField).first->_drivers[current]->setId( getId() );
799 //(*currentField).first->write(current) ;
802 // that's work, but it is more efficenty to write directly when we had driver, no ?
809 // ------------- Read Write Part --------------
811 MED_MED_RDWR_DRIVER22::MED_MED_RDWR_DRIVER22()
814 MED_MED_RDWR_DRIVER22::MED_MED_RDWR_DRIVER22(const string & fileName, MED * const ptrMed):
815 MED_MED_RDONLY_DRIVER22(fileName,ptrMed),
816 MED_MED_WRONLY_DRIVER22(fileName,ptrMed),
817 IMED_MED_RDWR_DRIVER(fileName,ptrMed),
818 MED_MED_DRIVER22(fileName,ptrMed,MED_REMP),
819 IMED_MED_WRONLY_DRIVER(fileName,ptrMed),
820 IMED_MED_RDONLY_DRIVER(fileName,ptrMed),
821 MED_MED_DRIVER(fileName,ptrMed,MED_REMP)
824 MED_MED_RDWR_DRIVER22::MED_MED_RDWR_DRIVER22(const MED_MED_RDWR_DRIVER22 & driver):
825 MED_MED_RDONLY_DRIVER22(driver),
826 MED_MED_WRONLY_DRIVER22(driver),
827 IMED_MED_RDWR_DRIVER(driver),
828 MED_MED_DRIVER22(driver),
829 IMED_MED_WRONLY_DRIVER(driver),
830 IMED_MED_RDONLY_DRIVER(driver),
831 MED_MED_DRIVER(driver)
834 MED_MED_RDWR_DRIVER22::~MED_MED_RDWR_DRIVER22() {
835 MESSAGE("MED_MED_RDWR_DRIVER22::~MED_MED_RDWR_DRIVER22() has been destroyed");
838 GENDRIVER * MED_MED_RDWR_DRIVER22::copy(void) const
840 return new MED_MED_RDWR_DRIVER22(*this) ;
843 void MED_MED_RDWR_DRIVER22::read(void)
844 throw (MEDEXCEPTION) // from MED_MED_RDONLY_DRIVER::read()
846 BEGIN_OF("MED_MED_RDWR_DRIVER22::read(void)");
847 MED_MED_RDONLY_DRIVER22::read();
848 END_OF("MED_MED_RDWR_DRIVER22::read(void)");
851 void MED_MED_RDWR_DRIVER22::readFileStruct(void)
852 throw (MEDEXCEPTION) // from MED_MED_RDONLY_DRIVER::readFileStruct()
854 BEGIN_OF("MED_MED_RDWR_DRIVER22::readFileStruct(void)");
855 MED_MED_RDONLY_DRIVER22::readFileStruct();
856 END_OF("MED_MED_RDWR_DRIVER22::readFileStruct(void)");
859 void MED_MED_RDWR_DRIVER22::write(void) const
860 throw (MEDEXCEPTION) // from MED_MED_WRONLY_DRIVER::write()
862 BEGIN_OF("MED_MED_RDWR_DRIVER22::write(void) const");
863 MED_MED_WRONLY_DRIVER22::write();
864 END_OF("MED_MED_RDWR_DRIVER22::write(void) const");
867 void MED_MED_RDWR_DRIVER22::writeFrom(void) const
868 throw (MEDEXCEPTION) // from MED_MED_WRONLY_DRIVER::writeFrom();
870 BEGIN_OF("MED_MED_RDWR_DRIVER22::writeFrom(void) const");
871 MED_MED_WRONLY_DRIVER22::writeFrom();
872 END_OF("MED_MED_RDWR_DRIVER22::writeFrom(void) const");