2The same as Test 3, but for DG.
3This tests checks that the DG solver converges to u_{random} for the RHS constructed as b = A_DG * u_{random}
4with some random u_{random}.
16Peano 4 multigrid solver using Discontinuous Galerkin
18 We set all the face values to 0.
20 As a reminder, we then:
21 1. Set the face solution (take the average of 0 and 0 to make 0)
22 2. Project the face solution (into the cell), update the residual and
23 set the cell solution. Note that the residual will be 0 at this point,
24 so we probably don't see any changes to the cell solution itself
25 3. Project new solution onto faces
26 4. Set the residual to mB - AccUc...
34from actionsets.InitDG
import InitDofsDGTest6, InitDofsIntermediatePhaseTest6
38parser = argparse.ArgumentParser(description=
'Multigrid - Poisson solver')
39parser.add_argument(
"-j",
"--parallel-builds", dest=
"j", type=int, default=-1, help=
"Parallel builds" )
40parser.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" )
41parser.add_argument(
"-pd",
"--peano-dir", dest=
"peanodir", default=
"../../../../", help=
"Peano4 directory" )
42parser.add_argument(
"-v",
"--verbose", dest=
"verbose", action=
"store_true", default=
False, help=
"Verbose")
43parser.add_argument(
"-d",
"--dimensions", dest=
"dimensions", type=int, default=2, help=
"Dimensions")
44parser.add_argument(
"-p",
"--poly_degree", dest=
"poly_degree", type=int, default=1, help=
"Polynomial Degree")
45parser.add_argument(
"-meshsize",
"--meshsize", dest=
"meshsize", default=0.3, help=
"Mesh size")
46parser.add_argument(
"-omega_c",
"--omega_c", dest=
"omega_c", default=0.5, help=
"Mesh size")
47parser.add_argument(
"-omega_f",
"--omega_f", dest=
"omega_f", default=1.0, help=
"Mesh size")
48parser.add_argument(
"-m",
"--mode", dest=
"mode", choices=[
"release",
"stats",
"asserts",
"trace"], required=
True, help=
"Pick build type" )
49args = parser.parse_args()
52project = mghype.matrixfree.api.Project( project_name =
"DGPointwise",
53 namespace = [
"tests",
"multigrid",
"matrixfree",
"test6" ]
57matrices = mghype.api.matrixgenerators.GLMatrixFree(
65assembly_matrix, assembly_matrix_scaling = matrices.get_cell_system_matrix_for_laplacian()
66mass_matrix, mass_matrix_scaling = matrices.get_cell_identity_matrix()
67face_from_cell_projection, \
68face_from_cell_projection_scaling = matrices.get_face_from_cell_matrix()
69cell_from_face_projection, \
70cell_from_face_projection_scaling = matrices.get_cell_from_face_matrix()
71approximate_system_matrix, \
72approximate_system_matrix_scaling = matrices.get_A_tilde()
74solver = mghype.matrixfree.solvers.api.DiscontinuousGalerkinDiscretisationPointWiseRiemannSolver(
76 dimensions = args.dimensions,
77 poly_degree = args.poly_degree,
78 unknowns_per_cell_node = 1,
79 solutions_per_face_node = 2,
80 projections_per_face_node = 2,
81 min_h = args.meshsize,
82 max_h = args.meshsize,
83 assembly_matrix= assembly_matrix,
84 assembly_matrix_scaling = assembly_matrix_scaling,
85 mass_matrix = mass_matrix,
86 mass_matrix_scaling = mass_matrix_scaling,
87 face_from_cell_projection = face_from_cell_projection,
88 face_from_cell_projection_scaling = face_from_cell_projection_scaling,
89 cell_from_face_projection = cell_from_face_projection,
90 cell_from_face_projection_scaling = cell_from_face_projection_scaling,
91 riemann_matrix = matrices.get_face_face_riemann_problem_matrix(),
92 boundary_matrix = matrices.get_boundary_matrix(),
93 cell_relaxation = args.omega_c,
94 face_relaxation = args.omega_f,
95 approximate_system_matrix = approximate_system_matrix,
96 approximate_system_matrix_scaling = approximate_system_matrix_scaling,
97 solver_tolerance = 1e-6,
98 custom_init_actionset=InitDofsDGTest6,
99 custom_plot_actionset=[(
"rand",
"getRand")]
103nodes_per_cell = (args.poly_degree + 1) ** args.dimensions
104solver.add_to_cell_data(
"rand", nodes_per_cell)
105solver.add_to_face_data(
"randProjection", 2*2*(args.poly_degree+1)**(1))
106solver.add_to_face_data(
"randSolution", 2*(args.poly_degree+1)**(1))
108solver.preprocessing_action_set = InitDofsIntermediatePhaseTest6(solver)
112project.add_solver(solver)
117if args.mode==
"release":
118 build_mode = peano4.api.output.CompileMode.RELEASE
119if args.mode==
"stats":
120 build_mode = peano4.api.output.CompileMode.STATS
121if args.mode==
"asserts":
122 build_mode = peano4.api.output.CompileMode.ASSERTS
123if args.mode==
"trace":
124 build_mode = peano4.api.output.CompileMode.TRACE
128project.set_global_simulation_parameters(
129 dimensions = args.dimensions,
130 offset = [ 0.0
for _
in range(args.dimensions) ],
131 domain_size = [ cube_size
for _
in range(args.dimensions) ],
132 plot_after_each_mesh_sweep = args.plot_after_each_mesh_sweep,
133 max_iterations = 1000
136project.set_load_balancing(
"toolbox::loadbalancing::RecursiveSubdivision",
"new ::exahype2::LoadBalancingConfiguration()" )
137project.set_Peano4_installation( args.peanodir, build_mode )
139peano4_project = project.generate_Peano4_project(args.verbose)
141peano4_project.generate()
143os.system(
"mkdir visualisation" )
145os.system(
"make clean" )
147 os.system(
"make -j{}".format(args.j) )
149 os.system(
"make -j" )