4 env = cf.Core.environment()
6 env.only_cpu0_writes =
True
7 env.exception_backtrace =
False
8 env.assertion_backtrace =
False
13 domain = root.create_component(
'Domain',
'cf3.mesh.Domain')
14 mesh = domain.create_component(
'mesh',
'cf3.mesh.Mesh')
17 blocks = root.create_component(
'model',
'cf3.mesh.BlockMesh.BlockArrays')
18 blocks.options.overlap = 0
19 points = blocks.create_points(dimensions = 2, nb_points = 4)
24 block_nodes = blocks.create_blocks(1)
25 block_nodes[0] = [0, 1, 2, 3]
26 block_subdivs = blocks.create_block_subdivisions()
27 block_subdivs[0] = [40,20]
28 gradings = blocks.create_block_gradings()
29 gradings[0] = [1., 1., 1., 1.]
30 blocks.create_patch_nb_faces(name =
'bottom', nb_faces = 1)[0] = [0, 1]
31 blocks.create_patch_nb_faces(name =
'right', nb_faces = 1)[0] = [1, 2]
32 blocks.create_patch_nb_faces(name =
'top', nb_faces = 1)[0] = [2, 3]
33 blocks.create_patch_nb_faces(name =
'left', nb_faces = 1)[0] = [3, 0]
34 blocks.extrude_blocks(positions=[1.], nb_segments=[20], gradings=[1.])
35 blocks.partition_blocks(nb_partitions = 2, direction = 0)
36 blocks.partition_blocks(nb_partitions = 2, direction = 1)
37 blocks.create_mesh(mesh.uri())
39 make_par_data = root.create_component(
'MakeParData',
'cf3.solver.actions.ParallelDataToFields')
40 make_par_data.mesh = mesh
41 make_par_data.execute()
43 domain.write_mesh(cf.URI(
'periodic-input.pvtu'))
45 periodic_partitioner = domain.create_component(
'Partitioner',
'cf3.mesh.actions.PeriodicMeshPartitioner')
46 periodic_partitioner.mesh = mesh
47 periodic_partitioner.load_balance =
True
49 link_horizontal = periodic_partitioner.create_link_periodic_nodes()
50 link_horizontal.source_region = mesh.topology.right
51 link_horizontal.destination_region = mesh.topology.left
52 link_horizontal.translation_vector = [-1., 0., 0.]
55 link_vertical = periodic_partitioner.create_link_periodic_nodes()
56 link_vertical.source_region = mesh.topology.top
57 link_vertical.destination_region = mesh.topology.bottom
58 link_vertical.translation_vector = [0., -1., 0.]
61 link_depth = periodic_partitioner.create_link_periodic_nodes()
62 link_depth.source_region = mesh.topology.back
63 link_depth.destination_region = mesh.topology.front
64 link_depth.translation_vector = [0., 0., -1.]
66 periodic_partitioner.execute()
68 make_par_data.execute()
70 domain.write_mesh(cf.URI(
'periodic.pvtu'))