8from actionsets.InitDG
import InitDofsDGTest7
9from actionsets.initCollocatedRandom
import InitCollocatedTest7
10from actionsets.DGCGCoupling
import Test7Coupling
12parser = argparse.ArgumentParser(description=
'Multigrid - Poisson solver')
13parser.add_argument(
"-j",
"--parallel-builds", dest=
"j", type=int, default=-1, help=
"Parallel builds" )
14parser.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" )
15parser.add_argument(
"-pd",
"--peano-dir", dest=
"peanodir", default=
"../../../../", help=
"Peano4 directory" )
16parser.add_argument(
"-v",
"--verbose", dest=
"verbose", action=
"store_true", default=
False, help=
"Verbose")
17parser.add_argument(
"-d",
"--dimensions", dest=
"dimensions", type=int, default=2, help=
"Dimensions")
18parser.add_argument(
"-p",
"--poly_degree", dest=
"poly_degree", type=int, default=2, help=
"Polynomial Degree")
19parser.add_argument(
"-meshsize",
"--meshsize", dest=
"meshsize", default=0.3, help=
"Mesh size")
20parser.add_argument(
"-omega_c",
"--omega_c", dest=
"omega_c", default=0.0, help=
"Mesh size")
21parser.add_argument(
"-omega_f",
"--omega_f", dest=
"omega_f", default=1.0, help=
"Mesh size")
22parser.add_argument(
"-m",
"--mode", dest=
"mode", choices=[
"release",
"stats",
"asserts",
"trace"], required=
True, help=
"Pick build type" )
23args = parser.parse_args()
25print(
'omega_c is set to 0 by default, see description of Test 7')
28project = mghype.matrixfree.api.Project( project_name =
"DGPointwise",
29 namespace = [
"tests",
"multigrid",
"matrixfree",
"Test7" ]
33matrices = mghype.api.matrixgenerators.GLMatrixFree(
41assembly_matrix, assembly_matrix_scaling = matrices.get_cell_system_matrix_for_laplacian()
42mass_matrix, mass_matrix_scaling = matrices.get_cell_identity_matrix()
43face_from_cell_projection, \
44face_from_cell_projection_scaling = matrices.get_face_from_cell_matrix()
45cell_from_face_projection, \
46cell_from_face_projection_scaling = matrices.get_cell_from_face_matrix()
47approximate_system_matrix, \
48approximate_system_matrix_scaling = matrices.get_A_tilde()
50solver = mghype.matrixfree.solvers.api.DiscontinuousGalerkinDiscretisationPointWiseRiemannSolver(
52 dimensions = args.dimensions,
53 poly_degree = args.poly_degree,
54 unknowns_per_cell_node = 1,
55 solutions_per_face_node = 2,
56 projections_per_face_node = 2,
57 min_h = args.meshsize,
58 max_h = args.meshsize,
59 assembly_matrix= assembly_matrix,
60 assembly_matrix_scaling = assembly_matrix_scaling,
61 mass_matrix = mass_matrix,
62 mass_matrix_scaling = mass_matrix_scaling,
63 face_from_cell_projection = face_from_cell_projection,
64 face_from_cell_projection_scaling = face_from_cell_projection_scaling,
65 cell_from_face_projection = cell_from_face_projection,
66 cell_from_face_projection_scaling = cell_from_face_projection_scaling,
67 riemann_matrix = matrices.get_face_face_riemann_problem_matrix(),
68 boundary_matrix = matrices.get_boundary_matrix(),
69 cell_relaxation = args.omega_c,
70 face_relaxation = args.omega_f,
71 approximate_system_matrix = approximate_system_matrix,
72 approximate_system_matrix_scaling = approximate_system_matrix_scaling,
73 solver_tolerance = 0.01,
74 custom_init_actionset=InitDofsDGTest7
77solver.add_to_face_data(
"randProjections", 2*2*(args.poly_degree+1)**(1))
78solver.add_to_face_data(
"randSolutions", 2*(args.poly_degree+1)**(1))
82 dimensions = args.dimensions,
86system_matrix, system_matrix_scaling = correction_equation_matrices.get_cell_system_matrix_for_laplacian()
87mass_matrix, maxx_matrix_scaling = correction_equation_matrices.get_cell_mass_matrix()
91correction_equation_solver = mghype.matrixfree.solvers.api.CollocatedDLinearDiscretisationWithPointJacobi(
92 name =
"CollocatedPoisson",
93 unknowns_per_vertex = 1,
94 dimensions = args.dimensions,
95 min_h = args.meshsize,
96 max_h = args.meshsize,
97 local_assembly_matrix = system_matrix,
98 local_assembly_matrix_scaling=system_matrix_scaling,
99 mass_matrix = mass_matrix,
100 mass_matrix_scaling = maxx_matrix_scaling,
101 solver_tolerance = 1e-12,
102 smoother_relaxation = 0.5,
103 custom_init_actionset=InitCollocatedTest7,
104 custom_plot_actionset=[(
"rand",
"getRand")]
108correction_equation_solver.add_to_vertex_data(
"rand", 1)
111 dim = args.dimensions,
113 fine_order = args.poly_degree
115prolongation_matrix = [intergrid_operators.prolongation()]
116prolongation_matrix_scaling = [0]
117restriction_matrix = [intergrid_operators.restriction()]
118restriction_matrix_scaling = [0]
119injection_matrix = [intergrid_operators.injection()]
120injection_matrix_scaling = [0]
122solver.preprocessing_action_set = Test7Coupling(
124 correction_equation_solver,
126 prolongation_matrix_scaling,
128 restriction_matrix_scaling,
130 injection_matrix_scaling,
132 smoothing_steps_DG = 1,
133 smoothing_steps_CG = 1e7
137project.add_solver(correction_equation_solver, auxiliary=
True)
138project.add_solver(solver)
144if args.mode==
"release":
145 build_mode = peano4.api.output.CompileMode.RELEASE
146if args.mode==
"stats":
147 build_mode = peano4.api.output.CompileMode.STATS
148if args.mode==
"asserts":
149 build_mode = peano4.api.output.CompileMode.ASSERTS
150if args.mode==
"trace":
151 build_mode = peano4.api.output.CompileMode.TRACE
155project.set_global_simulation_parameters(
156 dimensions = args.dimensions,
157 offset = [ 0.0
for _
in range(args.dimensions) ],
158 domain_size = [ cube_size
for _
in range(args.dimensions) ],
159 plot_after_each_mesh_sweep = args.plot_after_each_mesh_sweep,
162project.set_load_balancing(
"toolbox::loadbalancing::RecursiveSubdivision",
"new ::exahype2::LoadBalancingConfiguration()" )
163project.set_Peano4_installation( args.peanodir, build_mode )
165peano4_project = project.generate_Peano4_project(args.verbose)
167peano4_project.generate()
170os.system(
"mkdir visualisation" )
172os.system(
"make clean" )
174 os.system(
"make -j{}".format(args.j) )
176 os.system(
"make -j" )
Using normalised identity matrix instead of the mass matrix.