11 cf.env.assertion_backtrace =
False
12 cf.env.exception_backtrace =
False
13 cf.env.regist_signal_handlers =
False
14 cf.env.exception_log_level = 0
16 cf.env.exception_outputs =
False
23 model = cf.root.create_component(sf_name,
'cf3.solver.Model')
24 domain = model.create_domain()
25 physics = model.create_physics(
'cf3.UFEM.NavierStokesPhysics')
26 solver = model.create_solver(
'cf3.UFEM.Solver')
27 hc = solver.add_direct_solver(
'cf3.UFEM.HeatConductionSteady')
28 hc.options.heat_space_name = sf_name
29 hc.children.Assembly.options.k = k
30 hc.children.Update.options.relaxation_factor_hc = 1.
32 ic_heat = solver.InitialConditions.create_initial_condition(builder_name =
'cf3.UFEM.InitialConditionFunction', field_tag =
'source_terms')
33 ic_heat.variable_name =
'Heat'
34 ic_heat.options.field_space_name = sf_name
35 ic_heat.value = [
'x^2']
38 mesh = domain.create_component(
'mesh',
'cf3.mesh.Mesh')
39 mesh_generator = cf.root.create_component(
"mesh_generator",
"cf3.mesh.SimpleMeshGenerator")
40 mesh_generator.mesh = mesh.uri()
41 mesh_generator.nb_cells = [10]
42 mesh_generator.lengths = [2.]
43 mesh_generator.offsets = [-1.]
44 mesh_generator.execute()
47 hc.regions = [mesh.topology.uri()]
48 ic_heat.regions = hc.regions
51 bc = hc.BoundaryConditions
52 bc.add_constant_bc(region_name =
'xneg', variable_name =
'Temperature').value = Tb
53 bc.add_constant_bc(region_name =
'xpos', variable_name =
'Temperature').value = Tb
61 x_p1 = mesh_p1.geometry.coordinates
62 T_p1 = mesh_p1.geometry.heat_conduction_solution
65 x_p2 = mesh_p2.geometry.coordinates
66 T_p2 = mesh_p2.geometry.heat_conduction_solution
69 pl.plot(x_p1, T_p1,
'ko', mfc=
'none', label=
'P1')
70 pl.plot(x_p2, T_p2,
'kx', mfc=
'none', label=
'P2')
72 x_th = np.linspace(-1., 1., 500)
73 pl.plot(x_th, (-x_th**4. + 1.) + Tb,
'k-', label=
'Analytical')
75 pl.legend(loc =
'lower center')
78 pl.savefig(
'heat-p1-p2.eps')
def run_simulation(sf_name)