9 domain = model.create_domain()
11 physics = model.create_physics(
'cf3.physics.DynamicModel')
13 solver = model.create_solver(
'cf3.UFEM.Solver')
15 poisson_solver = solver.add_direct_solver(
'cf3.UFEM.demo.PoissonProto')
18 mesh = domain.create_component(
'Mesh',
'cf3.mesh.Mesh')
19 mesh_generator = domain.create_component(
"MeshGenerator",
"cf3.mesh.SimpleMeshGenerator")
20 mesh_generator.mesh = mesh.uri()
21 mesh_generator.nb_cells = [6,4]
22 mesh_generator.lengths = [1.,1.]
23 mesh_generator.offsets = [0.,0.]
24 mesh_generator.execute()
27 triangulator = domain.create_component(
'triangulator',
'cf3.mesh.MeshTriangulator')
28 triangulator.mesh = mesh
29 triangulator.execute()
32 poisson_solver.regions = [mesh.topology.uri()]
36 poisson_solver.LSS.SolutionStrategy.Parameters.linear_solver_type =
'Amesos'
37 poisson_solver.LSS.SolutionStrategy.print_settings =
False
40 bc = poisson_solver.BoundaryConditions.add_function_bc(region_name =
'left', variable_name =
'u')
41 bc.value = ['1 + x^2 + 2*y^2']
42 bc.regions = [mesh.topology.left.uri(), mesh.topology.right.uri(), mesh.topology.top.uri(), mesh.topology.bottom.uri()]
45 ic_f = solver.InitialConditions.create_initial_condition(builder_name =
'cf3.UFEM.InitialConditionConstant', field_tag =
'source_term')
47 ic_f.regions = [mesh.topology.uri()]
51 model.print_timing_tree()
54 domain.write_mesh(cf.URI(
'atest-ufem-demo-poisson.pvtu'))
57 for [x,y], [u]
in zip(mesh.geometry.coordinates, mesh.geometry.poisson_solution):
58 if abs(1. + x**2 + 2.*y**2 - u) > 1e-12:
59 raise Exception(
'Solution is incorrect')
boost::python::object create_component(ComponentWrapper &self, const std::string &name, const std::string &builder_name)