COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-ufem-surfaceintegral.py
Go to the documentation of this file.
1 import sys
2 import coolfluid as cf
3 
4 # Some shortcuts
5 root = cf.Core.root()
6 env = cf.Core.environment()
7 
8 # Global configuration
9 env.assertion_throws = False
10 env.assertion_backtrace = False
11 env.exception_backtrace = False
12 env.regist_signal_handlers = False
13 env.log_level = 4
14 
15 # setup a model
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')
20 
21 # Add the Navier-Stokes solver as an unsteady solver
22 ns_solver = solver.add_unsteady_solver('cf3.UFEM.NavierStokes')
23 
24 # Generate mesh
25 blocks = domain.create_component('blocks', 'cf3.mesh.BlockMesh.BlockArrays')
26 points = blocks.create_points(dimensions = 2, nb_points = 6)
27 points[0] = [0, 0.]
28 points[1] = [10., 0.]
29 points[2] = [0., 0.5]
30 points[3] = [10., 0.5]
31 points[4] = [0.,1.]
32 points[5] = [10., 1.]
33 
34 block_nodes = blocks.create_blocks(2)
35 block_nodes[0] = [0, 1, 3, 2]
36 block_nodes[1] = [2, 3, 5, 4]
37 
38 block_subdivs = blocks.create_block_subdivisions()
39 block_subdivs[0] = [20, 10]
40 block_subdivs[1] = [20, 10]
41 
42 grading = 5.
43 gradings = blocks.create_block_gradings()
44 gradings[0] = [1., 1., grading, grading]
45 gradings[1] = [1., 1., 1./grading, 1./grading]
46 
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]
50 
51 bottom_patch = blocks.create_patch_nb_faces(name = 'bottom', nb_faces = 1)
52 bottom_patch[0] = [0, 1]
53 
54 top_patch = blocks.create_patch_nb_faces(name = 'top', nb_faces = 1)
55 top_patch[0] = [5, 4]
56 
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]
60 
61 blocks.partition_blocks(nb_partitions = cf.Core.nb_procs(), direction = 1)
62 
63 mesh = domain.create_component('Mesh', 'cf3.mesh.Mesh')
64 blocks.create_mesh(mesh.uri())
65 
66 ns_solver.regions = [mesh.topology.uri()]
67 
68 u_in = [1., 0.]
69 
70 solver.create_fields()
71 
72 #initial condition for the velocity. Unset variables (i.e. the pressure) default to zero
73 solver.InitialConditions.navier_stokes_solution.Velocity = u_in
74 solver.InitialConditions.navier_stokes_solution.Pressure = 1.
75 solver.InitialConditions.execute()
76 
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()
81 
82 if abs(pressure_integral.result[0] - 1.) > 1e-10:
83  raise Exception('Wrong integration result: ' + str(pressure_integral.result[0]) + ', expected 1')
84 
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()
89 
90 print pressure_integral.result, velocity_integral.result
91 
common::URI uri(ComponentWrapper &self)
Send comments to:
COOLFluiD Web Admin