5 env = cf.Core.environment()
10 source_domain = root.create_component(
'SourceDomain',
'cf3.mesh.Domain')
11 target_domain = root.create_component(
'TargetDomain',
'cf3.mesh.Domain')
12 source_mesh = source_domain.create_component(
'sourcemesh',
'cf3.mesh.Mesh')
18 blocks = root.create_component(
'model',
'cf3.mesh.BlockMesh.BlockArrays')
25 points = blocks.create_points(dimensions = 2, nb_points = 6)
27 points[1] = [x_size, 0.]
29 points[3] = [x_size, h]
31 points[5] = [x_size, 2.*h]
32 block_nodes = blocks.create_blocks(2)
33 block_nodes[0] = [0, 1, 3, 2]
34 block_nodes[1] = [2, 3, 5, 4]
35 block_subdivs = blocks.create_block_subdivisions()
36 block_subdivs[0] = [x_segs, y_segs]
37 block_subdivs[1] = block_subdivs[0]
38 gradings = blocks.create_block_gradings()
39 gradings[0] = [1., 1., grading, grading]
40 gradings[1] = [1., 1., 1./grading, 1./grading]
41 left_patch = blocks.create_patch_nb_faces(name =
'left', nb_faces = 2)
42 left_patch[0] = [2, 0]
43 left_patch[1] = [4, 2]
44 bottom_patch = blocks.create_patch_nb_faces(name =
'bottom', nb_faces = 1)
45 bottom_patch[0] = [0, 1]
46 top_patch = blocks.create_patch_nb_faces(name =
'top', nb_faces = 1)
48 right_patch = blocks.create_patch_nb_faces(name =
'right', nb_faces = 2)
49 right_patch[0] = [1, 3]
50 right_patch[1] = [3, 5]
51 blocks.extrude_blocks(positions=[z_size], nb_segments=[z_segs], gradings=[1.])
52 blocks.partition_blocks(nb_partitions = 2, direction = 1)
53 blocks.partition_blocks(nb_partitions = 2, direction = 0)
54 blocks.partition_blocks(nb_partitions = 2, direction = 2)
55 blocks.create_mesh(source_mesh.uri())
57 source_coords = source_mesh.geometry.coordinates
58 testfield = source_mesh.geometry.create_field(name =
'test', variables =
'testx,testy')
59 for i
in range(len(source_coords)):
60 testfield[i][0] = 1.+2.*source_coords[i][0]
61 testfield[i][1] = 2.+3.*source_coords[i][1]
63 target_mesh = target_domain.create_component(
'targetmesh',
'cf3.mesh.Mesh')
64 generator = target_domain.create_component(
'Generator',
'cf3.mesh.GeneratePlane3D')
65 generator.mesh = target_mesh.uri()
66 generator.origin = [0., h, 0.]
67 generator.normal = [0., 1., 0.]
68 generator.size = [x_size, z_size]
69 generator.segments = [x_segs, z_segs]
72 interpolator = root.create_component(
'Interpolator',
'cf3.mesh.actions.MeshInterpolator')
73 interpolator.source_mesh = source_mesh
74 interpolator.target_mesh = target_mesh
75 interpolator.execute()
77 tgt_coords = target_mesh.geometry.coordinates
78 tgt_test = target_mesh.geometry.test
79 tgt_ranks = target_mesh.geometry.children.rank
80 my_rank = cf.Core.rank()
82 for i
in range(len(tgt_coords)):
83 if tgt_ranks[i] == my_rank:
84 print tgt_coords[i][0], tgt_coords[i][1], tgt_coords[i][2], tgt_test[i][0]