From 3857007e3b712cc2bf885df5a3af5405c552985a Mon Sep 17 00:00:00 2001 From: ageay Date: Fri, 28 Jun 2013 17:02:01 +0000 Subject: [PATCH] MED file loading on demand. --- src/MEDCoupling/MEDCouplingMemArray.cxx | 29 ++- src/MEDCoupling/MEDCouplingMemArray.hxx | 7 +- src/MEDCoupling/MEDCouplingMemArray.txx | 14 +- src/MEDCoupling/MEDCouplingMemArrayChar.cxx | 13 + .../Test/MEDCouplingBasicsTest1.cxx | 2 +- src/MEDCoupling_Swig/MEDCouplingBasicsTest.py | 24 ++ src/MEDCoupling_Swig/MEDCouplingMemArray.i | 5 +- src/MEDLoader/MEDFileField.cxx | 229 +++++++++++++++++- src/MEDLoader/MEDFileField.hxx | 18 +- src/MEDLoader/Swig/MEDLoaderCommon.i | 11 +- src/MEDLoader/Swig/MEDLoaderTest3.py | 1 - 11 files changed, 325 insertions(+), 28 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingMemArray.cxx b/src/MEDCoupling/MEDCouplingMemArray.cxx index d3354f7fa..b5dd7300f 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.cxx +++ b/src/MEDCoupling/MEDCouplingMemArray.cxx @@ -402,7 +402,8 @@ void DataArray::setInfoOnComponent(int i, const char *info) throw(INTERP_KERNEL: /*! * Sets information on all components. This method can change number of components * at certain conditions; if the conditions are not respected, an exception is thrown. - * The number of components can be changed provided that \a this is not allocated. + * The number of components can be changed in \a this only if \a this is not allocated. + * The condition of number of components must not be changed. * * To know more on format of the component information see * \ref MEDCouplingArrayBasicsCompoName "DataArrays infos". @@ -652,6 +653,16 @@ void DataArrayDouble::checkAllocated() const throw(INTERP_KERNEL::Exception) throw INTERP_KERNEL::Exception("DataArrayDouble::checkAllocated : Array is defined but not allocated ! Call alloc or setValues method first !"); } +/*! + * This method desallocated \a this without modification of informations relative to the components. + * After call of this method, DataArrayDouble::isAllocated will return false. + * If \a this is already not allocated, \a this is let unchanged. + */ +void DataArrayDouble::desallocate() throw(INTERP_KERNEL::Exception) +{ + _mem.destroy(); +} + std::size_t DataArrayDouble::getHeapMemorySize() const { std::size_t sz=_mem.getNbOfElemAllocated(); @@ -1209,9 +1220,12 @@ bool DataArrayDouble::isEqualWithoutConsideringStr(const DataArrayDouble& other, * than the current number the array is truncated, otherwise the array is extended. * \param [in] nbOfTuples - new number of tuples. * \throw If \a this is not allocated. + * \throw If \a nbOfTuples is negative. */ void DataArrayDouble::reAlloc(int nbOfTuples) throw(INTERP_KERNEL::Exception) { + if(nbOfTuples<0) + throw INTERP_KERNEL::Exception("DataArrayDouble::reAlloc : input new number of tuples should be >=0 !"); checkAllocated(); _mem.reAlloc(getNumberOfComponents()*(std::size_t)nbOfTuples); declareAsNew(); @@ -5428,6 +5442,16 @@ void DataArrayInt::checkAllocated() const throw(INTERP_KERNEL::Exception) throw INTERP_KERNEL::Exception("DataArrayInt::checkAllocated : Array is defined but not allocated ! Call alloc or setValues method first !"); } +/*! + * This method desallocated \a this without modification of informations relative to the components. + * After call of this method, DataArrayInt::isAllocated will return false. + * If \a this is already not allocated, \a this is let unchanged. + */ +void DataArrayInt::desallocate() throw(INTERP_KERNEL::Exception) +{ + _mem.destroy(); +} + std::size_t DataArrayInt::getHeapMemorySize() const { std::size_t sz=_mem.getNbOfElemAllocated(); @@ -7111,9 +7135,12 @@ DataArrayInt *DataArrayInt::changeNbOfComponents(int newNbOfComp, int dftValue) * than the current number the array is truncated, otherwise the array is extended. * \param [in] nbOfTuples - new number of tuples. * \throw If \a this is not allocated. + * \throw If \a nbOfTuples is negative. */ void DataArrayInt::reAlloc(int nbOfTuples) throw(INTERP_KERNEL::Exception) { + if(nbOfTuples<0) + throw INTERP_KERNEL::Exception("DataArrayInt::reAlloc : input new number of tuples should be >=0 !"); checkAllocated(); _mem.reAlloc(getNumberOfComponents()*(std::size_t)nbOfTuples); declareAsNew(); diff --git a/src/MEDCoupling/MEDCouplingMemArray.hxx b/src/MEDCoupling/MEDCouplingMemArray.hxx index 416caf8ee..1f2bc2c2c 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.hxx +++ b/src/MEDCoupling/MEDCouplingMemArray.hxx @@ -98,7 +98,7 @@ namespace ParaMEDMEM static void CPPDeallocator(void *pt, void *param); static void CDeallocator(void *pt, void *param); private: - static void destroyPointer(T *pt, Deallocator dealloc, void *param); + static void DestroyPointer(T *pt, Deallocator dealloc, void *param); static Deallocator BuildFromType(DeallocType type) throw(INTERP_KERNEL::Exception); private: std::size_t _nb_of_elem; @@ -136,10 +136,12 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT int getNumberOfComponents() const { return (int)_info_on_compo.size(); } MEDCOUPLING_EXPORT virtual bool isAllocated() const throw(INTERP_KERNEL::Exception) = 0; MEDCOUPLING_EXPORT virtual void checkAllocated() const throw(INTERP_KERNEL::Exception) = 0; + MEDCOUPLING_EXPORT virtual void desallocate() throw(INTERP_KERNEL::Exception) = 0; MEDCOUPLING_EXPORT virtual int getNumberOfTuples() const throw(INTERP_KERNEL::Exception) = 0; MEDCOUPLING_EXPORT virtual std::size_t getNbOfElems() const throw(INTERP_KERNEL::Exception) = 0; MEDCOUPLING_EXPORT virtual std::size_t getNbOfElemAllocated() const throw(INTERP_KERNEL::Exception) = 0; MEDCOUPLING_EXPORT virtual void alloc(int nbOfTuple, int nbOfCompo=1) throw(INTERP_KERNEL::Exception) = 0; + MEDCOUPLING_EXPORT virtual void reAlloc(int newNbOfTuple) throw(INTERP_KERNEL::Exception) = 0; MEDCOUPLING_EXPORT virtual void renumberInPlace(const int *old2New) throw(INTERP_KERNEL::Exception) = 0; MEDCOUPLING_EXPORT virtual void renumberInPlaceR(const int *new2Old) throw(INTERP_KERNEL::Exception) = 0; MEDCOUPLING_EXPORT virtual void setContigPartOfSelectedValues(int tupleIdStart, const DataArray *aBase, const DataArrayInt *tuplesSelec) throw(INTERP_KERNEL::Exception) = 0; @@ -189,6 +191,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT static DataArrayDouble *New(); MEDCOUPLING_EXPORT bool isAllocated() const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void checkAllocated() const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void desallocate() throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT int getNumberOfTuples() const throw(INTERP_KERNEL::Exception) { return _info_on_compo.empty()?0:_mem.getNbOfElem()/getNumberOfComponents(); } MEDCOUPLING_EXPORT std::size_t getNbOfElems() const throw(INTERP_KERNEL::Exception) { return _mem.getNbOfElem(); } MEDCOUPLING_EXPORT std::size_t getHeapMemorySize() const; @@ -411,6 +414,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT static DataArrayInt *New(); MEDCOUPLING_EXPORT bool isAllocated() const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void checkAllocated() const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void desallocate() throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT int getNumberOfTuples() const throw(INTERP_KERNEL::Exception) { return _info_on_compo.empty()?0:_mem.getNbOfElem()/getNumberOfComponents(); } MEDCOUPLING_EXPORT std::size_t getNbOfElems() const throw(INTERP_KERNEL::Exception) { return _mem.getNbOfElem(); } MEDCOUPLING_EXPORT std::size_t getHeapMemorySize() const; @@ -638,6 +642,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT virtual DataArrayChar *deepCpy() const = 0; MEDCOUPLING_EXPORT bool isAllocated() const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void checkAllocated() const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT void desallocate() throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT int getNumberOfTuples() const throw(INTERP_KERNEL::Exception) { return _info_on_compo.empty()?0:_mem.getNbOfElem()/getNumberOfComponents(); } MEDCOUPLING_EXPORT std::size_t getNbOfElems() const throw(INTERP_KERNEL::Exception) { return _mem.getNbOfElem(); } MEDCOUPLING_EXPORT std::size_t getHeapMemorySize() const; diff --git a/src/MEDCoupling/MEDCouplingMemArray.txx b/src/MEDCoupling/MEDCouplingMemArray.txx index 71be0a297..1eb130c25 100644 --- a/src/MEDCoupling/MEDCouplingMemArray.txx +++ b/src/MEDCoupling/MEDCouplingMemArray.txx @@ -61,9 +61,9 @@ namespace ParaMEDMEM template void MemArray::useArray(const T *array, bool ownership, DeallocType type, std::size_t nbOfElem) { + destroy(); _nb_of_elem=nbOfElem; _nb_of_elem_alloc=nbOfElem; - destroy(); if(ownership) _pointer.setInternal(const_cast(array)); else @@ -75,9 +75,9 @@ namespace ParaMEDMEM template void MemArray::useExternalArrayWithRWAccess(const T *array, std::size_t nbOfElem) { + destroy(); _nb_of_elem=nbOfElem; _nb_of_elem_alloc=nbOfElem; - destroy(); _pointer.setInternal(const_cast(array)); _ownership=false; _dealloc=CPPDeallocator; @@ -365,7 +365,7 @@ namespace ParaMEDMEM T *pointer=(T*)malloc(newNbOfElements*sizeof(T)); std::copy(_pointer.getConstPointer(),_pointer.getConstPointer()+std::min(_nb_of_elem,newNbOfElements),pointer); if(_ownership) - destroyPointer(const_cast(_pointer.getConstPointer()),_dealloc,_param_for_deallocator);//Do not use getPointer because in case of _external + DestroyPointer(const_cast(_pointer.getConstPointer()),_dealloc,_param_for_deallocator);//Do not use getPointer because in case of _external _pointer.setInternal(pointer); _nb_of_elem=std::min(_nb_of_elem,newNbOfElements); _nb_of_elem_alloc=newNbOfElements; @@ -391,7 +391,7 @@ namespace ParaMEDMEM T *pointer=(T*)malloc(newNbOfElements*sizeof(T)); std::copy(_pointer.getConstPointer(),_pointer.getConstPointer()+std::min(_nb_of_elem,newNbOfElements),pointer); if(_ownership) - destroyPointer(const_cast(_pointer.getConstPointer()),_dealloc,_param_for_deallocator);//Do not use getPointer because in case of _external + DestroyPointer(const_cast(_pointer.getConstPointer()),_dealloc,_param_for_deallocator);//Do not use getPointer because in case of _external _pointer.setInternal(pointer); _nb_of_elem=newNbOfElements; _nb_of_elem_alloc=newNbOfElements; @@ -427,7 +427,7 @@ namespace ParaMEDMEM } template - void MemArray::destroyPointer(T *pt, typename MemArray::Deallocator dealloc, void *param) + void MemArray::DestroyPointer(T *pt, typename MemArray::Deallocator dealloc, void *param) { if(dealloc) dealloc(pt,param); @@ -437,11 +437,13 @@ namespace ParaMEDMEM void MemArray::destroy() { if(_ownership) - destroyPointer(const_cast(_pointer.getConstPointer()),_dealloc,_param_for_deallocator);//Do not use getPointer because in case of _external + DestroyPointer(const_cast(_pointer.getConstPointer()),_dealloc,_param_for_deallocator);//Do not use getPointer because in case of _external _pointer.null(); _ownership=false; _dealloc=NULL; _param_for_deallocator=NULL; + _nb_of_elem=0; + _nb_of_elem_alloc=0; } template diff --git a/src/MEDCoupling/MEDCouplingMemArrayChar.cxx b/src/MEDCoupling/MEDCouplingMemArrayChar.cxx index 37f69d28f..d3872cf21 100644 --- a/src/MEDCoupling/MEDCouplingMemArrayChar.cxx +++ b/src/MEDCoupling/MEDCouplingMemArrayChar.cxx @@ -50,6 +50,16 @@ void DataArrayChar::checkAllocated() const throw(INTERP_KERNEL::Exception) throw INTERP_KERNEL::Exception("DataArrayChar::checkAllocated : Array is defined but not allocated ! Call alloc or setValues method first !"); } +/*! + * This method desallocated \a this without modification of informations relative to the components. + * After call of this method, DataArrayChar::isAllocated will return false. + * If \a this is already not allocated, \a this is let unchanged. + */ +void DataArrayChar::desallocate() throw(INTERP_KERNEL::Exception) +{ + _mem.destroy(); +} + std::size_t DataArrayChar::getHeapMemorySize() const { std::size_t sz=_mem.getNbOfElemAllocated(); @@ -336,9 +346,12 @@ std::string DataArrayChar::reprZip() const throw(INTERP_KERNEL::Exception) * than the current number the array is truncated, otherwise the array is extended. * \param [in] nbOfTuples - new number of tuples. * \throw If \a this is not allocated. + * \throw If \a nbOfTuples is negative. */ void DataArrayChar::reAlloc(int nbOfTuples) throw(INTERP_KERNEL::Exception) { + if(nbOfTuples<0) + throw INTERP_KERNEL::Exception("DataArrayChar::reAlloc : input new number of tuples should be >=0 !"); checkAllocated(); _mem.reAlloc(getNumberOfComponents()*(std::size_t)nbOfTuples); declareAsNew(); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx index 615c79a70..563774066 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest1.cxx @@ -145,7 +145,7 @@ void MEDCouplingBasicsTest1::testMesh() CPPUNIT_ASSERT_EQUAL(MEDCouplingMesh::GetDimensionOfGeometricType(INTERP_KERNEL::NORM_TRI3),2); CPPUNIT_ASSERT_EQUAL(std::string(MEDCouplingMesh::GetReprOfGeometricType(INTERP_KERNEL::NORM_TRI3)),std::string("NORM_TRI3")); CPPUNIT_ASSERT_THROW(MEDCouplingMesh::GetNumberOfNodesOfGeometricType(INTERP_KERNEL::NORM_POLYGON),INTERP_KERNEL::Exception); - CPPUNIT_ASSERT(not MEDCouplingMesh::IsStaticGeometricType(INTERP_KERNEL::NORM_POLYGON)); + CPPUNIT_ASSERT(!MEDCouplingMesh::IsStaticGeometricType(INTERP_KERNEL::NORM_POLYGON)); CPPUNIT_ASSERT(MEDCouplingMesh::IsLinearGeometricType(INTERP_KERNEL::NORM_POLYGON)); CPPUNIT_ASSERT_EQUAL(MEDCouplingMesh::GetDimensionOfGeometricType(INTERP_KERNEL::NORM_POLYGON),2); CPPUNIT_ASSERT_EQUAL(std::string(MEDCouplingMesh::GetReprOfGeometricType(INTERP_KERNEL::NORM_POLYGON)),std::string("NORM_POLYGON")); diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 941be3ae3..118a6547c 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -13369,6 +13369,30 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertTrue(c.isEqual(DataArrayInt([5,2,1,10]))) pass + def testSwig2DADesallocate1(self): + d=DataArrayDouble([(1,2),(6,7),(6,8)]) ; d.setInfoOnComponents(["aa","bbb"]) + self.assertTrue(d.isAllocated()) + d.checkAllocated() + self.assertEqual(d.getInfoOnComponents(),["aa","bbb"]) + ref=d.getHeapMemorySize() + d.desallocate() + self.assertEqual(ref-d.getHeapMemorySize(),6*8) + self.assertTrue(not d.isAllocated()) + self.assertEqual(d.getInfoOnComponents(),["aa","bbb"]) + self.assertRaises(InterpKernelException,d.checkAllocated) + # + d=DataArrayInt([(1,2),(6,7),(6,8)]) ; d.setInfoOnComponents(["aa","bbb"]) + self.assertTrue(d.isAllocated()) + d.checkAllocated() + self.assertEqual(d.getInfoOnComponents(),["aa","bbb"]) + ref=d.getHeapMemorySize() + d.desallocate() + self.assertEqual(ref-d.getHeapMemorySize(),6*4) + self.assertTrue(not d.isAllocated()) + self.assertEqual(d.getInfoOnComponents(),["aa","bbb"]) + self.assertRaises(InterpKernelException,d.checkAllocated) + pass + def setUp(self): pass pass diff --git a/src/MEDCoupling_Swig/MEDCouplingMemArray.i b/src/MEDCoupling_Swig/MEDCouplingMemArray.i index a4deec3bd..620c02a0f 100644 --- a/src/MEDCoupling_Swig/MEDCouplingMemArray.i +++ b/src/MEDCoupling_Swig/MEDCouplingMemArray.i @@ -41,8 +41,10 @@ namespace ParaMEDMEM void setInfoOnComponent(int i, const char *info) throw(INTERP_KERNEL::Exception); int getNumberOfComponents() const; virtual void alloc(int nbOfTuple, int nbOfCompo=1) throw(INTERP_KERNEL::Exception); + virtual void reAlloc(int nbOfTuples) throw(INTERP_KERNEL::Exception); virtual bool isAllocated() const throw(INTERP_KERNEL::Exception); virtual void checkAllocated() const throw(INTERP_KERNEL::Exception); + virtual void desallocate() throw(INTERP_KERNEL::Exception); virtual int getNumberOfTuples() const throw(INTERP_KERNEL::Exception); virtual std::size_t getNbOfElems() const throw(INTERP_KERNEL::Exception); virtual std::size_t getNbOfElemAllocated() const throw(INTERP_KERNEL::Exception); @@ -285,7 +287,6 @@ namespace ParaMEDMEM std::string reprZip() const throw(INTERP_KERNEL::Exception); bool isEqual(const DataArrayDouble& other, double prec) const throw(INTERP_KERNEL::Exception); bool isEqualWithoutConsideringStr(const DataArrayDouble& other, double prec) const throw(INTERP_KERNEL::Exception); - void reAlloc(int nbOfTuples) throw(INTERP_KERNEL::Exception); DataArrayInt *convertToIntArr() const throw(INTERP_KERNEL::Exception); DataArrayDouble *fromNoInterlace() const throw(INTERP_KERNEL::Exception); DataArrayDouble *toNoInterlace() const throw(INTERP_KERNEL::Exception); @@ -2314,7 +2315,6 @@ namespace ParaMEDMEM DataArrayInt *invertArrayO2N2N2O(int newNbOfElem) const throw(INTERP_KERNEL::Exception); DataArrayInt *invertArrayN2O2O2N(int oldNbOfElem) const throw(INTERP_KERNEL::Exception); DataArrayInt *invertArrayO2N2N2OBis(int newNbOfElem) const throw(INTERP_KERNEL::Exception); - void reAlloc(int nbOfTuples) throw(INTERP_KERNEL::Exception); DataArrayDouble *convertToDblArr() const throw(INTERP_KERNEL::Exception); DataArrayInt *fromNoInterlace() const throw(INTERP_KERNEL::Exception); DataArrayInt *toNoInterlace() const throw(INTERP_KERNEL::Exception); @@ -4572,7 +4572,6 @@ namespace ParaMEDMEM void fillWithValue(char val) throw(INTERP_KERNEL::Exception); std::string repr() const throw(INTERP_KERNEL::Exception); std::string reprZip() const throw(INTERP_KERNEL::Exception); - void reAlloc(int nbOfTuples) throw(INTERP_KERNEL::Exception); DataArrayInt *convertToIntArr() const throw(INTERP_KERNEL::Exception); DataArrayChar *renumber(const int *old2New) const throw(INTERP_KERNEL::Exception); DataArrayChar *renumberR(const int *new2Old) const throw(INTERP_KERNEL::Exception); diff --git a/src/MEDLoader/MEDFileField.cxx b/src/MEDLoader/MEDFileField.cxx index 8471e77ce..02dc4c7f1 100644 --- a/src/MEDLoader/MEDFileField.cxx +++ b/src/MEDLoader/MEDFileField.cxx @@ -482,9 +482,11 @@ void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, int profileIt, INTERP_KERNEL::NormalizedCellType geoType=getGeoType(); med_geometry_type mgeoti; med_entity_type menti=MEDFileFieldPerMeshPerType::ConvertIntoMEDFileType(type,geoType,mgeoti); - DataArray *arr=getOrCreateAndGetArray(); if(_start>_end) throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : internal error in range !"); + if(_start==_end) + return ; + DataArray *arr=getOrCreateAndGetArray();//arr is not null due to the spec of getOrCreateAndGetArray if(_start<0 || _start>=arr->getNumberOfTuples()) { std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << ") !"; @@ -495,10 +497,19 @@ void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, int profileIt, std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : Invalid start ("<< _start << ") regarding admissible range of allocated array [0," << arr->getNumberOfTuples() << "] !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } + med_int tmp1,nbi; + INTERP_KERNEL::AutoPtr locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE); + med_int nbValsInFile=MEDfieldnValueWithProfileByName(fid,fieldName.c_str(),iteration,order,menti,mgeoti,_profile.c_str(),MED_COMPACT_PFLMODE,&tmp1,locname,&nbi); + int nbOfCompo=arr->getNumberOfComponents(); + if(_end-_start!=nbValsInFile*nbi) + { + std::ostringstream oss; oss << "MEDFileFieldPerMeshPerTypePerDisc::loadBigArray : The number of tuples to read is " << nbValsInFile << "*" << nbi << " (nb integration points) ! But in data structure it values " << _end-_start << " is expected !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } DataArrayDouble *arrD=dynamic_cast(arr); if(arrD) { - double *startFeeding=arrD->getPointer()+_start*arrD->getNumberOfComponents(); + double *startFeeding=arrD->getPointer()+_start*nbOfCompo; MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE, _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast(startFeeding)); return ; @@ -506,7 +517,7 @@ void MEDFileFieldPerMeshPerTypePerDisc::loadBigArray(med_idt fid, int profileIt, DataArrayInt *arrI=dynamic_cast(arr); if(arrI) { - int *startFeeding=arrI->getPointer()+_start*arrI->getNumberOfComponents(); + int *startFeeding=arrI->getPointer()+_start*nbOfCompo; MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE, _profile.c_str(),MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast(startFeeding)); return ; @@ -4000,16 +4011,20 @@ void MEDFileAnyTypeField1TSWithoutSDA::writeLL(med_idt fid, const MEDFileWritabl _field_per_mesh[0]->writeLL(fid,nasc); } -void MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile() throw(INTERP_KERNEL::Exception) +/*! + * This methods returns true is the allocation has been needed leading to a modification of state in \a this->_nb_of_tuples_to_be_allocated. + * If false is returned the memory allocation is not required. + */ +bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile() throw(INTERP_KERNEL::Exception) { if(_nb_of_tuples_to_be_allocated>=0) { getOrCreateAndGetArray()->alloc(_nb_of_tuples_to_be_allocated,getNumberOfComponents()); _nb_of_tuples_to_be_allocated=-2; - return ; + return true; } if(_nb_of_tuples_to_be_allocated==-2 || _nb_of_tuples_to_be_allocated==-3) - return ; + return false; if(_nb_of_tuples_to_be_allocated==-1) throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : trying to read from a file an empty instance ! Need to prepare the structure before !"); if(_nb_of_tuples_to_be_allocated<-3) @@ -4044,12 +4059,29 @@ void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively(med_idt fid, con (*it)->loadBigArraysRecursively(fid,nasc); } +void MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception) +{ + if(allocIfNecessaryTheArrayToReceiveDataFromFile()) + for(std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > >::iterator it=_field_per_mesh.begin();it!=_field_per_mesh.end();it++) + (*it)->loadBigArraysRecursively(fid,nasc); +} + void MEDFileAnyTypeField1TSWithoutSDA::loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception) { loadOnlyStructureOfDataRecursively(fid,nasc); loadBigArraysRecursively(fid,nasc); } +void MEDFileAnyTypeField1TSWithoutSDA::releaseArrays() throw(INTERP_KERNEL::Exception) +{ + DataArray *thisArr(getUndergroundDataArray()); + if(thisArr && thisArr->isAllocated()) + { + _nb_of_tuples_to_be_allocated=thisArr->getNumberOfTuples(); + thisArr->desallocate(); + } +} + std::size_t MEDFileAnyTypeField1TSWithoutSDA::getHeapMemorySize() const { std::size_t ret=_dt_unit.capacity()+_field_per_mesh.capacity()*sizeof(MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh >); @@ -4687,10 +4719,16 @@ MEDFileAnyTypeField1TSWithoutSDA *MEDFileField1TSWithoutSDA::deepCpy() const thr void MEDFileField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception) { if(!arr) - _arr=0; + { + _nb_of_tuples_to_be_allocated=-1; + _arr=0; + return ; + } DataArrayDouble *arrC=dynamic_cast(arr); if(!arrC) throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !"); + else + _nb_of_tuples_to_be_allocated=-3; arrC->incrRef(); _arr=arrC; } @@ -4860,10 +4898,16 @@ MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::deepCpy() const void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr) throw(INTERP_KERNEL::Exception) { if(!arr) - _arr=0; + { + _nb_of_tuples_to_be_allocated=-1; + _arr=0; + return ; + } DataArrayInt *arrC=dynamic_cast(arr); if(!arrC) throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !"); + else + _nb_of_tuples_to_be_allocated=-3; arrC->incrRef(); _arr=arrC; } @@ -5124,7 +5168,10 @@ MEDFileAnyTypeField1TSWithoutSDA *MEDFileAnyTypeField1TS::BuildContentFrom(med_i oss << "(" << (*iter).first << "," << (*iter).second << "), "; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret)); + if(loadAll) + ret->loadStructureAndBigArraysRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret)); + else + ret->loadOnlyStructureOfDataRecursively(fid,*((const MEDFileAnyTypeField1TSWithoutSDA*)ret)); return ret.retn(); } @@ -5329,6 +5376,44 @@ void MEDFileAnyTypeField1TS::write(const char *fileName, int mode) const throw(I writeLL(fid); } +/*! + * This method alloc the arrays and load potentially huge arrays contained in this field. + * This method should be called when a MEDFileAnyTypeField1TS::New constructor has been with false as the last parameter. + * This method can be also called to refresh or reinit values from a file. + * + * \throw If the fileName is not set or points to a non readable MED file. + * \sa MEDFileAnyTypeField1TS::loadArraysIfNecessary + */ +void MEDFileAnyTypeField1TS::loadArrays() throw(INTERP_KERNEL::Exception) +{ + MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY); + contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase()); +} + +/*! + * This method behaves as MEDFileAnyTypeField1TS::loadArrays does, the first call, if \a this was built using a file without loading big arrays. + * But once data loaded once, this method does nothing. + * + * \throw If the fileName is not set or points to a non readable MED file. + * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::releaseArrays + */ +void MEDFileAnyTypeField1TS::loadArraysIfNecessary() throw(INTERP_KERNEL::Exception) +{ + MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY); + contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase()); +} + +/*! + * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false. + * This method does not release arrays set outside the context of a MED file. + * + * \sa MEDFileAnyTypeField1TS::loadArrays, MEDFileAnyTypeField1TS::loadArraysIfNecessary + */ +void MEDFileAnyTypeField1TS::releaseArrays() throw(INTERP_KERNEL::Exception) +{ + contentNotNullBase()->releaseArrays(); +} + void MEDFileAnyTypeField1TS::writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception) { int nbComp=getNumberOfComponents(); @@ -6772,6 +6857,36 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWri _time_steps[i]->writeLL(fid,opts,*this); } +void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception) +{ + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it=_time_steps.begin();it!=_time_steps.end();it++) + { + MEDFileAnyTypeField1TSWithoutSDA *elt(*it); + if(elt) + elt->loadBigArraysRecursively(fid,nasc); + } +} + +void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception) +{ + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it=_time_steps.begin();it!=_time_steps.end();it++) + { + MEDFileAnyTypeField1TSWithoutSDA *elt(*it); + if(elt) + elt->loadBigArraysRecursivelyIfNecessary(fid,nasc); + } +} + +void MEDFileAnyTypeFieldMultiTSWithoutSDA::releaseArrays() throw(INTERP_KERNEL::Exception) +{ + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it=_time_steps.begin();it!=_time_steps.end();it++) + { + MEDFileAnyTypeField1TSWithoutSDA *elt(*it); + if(elt) + elt->releaseArrays(); + } +} + int MEDFileAnyTypeFieldMultiTSWithoutSDA::getNumberOfTS() const { return _time_steps.size(); @@ -7499,11 +7614,11 @@ MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName * \throw If reading the file fails. * \throw If there is no field named \a fieldName in the file. */ -MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception) +MEDFileAnyTypeFieldMultiTS *MEDFileAnyTypeFieldMultiTS::New(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception) { MEDFileUtilities::CheckFileForRead(fileName); MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY); - MEDCouplingAutoRefCountObjectPtr c=BuildContentFrom(fid,fileName,fieldName); + MEDCouplingAutoRefCountObjectPtr c=BuildContentFrom(fid,fileName,fieldName,loadAll); MEDCouplingAutoRefCountObjectPtr ret=BuildNewInstanceFromContent(c,fileName); ret->loadGlobals(fid); return ret.retn(); @@ -7753,6 +7868,43 @@ void MEDFileAnyTypeFieldMultiTS::write(const char *fileName, int mode) const thr writeLL(fid); } +/*! + * This method alloc the arrays and load potentially huge arrays contained in this field. + * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter. + * This method can be also called to refresh or reinit values from a file. + * + * \throw If the fileName is not set or points to a non readable MED file. + */ +void MEDFileAnyTypeFieldMultiTS::loadArrays() throw(INTERP_KERNEL::Exception) +{ + MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY); + contentNotNullBase()->loadBigArraysRecursively(fid,*contentNotNullBase()); +} + +/*! + * This method behaves as MEDFileAnyTypeFieldMultiTS::loadArrays does, the first call, if \a this was built using a file without loading big arrays. + * But once data loaded once, this method does nothing. + * + * \throw If the fileName is not set or points to a non readable MED file. + * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::releaseArrays + */ +void MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary() throw(INTERP_KERNEL::Exception) +{ + MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY); + contentNotNullBase()->loadBigArraysRecursivelyIfNecessary(fid,*contentNotNullBase()); +} + +/*! + * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false. + * This method does not release arrays set outside the context of a MED file. + * + * \sa MEDFileAnyTypeFieldMultiTS::loadArrays, MEDFileAnyTypeFieldMultiTS::loadArraysIfNecessary + */ +void MEDFileAnyTypeFieldMultiTS::releaseArrays() throw(INTERP_KERNEL::Exception) +{ + contentNotNullBase()->releaseArrays(); +} + std::string MEDFileAnyTypeFieldMultiTS::simpleRepr() const { std::ostringstream oss; @@ -7770,7 +7922,7 @@ std::size_t MEDFileAnyTypeFieldMultiTS::getHeapMemorySize() const } /*! - * This method returns as MEDFileAnyTypeField1TS new instances as number of components in \a this. + * This method returns as MEDFileAnyTypeFieldMultiTS new instances as number of components in \a this. * The returned instances are deep copy of \a this except that for globals that are share with those contained in \a this. * ** WARNING ** do no forget to rename the ouput instances to avoid to write n-times in the same MED file field ! */ @@ -8907,6 +9059,59 @@ void MEDFileFields::write(const char *fileName, int mode) const throw(INTERP_KER writeLL(fid); } +/*! + * This method alloc the arrays and load potentially huge arrays contained in this field. + * This method should be called when a MEDFileAnyTypeFieldMultiTS::New constructor has been with false as the last parameter. + * This method can be also called to refresh or reinit values from a file. + * + * \throw If the fileName is not set or points to a non readable MED file. + */ +void MEDFileFields::loadArrays() throw(INTERP_KERNEL::Exception) +{ + MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY); + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it=_fields.begin();it!=_fields.end();it++) + { + MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it); + if(elt) + elt->loadBigArraysRecursively(fid,*elt); + } +} + +/*! + * This method behaves as MEDFileFields::loadArrays does, the first call, if \a this was built using a file without loading big arrays. + * But once data loaded once, this method does nothing. + * + * \throw If the fileName is not set or points to a non readable MED file. + * \sa MEDFileFields::loadArrays, MEDFileFields::releaseArrays + */ +void MEDFileFields::loadArraysIfNecessary() throw(INTERP_KERNEL::Exception) +{ + MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY); + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it=_fields.begin();it!=_fields.end();it++) + { + MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it); + if(elt) + elt->loadBigArraysRecursivelyIfNecessary(fid,*elt); + } +} + +/*! + * This method releases potentially big data arrays and so returns to the same heap memory than status loaded with 'loadAll' parameter set to false. + * This method does not release arrays set outside the context of a MED file. + * + * \sa MEDFileFields::loadArrays, MEDFileFields::loadArraysIfNecessary + */ +void MEDFileFields::releaseArrays() throw(INTERP_KERNEL::Exception) +{ + MEDFileUtilities::AutoFid fid=MEDfileOpen(getFileName(),MED_ACC_RDONLY); + for(std::vector< MEDCouplingAutoRefCountObjectPtr >::iterator it=_fields.begin();it!=_fields.end();it++) + { + MEDFileAnyTypeFieldMultiTSWithoutSDA *elt(*it); + if(elt) + elt->releaseArrays(); + } +} + std::vector MEDFileFields::getPflsReallyUsed() const { std::vector ret; diff --git a/src/MEDLoader/MEDFileField.hxx b/src/MEDLoader/MEDFileField.hxx index 867e36cb1..86a104dad 100644 --- a/src/MEDLoader/MEDFileField.hxx +++ b/src/MEDLoader/MEDFileField.hxx @@ -503,10 +503,12 @@ namespace ParaMEDMEM bool renumberEntitiesLyingOnMesh(const char *meshName, const std::vector& oldCode, const std::vector& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); public: void allocNotFromFile(int newNbOfTuples) throw(INTERP_KERNEL::Exception); - void allocIfNecessaryTheArrayToReceiveDataFromFile() throw(INTERP_KERNEL::Exception); + bool allocIfNecessaryTheArrayToReceiveDataFromFile() throw(INTERP_KERNEL::Exception); void loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); void loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); + void loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); void loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); + void releaseArrays() throw(INTERP_KERNEL::Exception); void writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception); protected: int getMeshIdFromMeshName(const char *mName) const throw(INTERP_KERNEL::Exception); @@ -644,6 +646,9 @@ namespace ParaMEDMEM int getNonEmptyLevels(const char *mname, std::vector& levs) const throw(INTERP_KERNEL::Exception); public: void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception); + void loadArrays() throw(INTERP_KERNEL::Exception); + void loadArraysIfNecessary() throw(INTERP_KERNEL::Exception); + void releaseArrays() throw(INTERP_KERNEL::Exception); std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > splitComponents() const throw(INTERP_KERNEL::Exception); MEDFileAnyTypeField1TS *deepCpy() const throw(INTERP_KERNEL::Exception); int copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception); @@ -802,6 +807,9 @@ namespace ParaMEDMEM bool renumberEntitiesLyingOnMesh(const char *meshName, const std::vector& oldCode, const std::vector& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); void loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll) throw(INTERP_KERNEL::Exception); void writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception); + void loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); + void loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); + void releaseArrays() throw(INTERP_KERNEL::Exception); public: const MEDFileAnyTypeField1TSWithoutSDA *getTimeStepAtPos2(int pos) const throw(INTERP_KERNEL::Exception); MEDFileAnyTypeField1TSWithoutSDA *getTimeStepAtPos2(int pos) throw(INTERP_KERNEL::Exception); @@ -881,7 +889,10 @@ namespace ParaMEDMEM static MEDFileAnyTypeFieldMultiTSWithoutSDA *BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception); public: static MEDFileAnyTypeFieldMultiTS *New(const char *fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); - static MEDFileAnyTypeFieldMultiTS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception); + static MEDFileAnyTypeFieldMultiTS *New(const char *fileName, const char *fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + void loadArrays() throw(INTERP_KERNEL::Exception); + void loadArraysIfNecessary() throw(INTERP_KERNEL::Exception); + void releaseArrays() throw(INTERP_KERNEL::Exception); void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception); void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception); std::size_t getHeapMemorySize() const; @@ -1043,6 +1054,9 @@ std::vector< std::vector > getFieldSplitedByType2(int iterati MEDFileFields *shallowCpy() const throw(INTERP_KERNEL::Exception); void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception); void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception); + void loadArrays() throw(INTERP_KERNEL::Exception); + void loadArraysIfNecessary() throw(INTERP_KERNEL::Exception); + void releaseArrays() throw(INTERP_KERNEL::Exception); int getNumberOfFields() const; std::vector< std::pair > getCommonIterations(bool& areThereSomeForgottenTS) const throw(INTERP_KERNEL::Exception); std::vector getFieldsNames() const throw(INTERP_KERNEL::Exception); diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index 99bd607de..8e26820ea 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -1106,6 +1106,9 @@ namespace ParaMEDMEM static MEDFileAnyTypeField1TS *New(const char *fileName, const char *fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception); static MEDFileAnyTypeField1TS *New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception); void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception); + void loadArrays() throw(INTERP_KERNEL::Exception); + void loadArraysIfNecessary() throw(INTERP_KERNEL::Exception); + void releaseArrays() throw(INTERP_KERNEL::Exception); int getDimension() const throw(INTERP_KERNEL::Exception); int getIteration() const throw(INTERP_KERNEL::Exception); int getOrder() const throw(INTERP_KERNEL::Exception); @@ -1491,7 +1494,7 @@ namespace ParaMEDMEM { public: static MEDFileAnyTypeFieldMultiTS *New(const char *fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); - static MEDFileAnyTypeFieldMultiTS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception); + static MEDFileAnyTypeFieldMultiTS *New(const char *fileName, const char *fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception); MEDFileAnyTypeFieldMultiTS *deepCpy() const throw(INTERP_KERNEL::Exception); virtual MEDFileAnyTypeFieldMultiTS *shallowCpy() const throw(INTERP_KERNEL::Exception); std::string getName() const throw(INTERP_KERNEL::Exception); @@ -1507,6 +1510,9 @@ namespace ParaMEDMEM int getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception); int getPosGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception); void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception); + void loadArrays() throw(INTERP_KERNEL::Exception); + void loadArraysIfNecessary() throw(INTERP_KERNEL::Exception); + void releaseArrays() throw(INTERP_KERNEL::Exception); // virtual MEDFileAnyTypeField1TS *getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception); MEDFileAnyTypeField1TS *getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception); @@ -2023,6 +2029,9 @@ namespace ParaMEDMEM static MEDFileFields *New(const char *fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); MEDFileFields *deepCpy() const throw(INTERP_KERNEL::Exception); MEDFileFields *shallowCpy() const throw(INTERP_KERNEL::Exception); + void loadArrays() throw(INTERP_KERNEL::Exception); + void loadArraysIfNecessary() throw(INTERP_KERNEL::Exception); + void releaseArrays() throw(INTERP_KERNEL::Exception); void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception); int getNumberOfFields() const; std::vector getFieldsNames() const throw(INTERP_KERNEL::Exception); diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py index d43ab1231..890796d2a 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -2799,7 +2799,6 @@ class MEDLoaderTest(unittest.TestCase): ff0=MEDFileField1TS() f0=MEDCouplingFieldDouble(ON_CELLS,ONE_TIME) ; f0.setMesh(m[:7]) ; arr=DataArrayDouble(7*2) ; arr.iota() ; arr.rearrange(2) ; arr.setInfoOnComponents(["XX [pm]","YYY [hm]"]) ; f0.setArray(arr) ; f0.setName("FieldCellPfl") f0.checkCoherency() - #ff0.setFieldNoProfileSBT(f0) pfl=DataArrayInt.Range(0,7,1) ; pfl.setName("pfl") ff0.setFieldProfile(f0,mm,0,pfl) fspExp=[(3,[(0,(0,4),'','')]),(4,[(0,(4,7),'pfl_NORM_QUAD4','')])] -- 2.30.2