COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
atest-boussinesq.py
Go to the documentation of this file.
1 import sys
2 # sys.path.append('/data/scholl/coolfluid3/build/dso')
3 # sys.path.append('/home/sebastian/coolfluid3/build/dso')
4 import coolfluid as cf
5 
6 # Some shortcuts
7 root = cf.Core.root()
8 env = cf.Core.environment()
9 
10 ## Global confifuration
11 env.assertion_throws = False
12 env.assertion_backtrace = False
13 env.exception_backtrace = False
14 env.regist_signal_handlers = False
15 env.log_level = 4
16 
17 # setup a model
18 model = root.create_component('Boussinesq', 'cf3.solver.ModelUnsteady')
19 domain = model.create_domain()
20 physics = model.create_physics('cf3.UFEM.NavierStokesPhysics')
21 solver = model.create_solver('cf3.UFEM.Solver')
22 
23 # Create a component to manage initial conditions
24 ic = solver.create_initial_conditions()
25 
26 # Add the Navier-Stokes solver as an unsteady solver
27 boussinesq = solver.add_unsteady_solver('cf3.UFEM.NavierStokes')
28 boussinesq.options().set('use_boussinesq', True)
29 
30 boussinesq.Assembly.BoussinesqAssemblyQuads.g = [0., 9.81]
31 
32 # Generate mesh
33 blocks = domain.create_component('blocks', 'cf3.mesh.BlockMesh.BlockArrays')
34 points = blocks.create_points(dimensions = 2, nb_points = 4)
35 points[0] = [0., 0.]
36 points[1] = [1., 0.]
37 points[2] = [1.,1.]
38 points[3] = [0., 1.]
39 
40 block_nodes = blocks.create_blocks(1)
41 block_nodes[0] = [0, 1, 2, 3]
42 
43 block_subdivs = blocks.create_block_subdivisions()
44 block_subdivs[0] = [40, 40]
45 
46 gradings = blocks.create_block_gradings()
47 gradings[0] = [1., 1., 1., 1.]
48 
49 # fluid block
50 left_patch = blocks.create_patch_nb_faces(name = 'left', nb_faces = 1)
51 left_patch[0] = [3, 0]
52 
53 bottom_patch = blocks.create_patch_nb_faces(name = 'bottom', nb_faces = 1)
54 bottom_patch[0] = [0, 1]
55 
56 right_patch = blocks.create_patch_nb_faces(name = 'right', nb_faces = 1)
57 right_patch[0] = [1, 2]
58 
59 top_patch = blocks.create_patch_nb_faces(name = 'top', nb_faces = 1)
60 top_patch[0] = [2, 3]
61 
62 blocks.options().set('block_regions', ['fluid'])
63 
64 mesh = domain.create_component('Mesh', 'cf3.mesh.Mesh')
65 blocks.create_mesh(mesh.uri())
66 
67 # For each solver, set the region in which it operates
68 boussinesq.options().set('regions', [mesh.access_component('topology/fluid').uri()])
69 
70 u_in = [1., 0.]
71 u_wall = [0., 0.]
72 phi_in = 1.
73 phi_wall = 0.
74 
75 #initial conditions
76 solver.InitialConditions.navier_stokes_solution.regions = [mesh.access_component('topology').uri()]
77 solver.InitialConditions.navier_stokes_solution.Velocity = u_in
78 solver.InitialConditions.navier_stokes_solution.Temperature = phi_in
79 
80 #properties for Navier-Stokes
81 physics.density = 1.
82 physics.dynamic_viscosity = 1.e-5
83 
84 # Boundary conditions for Boussinesq
85 bc = boussinesq.get_child('BoundaryConditions')
86 bc.options().set('regions', [mesh.access_component('topology').uri()]) # needed to make the lookup work
87 
88 bc.add_constant_bc(region_name = 'left', variable_name = 'Velocity').options().set('value', u_wall)
89 bc.add_constant_bc(region_name = 'bottom', variable_name = 'Velocity').options().set('value', u_wall)
90 bc.add_constant_bc(region_name = 'right', variable_name = 'Velocity').options().set('value', u_wall)
91 bc.add_constant_bc(region_name = 'top', variable_name = 'Velocity').options().set('value', u_wall)
92 
93 bc.add_constant_bc(region_name = 'left', variable_name = 'Temperature').options().set('value', phi_wall)
94 bc.add_constant_bc(region_name = 'bottom', variable_name = 'Temperature').options().set('value', phi_in)
95 bc.add_constant_bc(region_name = 'right', variable_name = 'Temperature').options().set('value', phi_wall)
96 bc.add_constant_bc(region_name = 'top', variable_name = 'Temperature').options().set('value', phi_wall)
97 
98 # Time setup
99 time = model.create_time()
100 time.options().set('time_step', 0.01)
101 
102 # Setup a time series write
103 
104 final_end_time = 0.1
105 save_interval = 0.01
106 current_end_time = 0.
107 iteration = 0.
108 
109 while current_end_time < final_end_time:
110  current_end_time += save_interval
111  time.options().set('end_time', current_end_time)
112  model.simulate()
113  domain.write_mesh(cf.URI('boussinesq-' +str(iteration) + '.pvtu'))
114  iteration += 1
115  if iteration == 1:
116  solver.options().set('disabled_actions', ['InitialConditions'])
117 
118 # print timings
119 model.print_timing_tree()
common::URI uri(ComponentWrapper &self)
Send comments to:
COOLFluiD Web Admin