}
}
+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<INTERP_KERNEL::NormalizedCellType> 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)
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();
void giveElemsInBoundingBox(const double *bbox, double eps, std::vector<int>& elems);
MEDCouplingFieldDouble *getMeasureField(bool isAbs) const;
void checkButterflyCells(std::vector<int>& cells) const;
+ bool checkConsecutiveCellTypes() const;
MEDCouplingMesh *mergeMyselfWith(const MEDCouplingMesh *other) const;
DataArrayDouble *getBarycenterAndOwner() const;
static MEDCouplingUMesh *mergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2);
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();
CPPUNIT_TEST( testApplyFunc );
CPPUNIT_TEST( testOperationsOnFields );
CPPUNIT_TEST( testMergeNodesOnField );
+ CPPUNIT_TEST( testCheckConsecutiveCellTypes );
CPPUNIT_TEST( test2DInterpP0P0_1 );
CPPUNIT_TEST( test2DInterpP0P0PL_1 );
CPPUNIT_TEST( test2DInterpP0P0PL_2 );
void testApplyFunc();
void testOperationsOnFields();
void testMergeNodesOnField();
+ void testCheckConsecutiveCellTypes();
void test2DInterpP0P0_1();
void test2DInterpP0P0PL_1();
void test2DInterpP0P0PL_2();
// 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"
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
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<std::string> getMeshNamesFid(med_idt fid);
int buildMEDSubConnectivityOfOneTypeStaticTypes(DataArrayInt *conn, DataArrayInt *connIndex, INTERP_KERNEL::NormalizedCellType type, std::vector<int>& 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<MEDLoader::MEDFieldDoublePerCellType>& 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";
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)
{
}
{
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;k<nbPdt && !found2;k++)
+ {
+ MEDpasdetempsInfo(fid,(char *)fieldName,MED_MAILLE,tabType[typeOfOutField][j],k+1,&ngauss,
+ &numdt,&numo,dt_unit,&dt,maa_ass,&local,&nbrefmaa);
+ found2=(numdt==iteration && numo==order);
+ if(found2)
+ time=dt;
+ }
MEDchampLire(fid,(char *)meshName,(char *)fieldName,(unsigned char*)valr,MED_FULL_INTERLACE,MED_ALL,locname,
pflname,MED_COMPACT,tabEnt[typeOfOutField],tabType[typeOfOutField][j],iteration,order);
field.push_back(MEDLoader::MEDFieldDoublePerCellType(typmai2[j],valr,ncomp,nval));
return MEDLoaderNS::readFieldDoubleLev1(fileName,meshName,meshDimRelToMax,fieldName,iteration,order,ON_NODES);
}
-void MEDLoader::WriteUMesh(const char *fileName, ParaMEDMEM::MEDCouplingUMesh *mesh)
+void MEDLoaderNS::writeUMeshDirectly(const char *fileName, ParaMEDMEM::MEDCouplingUMesh *mesh, bool forceFromScratch)
{
- med_idt fid=MEDouvrir((char *)fileName,MED_CREATION);
+ med_idt fid=MEDouvrir((char *)fileName,forceFromScratch?MED_CREATION:MED_LECTURE_ECRITURE);
std::string meshName(mesh->getName());
if(meshName=="")
{
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<MEDLoader::MEDFieldDoublePerCellType> split;
+ prepareCellFieldDoubleForWriting(f,split);
+ for(std::list<MEDLoader::MEDFieldDoublePerCellType>::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<MEDLoader::MEDFieldDoublePerCellType>& split)
+{
+ int nbComp=f->getNumberOfComponents();
+ const MEDCouplingMesh *mesh=f->getMesh();
+ const MEDCouplingUMesh *meshC=dynamic_cast<const MEDCouplingUMesh *>(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<MEDCouplingUMesh *>((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<std::string> 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<std::string> 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);
}
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;
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();
};
--- /dev/null
+// 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 <fstream>
+
+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 !");
+ }
+}
--- /dev/null
+// 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
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 \
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);
};
}
if(myRank==0)
WriteMasterFile(fileName,fileNames,mesh->getCellMesh()->getName());
- MEDLoader::WriteUMesh(fileNames[myRank].c_str(),dynamic_cast<MEDCouplingUMesh *>(mesh->getCellMesh()));
+ MEDLoader::WriteUMesh(fileNames[myRank].c_str(),dynamic_cast<MEDCouplingUMesh *>(mesh->getCellMesh()),true);
}
/*!
ostringstream filename;
filename<<"./sourcesquareb_"<<source_group->myRank()+1;
aRemover.Register(filename.str().c_str());
- MEDLoader::WriteField("./sourcesquareb",parafield->getField());
+ //MEDLoader::WriteField("./sourcesquareb",parafield->getField());
dec.recvData();
cout <<"writing"<<endl;
ParaMEDLoader::WriteParaMesh("./sourcesquare",paramesh);
if (source_group->myRank()==0)
aRemover.Register("./sourcesquare");
- MEDLoader::WriteField("./sourcesquare",parafield->getField());
+ //MEDLoader::WriteField("./sourcesquare",parafield->getField());
filename<<"./sourcesquare_"<<source_group->myRank()+1;
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;
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");
ostringstream filename;
filename<<"./sourcesquareb_"<<source_group->myRank()+1;
aRemover.Register(filename.str().c_str());
- MEDLoader::WriteField("./sourcesquareb",parafield->getField());
+ //MEDLoader::WriteField("./sourcesquareb",parafield->getField());
dec.recvData();
cout <<"writing"<<endl;
ParaMEDLoader::WriteParaMesh("./sourcesquare",paramesh);
if (source_group->myRank()==0)
aRemover.Register("./sourcesquare");
- MEDLoader::WriteField("./sourcesquare",parafield->getField());
+ //MEDLoader::WriteField("./sourcesquare",parafield->getField());
filename<<"./sourcesquare_"<<source_group->myRank()+1;
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;
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");
bool normalThrow=false;
try
{
- MEDLoader::WriteUMesh(outFileName.c_str(),mesh);
+ MEDLoader::WriteUMesh(outFileName.c_str(),mesh,true);
}
catch(INTERP_KERNEL::Exception& e)
{
}
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);
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);
//