2This test checks that the DG solver leaves the input invariant if the RHS is constructed as
3b = A_DG * u_{random} and u = u_{random} is the initial guess.
15Peano 4 multigrid solver using Discontinuous Galerkin
17@Alex - in the init action set we set each cell value to
18 be a random value. Then, we gather each of these (4 per cell),
19 apply the cell-cell matrix, and write each of these values into
20 the rhs. I also set the max_iterations to 10
22 We set all the face values to 0.
24 As a reminder, we then:
25 1. Set the face solution (take the average of 0 and 0 to make 0)
26 2. Project the face solution (into the cell), update the residual and
27 set the cell solution. Note that the residual will be 0 at this point,
28 so we probably don't see any changes to the cell solution itself
29 3. Project new solution onto faces
30 4. Set the residual to mB - AccUc...
38from actionsets.InitDG
import InitDofsDGTest1, InitDofsIntermediatePhaseTest1
42parser = argparse.ArgumentParser(description=
'Multigrid - Poisson solver')
43parser.add_argument(
"-j",
"--parallel-builds", dest=
"j", type=int, default=-1, help=
"Parallel builds" )
44parser.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" )
45parser.add_argument(
"-pd",
"--peano-dir", dest=
"peanodir", default=
"../../../../", help=
"Peano4 directory" )
46parser.add_argument(
"-v",
"--verbose", dest=
"verbose", action=
"store_true", default=
False, help=
"Verbose")
47parser.add_argument(
"-d",
"--dimensions", dest=
"dimensions", type=int, default=2, help=
"Dimensions")
48parser.add_argument(
"-p",
"--poly_degree", dest=
"poly_degree", type=int, default=1, help=
"Polynomial Degree")
49parser.add_argument(
"-meshsize",
"--meshsize", dest=
"meshsize", default=0.3, help=
"Mesh size")
50parser.add_argument(
"-omega_c",
"--omega_c", dest=
"omega_c", default=0.5, help=
"Mesh size")
51parser.add_argument(
"-omega_f",
"--omega_f", dest=
"omega_f", default=1.0, help=
"Mesh size")
52parser.add_argument(
"-m",
"--mode", dest=
"mode", choices=[
"release",
"stats",
"asserts",
"trace"], required=
True, help=
"Pick build type" )
53args = parser.parse_args()
56project = mghype.matrixfree.api.Project( project_name =
"DGPointwise",
57 namespace = [
"tests",
"multigrid",
"matrixfree",
"poisson" ]
61matrices = mghype.api.matrixgenerators.GLMatrixFree(
69assembly_matrix, assembly_matrix_scaling = matrices.get_cell_system_matrix_for_laplacian()
70mass_matrix, mass_matrix_scaling = matrices.get_cell_identity_matrix()
71face_from_cell_projection, \
72face_from_cell_projection_scaling = matrices.get_face_from_cell_matrix()
73cell_from_face_projection, \
74cell_from_face_projection_scaling = matrices.get_cell_from_face_matrix()
75approximate_system_matrix, \
76approximate_system_matrix_scaling = matrices.get_A_tilde()
78solver = mghype.matrixfree.solvers.api.DiscontinuousGalerkinDiscretisationPointWiseRiemannSolver(
80 dimensions = args.dimensions,
81 poly_degree = args.poly_degree,
82 unknowns_per_cell_node = 1,
83 solutions_per_face_node = 2,
84 projections_per_face_node = 2,
85 min_h = args.meshsize,
86 max_h = args.meshsize,
87 assembly_matrix= assembly_matrix,
88 assembly_matrix_scaling = assembly_matrix_scaling,
89 mass_matrix = mass_matrix,
90 mass_matrix_scaling = mass_matrix_scaling,
91 face_from_cell_projection = face_from_cell_projection,
92 face_from_cell_projection_scaling = face_from_cell_projection_scaling,
93 cell_from_face_projection = cell_from_face_projection,
94 cell_from_face_projection_scaling = cell_from_face_projection_scaling,
95 riemann_matrix = matrices.get_face_face_riemann_problem_matrix(),
96 boundary_matrix = matrices.get_boundary_matrix(),
97 cell_relaxation = args.omega_c,
98 face_relaxation = args.omega_f,
99 approximate_system_matrix = approximate_system_matrix,
100 approximate_system_matrix_scaling = approximate_system_matrix_scaling,
101 solver_tolerance = 1e-6,
102 custom_init_actionset=InitDofsDGTest1,
103 custom_plot_actionset=[(
"rand",
"getRand")]
107nodes_per_cell = (args.poly_degree + 1) ** args.dimensions
108solver.add_to_cell_data(
"rand", nodes_per_cell)
110solver.preprocessing_action_set = InitDofsIntermediatePhaseTest1(solver)
114project.add_solver(solver)
119if args.mode==
"release":
120 build_mode = peano4.api.output.CompileMode.RELEASE
121if args.mode==
"stats":
122 build_mode = peano4.api.output.CompileMode.STATS
123if args.mode==
"asserts":
124 build_mode = peano4.api.output.CompileMode.ASSERTS
125if args.mode==
"trace":
126 build_mode = peano4.api.output.CompileMode.TRACE
130project.set_global_simulation_parameters(
131 dimensions = args.dimensions,
132 offset = [ 0.0
for _
in range(args.dimensions) ],
133 domain_size = [ cube_size
for _
in range(args.dimensions) ],
134 plot_after_each_mesh_sweep = args.plot_after_each_mesh_sweep,
138project.set_load_balancing(
"toolbox::loadbalancing::RecursiveSubdivision",
"new ::exahype2::LoadBalancingConfiguration()" )
139project.set_Peano4_installation( args.peanodir, build_mode )
141peano4_project = project.generate_Peano4_project(args.verbose)
143peano4_project.generate()
145os.system(
"mkdir visualisation" )
147os.system(
"make clean" )
149 os.system(
"make -j{}".format(args.j) )
151 os.system(
"make -j" )