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_maillage meshType;
230 // MED_MESH_RDWR_DRIVER * ptrDriver; !! UNUSED VARIABLE !!
232 numberOfMeshes = med_2_2::MEDnMaa(_medIdt) ;
233 if ( numberOfMeshes <= 0 )
234 MESSAGE(LOC << "Be careful there is no mesh in file |"<<_fileName<<"| !");
236 MESH_ENTITIES::const_iterator currentEntity;
237 for (i=1;i<=numberOfMeshes;i++)
239 //get infoamation on the i^th mesh
241 err = MEDmaaInfo(_medIdt, i ,meshName, &meshDim, &meshType,
244 if (err != MED_VALID)
245 throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << ": can't get information about the mesh n°" << i << " of the file |" << _fileName << "| !"));
249 case med_2_2::MED_STRUCTURE:
250 MESSAGE(LOC<<": Mesh n°"<< i <<" nammed "<< meshName << " with the description " << meshDescription << " is structured");
252 med_2_2::med_type_grille type;
254 err = MEDnatureGrilleLire(_medIdt, meshName, &type);
256 if (err != MED_VALID)
257 throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << ": can't get the nature of the grid which is the mesh n°" << i << " of the file |" << _fileName << "| !"));
259 ptrMesh = new GRID((MED_EN::med_grid_type) type);
261 case med_2_2::MED_NON_STRUCTURE:
262 MESSAGE(LOC<<": Mesh n°"<< i <<" nammed "<< meshName << " with the description " << meshDescription << " is not structured");
264 ptrMesh = new MESH();
267 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mesh type !"));
270 bool isAGrid = ptrMesh->getIsAGrid();
273 MED_EN::med_mode_acces myMode = getAccessMode();
274 // MED_MESH_DRIVER * ptrDriver ;
276 // case MED_EN::MED_LECT: // V2_1->V2_2
277 // ptrDriver = new MED_MESH_RDONLY_DRIVER(_fileName, ptrMesh);
279 // case MED_EN::MED_REMP: // V2_1->V2_2
280 // ptrDriver = new MED_MESH_RDWR_DRIVER(_fileName, ptrMesh);
282 // case MED_EN::MED_ECRI: // should never append !! V2_1->V2_2
283 // ptrDriver = new MED_MESH_WRONLY_DRIVER(_fileName, ptrMesh);
286 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
289 GENDRIVER * ptrDriver =
290 DRIVERFACTORY::buildConcreteMedDriverForMesh(_fileName, ptrMesh,
291 meshName, myMode, V22);
293 ptrDriver->setId ( getId() );
294 ptrDriver->setMeshName ( meshName );
295 ptrMesh->addDriver(*ptrDriver);
299 _ptrMed->_meshes[meshName] = (MESH *) ptrMesh;
301 _ptrMed->_meshes[meshName] = ptrMesh;
303 // _ptrMed->_meshes[meshName] = ptrMesh;
305 ptrMesh->setName(meshName);
307 ptrMesh->setDescription(meshDescription);
311 MESSAGE(LOC<<"is" << (isAGrid ? "" : " NOT") << " a GRID and its name is "<<ptrMesh->getName());
313 // we create all global support (for each entity type :
315 for (currentEntity=meshEntities.begin();currentEntity != meshEntities.end(); currentEntity++) {
316 string supportName="SupportOnAll_" ;
317 supportName+=entNames[(MED_EN::medEntityMesh)(*currentEntity).first] ;
318 SUPPORT* mySupport = new SUPPORT() ;
319 mySupport->setName(supportName);
320 mySupport->setMesh(ptrMesh);
321 mySupport->setEntity((MED_EN::medEntityMesh) (*currentEntity).first);
322 mySupport->setAll(true);
323 (_ptrMed->_support)[meshName][(MED_EN::medEntityMesh)(*currentEntity).first] = mySupport ;
324 MESSAGE(LOC<< "The support " << supportName.c_str() << " on entity " << (*currentEntity).first << " is built");
327 MESSAGE(LOC <<"The mesh " <<ptrMesh->getName() << " has " << index << " support(s)");
330 map<MESH_NAME_, map<MED_EN::medEntityMesh,SUPPORT *> >::iterator itSupportOnMesh ;
334 vector<SUPPORT *> vectSupp;
335 for (itSupportOnMesh=_ptrMed->_support.begin();
336 itSupportOnMesh != _ptrMed->_support.end();
339 map<MED_EN::medEntityMesh,SUPPORT *>::iterator itSupport ;
340 for (itSupport=(*itSupportOnMesh).second.begin();
341 itSupport!=(*itSupportOnMesh).second.end();
348 MESSAGE(LOC << "In this MED object there is(are) " << index << " support(s):");
350 vectSupp.resize(index);
352 map<MESH_NAME_, map<MED_EN::medEntityMesh,SUPPORT *> >::const_iterator const_itSupportOnMesh ;
355 for (const_itSupportOnMesh=_ptrMed->_support.begin(); const_itSupportOnMesh != _ptrMed->_support.end();
356 const_itSupportOnMesh++ )
358 map<MED_EN::medEntityMesh,SUPPORT *>::const_iterator const_itSupport ;
359 for (const_itSupport=(*const_itSupportOnMesh).second.begin();
360 const_itSupport!=(*const_itSupportOnMesh).second.end();const_itSupport++)
362 vectSupp[index] = (*const_itSupport).second;
363 SCRUTE(vectSupp[index]);
364 MESSAGE(LOC << "Support number " << index << " is "<< *vectSupp[index]);
372 // Read number of fields, their associated name and their list of (timeStepNumber,iterationNumber)
374 int numberOfFields = 0; //MED_INVALID
375 // char fieldName[MED_TAILLE_NOM+1] = "";
376 char fieldName[MED_TAILLE_NOM+1] ;
377 int numberOfComponents = 0;
378 char * componentName = (char *) MED_NULL;
379 char * unitName = (char *) MED_NULL;
380 // char meshName[MED_TAILLE_NOM+1] = "";
381 char meshName[MED_TAILLE_NOM+1] ;
382 med_2_2::med_type_champ type;
383 MESH * ptrMesh = (MESH *) MED_NULL;
384 FIELD_ * ptrField = (FIELD_ *) MED_NULL;
385 //MED_FIELD_RDWR_DRIVER * ptrDriver = (MED_FIELD_RDWR_DRIVER * ) MED_NULL;
386 GENDRIVER * ptrDriver = (GENDRIVER * ) MED_NULL;
387 SUPPORT * ptrSupport = (SUPPORT * ) MED_NULL;
388 MESH_ENTITIES::const_iterator currentEntity;
389 list<MED_EN::medGeometryElement>::const_iterator currentGeometry;
390 med_2_2::med_int NbOfGaussPts = 0;
391 int numberOfTimeSteps = -1;
392 med_2_2::med_int timeStepNumber = -1;
393 // char timeStepUnit[MED_TAILLE_PNOM]= "";
394 char timeStepUnit[MED_TAILLE_PNOM22+1] ;
395 double timeStep = 0.0;
396 int orderNumber = -1; //???init?????
397 int numberOfRefMesh = 0;
398 med_2_2::med_booleen meshLink;
399 map<MESH_NAME_,MESH*> & _meshes = _ptrMed->_meshes;
400 map<FIELD_NAME_,MAP_DT_IT_> & _fields = _ptrMed->_fields;
401 map<FIELD_ *, MESH_NAME_> & _meshName = _ptrMed->_meshName;
402 map<MESH_NAME_, map<MED_EN::medEntityMesh,SUPPORT *> > & support = _ptrMed->_support;
404 numberOfFields = med_2_2::MEDnChamp(_medIdt,0) ;
405 if ( numberOfFields <= 0 )
406 MESSAGE(LOC << "Be careful there is no field in file |"<<
409 for (i=1;i<=numberOfFields;i++)
411 numberOfComponents = med_2_2::MEDnChamp(_medIdt,i) ;
413 if ( numberOfComponents <= 0 )
414 if (err != MED_VALID)
415 throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Be careful there is no compound for field n°" << i << "in file |"<<_fileName<<"| !"));
417 componentName = new char[numberOfComponents*MED_TAILLE_PNOM22+1] ;
418 unitName = new char[numberOfComponents*MED_TAILLE_PNOM22+1] ;
420 err = MEDchampInfo(_medIdt, i, fieldName, &type, componentName,
421 unitName, numberOfComponents) ;
423 if (err != MED_VALID)
424 throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << ": can't get information about the field n°" << i <<" of the file |" << _fileName << "| !"));
426 MESSAGE(LOC << "Field n°"<<i<<" nammed "<< fieldName
427 << " ,component(s) : " << componentName
428 <<" ,unit(s) : " << unitName);
430 // Loop on all (entity type,geometry type) until you find an existing
431 // one then get the (n°dt,n°it) pairs list for the current
432 // (field,entity type,geometry type) We suppose there is the same list
433 // whatever the existing (entity type,geometry type) pair
437 for (currentEntity=meshEntities.begin();currentEntity != meshEntities.end(); currentEntity++)
439 // numberOfTimeSteps MUST be given by MEDchampInfo !!!!!
440 for (currentGeometry = (*currentEntity).second.begin();
441 currentGeometry != (*currentEntity).second.end();
444 MESSAGE("Field information with Entity,Geom = "<<
445 (*currentEntity).first<<","<<(*currentGeometry));
448 MEDnPasdetemps(_medIdt, fieldName,
449 (med_2_2::med_entite_maillage)(*currentEntity).first,
450 (med_2_2::med_geometrie_element) (*currentGeometry) );
452 MESSAGE("Field information 2 : NumberOfTimeStep :"<<
455 if ( numberOfTimeSteps > MED_VALID )
457 // There are value for some med_geometrie_element of this
458 // med_entite_maillage.
460 if (numberOfTimeSteps>0) // we have at least one
462 for (currentGeometry = (*currentEntity).second.begin();
463 currentGeometry != (*currentEntity).second.end();
466 MESSAGE("Field information 3 : Geom : "<<(*currentGeometry));
468 for (j=1;j <= numberOfTimeSteps; j++)
470 MESSAGE("Field information 4 : time step j = "<<j);
472 // err = MEDpasdetempsInfo( _medIdt, fieldName,
473 // (med_2_2::med_entite_maillage) (*currentEntity).first,
474 // (*currentGeometry),j, meshName,
475 // &NbOfGaussPts, &timeStepNumber,
476 // timeStepUnit, &timeStep, &orderNumber);
478 err = MEDpasdetempsInfo(_medIdt, fieldName,
479 (med_2_2::med_entite_maillage)
480 (*currentEntity).first,
481 (med_2_2::med_geometrie_element)
482 (*currentGeometry),j,
483 &NbOfGaussPts, &timeStepNumber,
484 &orderNumber, timeStepUnit,
485 &timeStep, meshName, &meshLink,
488 if (err == MED_VALID)
489 { // we have found for (*currentEntity).first and
490 // (*currentGeometry)
491 MESSAGE("Field information 5 ;: NumberOfGaussPoint : " << NbOfGaussPts << ", timeStepNumber : " << timeStepNumber << ", orderNumber : " << orderNumber);
492 // CORRECT a bug in MEDpasdetempsInfo :
493 // we get a value n'importe quoi in NbOfGaussPts !!!!
495 if (timeStepNumber<0) timeStepNumber=-1 ;
496 if ((numberOfRefMesh != 1) ||
497 (meshLink != med_2_2::MED_VRAI) ||
502 MESSAGE("This field is Med Memory compliant because NumberOfGaussPoint : " << NbOfGaussPts << ", or numberOfRefMesh : " << numberOfRefMesh << ", or meshLink : " << meshLink);
505 // ATTENTION TRAITER L'EXCEPTION CI DESSUS !!!!!!!!
507 // Il faudra traiter le cas d'un champ qui utilise
508 // +sieurs (entity,geom) voir le travail de patrick
509 // Il faudra traiter le cas des profils...
510 // ptrField = new FIELD();
511 // _ptrDriver = new MED_FIELD_RDWR_DRIVER(_fileName,
513 // ptrField->addDriver(_ptrDriver);
514 // _fields[fieldName]=ptrField;
516 map<MESH_NAME_,MESH*>::iterator _meshesIt =
517 _meshes.find(meshName);
519 if ( _meshesIt == _meshes.end() ) {
520 MESSAGE(LOC << "There is no mesh |" << meshName <<
521 "| in the file |" << _fileName <<
522 "|, but |" << meshName <<
523 "| is referenced by field |" <<
524 fieldName <<"|, entity : |" <<
525 entNames[ (med_2_2::med_entite_maillage)
526 (*currentEntity).first] <<
527 "|, geometric element of type |" <<
528 geoNames [(*currentGeometry)] <<"|");
530 // POURQUOI SI JE NE MET PAS DE BLOCK J'AI UN PARSE
531 // ERROR : PG : c'est la macro MESSAGE qui fait ca !
533 ptrMesh = _meshes[meshName];
535 ptrSupport = support[meshName][(MED_EN::medEntityMesh) (*currentEntity).first];
536 if (NbOfGaussPts != 1)
537 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) <<"Number of Gauss Point must be equal to 1 for instance")) ;
539 // init to null to prevent some error if not
540 // correctly allocated !
542 ptrField = (FIELD_*)NULL ;
543 ptrDriver = (GENDRIVER*)NULL ;
546 case med_2_2::MED_INT64 :
547 if ( sizeof(med_2_2::med_int) != 8 )
548 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 !"));
550 case med_2_2::MED_INT32 : {
551 ptrField = new FIELD<int> ( );
552 // Les valeurs du champ ne doivent pas être lue
555 ptrField)->setSupport(ptrSupport);
557 ptrField)->setNumberOfComponents(numberOfComponents);
559 ptrField)->setName(fieldName) ;
560 //provisoire, pour debug
561 MESSAGE("#### SET NAME in FIELD : "<<fieldName);
563 MED_EN::med_mode_acces myMode = getAccessMode();
565 // case MED_EN::MED_LECT: // V2_1->V2_2
567 // MED_FIELD_RDONLY_DRIVER<int>
568 // (_fileName, (FIELD<int> *)
571 // case MED_EN::MED_REMP: // V2_1->V2_2
573 // MED_FIELD_RDWR_DRIVER<int>
574 // (_fileName, (FIELD<int> *)
577 // case MED_EN::MED_ECRI: // should never append !! V2_1->V2_2
579 // MED_FIELD_WRONLY_DRIVER<int>
580 // (_fileName, (FIELD<int> *)
584 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
587 ptrDriver = DRIVERFACTORY::buildConcreteMedDriverForField<int>(_fileName, (FIELD<int> *)ptrField, myMode, V22);
594 case MED_EN::MED_REEL64 : {
595 ptrField = new FIELD<double> ( );
596 // Les valeurs du champ ne doivent pas être lue
599 ptrField)->setSupport(ptrSupport);
601 ptrField)->setNumberOfComponents(numberOfComponents);
603 ptrField)->setName(fieldName) ;
604 //provisoire, pour debug
605 MESSAGE("#### SET NAME in FIELD : "<<fieldName);
607 MED_EN::med_mode_acces myMode = getAccessMode();
609 // case MED_EN::MED_LECT: // V2_1->V2_2
611 // MED_FIELD_RDONLY_DRIVER<double>
612 // (_fileName, (FIELD<double> *)
615 // case MED_EN::MED_REMP: // V2_1->V2_2
617 // MED_FIELD_RDWR_DRIVER<double>
618 // (_fileName, (FIELD<double> *)
621 // case MED_EN::MED_ECRI: // should never append !! V2_1->V2_2
623 // MED_FIELD_WRONLY_DRIVER<double>
624 // (_fileName, (FIELD<double> *)
628 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
631 ptrDriver = DRIVERFACTORY::buildConcreteMedDriverForField<double>(_fileName, (FIELD<double> *)ptrField, myMode, V22);
637 if ( numberOfTimeSteps > 1)
638 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 !"));
642 // need to write field !
644 MESSAGE("timeStepNumber :"<<timeStepNumber<<
645 ",orderNumber :"<<orderNumber);
646 ptrField->setIterationNumber ( timeStepNumber);
647 // A ajouter dans la classe FIELD
648 ptrField->setOrderNumber ( orderNumber);
649 ptrField->setTime ( timeStep);
651 // Create a driver for this (field n°dt,n°it)
652 ptrDriver->setId ( getId() );
653 MESSAGE("###### ptrDriver->setFieldName : #"<<
655 ptrDriver->setFieldName(fieldName);
656 ptrField->addDriver(*ptrDriver);
657 // driver is duplicated : remove it
661 dtIt.dt = timeStepNumber;
662 dtIt.it = orderNumber;
664 (_fields [fieldName])[dtIt] = ptrField;
665 _meshName[ptrField ] = meshName;
670 delete[] componentName ;
675 // read profil count and their names
676 // int support_count_= 0 ; !! UNUSED VARIABLE !!
677 // il faut lire les champs pour avoir les profils stockes !!!
678 // il faudrait implémenter la lecture des profils dans med !!!
684 // This method ask the drivers of all MESH/FIELD objects created from this MED driver
685 // to read themselves
686 void MED_MED_RDONLY_DRIVER22::read( void )
687 throw (MEDEXCEPTION) // from objects method read !
689 const char * LOC = "MED_MED_DRIVER22::read() : ";
693 const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
694 map<MESH_NAME_,MESH*>::const_iterator currentMesh;
696 const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
697 map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
699 for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ )
700 (*currentMesh).second->read(*this);
701 //(*currentMesh).second->read(); // default reader, from readFileStruct
704 _ptrMed->updateSupport() ;
706 for ( currentField =_meshName.begin(); currentField != _meshName.end(); currentField++ )
707 (*currentField).first->read(*this);
708 //(*currentField).first->read(); // default reader, from readFileStruct
713 // ------------- Write Only Part --------------
715 MED_MED_WRONLY_DRIVER22::MED_MED_WRONLY_DRIVER22()
719 MED_MED_WRONLY_DRIVER22::MED_MED_WRONLY_DRIVER22(const string & fileName, MED * const ptrMed):
720 IMED_MED_WRONLY_DRIVER(fileName,ptrMed),MED_MED_DRIVER22(fileName,ptrMed),MED_MED_DRIVER(fileName,ptrMed,MED_EN::MED_WRONLY)
723 MED_MED_WRONLY_DRIVER22::MED_MED_WRONLY_DRIVER22(const MED_MED_WRONLY_DRIVER22 & driver):
724 IMED_MED_WRONLY_DRIVER(driver),MED_MED_DRIVER(driver),MED_MED_DRIVER22(driver)
727 MED_MED_WRONLY_DRIVER22::~MED_MED_WRONLY_DRIVER22()
729 MESSAGE("MED_MED_WRONLY_DRIVER22::~MED_MED_WRONLY_DRIVER22() has been destroyed");
732 GENDRIVER * MED_MED_WRONLY_DRIVER22::copy(void) const
734 return new MED_MED_WRONLY_DRIVER22(*this) ;
737 void MED_MED_WRONLY_DRIVER22::read(void)
740 IMED_MED_WRONLY_DRIVER::read();
743 void MED_MED_WRONLY_DRIVER22::readFileStruct(void)
746 IMED_MED_WRONLY_DRIVER::readFileStruct();
749 // This method ask the drivers of all MESH/FIELD objects created from this MED driver
750 // to write themselves
751 void MED_MED_WRONLY_DRIVER22::writeFrom( void) const
752 throw (MEDEXCEPTION) //from object method write !
754 const char * LOC = "MED_MED_DRIVER22::writeFrom() : ";
758 const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
759 map<MESH_NAME_,MESH*>::const_iterator currentMesh;
761 const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
762 map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
764 for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
766 (*currentMesh).second->write(*this);
767 // On utilise pour les objects MESH ET FIELD le write(GENDRIVER *) et le == ds GENDRIVER avec eventuellement 1 id
769 catch ( const MED_DRIVER_NOT_FOUND_EXCEPTION & ex ) {
774 for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
776 (*currentField).first->write(*this);
778 catch ( const MED_DRIVER_NOT_FOUND_EXCEPTION & ex ) {
787 void MED_MED_WRONLY_DRIVER22::write(void ) const
788 throw (MEDEXCEPTION) // from object method write !
790 const char * LOC = "MED_MED_DRIVER22::write() : ";
795 // BCLE SUR LES OBJETS AVEC AJOUT DE DRIVER ET APPELS write
797 const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
798 map<MESH_NAME_,MESH*>::const_iterator currentMesh;
800 const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
801 map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
803 for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
804 //current = (*currentMesh).second->addDriver(MED_DRIVER,_fileName);
805 current = (*currentMesh).second->addDriver(MED_DRIVER,_fileName,(*currentMesh).second->getName());
806 // put right _id in Mesh driver (same as this._id)
807 (*currentMesh).second->_drivers[current]->setId( getId() );
808 //(*currentMesh).second->write(current) ;
811 for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
812 //current = (*currentField).first->addDriver(MED_DRIVER,_fileName);
813 current = (*currentField).first->addDriver(MED_DRIVER,_fileName,(*currentField).first->getName());
814 // put right _id in Field driver (same as this._id)
815 (*currentField).first->_drivers[current]->setId( getId() );
816 //(*currentField).first->write(current) ;
819 // that's work, but it is more efficenty to write directly when we had driver, no ?
826 // ------------- Read Write Part --------------
828 MED_MED_RDWR_DRIVER22::MED_MED_RDWR_DRIVER22()
831 MED_MED_RDWR_DRIVER22::MED_MED_RDWR_DRIVER22(const string & fileName, MED * const ptrMed):
832 MED_MED_RDONLY_DRIVER22(fileName,ptrMed),
833 MED_MED_WRONLY_DRIVER22(fileName,ptrMed),
834 IMED_MED_RDWR_DRIVER(fileName,ptrMed),
835 MED_MED_DRIVER22(fileName,ptrMed,MED_REMP),
836 IMED_MED_WRONLY_DRIVER(fileName,ptrMed),
837 IMED_MED_RDONLY_DRIVER(fileName,ptrMed),
838 MED_MED_DRIVER(fileName,ptrMed,MED_REMP)
841 MED_MED_RDWR_DRIVER22::MED_MED_RDWR_DRIVER22(const MED_MED_RDWR_DRIVER22 & driver):
842 MED_MED_RDONLY_DRIVER22(driver),
843 MED_MED_WRONLY_DRIVER22(driver),
844 IMED_MED_RDWR_DRIVER(driver),
845 MED_MED_DRIVER22(driver),
846 IMED_MED_WRONLY_DRIVER(driver),
847 IMED_MED_RDONLY_DRIVER(driver),
848 MED_MED_DRIVER(driver)
851 MED_MED_RDWR_DRIVER22::~MED_MED_RDWR_DRIVER22() {
852 MESSAGE("MED_MED_RDWR_DRIVER22::~MED_MED_RDWR_DRIVER22() has been destroyed");
855 GENDRIVER * MED_MED_RDWR_DRIVER22::copy(void) const
857 return new MED_MED_RDWR_DRIVER22(*this) ;
860 void MED_MED_RDWR_DRIVER22::read(void)
861 throw (MEDEXCEPTION) // from MED_MED_RDONLY_DRIVER::read()
863 BEGIN_OF("MED_MED_RDWR_DRIVER22::read(void)");
864 MED_MED_RDONLY_DRIVER22::read();
865 END_OF("MED_MED_RDWR_DRIVER22::read(void)");
868 void MED_MED_RDWR_DRIVER22::readFileStruct(void)
869 throw (MEDEXCEPTION) // from MED_MED_RDONLY_DRIVER::readFileStruct()
871 BEGIN_OF("MED_MED_RDWR_DRIVER22::readFileStruct(void)");
872 MED_MED_RDONLY_DRIVER22::readFileStruct();
873 END_OF("MED_MED_RDWR_DRIVER22::readFileStruct(void)");
876 void MED_MED_RDWR_DRIVER22::write(void) const
877 throw (MEDEXCEPTION) // from MED_MED_WRONLY_DRIVER::write()
879 BEGIN_OF("MED_MED_RDWR_DRIVER22::write(void) const");
880 MED_MED_WRONLY_DRIVER22::write();
881 END_OF("MED_MED_RDWR_DRIVER22::write(void) const");
884 void MED_MED_RDWR_DRIVER22::writeFrom(void) const
885 throw (MEDEXCEPTION) // from MED_MED_WRONLY_DRIVER::writeFrom();
887 BEGIN_OF("MED_MED_RDWR_DRIVER22::writeFrom(void) const");
888 MED_MED_WRONLY_DRIVER22::writeFrom();
889 END_OF("MED_MED_RDWR_DRIVER22::writeFrom(void) const");