6 env = cf.Core.environment()
9 env.assertion_throws =
False
10 env.assertion_backtrace =
False
11 env.exception_backtrace =
False
12 env.regist_signal_handlers =
False
16 model = root.create_component(
'NavierStokes',
'cf3.solver.ModelUnsteady')
17 domain = model.create_domain()
18 physics = model.create_physics(
'cf3.UFEM.NavierStokesPhysics')
19 solver = model.create_solver(
'cf3.UFEM.Solver')
22 ns_solver = solver.add_unsteady_solver(
'cf3.UFEM.NavierStokes')
25 blocks = domain.create_component(
'blocks',
'cf3.mesh.BlockMesh.BlockArrays')
26 points = blocks.create_points(dimensions = 2, nb_points = 6)
30 points[3] = [10., 0.5]
34 block_nodes = blocks.create_blocks(2)
35 block_nodes[0] = [0, 1, 3, 2]
36 block_nodes[1] = [2, 3, 5, 4]
38 block_subdivs = blocks.create_block_subdivisions()
39 block_subdivs[0] = [20, 10]
40 block_subdivs[1] = [20, 10]
43 gradings = blocks.create_block_gradings()
44 gradings[0] = [1., 1., grading, grading]
45 gradings[1] = [1., 1., 1./grading, 1./grading]
47 left_patch = blocks.create_patch_nb_faces(name =
'left', nb_faces = 2)
48 left_patch[0] = [2, 0]
49 left_patch[1] = [4, 2]
51 bottom_patch = blocks.create_patch_nb_faces(name =
'bottom', nb_faces = 1)
52 bottom_patch[0] = [0, 1]
54 top_patch = blocks.create_patch_nb_faces(name =
'top', nb_faces = 1)
57 right_patch = blocks.create_patch_nb_faces(name =
'right', nb_faces = 2)
58 right_patch[0] = [1, 3]
59 right_patch[1] = [3, 5]
61 blocks.partition_blocks(nb_partitions = cf.Core.nb_procs(), direction = 1)
63 mesh = domain.create_component(
'Mesh',
'cf3.mesh.Mesh')
64 blocks.create_mesh(mesh.uri())
66 ns_solver.regions = [mesh.topology.uri()]
70 solver.create_fields()
73 solver.InitialConditions.navier_stokes_solution.Velocity = u_in
74 solver.InitialConditions.navier_stokes_solution.Pressure = 1.
75 solver.InitialConditions.execute()
77 pressure_integral = solver.add_unsteady_solver(
'cf3.UFEM.SurfaceIntegral')
78 pressure_integral.set_field(variable_name =
'Pressure', field_tag =
'navier_stokes_solution')
79 pressure_integral.regions = [mesh.topology.access_component(
'right').
uri()]
80 pressure_integral.execute()
82 if abs(pressure_integral.result[0] - 1.) > 1e-10:
83 raise Exception(
'Wrong integration result: ' + str(pressure_integral.result[0]) +
', expected 1')
85 velocity_integral = solver.add_unsteady_solver(
'cf3.UFEM.SurfaceIntegral')
86 velocity_integral.set_field(variable_name =
'Velocity', field_tag =
'navier_stokes_solution')
87 velocity_integral.regions = [mesh.topology.access_component(
'left').
uri(), mesh.topology.access_component(
'bottom').
uri()]
88 velocity_integral.execute()
90 print pressure_integral.result, velocity_integral.result
common::URI uri(ComponentWrapper &self)