Skip to content

Commit a892f5f

Browse files
author
Daniel Ruprecht
committed
introduced flag do_coll_update as parameter for sweeper objects. If True (default), a proper collocation update is performed in compute_end_point. If False, the stage corresponding to the end point is copied. Throws an exception of set to False for collocation nodes where endpoint is not a stage
1 parent f693675 commit a892f5f

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

pySDC/Sweeper.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ def __init__(self,params):
3131

3232
defaults = dict()
3333
defaults['do_LU'] = False
34-
34+
defaults['do_coll_update'] = True
35+
3536
for k,v in defaults.items():
3637
setattr(self,k,v)
3738

@@ -43,6 +44,8 @@ def __init__(self,params):
4344

4445
coll = params['collocation_class'](params['num_nodes'],0,1)
4546
assert isinstance(coll, CollBase)
47+
if not coll.right_is_node:
48+
assert self.params['do_coll_update'], "For nodes where the right end point is not a node, do_coll_update has to be set to True"
4649

4750
# This will be set as soon as the sweeper is instantiated at the level
4851
self.__level = None
@@ -151,4 +154,4 @@ def update_nodes(self):
151154
"""
152155
Abstract interface to node update
153156
"""
154-
return None
157+
return None

pySDC/sweeper_classes/generic_LU.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,17 @@ def compute_end_point(self):
135135
L = self.level
136136
P = L.prob
137137

138-
# start with u0 and add integral over the full interval (using coll.weights)
139-
L.uend = P.dtype_u(L.u[0])
140-
for m in range(self.coll.num_nodes):
141-
L.uend += L.dt*self.coll.weights[m]*L.f[m+1]
142-
# add up tau correction of the full interval (last entry)
143-
if L.tau is not None:
144-
L.uend += L.tau[-1]
145-
146-
return None
138+
- # check if Mth node is equal to right point and do_coll_update is false, perform a simple copy
139+
- if (self.coll.right_is_node and not self.params['do_coll_update']):
140+
- # a copy is sufficient
141+
- L.uend = P.dtype_u(L.u[-1])
142+
else:
143+
# start with u0 and add integral over the full interval (using coll.weights)
144+
L.uend = P.dtype_u(L.u[0])
145+
for m in range(self.coll.num_nodes):
146+
L.uend += L.dt*self.coll.weights[m]*L.f[m+1]
147+
# add up tau correction of the full interval (last entry)
148+
if L.tau is not None:
149+
L.uend += L.tau[-1]
150+
151+
return None

0 commit comments

Comments
 (0)