5 cf.env.assertion_throws =
False
6 cf.env.assertion_backtrace =
False
7 cf.env.exception_backtrace =
False
8 cf.env.exception_outputs =
False
9 cf.env.regist_signal_handlers =
False
15 for modelname
in [
'PoissonProto',
'PoissonSpecialized',
'PoissonManual',
'PoissonVirtual']:
17 print '#################################'
19 print '#################################'
24 domain = model.create_domain()
26 physics = model.create_physics(
'cf3.physics.DynamicModel')
28 solver = model.create_solver(
'cf3.UFEM.Solver')
30 poisson_solver = solver.add_direct_solver(
'cf3.UFEM.demo.'+modelname)
33 mesh = domain.create_component(
'Mesh',
'cf3.mesh.Mesh')
34 mesh_generator = domain.create_component(
"MeshGenerator",
"cf3.mesh.SimpleMeshGenerator")
35 mesh_generator.mesh = mesh.uri()
36 mesh_generator.nb_cells = [n,n]
37 mesh_generator.lengths = [1.,1.]
38 mesh_generator.offsets = [0.,0.]
39 mesh_generator.execute()
42 triangulator = domain.create_component(
'triangulator',
'cf3.mesh.MeshTriangulator')
43 triangulator.mesh = mesh
44 triangulator.execute()
47 poisson_solver.regions = [mesh.topology.uri()]
48 poisson_solver.LSS.SolutionStrategy.Parameters.linear_solver_type =
'Amesos'
49 poisson_solver.LSS.SolutionStrategy.print_settings =
False
52 bc = poisson_solver.BoundaryConditions.add_function_bc(region_name =
'left', variable_name =
'u')
53 bc.value = ['1 + x^2 + 2*y^2']
54 bc.regions = [mesh.topology.left.uri(), mesh.topology.right.uri(), mesh.topology.top.uri(), mesh.topology.bottom.uri()]
57 ic_f = solver.InitialConditions.create_initial_condition(builder_name =
'cf3.UFEM.InitialConditionConstant', field_tag =
'source_term')
59 ic_f.regions = [mesh.topology.uri()]
65 for [x,y], [u]
in zip(mesh.geometry.coordinates, mesh.geometry.poisson_solution):
66 if abs(1. + x**2 + 2.*y**2 - u) > 1e-8:
67 raise Exception(
'Solution is incorrect')
69 model.delete_component()
boost::python::object create_component(ComponentWrapper &self, const std::string &name, const std::string &builder_name)