Skip to content

Commit c999933

Browse files
committed
cleanup
1 parent 793e1df commit c999933

File tree

3 files changed

+34
-13
lines changed

3 files changed

+34
-13
lines changed

pySDC/implementations/datatype_classes/mesh.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -309,13 +309,11 @@ def apply_mat(self, A):
309309

310310
class rhs_comp2_mesh(object):
311311
"""
312-
RHS data type for meshes with comp1icit and comp2icit components
313-
314-
This data type can be used to have RHS with 2 components (here comp1icit and comp2icit)
312+
RHS data type for meshes with 2 components
315313
316314
Attributes:
317-
comp1 (mesh.mesh): comp1icit part
318-
comp2 (mesh.mesh): comp2icit part
315+
comp1 (mesh.mesh): first part
316+
comp2 (mesh.mesh): second part
319317
"""
320318

321319
def __init__(self, init, val=0.0):
@@ -350,7 +348,7 @@ def __sub__(self, other):
350348
Raises:
351349
DataError: if other is not a rhs object
352350
Returns:
353-
mesh.rhs_imex_mesh: differences between caller and other values (self-other)
351+
mesh.rhs_comp2_mesh: differences between caller and other values (self-other)
354352
"""
355353

356354
if isinstance(other, rhs_comp2_mesh):
@@ -367,11 +365,11 @@ def __add__(self, other):
367365
Overloading the addition operator for rhs types
368366
369367
Args:
370-
other (mesh.rhs_imex_mesh): rhs object to be added
368+
other (mesh.rhs_comp2_mesh): rhs object to be added
371369
Raises:
372370
DataError: if other is not a rhs object
373371
Returns:
374-
mesh.rhs_imex_mesh: sum of caller and other values (self-other)
372+
mesh.rhs_comp2_mesh: sum of caller and other values (self-other)
375373
"""
376374

377375
if isinstance(other, rhs_comp2_mesh):
@@ -392,7 +390,7 @@ def __rmul__(self, other):
392390
Raises:
393391
DataError: is other is not a float
394392
Returns:
395-
mesh.rhs_imex_mesh: copy of original values scaled by factor
393+
mesh.rhs_comp2_mesh: copy of original values scaled by factor
396394
"""
397395

398396
if isinstance(other, float):
@@ -412,7 +410,7 @@ def apply_mat(self, A):
412410
A: a matrix
413411
414412
Returns:
415-
mesh.rhs_imex_mesh: each component multiplied by the matrix A
413+
mesh.rhs_comp2_mesh: each component multiplied by the matrix A
416414
"""
417415

418416
if not A.shape[1] == self.comp1.values.shape[0]:

pySDC/implementations/problem_classes/AllenCahn_2D_FD.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
# http://www.personal.psu.edu/qud2/Res/Pre/dz09sisc.pdf
1111

12+
1213
# noinspection PyUnusedLocal
1314
class allencahn_fullyimplicit(ptype):
1415
"""
@@ -227,7 +228,8 @@ def solve_system(self, rhs, factor, u0, t):
227228

228229
Id = sp.eye(self.params.nvars[0] * self.params.nvars[1])
229230

230-
me.values = cg(Id - factor * self.A, rhs.values.flatten(), x0=u0.values.flatten(), tol=self.params.lin_tol, maxiter=self.params.lin_maxiter)[0]
231+
me.values = cg(Id - factor * self.A, rhs.values.flatten(), x0=u0.values.flatten(), tol=self.params.lin_tol,
232+
maxiter=self.params.lin_maxiter)[0]
231233
me.values = me.values.reshape(self.params.nvars)
232234
return me
233235

@@ -364,7 +366,8 @@ def solve_system_1(self, rhs, factor, u0, t):
364366

365367
Id = sp.eye(self.params.nvars[0] * self.params.nvars[1])
366368

367-
me.values = cg(Id - factor * self.A, rhs.values.flatten(), x0=u0.values.flatten(), tol=self.params.lin_tol, maxiter=self.params.lin_maxiter)[0]
369+
me.values = cg(Id - factor * self.A, rhs.values.flatten(), x0=u0.values.flatten(), tol=self.params.lin_tol,
370+
maxiter=self.params.lin_maxiter)[0]
368371
me.values = me.values.reshape(self.params.nvars)
369372
return me
370373

@@ -525,4 +528,4 @@ def solve_system_2(self, rhs, factor, u0, t):
525528

526529
me.values = 1.0 / (1.0 - factor * 1.0 / self.params.eps ** 2) * rhs.values
527530
me.values = me.values.reshape(self.params.nvars)
528-
return me
531+
return me

pySDC/implementations/transfer_classes/TransferMesh.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,16 @@ def restrict(self, F):
160160
G.expl.values = G.expl.values.reshape(self.coarse_prob.params.nvars)
161161
F.impl.values = F.impl.values.reshape(self.fine_prob.params.nvars)
162162
F.expl.values = F.expl.values.reshape(self.fine_prob.params.nvars)
163+
elif isinstance(F, rhs_comp2_mesh):
164+
F.comp1.values = F.comp1.values.flatten()
165+
F.comp2.values = F.comp2.values.flatten()
166+
G = F.apply_mat(self.Rspace)
167+
G.comp1.values = G.comp1.values.reshape(self.coarse_prob.params.nvars)
168+
G.comp2.values = G.comp2.values.reshape(self.coarse_prob.params.nvars)
169+
F.comp1.values = F.comp1.values.reshape(self.fine_prob.params.nvars)
170+
F.comp2.values = F.comp2.values.reshape(self.fine_prob.params.nvars)
171+
else:
172+
raise TransferError('Wrong data type for restriction, got %s' % type(F))
163173
return G
164174

165175
def prolong(self, G):
@@ -181,4 +191,14 @@ def prolong(self, G):
181191
F.expl.values = F.expl.values.reshape(self.fine_prob.params.nvars)
182192
G.impl.values = G.impl.values.reshape(self.coarse_prob.params.nvars)
183193
G.expl.values = G.expl.values.reshape(self.coarse_prob.params.nvars)
194+
elif isinstance(G, rhs_comp2_mesh):
195+
G.comp1.values = G.comp1.values.flatten()
196+
G.comp2.values = G.comp2.values.flatten()
197+
F = G.apply_mat(self.Pspace)
198+
F.comp1.values = F.comp1.values.reshape(self.fine_prob.params.nvars)
199+
F.comp2.values = F.comp2.values.reshape(self.fine_prob.params.nvars)
200+
G.comp1.values = G.comp1.values.reshape(self.coarse_prob.params.nvars)
201+
G.comp2.values = G.comp2.values.reshape(self.coarse_prob.params.nvars)
202+
else:
203+
raise TransferError('Wrong data type for prolongation, got %s' % type(G))
184204
return F

0 commit comments

Comments
 (0)