#include "MEDCouplingUMesh.hxx"
+#include "InterpKernelAutoPtr.hxx"
+
#include <set>
extern med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE+2];
{
if(!coords)
return ;
- MEDcoordEcr(fid,maa,spaceDim,arr->getPointer(),MED_FULL_INTERLACE,mesh[0]->getNumberOfNodes(),MED_CART,comp,unit);
+ int spaceDim=coords->getNumberOfComponents();
+ INTERP_KERNEL::AutoPtr<char> comp=MEDLoaderBase::buildEmptyString(spaceDim*MED_TAILLE_PNOM);
+ INTERP_KERNEL::AutoPtr<char> unit=MEDLoaderBase::buildEmptyString(spaceDim*MED_TAILLE_PNOM);
+ for(int i=0;i<spaceDim;i++)
+ {
+ std::string info=coords->getInfoOnComponent(i);
+ std::string c,u;
+ MEDLoaderBase::splitIntoNameAndUnit(info,c,u);
+ MEDLoaderBase::safeStrCpy(c.c_str(),MED_TAILLE_PNOM-1,comp+i*MED_TAILLE_PNOM,0);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo
+ MEDLoaderBase::safeStrCpy(u.c_str(),MED_TAILLE_PNOM-1,unit+i*MED_TAILLE_PNOM,0);//MED_TAILLE_PNOM-1 to avoid to write '\0' on next compo
+ }
+ MEDcoordEcr(fid,(char *)mname,spaceDim,coords->getPointer(),MED_FULL_INTERLACE,coords->getNumberOfTuples(),MED_CART,comp,unit);
}
bool MEDFileUMeshL2::isFamDefinedOnLev(int levId) const
--- /dev/null
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2007-2010 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
+#
+
+from libMEDLoader_Swig import *
+import unittest
+from math import pi,e,sqrt
+from MEDLoaderDataForTest import MEDLoaderDataForTest
+
+class MEDLoaderTest(unittest.TestCase):
+ def testMEDMesh1(self):
+ fileName="Pyfile18.med"
+ mname="ExampleOfMultiDimW"
+ medmesh=MEDFileUMesh.New(fileName,mname)
+ self.assertEqual((0,-1),medmesh.getNonEmptyLevels())
+ m1_0=medmesh.getRank0Mesh()
+ m1_1=MEDLoader.ReadUMeshFromFile(fileName,mname,0)
+ self.assertTrue(m1_0.isEqual(m1_1,1e-12));
+ m2_0=medmesh.getRankM1Mesh()
+ m2_1=MEDLoader.ReadUMeshFromFile(fileName,mname,-1)
+ self.assertTrue(m2_0.isEqual(m2_1,1e-12));
+ pass
+ def testMEDMesh2(self):
+ fileName="Pyfile10.med"
+ mname="3DToto"
+ medmesh=MEDFileUMesh.New(fileName,mname)
+ self.assertEqual((0,),medmesh.getNonEmptyLevels())
+ m1_0=medmesh.getRank0Mesh()
+ m1_1=MEDLoader.ReadUMeshFromFile(fileName,mname,0)
+ self.assertTrue(m1_0.isEqual(m1_1,1e-12));
+ g1_0=medmesh.getGroup(0,"mesh2")
+ g1_1=MEDLoader.ReadUMeshFromGroups(fileName,mname,0,["mesh2"]);
+ self.assertTrue(g1_0.isEqual(g1_1,1e-12));
+ g1_0=medmesh.getGroup(0,"mesh3")
+ g1_1=MEDLoader.ReadUMeshFromGroups(fileName,mname,0,["mesh3"]);
+ self.assertTrue(g1_0.isEqual(g1_1,1e-12));
+ g1_0=medmesh.getGroups(0,["mesh3","mesh2"])
+ g1_1=MEDLoader.ReadUMeshFromGroups(fileName,mname,0,["mesh3","mesh2"]);
+ g1_1.setName(g1_0.getName())
+ self.assertTrue(g1_0.isEqual(g1_1,1e-12));
+ g1_0=medmesh.getFamily(0,"Family_2")
+ g1_1=MEDLoader.ReadUMeshFromFamilies(fileName,mname,0,["Family_2"]);
+ self.assertTrue(g1_0.isEqual(g1_1,1e-12));
+ g1_0=medmesh.getFamilies(0,["Family_2","Family_4"])
+ g1_1=MEDLoader.ReadUMeshFromFamilies(fileName,mname,0,["Family_2","Family_4"]);
+ g1_1.setName(g1_0.getName())
+ self.assertTrue(g1_0.isEqual(g1_1,1e-12));
+ ## st=g1_0.advancedRepr()
+ ## f=file("out1","w")
+ ## f.write(st)
+ ## f.close()
+ ## st=g1_1.advancedRepr()
+ ## f=file("out2","w")
+ ## f.write(st)
+ ## f.close()
+ self.assertTrue(g1_0.isEqual(g1_1,1e-12));
+ pass
+ pass
+
+unittest.main()
%{
#include "MEDLoader.hxx"
+#include "MEDFileMesh.hxx"
#include "MEDLoaderTypemaps.i"
+
+using namespace ParaMEDMEM;
%}
#if SWIG_VERSION >= 0x010329
%template() std::vector<std::string>;
#endif
+%typemap(out) ParaMEDMEM::MEDFileMesh*
+{
+ $result=convertMEDFileMesh($1,$owner);
+}
+
%newobject MEDLoader::ReadUMeshFromFamilies;
%newobject MEDLoader::ReadUMeshFromGroups;
%newobject MEDLoader::ReadUMeshFromFile;
%newobject MEDLoader::ReadFieldNode;
%newobject MEDLoader::ReadFieldGauss;
%newobject MEDLoader::ReadFieldGaussNE;
+%newobject ParaMEDMEM::MEDFileUMesh::New;
+%newobject ParaMEDMEM::MEDFileUMesh::getCoords;
+%newobject ParaMEDMEM::MEDFileUMesh::getGroup;
+%newobject ParaMEDMEM::MEDFileUMesh::getGroups;
+%newobject ParaMEDMEM::MEDFileUMesh::getFamily;
+%newobject ParaMEDMEM::MEDFileUMesh::getFamilies;
+%newobject ParaMEDMEM::MEDFileUMesh::getMeshAtRank;
+%newobject ParaMEDMEM::MEDFileUMesh::getRank0Mesh;
+%newobject ParaMEDMEM::MEDFileUMesh::getRankM1Mesh;
+%newobject ParaMEDMEM::MEDFileUMesh::getRankM2Mesh;
+%newobject ParaMEDMEM::MEDFileUMesh::getRankM3Mesh;
class MEDLoader
{
static void WriteFieldDep(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch) throw(INTERP_KERNEL::Exception);
static void WriteFieldUsingAlreadyWrittenMesh(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f) throw(INTERP_KERNEL::Exception);
};
+
+%include "MEDFileMesh.hxx"
+