4 env = cf.Core.environment()
6 env.only_cpu0_writes =
True
9 domain = root.create_component(
'Domain',
'cf3.mesh.Domain')
10 mesh = domain.create_component(
'OriginalMesh',
'cf3.mesh.Mesh')
12 blocks = root.create_component(
'model',
'cf3.mesh.BlockMesh.BlockArrays')
13 points = blocks.create_points(dimensions = 2, nb_points = 4)
18 block_nodes = blocks.create_blocks(1)
19 block_nodes[0] = [0, 1, 2, 3]
20 block_subdivs = blocks.create_block_subdivisions()
21 block_subdivs[0] = [40,20]
22 gradings = blocks.create_block_gradings()
23 gradings[0] = [1., 1., 1., 1.]
24 blocks.create_patch_nb_faces(name =
'bottom', nb_faces = 1)[0] = [0, 1]
25 blocks.create_patch_nb_faces(name =
'right', nb_faces = 1)[0] = [1, 2]
26 blocks.create_patch_nb_faces(name =
'top', nb_faces = 1)[0] = [2, 3]
27 blocks.create_patch_nb_faces(name =
'left', nb_faces = 1)[0] = [3, 0]
28 blocks.partition_blocks(nb_partitions = cf.Core.nb_procs(), direction = 1)
29 blocks.create_mesh(mesh.uri())
31 link_horizontal = domain.create_component(
'LinkHorizontal',
'cf3.mesh.actions.LinkPeriodicNodes')
32 link_horizontal.mesh = mesh
33 link_horizontal.source_region = mesh.topology.right
34 link_horizontal.destination_region = mesh.topology.left
35 link_horizontal.translation_vector = [-1., 0.]
36 link_horizontal.execute()
38 make_par_data = root.create_component(
'MakeParData',
'cf3.solver.actions.ParallelDataToFields')
39 make_par_data.mesh = mesh
40 make_par_data.execute()
42 p2space = mesh.create_continuous_space(name =
'TestP2Space', shape_function =
'cf3.mesh.LagrangeP2')
46 outfile = cf.URI(
'cf3test.cf3mesh')
47 domain.write_mesh(outfile)
49 reader = domain.create_component(
'CF3MeshReader',
'cf3.mesh.cf3mesh.Reader')
50 reader.mesh = domain.create_component(
'ReadBackMesh',
'cf3.mesh.Mesh')
54 reader.mesh.print_tree()
56 meshdiff = domain.create_component(
'MeshDiff',
'cf3.mesh.actions.MeshDiff')
58 meshdiff.right = reader.mesh
61 if not meshdiff.properties()[
'mesh_equal']:
62 raise Exception(
'Read mesh differs from original!')