1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/
20 #include "MEDMEM_Compatibility21_22.hxx"
21 # include "MEDMEM_MedMedDriver22.hxx"
22 # include "MEDMEM_MedMeshDriver.hxx"
23 # include "MEDMEM_DriversDef.hxx"
25 # include "MEDMEM_Mesh.hxx"
26 # include "MEDMEM_Grid.hxx"
27 # include "MEDMEM_Field.hxx"
28 // EN ATTENDANT L'utilisation de MedFieldDriver.hxx ds Field.hxx
29 # include "MEDMEM_MedFieldDriver.hxx"
30 # include "MEDMEM_Med.hxx"
31 # include "MEDMEM_define.hxx"
34 using namespace MED_EN;
35 using namespace MEDMEM;
37 MED_MED_DRIVER22::MED_MED_DRIVER22(): _medIdt(MED_INVALID)
40 MED_MED_DRIVER22::MED_MED_DRIVER22(const string & fileName, MED * const ptrMed):
41 MED_MED_DRIVER(fileName,ptrMed), _medIdt(MED_INVALID)
43 //_ptrMed->addDriver(*this); // The specific MED driver id is set within the addDriver method.
46 MED_MED_DRIVER22::MED_MED_DRIVER22(const string & fileName,
48 MED_EN::med_mode_acces accessMode):
49 MED_MED_DRIVER(fileName,ptrMed,accessMode), _medIdt(MED_INVALID)
52 //REM : As t'on besoin du champ _status : _medIdt <-> _status ? Oui
54 MED_MED_DRIVER22::MED_MED_DRIVER22(const MED_MED_DRIVER22 & driver):
55 MED_MED_DRIVER(driver), _medIdt(MED_INVALID)
59 MED_MED_DRIVER22::~MED_MED_DRIVER22()
61 MESSAGE("MED_MED_DRIVER22::~MED_MED_DRIVER22() has been destroyed");
64 // GENDRIVER * MED_MED_DRIVER::copy(void) const
66 // return new MED_MED_DRIVER(*this) ;
68 void MED_MED_DRIVER22::read()
71 void MED_MED_DRIVER22::readFileStruct()
74 void MED_MED_DRIVER22::write() const
77 GENDRIVER * MED_MED_DRIVER22::copy(void) const
79 return new MED_MED_DRIVER22(*this) ;
81 void MED_MED_DRIVER22::writeFrom() const
87 void MED_MED_DRIVER22::open()
91 const char * LOC ="MED_MED_DRIVER22::open() : ";
94 // REFLECHIR SUR CE TEST PAR RAPPORT A L'OUVERTURE/FERMETURE
95 // if ( _medIdt != MED_INVALID )
96 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
97 // << "_medIdt is already in use, please close the file |"
98 // << _fileName << "| before calling open()"
102 // if ( _status != MED_CLOSED )
103 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
104 // << "_status is closed, please close the file |"
105 // << _fileName << "| before calling open()"
109 if ( _fileName == "" )
110 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
111 << "_fileName is |\"\"|, please set a correct fileName before calling open()"
115 MESSAGE(LOC<<"_fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode);
117 _medIdt = med_2_2::MEDouvrir( (const_cast <char *> (_fileName.c_str())), (med_2_2::med_mode_acces) _accessMode);
118 MESSAGE(LOC<<" _medIdt = "<<_medIdt);
123 _status = MED_CLOSED;
124 _medIdt = MED_INVALID;
125 throw MED_EXCEPTION (LOCALIZED( STRING(LOC)
126 << "Can't open |" << _fileName
127 << "|, _medIdt : " << _medIdt
136 void MED_MED_DRIVER22::close()
138 med_2_2::med_int err = 0;
139 const char * LOC = "MED_MED_DRIVER22::close() : ";
142 // if ( _status == MED_CLOSED)
143 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": the file |"
144 // << _fileName << "| is already closed"
148 // if ( _medIdt == MED_INVALID )
149 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "_medIdt invalid, but the file |"
150 // << _fileName << "| seems to be openned !"
154 if ( _medIdt != MED_INVALID )
155 err=med_2_2::MEDfermer(_medIdt);
157 // if (err != MED_VALID)
158 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "the file |"
159 // << _fileName << "| couldn't be closed"
163 _status = MED_CLOSED;
164 _medIdt = MED_INVALID;
170 // ------------- Read Only Part --------------
172 MED_MED_RDONLY_DRIVER22::MED_MED_RDONLY_DRIVER22()
176 MED_MED_RDONLY_DRIVER22::MED_MED_RDONLY_DRIVER22(const string & fileName, MED * const ptrMed):
177 IMED_MED_RDONLY_DRIVER(fileName,ptrMed),MED_MED_DRIVER22(fileName,ptrMed,MED_EN::MED_RDONLY),MED_MED_DRIVER(fileName,ptrMed,MED_EN::MED_RDONLY)
179 MESSAGE("MED_MED_RDONLY_DRIVER22::MED_MED_RDONLY_DRIVER22(const string & fileName, MED * const ptrMed) Constructeur read only");
182 MED_MED_RDONLY_DRIVER22::MED_MED_RDONLY_DRIVER22(const MED_MED_RDONLY_DRIVER22 & driver):
183 IMED_MED_RDONLY_DRIVER(driver) ,MED_MED_DRIVER22(driver),MED_MED_DRIVER(driver)
187 MED_MED_RDONLY_DRIVER22::~MED_MED_RDONLY_DRIVER22()
189 MESSAGE("MED_MED_RDONLY_DRIVER22::~MED_MED_RDONLY_DRIVER22() has been destroyed");
192 GENDRIVER * MED_MED_RDONLY_DRIVER22::copy(void) const
194 return new MED_MED_RDONLY_DRIVER22(*this) ;
197 void MED_MED_RDONLY_DRIVER22::write ( void ) const throw (MEDEXCEPTION)
199 IMED_MED_RDONLY_DRIVER::write();
202 void MED_MED_RDONLY_DRIVER22::writeFrom ( void ) const throw (MEDEXCEPTION)
204 IMED_MED_RDONLY_DRIVER::writeFrom();
207 void MED_MED_RDONLY_DRIVER22::readFileStruct( void )
210 const char * LOC = "MED_MED_DRIVER22::readFileStruct() : ";
215 if ( _medIdt == MED_INVALID )
216 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
217 << "_medIdt is invalid, please open the file |"
218 << _fileName << "| before calling readFileStruct()"
221 // Read number of meshes and their associated name
224 char meshName[MED_TAILLE_NOM+1]="";
225 char meshDescription[MED_TAILLE_DESC+1]="";
227 med_2_2::med_int meshDim;
228 med_2_2::med_maillage meshType;
231 // MED_MESH_RDWR_DRIVER * ptrDriver; !! UNUSED VARIABLE !!
233 numberOfMeshes = med_2_2::MEDnMaa(_medIdt) ;
234 if ( numberOfMeshes <= 0 )
235 MESSAGE(LOC << "Be careful there is no mesh in file |"<<_fileName<<"| !");
237 MESH_ENTITIES::const_iterator currentEntity;
238 for (i=1;i<=numberOfMeshes;i++)
240 //get infoamation on the i^th mesh
242 err = MEDmaaInfo(_medIdt, i ,meshName, &meshDim, &meshType,
245 if (err != MED_VALID)
246 throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << ": can't get information about the mesh n°" << i << " of the file |" << _fileName << "| !"));
250 case med_2_2::MED_STRUCTURE:
251 MESSAGE(LOC<<": Mesh n°"<< i <<" nammed "<< meshName << " with the description " << meshDescription << " is structured");
253 med_2_2::med_type_grille type;
255 err = MEDnatureGrilleLire(_medIdt, meshName, &type);
257 if (err != MED_VALID)
258 throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << ": can't get the nature of the grid which is the mesh n°" << i << " of the file |" << _fileName << "| !"));
260 ptrMesh = new GRID((MED_EN::med_grid_type) type);
262 case med_2_2::MED_NON_STRUCTURE:
263 MESSAGE(LOC<<": Mesh n°"<< i <<" nammed "<< meshName << " with the description " << meshDescription << " is not structured");
265 ptrMesh = new MESH();
268 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mesh type !"));
271 bool isAGrid = ptrMesh->getIsAGrid();
274 MED_EN::med_mode_acces myMode = getAccessMode();
275 // MED_MESH_DRIVER * ptrDriver ;
277 // case MED_EN::MED_LECT: // V2_1->V2_2
278 // ptrDriver = new MED_MESH_RDONLY_DRIVER(_fileName, ptrMesh);
280 // case MED_EN::MED_REMP: // V2_1->V2_2
281 // ptrDriver = new MED_MESH_RDWR_DRIVER(_fileName, ptrMesh);
283 // case MED_EN::MED_ECRI: // should never append !! V2_1->V2_2
284 // ptrDriver = new MED_MESH_WRONLY_DRIVER(_fileName, ptrMesh);
287 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
290 GENDRIVER * ptrDriver =
291 DRIVERFACTORY::buildConcreteMedDriverForMesh(_fileName, ptrMesh,
292 meshName, myMode, V22);
294 ptrDriver->setId ( getId() );
295 ptrDriver->setMeshName ( meshName );
296 ptrMesh->addDriver(*ptrDriver);
300 _ptrMed->_meshes[meshName] = (MESH *) ptrMesh;
302 _ptrMed->_meshes[meshName] = ptrMesh;
304 // _ptrMed->_meshes[meshName] = ptrMesh;
306 ptrMesh->setName(meshName);
308 ptrMesh->setDescription(meshDescription);
312 MESSAGE(LOC<<"is" << (isAGrid ? "" : " NOT") << " a GRID and its name is "<<ptrMesh->getName());
314 // we create all global support (for each entity type :
316 for (currentEntity=meshEntities.begin();currentEntity != meshEntities.end(); currentEntity++) {
317 string supportName="SupportOnAll_" ;
318 supportName+=entNames[(MED_EN::medEntityMesh)(*currentEntity).first] ;
319 SUPPORT* mySupport = new SUPPORT() ;
320 mySupport->setName(supportName);
321 mySupport->setMesh(ptrMesh);
322 mySupport->setEntity((MED_EN::medEntityMesh) (*currentEntity).first);
323 mySupport->setAll(true);
324 (_ptrMed->_support)[meshName][(MED_EN::medEntityMesh)(*currentEntity).first] = mySupport ;
325 MESSAGE(LOC<< "The support " << supportName.c_str() << " on entity " << (*currentEntity).first << " is built");
328 MESSAGE(LOC <<"The mesh " <<ptrMesh->getName() << " has " << index << " support(s)");
331 map<MESH_NAME_, map<MED_EN::medEntityMesh,SUPPORT *> >::iterator itSupportOnMesh ;
335 vector<SUPPORT *> vectSupp;
336 for (itSupportOnMesh=_ptrMed->_support.begin();
337 itSupportOnMesh != _ptrMed->_support.end();
340 map<MED_EN::medEntityMesh,SUPPORT *>::iterator itSupport ;
341 for (itSupport=(*itSupportOnMesh).second.begin();
342 itSupport!=(*itSupportOnMesh).second.end();
349 MESSAGE(LOC << "In this MED object there is(are) " << index << " support(s):");
351 vectSupp.resize(index);
353 map<MESH_NAME_, map<MED_EN::medEntityMesh,SUPPORT *> >::const_iterator const_itSupportOnMesh ;
356 for (const_itSupportOnMesh=_ptrMed->_support.begin(); const_itSupportOnMesh != _ptrMed->_support.end();
357 const_itSupportOnMesh++ )
359 map<MED_EN::medEntityMesh,SUPPORT *>::const_iterator const_itSupport ;
360 for (const_itSupport=(*const_itSupportOnMesh).second.begin();
361 const_itSupport!=(*const_itSupportOnMesh).second.end();const_itSupport++)
363 vectSupp[index] = (*const_itSupport).second;
364 SCRUTE(vectSupp[index]);
365 MESSAGE(LOC << "Support number " << index << " is "<< *vectSupp[index]);
373 // Read number of fields, their associated name and their list of (timeStepNumber,iterationNumber)
375 int numberOfFields = 0; //MED_INVALID
376 // char fieldName[MED_TAILLE_NOM+1] = "";
377 char fieldName[MED_TAILLE_NOM+1] ;
378 int numberOfComponents = 0;
379 char * componentName = (char *) MED_NULL;
380 char * unitName = (char *) MED_NULL;
381 // char meshName[MED_TAILLE_NOM+1] = "";
382 char meshName[MED_TAILLE_NOM+1] ;
383 med_2_2::med_type_champ type;
384 MESH * ptrMesh = (MESH *) MED_NULL;
385 FIELD_ * ptrField = (FIELD_ *) MED_NULL;
386 //MED_FIELD_RDWR_DRIVER * ptrDriver = (MED_FIELD_RDWR_DRIVER * ) MED_NULL;
387 GENDRIVER * ptrDriver = (GENDRIVER * ) MED_NULL;
388 SUPPORT * ptrSupport = (SUPPORT * ) MED_NULL;
389 MESH_ENTITIES::const_iterator currentEntity;
390 list<MED_EN::medGeometryElement>::const_iterator currentGeometry;
391 med_2_2::med_int NbOfGaussPts = 0;
392 int numberOfTimeSteps = -1;
393 med_2_2::med_int timeStepNumber = -1;
394 // char timeStepUnit[MED_TAILLE_PNOM]= "";
395 char timeStepUnit[MED_TAILLE_PNOM22+1] ;
396 double timeStep = 0.0;
397 //CCRT int orderNumber = -1; //???init?????
398 med_2_2::med_int orderNumber = -1; //???init?????
399 //CCRT int numberOfRefMesh = 0;
400 med_2_2::med_int numberOfRefMesh = 0;
401 med_2_2::med_booleen meshLink;
402 map<MESH_NAME_,MESH*> & _meshes = _ptrMed->_meshes;
403 map<FIELD_NAME_,MAP_DT_IT_> & _fields = _ptrMed->_fields;
404 map<FIELD_ *, MESH_NAME_> & _meshName = _ptrMed->_meshName;
405 map<MESH_NAME_, map<MED_EN::medEntityMesh,SUPPORT *> > & support = _ptrMed->_support;
407 numberOfFields = med_2_2::MEDnChamp(_medIdt,0) ;
408 if ( numberOfFields <= 0 )
409 MESSAGE(LOC << "Be careful there is no field in file |"<<
412 for (i=1;i<=numberOfFields;i++)
414 numberOfComponents = med_2_2::MEDnChamp(_medIdt,i) ;
416 if ( numberOfComponents <= 0 )
417 if (err != MED_VALID)
418 throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Be careful there is no compound for field n°" << i << "in file |"<<_fileName<<"| !"));
420 componentName = new char[numberOfComponents*MED_TAILLE_PNOM22+1] ;
421 unitName = new char[numberOfComponents*MED_TAILLE_PNOM22+1] ;
423 err = MEDchampInfo(_medIdt, i, fieldName, &type, componentName,
424 unitName, numberOfComponents) ;
426 if (err != MED_VALID)
427 throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << ": can't get information about the field n°" << i <<" of the file |" << _fileName << "| !"));
429 MESSAGE(LOC << "Field n°"<<i<<" nammed "<< fieldName
430 << " ,component(s) : " << componentName
431 <<" ,unit(s) : " << unitName);
433 // Loop on all (entity type,geometry type) until you find an existing
434 // one then get the (n°dt,n°it) pairs list for the current
435 // (field,entity type,geometry type) We suppose there is the same list
436 // whatever the existing (entity type,geometry type) pair
440 for (currentEntity=meshEntities.begin();currentEntity != meshEntities.end(); currentEntity++)
442 // numberOfTimeSteps MUST be given by MEDchampInfo !!!!!
443 for (currentGeometry = (*currentEntity).second.begin();
444 currentGeometry != (*currentEntity).second.end();
447 MESSAGE("Field information with Entity,Geom = "<<
448 (*currentEntity).first<<","<<(*currentGeometry));
451 MEDnPasdetemps(_medIdt, fieldName,
452 (med_2_2::med_entite_maillage)(*currentEntity).first,
453 (med_2_2::med_geometrie_element) (*currentGeometry) );
455 MESSAGE("Field information 2 : NumberOfTimeStep :"<<
458 if ( numberOfTimeSteps > MED_VALID )
460 // There are value for some med_geometrie_element of this
461 // med_entite_maillage.
463 if (numberOfTimeSteps>0) // we have at least one
465 for (currentGeometry = (*currentEntity).second.begin();
466 currentGeometry != (*currentEntity).second.end();
469 MESSAGE("Field information 3 : Geom : "<<(*currentGeometry));
471 for (j=1;j <= numberOfTimeSteps; j++)
473 MESSAGE("Field information 4 : time step j = "<<j);
475 // err = MEDpasdetempsInfo( _medIdt, fieldName,
476 // (med_2_2::med_entite_maillage) (*currentEntity).first,
477 // (*currentGeometry),j, meshName,
478 // &NbOfGaussPts, &timeStepNumber,
479 // timeStepUnit, &timeStep, &orderNumber);
481 err = MEDpasdetempsInfo(_medIdt, fieldName,
482 (med_2_2::med_entite_maillage)
483 (*currentEntity).first,
484 (med_2_2::med_geometrie_element)
485 (*currentGeometry),j,
486 &NbOfGaussPts, &timeStepNumber,
487 &orderNumber, timeStepUnit,
488 &timeStep, meshName, &meshLink,
491 if (err == MED_VALID)
492 { // we have found for (*currentEntity).first and
493 // (*currentGeometry)
494 MESSAGE("Field information 5 ;: NumberOfGaussPoint : " << NbOfGaussPts << ", timeStepNumber : " << timeStepNumber << ", orderNumber : " << orderNumber);
495 // CORRECT a bug in MEDpasdetempsInfo :
496 // we get a value n'importe quoi in NbOfGaussPts !!!!
498 if (timeStepNumber<0) timeStepNumber=-1 ;
499 if ((numberOfRefMesh != 1) ||
500 (meshLink != med_2_2::MED_VRAI) ||
505 MESSAGE("This field is Med Memory compliant because NumberOfGaussPoint : " << NbOfGaussPts << ", or numberOfRefMesh : " << numberOfRefMesh << ", or meshLink : " << meshLink);
508 // ATTENTION TRAITER L'EXCEPTION CI DESSUS !!!!!!!!
510 // Il faudra traiter le cas d'un champ qui utilise
511 // +sieurs (entity,geom) voir le travail de patrick
512 // Il faudra traiter le cas des profils...
513 // ptrField = new FIELD();
514 // _ptrDriver = new MED_FIELD_RDWR_DRIVER(_fileName,
516 // ptrField->addDriver(_ptrDriver);
517 // _fields[fieldName]=ptrField;
519 map<MESH_NAME_,MESH*>::iterator _meshesIt =
520 _meshes.find(meshName);
522 if ( _meshesIt == _meshes.end() ) {
523 MESSAGE(LOC << "There is no mesh |" << meshName <<
524 "| in the file |" << _fileName <<
525 "|, but |" << meshName <<
526 "| is referenced by field |" <<
527 fieldName <<"|, entity : |" <<
528 entNames[ (med_2_2::med_entite_maillage)
529 (*currentEntity).first] <<
530 "|, geometric element of type |" <<
531 geoNames [(*currentGeometry)] <<"|");
533 // POURQUOI SI JE NE MET PAS DE BLOCK J'AI UN PARSE
534 // ERROR : PG : c'est la macro MESSAGE qui fait ca !
536 ptrMesh = _meshes[meshName];
538 ptrSupport = support[meshName][(MED_EN::medEntityMesh) (*currentEntity).first];
539 if (NbOfGaussPts != 1)
540 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Number of Gauss Point must be equal to 1 for instance")) ;
542 // init to null to prevent some error if not
543 // correctly allocated !
545 ptrField = (FIELD_*)NULL ;
546 ptrDriver = (GENDRIVER*)NULL ;
549 case med_2_2::MED_INT64 :
550 if ( sizeof(med_2_2::med_int) != 8 )
551 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 !"));
553 case med_2_2::MED_INT32 : {
554 ptrField = new FIELD<int> ( );
555 // Les valeurs du champ ne doivent pas être lue
558 ptrField)->setSupport(ptrSupport);
560 ptrField)->setNumberOfComponents(numberOfComponents);
562 ptrField)->setName(fieldName) ;
563 //provisoire, pour debug
564 MESSAGE("#### SET NAME in FIELD : "<<fieldName);
566 MED_EN::med_mode_acces myMode = getAccessMode();
568 // case MED_EN::MED_LECT: // V2_1->V2_2
570 // MED_FIELD_RDONLY_DRIVER<int>
571 // (_fileName, (FIELD<int> *)
574 // case MED_EN::MED_REMP: // V2_1->V2_2
576 // MED_FIELD_RDWR_DRIVER<int>
577 // (_fileName, (FIELD<int> *)
580 // case MED_EN::MED_ECRI: // should never append !! V2_1->V2_2
582 // MED_FIELD_WRONLY_DRIVER<int>
583 // (_fileName, (FIELD<int> *)
587 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
590 ptrDriver = DRIVERFACTORY::buildConcreteMedDriverForField<int>(_fileName, (FIELD<int> *)ptrField, myMode, V22);
597 case MED_EN::MED_REEL64 : {
598 ptrField = new FIELD<double> ( );
599 // Les valeurs du champ ne doivent pas être lue
602 ptrField)->setSupport(ptrSupport);
604 ptrField)->setNumberOfComponents(numberOfComponents);
606 ptrField)->setName(fieldName) ;
607 //provisoire, pour debug
608 MESSAGE("#### SET NAME in FIELD : "<<fieldName);
610 MED_EN::med_mode_acces myMode = getAccessMode();
612 // case MED_EN::MED_LECT: // V2_1->V2_2
614 // MED_FIELD_RDONLY_DRIVER<double>
615 // (_fileName, (FIELD<double> *)
618 // case MED_EN::MED_REMP: // V2_1->V2_2
620 // MED_FIELD_RDWR_DRIVER<double>
621 // (_fileName, (FIELD<double> *)
624 // case MED_EN::MED_ECRI: // should never append !! V2_1->V2_2
626 // MED_FIELD_WRONLY_DRIVER<double>
627 // (_fileName, (FIELD<double> *)
631 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
634 ptrDriver = DRIVERFACTORY::buildConcreteMedDriverForField<double>(_fileName, (FIELD<double> *)ptrField, myMode, V22);
640 if ( numberOfTimeSteps > 1)
641 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 !"));
645 // need to write field !
647 MESSAGE("timeStepNumber :"<<timeStepNumber<<
648 ",orderNumber :"<<orderNumber);
649 ptrField->setIterationNumber ( timeStepNumber);
650 // A ajouter dans la classe FIELD
651 ptrField->setOrderNumber ( orderNumber);
652 ptrField->setTime ( timeStep);
654 // Create a driver for this (field n°dt,n°it)
655 ptrDriver->setId ( getId() );
656 MESSAGE("###### ptrDriver->setFieldName : #"<<
658 ptrDriver->setFieldName(fieldName);
659 ptrField->addDriver(*ptrDriver);
660 // driver is duplicated : remove it
664 dtIt.dt = timeStepNumber;
665 dtIt.it = orderNumber;
667 (_fields [fieldName])[dtIt] = ptrField;
668 _meshName[ptrField ] = meshName;
673 delete[] componentName ;
678 // read profil count and their names
679 // int support_count_= 0 ; !! UNUSED VARIABLE !!
680 // il faut lire les champs pour avoir les profils stockes !!!
681 // il faudrait implémenter la lecture des profils dans med !!!
687 // This method ask the drivers of all MESH/FIELD objects created from this MED driver
688 // to read themselves
689 void MED_MED_RDONLY_DRIVER22::read( void )
690 throw (MEDEXCEPTION) // from objects method read !
692 const char * LOC = "MED_MED_DRIVER22::read() : ";
696 const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
697 map<MESH_NAME_,MESH*>::const_iterator currentMesh;
699 const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
700 map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
702 for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ )
703 (*currentMesh).second->read(*this);
704 //(*currentMesh).second->read(); // default reader, from readFileStruct
707 _ptrMed->updateSupport() ;
709 for ( currentField =_meshName.begin(); currentField != _meshName.end(); currentField++ )
710 (*currentField).first->read(*this);
711 //(*currentField).first->read(); // default reader, from readFileStruct
716 // ------------- Write Only Part --------------
718 MED_MED_WRONLY_DRIVER22::MED_MED_WRONLY_DRIVER22()
722 MED_MED_WRONLY_DRIVER22::MED_MED_WRONLY_DRIVER22(const string & fileName, MED * const ptrMed):
723 IMED_MED_WRONLY_DRIVER(fileName,ptrMed),MED_MED_DRIVER22(fileName,ptrMed),MED_MED_DRIVER(fileName,ptrMed,MED_EN::MED_WRONLY)
726 MED_MED_WRONLY_DRIVER22::MED_MED_WRONLY_DRIVER22(const MED_MED_WRONLY_DRIVER22 & driver):
727 IMED_MED_WRONLY_DRIVER(driver),MED_MED_DRIVER(driver),MED_MED_DRIVER22(driver)
730 MED_MED_WRONLY_DRIVER22::~MED_MED_WRONLY_DRIVER22()
732 MESSAGE("MED_MED_WRONLY_DRIVER22::~MED_MED_WRONLY_DRIVER22() has been destroyed");
735 GENDRIVER * MED_MED_WRONLY_DRIVER22::copy(void) const
737 return new MED_MED_WRONLY_DRIVER22(*this) ;
740 void MED_MED_WRONLY_DRIVER22::read(void)
743 IMED_MED_WRONLY_DRIVER::read();
746 void MED_MED_WRONLY_DRIVER22::readFileStruct(void)
749 IMED_MED_WRONLY_DRIVER::readFileStruct();
752 // This method ask the drivers of all MESH/FIELD objects created from this MED driver
753 // to write themselves
754 void MED_MED_WRONLY_DRIVER22::writeFrom( void) const
755 throw (MEDEXCEPTION) //from object method write !
757 const char * LOC = "MED_MED_DRIVER22::writeFrom() : ";
761 const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
762 map<MESH_NAME_,MESH*>::const_iterator currentMesh;
764 const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
765 map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
767 for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
769 (*currentMesh).second->write(*this);
770 // On utilise pour les objects MESH ET FIELD le write(GENDRIVER *) et le == ds GENDRIVER avec eventuellement 1 id
772 catch ( const MED_DRIVER_NOT_FOUND_EXCEPTION & ex ) {
777 for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
779 (*currentField).first->write(*this);
781 catch ( const MED_DRIVER_NOT_FOUND_EXCEPTION & ex ) {
790 void MED_MED_WRONLY_DRIVER22::write(void ) const
791 throw (MEDEXCEPTION) // from object method write !
793 const char * LOC = "MED_MED_DRIVER22::write() : ";
798 // BCLE SUR LES OBJETS AVEC AJOUT DE DRIVER ET APPELS write
800 const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
801 map<MESH_NAME_,MESH*>::const_iterator currentMesh;
803 const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
804 map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
806 for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
807 //current = (*currentMesh).second->addDriver(MED_DRIVER,_fileName);
808 current = (*currentMesh).second->addDriver(MED_DRIVER,_fileName,(*currentMesh).second->getName());
809 // put right _id in Mesh driver (same as this._id)
810 (*currentMesh).second->_drivers[current]->setId( getId() );
811 //(*currentMesh).second->write(current) ;
814 for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
815 //current = (*currentField).first->addDriver(MED_DRIVER,_fileName);
816 current = (*currentField).first->addDriver(MED_DRIVER,_fileName,(*currentField).first->getName());
817 // put right _id in Field driver (same as this._id)
818 (*currentField).first->_drivers[current]->setId( getId() );
819 //(*currentField).first->write(current) ;
822 // that's work, but it is more efficenty to write directly when we had driver, no ?
829 // ------------- Read Write Part --------------
831 MED_MED_RDWR_DRIVER22::MED_MED_RDWR_DRIVER22()
834 MED_MED_RDWR_DRIVER22::MED_MED_RDWR_DRIVER22(const string & fileName, MED * const ptrMed):
835 MED_MED_RDONLY_DRIVER22(fileName,ptrMed),
836 MED_MED_WRONLY_DRIVER22(fileName,ptrMed),
837 IMED_MED_RDWR_DRIVER(fileName,ptrMed),
838 MED_MED_DRIVER22(fileName,ptrMed,MED_REMP),
839 IMED_MED_WRONLY_DRIVER(fileName,ptrMed),
840 IMED_MED_RDONLY_DRIVER(fileName,ptrMed),
841 MED_MED_DRIVER(fileName,ptrMed,MED_REMP)
844 MED_MED_RDWR_DRIVER22::MED_MED_RDWR_DRIVER22(const MED_MED_RDWR_DRIVER22 & driver):
845 MED_MED_RDONLY_DRIVER22(driver),
846 MED_MED_WRONLY_DRIVER22(driver),
847 IMED_MED_RDWR_DRIVER(driver),
848 MED_MED_DRIVER22(driver),
849 IMED_MED_WRONLY_DRIVER(driver),
850 IMED_MED_RDONLY_DRIVER(driver),
851 MED_MED_DRIVER(driver)
854 MED_MED_RDWR_DRIVER22::~MED_MED_RDWR_DRIVER22() {
855 MESSAGE("MED_MED_RDWR_DRIVER22::~MED_MED_RDWR_DRIVER22() has been destroyed");
858 GENDRIVER * MED_MED_RDWR_DRIVER22::copy(void) const
860 return new MED_MED_RDWR_DRIVER22(*this) ;
863 void MED_MED_RDWR_DRIVER22::read(void)
864 throw (MEDEXCEPTION) // from MED_MED_RDONLY_DRIVER::read()
866 BEGIN_OF("MED_MED_RDWR_DRIVER22::read(void)");
867 MED_MED_RDONLY_DRIVER22::read();
868 END_OF("MED_MED_RDWR_DRIVER22::read(void)");
871 void MED_MED_RDWR_DRIVER22::readFileStruct(void)
872 throw (MEDEXCEPTION) // from MED_MED_RDONLY_DRIVER::readFileStruct()
874 BEGIN_OF("MED_MED_RDWR_DRIVER22::readFileStruct(void)");
875 MED_MED_RDONLY_DRIVER22::readFileStruct();
876 END_OF("MED_MED_RDWR_DRIVER22::readFileStruct(void)");
879 void MED_MED_RDWR_DRIVER22::write(void) const
880 throw (MEDEXCEPTION) // from MED_MED_WRONLY_DRIVER::write()
882 BEGIN_OF("MED_MED_RDWR_DRIVER22::write(void) const");
883 MED_MED_WRONLY_DRIVER22::write();
884 END_OF("MED_MED_RDWR_DRIVER22::write(void) const");
887 void MED_MED_RDWR_DRIVER22::writeFrom(void) const
888 throw (MEDEXCEPTION) // from MED_MED_WRONLY_DRIVER::writeFrom();
890 BEGIN_OF("MED_MED_RDWR_DRIVER22::writeFrom(void) const");
891 MED_MED_WRONLY_DRIVER22::writeFrom();
892 END_OF("MED_MED_RDWR_DRIVER22::writeFrom(void) const");