本文整理汇总了Python中MEDLoaderDataForTest.MEDLoaderDataForTest.build2DMesh_1方法的典型用法代码示例。如果您正苦于以下问题:Python MEDLoaderDataForTest.build2DMesh_1方法的具体用法?Python MEDLoaderDataForTest.build2DMesh_1怎么用?Python MEDLoaderDataForTest.build2DMesh_1使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MEDLoaderDataForTest.MEDLoaderDataForTest
的用法示例。
在下文中一共展示了MEDLoaderDataForTest.build2DMesh_1方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testMesh2DRW
# 需要导入模块: from MEDLoaderDataForTest import MEDLoaderDataForTest [as 别名]
# 或者: from MEDLoaderDataForTest.MEDLoaderDataForTest import build2DMesh_1 [as 别名]
def testMesh2DRW(self):
mesh=MEDLoaderDataForTest.build2DMesh_1();
mesh.checkConsistencyLight();
WriteUMeshDep("Pyfile3.med",mesh,False);
mesh_rw=ReadUMeshFromFile("Pyfile3.med",mesh.getName(),0);
self.assertTrue(mesh.isEqual(mesh_rw,1e-12));
pass
示例2: testMesh2DRW
# 需要导入模块: from MEDLoaderDataForTest import MEDLoaderDataForTest [as 别名]
# 或者: from MEDLoaderDataForTest.MEDLoaderDataForTest import build2DMesh_1 [as 别名]
def testMesh2DRW(self):
mesh = MEDLoaderDataForTest.build2DMesh_1()
mesh.checkCoherency()
MEDLoader.WriteUMeshDep("Pyfile3.med", mesh, False)
mesh_rw = MEDLoader.ReadUMeshFromFile("Pyfile3.med", mesh.getName(), 0)
self.assertTrue(mesh.isEqual(mesh_rw, 1e-12))
pass
示例3: testFieldNodeProfilRW1
# 需要导入模块: from MEDLoaderDataForTest import MEDLoaderDataForTest [as 别名]
# 或者: from MEDLoaderDataForTest.MEDLoaderDataForTest import build2DMesh_1 [as 别名]
def testFieldNodeProfilRW1(self):
fileName="Pyfile19.med";
fileName2="Pyfile20.med";
m=MEDLoaderDataForTest.build2DMesh_1();
nbOfNodes=m.getNumberOfNodes();
MEDLoader.WriteUMesh(fileName,m,True);
f1=MEDLoader.MEDCouplingFieldDouble.New(MEDLoader.ON_NODES,MEDLoader.ONE_TIME);
f1.setName("VFieldOnNodes");
f1.setMesh(m);
array=MEDLoader.DataArrayDouble.New();
arr1=[1.,101.,2.,102.,3.,103.,4.,104.,5.,105.,6.,106.,7.,107.,8.,108.,9.,109.,10.,110.,11.,111.,12.,112.]
array.setValues(arr1,nbOfNodes,2);
f1.setArray(array);
array.setInfoOnComponent(0,"tyty [mm]");
array.setInfoOnComponent(1,"uiop [MW]");
f1.setTime(3.14,2,7);
f1.checkConsistencyLight();
arr2=[1,4]
f2=f1.buildSubPart(arr2);
f2.getMesh().setName(f1.getMesh().getName());
MEDLoader.WriteField(fileName,f2,False);#<- False important for the test
#
f3=MEDLoader.ReadFieldNode(fileName,f2.getMesh().getName(),0,f2.getName(),2,7);
f3.checkConsistencyLight();
self.assertTrue(f3.isEqual(f2,1e-12,1e-12));
#
arr3=[1,3,0,5,2,4]
f2.renumberNodes(arr3);
MEDLoader.WriteUMesh(fileName2,m,True);
MEDLoader.WriteField(fileName2,f2,False);#<- False important for the test
f3=MEDLoader.ReadFieldNode(fileName2,f2.getMesh().getName(),0,f2.getName(),2,7);
f3.checkConsistencyLight();
self.assertTrue(f3.isEqual(f2,1e-12,1e-12));
#
pass
示例4: testExampleReadFieldPartial1
# 需要导入模块: from MEDLoaderDataForTest import MEDLoaderDataForTest [as 别名]
# 或者: from MEDLoaderDataForTest.MEDLoaderDataForTest import build2DMesh_1 [as 别名]
def testExampleReadFieldPartial1(self):
from MEDLoaderDataForTest import MEDLoaderDataForTest
#! [PySnippetReadFieldPartial1_1]
fname="PyExamples2.med"
meshName="mesh"
fieldName="FieldPartial"
iteration=3
order=4
#! [PySnippetReadFieldPartial1_1]
#! [PySnippetWriteFieldPartial1_2]
m=MEDLoaderDataForTest.build2DMesh_1()
m.sortCellsInMEDFileFrmt()
m.setName(meshName)
# end of generation of a mesh -> let's create a field on that mesh
f=m.getMeasureField(False)
f=f.buildNewTimeReprFromThis(ONE_TIME,False)
f.setTime(5.5,iteration,order)
f.setName(fieldName)
# The MEDCoupling part is finished -> let's perform advanced API
mm=MEDFileUMesh.New()
mm.setMeshAtLevel(0,m) # the MED file data structure is ready for writing. Of course mm could have been more complicated with groups, families, multilevel
# Let's building a sub field
pfl=DataArrayInt.New([1,3,4,5])
pfl.setName("myPfl") # here it is necessary to give a name to be compliant with MED file
f=f[pfl] ; f.getMesh().setName(m.getName()) # of course f should be in coherence with pfl -> f[pfl]
#
ff=MEDFileField1TS.New()
tmp=f.getMesh() # useless line, only to show that mesh into f is not considered by MEDFileField1TS.setFieldProfile
f.setMesh(None) # useless line, only to show that mesh into f is not considered by MEDFileField1TS.setFieldProfile
ff.setFieldProfile(f,mm,0,pfl)
f.setMesh(tmp) # useless line, only to show that mesh into f is not considered by MEDFileField1TS.setFieldProfile
mm.write(fname,2)
ff.write(fname,0)
#! [PySnippetWriteFieldPartial1_2]
#! [PySnippetReadFieldPartial1_3]
mm=MEDFileMesh.New(fname)
medfileField1TS=MEDFileField1TS.New(fname,fieldName,iteration,order)
fread=medfileField1TS.getFieldOnMeshAtLevel(ON_CELLS,0,mm)
fread2=medfileField1TS.getFieldAtLevel(ON_CELLS,0)
self.assertTrue(fread.isEqual(f,1e-12,1e-12))
self.assertTrue(fread2.isEqual(f,1e-12,1e-12))
#! [PySnippetReadFieldPartial1_3]
#! [PySnippetReadFieldPartial1_4]
medfileField1TS=MEDFileField1TS.New(fname,fieldName,iteration,order)
mm=MEDFileMesh.New(fname)
valsRead,pflRead=medfileField1TS.getFieldWithProfile(ON_CELLS,0,mm)
self.assertEqual(valsRead.getName(),f.getName())
valsRead.setName("")
self.assertTrue(valsRead.isEqual(f.getArray(),1e-12))
pflRead.setName(pfl.getName())
self.assertTrue(pflRead.isEqual(pfl))
#! [PySnippetReadFieldPartial1_4]
#! [PySnippetReadFieldPartial1_5]
firstApproachMesh=fread.getMesh()
mm=MEDFileMesh.New(fname)
wholeMesh=mm.getMeshAtLevel(0)
wholeMesh.tryToShareSameCoords(firstApproachMesh,1e-12)
isIncluded,pflComputed=wholeMesh.areCellsIncludedIn(firstApproachMesh,2)
self.assertTrue(isIncluded)
self.assertEqual(pflComputed.getName(),mm.getName())
pflComputed.setName(pflRead.getName())
self.assertTrue(pflComputed.isEqual(pflRead))
#! [PySnippetReadFieldPartial1_5]
#! [PySnippetReadFieldPartial1_6]
mm=MEDFileMesh.New(fname)
wholeMesh=mm.getMeshAtLevel(0)
computedMesh=wholeMesh[pflRead] ; computedMesh.setName(mm.getName())
self.assertTrue(computedMesh.isEqual(fread.getMesh(),1e-12))
fieldFromSecondApproach=MEDCouplingFieldDouble.New(ON_CELLS,ONE_TIME)
fieldFromSecondApproach.setName(medfileField1TS.getName())
fieldFromSecondApproach.setMesh(computedMesh)
fieldFromSecondApproach.setArray(valsRead)
fieldFromSecondApproach.setTime(medfileField1TS.getTime()[2],medfileField1TS.getTime()[0],medfileField1TS.getTime()[1])
self.assertTrue(fieldFromSecondApproach.isEqual(fread,1e-12,1e-12))
#! [PySnippetReadFieldPartial1_6]
pass