6 destination = domain.create_component(source.name(),
'cf3.mesh.Field')
7 destination.set_row_size(1)
8 destination.resize(nb_items)
10 for i
in range(nb_items):
11 destination[i][0] = source[i][0]
16 env = cf.Core.environment()
18 env.only_cpu0_writes =
True
21 domain = root.create_component(
'Domain',
'cf3.mesh.Domain')
22 mesh = domain.create_component(
'OriginalMesh',
'cf3.mesh.Mesh')
25 blocks = root.create_component(
'model',
'cf3.mesh.BlockMesh.BlockArrays')
26 points = blocks.create_points(dimensions = 2, nb_points = 4)
31 block_nodes = blocks.create_blocks(1)
32 block_nodes[0] = [0, 1, 2, 3]
33 block_subdivs = blocks.create_block_subdivisions()
34 block_subdivs[0] = [16,16]
35 gradings = blocks.create_block_gradings()
36 gradings[0] = [1., 1., 1., 1.]
37 blocks.create_patch_nb_faces(name =
'bottom', nb_faces = 1)[0] = [0, 1]
38 blocks.create_patch_nb_faces(name =
'right', nb_faces = 1)[0] = [1, 2]
39 blocks.create_patch_nb_faces(name =
'top', nb_faces = 1)[0] = [2, 3]
40 blocks.create_patch_nb_faces(name =
'left', nb_faces = 1)[0] = [3, 0]
41 blocks.partition_blocks(nb_partitions = cf.Core.nb_procs(), direction = 1)
42 blocks.create_mesh(mesh.uri())
44 link_horizontal = domain.create_component(
'LinkHorizontal',
'cf3.mesh.actions.LinkPeriodicNodes')
45 link_horizontal.mesh = mesh
46 link_horizontal.source_region = mesh.topology.right
47 link_horizontal.destination_region = mesh.topology.left
48 link_horizontal.translation_vector = [-1., 0.]
49 link_horizontal.execute()
51 make_par_data = root.create_component(
'MakeParData',
'cf3.solver.actions.ParallelDataToFields')
52 make_par_data.mesh = mesh
53 make_par_data.execute()
56 time = domain.create_component(
'Time',
'cf3.solver.Time')
57 time.current_time = 2.
62 restart_file = cf.URI(
'restart-test.cf3restart')
63 writer = domain.create_component(
'Writer',
'cf3.solver.actions.WriteRestartFile')
64 writer.fields = [mesh.geometry.node_gids, mesh.elems_P0.element_gids]
65 writer.file = restart_file
72 time.current_time = 0.
77 reader = domain.create_component(
'Reader',
'cf3.solver.actions.ReadRestartFile')
79 reader.file = restart_file
81 reader.read_time_step =
False
83 if time.time_step != 1.:
84 raise Exception(
'Time step read when it shouldn not have been')
86 reader.read_time_step =
True
90 differ = domain.create_component(
'Differ',
'cf3.common.ArrayDiff')
91 differ.left = ref_node_gids
92 differ.right = mesh.geometry.node_gids
94 if not differ.properties()[
'arrays_equal']:
95 raise Exception(
'Node GIDS do not match')
97 differ.left = ref_element_gids
98 differ.right = mesh.elems_P0.element_gids
100 if not differ.properties()[
'arrays_equal']:
101 raise Exception(
'Element GIDS do not match')
103 if time.current_time != 2.
or time.time_step != 0.2
or time.iteration != 10:
104 raise Exception(
'Error in time data')
def copy_and_reset(source, domain)