Skip to content

Commit afdb174

Browse files
committed
Always use collocation formulation to compute uend. This fixes #52.
1 parent 48d3ffa commit afdb174

File tree

4 files changed

+28
-52
lines changed

4 files changed

+28
-52
lines changed

pySDC/sweeper_classes/boris_2nd_order.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -174,29 +174,23 @@ def compute_end_point(self):
174174
"""
175175
Compute u at the right point of the interval
176176
177-
The value uend computed here might be a simple copy from u[M] (if right point is a collocation node) or
178-
a full evaluation of the Picard formulation (if right point is not a collocation node)
177+
The value uend computed here is a full evaluation of the Picard formulation (always!)
179178
"""
180179

181180
# get current level and problem description
182181
L = self.level
183182
P = L.prob
184183

185-
# check if Mth node is equal to right point (flag is set in collocation class)
186-
if self.coll.right_is_node:
187-
# a copy is sufficient
188-
L.uend = P.dtype_u(L.u[-1])
189-
else:
190-
# start with u0 and add integral over the full interval (using coll.weights)
191-
L.uend = P.dtype_u(L.u[0])
192-
# compute q*Q on the fly.. could be done a priori (fixme)
193-
qQ = np.dot(self.coll.weights,self.coll.Qmat[1:,1:])
194-
for m in range(self.coll.num_nodes):
195-
f = P.build_f(L.f[m+1],L.u[m+1],L.time+L.dt*self.coll.nodes[m])
196-
L.uend.pos += L.dt*(L.dt*qQ[m]*f) + L.dt*self.coll.weights[m]*L.u[0].vel
197-
L.uend.vel += L.dt*self.coll.weights[m]*f
198-
# add up tau correction of the full interval (last entry)
199-
if L.tau is not None:
200-
L.uend += L.tau[-1]
184+
# start with u0 and add integral over the full interval (using coll.weights)
185+
L.uend = P.dtype_u(L.u[0])
186+
# compute q*Q on the fly.. could be done a priori (fixme)
187+
qQ = np.dot(self.coll.weights,self.coll.Qmat[1:,1:])
188+
for m in range(self.coll.num_nodes):
189+
f = P.build_f(L.f[m+1],L.u[m+1],L.time+L.dt*self.coll.nodes[m])
190+
L.uend.pos += L.dt*(L.dt*qQ[m]*f) + L.dt*self.coll.weights[m]*L.u[0].vel
191+
L.uend.vel += L.dt*self.coll.weights[m]*f
192+
# add up tau correction of the full interval (last entry)
193+
if L.tau is not None:
194+
L.uend += L.tau[-1]
201195

202196
return None

pySDC/sweeper_classes/generic_LU.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -128,25 +128,19 @@ def compute_end_point(self):
128128
"""
129129
Compute u at the right point of the interval
130130
131-
The value uend computed here might be a simple copy from u[M] (if right point is a collocation node) or
132-
a full evaluation of the Picard formulation (if right point is not a collocation node)
131+
The value uend computed here is a full evaluation of the Picard formulation (always!)
133132
"""
134133

135134
# get current level and problem description
136135
L = self.level
137136
P = L.prob
138137

139-
# check if Mth node is equal to right point (flag is set in collocation class)
140-
if self.coll.right_is_node:
141-
# a copy is sufficient
142-
L.uend = P.dtype_u(L.u[-1])
143-
else:
144-
# start with u0 and add integral over the full interval (using coll.weights)
145-
L.uend = P.dtype_u(L.u[0])
146-
for m in range(self.coll.num_nodes):
147-
L.uend += L.dt*self.coll.weights[m]*L.f[m+1]
148-
# add up tau correction of the full interval (last entry)
149-
if L.tau is not None:
150-
L.uend += L.tau[-1]
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]
151145

152146
return None

pySDC/sweeper_classes/imex_1st_order.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -134,25 +134,19 @@ def compute_end_point(self):
134134
"""
135135
Compute u at the right point of the interval
136136
137-
The value uend computed here might be a simple copy from u[M] (if right point is a collocation node) or
138-
a full evaluation of the Picard formulation (if right point is not a collocation node)
137+
The value uend computed here is a full evaluation of the Picard formulation (always!)
139138
"""
140139

141140
# get current level and problem description
142141
L = self.level
143142
P = L.prob
144143

145-
# check if Mth node is equal to right point (flag is set in collocation class)
146-
if self.coll.right_is_node:
147-
# a copy is sufficient
148-
L.uend = P.dtype_u(L.u[-1])
149-
else:
150-
# start with u0 and add integral over the full interval (using coll.weights)
151-
L.uend = P.dtype_u(L.u[0])
152-
for m in range(self.coll.num_nodes):
153-
L.uend += L.dt*self.coll.weights[m]*(L.f[m+1].impl + L.f[m+1].expl)
154-
# add up tau correction of the full interval (last entry)
155-
if L.tau is not None:
156-
L.uend += L.tau[-1]
144+
# start with u0 and add integral over the full interval (using coll.weights)
145+
L.uend = P.dtype_u(L.u[0])
146+
for m in range(self.coll.num_nodes):
147+
L.uend += L.dt*self.coll.weights[m]*(L.f[m+1].impl + L.f[m+1].expl)
148+
# add up tau correction of the full interval (last entry)
149+
if L.tau is not None:
150+
L.uend += L.tau[-1]
157151

158152
return None

tests/test_imexsweeper.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,6 @@ def test_sweepequalmatrix(self):
121121
#
122122
def test_updateformula(self):
123123

124-
if (self.swparams['collocation_class']==collclass.CollGaussLobatto):
125-
raise unittest.SkipTest("Needs fix of issue #52 before passing for Gauss Lobatto nodes")
126-
127124
step, level, problem, nnodes = self.setupLevelStepProblem()
128125
level.sweep.predict()
129126
u0full = np.array([ level.u[l].values.flatten() for l in range(1,nnodes+1) ])
@@ -209,9 +206,6 @@ def test_manysweepsequalmatrix(self):
209206
#
210207
def test_maysweepupdate(self):
211208

212-
if (self.swparams['collocation_class']==collclass.CollGaussLobatto):
213-
raise unittest.SkipTest("Needs fix of issue #52 before passing for Gauss Lobatto nodes")
214-
215209
step, level, problem, nnodes = self.setupLevelStepProblem()
216210
step.levels[0].sweep.predict()
217211
u0full = np.array([ level.u[l].values.flatten() for l in range(1,nnodes+1) ])

0 commit comments

Comments
 (0)