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_MedMedDriver21.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"
36 using namespace MED_EN;
37 using namespace MEDMEM;
39 MED_MED_DRIVER21::MED_MED_DRIVER21(): _medIdt(MED_INVALID)
42 MED_MED_DRIVER21::MED_MED_DRIVER21(const string & fileName, MED * const ptrMed):
43 MED_MED_DRIVER(fileName,ptrMed), _medIdt(MED_INVALID)
45 //_ptrMed->addDriver(*this); // The specific MED driver id is set within the addDriver method.
48 MED_MED_DRIVER21::MED_MED_DRIVER21(const string & fileName,
50 MED_EN::med_mode_acces accessMode):
51 MED_MED_DRIVER(fileName,ptrMed,accessMode), _medIdt(MED_INVALID)
54 //REM : As t'on besoin du champ _status : _medIdt <-> _status ? Oui
56 MED_MED_DRIVER21::MED_MED_DRIVER21(const MED_MED_DRIVER21 & driver):
57 MED_MED_DRIVER(driver),_medIdt(driver._medIdt)
61 MED_MED_DRIVER21::~MED_MED_DRIVER21()
63 MESSAGE("MED_MED_DRIVER21::~MED_MED_DRIVER21() has been destroyed");
66 void MED_MED_DRIVER21::read()
69 void MED_MED_DRIVER21::readFileStruct()
72 void MED_MED_DRIVER21::write() const
75 GENDRIVER * MED_MED_DRIVER21::copy(void) const
77 return new MED_MED_DRIVER21(*this) ;
79 void MED_MED_DRIVER21::writeFrom() const
83 void MED_MED_DRIVER21::open()
87 const char * LOC ="MED_MED_DRIVER21::open() : ";
90 // REFLECHIR SUR CE TEST PAR RAPPORT A L'OUVERTURE/FERMETURE
91 // if ( _medIdt != MED_INVALID )
92 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
93 // << "_medIdt is already in use, please close the file |"
94 // << _fileName << "| before calling open()"
98 // if ( _status != MED_CLOSED )
99 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
100 // << "_status is closed, please close the file |"
101 // << _fileName << "| before calling open()"
105 if ( _fileName == "" )
106 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
107 << "_fileName is |\"\"|, please set a correct fileName before calling open()"
111 MESSAGE(LOC<<"_fileName.c_str : "<< _fileName.c_str()<<",mode : "<< _accessMode);
112 _medIdt = med_2_1::MEDouvrir( (const_cast <char *> (_fileName.c_str())), (med_2_1::med_mode_acces) _accessMode);
113 MESSAGE(LOC<<" _medIdt = "<<_medIdt);
118 _status = MED_CLOSED;
119 _medIdt = MED_INVALID;
120 throw MED_EXCEPTION (LOCALIZED( STRING(LOC)
121 << "Can't open |" << _fileName
122 << "|, _medIdt : " << _medIdt
131 void MED_MED_DRIVER21::close()
133 med_2_1::med_int err = 0;
134 const char * LOC = "MED_MED_DRIVER21::close() : ";
137 // if ( _status == MED_CLOSED)
138 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": the file |"
139 // << _fileName << "| is already closed"
143 // if ( _medIdt == MED_INVALID )
144 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "_medIdt invalid, but the file |"
145 // << _fileName << "| seems to be openned !"
149 if ( _medIdt != MED_INVALID )
150 err=med_2_1::MEDfermer(_medIdt);
152 // if (err != MED_VALID)
153 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "the file |"
154 // << _fileName << "| couldn't be closed"
158 _status = MED_CLOSED;
159 _medIdt = MED_INVALID;
165 // ------------- Read Only Part --------------
167 MED_MED_RDONLY_DRIVER21::MED_MED_RDONLY_DRIVER21()
171 MED_MED_RDONLY_DRIVER21::MED_MED_RDONLY_DRIVER21(const string & fileName, MED * const ptrMed):
172 IMED_MED_RDONLY_DRIVER(fileName,ptrMed),MED_MED_DRIVER21(fileName,ptrMed,MED_EN::MED_RDONLY),MED_MED_DRIVER(fileName,ptrMed,MED_EN::MED_RDONLY)
174 MESSAGE("MED_MED_RDONLY_DRIVER21::MED_MED_RDONLY_DRIVER21(const string & fileName, MED * const ptrMed) Constructeur read only");
177 MED_MED_RDONLY_DRIVER21::MED_MED_RDONLY_DRIVER21(const MED_MED_RDONLY_DRIVER21 & driver):
178 IMED_MED_RDONLY_DRIVER(driver) ,MED_MED_DRIVER21(driver),MED_MED_DRIVER(driver)
182 MED_MED_RDONLY_DRIVER21::~MED_MED_RDONLY_DRIVER21()
184 MESSAGE("MED_MED_RDONLY_DRIVER21::~MED_MED_RDONLY_DRIVER21() has been destroyed");
187 GENDRIVER * MED_MED_RDONLY_DRIVER21::copy(void) const
189 return new MED_MED_RDONLY_DRIVER21(*this) ;
192 void MED_MED_RDONLY_DRIVER21::write ( void ) const throw (MEDEXCEPTION)
194 IMED_MED_RDONLY_DRIVER::write();
197 void MED_MED_RDONLY_DRIVER21::writeFrom ( void ) const throw (MEDEXCEPTION)
199 IMED_MED_RDONLY_DRIVER::writeFrom();
202 void MED_MED_RDONLY_DRIVER21::readFileStruct( void )
205 const char * LOC = "MED_MED_DRIVER21::readFileStruct() : ";
210 if ( _medIdt == MED_INVALID )
211 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
212 << "_medIdt is invalid, please open the file |"
213 << _fileName << "| before calling readFileStruct()"
216 // Read number of meshes and their associated name
219 char meshName[MED_TAILLE_NOM+1]="";
220 char meshDescription[MED_TAILLE_DESC+1]="";
221 med_2_1::med_int meshDim;
223 // MED_MESH_RDWR_DRIVER * ptrDriver; !! UNUSED VARIABLE !!
225 numberOfMeshes = med_2_1::MEDnMaa(_medIdt) ;
226 if ( numberOfMeshes <= 0 )
227 MESSAGE(LOC << "Be careful there is no mesh in file |"<<_fileName<<"| !");
229 MESH_ENTITIES::const_iterator currentEntity;
230 for (i=1;i<=numberOfMeshes;i++) {
232 // find out if the mesh is a Grid
234 med_2_1::med_int isAGrid = false;
235 med_2_1::med_grid_type type;
237 err = MEDgridInfo (_medIdt, i, &isAGrid, &type);
238 if (err != MED_VALID)
239 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "error in MEDgridInfo()") );
241 err = med_2_1::MEDmaaInfo(_medIdt, i ,meshName, &meshDim) ;
243 strcpy(meshDescription,"Mesh from Med 2.2 format");
245 if (err != MED_VALID)
246 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << ": can't get information about the mesh n°"
247 << i <<" of the file |" << _fileName << "| !"
250 MESSAGE(LOC<<": Mesh n°"<<i<<" nammed "<<meshName);
253 ptrMesh = new GRID((MED_EN::med_grid_type) type);
255 ptrMesh = new MESH();
257 //MED_MESH_RDWR_DRIVER * _ptrDriver = new MED_MESH_RDWR_DRIVER(_fileName, ptrMesh);
258 MED_EN::med_mode_acces myMode = getAccessMode();
259 // MED_MESH_DRIVER * ptrDriver ;
261 // case MED_EN::MED_LECT:
262 // ptrDriver = new MED_MESH_RDONLY_DRIVER(_fileName, ptrMesh);
264 // case MED_EN::MED_REMP:
265 // ptrDriver = new MED_MESH_RDWR_DRIVER(_fileName, ptrMesh);
267 // case MED_EN::MED_ECRI: // should never append !!
268 // ptrDriver = new MED_MESH_RDONLY_DRIVER(_fileName, ptrMesh);
271 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
274 GENDRIVER * ptrDriver =
275 DRIVERFACTORY::buildConcreteMedDriverForMesh(_fileName, ptrMesh,
276 meshName, myMode, V21);
278 ptrDriver->setId ( getId() );
279 ptrDriver->setMeshName ( meshName );
280 ptrMesh->setDescription(meshDescription);
284 ptrMesh->addDriver(*ptrDriver);
288 _ptrMed->_meshes[meshName] = (MESH *) ptrMesh;
290 _ptrMed->_meshes[meshName] = ptrMesh;
292 ptrMesh->setName(meshName);
296 MESSAGE(LOC<<"is" << (isAGrid ? "" : " NOT") << " a GRID and its name is "<<ptrMesh->getName());
298 // we create all global support (for each entity type :
300 for (currentEntity=meshEntities.begin();currentEntity != meshEntities.end(); currentEntity++) {
301 string supportName="SupportOnAll_" ;
302 supportName+=entNames[(*currentEntity).first] ;
303 //(_ptrMed->_support)[meshName][(MED_EN::medEntityMesh)(*currentEntity).first]=new SUPPORT(ptrMesh,supportName,(MED_EN::medEntityMesh) (*currentEntity).first) ;
304 SUPPORT* mySupport = new SUPPORT() ;
305 mySupport->setName(supportName);
306 mySupport->setMesh(ptrMesh);
307 mySupport->setEntity((MED_EN::medEntityMesh) (*currentEntity).first);
308 mySupport->setAll(true);
309 (_ptrMed->_support)[meshName][(MED_EN::medEntityMesh)(*currentEntity).first] = mySupport ;
310 MESSAGE(LOC<< "The support " << supportName.c_str() << " on entity " << (*currentEntity).first << " is built");
313 MESSAGE(LOC <<"The mesh " <<ptrMesh->getName() << " has " << index << " support(s)");
316 map<MESH_NAME_, map<MED_EN::medEntityMesh,SUPPORT *> >::const_iterator const_itSupportOnMesh ;
320 vector<SUPPORT *> vectSupp;
321 for (const_itSupportOnMesh=_ptrMed->_support.begin(); const_itSupportOnMesh != _ptrMed->_support.end();
322 const_itSupportOnMesh++ )
324 map<MED_EN::medEntityMesh,SUPPORT *>::const_iterator const_itSupport ;
325 for (const_itSupport=(*const_itSupportOnMesh).second.begin();
326 const_itSupport!=(*const_itSupportOnMesh).second.end();const_itSupport++) index++;
329 MESSAGE(LOC << "In this MED object there is(are) " << index << " support(s):");
331 vectSupp.resize(index);
334 for (const_itSupportOnMesh=_ptrMed->_support.begin(); const_itSupportOnMesh != _ptrMed->_support.end();
335 const_itSupportOnMesh++ )
337 map<MED_EN::medEntityMesh,SUPPORT *>::const_iterator const_itSupport ;
338 for (const_itSupport=(*const_itSupportOnMesh).second.begin();
339 const_itSupport!=(*const_itSupportOnMesh).second.end();const_itSupport++)
341 vectSupp[index] = (*const_itSupport).second;
342 SCRUTE(vectSupp[index]);
343 MESSAGE(LOC << "Support number " << index << " is "<< *vectSupp[index]);
351 // Read number of fields, their associated name and their list of (timeStepNumber,iterationNumber)
353 int numberOfFields = 0; //MED_INVALID
354 // char fieldName[MED_TAILLE_NOM+1] = "";
355 char fieldName[MED_TAILLE_NOM+1] ;
356 int numberOfComponents = 0;
357 char * componentName = (char *) MED_NULL;
358 char * unitName = (char *) MED_NULL;
359 // char meshName[MED_TAILLE_NOM+1] = "";
360 char meshName[MED_TAILLE_NOM+1] ;
361 med_2_1::med_type_champ type;
362 MESH * ptrMesh = (MESH *) MED_NULL;
363 FIELD_ * ptrField = (FIELD_ *) MED_NULL;
364 //MED_FIELD_RDWR_DRIVER * ptrDriver = (MED_FIELD_RDWR_DRIVER * ) MED_NULL;
365 GENDRIVER * ptrDriver = (GENDRIVER * ) MED_NULL;
366 SUPPORT * ptrSupport = (SUPPORT * ) MED_NULL;
367 MESH_ENTITIES::const_iterator currentEntity;
368 list<MED_EN::medGeometryElement>::const_iterator currentGeometry;
369 med_2_1::med_int NbOfGaussPts = 0;
370 int numberOfTimeSteps = -1;
371 med_2_1::med_int timeStepNumber = -1;
372 // char timeStepUnit[MED_TAILLE_PNOM]= "";
373 char timeStepUnit[MED_TAILLE_PNOM21+1] ;
374 double timeStep = 0.0;
375 med_2_1::med_int orderNumber = -1; //???init?????
376 map<MESH_NAME_,MESH*> & _meshes = _ptrMed->_meshes;
377 map<FIELD_NAME_,MAP_DT_IT_> & _fields = _ptrMed->_fields;
378 map<FIELD_ *, MESH_NAME_> & _meshName = _ptrMed->_meshName;
379 map<MESH_NAME_, map<MED_EN::medEntityMesh,SUPPORT *> > & support = _ptrMed->_support;
382 numberOfFields = med_2_1::MEDnChamp(_medIdt,0) ;
383 if ( numberOfFields <= 0 )
384 MESSAGE(LOC << "Be careful there is no field in file |"<<_fileName<<"| !");
386 for (i=1;i<=numberOfFields;i++) {
388 numberOfComponents = med_2_1::MEDnChamp(_medIdt,i) ;
389 if ( numberOfComponents <= 0 )
390 if (err != MED_VALID)
391 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) << "Be careful there is no compound for field n°"
392 << i << "in file |"<<_fileName<<"| !"));
394 componentName = new char[numberOfComponents*MED_TAILLE_PNOM21+1] ;
395 unitName = new char[numberOfComponents*MED_TAILLE_PNOM21+1] ;
397 err = MEDchampInfo(_medIdt, i, fieldName, &type, componentName,
398 unitName, numberOfComponents) ;
400 if (err != MED_VALID)
401 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
402 << ": can't get information about the field n°"
403 << i <<" of the file |" << _fileName << "| !"));
405 MESSAGE(LOC << "Field n°"<<i<<" nammed "<< fieldName
406 << " ,component(s) : " << componentName
407 <<" ,unit(s) : " << unitName);
410 // Loop on all (entity type,geometry type) until you find an existing one then
411 // get the (n°dt,n°it) pairs list for the current (field,entity type,geometry type)
412 // We suppose there is the same list whatever the existing (entity type,geometry type) pair
414 for (currentEntity=meshEntities.begin();currentEntity != meshEntities.end(); currentEntity++) {
415 // numberOfTimeSteps MUST be given by MEDchampInfo !!!!!
416 for (currentGeometry = (*currentEntity).second.begin();currentGeometry != (*currentEntity).second.end(); currentGeometry++) {
417 MESSAGE("Field information with Entity,Geom = "<<(*currentEntity).first<<","<<(*currentGeometry));
418 numberOfTimeSteps = MEDnPasdetemps(_medIdt, fieldName,
419 (med_2_1::med_entite_maillage)(*currentEntity).first,
420 (med_2_1::med_geometrie_element) (*currentGeometry) );
421 MESSAGE("Field information 2 : NumberOfTimeStep :"<<numberOfTimeSteps);
422 if ( numberOfTimeSteps > MED_VALID )
423 break ; // There are value for some med_geometrie_element of this med_entite_maillage.
425 if (numberOfTimeSteps>0) // we have at least one
427 for (currentGeometry = (*currentEntity).second.begin();currentGeometry != (*currentEntity).second.end(); currentGeometry++) {
429 MESSAGE("Field information 3 : Geom : "<<(*currentGeometry));
430 for (j=1;j <= numberOfTimeSteps; j++) {
432 MESSAGE("Field information 4 : time step j = "<<j);
433 err = MEDpasdetempsInfo( _medIdt, fieldName,
434 (med_2_1::med_entite_maillage) (*currentEntity).first,
435 (med_2_1::med_geometrie_element) (*currentGeometry),j,
436 meshName, &NbOfGaussPts,
437 &timeStepNumber, timeStepUnit, &timeStep,
439 if (err == MED_VALID) { // we have found for (*currentEntity).first and (*currentGeometry)
441 MESSAGE("Field information 5 ;: NumberOfGaussPoint : "<<NbOfGaussPts<<", timeStepNumber : "<<timeStepNumber);
442 // CORRECT a bug in MEDpasdetempsInfo :
443 // we get a value n'importe quoi in NbOfGaussPts !!!!
445 if (NbOfGaussPts>100)
447 if (timeStepNumber<0)
451 // ATTENTION TRAITER L'EXCEPTION !!!!!!!!!!!!
453 // Il faudra traiter le cas d'un champ qui utilise +sieurs (entity,geom) voir le travail de patrick
454 // Il faudra traiter le cas des profils...
455 // ptrField = new FIELD();
456 // _ptrDriver = new MED_FIELD_RDWR_DRIVER(_fileName, ptrField);
457 // ptrField->addDriver(_ptrDriver);
458 // _fields[fieldName]=ptrField;
460 // Verify meshName is already known
462 map<MESH_NAME_,MESH*>::iterator _meshesIt = _meshes.find(meshName);
463 if ( _meshesIt == _meshes.end() ) {
464 MESSAGE(LOC << "There is no mesh |"
465 << meshName <<"| in the file |"
466 << _fileName <<"|, but |" << meshName <<"| is referenced by field |"
467 << fieldName <<"|, entity : |"
468 << entNames [(*currentEntity).first] <<"|, geometric element of type |"
469 << geoNames [(*currentGeometry)] <<"|"
471 } // POURQUOI SI JE NE MET PAS DE BLOCK J'AI UN PARSE ERROR : PG : c'est la macro MESSAGE qui fait ca !
473 ptrMesh = _meshes[meshName];
475 ptrSupport = support[meshName][(MED_EN::medEntityMesh) (*currentEntity).first];
476 if (NbOfGaussPts != 1)
477 throw MEDEXCEPTION(LOCALIZED( STRING(LOC) <<"Number of Gauss Point must be equal to 1 for instance")) ;
479 // init to null to prevent some error if not correctly allocated !
480 ptrField = (FIELD_*)NULL ;
481 // ptrDriver = (GENDRIVER*)NULL ;
484 case med_2_1::MED_INT64 :
485 if ( sizeof(med_2_1::med_int) != 8 )
486 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) <<
487 " The Field type of |"
488 << fieldName <<"|, entity : |"
489 << entNames [(*currentEntity).first] <<"|, geometric element of type |"
490 << geoNames [(*currentGeometry) ] <<
491 "| is MED_INT64 but size of med_int is not equal to 8 bytes !"
495 case med_2_1::MED_INT32 : {
496 // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) <<
497 // "NOT IMPLEMENTED : BUG IN STL !")
499 // ptrField = new FIELD<med_2_1::med_int> ( ptrSupport,numberOfComponents ); // Les valeurs du champ ne doivent pas être lue pour l'instant
501 ptrField = new FIELD<int> ( ); // Les valeurs du champ ne doivent pas être lue pour l'instant
502 ((FIELD<int>*) ptrField)->setSupport(ptrSupport);
503 ((FIELD<int>*) ptrField)->setNumberOfComponents(numberOfComponents);
504 ((FIELD<int>*) ptrField)->setName(fieldName) ; //provisoire, pour debug
505 MESSAGE("#### SET NAME in FIELD : "<<fieldName);
507 MED_EN::med_mode_acces myMode = getAccessMode();
509 // case MED_EN::MED_LECT:
510 // ptrDriver = new MED_FIELD_RDONLY_DRIVER<int>(_fileName, (FIELD<int> *)ptrField);
512 // case MED_EN::MED_REMP:
513 // ptrDriver = new MED_FIELD_RDWR_DRIVER<int>(_fileName, (FIELD<int> *)ptrField);
515 // case MED_EN::MED_ECRI: // should never append !!
516 // ptrDriver = new MED_FIELD_RDONLY_DRIVER<int>(_fileName, (FIELD<int> *)ptrField);
519 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
522 ptrDriver = DRIVERFACTORY::buildConcreteMedDriverForField<int>(_fileName, (FIELD<int> *)ptrField, myMode, V21);
528 case med_2_1::MED_REEL64 : {
529 // ptrField = new FIELD<med_2_1::med_float> ( ptrSupport,numberOfComponents ); // Les valeurs du champ ne doivent pas être lue pour l'instant
530 ptrField = new FIELD<double> ( ); // Les valeurs du champ ne doivent pas être lue pour l'instant
531 ((FIELD<med_2_1::med_float>*) ptrField)->setSupport(ptrSupport);
532 ((FIELD<med_2_1::med_float>*) ptrField)->setNumberOfComponents(numberOfComponents);
533 ((FIELD<med_2_1::med_float>*) ptrField)->setName(fieldName) ; //provisoire, pour debug
534 MESSAGE("#### SET NAME in FIELD : "<<fieldName);
536 MED_EN::med_mode_acces myMode = getAccessMode();
538 // case MED_EN::MED_LECT:
539 // ptrDriver = new MED_FIELD_RDONLY_DRIVER<med_2_1::med_float>(_fileName, (FIELD<med_2_1::med_float> *)ptrField);
541 // case MED_EN::MED_REMP:
542 // ptrDriver = new MED_FIELD_RDWR_DRIVER<med_2_1::med_float>(_fileName, (FIELD<med_2_1::med_float> *)ptrField);
544 // case MED_EN::MED_ECRI: // should never append !!
545 // ptrDriver = new MED_FIELD_RDONLY_DRIVER<med_2_1::med_float>(_fileName, (FIELD<med_2_1::med_float> *)ptrField);
548 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Bad file mode access !"));
551 ptrDriver = DRIVERFACTORY::buildConcreteMedDriverForField<med_2_1::med_float>(_fileName, (FIELD<med_2_1::med_float> *)ptrField, myMode, V21);
557 if ( numberOfTimeSteps > 1)
558 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) <<
559 " The Field type of |"
560 << fieldName <<"|, entity : |"
561 << entNames [(*currentEntity).first]
562 <<"|, geometric element of type |"
563 << geoNames [(*currentGeometry)]
564 <<"| is neither MED_INT, MED_INT32, MED_INT64 nor MED_REEL64 !"
571 MESSAGE("timeStepNumber :"<<timeStepNumber<<",orderNumber :"<<orderNumber);
572 ptrField->setIterationNumber ( timeStepNumber); // A ajouter dans la classe FIELD
573 ptrField->setOrderNumber ( orderNumber);
574 ptrField->setTime ( timeStep);
576 // Create a driver for this (field n°dt,n°it)
577 ptrDriver->setId ( getId() );
578 MESSAGE("###### ptrDriver->setFieldName : #"<<fieldName<<"#");
579 ptrDriver->setFieldName(fieldName);
580 ptrField->addDriver(*ptrDriver);
581 // driver is duplicated : remove it
585 dtIt.dt = timeStepNumber;
586 dtIt.it = orderNumber;
588 (_fields [fieldName])[dtIt] = ptrField;
589 _meshName[ptrField ] = meshName;
594 delete[] componentName ;
599 // read profil count and their names
600 // int support_count_= 0 ; !! UNUSED VARIABLE !!
601 // il faut lire les champs pour avoir les profils stockes !!!
602 // il faudrait implémenter la lecture des profils dans med !!!
608 // This method ask the drivers of all MESH/FIELD objects created from this MED driver
609 // to read themselves
610 void MED_MED_RDONLY_DRIVER21::read( void )
611 throw (MEDEXCEPTION) // from objects method read !
613 const char * LOC = "MED_MED_DRIVER21::read() : ";
617 const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
618 map<MESH_NAME_,MESH*>::const_iterator currentMesh;
620 const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
621 map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
623 for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ )
624 (*currentMesh).second->read(*this);
625 //(*currentMesh).second->read(); // default reader, from readFileStruct
628 _ptrMed->updateSupport() ;
630 for ( currentField =_meshName.begin(); currentField != _meshName.end(); currentField++ )
631 (*currentField).first->read(*this);
632 //(*currentField).first->read(); // default reader, from readFileStruct
637 // ------------- Write Only Part --------------
639 MED_MED_WRONLY_DRIVER21::MED_MED_WRONLY_DRIVER21()
643 MED_MED_WRONLY_DRIVER21::MED_MED_WRONLY_DRIVER21(const string & fileName, MED * const ptrMed):
644 IMED_MED_WRONLY_DRIVER(fileName,ptrMed),MED_MED_DRIVER21(fileName,ptrMed),MED_MED_DRIVER(fileName,ptrMed,MED_EN::MED_WRONLY)
647 MED_MED_WRONLY_DRIVER21::MED_MED_WRONLY_DRIVER21(const MED_MED_WRONLY_DRIVER21 & driver):
648 IMED_MED_WRONLY_DRIVER(driver),MED_MED_DRIVER(driver),MED_MED_DRIVER21(driver)
651 MED_MED_WRONLY_DRIVER21::~MED_MED_WRONLY_DRIVER21()
653 MESSAGE("MED_MED_WRONLY_DRIVER21::~MED_MED_WRONLY_DRIVER21() has been destroyed");
656 GENDRIVER * MED_MED_WRONLY_DRIVER21::copy(void) const
658 return new MED_MED_WRONLY_DRIVER21(*this) ;
661 void MED_MED_WRONLY_DRIVER21::read ( void ) throw (MEDEXCEPTION)
663 IMED_MED_WRONLY_DRIVER::read();
666 void MED_MED_WRONLY_DRIVER21::readFileStruct ( void ) throw (MEDEXCEPTION)
668 IMED_MED_WRONLY_DRIVER::readFileStruct();
671 // This method ask the drivers of all MESH/FIELD objects created from this MED driver
672 // to write themselves
673 void MED_MED_WRONLY_DRIVER21::writeFrom( void) const
674 throw (MEDEXCEPTION) //from object method write !
676 const char * LOC = "MED_MED_DRIVER21::writeFrom() : ";
680 const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
681 map<MESH_NAME_,MESH*>::const_iterator currentMesh;
683 const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
684 map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
686 for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
688 (*currentMesh).second->write(*this);
689 // On utilise pour les objects MESH ET FIELD le write(GENDRIVER *) et le == ds GENDRIVER avec eventuellement 1 id
691 catch ( const MED_DRIVER_NOT_FOUND_EXCEPTION & ex ) {
696 for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
698 (*currentField).first->write(*this);
700 catch ( const MED_DRIVER_NOT_FOUND_EXCEPTION & ex ) {
709 void MED_MED_WRONLY_DRIVER21::write(void ) const
710 throw (MEDEXCEPTION) // from object method write !
712 const char * LOC = "MED_MED_DRIVER21::write() : ";
717 // BCLE SUR LES OBJETS AVEC AJOUT DE DRIVER ET APPELS write
719 const map<MESH_NAME_, MESH*> & _meshes = const_cast<const map<MESH_NAME_, MESH*>& > (_ptrMed->_meshes);
720 map<MESH_NAME_,MESH*>::const_iterator currentMesh;
722 const map<FIELD_ *, MESH_NAME_> & _meshName = const_cast<const map<FIELD_ *, MESH_NAME_>& > (_ptrMed->_meshName);
723 map<FIELD_ *, MESH_NAME_>::const_iterator currentField;
725 for ( currentMesh=_meshes.begin();currentMesh != _meshes.end(); currentMesh++ ) {
726 //current = (*currentMesh).second->addDriver(MED_DRIVER,_fileName);
727 current = (*currentMesh).second->addDriver(MED_DRIVER,_fileName,(*currentMesh).second->getName());
728 // put right _id in Mesh driver (same as this._id)
729 (*currentMesh).second->_drivers[current]->setId( getId() );
730 (*currentMesh).second->write(current) ;
733 for ( currentField=_meshName.begin();currentField != _meshName.end(); currentField++ ) {
734 //current = (*currentField).first->addDriver(MED_DRIVER,_fileName);
735 current = (*currentField).first->addDriver(MED_DRIVER,_fileName,(*currentField).first->getName());
736 // put right _id in Field driver (same as this._id)
737 (*currentField).first->_drivers[current]->setId( getId() );
738 (*currentField).first->write(current) ;
741 // that's work, but it is more efficenty to write directly when we had driver, no ?
748 // ------------- Read Write Part --------------
750 MED_MED_RDWR_DRIVER21::MED_MED_RDWR_DRIVER21()
753 MED_MED_RDWR_DRIVER21::MED_MED_RDWR_DRIVER21(const string & fileName, MED * const ptrMed):
754 MED_MED_RDONLY_DRIVER21(fileName,ptrMed),
755 MED_MED_WRONLY_DRIVER21(fileName,ptrMed),
756 IMED_MED_RDWR_DRIVER(fileName,ptrMed),
757 MED_MED_DRIVER21(fileName,ptrMed,MED_REMP),
758 IMED_MED_WRONLY_DRIVER(fileName,ptrMed),
759 IMED_MED_RDONLY_DRIVER(fileName,ptrMed),
760 MED_MED_DRIVER(fileName,ptrMed,MED_REMP)
763 MED_MED_RDWR_DRIVER21::MED_MED_RDWR_DRIVER21(const MED_MED_RDWR_DRIVER21 & driver):
764 MED_MED_RDONLY_DRIVER21(driver),
765 MED_MED_WRONLY_DRIVER21(driver),
766 IMED_MED_RDWR_DRIVER(driver),
767 MED_MED_DRIVER21(driver),
768 IMED_MED_WRONLY_DRIVER(driver),
769 IMED_MED_RDONLY_DRIVER(driver),
770 MED_MED_DRIVER(driver)
773 MED_MED_RDWR_DRIVER21::~MED_MED_RDWR_DRIVER21() {
774 MESSAGE("MED_MED_RDWR_DRIVER21::~MED_MED_RDWR_DRIVER21() has been destroyed");
777 GENDRIVER * MED_MED_RDWR_DRIVER21::copy(void) const
779 return new MED_MED_RDWR_DRIVER21(*this) ;
782 void MED_MED_RDWR_DRIVER21::read(void)
783 throw (MEDEXCEPTION) // from MED_MED_RDONLY_DRIVER::read()
785 BEGIN_OF("MED_MED_RDWR_DRIVER21::read(void)");
786 MED_MED_RDONLY_DRIVER21::read();
787 END_OF("MED_MED_RDWR_DRIVER21::read(void)");
790 void MED_MED_RDWR_DRIVER21::readFileStruct(void)
791 throw (MEDEXCEPTION) // from MED_MED_RDONLY_DRIVER::readFileStruct()
793 BEGIN_OF("MED_MED_RDWR_DRIVER21::readFileStruct(void)");
794 MED_MED_RDONLY_DRIVER21::readFileStruct();
795 END_OF("MED_MED_RDWR_DRIVER21::readFileStruct(void)");
798 void MED_MED_RDWR_DRIVER21::write(void) const
799 throw (MEDEXCEPTION) // from MED_MED_WRONLY_DRIVER::write()
801 BEGIN_OF("MED_MED_RDWR_DRIVER21::write(void) const");
802 MED_MED_WRONLY_DRIVER21::write();
803 END_OF("MED_MED_RDWR_DRIVER21::write(void) const");
806 void MED_MED_RDWR_DRIVER21::writeFrom(void) const
807 throw (MEDEXCEPTION) // from MED_MED_WRONLY_DRIVER::writeFrom();
809 BEGIN_OF("MED_MED_RDWR_DRIVER21::writeFrom(void) const");
810 MED_MED_WRONLY_DRIVER21::writeFrom();
811 END_OF("MED_MED_RDWR_DRIVER21::writeFrom(void) const");