From: ageay Date: Mon, 8 Feb 2010 08:40:38 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: V5_1_main_FINAL~220 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d09af418a6f1c46af1b1c7828aa869ff43db4cc5;p=tools%2Fmedcoupling.git *** empty log message *** --- diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 5397203af..330a15266 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -842,6 +842,36 @@ void MEDCouplingUMesh::checkButterflyCells(std::vector& cells) const } } +namespace ParaMEDMEMImpl +{ + class ConnReader + { + public: + ConnReader(const int *c, int val):_conn(c),_val(val) { } + bool operator() (const int& pos) { return _conn[pos]!=_val; } + private: + const int *_conn; + int _val; + }; +} + +bool MEDCouplingUMesh::checkConsecutiveCellTypes() const +{ + const int *conn=_nodal_connec->getConstPointer(); + const int *connI=_nodal_connec_index->getConstPointer(); + int nbOfCells=getNumberOfCells(); + std::set types; + for(const int *i=connI;i!=connI+nbOfCells;) + { + INTERP_KERNEL::NormalizedCellType curType=(INTERP_KERNEL::NormalizedCellType)conn[*i]; + if(types.find(curType)!=types.end()) + return false; + types.insert(curType); + i=std::find_if(i+1,connI+nbOfCells,ParaMEDMEMImpl::ConnReader(conn,(int)curType)); + } + return true; +} + MEDCouplingMesh *MEDCouplingUMesh::mergeMyselfWith(const MEDCouplingMesh *other) const { if(other->getType()!=UNSTRUCTURED) @@ -880,6 +910,7 @@ DataArrayDouble *MEDCouplingUMesh::getBarycenterAndOwner() const MEDCouplingUMesh *MEDCouplingUMesh::mergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) { MEDCouplingUMesh *ret=MEDCouplingUMesh::New(); + ret->setName("merge"); DataArrayDouble *pts=mergeNodesArray(mesh1,mesh2); ret->setCoords(pts); pts->decrRef(); diff --git a/src/MEDCoupling/MEDCouplingUMesh.hxx b/src/MEDCoupling/MEDCouplingUMesh.hxx index cc426d0ed..7743d2e99 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.hxx +++ b/src/MEDCoupling/MEDCouplingUMesh.hxx @@ -70,6 +70,7 @@ namespace ParaMEDMEM void giveElemsInBoundingBox(const double *bbox, double eps, std::vector& elems); MEDCouplingFieldDouble *getMeasureField(bool isAbs) const; void checkButterflyCells(std::vector& cells) const; + bool checkConsecutiveCellTypes() const; MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const; DataArrayDouble *getBarycenterAndOwner() const; static MEDCouplingUMesh *mergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest.cxx index d0a9b9a73..1951816c0 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest.cxx @@ -1307,6 +1307,16 @@ void MEDCouplingBasicsTest::testMergeNodesOnField() targetMesh->decrRef(); } +void MEDCouplingBasicsTest::testCheckConsecutiveCellTypes() +{ + MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1(); + MEDCouplingUMesh *targetMesh=build2DTargetMesh_1(); + CPPUNIT_ASSERT(sourceMesh->checkConsecutiveCellTypes()); + CPPUNIT_ASSERT(!targetMesh->checkConsecutiveCellTypes()); + targetMesh->decrRef(); + sourceMesh->decrRef(); +} + void MEDCouplingBasicsTest::test2DInterpP0P0_1() { MEDCouplingUMesh *sourceMesh=build2DSourceMesh_1(); diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx index 0502c198f..ef9558d4b 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest.hxx @@ -58,6 +58,7 @@ namespace ParaMEDMEM CPPUNIT_TEST( testApplyFunc ); CPPUNIT_TEST( testOperationsOnFields ); CPPUNIT_TEST( testMergeNodesOnField ); + CPPUNIT_TEST( testCheckConsecutiveCellTypes ); CPPUNIT_TEST( test2DInterpP0P0_1 ); CPPUNIT_TEST( test2DInterpP0P0PL_1 ); CPPUNIT_TEST( test2DInterpP0P0PL_2 ); @@ -135,6 +136,7 @@ namespace ParaMEDMEM void testApplyFunc(); void testOperationsOnFields(); void testMergeNodesOnField(); + void testCheckConsecutiveCellTypes(); void test2DInterpP0P0_1(); void test2DInterpP0P0PL_1(); void test2DInterpP0P0PL_2(); diff --git a/src/MEDLoader/MEDLoader.cxx b/src/MEDLoader/MEDLoader.cxx index 6d09a3e75..5d3be43c3 100644 --- a/src/MEDLoader/MEDLoader.cxx +++ b/src/MEDLoader/MEDLoader.cxx @@ -17,6 +17,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "MEDLoader.hxx" +#include "MEDLoaderBase.hxx" #include "CellModel.hxx" #include "MEDCouplingUMesh.hxx" #include "MEDCouplingMemArray.hxx" @@ -73,6 +74,40 @@ INTERP_KERNEL::NormalizedCellType typmai2[MED_NBR_GEOMETRIE_MAILLE+2] = { INTERP INTERP_KERNEL::NORM_POLYGON, INTERP_KERNEL::NORM_POLYHED }; +med_geometrie_element typmai3[32] = { MED_POINT1,//0 + MED_SEG2,//1 + MED_SEG3,//2 + MED_TRIA3,//3 + MED_QUAD4,//4 + MED_POLYGONE,//5 + MED_TRIA6,//6 + MED_NONE,//7 + MED_QUAD8,//8 + MED_NONE,//9 + MED_NONE,//10 + MED_NONE,//11 + MED_NONE,//12 + MED_NONE,//13 + MED_TETRA4,//14 + MED_PYRA5,//15 + MED_PENTA6,//16 + MED_NONE,//17 + MED_HEXA8,//18 + MED_NONE,//19 + MED_TETRA10,//20 + MED_NONE,//21 + MED_NONE,//22 + MED_PYRA13,//23 + MED_NONE,//24 + MED_PENTA15,//25 + MED_NONE,//26 + MED_NONE,//27 + MED_NONE,//28 + MED_NONE,//29 + MED_HEXA20,//30 + MED_POLYEDRE//31 +}; + using namespace ParaMEDMEM; namespace MEDLoaderNS @@ -85,6 +120,16 @@ namespace MEDLoaderNS private: double *_ptr; }; + + class ConnReaderML + { + public: + ConnReaderML(const int *c, int val):_conn(c),_val(val) { } + bool operator() (const int& pos) { return _conn[pos]!=_val; } + private: + const int *_conn; + int _val; + }; std::string buildStringFromFortran(const char *expr, int lgth); std::vector getMeshNamesFid(med_idt fid); @@ -110,6 +155,10 @@ namespace MEDLoaderNS int buildMEDSubConnectivityOfOneTypeStaticTypes(DataArrayInt *conn, DataArrayInt *connIndex, INTERP_KERNEL::NormalizedCellType type, std::vector& conn4MEDFile); ParaMEDMEM::MEDCouplingFieldDouble *readFieldDoubleLev1(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order, ParaMEDMEM::TypeOfField typeOfOutField); + void appendFieldDirectly(const char *fileName, ParaMEDMEM::MEDCouplingFieldDouble *f); + void prepareCellFieldDoubleForWriting(const ParaMEDMEM::MEDCouplingFieldDouble *f, std::list& split); + void writeUMeshDirectly(const char *fileName, ParaMEDMEM::MEDCouplingUMesh *mesh, bool forceFromScratch); + void writeFieldAndMeshDirectly(const char *fileName, ParaMEDMEM::MEDCouplingFieldDouble *f, bool forceFromScratch); } const char WHITE_SPACES[]=" \n"; @@ -144,7 +193,7 @@ void MEDLoader::MEDConnOfOneElemType::releaseArray() delete [] _global; } -MEDLoader::MEDFieldDoublePerCellType::MEDFieldDoublePerCellType(INTERP_KERNEL::NormalizedCellType type, double *values, int ncomp, int nval):_nval(nval),_ncomp(ncomp),_values(values),_type(type) +MEDLoader::MEDFieldDoublePerCellType::MEDFieldDoublePerCellType(INTERP_KERNEL::NormalizedCellType type, double *values, int ncomp, int ntuple):_ntuple(ntuple),_ncomp(ncomp),_values(values),_type(type) { } @@ -460,6 +509,23 @@ void MEDLoaderNS::readFieldDoubleDataInMedFile(const char *fileName, const char { int nval=MEDnVal(fid,(char *)fieldName,tabEnt[typeOfOutField],tabType[typeOfOutField][j],iteration,order,(char *)meshName,MED_COMPACT); double *valr=new double[ncomp*nval]; + // + med_int ngauss=0; + med_int numdt=0,numo=0,nbrefmaa; + char dt_unit[MED_TAILLE_PNOM+1]=""; + char maa_ass[MED_TAILLE_NOM+1]=""; + med_float dt=0.0; + med_booleen local; + med_int nbPdt=MEDnPasdetemps(fid,(char *)fieldName,MED_MAILLE,tabType[typeOfOutField][j]); + bool found2=false; + for(int k=0;kgetName()); if(meshName=="") { @@ -1104,6 +1170,169 @@ void MEDLoader::WriteUMesh(const char *fileName, ParaMEDMEM::MEDCouplingUMesh *m MEDfermer(fid); } -void MEDLoader::WriteField(const char *fileName, ParaMEDMEM::MEDCouplingFieldDouble *f) +void MEDLoaderNS::appendFieldDirectly(const char *fileName, ParaMEDMEM::MEDCouplingFieldDouble *f) +{ + med_idt fid=MEDouvrir((char *)fileName,MED_LECTURE_ECRITURE); + int nbComp=f->getNumberOfComponents(); + char *comp=new char[nbComp*MED_TAILLE_PNOM+1]; + std::fill(comp,comp+nbComp*MED_TAILLE_PNOM,' '); + comp[nbComp*MED_TAILLE_PNOM]='\0'; + char *unit=new char[nbComp*MED_TAILLE_PNOM+1]; + std::fill(unit,unit+nbComp*MED_TAILLE_PNOM,' '); + unit[nbComp*MED_TAILLE_PNOM]='\0'; + MEDchampCr(fid,(char *)f->getName(),MED_FLOAT64,comp,unit,nbComp); + med_int numdt,numo; + med_float dt; + ParaMEDMEM::TypeOfTimeDiscretization td=f->getTimeDiscretization(); + if(td==ParaMEDMEM::NO_TIME) + { + numdt=MED_NOPDT; numo=MED_NONOR; dt=0.0; + } + else if(td==ParaMEDMEM::ONE_TIME) + { + int tmp1,tmp2; + double tmp0=f->getTime(tmp1,tmp2); + numdt=(med_int)tmp1; numo=(med_int)tmp2; + dt=(med_float)tmp0; + } + const double *pt=f->getArray()->getConstPointer(); + switch(f->getTypeOfField()) + { + case ParaMEDMEM::ON_CELLS: + { + std::list split; + prepareCellFieldDoubleForWriting(f,split); + for(std::list::const_iterator iter=split.begin();iter!=split.end();iter++) + { + char nommaa[MED_TAILLE_NOM+1]; + std::fill(nommaa,nommaa+MED_TAILLE_NOM,' '); nommaa[MED_TAILLE_NOM]='\0'; + strcpy(nommaa,f->getMesh()->getName()); + MEDchampEcr(fid,(char *)nommaa,(char *)f->getName(),(unsigned char*)pt,MED_FULL_INTERLACE,(*iter).getNbOfTuple(), + (char *)MED_NOGAUSS,MED_ALL,(char *)MED_NOPFL,MED_NO_PFLMOD,MED_MAILLE, + typmai3[(int)(*iter).getType()],numdt,(char *)"",dt,numo); + pt+=(*iter).getNbOfTuple()*nbComp; + } + break; + } + case ParaMEDMEM::ON_NODES: + { + int nbOfTuples=f->getArray()->getNumberOfTuples(); + MEDchampEcr(fid,(char *)f->getMesh()->getName(),(char *)f->getName(),(unsigned char*)pt,MED_FULL_INTERLACE,nbOfTuples,(char *)MED_NOGAUSS, + MED_ALL,(char *)MED_NOPFL,MED_NO_PFLMOD,MED_NOEUD,MED_NONE,numdt,(char *)"",dt,numo); + break; + } + default: + throw INTERP_KERNEL::Exception("Not managed this type of FIELD !"); + } + delete [] comp; + delete [] unit; + MEDfermer(fid); +} + +void MEDLoaderNS::prepareCellFieldDoubleForWriting(const ParaMEDMEM::MEDCouplingFieldDouble *f, std::list& split) +{ + int nbComp=f->getNumberOfComponents(); + const MEDCouplingMesh *mesh=f->getMesh(); + const MEDCouplingUMesh *meshC=dynamic_cast(mesh); + if(!meshC) + throw INTERP_KERNEL::Exception("Not implemented yet for not unstructured mesh !"); + if(!meshC->checkConsecutiveCellTypes()) + throw INTERP_KERNEL::Exception("Unstructuded mesh has not consecutive cell types !"); + const int *connI=meshC->getNodalConnectivityIndex()->getConstPointer(); + const int *conn=meshC->getNodalConnectivity()->getConstPointer(); + int nbOfCells=meshC->getNumberOfCells(); + INTERP_KERNEL::NormalizedCellType curType; + for(const int *pt=connI;pt!=connI+nbOfCells;) + { + curType=(INTERP_KERNEL::NormalizedCellType)conn[*pt]; + const int *pt2=std::find_if(pt+1,connI+nbOfCells,ConnReaderML(conn,(int)curType)); + split.push_back(MEDLoader::MEDFieldDoublePerCellType(curType,0,nbComp,pt2-pt)); + pt=pt2; + } +} + +void MEDLoaderNS::writeFieldAndMeshDirectly(const char *fileName, ParaMEDMEM::MEDCouplingFieldDouble *f, bool forceFromScratch) +{ + MEDCouplingUMesh *mesh=dynamic_cast((MEDCouplingMesh *)f->getMesh()); + writeUMeshDirectly(fileName,mesh,forceFromScratch); + appendFieldDirectly(fileName,f); +} + +void MEDLoader::WriteUMesh(const char *fileName, ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch) { + 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 !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + if(writeFromScratch) + { + MEDLoaderNS::writeUMeshDirectly(fileName,mesh,true); + return ; + } + if(status==MEDLoaderBase::NOT_EXIST) + { + MEDLoaderNS::writeUMeshDirectly(fileName,mesh,true); + return; + } + else + { + std::vector meshNames=GetMeshNames(fileName); + std::string fileNameCpp(mesh->getName()); + if(std::find(meshNames.begin(),meshNames.end(),fileNameCpp)==meshNames.end()) + MEDLoaderNS::writeUMeshDirectly(fileName,mesh,false); + else + { + std::ostringstream oss; oss << "File \'" << fileName << "\' already exists and has already a mesh called \""; + oss << fileNameCpp << "\" !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + } +} + +void MEDLoader::WriteField(const char *fileName, ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) +{ + f->checkCoherency(); + 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 !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + if(writeFromScratch) + { + MEDLoaderNS::writeFieldAndMeshDirectly(fileName,f,true); + return ; + } + if(status==MEDLoaderBase::NOT_EXIST) + { + MEDLoaderNS::writeFieldAndMeshDirectly(fileName,f,true); + return ; + } + else + { + std::vector meshNames=GetMeshNames(fileName); + std::string fileNameCpp(f->getMesh()->getName()); + if(std::find(meshNames.begin(),meshNames.end(),fileNameCpp)==meshNames.end()) + MEDLoaderNS::writeFieldAndMeshDirectly(fileName,f,false); + else + { + std::ostringstream oss; oss << "File \'" << fileName << "\' already exists and has already a mesh called \""; + oss << fileNameCpp << "\" !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + } +} + +void MEDLoader::WriteFieldUsingAlreadyWrittenMesh(const char *fileName, ParaMEDMEM::MEDCouplingFieldDouble *f) +{ + f->checkCoherency(); + 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()); + } + MEDLoaderNS::appendFieldDirectly(fileName,f); } diff --git a/src/MEDLoader/MEDLoader.hxx b/src/MEDLoader/MEDLoader.hxx index 71065e217..b79779266 100644 --- a/src/MEDLoader/MEDLoader.hxx +++ b/src/MEDLoader/MEDLoader.hxx @@ -60,15 +60,15 @@ public: class MEDFieldDoublePerCellType { public: - MEDFieldDoublePerCellType(INTERP_KERNEL::NormalizedCellType type, double *values, int ncomp, int nval); + MEDFieldDoublePerCellType(INTERP_KERNEL::NormalizedCellType type, double *values, int ncomp, int ntuple); INTERP_KERNEL::NormalizedCellType getType() const { return _type; } int getNbComp() const { return _ncomp; } - int getNbOfTuple() const { return _nval; } - int getNbOfValues() const { return _ncomp*_nval; } + int getNbOfTuple() const { return _ntuple; } + int getNbOfValues() const { return _ncomp*_ntuple; } double *getArray() const { return _values; } void releaseArray(); private: - int _nval; + int _ntuple; int _ncomp; double *_values; INTERP_KERNEL::NormalizedCellType _type; @@ -87,8 +87,9 @@ public: static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception); static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldDoubleCell(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order); static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldDoubleNode(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order); - static void WriteUMesh(const char *fileName, ParaMEDMEM::MEDCouplingUMesh *mesh); - static void WriteField(const char *fileName, ParaMEDMEM::MEDCouplingFieldDouble *f); + static void WriteUMesh(const char *fileName, ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch); + static void WriteField(const char *fileName, ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch); + static void WriteFieldUsingAlreadyWrittenMesh(const char *fileName, ParaMEDMEM::MEDCouplingFieldDouble *f); private: MEDLoader(); }; diff --git a/src/MEDLoader/MEDLoaderBase.cxx b/src/MEDLoader/MEDLoaderBase.cxx new file mode 100644 index 000000000..09909b3a6 --- /dev/null +++ b/src/MEDLoader/MEDLoaderBase.cxx @@ -0,0 +1,60 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#include "MEDLoaderBase.hxx" +#include "InterpKernelException.hxx" + +#include + +int MEDLoaderBase::getStatusOfFile(const char *fileName) +{ + std::ifstream ifs; + ifs.open(fileName); + unsigned int res=0; + if((ifs.rdstate() & std::ifstream::failbit)!=0) + { + res+=1; + ifs.close(); + } + std::ofstream ofs(fileName,std::ios_base::app); + if((ofs.rdstate() & std::ofstream::failbit)!=0) + { + ofs.close(); + res+=2; + } + switch(res) + { + case 0: + return EXIST_RW; + case 1: + { + std::ifstream ifs2; + ifs2.open(fileName); + if((ifs2.rdstate() & std::ifstream::failbit)!=0) + return EXIST_WRONLY; + else + return NOT_EXIST; + } + case 2: + return EXIST_RDONLY; + case 3: + return DIR_LOCKED; + default: + throw INTERP_KERNEL::Exception("Internal error !"); + } +} diff --git a/src/MEDLoader/MEDLoaderBase.hxx b/src/MEDLoader/MEDLoaderBase.hxx new file mode 100644 index 000000000..e5d8ad95a --- /dev/null +++ b/src/MEDLoader/MEDLoaderBase.hxx @@ -0,0 +1,34 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +#ifndef __MEDLOADERBASE_HXX__ +#define __MEDLOADERBASE_HXX__ + +class MEDLoaderBase +{ +public: + static int getStatusOfFile(const char *fileName); +public: + static const int EXIST_RW=0; + static const int NOT_EXIST=1; + static const int EXIST_RDONLY=2; + static const int EXIST_WRONLY=3; + static const int DIR_LOCKED=4; +}; + +#endif diff --git a/src/MEDLoader/Makefile.am b/src/MEDLoader/Makefile.am index 6409c4bc1..c901dc99d 100755 --- a/src/MEDLoader/Makefile.am +++ b/src/MEDLoader/Makefile.am @@ -27,10 +27,10 @@ endif lib_LTLIBRARIES = libmedloader.la salomeinclude_HEADERS= \ -MEDLoader.hxx +MEDLoader.hxx MEDLoaderBase.hxx dist_libmedloader_la_SOURCES= \ -MEDLoader.cxx +MEDLoader.cxx MEDLoaderBase.cxx libmedloader_la_CPPFLAGS= $(MPI_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES) @CXXTMPDPTHFLAGS@ \ -I$(srcdir)/../INTERP_KERNEL \ diff --git a/src/MEDLoader/Swig/libMEDLoader_Swig.i b/src/MEDLoader/Swig/libMEDLoader_Swig.i index b4994f056..a96de033c 100644 --- a/src/MEDLoader/Swig/libMEDLoader_Swig.i +++ b/src/MEDLoader/Swig/libMEDLoader_Swig.i @@ -65,4 +65,7 @@ public: static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception); static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, int meshDimRelToMax=0) throw(INTERP_KERNEL::Exception); static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldDoubleCell(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order); + static void WriteUMesh(const char *fileName, ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch); + static void WriteField(const char *fileName, ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch); + static void WriteFieldUsingAlreadyWrittenMesh(const char *fileName, ParaMEDMEM::MEDCouplingFieldDouble *f); }; diff --git a/src/ParaMEDLoader/ParaMEDLoader.cxx b/src/ParaMEDLoader/ParaMEDLoader.cxx index e01409611..dcf420744 100644 --- a/src/ParaMEDLoader/ParaMEDLoader.cxx +++ b/src/ParaMEDLoader/ParaMEDLoader.cxx @@ -45,7 +45,7 @@ void ParaMEDLoader::WriteParaMesh(const char *fileName, ParaMEDMEM::ParaMESH *me } if(myRank==0) WriteMasterFile(fileName,fileNames,mesh->getCellMesh()->getName()); - MEDLoader::WriteUMesh(fileNames[myRank].c_str(),dynamic_cast(mesh->getCellMesh())); + MEDLoader::WriteUMesh(fileNames[myRank].c_str(),dynamic_cast(mesh->getCellMesh()),true); } /*! diff --git a/src/ParaMEDMEMTest/ParaMEDMEMTest_InterpKernelDEC.cxx b/src/ParaMEDMEMTest/ParaMEDMEMTest_InterpKernelDEC.cxx index a195446d5..5e6aeef7f 100644 --- a/src/ParaMEDMEMTest/ParaMEDMEMTest_InterpKernelDEC.cxx +++ b/src/ParaMEDMEMTest/ParaMEDMEMTest_InterpKernelDEC.cxx @@ -218,14 +218,14 @@ void ParaMEDMEMTest::testInterpKernelDEC_2D_(const char *srcMeth, const char *ta ostringstream filename; filename<<"./sourcesquareb_"<myRank()+1; aRemover.Register(filename.str().c_str()); - MEDLoader::WriteField("./sourcesquareb",parafield->getField()); + //MEDLoader::WriteField("./sourcesquareb",parafield->getField()); dec.recvData(); cout <<"writing"<myRank()==0) aRemover.Register("./sourcesquare"); - MEDLoader::WriteField("./sourcesquare",parafield->getField()); + //MEDLoader::WriteField("./sourcesquare",parafield->getField()); filename<<"./sourcesquare_"<myRank()+1; @@ -248,7 +248,7 @@ void ParaMEDMEMTest::testInterpKernelDEC_2D_(const char *srcMeth, const char *ta dec.recvData(); ParaMEDLoader::WriteParaMesh("./targetsquareb",paramesh); - MEDLoader::WriteField("./targetsquareb",parafield->getField()); + //MEDLoader::WriteField("./targetsquareb",parafield->getField()); if (target_group->myRank()==0) aRemover.Register("./targetsquareb"); ostringstream filename; @@ -256,7 +256,7 @@ void ParaMEDMEMTest::testInterpKernelDEC_2D_(const char *srcMeth, const char *ta aRemover.Register(filename.str().c_str()); dec.sendData(); ParaMEDLoader::WriteParaMesh("./targetsquare",paramesh); - MEDLoader::WriteField("./targetsquare",parafield->getField()); + //MEDLoader::WriteField("./targetsquare",parafield->getField()); if (target_group->myRank()==0) aRemover.Register("./targetsquareb"); @@ -580,14 +580,14 @@ void ParaMEDMEMTest::testInterpKernelDEC_3D_(const char *srcMeth, const char *ta ostringstream filename; filename<<"./sourcesquareb_"<myRank()+1; aRemover.Register(filename.str().c_str()); - MEDLoader::WriteField("./sourcesquareb",parafield->getField()); + //MEDLoader::WriteField("./sourcesquareb",parafield->getField()); dec.recvData(); cout <<"writing"<myRank()==0) aRemover.Register("./sourcesquare"); - MEDLoader::WriteField("./sourcesquare",parafield->getField()); + //MEDLoader::WriteField("./sourcesquare",parafield->getField()); filename<<"./sourcesquare_"<myRank()+1; @@ -606,7 +606,7 @@ void ParaMEDMEMTest::testInterpKernelDEC_3D_(const char *srcMeth, const char *ta dec.recvData(); ParaMEDLoader::WriteParaMesh("./targetsquareb",paramesh); - MEDLoader::WriteField("./targetsquareb",parafield->getField()); + //MEDLoader::WriteField("./targetsquareb",parafield->getField()); if (target_group->myRank()==0) aRemover.Register("./targetsquareb"); ostringstream filename; @@ -614,7 +614,7 @@ void ParaMEDMEMTest::testInterpKernelDEC_3D_(const char *srcMeth, const char *ta aRemover.Register(filename.str().c_str()); dec.sendData(); ParaMEDLoader::WriteParaMesh("./targetsquare",paramesh); - MEDLoader::WriteField("./targetsquare",parafield->getField()); + //MEDLoader::WriteField("./targetsquare",parafield->getField()); if (target_group->myRank()==0) aRemover.Register("./targetsquareb"); diff --git a/src/ParaMEDMEMTest/ParaMEDMEMTest_MEDLoader.cxx b/src/ParaMEDMEMTest/ParaMEDMEMTest_MEDLoader.cxx index c8b5a923a..b496f5846 100644 --- a/src/ParaMEDMEMTest/ParaMEDMEMTest_MEDLoader.cxx +++ b/src/ParaMEDMEMTest/ParaMEDMEMTest_MEDLoader.cxx @@ -395,7 +395,7 @@ void ParaMEDMEMTest::testMEDLoaderWrite1() bool normalThrow=false; try { - MEDLoader::WriteUMesh(outFileName.c_str(),mesh); + MEDLoader::WriteUMesh(outFileName.c_str(),mesh,true); } catch(INTERP_KERNEL::Exception& e) { @@ -403,7 +403,7 @@ void ParaMEDMEMTest::testMEDLoaderWrite1() } CPPUNIT_ASSERT(normalThrow); mesh->setName(meshName); - MEDLoader::WriteUMesh(outFileName.c_str(),mesh); + MEDLoader::WriteUMesh(outFileName.c_str(),mesh,true); mesh->decrRef(); // mesh=MEDLoader::ReadUMeshFromFile(outFileName.c_str(),meshName,0); @@ -429,7 +429,7 @@ void ParaMEDMEMTest::testMEDLoaderPolygonWrite() MEDCouplingUMesh *mesh=MEDLoader::ReadUMeshFromFile(fileName.c_str(),meshNames[0].c_str(),0); mesh->checkCoherency(); string outFileName=makeTmpFile("toto22138.med"); - MEDLoader::WriteUMesh(outFileName.c_str(),mesh); + MEDLoader::WriteUMesh(outFileName.c_str(),mesh,true); // MEDCouplingUMesh *mesh2=MEDLoader::ReadUMeshFromFile(outFileName.c_str(),meshNames[0].c_str(),0); //