Coverage for pySDC/tutorial/step_5/A_multistep_multilevel_hierarchy.py: 100%
32 statements
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-16 14:51 +0000
« prev ^ index » next coverage.py v7.6.7, created at 2024-11-16 14:51 +0000
1from pathlib import Path
4from pySDC.implementations.controller_classes.controller_nonMPI import controller_nonMPI
5from pySDC.implementations.problem_classes.HeatEquation_ND_FD import heatNd_forced
6from pySDC.implementations.sweeper_classes.imex_1st_order import imex_1st_order
7from pySDC.implementations.transfer_classes.TransferMesh import mesh_to_mesh
10def main():
11 """
12 A simple test program to setup a full multi-step multi-level hierarchy
13 """
15 # initialize level parameters
16 level_params = {}
17 level_params['restol'] = 1e-10
18 level_params['dt'] = 0.5
20 # initialize sweeper parameters
21 sweeper_params = {}
22 sweeper_params['quad_type'] = 'RADAU-RIGHT'
23 sweeper_params['num_nodes'] = [3]
25 # initialize problem parameters
26 problem_params = {}
27 problem_params['nu'] = 0.1 # diffusion coefficient
28 problem_params['freq'] = 4 # frequency for the test value
29 problem_params['nvars'] = [31, 15, 7] # number of degrees of freedom for each level
30 problem_params['bc'] = 'dirichlet-zero' # boundary conditions
32 # initialize step parameters
33 step_params = {}
34 step_params['maxiter'] = 20
36 # initialize space transfer parameters
37 space_transfer_params = {}
38 space_transfer_params['rorder'] = 2
39 space_transfer_params['iorder'] = 6
41 # fill description dictionary for easy step instantiation
42 description = {}
43 description['problem_class'] = heatNd_forced # pass problem class
44 description['problem_params'] = problem_params # pass problem parameters
45 description['sweeper_class'] = imex_1st_order # pass sweeper (see part B)
46 description['sweeper_params'] = sweeper_params # pass sweeper parameters
47 description['level_params'] = level_params # pass level parameters
48 description['step_params'] = step_params # pass step parameters
49 description['space_transfer_class'] = mesh_to_mesh # pass spatial transfer class
50 description['space_transfer_params'] = space_transfer_params # pass parameters for spatial transfer
52 # instantiate controller
53 controller = controller_nonMPI(num_procs=10, controller_params={}, description=description)
55 # check number of levels
56 Path("data").mkdir(parents=True, exist_ok=True)
57 f = open('data/step_5_A_out.txt', 'w')
58 for i in range(len(controller.MS)):
59 out = "Process %2i has %2i levels" % (i, len(controller.MS[i].levels))
60 f.write(out + '\n')
61 print(out)
62 f.close()
64 assert all(len(S.levels) == 3 for S in controller.MS), "ERROR: not all steps have the same number of levels"
67if __name__ == "__main__":
68 main()