9Peano 4 multigrid solver using Discontinuous Galerkin
13parser = argparse.ArgumentParser(description=
'Multigrid - Poisson solver')
14parser.add_argument(
"-j",
"--parallel-builds", dest=
"j", type=int, default=-1, help=
"Parallel builds" )
15parser.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" )
16parser.add_argument(
"-fas",
"--use-fas", dest=
"fas", action=
"store_true", default=
False, help=
"Switch to FAS" )
17parser.add_argument(
"-pd",
"--peano-dir", dest=
"peanodir", default=
"../../../../", help=
"Peano4 directory" )
18parser.add_argument(
"-v",
"--verbose", dest=
"verbose", action=
"store_true", default=
False, help=
"Verbose")
19parser.add_argument(
"-d",
"--dimensions", dest=
"dimensions", type=int, default=2, help=
"Dimensions")
20parser.add_argument(
"-p",
"--poly_degree", dest=
"poly_degree", type=int, default=2, help=
"Polynomial Degree")
21parser.add_argument(
"-meshsize",
"--meshsize", dest=
"meshsize", default=0.3, help=
"Mesh size")
22parser.add_argument(
"-omega_c",
"--omega_c", dest=
"omega_c", default=0.5, help=
"Smoothing parameter for cells")
23parser.add_argument(
"-omega_f",
"--omega_f", dest=
"omega_f", default=1.0, help=
"Smoothing parameter for faces")
24parser.add_argument(
"-m",
"--mode", dest=
"mode", choices=[
"release",
"stats",
"asserts",
"trace"], required=
True, help=
"Pick build type" )
25args = parser.parse_args()
27project = mghype.matrixfree.api.Project( project_name =
"DGTwoGrid",
28 namespace = [
"tests",
"multigrid",
"matrixfree",
"poisson" ]
39assembly_matrix, assembly_matrix_scaling = matrices.get_cell_system_matrix_for_laplacian()
40mass_matrix, mass_matrix_scaling = matrices.get_cell_mass_matrix()
41face_from_cell_projection, \
42face_from_cell_projection_scaling = matrices.get_face_from_cell_matrix()
43cell_from_face_projection, \
44cell_from_face_projection_scaling = matrices.get_cell_from_face_matrix()
45approximate_system_matrix, \
46approximate_system_matrix_scaling = matrices.get_A_tilde()
49solver = mghype.matrixfree.solvers.api.DiscontinuousGalerkinDiscretisationPointWiseRiemannSolver(
51 dimensions = args.dimensions,
52 poly_degree = args.poly_degree,
53 unknowns_per_cell_node = 1,
54 solutions_per_face_node = 2,
55 projections_per_face_node = 2,
56 min_h = args.meshsize,
57 max_h = args.meshsize,
58 assembly_matrix= assembly_matrix,
59 assembly_matrix_scaling = assembly_matrix_scaling,
60 mass_matrix = mass_matrix,
61 mass_matrix_scaling = mass_matrix_scaling,
62 face_from_cell_projection = face_from_cell_projection,
63 face_from_cell_projection_scaling = face_from_cell_projection_scaling,
64 cell_from_face_projection = cell_from_face_projection,
65 cell_from_face_projection_scaling = cell_from_face_projection_scaling,
66 riemann_matrix = matrices.get_face_face_riemann_problem_matrix(),
67 boundary_matrix = matrices.get_boundary_matrix(),
68 cell_relaxation = args.omega_c,
69 face_relaxation = args.omega_f,
70 approximate_system_matrix = approximate_system_matrix,
71 approximate_system_matrix_scaling = approximate_system_matrix_scaling,
72 solver_tolerance = 1.0e-6,
73 integration_points = 0.5*(matrices.get_nodal_points_1d() + 1.0)
79 dimensions = args.dimensions,
86system_matrix, system_matrix_scaling = correction_equation_matrices.get_cell_system_matrix_for_laplacian()
87mass_matrix, mass_matrix_scaling = correction_equation_matrices.get_cell_mass_matrix()
89correction_matrix, correction_matrix_scaling = correction_equation_matrices.get_cell_mass_matrix()
93We use the identity matrix everywhere...
95correction_equation_solver = mghype.matrixfree.solvers.api.CollocatedMGSingleThreaded(
"CollocatedMG",
100 local_assembly_matrix = system_matrix,
101 local_assembly_matrix_scaling=system_matrix_scaling,
102 mass_matrix = mass_matrix,
103 mass_matrix_scaling = mass_matrix_scaling,
104 correction_matrix = correction_matrix,
105 correction_matrix_scaling = correction_matrix_scaling,
106 solver_tolerance=1e-12,
107 pre_smoothing_steps =6,
108 post_smoothing_steps=5,
109 restriction_matrix=intergridOperators.restriction(),
110 prolongation_matrix=intergridOperators.prolongation(),
116 dim = args.dimensions,
118 fine_order = args.poly_degree
120prolongation_matrix = [intergrid_operators.prolongation()]
121prolongation_matrix_scaling = [0]
122restriction_matrix = [intergrid_operators.restriction()]
123restriction_matrix_scaling = [0]
124injection_matrix = [intergrid_operators.injection()]
125injection_matrix_scaling = [0]
127solver.preprocessing_action_set = mghype.matrixfree.solvers.api.actionsets.MultiplicativeDGCGCoupling(
129 correction_equation_solver,
131 prolongation_matrix_scaling,
133 restriction_matrix_scaling,
135 injection_matrix_scaling,
142project.add_solver(correction_equation_solver, auxiliary=
True)
143project.add_solver(solver)
149if args.mode==
"release":
150 build_mode = peano4.api.output.CompileMode.RELEASE
151if args.mode==
"stats":
152 build_mode = peano4.api.output.CompileMode.STATS
153if args.mode==
"asserts":
154 build_mode = peano4.api.output.CompileMode.ASSERTS
155if args.mode==
"trace":
156 build_mode = peano4.api.output.CompileMode.TRACE
160project.set_global_simulation_parameters(
161 dimensions = args.dimensions,
162 offset = [ 0.0
for _
in range(args.dimensions) ],
163 domain_size = [ cube_size
for _
in range(args.dimensions) ],
164 plot_after_each_mesh_sweep = args.plot_after_each_mesh_sweep,
165 max_iterations = 2000
168project.set_Peano4_installation( args.peanodir, build_mode )
170peano4_project = project.generate_Peano4_project(args.verbose)
171peano4_project.output.makefile.add_cpp_file(
"Scenario.cpp" )
172peano4_project.generate()
174os.system(
"make clean" )
176 os.system(
"make -j{}".format(args.j) )
178 os.system(
"make -j" )
Using normalised identity matrix instead of the mass matrix.
Class to produce restriction/prolongation matrices for multigrid tasks.