7 destination = domain.create_component(source.name(),
'cf3.mesh.Field')
8 destination.set_row_size(1)
9 destination.resize(nb_items)
11 for i
in range(nb_items):
12 destination[i][0] = source[i][0]
17 env = cf.Core.environment()
19 env.only_cpu0_writes =
True
22 domain = root.create_component(
'Domain',
'cf3.mesh.Domain')
23 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 time = domain.create_component(
'Time',
'cf3.solver.Time')
48 series_writer = domain.create_component(
'SeriesWriter',
'cf3.solver.actions.TimeSeriesWriter')
49 series_writer.time = time
50 series_writer.interval = 5
52 writer = series_writer.create_component(
'Writer',
'cf3.mesh.cf3mesh.Writer')
53 file_template =
'timeseries-{iteration}-{time}.cf3mesh'
54 writer.file = cf.URI(file_template)
57 advance_time = domain.create_component(
'AdvanceTime',
'cf3.solver.actions.AdvanceTime')
58 advance_time.time = time
62 series_writer.execute()
63 advance_time.execute()
66 reader = domain.create_component(
'Reader',
'cf3.mesh.cf3mesh.Reader')
67 meshdiff = domain.create_component(
'MeshDiff',
'cf3.mesh.actions.MeshDiff')
71 filename = file_template.format(time = float(i)*time.time_step, iteration = i)
73 filename = file_template.format(time = 0, iteration = 0)
74 if i % series_writer.interval != 0:
75 if os.path.isfile(filename):
76 raise Exception(
'File ' + filename +
' is not supposed to exist')
78 reader.mesh = domain.create_component(
'ReadMesh',
'cf3.mesh.Mesh')
79 reader.file = cf.URI(filename)
81 meshdiff.right = reader.mesh
83 if not meshdiff.properties()[
'mesh_equal']:
84 raise Exception(
'Error in read mesh')
def copy_and_reset(source, domain)