Skip to content

Commit 40c325d

Browse files
committed
bugfix for Q transfer (this fixes #92)
1 parent 57f7abe commit 40c325d

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

pySDC/core/BaseTransfer.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def __init__(self, fine_level, coarse_level, base_transfer_params, space_transfe
3333
class __Pars(FrozenClass):
3434
def __init__(self, pars):
3535
self.finter = False
36-
self.coll_iorder = 1
36+
self.coll_iorder = 2
3737
self.coll_rorder = 1
3838
for k, v in pars.items():
3939
setattr(self, k, v)
@@ -110,8 +110,7 @@ def restrict(self):
110110
tmp_u.append(self.space_transfer.restrict(F.u[m]))
111111

112112
# restrict collocation values
113-
G.u[0] = tmp_u[0]
114-
for n in range(1, SG.coll.num_nodes + 1):
113+
for n in range(0, SG.coll.num_nodes + 1):
115114
G.u[n] = self.Rcoll[n, 0] * tmp_u[0]
116115
for m in range(1, SF.coll.num_nodes + 1):
117116
G.u[n] += self.Rcoll[n, m] * tmp_u[m]
@@ -133,11 +132,11 @@ def restrict(self):
133132
tmp_tau.append(self.space_transfer.restrict(tauF[m]))
134133

135134
# restrict fine level tau correction part in collocation
136-
tauFG = [tmp_tau[0]]
137-
for n in range(1, SG.coll.num_nodes):
138-
tauFG.append(self.Rcoll[n + 1, 1] * tmp_tau[0])
135+
tauFG = []
136+
for n in range(1, SG.coll.num_nodes + 1):
137+
tauFG.append(self.Rcoll[n, 1] * tmp_tau[0])
139138
for m in range(1, SF.coll.num_nodes):
140-
tauFG[-1] += self.Rcoll[n + 1, m + 1] * tmp_tau[m]
139+
tauFG[-1] += self.Rcoll[n, m + 1] * tmp_tau[m]
141140

142141
# build tau correction
143142
for m in range(SG.coll.num_nodes):
@@ -150,10 +149,10 @@ def restrict(self):
150149
tmp_tau.append(self.space_transfer.restrict(F.tau[m]))
151150

152151
# restrict possible tau correction from fine in collocation
153-
for n in range(0, SG.coll.num_nodes):
154-
G.tau[n] += self.Rcoll[n + 1, 1] * tmp_tau[0]
152+
for n in range(1, SG.coll.num_nodes + 1):
153+
G.tau[n - 1] += self.Rcoll[n, 1] * tmp_tau[0]
155154
for m in range(1, SF.coll.num_nodes):
156-
G.tau[n] += self.Rcoll[n + 1, m + 1] * tmp_tau[m]
155+
G.tau[n - 1] += self.Rcoll[n, m + 1] * tmp_tau[m]
157156
else:
158157
pass
159158

@@ -201,8 +200,7 @@ def prolong(self):
201200
tmp_u.append(self.space_transfer.prolong(G.u[m] - G.uold[m]))
202201

203202
# interpolate values in collocation
204-
F.u[0] += tmp_u[0]
205-
for n in range(1, SF.coll.num_nodes + 1):
203+
for n in range(0, SF.coll.num_nodes + 1):
206204
for m in range(0, SG.coll.num_nodes + 1):
207205
F.u[n] += self.Pcoll[n, m] * tmp_u[m]
208206

@@ -247,9 +245,7 @@ def prolong_f(self):
247245
tmp_f.append(self.space_transfer.prolong(G.f[m] - G.fold[m]))
248246

249247
# interpolate values in collocation
250-
F.u[0] += tmp_u[0]
251-
F.f[0] += tmp_f[0]
252-
for n in range(1, SF.coll.num_nodes + 1):
248+
for n in range(0, SF.coll.num_nodes + 1):
253249
for m in range(0, SG.coll.num_nodes + 1):
254250
F.u[n] += self.Pcoll[n, m] * tmp_u[m]
255251
F.f[n] += self.Pcoll[n, m] * tmp_f[m]

tests/test_Q_transfer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ def check_Q_transfer_minimal(collclass):
109109
err_inter = np.linalg.norm(uinter-ufine, np.inf)
110110
err_restr = np.linalg.norm(urestr-ucoarse, np.inf)
111111

112-
print(M, Mcoarse, 2, err_inter)
113-
114112
if polyorder <= 2:
115113
assert err_inter < 2E-15, "ERROR: Q-interpolation order is not reached, got %s" %err_inter
116114
assert err_restr < 2E-15, "ERROR: Q-restriction order is not reached, got %s" % err_restr

0 commit comments

Comments
 (0)