-// MED MEDMEM : MED files in memory
-//
-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
-//
-//
-//
-// File : MEDMEM_MedFieldDriver.hxx
-// Module : MED
-
#ifndef MED_FIELD_DRIVER_HXX
#define MED_FIELD_DRIVER_HXX
//using namespace MED_FR ;
+namespace MEDMEM {
template <class T> class FIELD;
// A QD LA CLASSE MED_ALL_ELEMENTS_DRIVER.... :) pour mutualiser le open ..... avec led _medIdt...
GENDRIVER * copy( void ) const ;
};
+}
/*-------------------------*/
/* template implementation */
/*-------------------------*/
+using namespace MEDMEM;
/*--------------------- DRIVER PART -------------------------------*/
template <class T> void MED_FIELD_DRIVER<T>::setFieldName(const string & fieldName)
for (int i=0; i<NumberOfTypes; i++) {
MESSAGE ("Type["<<i+1<<"] :"<< Types[i]);
MESSAGE ("Entity :"<<_ptrField->_support->getEntity());
- NumberOfValues[i] =
- MEDnVal(_medIdt,
- const_cast <char*> (_fieldName.c_str()),
- (MED_FR::med_entite_maillage)_ptrField->_support->getEntity(),
- (MED_FR::med_geometrie_element)Types[i],
- _ptrField->_iterationNumber,
- _ptrField->_orderNumber) ; // no time step ! prend en compte le nbre de pt de gauss
+// NumberOfValues[i] =
+// MEDnVal(_medIdt,
+// const_cast <char*> (_fieldName.c_str()),
+// (MED_FR::med_entite_maillage)_ptrField->_support->getEntity(),
+// (MED_FR::med_geometrie_element)Types[i],
+// _ptrField->_iterationNumber,
+// _ptrField->_orderNumber) ; // no time step ! prend en compte le nbre de pt de gauss
// test if NumberOfValues is the same in _support !!! TODO that !!
// we suppose it is
// we could allocate array
+ // Be really carefull about the profil; especially the last arg of
+ // MEDnVal
+
+ NumberOfValues[i] =
+ MEDnVal(_medIdt,
+ const_cast <char*> (_fieldName.c_str()),
+ (MED_FR::med_entite_maillage)_ptrField->_support->getEntity(),
+ (MED_FR::med_geometrie_element) Types[i],
+ _ptrField->_iterationNumber, _ptrField->_orderNumber,
+ const_cast <char*> (_ptrField->_support->getMesh()->getName().c_str()),
+ MED_FR::MED_COMPACT) ;
+
myValues[i] = new T[ NumberOfValues[i]*numberOfComponents ] ;
TotalNumberOfValues+=NumberOfValues[i] ;// diviser par le nombre de point de gauss
char * ProfilName = new char[MED_TAILLE_NOM+1];
+ char * LocalGaussName = new char[MED_TAILLE_NOM+1];
MESSAGE ("NumberOfValues :"<< NumberOfValues[i]);
MESSAGE ("NumberOfComponents :"<< numberOfComponents);
MESSAGE ("MESH_NAME :"<< MeshName.c_str());
MESSAGE("MED_GEOM :"<<(MED_FR::med_geometrie_element)Types[i]);
MESSAGE("Iteration :"<<_ptrField->getIterationNumber());
MESSAGE("Order :"<<_ptrField->getOrderNumber());
- if ( MED_FR::MEDchampLire(_medIdt,const_cast <char*> (MeshName.c_str()),
- const_cast <char*> (_fieldName.c_str()),
- (unsigned char*) myValues[i],
- MED_FR::MED_NO_INTERLACE,
- MED_ALL,
- ProfilName,
- (MED_FR::med_entite_maillage) _ptrField->_support->getEntity(),(MED_FR::med_geometrie_element)Types[i],
- _ptrField->getIterationNumber(),
- _ptrField->getOrderNumber()
- ) < 0) {
+ _ptrField->_numberOfValues+=NumberOfValues[i]; // problem with gauss point : _numberOfValues != TotalNumberOfValues !!!!!!!
+
+ err = MEDchampLire(_medIdt,const_cast <char*> (MeshName.c_str()),
+ const_cast <char*> (_fieldName.c_str()),
+ (unsigned char*) myValues[i],
+ MED_FR::MED_NO_INTERLACE,MED_ALL,
+ LocalGaussName,ProfilName,
+ MED_FR::MED_NO_PFLMOD,
+ (MED_FR::med_entite_maillage) _ptrField->_support->getEntity(),(MED_FR::med_geometrie_element)Types[i],
+ _ptrField->getIterationNumber(),
+ _ptrField->getOrderNumber());
+
+ if ( err < 0) {
// we must do some delete !!!
for(int j=0; j<=i;j++)
delete[] myValues[j];
delete[] myValues;
delete[] NumberOfValues ;
delete[] ProfilName;
+ delete[] LocalGaussName;
delete[] _ptrField->_componentsTypes ;
delete[] _ptrField->_componentsNames ;
delete[] _ptrField->_componentsUnits ;
throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": ERROR when read value")) ;
}
+ // At this time ProfilName should be MED_FR::MED_NOPFL and
+ // LocalGaussName should be MED_FR::MED_NOGAUSS
delete[] ProfilName ;
+ delete[] LocalGaussName ;
}
// allocate _value
// probleme avec les points de gauss : voir lorsqu-il y en a (!= 1)
for (int j=0; j<NumberOfTypes; j++) {
T * myValue = myValues[j] ;
int NumberOf = NumberOfValues[j] ;
- _ptrField->_numberOfValues+=NumberOf; // problem with gauss point : _numberOfValues != TotalNumberOfValues !!!!!!!
+// _ptrField->_numberOfValues+=NumberOf; // problem with gauss point : _numberOfValues != TotalNumberOfValues !!!!!!!
int offset = NumberOf*i ;
for (int k=0 ; k<NumberOf; k++) {
//ValuesT[Count]=myValue[k+offset] ;
MED_EN::med_type_champ ValueType=_ptrField->getValueType() ;
+ MESSAGE("Template Type =|"<<ValueType<<"|");
+
// le champ existe deja ???
char * champName = new char[MED_TAILLE_NOM+1] ;
MED_FR::med_type_champ type ;
for (int i=0;i<NumberOfType;i++) {
int NumberOfElements = mySupport->getNumberOfElements(Types[i]) ;
- MESSAGE(" "<<_ptrField->getName());
- MESSAGE(" "<<NumberOfElements);
- MESSAGE(" "<<NumberOfGaussPoint[i]);
- MESSAGE(" "<<mySupport->getEntity());
- MESSAGE(" "<<Types[i]);
- MESSAGE(" "<<_ptrField->getIterationNumber());
- MESSAGE(" "<<_ptrField->getTime());
- MESSAGE(" "<<_ptrField->getOrderNumber());
- MESSAGE("MEDchampEcr :"<<MeshName.c_str());
-
const T * value = _ptrField->getValueI(MED_EN::MED_FULL_INTERLACE,Index) ;
-
- err=MED_FR::MEDchampEcr(_medIdt, const_cast <char*> ( MeshName.c_str()) , //( string(mesh_name).resize(MED_TAILLE_NOM).c_str())
+
+ MESSAGE("_medIdt : "<<_medIdt);
+ MESSAGE("MeshName.c_str() : "<<MeshName.c_str());
+ MESSAGE("_ptrField->getName() : "<<_ptrField->getName());
+ MESSAGE("value : "<<value);
+ MESSAGE("NumberOfElements : "<<NumberOfElements);
+ MESSAGE("NumberOfGaussPoint[i] : "<<NumberOfGaussPoint[i]);
+ MESSAGE("mySupport->getEntity() : "<<mySupport->getEntity());
+ MESSAGE("Types[i] : "<<Types[i]);
+ MESSAGE("_ptrField->getIterationNumber() : "<<_ptrField->getIterationNumber());
+ MESSAGE("_ptrField->getTime() : "<<_ptrField->getTime());
+ MESSAGE("_ptrField->getOrderNumber() : "<<_ptrField->getOrderNumber());
+
+/* char chanom[MED_TAILLE_NOM+1];
+ char chacomp[MED_TAILLE_NOM+1];
+ char chaunit[MED_TAILLE_NOM+1];
+ MED_FR::med_type_champ chatype;
+ med_int chancomp=1;
+
+ err=MED_FR::MEDchampInfo(_medIdt,1,chanom,&chatype,chacomp,chaunit,chancomp);
+
+ if (err<0)
+ {
+ cout<<"=======================================================================> gros probleme"<<endl;
+ exit(-1);
+ }
+ cout<<"==================> nom lu = "<<chanom<<endl;
+ cout<<"==================> type lu = "<<chatype<<endl;
+ cout<<"==================> nom composante lu = "<<chacomp<<endl;
+ cout<<"==================> nom unit lu = "<<chaunit<<endl;
+ cout<<"==================> valeur de MED_FR::MED_REEL64 = "<<MED_FR::MED_REEL64<<endl;
+*/
+
+// err=MED_FR::MEDchampEcr(_medIdt,
+// const_cast <char*> ( MeshName.c_str()) , //( string(mesh_name).resize(MED_TAILLE_NOM).c_str())
+// const_cast <char*> ( (_ptrField->getName()).c_str()),
+// (unsigned char*)value,
+// MED_FR::MED_FULL_INTERLACE,
+// NumberOfElements,
+// NumberOfGaussPoint[i],
+// MED_ALL,
+// MED_NOPFL,
+// MED_FR::MED_REMP, // PROFIL NON GERE, mode de remplacement non géré
+// (MED_FR::med_entite_maillage)mySupport->getEntity(),
+// (MED_FR::med_geometrie_element)Types[i],
+// _ptrField->getIterationNumber(),
+// " ",
+// _ptrField->getTime(),
+// _ptrField->getOrderNumber()
+// );
+
+ err=MED_FR::MEDchampEcr(_medIdt,
+ const_cast <char*> ( MeshName.c_str()) , //( string(mesh_name).resize(MED_TAILLE_NOM).c_str())
const_cast <char*> ( (_ptrField->getName()).c_str()),
- (unsigned char*)value, MED_FR::MED_FULL_INTERLACE,
- NumberOfElements,
- NumberOfGaussPoint[i],MED_ALL, MED_NOPFL, MED_FR::MED_REMP, // PROFIL NON GERE, mode de remplacement non géré
+ (unsigned char*)value,
+ MED_FR::MED_FULL_INTERLACE,
+ NumberOfElements*NumberOfGaussPoint[i],
+ MED_NOGAUSS, MED_ALL, MED_NOPFL,
+ MED_FR::MED_NO_PFLMOD, // PROFIL NON GERE, mode de remplacement non géré
(MED_FR::med_entite_maillage)mySupport->getEntity(),
(MED_FR::med_geometrie_element)Types[i],
- _ptrField->getIterationNumber()," ",
- _ptrField->getTime(),_ptrField->getOrderNumber()
+ _ptrField->getIterationNumber(),
+ " ",
+ _ptrField->getTime(),
+ _ptrField->getOrderNumber()
);
+
if (err < MED_VALID )
throw MEDEXCEPTION(LOCALIZED( STRING(LOC)
<<": Error in writing Field "<< _ptrField->getName() <<", type "<<Types[i]
)
);
+
Index += NumberOfElements ;
}
MED_FIELD_RDONLY_DRIVER<T>::read();
END_OF("MED_FIELD_RDWR_DRIVER::read(void)");
}
-
/*-----------------------------------------------------------------*/
#endif /* MED_FIELD_DRIVER_HXX */