COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
atest-ufem-navier-stokes-cylinder2d.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 confifuration
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 # Store the SUPG coefficient values
22 # su_fields = solver.add_unsteady_solver('cf3.UFEM.SUPGFields')
23 
24 # Add the Navier-Stokes solver as an unsteady solver
25 ns_solver = solver.add_unsteady_solver('cf3.UFEM.NavierStokes')
26 ns_solver.options.use_specializations = False
27 
28 #Load mesh
29 mesh = domain.load_mesh(file = cf.URI(sys.argv[1]), name = 'Mesh')
30 
31 #su_fields.regions = [mesh.topology.uri()]
32 ns_solver.regions = [mesh.topology.uri()]
33 
34 u_in = [2., 0.]
35 
36 #initial condition for the velocity. Unset variables (i.e. the pressure) default to zero
37 solver.InitialConditions.navier_stokes_solution.Velocity = u_in
38 # Physical constants
39 physics.options().set('density', 1000.)
40 physics.options().set('dynamic_viscosity', 10.)
41 
42 # Boundary conditions
43 bc = ns_solver.BoundaryConditions
44 bc.add_constant_bc(region_name = 'in', variable_name = 'Velocity').value = u_in
45 bc.add_constant_bc(region_name = 'symm', variable_name = 'Velocity').value = u_in
46 bc.add_constant_bc(region_name = 'wall', variable_name = 'Velocity').value = [0., 0.]
47 bc.add_constant_bc(region_name = 'out', variable_name = 'Pressure').value = 0.
48 
49 # Time setup
50 time = model.create_time()
51 time.options().set('time_step', 0.1)
52 
53 # Setup a time series write
54 final_end_time = 0.5
55 save_interval = 0.5
56 current_end_time = 0.
57 iteration = 0
58 while current_end_time < final_end_time:
59  current_end_time += save_interval
60  time.options().set('end_time', current_end_time)
61  model.simulate()
62  domain.write_mesh(cf.URI('navier-stokes-cylinder2d_output-' +str(iteration) + '.pvtu'))
63  iteration += 1
64  if iteration == 1:
65  solver.options().set('disabled_actions', ['InitialConditions'])
66 
67 # print timings
68 model.print_timing_tree()
Send comments to:
COOLFluiD Web Admin