10from actionsets.test8
import InitDofsTest8
13 WARNING: implementation file (eg CollocatedPoisson.cpp) must be removed before
14 running this script if you want custom behaviour.
20parser = argparse.ArgumentParser(description=
'Multigrid - Poisson solver')
21parser.add_argument(
"-j",
"--parallel-builds", dest=
"j", type=int, default=-1, help=
"Parallel builds" )
22parser.add_argument(
"-pt",
"--plot-timestep", dest=
"plot_after_each_mesh_sweep", action=
"store_true", default=
False, help=
"Plot after each timestep. By default (False) we plot after initialisation and at the end" )
23parser.add_argument(
"-pd",
"--peano-dir", dest=
"peanodir", default=
"../../../../", help=
"Peano4 directory" )
24parser.add_argument(
"-v",
"--verbose", dest=
"verbose", action=
"store_true", default=
False, help=
"Verbose")
25parser.add_argument(
"-d",
"--dimensions", dest=
"dimensions", type=int, default=2, help=
"Dimensions")
26parser.add_argument(
"-meshsize",
"--meshsize", dest=
"meshsize", default=0.3, help=
"Mesh size")
27parser.add_argument(
"-m",
"--mode", dest=
"mode", choices=[
"release",
"stats",
"asserts",
"trace"], required=
True, help=
"Pick build type" )
28args = parser.parse_args()
30project = mghype.matrixfree.api.Project( project_name =
"CollocatedFEM",
31 namespace = [
"tests",
"multigrid",
"matrixfree",
"verifyRandom" ]
36 dimensions = args.dimensions,
40system_matrix, system_matrix_scaling = poisson_equation_matrices.get_cell_system_matrix_for_laplacian()
41mass_matrix, maxx_matrix_scaling = poisson_equation_matrices.get_cell_mass_matrix()
46custom_boundary_conditions=
"""
47 for (int i=0; i<value.size(); i++) {
52solver = mghype.matrixfree.solvers.api.CollocatedDLinearDiscretisationWithPointJacobi(
"CollocatedPoisson",
57 local_assembly_matrix = system_matrix,
58 local_assembly_matrix_scaling=system_matrix_scaling,
59 mass_matrix = mass_matrix,
60 mass_matrix_scaling = maxx_matrix_scaling,
61 solver_tolerance=1e-6,
62 custom_init_actionset=InitDofsTest8,
63 custom_plot_actionset=[(
"vu",
"getVu"), ((
"vb",
"getVb"))],
64 custom_boundary_conditions=custom_boundary_conditions
68solver.add_to_vertex_data(
"vu", 1)
69solver.add_to_vertex_data(
"vb", 1)
71project.add_solver(solver)
76if args.mode==
"release":
77 build_mode = peano4.api.output.CompileMode.RELEASE
79 build_mode = peano4.api.output.CompileMode.STATS
80if args.mode==
"asserts":
81 build_mode = peano4.api.output.CompileMode.ASSERTS
83 build_mode = peano4.api.output.CompileMode.TRACE
86project.set_global_simulation_parameters(
87 dimensions = args.dimensions,
88 offset = [ 0.0
for _
in range(args.dimensions) ],
89 domain_size = [ cube_size
for _
in range(args.dimensions) ],
90 plot_after_each_mesh_sweep = args.plot_after_each_mesh_sweep,
94project.set_load_balancing(
"toolbox::loadbalancing::RecursiveSubdivision",
"new ::exahype2::LoadBalancingConfiguration()" )
95project.set_Peano4_installation( args.peanodir, build_mode )
97peano4_project = project.generate_Peano4_project(args.verbose)
98peano4_project.generate()
100os.system(
"make clean" )
102 os.system(
"make -j{}".format(args.j) )
104 os.system(
"make -j" )
Simple matrix generator for continuous d-linear finite elements.