import MEDLoader
import unittest
from math import pi,e,sqrt
-from MEDLoaderDataForTest import MEDLoaderDataForTest
+from MEDLoaderDataForTest import MEDLoaderDataForTest,WriteInTmpDir
class MEDLoaderTest1(unittest.TestCase):
+ @WriteInTmpDir
def testMesh1DRW(self):
mesh=MEDLoaderDataForTest.build1DMesh_1();
mesh.checkConsistencyLight();
self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
pass
+ @WriteInTmpDir
def testMesh2DCurveRW(self):
mesh=MEDLoaderDataForTest.build2DCurveMesh_1();
mesh.checkConsistencyLight();
self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
pass
+ @WriteInTmpDir
def testMesh2DRW(self):
mesh=MEDLoaderDataForTest.build2DMesh_1();
mesh.checkConsistencyLight();
self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
pass
+ @WriteInTmpDir
def testMesh3DSurfRW(self):
mesh=MEDLoaderDataForTest.build3DSurfMesh_1();
mesh.checkConsistencyLight();
self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
pass
+ @WriteInTmpDir
def testMesh3DRW(self):
mesh=MEDLoaderDataForTest.build3DMesh_1();
mesh.checkConsistencyLight();
self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
pass
+ @WriteInTmpDir
def testFieldRW1(self):
f1=MEDLoaderDataForTest.buildVecFieldOnCells_1();
MEDLoader.WriteField("Pyfile6.med",f1,True);
self.assertRaises(Exception,MEDLoader.ReadFieldCell,"Pyfile7.med",f1.getMesh().getName(),0,f1.getName(),2,3);
pass
+ @WriteInTmpDir
def testFieldRW2(self):
fileName="Pyfile8.med";
VAL1=12345.67890314;
#
# Multi field in a same file, but this field has several
#
+ @WriteInTmpDir
def testFieldRW3(self):
fileName="Pyfile11.med";
VAL1=12345.67890314;
self.assertAlmostEqual(VAL2,f1.getArray().getIJ(0,3),13);
pass
+ @WriteInTmpDir
def testMultiMeshRW1(self):
fileName="Pyfile10.med";
mesh1=MEDLoaderDataForTest.build3DMesh_1();
self.assertEqual(ret1[1],"mesh2");
pass
+ @WriteInTmpDir
def testFieldProfilRW1(self):
fileName="Pyfile12.med";
mesh1=MEDLoaderDataForTest.build3DMesh_1();
#
pass
+ @WriteInTmpDir
def testFieldGaussRW1(self):
fileName="Pyfile13.med";
f1=MEDLoaderDataForTest.buildVecFieldOnGauss_1();
self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
pass
+ @WriteInTmpDir
def testFieldGaussNERW1(self):
fileName="Pyfile14.med";
f1=MEDLoaderDataForTest.buildVecFieldOnGaussNE_1();
self.assertTrue(f1.isEqual(f2,1e-12,1e-12));
pass
+ @WriteInTmpDir
def testMesh3DSurfShuffleRW(self):
fileName="Pyfile15.med";
mesh=MEDLoaderDataForTest.build3DSurfMesh_1();
self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
pass
+ @WriteInTmpDir
def testMultiFieldShuffleRW1(self):
fileName="Pyfile17.med";
m=MEDLoaderDataForTest.build3DMesh_2();
self.assertTrue(fs[2].isEqual(f_3,1e-12,1e-12));
pass
+ @WriteInTmpDir
def testWriteUMeshesRW1(self):
fileName="Pyfile18.med";
m3d=MEDLoaderDataForTest.build3DMesh_2();
self.assertTrue(f2.isEqual(f1,1e-12,1e-12));
pass
+ @WriteInTmpDir
def testFieldNodeProfilRW1(self):
fileName="Pyfile19.med";
fileName2="Pyfile20.med";
#
pass
+ @WriteInTmpDir
def testFieldNodeProfilRW2(self):
fileName="Pyfile23.med";
mesh=MEDLoaderDataForTest.build3DSurfMesh_1();
#
pass
+ @WriteInTmpDir
def testMixCellAndNodesFieldRW1(self):
fileName="Pyfile21.med";
mesh=MEDLoaderDataForTest.build3DSurfMesh_1();
#
pass
+ @WriteInTmpDir
def testGetAllFieldNamesRW1(self):
fileName="Pyfile22.med";
mesh=MEDLoaderDataForTest.build2DMesh_2();
self.assertTrue(fs[3]=="Field8");
pass
+ @WriteInTmpDir
def testBigNbOfCompoNonReg(self):
fileName="Pyfile57.med"
m=MEDLoader.MEDCouplingCMesh() ; m.setCoords(MEDLoader.DataArrayDouble([0,1,2,3]),MEDLoader.DataArrayDouble([0,1]),MEDLoader.DataArrayDouble([0,1]))
self.assertTrue(f.isEqual(f2,1e-12,1e-12))
pass
+ @WriteInTmpDir
def testMultiMeshTypeWrite0(self):
fname="Pyfile73.med"
m=MEDLoader.MEDCoupling1SGTUMesh("mesh",MEDLoader.NORM_QUAD4) ; m.allocateCells()
self.assertTrue(f.isEqual(fRead,1e-12,1e-12))
pass
+ @WriteInTmpDir
def testMultiMeshTypeWrite1(self):
fname="Pyfile74.med"
m=MEDLoader.MEDCoupling1SGTUMesh("mesh",MEDLoader.NORM_QUAD4) ; m.allocateCells()
self.assertTrue(m0.isEqual(mRead,1e-12))
pass
+ @WriteInTmpDir
def testChangeGroupName(self):
""" This test is a non regression test on MEDFileUMesh.changeGroupName thanks to Alliance.
"""
self.assertTrue("xonall1" in mesh.getGroupsNames())
pass
+ @WriteInTmpDir
def testFieldWithTooLongName(self):
""" This test is a non regression test, to check that in basic API the policies are taken into account.
"""
MEDLoader.WriteField(fname,f,True)
pass
+ @WriteInTmpDir
def testUsingAlreadyWrittenMesh2(self):
""" This test focuses on MEDLoader.WriteFieldUsingAlreadyWrittenMesh with mesh different from UMesh.
"""
self.assertTrue(f3r.getArray().isEqual(MEDLoader.DataArrayDouble([0.,4.,8.,12.,16.,20.,24.,28.,32.,36.,40.,44.,48.,52.,56.,60.,64.,68.,72.,76.]),1e-12))
pass
+ @WriteInTmpDir
def testEasyFieldRead1(self):
fname="Pyfile111.med"
arr=MEDLoader.DataArrayDouble(4) ; arr.iota()
self.assertRaises(Exception,MEDLoader.ReadField,MEDLoader.ON_CELLS,fname,"mesh",0,"field2",5,5) # invalid time step
pass
+ @WriteInTmpDir
def testMultiWriteFieldOnMergeableNodesMeshes(self):
fname="Pyfile120.med"
arr=MEDLoader.DataArrayDouble([(0,0),(1,0),(0,1),(0,0),(1,0),(0,1)])
import unittest
import platform
from math import pi,e,sqrt
-from MEDLoaderDataForTest import MEDLoaderDataForTest
+from MEDLoaderDataForTest import MEDLoaderDataForTest,WriteInTmpDir,TestWriteUMeshesRW1
from distutils.version import LooseVersion
import sys
os.close(self.stdoutOld)
class MEDLoaderTest3(unittest.TestCase):
+ @WriteInTmpDir
def testMEDMesh1(self):
fileName="Pyfile18.med"
mname="ExampleOfMultiDimW"
self.assertTrue(m2_0.isEqual(m2_1,1e-12));
pass
+ @WriteInTmpDir
def testMEDMesh2(self):
fileName="Pyfile10.med"
mname="3DToto"
pass
# this tests emulates MEDMEM ( Except that it works ! ) The permutation are NOT taken into account
+ @WriteInTmpDir
def testMEDMesh3(self):
outFileName="MEDFileMesh3.med"
c=DataArrayDouble.New()
pass
# this test is the testMEDMesh3 except that permutation is dealed here
+ @WriteInTmpDir
def testMEDMesh4(self):
outFileName="MEDFileMesh4.med"
c=DataArrayDouble.New()
pass
#testing persistence of retrieved arrays
+ @WriteInTmpDir
def testMEDMesh5(self):
fileName="Pyfile18.med"
mname="ExampleOfMultiDimW"
self.assertEqual(20,da1.getNumberOfTuples())
pass
- def testMEDMesh6(self):
+ def internalMEDMesh6(self):
outFileName="MEDFileMesh5.med"
m=MEDFileCMesh.New()
m.setTime(-1,-1,2.3)
m1.setTimeUnit(m.getTimeUnit())
m1.setDescription(m.getDescription())
self.assertTrue(m2.isEqual(m1,1e-12));
+
+ @WriteInTmpDir
+ def testMEDMesh6(self):
+ self.internalMEDMesh6()
pass
+ @WriteInTmpDir
def testMEDMesh7(self):
fileName="Pyfile24.med"
m2,m1,m0,f2,f1,f0,p,n2,n1,n0,fns,fids,grpns,famIdsPerGrp=MEDLoaderDataForTest.buildMultiLevelMesh_1()
pass
#emulation of pointe.med file.
+ @WriteInTmpDir
def testMEDField1(self):
mm=MEDFileMesh.New("Pyfile17.med")
mm.write("Pyfile17_bis.med",2)
pass
#profiles
+ @WriteInTmpDir
def testMEDField2(self):
mm=MEDFileMesh.New("Pyfile19.med")
mm.write("Pyfile19_bis.med",2)
pass
#gauss points
+ @WriteInTmpDir
def testMEDField3(self):
mm=MEDFileMesh.New("Pyfile13.med")
mm.write("Pyfile13_bis.med",2)
pass
#gauss NE
+ @WriteInTmpDir
def testMEDField4(self):
mm=MEDFileMesh.New("Pyfile14.med")
mm.write("Pyfile14_bis.med",2)
pass
# MEDField get/set on pointe.med
+ @WriteInTmpDir
def testMEDField5(self):
ff=MEDFileField1TS.New("Pyfile17.med","MeasureOfMesh_Extruded",1,2)
f=ff.getFieldAtLevel(ON_CELLS,0)
pass
# MEDField get/set on profiles nodes
+ @WriteInTmpDir
def testMEDField6(self):
ff=MEDFileFieldMultiTS.New("Pyfile7.med","VectorFieldOnNodes")
its=ff.getIterations()
pass
# MEDField get/set on profiles cells
+ @WriteInTmpDir
def testMEDField7(self):
ff=MEDFileFieldMultiTS.New("Pyfile12.med","VectorFieldOnCells")
its=ff.getIterations()
pass
#first test of assignation. No profile and types sorted by type.
+ @WriteInTmpDir
def testMEDField8(self):
fname="Pyfile25.med"
f1=MEDLoaderDataForTest.buildVecFieldOnCells_1();
#
pass
+ @WriteInTmpDir
def testMEDFileData1(self):
fname="Pyfile29.med"
d=MEDFileData.New()
self.assertEqual([(-1,-1,0.0)],d2.getFields()["f21"].getTimeSteps())
pass
+ @WriteInTmpDir
def testMEDField9(self):
# first test field profile WR. Full type but with some type missing
fname="Pyfile30.med"
self.assertTrue(vals.isEqual(d,1e-14))
pass
+ @WriteInTmpDir
def testMEDField10(self):
fname="Pyfile31.med"
m1=MEDLoaderDataForTest.build2DMesh_1()
pass
# idem testMEDField9 method except that here testing profile on nodes and not on cells.
+ @WriteInTmpDir
def testMEDField11(self):
fname="Pyfile32.med"
m1=MEDLoaderDataForTest.build2DMesh_1()
self.assertTrue(vals.isEqual(d,1e-14))
pass
+ @WriteInTmpDir
def testMEDField12(self):
fname="Pyfile33.med"
m1=MEDLoaderDataForTest.build2DMesh_1()
self.assertTrue(vals.isEqual(d,1e-14))
pass
+ @WriteInTmpDir
def testMEDField13(self):
fname="Pyfile34.med"
m1=MEDLoaderDataForTest.build2DMesh_1()
self.assertTrue(vals.isEqual(d,1e-14))
pass
+ @WriteInTmpDir
def testMEDField14(self):
fname="Pyfile35.med"
m1=MEDLoaderDataForTest.build2DMesh_1()
# Tricky test of the case of in a MED file containing a Field on GAUSS_NE is lying on a profile that is reality represents all the geom entities of a level.
# By default when using setFieldProfile method such profile is not created because it is not useful ! So here a trick is used to force MEDLoader to do that
# for the necessity of the test ! The idea is too create artificially a mesh having one more fictitious cell per type and to roll back right after !
+ @WriteInTmpDir
def testMEDField15(self):
fname="Pyfile36.med"
m0=MEDLoaderDataForTest.build2DMesh_1()
self.assertTrue(f1.getArray().isEqual(f2,1e-12))
pass
# Test for getFieldAtTopLevel method
+ @WriteInTmpDir
def testMEDField16(self):
fname="Pyfile37.med"
f1=MEDLoaderDataForTest.buildVecFieldOnCells_1();
pass
# Non regression test to check that globals are correctly appended on MEDFileFields::setFieldAtPos
+ @WriteInTmpDir
def testMEDField17(self):
fname="Pyfile39.med"
m1=MEDLoaderDataForTest.build2DMesh_1()
pass
# Non regression test to check that globals are correctly appended on MEDFileFields::setFieldAtPos
+ @WriteInTmpDir
def testMEDField18(self):
fname="Pyfile40.med"
m1=MEDLoaderDataForTest.build2DMesh_1()
self.assertTrue(f4.getArray().isEqual(f1.getArray(),1e-12))
pass
+ @WriteInTmpDir
def testMEDFieldBug1(self):
fname="Pyfile13.med"
d=MEDFileData.New(fname)
self.assertEqual(('Loc_MyFirstFieldOnGaussPoint_NORM_QUAD4_1','Loc_MyFirstFieldOnGaussPoint_NORM_TRI3_0','Loc_MyFirstFieldOnGaussPoint_NORM_TRI6_2'),d.getFields().getFieldAtPos(0).getLocs())
pass
+ @WriteInTmpDir
def testMEDMesh8(self):
m=MEDLoaderDataForTest.build1DMesh_1()
m.convertQuadraticCellsToLinear()
pass
# bug detected by gauthier
+ @WriteInTmpDir
def testMEDLoaderMEDLoaderNSReadFieldDoubleDataInMedFile(self):
fname="Pyfile41.med"
f1=MEDLoaderDataForTest.buildVecFieldOnCells_1();
self.assertTrue(f4.isEqual(f2,1e-12,1e-12))
pass
+ @WriteInTmpDir
def testMEDLoaderMultiLevelCellField1(self):
fname="Pyfile42.med"
m2,m1,m0,f2,f1,f0,p,n2,n1,n0,fns,fids,grpns,famIdsPerGrp=MEDLoaderDataForTest.buildMultiLevelMesh_1()
self.assertEqual(ff2.getFieldSplitedByType(),[(0, [(0, (0, 4), '', '')]), (1, [(0, (4, 84), '', '')])])
pass
+ @WriteInTmpDir
def testFieldOnPflRetrieveOnMdimRelMax1(self):
fname="Pyfile43.med"
m2,m1,m0,f2,f1,f0,p,n2,n1,n0,fns,fids,grpns,famIdsPerGrp=MEDLoaderDataForTest.buildMultiLevelMesh_1()
pass
pass
+ @WriteInTmpDir
def testBuildInnerBoundaryAlongM1Group1(self):
fname="Pyfile44.med"
m=MEDCouplingCMesh.New()
mm.write(fname,2)
pass
+ @WriteInTmpDir
def testBuildInnerBoundaryAlongM1Group3(self):
""" Test buildInnerBoundaryAlongM1Group() with *non-connex* cracks """
fname = "Pyfile73.med"
self.assertTrue(delta.getMaxValue()[0]<1e-12)
mm.write(fname,2)
+ @WriteInTmpDir
def testBuildInnerBoundaryAlongM1Group4(self):
""" Test case where cells touch the M1 group on some nodes only and not on full edges (triangle mesh for ex)
"""
m_desc, _, _, _, _ = m_bis0.buildDescendingConnectivity()
m_bis0.checkDeepEquivalOnSameNodesWith(mfu.getMeshAtLevel(-1), 2, 9.9999999)
+ @WriteInTmpDir
def testBuildInnerBoundary5(self):
""" Full 3D test with tetras only. In this case a tri from the group is not duplicated because it is made only
of non duplicated nodes. The tri in question is hence not part of the final new "dup" group. """
m_bis0.checkDeepEquivalOnSameNodesWith(mfu.getMeshAtLevel(-1), 2, 9.9999999)
pass
+ @WriteInTmpDir
def testBasicConstructors(self):
fname="Pyfile18.med"
+ TestWriteUMeshesRW1(self)
m=MEDFileMesh.New(fname)
m=MEDFileMesh.New(fname,"ExampleOfMultiDimW",-1,-1)
m=MEDFileMesh.New(fname)
m=MEDFileUMesh(fname,"ExampleOfMultiDimW",-1,-1)
m=MEDFileUMesh(fname)
m=MEDFileUMesh()
- self.testMEDMesh6()
+ self.internalMEDMesh6()
m=MEDFileCMesh("MEDFileMesh5.med")
m=MEDFileCMesh("MEDFileMesh5.med","myFirstCartMesh",-1,-1)
m=MEDFileCMesh()
pass
# This is a non regression test. When a field lies partially on a mesh but fully on one of its geometric type.
+ @WriteInTmpDir
def testBugSemiPartialField(self):
fname="Pyfile46.med"
m=MEDLoaderDataForTest.build2DMesh_3()
self.assertTrue(fread2.isEqual(f1,1e-12,1e-12))
pass
+ @WriteInTmpDir
def testUnPolyze1(self):
fname="Pyfile47.med"
mm=MEDLoaderDataForTest.buildMLMeshUnPolyze(self)
mm.setFamilyFieldArr(-1,None)
pass
+ @WriteInTmpDir
def testUnPolyze2(self):
fname="Pyfile48.med"
mfd=MEDFileData.New()
mfd.write(fname,2)
pass
+ @WriteInTmpDir
def testGaussWriteOnPfl1(self):
fname="Pyfile49.med"
fname2="Pyfile50.med"
pass
# Testing profile on nodes when the profile is identity but not on all nodes.
+ @WriteInTmpDir
def testMEDFieldPflOnNode1(self):
fname="Pyfile51.med"
coo=DataArrayDouble([0.,0.,0.5,0.,1.,0.,0.,0.5,0.5,0.5,1.,0.5,0.,1.,0.5,1.,1.,1.],9,2)
pass
# Testing profile on nodes when the profile is identity but not on all nodes.
+ @WriteInTmpDir
def testMEDFieldPflOnCell1(self):
fname="Pyfile52.med"
coo=DataArrayDouble([0.,0.,0.5,0.,1.,0.,0.,0.5,0.5,0.5,1.,0.5,0.,1.,0.5,1.,1.,1.],9,2)
self.assertTrue(pfl1_r.isEqual(pfl1))
pass
+ @WriteInTmpDir
def testMEDFileUMeshZipCoords1(self):
m=MEDFileUMesh()
coo=DataArrayDouble(30) ; coo.iota(1.) ; coo.rearrange(3) ; coo.setInfoOnComponents(["aaa [b]","cc [dd]", "e [fff]"])
self.assertTrue(m.getMeshAtLevel(-2).getNodalConnectivityIndex().isEqual(DataArrayInt([0,2,4,6])))
pass
+ @WriteInTmpDir
def testMEDUMeshAddNodeGroup1(self):
fname="Pyfile53.med"
m=MEDFileUMesh()
self.assertTrue(mm.getGroupArr(-1,"grp0").isEqual(da))
pass
+ @WriteInTmpDir
def testMEDUMeshAddGroup1(self):
fname="Pyfile54.med"
m=MEDFileUMesh()
self.assertTrue(mm.getGroupArr(-1,"grp0").isEqual(da))
pass
+ @WriteInTmpDir
def testHeapMem1(self):
a=DataArrayInt() ; aa=a.getHeapMemorySize()
a.alloc(0,1)
self.assertIn(fff[1, -1].getHeapMemorySize(), list(range(738 - 50, 838 + 30 + 4 * strMulFac)))
pass
+ @WriteInTmpDir
def testCurveLinearMesh1(self):
fname="Pyfile55.med"
mesh=MEDCouplingCurveLinearMesh();
self.assertTrue(m1.getMesh().isEqual(mesh,1e-12))
pass
+ @WriteInTmpDir
def testParameters1(self):
fname="Pyfile56.med"
m=MEDCouplingCMesh() ; arr=DataArrayDouble([0.,1.2,3.5]) ; m.setCoords(arr,arr) ; m.setName("mesh")
self.assertAlmostEqual(data2.getParams()["B"][1,2].getValue(),567.89,13)
pass
+ @WriteInTmpDir
def testNamesOnCellAndNodesInMeshes1(self):
fname="Pyfile58.med"
fname2="Pyfile59.med"
self.assertTrue(cc.isEqual(ccCpy,1e-12)[0])
pass
+ @WriteInTmpDir
def testToExportInExamples1(self):
m=MEDCouplingCMesh()
arr=DataArrayDouble([0.,1.,2.,3.,4.])
splitOfM1[1].isEqual(DataArrayInt([4,5,7,9,14,15]))
pass
+ @WriteInTmpDir
def testBugCorrection1(self):
fs=MEDFileFields()
fs.resize(3)
self.assertEqual(3,len(fs))
pass
+ @WriteInTmpDir
def testCompareMEDFilesContainingOnlyFieldsOnCell1(self):
f1Name="Pyfile60.med"
f2Name="Pyfile61.med"
pass
pass
+ @WriteInTmpDir
def testNonRegBugNormalizeFamIdsMEDFile1(self):
m=MEDCouplingCMesh()
arr=DataArrayDouble([0.,1.,2.,3.,4.])
pass
pass
+ @WriteInTmpDir
def testNonRegressionMantis22212ChangeGrpName(self):
fileName="Pyfile62.med"
m2,m1,m0,f2,f1,f0,p,n2,n1,n0,fns,fids,grpns,famIdsPerGrp=MEDLoaderDataForTest.buildMultiLevelMesh_1()
pass
pass
pass
-
+
+ @WriteInTmpDir
def testInt32InMEDFileFieldStar1(self):
fname="Pyfile63.med"
f1=MEDLoaderDataForTest.buildVecFieldOnCells_1();
self.assertTrue(not fs.changeMeshNames([('3DSurfMesh_1','3DSurfMesh')]))
pass
+ @WriteInTmpDir
def testMEDFileFields1(self):
fname="Pyfile64.med"
f1=MEDCouplingFieldDouble(ON_NODES)
pass
# Multi time steps and multi fields management without Globals (profiles, locs) aspects
+ @WriteInTmpDir
def testMEDFileFields2(self):
fname="Pyfile65.med"
# to check that all is initialize
pass
# Multi time steps and multi fields management with Globals (profiles, locs) aspects
+ @WriteInTmpDir
def testMEDFileFields3(self):
fname="Pyfile66.med"
# building a mesh containing 4 tri3 + 5 quad4
fs0.write(fname,0)
pass
+ @WriteInTmpDir
def testSplitComponents1(self):
fname="Pyfile67.med"
# building a mesh containing 4 tri3 + 5 quad4
pass
pass
+ @WriteInTmpDir
def testMEDFileFieldConvertTo1(self):
fname="Pyfile68.med"
# building a mesh containing 4 tri3 + 5 quad4
self.assertEqual(ff1.getPfls(),('pfl_NORM_QUAD4',))
pass
+ @WriteInTmpDir
def testMEDFileFieldPartialLoading(self):
fname="Pyfile69.med"
#
self.assertEqual(ffs.getHeapMemorySize()-heap_memory_ref,20*70*8*2+70*8*2+50*8*2)
pass
+ @WriteInTmpDir
def testMEDFileMeshReadSelector1(self):
mrs=MEDFileMeshReadSelector()
self.assertTrue(mrs.isCellFamilyFieldReading() and mrs.isNodeFamilyFieldReading() and mrs.isCellNameFieldReading() and mrs.isNodeNameFieldReading() and mrs.isCellNumFieldReading() and mrs.isNodeNumFieldReading())
self.assertEqual(mrs.getCode(),63)
pass
+ @WriteInTmpDir
def testPartialReadOfMeshes(self):
fname="Pyfile70.med"
# building a mesh containing 4 tri3 + 5 quad4
# this test checks that setFieldProfile perform a check of the array length
# compared to the profile length. This test also checks that mesh attribute of field
# is not used by setFieldProfile (because across this test mesh is equal to None)
+ @WriteInTmpDir
def testCheckCompatibilityPfl1(self):
# building a mesh containing 4 tri3 + 5 quad4
tri=MEDCouplingUMesh("tri",2)
f1ts.setFieldProfile(f,mm,0,pfl)
pass
+ @WriteInTmpDir
def testWRMeshWithNoCells(self):
fname="Pyfile71.med"
a=DataArrayDouble(4) ; a.iota()
self.assertTrue(f_read.isEqual(f,1e-12,1e-12))
pass
+ @WriteInTmpDir
def testLoadIfNecessaryOnFromScratchFields0(self):
"""
This test checks that a call to loadArraysIfNecessary works (does nothing) on field data structure whatever its level 1TS, MTS, Fields.
pass
pass
+ @WriteInTmpDir
def testField1TSSetFieldNoProfileSBTPerGeoTypes(self):
""" This test is very important, because the same mechanism is used by the MEDReader to generate a field on all the mesh without any processing and memory.
"""
self.assertEqual(f1ts.getFieldSplitedByType(),[(0,[(0,(0,4),'','')]),(3,[(0,(4,6),'','')]),(4,[(0,(6,9),'','')]),(14,[(0,(9,15),'','')]),(15,[(0,(15,20),'','')]),(16,[(0,(20,24),'','')])])
self.assertTrue(f1ts.getUndergroundDataArray().isEqual(DataArrayDouble([0,1,2,3,0,1,0,1,2,0,1,2,3,4,5,0,1,2,3,4,0,1,2,3]),1e-12))
pass
-
+
+ @WriteInTmpDir
def testMEDFileUMeshSetName(self):
""" This test is a small but important one for MEDReader in sauv mode. When .sauv file is loaded the conversion is performed in memory and a preparation is done then.
This preparation makes access to internal MEDCouplingMesh pointers whose name must be updated.
self.assertEqual(mm.getMeshAtLevel(0).getName(),"abc")
pass
+ @WriteInTmpDir
def testMEDFileFieldsUnloadArraysWithoutDataLoss1(self):
fileName="Pyfile80.med"
m=MEDCouplingCMesh() ; m.setName("cmesh")
self.assertTrue(f1ts.getUndergroundDataArray().isEqual(DataArrayDouble([0.,1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.,17.,18.,19.,20.,21.,22.,23.,24.]),1e-12))
pass
+ @WriteInTmpDir
def testMEDFileUMeshLoadPart1(self):
""" This method tests MEDFileUMesh.LoadPart that loads only a part of a specified mesh in a MED file. The part is specified using a slice of cell ids. Only nodes on which cells lies are loaded to reduce at most the amount of
memory of the returned instance.
self.assertTrue(mm2.getNameFieldAtLevel(1).isEqual(namesNodes[:18]))
pass
+ @WriteInTmpDir
def testMEDFileFieldsLoadPart1(self):
"""This method tests partial loading on fields on CELL. It is the same principle than those in testMEDFileUMeshLoadPart1.
"""
self.assertTrue(fs[1][0].getUndergroundDataArray().isEqual(arr,1e-12))
pass
+ @WriteInTmpDir
def testMEDFileWithoutCells1(self):
fileName="Pyfile83.med"
coo=DataArrayDouble([(0,0,0),(1,0,0),(2,0,0)])
self.assertTrue(mm.getCoords().isEqual(coo,1e-12))
pass
+ @WriteInTmpDir
def testZipCoordsWithLoadPart1(self):
""" Test close to Pyfile82.med except that here zipCoords on MEDFileUMesh is invoked here to see if the PartDef is correctly updated.
"""
self.assertTrue(fs[1][0].getUndergroundDataArray().isEqual(arr,1e-12))
pass
+ @WriteInTmpDir
def testMEDFileCMeshSetGroupsAtLevel(self):
""" Non regression test to check that setGroupsAtLevel is available with MEDFileCMesh.
"""
self.assertTrue(mm.getFamilyFieldAtLevel(0).isEqual(DataArrayInt([-1,-2,-1,-2,-2,-2,-1,-2,-1,-1,-1,-1,-1,-1,-1,-1])))
pass
+ @WriteInTmpDir
def testMEDFileUMeshBuildExtrudedMesh1(self):
""" New functionality of MEDFileUMesh.buildExtrudedMesh."""
fileName="Pyfile85.med"
pass
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @WriteInTmpDir
def testMEDFileUMeshPickeling1(self):
outFileName="Pyfile86.med"
c=DataArrayDouble([-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 ],9,2)
self.assertEqual(mm2.getAxisType(),AX_CYL)
pass
+ @WriteInTmpDir
def testMEDFileFieldsLoadSpecificEntities1(self):
nbNodes=11
fieldName="myField"
pass
pass
+ @WriteInTmpDir
def testMEDFileLotsOfTSRW1(self):
nbNodes=11
fieldName="myField"
self.assertEqual(fs2[0].getTimeSteps(), [(i, 0, float(i)) for i in range(nbPdt)])
pass
+ @WriteInTmpDir
def testMEDFileMeshRearrangeFamIds1(self):
""" Test for bug EDF10720. The aim of this test is the call of MEDFileMesh.rearrangeFamilies."""
fileName="Pyfile89.med"
self.assertEqual(mm.getFamilyId(elt),eltId)
pass
+ @WriteInTmpDir
def testNonRegrCMeshSetFieldPfl1(self):
""" Non regression test. For structured mesh, push a false partial field in MEDFileField1TS using setFieldProfile."""
ff=MEDFileField1TS()
self.assertTrue(field.isEqual(field2,1e-12,1e-12))
pass
+ @WriteInTmpDir
def testMEDFileUMeshLinearToQuadraticAndRev1(self):
meshName="mesh"
fileName="Pyfile90.med"
self.assertTrue(mm.isEqual(mmOut2,1e-12)[0])
pass
+ @WriteInTmpDir
def testMEDFileMeshAddGroup1(self):
m=MEDCouplingCMesh()
arrX=DataArrayDouble(9) ; arrX.iota()
self.assertTrue(mm.getGroupArr(1,"%s_node"%grp.getName()).isEqual(grpExp))
pass
+ @WriteInTmpDir
def testMEDFileJoint1(self):
fileName="Pyfile92.med"
coo=DataArrayDouble([(0,0,0),(1,0,0),(2,0,0)])
jointsR.destroyJointAtPos(0)
pass
+ @WriteInTmpDir
def testMEDFileJoint2(self):
fileNameWr="Pyfile93.med"
coo=DataArrayDouble([(0,0,0),(1,0,0),(2,0,0)])
self.assertTrue( jointR2.isEqual( two_joint ))
pass
+ @WriteInTmpDir
def testMEDFileJoint1(self):
node_correspond=MEDFileJointCorrespondence(DataArrayInt([1,2,3,4,5,6,7,8]))
cell_correspond=MEDFileJointCorrespondence(DataArrayInt([9,10,11,12]),NORM_TRI3,NORM_TRI3)
pass
@unittest.skipUnless('linux'==platform.system().lower(),"stderr redirection not ported on Windows ?")
+ @WriteInTmpDir
def testMEDFileSafeCall0(self):
""" EDF11242 : check status of MED file calls to detect problems immediately. Sorry this test generates awful messages !"""
fname="Pyfile94.med"
#
pass
+ @WriteInTmpDir
def testUnivStatus1(self):
""" Non regression test to check the effectiveness of univ write status."""
fname="Pyfile95.med"
self.assertTrue(mm.getUnivName()!="")
pass
+ @WriteInTmpDir
def testEmptyMesh(self):
""" MEDLoader should be able to consistently write and read an empty mesh (coords array
with 0 tuples """
self.assertTrue(mesh.isEqual(mm2,1e-12)[0])
pass
+ @WriteInTmpDir
def testMEDFileEquivalence1(self):
""" First check of equivalence implementation in MEDFileMesh"""
fileName="Pyfile97.med"
self.assertTrue(mm.isEqual(mm3,1e-12)[0])
pass
+ @WriteInTmpDir
def testMEDFileForFamiliesPlayer1(self):
"""Non regression bug EDF11911. For serial killers using same family name to store both cells and nodes ! Only sky is the limit."""
fileName="Pyfile98.med"
self.assertEqual(mm2.getFamiliesIdsOnGroup("RID"),(-4,3))# <- very important too !
pass
+ @WriteInTmpDir
def testCartesianizer1(self):
""" This test is advanced to be sure that no unnecessary copies had been made during cartesianization process. """
# UMesh non cart
self.assertTrue(mm.getHiddenCppPointer()==mm2.getHiddenCppPointer()) # optimization
pass
+ @WriteInTmpDir
def testCheckCoherency(self):
m2 = MEDCouplingUMesh("2d", 2)
m2.setCoords(DataArrayDouble([(0.0, 1.0)] * 4, 4,2)) # whatever
mum.setNameFieldAtLevel(-1, arr); arr.reAlloc(35);
self.assertRaises(InterpKernelException, mum.checkConsistency)
+ @WriteInTmpDir
def testCheckSMESHConsistency(self):
m2 = MEDCouplingUMesh("2d", 2)
m2.setCoords(DataArrayDouble([(0.0, 1.0)] * 4, 4,2)) # whatever
mum.checkSMESHConsistency()
pass
+ @WriteInTmpDir
def testClearNodeAndCellNumbers(self):
m2 = MEDCouplingUMesh("2d", 2)
m2.setCoords(DataArrayDouble([(0.0, 1.0)] * 4, 4,2)) # whatever
mum.checkSMESHConsistency()
pass
+ @WriteInTmpDir
def testCMeshSetFamilyFieldArrNull(self):
meshName="mesh"
fname="Pyfile99.med"
self.assertTrue(mm2.getFamilyFieldAtLevel(0) is None)
self.assertTrue(mm2.getFamilyFieldAtLevel(1) is None)
pass
-
+
+ @WriteInTmpDir
def testAppendFieldProfileOnIntField(self):
fname="Pyfile100.med"
arrX=DataArrayDouble([0,1,2,3])
self.assertEqual(ftest2.getMesh().getNumberOfCells(),len(arr))
pass
+ @WriteInTmpDir
def testMEDFileFieldEasyField1(self):
"""Check for all spatial discretization of field (cells,nodes,elno,gauss) for double field that all is OK. Here no profile and only top level is considered."""
## Basic test on cells on top level
self.assertTrue(f4.isEqual(f1ts.field(mm),1e-12,1e-12))
pass
+ @WriteInTmpDir
def testMEDFileFieldEasyField2(self):
"""Same thantestMEDFileFieldEasyField1 except that here intfields are considered.
Check for all spatial discretization of field (cells,nodes,elno,gauss) for int field that all is OK. Here no profile and only top level is considered."""
self.assertTrue(f4.isEqual(f1ts.field(mm),1e-12,0))
pass
+ @WriteInTmpDir
def testMEDFileFieldEasyField3(self):
"""Here a multi level mesh. And field on cells lying on different level of this mesh. Show how "field" method deal with that. Here on field double are considered."""
fname="Pyfile103.med"
self.assertTrue(f4.isEqual(f1ts.field(mm),1e-12,1e-12))
pass
+ @WriteInTmpDir
def testMEDFileFieldEasyField4(self):
""" Same than testMEDFileFieldEasyField3 but with integers"""
fname="Pyfile104.med"
self.assertTrue(f4.isEqual(f1ts.field(mm),1e-12,0))
pass
+ @WriteInTmpDir
def testMEDFileFieldEasyField5(self):
"""More and more difficult now look at how profiles are managed by "field" method."""
fname="Pyfile105.med"
self.assertTrue(f.isEqual(f1ts.field(mm),1e-12,1e-12))
pass
+ @WriteInTmpDir
def testExtractPart1(self):
coo=DataArrayDouble([(0,0),(1,0),(2,0),(3,0),(4,0),(0,1),(1,1),(2,1),(3,1),(4,1),(0,2),(1,2),(2,2),(3,2),(4,2)])
meshName="mesh"
pass
pass
+ @WriteInTmpDir
def testSymmetryPlusAggregationMFD1(self):
""" Testing of MEDFileData::Aggregate and MEDFileUMesh::Aggregate and MEDFileUMesh::getAllDistributionOfType """
fname1="Pyfile106_1.med"
CheckMFD(self,mfd)
pass
+ @WriteInTmpDir
def testExtrudedMesh1(self):
fname="Pyfile107.med"
arrX=DataArrayDouble([0,1,2,3]) ; arrY=DataArrayDouble([0,1,2,3,4]) ; arrZ=DataArrayDouble([0,1,2,3,4,5])
pass
@unittest.skipUnless(LooseVersion(MEDFileVersionStr())>=LooseVersion('3.2.1'),"This test requires at least MEDFile version 3.2.1")
+ @WriteInTmpDir
def testWriteInto30(self):
fname="Pyfile108.med"
fname2="Pyfile109.med"
pass
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @WriteInTmpDir
def testPickelizationOfMEDFileObjects1(self):
fname="Pyfile110.med"
coo=DataArrayDouble([0.,0.,0.5,0.,1.,0.,0.,0.5,0.5,0.5,1.,0.5,0.,1.,0.5,1.,1.,1.],9,2)
pass
@unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+ @WriteInTmpDir
def testPickelizationOfMEDFileObjects2(self):
# CMesh
self.testMEDMesh6() # generates MEDFileMesh5.med file
pass
pass
+ @WriteInTmpDir
def testGlobalNumOnNodes1(self):
"""Test global number on nodes here. Used by partitionners."""
fname="Pyfile112.med"
self.assertTrue(mm.isEqual(mm2,1e-12)[0])
pass
+ @WriteInTmpDir
def testPartialReadOfEntities1(self):
"""Test for advanced API on read to speed up read phase for users with "huge" number of time steps (more than 10 000)."""
fname="Pyfile113.med"
self.assertTrue(ff1.field(mm).isEqual(f3,1e-12,1e-12))
pass
+ @WriteInTmpDir
def testFloat32InMEDFileFieldStar1(self):
"""Like testInt32InMEDFileFieldStar1 but with float32 :)"""
fname="Pyfile114.med"
self.assertTrue(not fs.changeMeshNames([('3DSurfMesh_1','3DSurfMesh')]))
pass
+ @WriteInTmpDir
def testPenta18_1(self):
"""EDF8478 : Test of read/write of penta18"""
fname="Pyfile115.med"
self.assertEqual(f3.getMesh().getTypeOfCell(0),NORM_PENTA18)
pass
+ @WriteInTmpDir
def testFieldsLinearToQuadratic(self):
fname="Pyfile117.med"
arr=DataArrayDouble([0,1])
self.assertTrue(fToTest.getArray().isEqual(2*dataExp2,1e-12))
pass
+ @WriteInTmpDir
def testFieldsLinearToQuadratic2(self):
"""Same than testFieldsLinearToQuadratic but with profile on NODES"""
fname="Pyfile118.med"
pass
+ @WriteInTmpDir
def testSetFieldProfileFlatly1(self):
""" Sometimes for downstream code fan of profiles, profile are requested unconditionally. setFieldProfile try to reduce at most profile usage. So setFieldProfileFlatly has been added to always create
a profile."""
self.assertTrue(f1ts.getProfile("pfl_NORM_QUAD4").isIota(81))
pass
+ @WriteInTmpDir
def testRmGroupAtSpeLevelAndMultiLevGrpCreation(self):
""" Here multi level groups are created"""
arr=DataArrayDouble(11) ; arr.iota()
self.assertTrue(mm.getGroupArr(-1,"grp2").isEqual(grp2))
pass
+ @WriteInTmpDir
def testYutaka(self):
""" Thank you to Yutaka Nishizawa for having report this bug. At level -1, adding a first group on all entities leads to a group lying on family 0...
Then rearrange method removes unused entites by putting 0 on them -> Previously group has been modified by rearrange. Should not !"""
pass
pass
- def tessContxtMger1TS(self):
+ @WriteInTmpDir
+ def testContxtMger1TS(self):
fname="Pyfile119.med"
coo=DataArrayDouble(1000) ; coo.iota()
m=MEDCouplingUMesh.Build0DMeshFromCoords(coo)