22
33from pySDC .implementations .problem_classes .HeatEquation_1D_FD import heat1d
44from pySDC .implementations .problem_classes .AdvectionEquation_1D_FD import advection1d
5+ from pySDC .implementations .problem_classes .TestEquation_0D import testequation0d
56from pySDC .implementations .datatype_classes .mesh import mesh
7+ from pySDC .implementations .datatype_classes .complex_mesh import mesh as cmesh
68from pySDC .implementations .collocation_classes .gauss_radau_right import CollGaussRadau_Right
79from pySDC .implementations .sweeper_classes .generic_implicit import generic_implicit
810from pySDC .implementations .transfer_classes .TransferMesh import mesh_to_mesh
11+ from pySDC .implementations .transfer_classes .TransferMesh_NoCoarse import mesh_to_mesh as mesh_to_mesh_nocoarse
912from pySDC .projects .matrixPFASST .allinclusive_matrix_nonMPI import allinclusive_matrix_nonMPI
1013
1114from pySDC .helpers .stats_helper import filter_stats , sort_stats
@@ -28,7 +31,7 @@ def diffusion_setup(par=0.0):
2831 sweeper_params = dict ()
2932 sweeper_params ['collocation_class' ] = CollGaussRadau_Right
3033 sweeper_params ['num_nodes' ] = 3
31- sweeper_params ['QI' ] = 'LU' # For the IMEX sweeper, the LU-trick can be activated for the implicit part
34+ sweeper_params ['QI' ] = 'LU'
3235 sweeper_params ['spread' ] = True
3336
3437 # initialize problem parameters
@@ -84,7 +87,7 @@ def advection_setup(par=0.0):
8487 sweeper_params = dict ()
8588 sweeper_params ['collocation_class' ] = CollGaussRadau_Right
8689 sweeper_params ['num_nodes' ] = [3 ]
87- sweeper_params ['QI' ] = ['LU' ] # For the IMEX sweeper, the LU-trick can be activated for the implicit part
90+ sweeper_params ['QI' ] = ['LU' ]
8891 sweeper_params ['spread' ] = True
8992
9093 # initialize problem parameters
@@ -126,6 +129,73 @@ def advection_setup(par=0.0):
126129 return description , controller_params
127130
128131
132+ def testequation_setup ():
133+ """
134+ Setup routine for the test equation
135+
136+ Args:
137+ par (float): parameter for controlling stiffness
138+ """
139+ # initialize level parameters
140+ level_params = dict ()
141+ level_params ['restol' ] = 1E-08
142+ level_params ['dt' ] = 0.25
143+ level_params ['nsweeps' ] = [3 ]
144+
145+ # initialize sweeper parameters
146+ sweeper_params = dict ()
147+ sweeper_params ['collocation_class' ] = CollGaussRadau_Right
148+ sweeper_params ['num_nodes' ] = [3 ]
149+ sweeper_params ['QI' ] = 'LU'
150+ sweeper_params ['spread' ] = True
151+
152+ # initialize problem parameters
153+ problem_params = dict ()
154+ problem_params ['u0' ] = 1.0 # initial value (for all instances)
155+ # use single values like this...
156+ problem_params ['lambdas' ] = [[- 1.0 ]]
157+ # .. or a list of values like this ...
158+ problem_params ['lambdas' ] = [[- 1.0 , - 2.0 , 1j , - 1j ]]
159+ # .. or a whole block of values like this
160+ ilim_left = - 11
161+ ilim_right = 0
162+ rlim_left = 0
163+ rlim_right = 11
164+ ilam = 1j * np .logspace (ilim_left , ilim_right , 11 )
165+ rlam = - 1 * np .logspace (rlim_left , rlim_right , 11 )
166+ lambdas = []
167+ for rl in rlam :
168+ for il in ilam :
169+ lambdas .append (rl + il )
170+ problem_params ['lambdas' ] = [lambdas ]
171+ # note: PFASST will do all of those at once, but without interaction (realized via diagonal matrix).
172+ # The propagation matrix will be diagonal too, corresponding to the respective lambda value.
173+
174+ # initialize step parameters
175+ step_params = dict ()
176+ step_params ['maxiter' ] = 50
177+
178+ # initialize controller parameters
179+ controller_params = dict ()
180+ controller_params ['logger_level' ] = 30
181+ controller_params ['predict' ] = False
182+
183+ # fill description dictionary for easy step instantiation
184+ description = dict ()
185+ description ['problem_class' ] = testequation0d # pass problem class
186+ description ['problem_params' ] = problem_params # pass problem parameters
187+ description ['dtype_u' ] = cmesh # pass data type for u
188+ description ['dtype_f' ] = cmesh # pass data type for f
189+ description ['sweeper_class' ] = generic_implicit # pass sweeper
190+ description ['sweeper_params' ] = sweeper_params # pass sweeper parameters
191+ description ['level_params' ] = level_params # pass level parameters
192+ description ['step_params' ] = step_params # pass step parameters
193+ description ['space_transfer_class' ] = mesh_to_mesh_nocoarse # pass spatial transfer class
194+ description ['space_transfer_params' ] = dict () # pass paramters for spatial transfer
195+
196+ return description , controller_params
197+
198+
129199def compare_controllers (type = None , par = 0.0 , f = None ):
130200 """
131201 A simple test program to compare PFASST runs with matrix-based and matrix-free controllers
@@ -144,6 +214,8 @@ def compare_controllers(type=None, par=0.0, f=None):
144214 description , controller_params = diffusion_setup (par )
145215 elif type == 'advection' :
146216 description , controller_params = advection_setup (par )
217+ elif type == 'testequation' :
218+ description , controller_params = testequation_setup ()
147219 else :
148220 raise ValueError ('No valis setup type provided, aborting..' )
149221
@@ -196,12 +268,10 @@ def compare_controllers(type=None, par=0.0, f=None):
196268
197269def main ():
198270
199- par_list = [1E-02 , 1.0 , 1E+02 ]
200-
201271 f = open ('comparison_matrix_vs_propagator_detail.txt' , 'a' )
202- for par in par_list :
203- compare_controllers (type = 'diffusion ' , par = par , f = f )
204- compare_controllers (type = 'advection ' , par = par , f = f )
272+ # compare_controllers(type='diffusion', par=1E-00, f=f)
273+ # compare_controllers(type='advection ', par=1E-00 , f=f)
274+ compare_controllers (type = 'testequation ' , par = 0.0 , f = f )
205275 f .close ()
206276
207277
0 commit comments