COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
atest-multiregion.py
Go to the documentation of this file.
1 import sys
2 import coolfluid as cf
3 
4 # This test runs two separate heat conduction problems on two different regions of the same mesh
5 
6 # Some shortcuts
7 root = cf.Core.root()
8 env = cf.Core.environment()
9 
10 ## Global confifuration
11 env.options().set('assertion_throws', False)
12 env.options().set('assertion_backtrace', False)
13 env.options().set('exception_backtrace', False)
14 env.options().set('regist_signal_handlers', False)
15 env.options().set('log_level', 4)
16 
17 # setup a model
18 model = cf.Core.root().create_component('HotModel', 'cf3.solver.Model')
19 domain = model.create_domain()
20 physics = model.create_physics('cf3.UFEM.NavierStokesPhysics')
21 solver = model.create_solver('cf3.UFEM.Solver')
22 hc_bottom = solver.add_direct_solver('cf3.UFEM.HeatConductionSteady')
23 hc_top = solver.add_direct_solver('cf3.UFEM.HeatConductionSteady')
24 
25 # Generate mesh (1x1 square, cut in half horizontally)
26 blocks = domain.create_component('blocks', 'cf3.mesh.BlockMesh.BlockArrays')
27 points = blocks.create_points(dimensions = 2, nb_points = 6)
28 points[0] = [0, 0.]
29 points[1] = [1, 0.]
30 points[2] = [0., 0.5]
31 points[3] = [1., 0.5]
32 points[4] = [0.,1.]
33 points[5] = [1., 1.]
34 
35 block_nodes = blocks.create_blocks(2)
36 block_nodes[0] = [0, 1, 3, 2]
37 block_nodes[1] = [2, 3, 5, 4]
38 
39 block_subdivs = blocks.create_block_subdivisions()
40 block_subdivs[0] = [40, 20]
41 block_subdivs[1] = [40, 20]
42 
43 gradings = blocks.create_block_gradings()
44 gradings[0] = [1., 1., 1., 1.]
45 gradings[1] = [1., 1., 1., 1.]
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 # Put each block in a different region
62 blocks.options().set('block_regions', ['solid_bottom', 'solid_top'])
63 
64 mesh = domain.create_component('Mesh', 'cf3.mesh.Mesh')
65 blocks.create_mesh(mesh.uri())
66 
67 hc_bottom.options().set('regions', [mesh.access_component('topology/solid_bottom').uri()])
68 hc_top.options().set('regions', [mesh.access_component('topology/solid_top').uri()])
69 
70 # Boundary conditions for the bottom part
71 bc_bot = hc_bottom.get_child('BoundaryConditions')
72 bc_bot.options().set('regions', [mesh.access_component('topology').uri()]) # needed to make the lookup work
73 bc_bot.add_constant_bc(region_name = 'bottom', variable_name = 'Temperature').options().set('value', 10)
74 # the boundary between the regions had an automatically generated region, named 'region_bnd_<name of first region>_<name of second region>
75 bc_bot.add_constant_bc(region_name = 'region_bnd_solid_bottom_solid_top', variable_name = 'Temperature').options().set('value', 50)
76 
77 # Boundary conditions for the top part
78 bc_top = hc_top.get_child('BoundaryConditions')
79 bc_top.options().set('regions', [mesh.access_component('topology').uri()]) # needed to make the lookup work
80 bc_top.add_constant_bc(region_name = 'top', variable_name = 'Temperature').options().set('value', 10)
81 bc_top.add_constant_bc(region_name = 'region_bnd_solid_top_solid_bottom', variable_name = 'Temperature').options().set('value', 50)
82 
83 # run the simulation
84 model.simulate()
85 
86 # Write result
87 domain.write_mesh(cf.URI('atest-multiregion.pvtu'))
boost::python::object create_component(ComponentWrapper &self, const std::string &name, const std::string &builder_name)
common::URI uri(ComponentWrapper &self)
Send comments to:
COOLFluiD Web Admin