From 7e632de173a3f7701ed288471c5de2bc0f55dbc3 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Tue, 19 Sep 2017 11:30:54 +0200 Subject: [PATCH] Make WriteField and WriteFieldUsingAlreadyWrittenMesh accessible for INT32, FLOAT32 and FLOAT64 --- src/MEDCoupling/MEDCouplingFieldDouble.cxx | 70 ------------- src/MEDCoupling/MEDCouplingFieldDouble.hxx | 2 - src/MEDCoupling/MEDCouplingFieldT.hxx | 2 + src/MEDCoupling/MEDCouplingFieldT.txx | 72 ++++++++++++++ src/MEDLoader/MEDLoader.cxx | 108 +++++++++++++++------ src/MEDLoader/MEDLoader.hxx | 6 +- src/MEDLoader/MEDLoaderNS.hxx | 3 +- src/MEDLoader/Swig/MEDLoaderCommon.i | 6 +- 8 files changed, 163 insertions(+), 106 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.cxx b/src/MEDCoupling/MEDCouplingFieldDouble.cxx index 20ded05dd..5d5f50ae7 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.cxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.cxx @@ -368,76 +368,6 @@ bool MEDCouplingFieldDouble::areCompatibleForMeld(const MEDCouplingFieldDouble * return true; } -/*! - * Permutes values of \a this field according to a given permutation array for cells - * renumbering. The underlying mesh is deeply copied and its cells are also permuted. - * The number of cells remains the same; for that the permutation array \a old2NewBg - * should not contain equal ids. - * ** Warning, this method modifies the mesh aggreagated by \a this (by performing a deep copy ) **. - * - * \param [in] old2NewBg - the permutation array in "Old to New" mode. Its length is - * to be equal to \a this->getMesh()->getNumberOfCells(). - * \param [in] check - if \c true, \a old2NewBg is transformed to a new permutation - * array, so that its maximal cell id to correspond to (be less than) the number - * of cells in mesh. This new array is then used for the renumbering. If \a - * check == \c false, \a old2NewBg is used as is, that is less secure as validity - * of ids in \a old2NewBg is not checked. - * \throw If the mesh is not set. - * \throw If the spatial discretization of \a this field is NULL. - * \throw If \a check == \c true and \a old2NewBg contains equal ids. - * \throw If mesh nature does not allow renumbering (e.g. structured mesh). - * - * \if ENABLE_EXAMPLES - * \ref cpp_mcfielddouble_renumberCells "Here is a C++ example".
- * \ref py_mcfielddouble_renumberCells "Here is a Python example". - * \endif - */ -void MEDCouplingFieldDouble::renumberCells(const int *old2NewBg, bool check) -{ - renumberCellsWithoutMesh(old2NewBg,check); - MCAuto m=_mesh->deepCopy(); - m->renumberCells(old2NewBg,check); - setMesh(m); - updateTime(); -} - -/*! - * Permutes values of \a this field according to a given permutation array for cells - * renumbering. The underlying mesh is \b not permuted. - * The number of cells remains the same; for that the permutation array \a old2NewBg - * should not contain equal ids. - * This method performs a part of job of renumberCells(). The reasonable use of this - * method is only for multi-field instances lying on the same mesh to avoid a - * systematic duplication and renumbering of _mesh attribute. - * \warning Use this method with a lot of care! - * \param [in] old2NewBg - the permutation array in "Old to New" mode. Its length is - * to be equal to \a this->getMesh()->getNumberOfCells(). - * \param [in] check - if \c true, \a old2NewBg is transformed to a new permutation - * array, so that its maximal cell id to correspond to (be less than) the number - * of cells in mesh. This new array is then used for the renumbering. If \a - * check == \c false, \a old2NewBg is used as is, that is less secure as validity - * of ids in \a old2NewBg is not checked. - * \throw If the mesh is not set. - * \throw If the spatial discretization of \a this field is NULL. - * \throw If \a check == \c true and \a old2NewBg contains equal ids. - * \throw If mesh nature does not allow renumbering (e.g. structured mesh). - */ -void MEDCouplingFieldDouble::renumberCellsWithoutMesh(const int *old2NewBg, bool check) -{ - if(!_mesh) - throw INTERP_KERNEL::Exception("Expecting a defined mesh to be able to operate a renumbering !"); - if(_type.isNull()) - throw INTERP_KERNEL::Exception("Expecting a spatial discretization to be able to operate a renumbering !"); - // - _type->renumberCells(old2NewBg,check); - std::vector arrays; - timeDiscr()->getArrays(arrays); - std::vector arrays2(arrays.size()); std::copy(arrays.begin(),arrays.end(),arrays2.begin()); - _type->renumberArraysForCell(_mesh,arrays2,old2NewBg,check); - // - updateTime(); -} - /*! * Permutes values of \a this field according to a given permutation array for node * renumbering. The underlying mesh is deeply copied and its nodes are also permuted. diff --git a/src/MEDCoupling/MEDCouplingFieldDouble.hxx b/src/MEDCoupling/MEDCouplingFieldDouble.hxx index 7ae4248dd..322d66dd7 100644 --- a/src/MEDCoupling/MEDCouplingFieldDouble.hxx +++ b/src/MEDCoupling/MEDCouplingFieldDouble.hxx @@ -41,8 +41,6 @@ namespace MEDCoupling MEDCOUPLING_EXPORT std::string writeVTK(const std::string& fileName, bool isBinary=true) const; MEDCOUPLING_EXPORT bool areCompatibleForMerge(const MEDCouplingField *other) const; MEDCOUPLING_EXPORT bool areCompatibleForMeld(const MEDCouplingFieldDouble *other) const; - MEDCOUPLING_EXPORT void renumberCells(const int *old2NewBg, bool check=true); - MEDCOUPLING_EXPORT void renumberCellsWithoutMesh(const int *old2NewBg, bool check=true); MEDCOUPLING_EXPORT void renumberNodes(const int *old2NewBg, double eps=1e-15); MEDCOUPLING_EXPORT void renumberNodesWithoutMesh(const int *old2NewBg, int newNbOfNodes, double eps=1e-15); MEDCOUPLING_EXPORT DataArrayInt *findIdsInRange(double vmin, double vmax) const; diff --git a/src/MEDCoupling/MEDCouplingFieldT.hxx b/src/MEDCoupling/MEDCouplingFieldT.hxx index 3e832ef56..933a577f1 100644 --- a/src/MEDCoupling/MEDCouplingFieldT.hxx +++ b/src/MEDCoupling/MEDCouplingFieldT.hxx @@ -88,6 +88,8 @@ namespace MEDCoupling MEDCOUPLING_EXPORT bool areCompatibleForDiv(const MEDCouplingField *other) const; MEDCOUPLING_EXPORT void copyTinyAttrFrom(const MEDCouplingFieldT *other); MEDCOUPLING_EXPORT void copyAllTinyAttrFrom(const MEDCouplingFieldT *other); + MEDCOUPLING_EXPORT void renumberCells(const int *old2NewBg, bool check=true); + MEDCOUPLING_EXPORT void renumberCellsWithoutMesh(const int *old2NewBg, bool check=true); // MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector& tinyInfo) const; MEDCOUPLING_EXPORT void getTinySerializationDbleInformation(std::vector& tinyInfo) const; diff --git a/src/MEDCoupling/MEDCouplingFieldT.txx b/src/MEDCoupling/MEDCouplingFieldT.txx index d274bdce6..33ef4a4b4 100644 --- a/src/MEDCoupling/MEDCouplingFieldT.txx +++ b/src/MEDCoupling/MEDCouplingFieldT.txx @@ -203,6 +203,78 @@ namespace MEDCoupling copyTinyAttrFrom(other); } + /*! + * Permutes values of \a this field according to a given permutation array for cells + * renumbering. The underlying mesh is deeply copied and its cells are also permuted. + * The number of cells remains the same; for that the permutation array \a old2NewBg + * should not contain equal ids. + * ** Warning, this method modifies the mesh aggreagated by \a this (by performing a deep copy ) **. + * + * \param [in] old2NewBg - the permutation array in "Old to New" mode. Its length is + * to be equal to \a this->getMesh()->getNumberOfCells(). + * \param [in] check - if \c true, \a old2NewBg is transformed to a new permutation + * array, so that its maximal cell id to correspond to (be less than) the number + * of cells in mesh. This new array is then used for the renumbering. If \a + * check == \c false, \a old2NewBg is used as is, that is less secure as validity + * of ids in \a old2NewBg is not checked. + * \throw If the mesh is not set. + * \throw If the spatial discretization of \a this field is NULL. + * \throw If \a check == \c true and \a old2NewBg contains equal ids. + * \throw If mesh nature does not allow renumbering (e.g. structured mesh). + * + * \if ENABLE_EXAMPLES + * \ref cpp_mcfielddouble_renumberCells "Here is a C++ example".
+ * \ref py_mcfielddouble_renumberCells "Here is a Python example". + * \endif + */ + template + void MEDCouplingFieldT::renumberCells(const int *old2NewBg, bool check) + { + renumberCellsWithoutMesh(old2NewBg,check); + MCAuto m(_mesh->deepCopy()); + m->renumberCells(old2NewBg,check); + setMesh(m); + updateTime(); + } + + /*! + * Permutes values of \a this field according to a given permutation array for cells + * renumbering. The underlying mesh is \b not permuted. + * The number of cells remains the same; for that the permutation array \a old2NewBg + * should not contain equal ids. + * This method performs a part of job of renumberCells(). The reasonable use of this + * method is only for multi-field instances lying on the same mesh to avoid a + * systematic duplication and renumbering of _mesh attribute. + * \warning Use this method with a lot of care! + * \param [in] old2NewBg - the permutation array in "Old to New" mode. Its length is + * to be equal to \a this->getMesh()->getNumberOfCells(). + * \param [in] check - if \c true, \a old2NewBg is transformed to a new permutation + * array, so that its maximal cell id to correspond to (be less than) the number + * of cells in mesh. This new array is then used for the renumbering. If \a + * check == \c false, \a old2NewBg is used as is, that is less secure as validity + * of ids in \a old2NewBg is not checked. + * \throw If the mesh is not set. + * \throw If the spatial discretization of \a this field is NULL. + * \throw If \a check == \c true and \a old2NewBg contains equal ids. + * \throw If mesh nature does not allow renumbering (e.g. structured mesh). + */ + template + void MEDCouplingFieldT::renumberCellsWithoutMesh(const int *old2NewBg, bool check) + { + if(!_mesh) + throw INTERP_KERNEL::Exception("Expecting a defined mesh to be able to operate a renumbering !"); + if(_type.isNull()) + throw INTERP_KERNEL::Exception("Expecting a spatial discretization to be able to operate a renumbering !"); + // + _type->renumberCells(old2NewBg,check); + std::vector< typename MEDCoupling::Traits::ArrayType *> arrays; + timeDiscrSafe()->getArrays(arrays); + std::vector arrays2(arrays.size()); std::copy(arrays.begin(),arrays.end(),arrays2.begin()); + _type->renumberArraysForCell(_mesh,arrays2,old2NewBg,check); + // + updateTime(); + } + /*! * This method is more strict than MEDCouplingField::areCompatibleForMerge method. * This method is used for operation on fields to operate a first check before attempting operation. diff --git a/src/MEDLoader/MEDLoader.cxx b/src/MEDLoader/MEDLoader.cxx index 79bc80682..eadf569a7 100644 --- a/src/MEDLoader/MEDLoader.cxx +++ b/src/MEDLoader/MEDLoader.cxx @@ -32,6 +32,7 @@ #include "MEDCouplingFieldFloat.hxx" #include "MEDCouplingFieldInt.hxx" #include "MEDCouplingGaussLocalization.hxx" +#include "MEDCouplingTraits.hxx" #include "MCAuto.hxx" #include "InterpKernelAutoPtr.hxx" @@ -1493,25 +1494,26 @@ void MEDCoupling::WriteUMeshesPartitionDep(const std::string& fileName, const st void MEDCoupling::WriteUMeshes(const std::string& fileName, const std::vector& meshes, bool writeFromScratch) { - int mod=writeFromScratch?2:0; + int mod(writeFromScratch?2:0); MCAuto m(MEDFileUMesh::New()); AssignStaticWritePropertiesTo(*m); m->setMeshes(meshes,true); m->write(fileName,mod); } -void MEDLoaderNS::writeFieldWithoutReadingAndMappingOfMeshInFile(const std::string& fileName, const MEDCoupling::MEDCouplingFieldDouble *f, bool writeFromScratch) +template +void MEDLoaderNS::writeFieldWithoutReadingAndMappingOfMeshInFile(const std::string& fileName, const typename MEDCoupling::Traits::FieldType *f, bool writeFromScratch) { - MCAuto ff(MEDFileField1TS::New()); + MCAuto< typename MLFieldTraits::F1TSType > ff(MLFieldTraits::F1TSType::New()); AssignStaticWritePropertiesTo(*ff); - MCAuto f2(f->deepCopy()); + MCAuto::FieldType> f2(f->deepCopy()); const MEDCouplingMesh *m(f2->getMesh()); const MEDCouplingUMesh *um(dynamic_cast(m)); const MEDCoupling1GTUMesh *um2(dynamic_cast(m)); const MEDCouplingCMesh *um3(dynamic_cast(m)); const MEDCouplingCurveLinearMesh *um4(dynamic_cast(m)); MCAuto mm; - int mod=writeFromScratch?2:0; + int mod(writeFromScratch?2:0); if(um) { MCAuto mmu(MEDFileUMesh::New()); @@ -1553,12 +1555,13 @@ void MEDLoaderNS::writeFieldWithoutReadingAndMappingOfMeshInFile(const std::stri ff->write(fileName,0); } -void MEDCoupling::WriteField(const std::string& fileName, const MEDCoupling::MEDCouplingFieldDouble *f, bool writeFromScratch) +template +void WriteFieldT(const std::string& fileName, const typename MEDCoupling::Traits::FieldType *f, bool writeFromScratch) { if(!f) throw INTERP_KERNEL::Exception("WriteField : input field is NULL !"); f->checkConsistencyLight(); - int status=MEDLoaderBase::getStatusOfFile(fileName); + int status(MEDLoaderBase::getStatusOfFile(fileName)); if(status!=MEDLoaderBase::EXIST_RW && status!=MEDLoaderBase::NOT_EXIST) { std::ostringstream oss; oss << "File with name \'" << fileName << "\' has not valid permissions !"; @@ -1566,44 +1569,44 @@ void MEDCoupling::WriteField(const std::string& fileName, const MEDCoupling::MED } if(writeFromScratch || (!writeFromScratch && status==MEDLoaderBase::NOT_EXIST)) { - MEDLoaderNS::writeFieldWithoutReadingAndMappingOfMeshInFile(fileName,f,true); + MEDLoaderNS::writeFieldWithoutReadingAndMappingOfMeshInFile(fileName,f,true); } else { - std::vector meshNames=GetMeshNames(fileName); + std::vector meshNames(GetMeshNames(fileName)); if(!f->getMesh()) throw INTERP_KERNEL::Exception("WriteField : trying to write a field with no mesh !"); std::string fileNameCpp(f->getMesh()->getName()); if(std::find(meshNames.begin(),meshNames.end(),fileNameCpp)==meshNames.end()) - MEDLoaderNS::writeFieldWithoutReadingAndMappingOfMeshInFile(fileName,f,false); + MEDLoaderNS::writeFieldWithoutReadingAndMappingOfMeshInFile(fileName,f,false); else { MCAuto mm(MEDFileMesh::New(fileName,f->getMesh()->getName().c_str())); AssignStaticWritePropertiesTo(*mm); const MEDFileMesh *mmPtr(mm); - const MEDFileUMesh *mmuPtr=dynamic_cast(mmPtr); + const MEDFileUMesh *mmuPtr(dynamic_cast(mmPtr)); if(!mmuPtr) throw INTERP_KERNEL::Exception("WriteField : only umeshes are supported now !"); - MCAuto f2(f->deepCopy()); - MEDCouplingUMesh *m=dynamic_cast(const_cast(f2->getMesh())); + MCAuto< typename MEDCoupling::Traits::FieldType > f2(f->deepCopy()); + MEDCouplingUMesh *m(dynamic_cast(const_cast(f2->getMesh()))); if(!m) throw INTERP_KERNEL::Exception("WriteField : only umesh in input field supported !"); - MCAuto o2n=m->getRenumArrForMEDFileFrmt(); + MCAuto o2n(m->getRenumArrForMEDFileFrmt()); f2->renumberCells(o2n->begin(),false); m=static_cast(const_cast(f2->getMesh())); - MCAuto mread=mmuPtr->getMeshAtLevel(m->getMeshDimension()-mm->getMeshDimension()); + MCAuto mread(mmuPtr->getMeshAtLevel(m->getMeshDimension()-mm->getMeshDimension())); if(f2->getTypeOfField()!=ON_NODES) { m->tryToShareSameCoordsPermute(*mread,_EPS_FOR_NODE_COMP); - DataArrayInt *part=0; - bool b=mread->areCellsIncludedIn(m,_COMP_FOR_CELL,part); + DataArrayInt *part(NULL); + bool b(mread->areCellsIncludedIn(m,_COMP_FOR_CELL,part)); MCAuto partSafe(part); if(!b) { std::ostringstream oss; oss << "WriteField : The file \""<< fileName << "\" already contains a mesh named \""<< f->getMesh()->getName() << "\" and this mesh in the file is not compatible (a subpart) with the mesh you intend to write ! This is maybe due to a too strict policy ! Try with to lease it by calling SetCompPolicyForCell !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - MCAuto f1ts(MEDFileField1TS::New()); + MCAuto< typename MLFieldTraits::F1TSType > f1ts(MLFieldTraits::F1TSType::New()); AssignStaticWritePropertiesTo(*f1ts); if(part->isIota(mread->getNumberOfCells())) f1ts->setFieldNoProfileSBT(f2); @@ -1617,15 +1620,15 @@ void MEDCoupling::WriteField(const std::string& fileName, const MEDCoupling::MED } else { - DataArrayInt *part=0; - bool b=mread->getCoords()->areIncludedInMe(m->getCoords(),_EPS_FOR_NODE_COMP,part); + DataArrayInt *part(NULL); + bool b(mread->getCoords()->areIncludedInMe(m->getCoords(),_EPS_FOR_NODE_COMP,part)); MCAuto partSafe(part); if(!b) { std::ostringstream oss; oss << "WriteField : The file \""<< fileName << "\" already contains a mesh named \""<< f->getMesh()->getName() << "\" and this mesh in the file is not compatible (a subpart regarding nodes) with the mesh you intend to write ! This is maybe due to a too strict epsilon ! Try with to lease it by calling SetEpsilonForNodeComp !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - MCAuto f1ts(MEDFileField1TS::New()); + MCAuto< typename MLFieldTraits::F1TSType > f1ts(MLFieldTraits::F1TSType::New()); AssignStaticWritePropertiesTo(*f1ts); if(part->isIota(mread->getNumberOfNodes())) f1ts->setFieldNoProfileSBT(f2); @@ -1640,29 +1643,55 @@ void MEDCoupling::WriteField(const std::string& fileName, const MEDCoupling::MED } } -void MEDCoupling::WriteFieldDep(const std::string& fileName, const MEDCoupling::MEDCouplingFieldDouble *f, bool writeFromScratch) +void MEDCoupling::WriteField(const std::string& fileName, const MEDCoupling::MEDCouplingField *f, bool writeFromScratch) +{ + if(!f) + throw INTERP_KERNEL::Exception("WriteField : input field is null !"); + { + const MEDCoupling::MEDCouplingFieldDouble *f1(dynamic_cast(f)); + if(f1) + WriteFieldT(fileName,f1,writeFromScratch); + return ; + } + { + const MEDCoupling::MEDCouplingFieldInt *f1(dynamic_cast(f)); + if(f1) + WriteFieldT(fileName,f1,writeFromScratch); + return ; + } + { + const MEDCoupling::MEDCouplingFieldFloat *f1(dynamic_cast(f)); + if(f1) + WriteFieldT(fileName,f1,writeFromScratch); + return ; + } + throw INTERP_KERNEL::Exception("WriteField : input field is not in FLOAT32, FLOAT64, INT32 !"); +} + +void MEDCoupling::WriteFieldDep(const std::string& fileName, const MEDCoupling::MEDCouplingField *f, bool writeFromScratch) { WriteField(fileName,f,writeFromScratch); } -void MEDCoupling::WriteFieldUsingAlreadyWrittenMesh(const std::string& fileName, const MEDCoupling::MEDCouplingFieldDouble *f) +template +void WriteFieldUsingAlreadyWrittenMeshT(const std::string& fileName, const typename MEDCoupling::Traits::FieldType *f) { if(!f) - throw INTERP_KERNEL::Exception("WriteFieldUsingAlreadyWrittenMesh : input field is null !"); + throw INTERP_KERNEL::Exception("WriteFieldUsingAlreadyWrittenMeshT : input field is null !"); f->checkConsistencyLight(); - int status=MEDLoaderBase::getStatusOfFile(fileName); + int status(MEDLoaderBase::getStatusOfFile(fileName)); if(status!=MEDLoaderBase::EXIST_RW) { std::ostringstream oss; oss << "File with name \'" << fileName << "\' has not valid permissions or not exists !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } - MCAuto f1ts(MEDFileField1TS::New()); + MCAuto< typename MLFieldTraits::F1TSType > f1ts(MLFieldTraits::F1TSType::New()); AssignStaticWritePropertiesTo(*f1ts); MEDCouplingUMesh *m(dynamic_cast(const_cast(f->getMesh()))); if(m) { MCAuto o2n(m->getRenumArrForMEDFileFrmt()); - MCAuto f2(f->deepCopy()); + MCAuto< typename MEDCoupling::Traits::FieldType > f2(f->deepCopy()); f2->renumberCells(o2n->begin(),false); f1ts->setFieldNoProfileSBT(f2); } @@ -1670,3 +1699,28 @@ void MEDCoupling::WriteFieldUsingAlreadyWrittenMesh(const std::string& fileName, f1ts->setFieldNoProfileSBT(f); f1ts->write(fileName,0); } + +void MEDCoupling::WriteFieldUsingAlreadyWrittenMesh(const std::string& fileName, const MEDCoupling::MEDCouplingField *f) +{ + if(!f) + throw INTERP_KERNEL::Exception("WriteFieldUsingAlreadyWrittenMesh : input field is null !"); + { + const MEDCoupling::MEDCouplingFieldDouble *f1(dynamic_cast(f)); + if(f1) + WriteFieldUsingAlreadyWrittenMeshT(fileName,f1); + return ; + } + { + const MEDCoupling::MEDCouplingFieldInt *f1(dynamic_cast(f)); + if(f1) + WriteFieldUsingAlreadyWrittenMeshT(fileName,f1); + return ; + } + { + const MEDCoupling::MEDCouplingFieldFloat *f1(dynamic_cast(f)); + if(f1) + WriteFieldUsingAlreadyWrittenMeshT(fileName,f1); + return ; + } + throw INTERP_KERNEL::Exception("WriteFieldUsingAlreadyWrittenMesh : input field is not in FLOAT32, FLOAT64, INT32 !"); +} diff --git a/src/MEDLoader/MEDLoader.hxx b/src/MEDLoader/MEDLoader.hxx index 4fdba13b8..5398b1c3f 100644 --- a/src/MEDLoader/MEDLoader.hxx +++ b/src/MEDLoader/MEDLoader.hxx @@ -97,9 +97,9 @@ namespace MEDCoupling MEDLOADER_EXPORT void WriteUMeshesPartition(const std::string& fileName, const std::string& meshName, const std::vector& meshes, bool writeFromScratch); MEDLOADER_EXPORT void WriteUMeshesPartitionDep(const std::string& fileName, const std::string& meshName, const std::vector& meshes, bool writeFromScratch); MEDLOADER_EXPORT void WriteUMeshes(const std::string& fileName, const std::vector& meshes, bool writeFromScratch); - MEDLOADER_EXPORT void WriteField(const std::string& fileName, const MEDCoupling::MEDCouplingFieldDouble *f, bool writeFromScratch); - MEDLOADER_EXPORT void WriteFieldDep(const std::string& fileName, const MEDCoupling::MEDCouplingFieldDouble *f, bool writeFromScratch); - MEDLOADER_EXPORT void WriteFieldUsingAlreadyWrittenMesh(const std::string& fileName, const MEDCoupling::MEDCouplingFieldDouble *f); + MEDLOADER_EXPORT void WriteField(const std::string& fileName, const MEDCoupling::MEDCouplingField *f, bool writeFromScratch); + MEDLOADER_EXPORT void WriteFieldDep(const std::string& fileName, const MEDCoupling::MEDCouplingField *f, bool writeFromScratch); + MEDLOADER_EXPORT void WriteFieldUsingAlreadyWrittenMesh(const std::string& fileName, const MEDCoupling::MEDCouplingField *f); MEDLOADER_EXPORT void AssignStaticWritePropertiesTo(MEDCoupling::MEDFileWritable& obj); } diff --git a/src/MEDLoader/MEDLoaderNS.hxx b/src/MEDLoader/MEDLoaderNS.hxx index 3db880f54..b9a756a11 100644 --- a/src/MEDLoader/MEDLoaderNS.hxx +++ b/src/MEDLoader/MEDLoaderNS.hxx @@ -35,7 +35,8 @@ namespace MEDLoaderNS { int readUMeshDimFromFile(const std::string& fileName, const std::string& meshName, std::vector& possibilities); void dispatchElems(int nbOfElemCell, int nbOfElemFace, int& nbOfElem, med_entity_type& whichEntity); - void writeFieldWithoutReadingAndMappingOfMeshInFile(const std::string& fileName, const MEDCoupling::MEDCouplingFieldDouble *f, bool writeFromScratch); + template + void writeFieldWithoutReadingAndMappingOfMeshInFile(const std::string& fileName, const typename MEDCoupling::Traits::FieldType *f, bool writeFromScratch); med_int getIdFromMeshName(med_idt fid, const std::string& meshName, std::string& trueMeshName); std::vector getMeshNamesFid(med_idt fid); } diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index 0a1262950..b2694f7e6 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -372,9 +372,9 @@ namespace MEDCoupling void WriteMesh(const std::string& fileName, const MEDCoupling::MEDCouplingMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception); void WriteUMesh(const std::string& fileName, const MEDCoupling::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception); void WriteUMeshDep(const std::string& fileName, const MEDCoupling::MEDCouplingUMesh *mesh, bool writeFromScratch) throw(INTERP_KERNEL::Exception); - void WriteField(const std::string& fileName, const MEDCoupling::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception); - void WriteFieldDep(const std::string& fileName, const MEDCoupling::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception); - void WriteFieldUsingAlreadyWrittenMesh(const std::string& fileName, const MEDCoupling::MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception); + void WriteField(const std::string& fileName, const MEDCoupling::MEDCouplingField *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception); + void WriteFieldDep(const std::string& fileName, const MEDCoupling::MEDCouplingField *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception); + void WriteFieldUsingAlreadyWrittenMesh(const std::string& fileName, const MEDCoupling::MEDCouplingField *f) throw(INTERP_KERNEL::Exception); } %rename (MEDFileVersion) MEDFileVersionSwig; -- 2.39.2