9Peano 4 multigrid solver using Continuous Galerkin
11@author 2022 Sean Baccas, Dmitry Nikolaenko, Tobias Weinzierl
15parser = argparse.ArgumentParser(description=
'Multigrid - Poisson solver')
16parser.add_argument(
"-j",
"--parallel-builds", dest=
"j", type=int, default=-1, help=
"Parallel builds" )
17parser.add_argument(
"-pt",
"--plot-sweep", 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" )
18parser.add_argument(
"-pd",
"--peano-dir", dest=
"peanodir", default=
"../../../../", help=
"Peano4 directory" )
19parser.add_argument(
"-v",
"--verbose", dest=
"verbose", action=
"store_true", default=
False, help=
"Verbose")
20parser.add_argument(
"-d",
"--dimensions", dest=
"dimensions", type=int, default=2, help=
"Dimensions")
21parser.add_argument(
"-c",
"--coarse-level", dest=
"coarsest_level", type=int, default=0, help=
"coarsest_level")
22parser.add_argument(
"-meshsize",
"--meshsize", dest=
"meshsize", default=0.3, help=
"Mesh size")
23parser.add_argument(
"-m",
"--mode", dest=
"mode", choices=[
"release",
"stats",
"asserts",
"trace"], required=
True, help=
"Pick build type" )
24args = parser.parse_args()
26project = mghype.matrixfree.api.Project( project_name =
"CollocatedMG",
27 namespace = [
"tests",
"multigrid",
"matrixfree",
"poisson" ]
32 dimensions = args.dimensions,
38 dimensions = args.dimensions,
44system_matrix, system_matrix_scaling = finest_level_matrices.get_cell_system_matrix_for_laplacian()
45mass_matrix, mass_matrix_scaling = finest_level_matrices.get_cell_mass_matrix()
47correction_matrix, correction_matrix_scaling = correction_equation_matrices.get_cell_mass_matrix()
49solver = mghype.matrixfree.solvers.api.CollocatedMGSingleThreaded(
"CollocatedMG",
54 local_assembly_matrix = system_matrix,
55 local_assembly_matrix_scaling=system_matrix_scaling,
56 mass_matrix = mass_matrix,
57 mass_matrix_scaling = mass_matrix_scaling,
58 correction_matrix = correction_matrix,
59 correction_matrix_scaling = correction_matrix_scaling,
60 solver_tolerance=0.01,
61 pre_smoothing_steps =5,
62 post_smoothing_steps=5,
63 restriction_matrix=intergridOperators.restriction(),
64 prolongation_matrix=intergridOperators.prolongation(),
66 coarsest_level=args.coarsest_level
69project.add_solver(solver)
74if args.mode==
"release":
75 build_mode = peano4.api.output.CompileMode.RELEASE
77 build_mode = peano4.api.output.CompileMode.STATS
78if args.mode==
"asserts":
79 build_mode = peano4.api.output.CompileMode.ASSERTS
81 build_mode = peano4.api.output.CompileMode.TRACE
84project.set_global_simulation_parameters(
85 dimensions = args.dimensions,
86 offset = [ 0.0
for _
in range(args.dimensions) ],
87 domain_size = [ cube_size
for _
in range(args.dimensions) ],
88 plot_after_each_mesh_sweep = args.plot_after_each_mesh_sweep,
93The first attempt to parallelise this code was a failure. So we comment out the load balancing.
97project.set_Peano4_installation( args.peanodir, build_mode )
99peano4_project = project.generate_Peano4_project(args.verbose)
100peano4_project.output.makefile.add_cpp_file(
"Scenario.cpp" )
101peano4_project.generate()
103os.system(
"make clean" )
105 os.system(
"make -j{}".format(args.j) )
107 os.system(
"make -j$(nproc --all)" )
Using normalised identity matrix instead of the mass matrix.
Simple matrix generator for continuous d-linear finite elements.
Class to produce restriction/prolongation matrices for multigrid tasks.