本文整理汇总了Python中PerceptMesh.get_bulk_data方法的典型用法代码示例。如果您正苦于以下问题:Python PerceptMesh.get_bulk_data方法的具体用法?Python PerceptMesh.get_bulk_data怎么用?Python PerceptMesh.get_bulk_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PerceptMesh
的用法示例。
在下文中一共展示了PerceptMesh.get_bulk_data方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_mesh_diff
# 需要导入模块: import PerceptMesh [as 别名]
# 或者: from PerceptMesh import get_bulk_data [as 别名]
def test_mesh_diff(self):
self.fixture_setup()
p_size = parallel_machine_size(self.pm)
if p_size <= 2:
eMesh_0 = PerceptMesh(2)
eMesh_0.open_read_only("./exodus_files/quad_fixture.e")
eMesh_0.save_as("./exodus_files/quad_fixture_readwrite.e")
eMesh_1 = PerceptMesh(2)
eMesh_2 = PerceptMesh(2)
eMesh_1.open_read_only("./exodus_files/quad_fixture_readwrite.e")
eMesh_2.open_read_only("./exodus_files/quad_fixture.e")
if p_size == 1:
add_newlines = False
eMesh_1.print_info("quad fixture", 2, add_newlines)
eMesh_2.print_info("quad fixture", 2, add_newlines)
#Here the unit test compares an expected output string with the output of the print_infos
diff_msg = "diff report: "
diff = PerceptMesh.mesh_difference(eMesh_1, eMesh_2, diff_msg, True )
self.assertFalse(diff)
#metaData_1 = eMesh_1.get_fem_meta_data()
#metaData_2 = eMesh_2.get_fem_meta_data()
bulkData_1 = eMesh_1.get_bulk_data()
#bulkData_2 = eMesh_2.get_bulk_data()
#coordField_1 = eMesh_1.get_coordinates_field()
#coordField_2 = eMesh_2.get_coordinates_field()
#diff = PerceptMesh.mesh_difference(metaData_1, metaData_2, bulkData_1, bulkData_2, diff_msg, True)
#self.assertFalse(diff)
buckets = bulkData_1.buckets(FEMMetaData.NODE_RANK)
示例2: test_use_case_1
# 需要导入模块: import PerceptMesh [as 别名]
# 或者: from PerceptMesh import get_bulk_data [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)
示例3: __init__
# 需要导入模块: import PerceptMesh [as 别名]
# 或者: from PerceptMesh import get_bulk_data [as 别名]
class LocalFixture:
def __init__(self, num_xyz, num_y, num_z):
self.eMesh = PerceptMesh()
self.num_x = num_xyz
self.num_y = num_y
self.num_z = num_z
config_mesh = str(self.num_x) + "x" + str(self.num_y) + "x" + str(self.num_z) + "|bbox:-0.5,-0.5,-0.5,0.5,0.5,0.5"
self.eMesh.new_mesh(GMeshSpec(config_mesh))
self.eMesh.commit()
self.metaData = self.eMesh.get_fem_meta_data()
self.bulkData = self.eMesh.get_bulk_data()
self.coords_field = self.metaData.get_field("coordinates")
self.sfx = StringFunction("x", "sfx", Dimensions(3), Dimensions(1))
self.sfx_res = ConstantFunction(0.0, "sfx_res")
示例4: test_perceptMesh_walk_nodes
# 需要导入模块: import PerceptMesh [as 别名]
# 或者: from PerceptMesh import get_bulk_data [as 别名]
def test_perceptMesh_walk_nodes(self):
self.fixture_setup()
p_size = self.pm.size
p_rank = self.pm.rank
if p_size <= 2:
n = 12
nx = n
ny = n
sidesets_on = 1
fixture = QuadFixture_4(self.pm, nx, ny, sidesets_on)
fixture.meta_data.commit()
fixture.generate_mesh()
eMesh = PerceptMesh(fixture.meta_data, fixture.bulk_data)
eMesh.print_info("quad fixture", 2)
metaData = eMesh.get_fem_meta_data()
parts = metaData.get_parts()
nparts = len(parts)
print "Number of parts = ", nparts
surface_id = 2
surface_name = "surface_" + str(surface_id)
part = eMesh.get_part(surface_name)
in_surface_selector = Selector(part)
bulkData = eMesh.get_bulk_data()
coordField = eMesh.get_coordinates_field()
if eMesh.get_spatial_dim() == 2:
buckets_arg = eMesh.edge_rank()
else:
buckets_arg = eMesh.face_rank
buckets = bulkData.buckets(buckets_arg)
sum = 0.0
示例5: test_fieldFunction_point_eval_verify
# 需要导入模块: import PerceptMesh [as 别名]
# 或者: from PerceptMesh import get_bulk_data [as 别名]
def test_fieldFunction_point_eval_verify(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))
eMesh.commit()
f_coords = eMesh.get_field("coordinates")
ff_coords = FieldFunction("ff_coords", f_coords, eMesh, Dimensions(3), Dimensions(3), FieldFunction.SIMPLE_SEARCH)
val1 = eval_vec3_print(0.2,0.3,0.4,0.0,ff_coords)
bulkData = eMesh.get_bulk_data()
try:
val10 = eval_print_vec3(1.2, 1.3, 1.4, 0.0, ff_coords)
except:
print "expected to catch this exception: "
pts = array([0.2, 0.3, 0.4])
output_pts = array([0.0, 0.0, 0.0])
output_pts = ff_coords.value(pts, output_pts)
tol = 1.e-9
print "output(0) = ", pts[0], " == output_pts(0) = ", output_pts[0]
print "output(1) = ", pts[1], " == output_pts(1) = ", output_pts[1]
print "output(2) = ", pts[2], " == output_pts(2) = ", output_pts[2]
self.assertAlmostEqual(pts[0], output_pts[0], delta = tol)
self.assertAlmostEqual(pts[1], output_pts[1], delta = tol)
self.assertAlmostEqual(pts[2], output_pts[2], delta = tol)
示例6: test_high_level_interface
# 需要导入模块: import PerceptMesh [as 别名]
# 或者: from PerceptMesh import get_bulk_data [as 别名]
def test_high_level_interface(self):
self.fixture_setup()
p_size = parallel_machine_size(self.pm)
if p_size <= 2:
eMesh = PerceptMesh(2)
eMesh.open("./exodus_files/quad_fixture.e")
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, 2, 2)
#eval_vec3_print(0.1,0.1,0.1,0.0,ff_coords)
coords_mag_sf = StringFunction("sqrt(x*x + y*y )" , "coords_mag_sf", 2, 1)
x = 0.123
y = 0.234
vv = sqrt(x*x + y*y )
v1 = eval_func2(x,y,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, 2, 1)
coords_mag_field_function.interpolateFrom(coords_mag_sf)
eMesh.save_as("./exodus_files/quad_fixture_with_coords_mag.e")
ff_coords.add_alias("mc")
sfcm = StringFunction("sqrt(mc[0]*mc[0]+mc[1]*mc[1]+mc[2]*mc[2])", "sfcm", 3, 1)
add_newlines = True
eMesh.print_info("quad fixture", 2, add_newlines)
self.assertTrue(eMesh.get_spatial_dim() == 2)
self.assertTrue(eMesh.get_number_elements() == 12*12)
self.assertTrue(eMesh.get_number_nodes() == 13*13)
self.assertTrue(eMesh.get_parallel_size() == p_size)
self.assertTrue(eMesh.get_bulk_data() != 0)
self.assertTrue(eMesh.get_fem_meta_data() != 0)
# // entity data setter/getters
node = eMesh.get_node(1)
self.assertTrue(node != 0)
cm1 = eMesh.get_field_data(coords_mag_field, node)
co1 = [0,0]
co1[0] = eMesh.get_field_data(f_coords, node, 0)
co1[1] = eMesh.get_field_data(f_coords, node, 1)
print "cm1= ", cm1, " co1= ", co1
eMesh.set_field_data(123.0, f_coords, node, 0)
co1[0] = eMesh.get_field_data(f_coords, node, 0)
print " co1= ", co1
element = eMesh.get_element(1)
self.assertTrue(element != 0)
element1 = eMesh.get_entity(eMesh.element_rank(), 1)
self.assertTrue(element == element1)
#/// find node closest to given point
node = eMesh.get_node(0,0)
self.assertTrue(node != 0)
#/// find element that contains given point
element = eMesh.get_element(0.01, 0.01)
self.assertTrue(element != 0)
示例7: range
# 需要导入模块: import PerceptMesh [as 别名]
# 或者: from PerceptMesh import get_bulk_data [as 别名]
print "rates= ", rates
#####################################################################################
# B) loop over meshes and compute errors
for i in range(0,num_meshes):
pMesh = PerceptMesh(2)
pMesh.open(mesh_files[i])
pMesh.commit()
spatial_dim=pMesh.get_spatial_dim()
# TODO: check that this matches the StringFunction exact solution
metaData = pMesh.get_fem_meta_data()
bulkData = pMesh.get_bulk_data()
nodal_field = metaData.get_field(nodal_fields[0])
ff_Tnd = FieldFunction(nodal_fields[0], nodal_field, bulkData, Dimensions(spatial_dim), Dimensions(1))
error_string = [exact_soln_name[0]+" - "+nodal_fields[0]];
error_name = [nodal_fields[0]+"_err"]
sf_Terr = StringFunction(error_string[0], error_name[0], Dimensions(spatial_dim), Dimensions(1))
numSteps = pMesh.get_database_time_step_count()
pMesh.read_database_at_step(numSteps)
# DEBUG
print numSteps, pMesh.get_current_database_step(), pMesh.get_current_database_time()
cubDegree = 2