本文整理汇总了Python中PerceptMesh.add_field方法的典型用法代码示例。如果您正苦于以下问题:Python PerceptMesh.add_field方法的具体用法?Python PerceptMesh.add_field怎么用?Python PerceptMesh.add_field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PerceptMesh
的用法示例。
在下文中一共展示了PerceptMesh.add_field方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_hex27_hex27_0
# 需要导入模块: import PerceptMesh [as 别名]
# 或者: from PerceptMesh import add_field [as 别名]
def test_hex27_hex27_0(self):
fixture_setup()
scalarDimension = 0
eMesh = PerceptMesh()
p_size = eMesh.get_parallel_size()
gmesh_spec = "1x1x" + str(p_size) + "|bbox:0,0,0,1,1," + str(p_size)
eMesh.new_mesh(GMeshSpec(gmesh_spec))
proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension)
breaker = Refiner(eMesh, HEX8_HEX27_1, proc_rank_field)
eMesh.commit()
eMesh.print_info()
eMesh.save_as("hex27_hex27_cube1x1x" + str(p_size) + "-orig.e")
breaker.setRemoveOldElements(True)
breaker.doBreak()
eMesh.save_as("hex27_hex27_cube1x1x" + str(p_size) + "_0.e")
em1 = PerceptMesh(3)
p_size = em1.get_parallel_size()
em1.open("hex27_hex27_cube1x1x" + str(p_size) + "_0.e")
proc_rank_field = em1.add_field("proc_rank", eMesh.element_rank(), scalarDimension)
breaker = Refiner(em1, HEX27_HEX27_8, proc_rank_field)
em1.commit()
breaker.setIgnoreSideSets(True)
breaker.setRemoveOldElements(True)
breaker.doBreak()
em1.save_as("hex27_hex27_cube1x1x" + str(p_size) + "_1.e")
示例2: test_break_tri3_to_tri6_sierra
# 需要导入模块: import PerceptMesh [as 别名]
# 或者: from PerceptMesh import add_field [as 别名]
def test_break_tri3_to_tri6_sierra(self):
fixture_setup()
pm = MPI.COMM_WORLD
p_size = parallel_machine_size(pm)
print p_size, "++++++++++++++++++++"
for i in range(100):
print "-------------------"
if p_size <= 3:
n = 12
nx = n
ny = n
createEdgeSets = True
fixture = QuadFixture_3(pm, nx, ny, createEdgeSets)
isCommited = False
eMesh = PerceptMesh(fixture.meta_data, fixture.bulk_data, isCommited)
scalarDimension = 0
proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension)
eMesh.add_field("proc_rank_ede", eMesh.edge_rank(), scalarDimension)
breaker = Refiner(eMesh, TRI3_TRI6_1, proc_rank_field)
eMesh.commit()
fixture.generate_mesh()
eMesh.print_info("tri mesh tri6")
eMesh.save_as("quad_fixture_tri3_tri6_0.e")
breaker.doBreak()
eMesh.print_info("tri mesh enriched")
eMesh.save_as("quad_fixture_tri6_tri6_0.e")
eMesh.save_as("quad_fixture_tri3_tri6_1.e")
示例3: test_fieldFunction_demo_2
# 需要导入模块: import PerceptMesh [as 别名]
# 或者: from PerceptMesh import add_field [as 别名]
def test_fieldFunction_demo_2(self):
eMesh = PerceptMesh()
eMesh.new_mesh(GMeshSpec("3x3x3|bbox:0,0,0,1,1,1"))
vectorDimension = 0
eMesh.add_field("coords_mag_field", FEMMetaData.NODE_RANK, vectorDimension)
eMesh.commit()
f_coords = eMesh.get_field("coordinates")
coords_mag_field = eMesh.get_field("coords_mag_field")
ff_coords = FieldFunction("ff_coords", f_coords, eMesh, 3, 3)
eval_vec3_print(0.1,0.1,0.1,0.0,ff_coords)
coords_mag_sf = StringFunction("sqrt(x*x + y*y + z*z)" , "coords_mag_sf", 3, 1)
x = 0.123
y = 0.234
z = 0.345
vv = sqrt(x*x + y*y + z*z)
v1 = eval_func(x,y,z,0,coords_mag_sf)
print "vv = ", vv, "== v1 = ", v1
self.assertEqual(vv, v1)
coords_mag_field_function = FieldFunction("coords_mag_field_function", coords_mag_field, eMesh, 3, 1)
coords_mag_field_function.interpolateFrom(coords_mag_sf)
eMesh.save_as("./cubehex8_withCoordMag_out.e")
ff_coords.add_alias("mc")
sfcm = StringFunction("sqrt(mc[0]*mc[0]+mc[1]*mc[1]+mc[2]*mc[2])", "sfcm", 3, 1)
示例4: test_hex27_hex27_1
# 需要导入模块: import PerceptMesh [as 别名]
# 或者: from PerceptMesh import add_field [as 别名]
def test_hex27_hex27_1(self):
fixture_setup()
pm = MPI.COMM_WORLD
p_size = parallel_machine_size(pm)
if p_size == 1 or p_size == 3:
eMesh = PerceptMesh(3)
eMesh.open("hex_fixture.e")
scalarDimension = 0
proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension)
breaker = Refiner(eMesh, HEX8_HEX27_1, proc_rank_field)
eMesh.commit()
eMesh.print_info()
eMesh.save_as("hex8_hex27_0.e")
breaker.doBreak()
eMesh.save_as("hex8_27_1.e")
if p_size == 1 or p_size == 3:
eMesh = PerceptMesh(3)
eMesh.open("hex8_27_1.e")
scalarDimension = 0
proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension)
breaker = Refiner(eMesh, HEX27_HEX27_8, proc_rank_field)
eMesh.commit()
breaker.setRemoveOldElements(True)
breaker.doBreak()
eMesh.save_as("hex8_hex27_hex27_1.e")
示例5: test_break_quad4_to_quad9_to_quad9
# 需要导入模块: import PerceptMesh [as 别名]
# 或者: from PerceptMesh import add_field [as 别名]
def test_break_quad4_to_quad9_to_quad9(self):
fixture_setup()
pm = MPI.COMM_WORLD
p_size = parallel_machine_size(pm)
doGenSideSets = True
if p_size <= 3:
n = 12
nx = n
ny = n
fixture = QuadFixture_4(pm, nx, ny, doGenSideSets)
isCommited = False
eMesh = PerceptMesh(fixture.meta_data, fixture.bulk_data, isCommited)
scalarDimension = 0
proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension)
breaker = Refiner(eMesh, QUAD4_QUAD9_1, proc_rank_field)
eMesh.commit()
fixture.generate_mesh()
breaker.doBreak()
eMesh.save_as("quad_fixture_quad9_quad9_0.e")
em1 = PerceptMesh(2)
em1.open("quad_fixture_quad9_quad9_0.e")
scalarDimension = 0
proc_rank_field = em1.add_field("proc_rank", eMesh.element_rank(), scalarDimension)
breaker = Refiner(em1, QUAD9_QUAD9_4, proc_rank_field)
em1.commit()
breaker.doBreak()
em1.save_as("quad_fixture_quad9_quad9_1.e")
示例6: test_fieldFunction_readMesh_createField_interpolateFrom
# 需要导入模块: import PerceptMesh [as 别名]
# 或者: from PerceptMesh import add_field [as 别名]
def test_fieldFunction_readMesh_createField_interpolateFrom(self):
num_x = 3
num_y = 3
num_z = 3
config_mesh = str(num_x) + "x" + str(num_y) + "x" + str(num_z) + "|bbox:0,0,0,1,1,1"
eMesh = PerceptMesh()
eMesh.new_mesh(GMeshSpec(config_mesh))
vectorDimension = 0
eMesh.add_field("coords_mag_field", FEMMetaData.NODE_RANK, vectorDimension)
eMesh.commit()
#p_rank = eMesh.get_bulk_data().parallel_rank()
#setRank(p_rank)
#from Util
f_coords = eMesh.get_field("coordinates")
coords_mag_field = eMesh.get_field("coords_mag_field")
#VERIFY_OP_ON Here the unit test does something
ff_coords = FieldFunction("ff_coords", f_coords, eMesh, 3, 3, FieldFunction.SIMPLE_SEARCH)
#here we could evaluate the function
#eval_vec3_print(0.1,0.2,0.3,0.0,ff_coords)
coords_mag_sf = StringFunction("sqrt(x*x + y*y + z*z)", "coords_mag_sf", 3, 1)
coords_mag_field_function = FieldFunction("coords_mag_field_function", coords_mag_field, eMesh, 3, 3, FieldFunction.SIMPLE_SEARCH)
coords_mag_field_function.interpolateFrom(coords_mag_sf)
#The following is not doable from Python
checkCoordMag = CheckCoordMag()
#eMesh.nodalOpLoop(checkCoordMag, coords_mag_field)
print checkCoordMag.error
ff_coords.add_alias("mc")
sfcm = StringFunction("sqrt(mc[0]*mc[0]+mc[1]*mc[1]+mc[2]*mc[2])", "sfcm", Dimensions(3), Dimensions(1))
tol1 = 1.e-12
vv = eval_vec3(0.1, 0.2, 0.3, 0.0, ff_coords)
print
print "0.1 == vv[0] = ", vv[0], "passed"
print "0.2 == vv[1] = ", vv[1], "passed"
print "0.3 == vv[2] = ", vv[2], "passed"
self.assertAlmostEqual(.1, vv[0], delta=tol1)
self.assertAlmostEqual(.2, vv[1], delta=tol1)
self.assertAlmostEqual(.3, vv[2], delta=tol1)
vv = eval_func(0.1, 0.2, 0.3, 0.0, sfcm)
v_expect = sqrt(0.1*0.1+0.2*0.2+0.3*0.3)
if ((vv-v_expect) < tol1):
print "vv = ", vv, " == v_expect = ", v_expect, "passed"
coords_mag_field_function.interpolateFrom(sfcm)
示例7: test_use_case_1
# 需要导入模块: import PerceptMesh [as 别名]
# 或者: from PerceptMesh import add_field [as 别名]
def test_use_case_1(self):
pMesh = PerceptMesh()
pMesh.new_mesh(GMeshSpec("3x3x3|bbox:0,0,0,2,2,2"))
field = pMesh.add_field("coordinates", 1)
pMesh.commit()
input_array = array([1.0, 0.5, 0.5])
input_array_2 = array([1.0, 1.5, 1.5])
ff = FieldFunction("ff", field, pMesh, 3, 3)
ff.add_alias("myalias")
ff_output = ff.evaluate(input_array)
f2 = FieldFunction("f2", field, pMesh, 3, 3)
f2_output = f2.evaluate(input_array_2)
sf = StringFunction("x+y+z", "myname", 3, 1)
sf_output = sf.evaluate(input_array)
sf_diff = StringFunction("ff-f2", "myname")
norm = L1Norm(pMesh.get_bulk_data())
value = norm.evaluate(ff)
diffnorm = norm.evaluate(sf_diff)
示例8: test_break_quad_to_quad_sierra_2
# 需要导入模块: import PerceptMesh [as 别名]
# 或者: from PerceptMesh import add_field [as 别名]
def test_break_quad_to_quad_sierra_2(self):
fixture_setup()
pm = MPI.COMM_WORLD
p_size = parallel_machine_size(pm)
doGenSideSets = True
if p_size <= 3:
n = 12
nx = n
ny = n
fixture = QuadFixture_4(pm,nx,ny,doGenSideSets)
isCommited = False
eMesh = PerceptMesh(fixture.meta_data, fixture.bulk_data, isCommited)
eMesh.commit()
fixture.generate_mesh()
eMesh.save_as("quad_fixture_mbreak_0.e")
eMesh.close()
eMesh1 = PerceptMesh(2)
eMesh1.open("quad_fixture_mbreak_0.e")
scalarDimension = 0
proc_rank_field = eMesh1.add_field("proc_rank", eMesh.element_rank(), scalarDimension)
breaker = Refiner(eMesh1, QUAD4_QUAD4_4_SIERRA, proc_rank_field)
eMesh1.commit()
i = 0
while i < 2:
print "\n\n\n ================ tmp Refine Pass = ", i
breaker.doBreak()
eMesh1.save_as("quad_fixture_mbreak_" + str(i) + ".e")
i = i + 1
示例9: test_break_tri3_to_tri6_to_tri6_sierra
# 需要导入模块: import PerceptMesh [as 别名]
# 或者: from PerceptMesh import add_field [as 别名]
def test_break_tri3_to_tri6_to_tri6_sierra(self):
fixture_setup()
pm = MPI.COMM_WORLD
p_size = parallel_machine_size(pm)
if p_size <= 3:
eMesh = PerceptMesh(2)
eMesh.open("quad_fixture_tri6_tri6_0.e")
scalarDimension = 0
proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension)
eMesh.add_field("proc_rank_ede", eMesh.edge_rank(), scalarDimension)
breaker = Refiner(eMesh, TRI6_TRI6_4, proc_rank_field)
eMesh.commit()
eMesh.print_info("tri mesh tri6")
eMesh.save_as("quad_fixture_tri6_tri6_0.e")
breaker.doBreak()
eMesh.print_info("tri mesh refined")
eMesh.save_as("quad_fixture_tri6_tri6_1.e")
示例10: test_hex8_hex8_8_1
# 需要导入模块: import PerceptMesh [as 别名]
# 或者: from PerceptMesh import add_field [as 别名]
def test_hex8_hex8_8_1(self):
fixture_setup()
eMesh = PerceptMesh()
p_size = eMesh.get_parallel_size()
gmesh_spec = "4x4x"+str(4*p_size)+"|bbox:0,0,0,1,1,1"
eMesh.new_mesh(GMeshSpec(gmesh_spec))
scalarDimension = 0
proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension)
breaker = Refiner(eMesh, HEX8_HEX8_8, proc_rank_field)
eMesh.commit()
breaker.doBreak
示例11: test_break_tri_to_tri_sierra_1_test
# 需要导入模块: import PerceptMesh [as 别名]
# 或者: from PerceptMesh import add_field [as 别名]
def test_break_tri_to_tri_sierra_1_test(self):
pm = MPI.COMM_WORLD
p_size = parallel_machine_size(pm)
if p_size <= 2:
n = 2
nx = n
ny = n
createEdgeSets = False
fixture = QuadFixture_4(pm,nx,ny,createEdgeSets)
isCommited = False
eMesh = PerceptMesh(fixture.meta_data, fixture.bulk_data, isCommited)
scalarDimension = 0
proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension)
eMesh.add_field("proc_rank_edge", eMesh.edge_rank(), scalarDimension)
breaker = Refiner(eMesh, TRI3_TRI3_4, proc_rank_field)
eMesh.commit()
fixture.generate_mesh()
breaker.setRemoveOldElements(False)
breaker.doBreak()
eMesh.dump_elements_compact()
示例12: test_wedge6_wedge18_enrich
# 需要导入模块: import PerceptMesh [as 别名]
# 或者: from PerceptMesh import add_field [as 别名]
def test_wedge6_wedge18_enrich(self):
pm = MPI.COMM_WORLD
p_size = parallel_machine_size(pm)
if p_size == 1:
wedgeFixture = WedgeFixture()
bulk = wedgeFixture.createMesh(MPI.COMM_WORLD, 4,3,2,0,1,0,1,0,1,"")
eMesh = PerceptMesh(wedgeFixture.getMetaData(), bulk, False)
scalarDimension = 0
proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension)
breaker = Refiner(eMesh, WEDGE6_WEDGE18_1, proc_rank_field)
eMesh.commit()
wedgeFixture.createBulkAfterMetaCommit(MPI.COMM_WORLD)
breaker.doBreak()
示例13: test_hex8_tet4_6_12_2
# 需要导入模块: import PerceptMesh [as 别名]
# 或者: from PerceptMesh import add_field [as 别名]
def test_hex8_tet4_6_12_2(self):
fixture_setup()
pm = MPI.COMM_WORLD
p_size = parallel_machine_size(pm)
eMesh = PerceptMesh(3)
eMesh.open("hex_fixture.e")
scalarDimension = 0
proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension)
breaker = Refiner(eMesh, HEX8_TET4_6_12, proc_rank_field)
eMesh.commit()
eMesh.print_info()
breaker.doBreak()
eMesh.save_as("hex_tet_6_12_1.e")
示例14: test_hex20_hex20_1
# 需要导入模块: import PerceptMesh [as 别名]
# 或者: from PerceptMesh import add_field [as 别名]
def test_hex20_hex20_1(self):
fixture_setup()
eMesh = PerceptMesh(3)
p_size = eMesh.get_parallel_size()
if p_size <= 3:
eMesh.open("hex20_hex20_cube1x1x"+str(p_size) + "_0.e")
scalarDimension = 0
proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension)
breaker = Refiner(eMesh, HEX20_HEX20_8, proc_rank_field)
eMesh.commit()
breaker.setRemoveOldElements(True)
breaker.doBreak()
eMesh.save_as("hex20_hex20_cube1x1x" + str(p_size) + "_1.e")
示例15: test_wedge6_wedge18_enrich
# 需要导入模块: import PerceptMesh [as 别名]
# 或者: from PerceptMesh import add_field [as 别名]
def test_wedge6_wedge18_enrich(self):
pm = MPI.COMM_WORLD
p_size = parallel_machine_size(pm)
if p_size == 1:
wedgeFixture = WedgeFixture()
bulk = wedgeFixture.createMesh(MPI.COMM_WORLD, 4,3,2,0,1,0,1,0,1,"") # create stk::mesh::BulkData from wedge fixture
eMesh = PerceptMesh(wedgeFixture.getMetaData(), bulk, False) # adopt bulk data
scalarDimension = 0
proc_rank_field = eMesh.add_field("proc_rank", eMesh.element_rank(), scalarDimension)
breaker = Refiner(eMesh, WEDGE6_WEDGE15_1, proc_rank_field)
eMesh.commit()
wedgeFixture.createBulkAfterMetaCommit(MPI.COMM_WORLD) # generate the mesh
breaker.doBreak() # refine
eMesh.save_as("./wedge6-15.e") # save