Skip to content

Commit 549d74f

Browse files
committed
better output, bugfixes for controllers
1 parent 3fa7bb0 commit 549d74f

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

pySDC/implementations/controller_classes/controller_MPI.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ def run(self, u0, t0, Tend):
7777
all_time = [t0 + sum(all_dt[0:i]) for i in range(num_procs)]
7878
time = all_time[rank]
7979
all_active = all_time < Tend - 10 * np.finfo(float).eps
80+
81+
if not any(all_active):
82+
raise ControllerError('Nothing to do, check t0, dt and Tend')
83+
8084
active = all_active[rank]
8185
if not all(all_active):
8286
comm_active = self.comm.Split(active)

pySDC/implementations/controller_classes/controller_nonMPI.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ def run(self, u0, t0, Tend):
101101
# determine which steps are still active (time < Tend)
102102
active = [time[p] < Tend - 10 * np.finfo(float).eps for p in slots]
103103

104+
if not any(active):
105+
raise ControllerError('Nothing to do, check t0, dt and Tend.')
106+
104107
# compress slots according to active steps, i.e. remove all steps which have times above Tend
105108
active_slots = list(itertools.compress(slots, active))
106109

pySDC/playgrounds/parallel/AllenCahn_contracting_circle_FFT.py

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def run_SDC_variant(variant=None):
9797
raise NotImplemented('Wrong variant specified, got %s' % variant)
9898

9999
# setup parameters "in time"
100-
t0 = 0
100+
t0 = 0.0
101101
Tend = 0.032
102102

103103
# set MPI communicator
@@ -141,29 +141,20 @@ def run_SDC_variant(variant=None):
141141

142142
rank = comm.Get_rank()
143143

144-
if rank == 0:
145-
146-
# filter statistics by variant (number of iterations)
147-
filtered_stats = filter_stats(stats, type='niter')
144+
# filter statistics by variant (number of iterations)
145+
filtered_stats = filter_stats(stats, type='niter')
148146

149-
# convert filtered statistics to list of iterations count, sorted by process
150-
iter_counts = sort_stats(filtered_stats, sortby='time')
147+
# convert filtered statistics to list of iterations count, sorted by process
148+
iter_counts = sort_stats(filtered_stats, sortby='time')
151149

152-
# compute and print statistics
153-
niters = np.array([item[1] for item in iter_counts])
154-
out = ' Mean number of iterations: %4.2f' % np.mean(niters)
155-
print(out)
156-
out = ' Range of values for number of iterations: %2i ' % np.ptp(niters)
157-
print(out)
158-
out = ' Position of max/min number of iterations: %2i -- %2i' % \
159-
(int(np.argmax(niters)), int(np.argmin(niters)))
160-
print(out)
161-
out = ' Std and var for number of iterations: %4.2f -- %4.2f' % (float(np.std(niters)), float(np.var(niters)))
162-
print(out)
150+
# compute and print statistics
151+
niters = np.array([item[1] for item in iter_counts])
152+
print(f'Mean number of iterations on rank {rank}: {np.mean(niters):.4f}')
163153

154+
if rank == 0:
164155
timing = sort_stats(filter_stats(stats, type='timing_run'), sortby='time')
165156

166-
print('Time to solution: %6.4f sec.' % timing[0][1])
157+
print(f'---> Time to solution: {timing[0][1]:.4f} sec.')
167158
print()
168159

169160
return stats

0 commit comments

Comments
 (0)