8 env = cf.Core.environment()
10 env.only_cpu0_writes =
True
13 domain = root.create_component(
'Domain',
'cf3.mesh.Domain')
14 mesh = domain.create_component(
'OriginalMesh',
'cf3.mesh.Mesh')
16 blocks = root.create_component(
'model',
'cf3.mesh.BlockMesh.BlockArrays')
17 points = blocks.create_points(dimensions = 2, nb_points = 4)
22 block_nodes = blocks.create_blocks(1)
23 block_nodes[0] = [0, 1, 2, 3]
24 block_subdivs = blocks.create_block_subdivisions()
25 block_subdivs[0] = [40,40]
26 gradings = blocks.create_block_gradings()
27 gradings[0] = [1., 1., 1., 1.]
28 blocks.create_patch_nb_faces(name =
'bottom', nb_faces = 1)[0] = [0, 1]
29 blocks.create_patch_nb_faces(name =
'right', nb_faces = 1)[0] = [1, 2]
30 blocks.create_patch_nb_faces(name =
'top', nb_faces = 1)[0] = [2, 3]
31 blocks.create_patch_nb_faces(name =
'left', nb_faces = 1)[0] = [3, 0]
32 blocks.partition_blocks(nb_partitions = cf.Core.nb_procs(), direction = 1)
33 blocks.create_mesh(mesh.uri())
36 velocity = mesh.geometry.create_field(name =
'velocity', variables=
'Velocity[vector]')
37 pressure = mesh.geometry.create_field(name =
'pressure', variables=
'Pressure')
40 init_field = domain.create_component(
'InitField',
'cf3.mesh.actions.InitFieldFunction')
41 init_field.field = velocity
42 init_field.functions = [
'4.*{Uc}*y*(1.-y)'.format(Uc=Uc),
'0']
45 randomizer = domain.create_component(
'Randomizer',
'cf3.solver.actions.RandomizeField')
46 randomizer.field = velocity
47 randomizer.variable_name =
'Velocity'
48 randomizer.maximum_variations = [0.3, 0.3]
49 randomizer.maximum_values = [Uc*1.3, Uc/3.]
50 randomizer.minimum_values = [-Uc, -Uc/3.]
52 stats = domain.create_component(
'Statistics',
'cf3.solver.actions.TurbulenceStatistics')
53 stats.region = mesh.topology
54 stats.file = cf.URI(
'turbulence-statistics.txt')
55 stats.rolling_window = 10
56 stats.add_probe([1., 0.5 ])
57 stats.add_probe([1., 0.15])
60 avg = domain.create_component(
'Average',
'cf3.solver.actions.FieldTimeAverage')
63 dir_avg = domain.create_component(
'DirectionalAverage',
'cf3.solver.actions.DirectionalAverage')
65 dir_avg.field = mesh.geometry.turbulence_statistics
66 dir_avg.file = cf.URI(
'turbulence-statistics-profile.txt')
70 randomizer.options.seed = i
77 writer = domain.create_component(
'PVWriter',
'cf3.mesh.VTKXML.Writer')
78 writer.fields = [velocity.uri(), mesh.geometry.coordinates.uri(), mesh.geometry.turbulence_statistics.uri(), mesh.geometry.average_velocity.uri()]
80 writer.file = cf.URI(
'turbulence-statistics.pvtu')