Skip to content

Commit c9deddf

Browse files
committed
fixes for TOMS JURECA example
1 parent 31786d0 commit c9deddf

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

pySDC/implementations/problem_classes/HeatEquation_2D_PETSc_forced.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,16 @@ def __init__(self, problem_params, dtype_u=petsc_data, dtype_f=rhs_imex_petsc_da
6868
# setup solver
6969
self.ksp = PETSc.KSP()
7070
self.ksp.create(comm=self.params.comm)
71-
self.ksp.setType('cg')
71+
self.ksp.setType('gmres')
7272
pc = self.ksp.getPC()
7373
pc.setType('none')
74-
self.ksp.setInitialGuessNonzero(True)
74+
# self.ksp.setInitialGuessNonzero(True)
7575
self.ksp.setFromOptions()
7676
self.ksp.setTolerances(rtol=self.params.sol_tol, atol=self.params.sol_tol, max_it=self.params.sol_maxiter)
7777

78+
self.ksp_ncalls = 0
79+
self.ksp_itercount = 0
80+
7881
def __get_A(self):
7982
"""
8083
Helper function to assemble PETSc matrix A
@@ -188,6 +191,8 @@ def solve_system(self, rhs, factor, u0, t):
188191
me = self.dtype_u(u0)
189192
self.ksp.setOperators(self.Id - factor * self.A)
190193
self.ksp.solve(rhs.values, me.values)
194+
self.ksp_ncalls += 1
195+
self.ksp_itercount += int(self.ksp.getIterationNumber())
191196

192197
return me
193198

pySDC/projects/TOMS/pySDC_with_PETSc.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def main():
4747
level_params = dict()
4848
level_params['restol'] = 1E-08
4949
level_params['dt'] = 0.125
50-
level_params['nsweeps'] = [1]
50+
level_params['nsweeps'] = [3, 1]
5151

5252
# initialize sweeper parameters
5353
sweeper_params = dict()
@@ -62,7 +62,7 @@ def main():
6262
problem_params['freq'] = 2 # frequency for the test value
6363
problem_params['nvars'] = [(129, 129), (65, 65)] # number of degrees of freedom for each level
6464
problem_params['comm'] = space_comm # pass space-communicator to problem class
65-
problem_params['sol_tol'] = 1E-12 # set tolerance to PETSc' linear solver
65+
problem_params['sol_tol'] = 1E-10 # set tolerance to PETSc' linear solver
6666

6767
# initialize step parameters
6868
step_params = dict()
@@ -137,6 +137,9 @@ def main():
137137
out = ' Std and var for number of iterations: %4.2f -- %4.2f' % (float(np.std(niters)), float(np.var(niters)))
138138
print(out)
139139

140+
print(' Iteration count linear solver: %i' % P.ksp_itercount)
141+
print(' Mean Iteration count per call: %4.2f' % (P.ksp_itercount / max(P.ksp_ncalls, 1)))
142+
140143
timing = sort_stats(filter_stats(stats, type='timing_run'), sortby='time')
141144

142145
out = 'Time to solution: %6.4f sec.' % timing[0][1]

pySDC/projects/TOMS/visualize_pySDC_with_PETSc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def visualize_matrix(result=None):
9898
plt_helper.newfig(textwidth=120, scale=1.5)
9999
cmap = plt_helper.plt.get_cmap('RdYlGn_r')
100100
new_cmap = truncate_colormap(cmap, 0.1, 0.9)
101-
plt_helper.plt.imshow(mat, origin='lower', norm=colors.LogNorm(vmin=tmin, vmax=tmax), cmap=new_cmap, aspect='auto')
101+
plt_helper.plt.imshow(mat.T, origin='lower', norm=colors.LogNorm(vmin=tmin, vmax=tmax), cmap=new_cmap, aspect='auto')
102102

103103
for key, item in result.items():
104104
timing = "{:3.1f}".format(item)

0 commit comments

Comments
 (0)