7from actionsets.InitDG
import InitDofsDGTest4
8from actionsets.initCollocatedRandom
import InitCollocatedTest4
9from actionsets.DGCGCoupling
import Test4Coupling
11parser = argparse.ArgumentParser(description=
'Multigrid - Poisson solver')
12parser.add_argument(
"-j",
"--parallel-builds", dest=
"j", type=int, default=-1, help=
"Parallel builds" )
13parser.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" )
14parser.add_argument(
"-pd",
"--peano-dir", dest=
"peanodir", default=
"../../../../", help=
"Peano4 directory" )
15parser.add_argument(
"-v",
"--verbose", dest=
"verbose", action=
"store_true", default=
False, help=
"Verbose")
16parser.add_argument(
"-d",
"--dimensions", dest=
"dimensions", type=int, default=2, help=
"Dimensions")
17parser.add_argument(
"-p",
"--poly_degree", dest=
"poly_degree", type=int, default=2, help=
"Polynomial Degree")
18parser.add_argument(
"-meshsize",
"--meshsize", dest=
"meshsize", default=0.3, help=
"Mesh size")
19parser.add_argument(
"-omega_c",
"--omega_c", dest=
"omega_c", default=0.5, help=
"Mesh size")
20parser.add_argument(
"-omega_f",
"--omega_f", dest=
"omega_f", default=1.0, help=
"Mesh size")
21parser.add_argument(
"-m",
"--mode", dest=
"mode", choices=[
"release",
"stats",
"asserts",
"trace"], required=
True, help=
"Pick build type" )
22args = parser.parse_args()
24project = mghype.matrixfree.api.Project( project_name =
"DGPointwise",
25 namespace = [
"tests",
"multigrid",
"matrixfree",
"test4" ]
29matrices = mghype.api.matrixgenerators.GLMatrixFree(
37assembly_matrix, assembly_matrix_scaling = matrices.get_cell_system_matrix_for_laplacian()
38mass_matrix, mass_matrix_scaling = matrices.get_cell_mass_matrix()
39face_from_cell_projection, \
40face_from_cell_projection_scaling = matrices.get_face_from_cell_matrix()
41cell_from_face_projection, \
42cell_from_face_projection_scaling = matrices.get_cell_from_face_matrix()
43approximate_system_matrix, \
44approximate_system_matrix_scaling = matrices.get_A_tilde()
47dg_solver = mghype.matrixfree.solvers.api.DiscontinuousGalerkinDiscretisationPointWiseRiemannSolver(
49 dimensions = args.dimensions,
50 poly_degree = args.poly_degree,
51 unknowns_per_cell_node = 1,
52 solutions_per_face_node = 2,
53 projections_per_face_node = 2,
54 min_h = args.meshsize,
55 max_h = args.meshsize,
56 assembly_matrix= assembly_matrix,
57 assembly_matrix_scaling = assembly_matrix_scaling,
58 mass_matrix = mass_matrix,
59 mass_matrix_scaling = mass_matrix_scaling,
60 face_from_cell_projection = face_from_cell_projection,
61 face_from_cell_projection_scaling = face_from_cell_projection_scaling,
62 cell_from_face_projection = cell_from_face_projection,
63 cell_from_face_projection_scaling = cell_from_face_projection_scaling,
64 riemann_matrix = matrices.get_face_face_riemann_problem_matrix(),
65 boundary_matrix = matrices.get_boundary_matrix(),
66 cell_relaxation = args.omega_c,
67 face_relaxation = args.omega_f,
68 approximate_system_matrix = approximate_system_matrix,
69 approximate_system_matrix_scaling = approximate_system_matrix_scaling,
70 solver_tolerance = 0.01,
71 custom_plot_actionset=[(
"vector1",
"getVector1")],
72 custom_init_actionset=InitDofsDGTest4
75dg_solver.add_to_cell_data(
"vector1", (args.poly_degree + 1) ** args.dimensions )
80 dimensions = args.dimensions,
84system_matrix, system_matrix_scaling = correction_equation_matrices.get_cell_system_matrix_for_laplacian()
85mass_matrix, maxx_matrix_scaling = correction_equation_matrices.get_cell_mass_matrix()
88collocated_solver = mghype.matrixfree.solvers.api.CollocatedDLinearDiscretisationWithPointJacobi(
90 unknowns_per_vertex = 1,
91 dimensions = args.dimensions,
92 min_h = args.meshsize,
93 max_h = args.meshsize,
94 local_assembly_matrix = system_matrix,
95 local_assembly_matrix_scaling=system_matrix_scaling,
96 mass_matrix = mass_matrix,
97 mass_matrix_scaling = maxx_matrix_scaling,
98 solver_tolerance = 1e-12,
99 smoother_relaxation = 0.5,
100 custom_plot_actionset=[(
"vector2",
"getVector2")],
101 custom_init_actionset=InitCollocatedTest4
104collocated_solver.add_to_vertex_data(
"vector2", 1 )
108 dim = args.dimensions,
110 fine_order = args.poly_degree
112prolongation_matrix = [intergrid_operators.prolongation()]
113prolongation_matrix_scaling = [0]
114restriction_matrix = [intergrid_operators.restriction()]
115restriction_matrix_scaling = [0]
116injection_matrix = [intergrid_operators.injection()]
117injection_matrix_scaling = [0]
119dg_solver.preprocessing_action_set = Test4Coupling(
123 prolongation_matrix_scaling,
125 restriction_matrix_scaling,
127 injection_matrix_scaling
130project.add_solver( collocated_solver, auxiliary=
True )
131project.add_solver( dg_solver )
136if args.mode==
"release":
137 build_mode = peano4.api.output.CompileMode.RELEASE
138if args.mode==
"stats":
139 build_mode = peano4.api.output.CompileMode.STATS
140if args.mode==
"asserts":
141 build_mode = peano4.api.output.CompileMode.ASSERTS
142if args.mode==
"trace":
143 build_mode = peano4.api.output.CompileMode.TRACE
147project.set_global_simulation_parameters(
148 dimensions = args.dimensions,
149 offset = [ 0.0
for _
in range(args.dimensions) ],
150 domain_size = [ cube_size
for _
in range(args.dimensions) ],
151 plot_after_each_mesh_sweep = args.plot_after_each_mesh_sweep,
155project.set_load_balancing(
"toolbox::loadbalancing::RecursiveSubdivision",
"new ::exahype2::LoadBalancingConfiguration()" )
156project.set_Peano4_installation( args.peanodir, build_mode )
158peano4_project = project.generate_Peano4_project(args.verbose)
160peano4_project.generate()
162os.system(
"mkdir visualisation" )
164os.system(
"make clean" )
166 os.system(
"make -j{}".format(args.j) )
168 os.system(
"make -j" )
Using normalised identity matrix instead of the mass matrix.