COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-ufem-heat2d-periodic.py
Go to the documentation of this file.
1 import sys
2 import coolfluid as cf
3 
4 # Global configuration
5 cf.env.assertion_backtrace = False
6 cf.env.exception_backtrace = True
7 cf.env.regist_signal_handlers = False
8 cf.env.exception_log_level = 0
9 cf.env.log_level = 4
10 cf.env.exception_outputs = False
11 
12 # setup a model
13 model = cf.Core.root().create_component('HotModel', 'cf3.solver.Model')
14 domain = model.create_domain()
15 physics = model.create_physics('cf3.UFEM.NavierStokesPhysics')
16 solver = model.create_solver('cf3.UFEM.Solver')
17 hc = solver.add_direct_solver('cf3.UFEM.HeatConductionSteady')
18 
19 # load the mesh (passed as first argument to the script)
20 mesh = domain.create_component('mesh','cf3.mesh.Mesh')
21 
22 blocks = domain.create_component('model', 'cf3.mesh.BlockMesh.BlockArrays')
23 points = blocks.create_points(dimensions = 2, nb_points = 4)
24 points[0] = [0., 0.]
25 points[1] = [1., 0.]
26 points[2] = [1., 1.]
27 points[3] = [0., 1.]
28 block_nodes = blocks.create_blocks(1)
29 block_nodes[0] = [0, 1, 2, 3]
30 block_subdivs = blocks.create_block_subdivisions()
31 block_subdivs[0] = [20,20]
32 gradings = blocks.create_block_gradings()
33 gradings[0] = [1., 1., 1., 1.]
34 blocks.create_patch_nb_faces(name = 'bottom', nb_faces = 1)[0] = [0, 1]
35 blocks.create_patch_nb_faces(name = 'right', nb_faces = 1)[0] = [1, 2]
36 blocks.create_patch_nb_faces(name = 'top', nb_faces = 1)[0] = [2, 3]
37 blocks.create_patch_nb_faces(name = 'left', nb_faces = 1)[0] = [3, 0]
38 blocks.partition_blocks(nb_partitions = 4, direction = 1)
39 blocks.create_mesh(mesh.uri())
40 
41 partitioner = domain.create_component('Partitioner', 'cf3.mesh.actions.PeriodicMeshPartitioner')
42 partitioner.mesh = mesh
43 
44 link_horizontal = partitioner.create_link_periodic_nodes()
45 link_horizontal.source_region = mesh.topology.right
46 link_horizontal.destination_region = mesh.topology.left
47 link_horizontal.translation_vector = [-1., 0.]
48 
49 partitioner.execute()
50 # link_horizontal.mesh = mesh
51 # link_horizontal.execute()
52 
53 make_par_data = domain.create_component('MakeParData', 'cf3.solver.actions.ParallelDataToFields')
54 make_par_data.mesh = mesh
55 make_par_data.execute()
56 
57 domain.write_mesh(cf.URI('heat2d-periodic-input.pvtu'))
58 
59 hc.regions = [mesh.topology.interior.uri()]
60 
61 writer = domain.create_component('MshWriter', 'cf3.mesh.gmsh.Writer')
62 writer.enable_overlap = True
63 writer.mesh = mesh
64 writer.fields = [mesh.geometry.node_gids.uri()]
65 writer.file = cf.URI('heat2d-periodic-input.msh')
66 writer.execute()
67 
68 # Boundary conditions
69 bc = hc.BoundaryConditions
70 bc.regions = [mesh.topology.uri()]
71 bc.add_constant_bc(region_name = 'bottom', variable_name = 'Temperature').value = 10
72 bc.add_constant_bc(region_name = 'top', variable_name = 'Temperature').value = 30
73 
74 # run the simulation
75 model.simulate()
76 
77 # Write result
78 writer.fields = [mesh.geometry.heat_conduction_solution.uri()]
79 writer.file = cf.URI('heat2d-periodic.msh')
80 writer.execute()
81 domain.write_mesh(cf.URI('heat2d-periodic.pvtu'))
boost::python::object create_component(ComponentWrapper &self, const std::string &name, const std::string &builder_name)
Send comments to:
COOLFluiD Web Admin