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 blocks = root.create_component(
'model',
'cf3.mesh.BlockMesh.BlockArrays')
71 points = blocks.create_points(dimensions = 2, nb_points = 6)
73 points[1] = [x_size, 0.]
75 points[3] = [x_size, h]
77 points[5] = [x_size, 2.*h]
78 block_nodes = blocks.create_blocks(2)
79 block_nodes[0] = [0, 1, 3, 2]
80 block_nodes[1] = [2, 3, 5, 4]
81 block_subdivs = blocks.create_block_subdivisions()
82 block_subdivs[0] = [x_segs, y_segs]
83 block_subdivs[1] = block_subdivs[0]
84 gradings = blocks.create_block_gradings()
85 gradings[0] = [1., 1., grading, grading]
86 gradings[1] = [1., 1., 1./grading, 1./grading]
87 left_patch = blocks.create_patch_nb_faces(name =
'left', nb_faces = 2)
88 left_patch[0] = [2, 0]
89 left_patch[1] = [4, 2]
90 bottom_patch = blocks.create_patch_nb_faces(name =
'bottom', nb_faces = 1)
91 bottom_patch[0] = [0, 1]
92 top_patch = blocks.create_patch_nb_faces(name =
'top', nb_faces = 1)
94 right_patch = blocks.create_patch_nb_faces(name =
'right', nb_faces = 2)
95 right_patch[0] = [1, 3]
96 right_patch[1] = [3, 5]
97 blocks.extrude_blocks(positions=[z_size], nb_segments=[z_segs], gradings=[1.])
99 blocks.partition_blocks(nb_partitions = 8, direction = 0)
101 blocks.create_mesh(target_mesh.uri())
103 interpolator = root.create_component(
'Interpolator',
'cf3.vtk.MeshInterpolator')
104 interpolator.source_mesh = source_mesh
105 interpolator.target_mesh = target_mesh
106 interpolator.execute()
108 source_domain.write_mesh(cf.URI(
'interpolator-source.pvtu'))
109 target_domain.write_mesh(cf.URI(
'interpolator-target.pvtu'))