diff --git a/.doctrees/environment.pickle b/.doctrees/environment.pickle index 17f9591365..6818e9c33a 100644 Binary files a/.doctrees/environment.pickle and b/.doctrees/environment.pickle differ diff --git a/.doctrees/projects/Hamiltonian.doctree b/.doctrees/projects/Hamiltonian.doctree index ca8de15da3..50d2dc3627 100644 Binary files a/.doctrees/projects/Hamiltonian.doctree and b/.doctrees/projects/Hamiltonian.doctree differ diff --git a/.doctrees/projects/doc_fput.doctree b/.doctrees/projects/doc_fput.doctree index a453010177..a8e511777f 100644 Binary files a/.doctrees/projects/doc_fput.doctree and b/.doctrees/projects/doc_fput.doctree differ diff --git a/.doctrees/pySDC/helpers.transfer_helper.doctree b/.doctrees/pySDC/helpers.transfer_helper.doctree index 2847b3f9c8..b367a81019 100644 Binary files a/.doctrees/pySDC/helpers.transfer_helper.doctree and b/.doctrees/pySDC/helpers.transfer_helper.doctree differ diff --git a/.doctrees/pySDC/implementations.transfer_classes.TransferMesh.doctree b/.doctrees/pySDC/implementations.transfer_classes.TransferMesh.doctree index d6aa71c180..f90ba5c532 100644 Binary files a/.doctrees/pySDC/implementations.transfer_classes.TransferMesh.doctree and b/.doctrees/pySDC/implementations.transfer_classes.TransferMesh.doctree differ diff --git a/.doctrees/pySDC/implementations.transfer_classes.TransferMesh_MPIFFT.doctree b/.doctrees/pySDC/implementations.transfer_classes.TransferMesh_MPIFFT.doctree index 39e298c180..6c46dbd52c 100644 Binary files a/.doctrees/pySDC/implementations.transfer_classes.TransferMesh_MPIFFT.doctree and b/.doctrees/pySDC/implementations.transfer_classes.TransferMesh_MPIFFT.doctree differ diff --git a/.doctrees/tutorial/doc_step_2_C.doctree b/.doctrees/tutorial/doc_step_2_C.doctree index 3b242b66be..7b81800a56 100644 Binary files a/.doctrees/tutorial/doc_step_2_C.doctree and b/.doctrees/tutorial/doc_step_2_C.doctree differ diff --git a/.doctrees/tutorial/doc_step_3_B.doctree b/.doctrees/tutorial/doc_step_3_B.doctree index fea8282f0d..38fb5c9b63 100644 Binary files a/.doctrees/tutorial/doc_step_3_B.doctree and b/.doctrees/tutorial/doc_step_3_B.doctree differ diff --git a/.doctrees/tutorial/doc_step_4_D.doctree b/.doctrees/tutorial/doc_step_4_D.doctree index 4f2110ef34..1059c2a00b 100644 Binary files a/.doctrees/tutorial/doc_step_4_D.doctree and b/.doctrees/tutorial/doc_step_4_D.doctree differ diff --git a/.doctrees/tutorial/doc_step_7_A.doctree b/.doctrees/tutorial/doc_step_7_A.doctree index c4825b650c..ec33a46f71 100644 Binary files a/.doctrees/tutorial/doc_step_7_A.doctree and b/.doctrees/tutorial/doc_step_7_A.doctree differ diff --git a/.doctrees/tutorial/doc_step_7_B.doctree b/.doctrees/tutorial/doc_step_7_B.doctree index 2dfc0cfcb0..1101b2dcf7 100644 Binary files a/.doctrees/tutorial/doc_step_7_B.doctree and b/.doctrees/tutorial/doc_step_7_B.doctree differ diff --git a/.doctrees/tutorial/doc_step_7_C.doctree b/.doctrees/tutorial/doc_step_7_C.doctree index 3817587908..0db77bcecd 100644 Binary files a/.doctrees/tutorial/doc_step_7_C.doctree and b/.doctrees/tutorial/doc_step_7_C.doctree differ diff --git a/.doctrees/tutorial/doc_step_8_C.doctree b/.doctrees/tutorial/doc_step_8_C.doctree index c114497027..8416895036 100644 Binary files a/.doctrees/tutorial/doc_step_8_C.doctree and b/.doctrees/tutorial/doc_step_8_C.doctree differ diff --git a/.doctrees/tutorial/step_2.doctree b/.doctrees/tutorial/step_2.doctree index f2fe1e58e8..bc5a5290a0 100644 Binary files a/.doctrees/tutorial/step_2.doctree and b/.doctrees/tutorial/step_2.doctree differ diff --git a/.doctrees/tutorial/step_3.doctree b/.doctrees/tutorial/step_3.doctree index 71f52dd987..75fe074679 100644 Binary files a/.doctrees/tutorial/step_3.doctree and b/.doctrees/tutorial/step_3.doctree differ diff --git a/.doctrees/tutorial/step_4.doctree b/.doctrees/tutorial/step_4.doctree index 490625c832..e355581b8a 100644 Binary files a/.doctrees/tutorial/step_4.doctree and b/.doctrees/tutorial/step_4.doctree differ diff --git a/.doctrees/tutorial/step_7.doctree b/.doctrees/tutorial/step_7.doctree index 9305c6ef5c..6b0ef70031 100644 Binary files a/.doctrees/tutorial/step_7.doctree and b/.doctrees/tutorial/step_7.doctree differ diff --git a/.doctrees/tutorial/step_8.doctree b/.doctrees/tutorial/step_8.doctree index 96c7aa5bbf..71fbe56699 100644 Binary files a/.doctrees/tutorial/step_8.doctree and b/.doctrees/tutorial/step_8.doctree differ diff --git a/_images/timings_SDC_variants_Fisher.png b/_images/timings_SDC_variants_Fisher.png index ffe4a760b7..47e6c71c23 100644 Binary files a/_images/timings_SDC_variants_Fisher.png and b/_images/timings_SDC_variants_Fisher.png differ diff --git a/_images/timings_SDC_variants_GrayScott.png b/_images/timings_SDC_variants_GrayScott.png index 952f32f148..caaab24f39 100644 Binary files a/_images/timings_SDC_variants_GrayScott.png and b/_images/timings_SDC_variants_GrayScott.png differ diff --git a/_modules/helpers/transfer_helper.html b/_modules/helpers/transfer_helper.html index a442b81e75..90653cc655 100644 --- a/_modules/helpers/transfer_helper.html +++ b/_modules/helpers/transfer_helper.html @@ -191,7 +191,7 @@

Source code for helpers.transfer_helper

 [docs]
 def interpolation_matrix_1d(fine_grid, coarse_grid, k=2, periodic=False, pad=1, equidist_nested=True):
     """
-    Function to contruct the restriction matrix in 1d using barycentric interpolation
+    Function to construct the restriction matrix in 1d using barycentric interpolation
 
     Args:
         fine_grid (np.ndarray): a one dimensional 1d array containing the nodes of the fine grid
diff --git a/_modules/implementations/convergence_controller_classes/check_iteration_estimator.html b/_modules/implementations/convergence_controller_classes/check_iteration_estimator.html
index 42307dea6c..dd931a9bc5 100644
--- a/_modules/implementations/convergence_controller_classes/check_iteration_estimator.html
+++ b/_modules/implementations/convergence_controller_classes/check_iteration_estimator.html
@@ -47,7 +47,7 @@ 

Source code for implementations.convergence_controller_classes.check_iterati class CheckIterationEstimatorNonMPI(ConvergenceController): def __init__(self, controller, params, description, **kwargs): """ - Initalization routine + Initialization routine Args: controller (pySDC.Controller): The controller diff --git a/_modules/implementations/datatype_classes/mesh.html b/_modules/implementations/datatype_classes/mesh.html index 601fdb91a9..14519b4098 100644 --- a/_modules/implementations/datatype_classes/mesh.html +++ b/_modules/implementations/datatype_classes/mesh.html @@ -252,7 +252,7 @@

Source code for implementations.datatype_classes.mesh

def __getattr__(self, name): if name in self.components: if self.shape[0] == len(self.components): - return self[self.components.index(name)] + return self[self.components.index(name)].view(mesh) else: raise AttributeError(f'Cannot access {name!r} in {type(self)!r} because the shape is unexpected.') else: diff --git a/_modules/implementations/problem_classes/Brusselator.html b/_modules/implementations/problem_classes/Brusselator.html index 4f950c9944..4f30c9af8e 100644 --- a/_modules/implementations/problem_classes/Brusselator.html +++ b/_modules/implementations/problem_classes/Brusselator.html @@ -71,6 +71,7 @@

Source code for implementations.problem_classes.Brusselator

shape = (2,) + (self.init[0]) self.iU = 0 self.iV = 1 + self.ncomp = 2 # needed for transfer class self.init = (shape, self.comm, np.dtype('float')) def _eval_explicit_part(self, u, t, f_expl): diff --git a/_modules/implementations/problem_classes/GrayScott_MPIFFT.html b/_modules/implementations/problem_classes/GrayScott_MPIFFT.html index fa5249228a..c0fd08b451 100644 --- a/_modules/implementations/problem_classes/GrayScott_MPIFFT.html +++ b/_modules/implementations/problem_classes/GrayScott_MPIFFT.html @@ -120,6 +120,7 @@

Source code for implementations.problem_classes.GrayScott_MPIFFT

shape = (2,) + (self.init[0]) self.iU = 0 self.iV = 1 + self.ncomp = 2 # needed for transfer class self.init = (shape, self.comm, self.xp.dtype('float')) self._makeAttributeAndRegister('Du', 'Dv', 'A', 'B', localVars=locals(), readOnly=True) diff --git a/_modules/implementations/sweeper_classes/imex_1st_order.html b/_modules/implementations/sweeper_classes/imex_1st_order.html index d81146f597..601f9be65f 100644 --- a/_modules/implementations/sweeper_classes/imex_1st_order.html +++ b/_modules/implementations/sweeper_classes/imex_1st_order.html @@ -85,16 +85,14 @@

Source code for implementations.sweeper_classes.imex_1st_order

list of dtype_u: containing the integral as values """ - # get current level and problem description L = self.level + P = L.prob me = [] - # integrate RHS over all collocation nodes for m in range(1, self.coll.num_nodes + 1): - me.append(L.dt * self.coll.Qmat[m, 1] * (L.f[1].impl + L.f[1].expl)) - # new instance of dtype_u, initialize values with 0 - for j in range(2, self.coll.num_nodes + 1): + me.append(P.dtype_u(P.init, val=0.0)) + for j in range(1, self.coll.num_nodes + 1): me[m - 1] += L.dt * self.coll.Qmat[m, j] * (L.f[j].impl + L.f[j].expl) return me
diff --git a/_modules/implementations/transfer_classes/TransferMesh.html b/_modules/implementations/transfer_classes/TransferMesh.html index dde4268327..9116383413 100644 --- a/_modules/implementations/transfer_classes/TransferMesh.html +++ b/_modules/implementations/transfer_classes/TransferMesh.html @@ -43,17 +43,16 @@

Source code for implementations.transfer_classes.TransferMesh

import pySDC.helpers.transfer_helper as th from pySDC.core.Errors import TransferError from pySDC.core.SpaceTransfer import space_transfer -from pySDC.implementations.datatype_classes.mesh import mesh, imex_mesh, comp2_mesh
[docs] class mesh_to_mesh(space_transfer): """ - Custon base_transfer class, implements Transfer.py + Custom base_transfer class, implements Transfer.py This implementation can restrict and prolong between nd meshes with dirichlet-0 or periodic boundaries - via matrix-vector products + via matrix-vector products. Attributes: Rspace: spatial restriction matrix, dim. Nf x Nc @@ -71,7 +70,7 @@

Source code for implementations.transfer_classes.TransferMesh

""" # invoke super initialization - super(mesh_to_mesh, self).__init__(fine_prob, coarse_prob, params) + super().__init__(fine_prob, coarse_prob, params) if self.params.rorder % 2 != 0: raise TransferError('Need even order for restriction') @@ -196,51 +195,31 @@

Source code for implementations.transfer_classes.TransferMesh

Args: F: the fine level data (easier to access than via the fine attribute) """ - if isinstance(F, mesh): - G = self.coarse_prob.dtype_u(self.coarse_prob.init) - if hasattr(self.fine_prob, 'ncomp'): - for i in range(self.fine_prob.ncomp): - tmpF = F[..., i].flatten() - tmpG = self.Rspace.dot(tmpF) - G[..., i] = tmpG.reshape(self.coarse_prob.nvars) - else: - tmpF = F.flatten() - tmpG = self.Rspace.dot(tmpF) - G[:] = tmpG.reshape(self.coarse_prob.nvars) - elif isinstance(F, imex_mesh): - G = self.coarse_prob.dtype_f(self.coarse_prob.init) - if hasattr(self.fine_prob, 'ncomp'): - for i in range(self.fine_prob.ncomp): - tmpF = F.impl[..., i].flatten() - tmpG = self.Rspace.dot(tmpF) - G.impl[..., i] = tmpG.reshape(self.coarse_prob.nvars) - tmpF = F.expl[..., i].flatten() - tmpG = self.Rspace.dot(tmpF) - G.expl[..., i] = tmpG.reshape(self.coarse_prob.nvars) - else: - tmpF = F.impl.flatten() - tmpG = self.Rspace.dot(tmpF) - G.impl[:] = tmpG.reshape(self.coarse_prob.nvars) - tmpF = F.expl.flatten() - tmpG = self.Rspace.dot(tmpF) - G.expl[:] = tmpG.reshape(self.coarse_prob.nvars) - elif isinstance(F, comp2_mesh): - G = self.coarse_prob.dtype_f(self.coarse_prob.init) + G = type(F)(self.coarse_prob.init) + + def _restrict(fine, coarse): if hasattr(self.fine_prob, 'ncomp'): for i in range(self.fine_prob.ncomp): - tmpF = F.comp1[..., i].flatten() - tmpG = self.Rspace.dot(tmpF) - G.comp1[..., i] = tmpG.reshape(self.coarse_prob.nvars) - tmpF = F.comp2[..., i].flatten() - tmpG = self.Rspace.dot(tmpF) - G.comp2[..., i] = tmpG.reshape(self.coarse_prob.nvars) + if fine.shape[-1] == self.fine_prob.ncomp: + tmpF = fine[..., i].flatten() + tmpG = self.Rspace.dot(tmpF) + coarse[..., i] = tmpG.reshape(self.coarse_prob.nvars) + elif fine.shape[0] == self.fine_prob.ncomp: + tmpF = fine[i, ...].flatten() + tmpG = self.Rspace.dot(tmpF) + coarse[i, ...] = tmpG.reshape(self.coarse_prob.nvars) + else: + raise TransferError('Don\'t know how to restrict for this problem with multiple components') else: - tmpF = F.comp1.flatten() - tmpG = self.Rspace.dot(tmpF) - G.comp1[:] = tmpG.reshape(self.coarse_prob.nvars) - tmpF = F.comp2.flatten() + tmpF = fine.flatten() tmpG = self.Rspace.dot(tmpF) - G.comp2[:] = tmpG.reshape(self.coarse_prob.nvars) + coarse[:] = tmpG.reshape(self.coarse_prob.nvars) + + if hasattr(type(F), 'components'): + for comp in F.components: + _restrict(F.__getattr__(comp), G.__getattr__(comp)) + elif type(F).__name__ == 'mesh': + _restrict(F, G) else: raise TransferError('Wrong data type for restriction, got %s' % type(F)) return G
@@ -254,51 +233,32 @@

Source code for implementations.transfer_classes.TransferMesh

Args: G: the coarse level data (easier to access than via the coarse attribute) """ - if isinstance(G, mesh): - F = self.fine_prob.dtype_u(self.fine_prob.init) - if hasattr(self.fine_prob, 'ncomp'): - for i in range(self.fine_prob.ncomp): - tmpG = G[..., i].flatten() - tmpF = self.Pspace.dot(tmpG) - F[..., i] = tmpF.reshape(self.fine_prob.nvars) - else: - tmpG = G.flatten() - tmpF = self.Pspace.dot(tmpG) - F[:] = tmpF.reshape(self.fine_prob.nvars) - elif isinstance(G, imex_mesh): - F = self.fine_prob.dtype_f(self.fine_prob.init) - if hasattr(self.fine_prob, 'ncomp'): - for i in range(self.fine_prob.ncomp): - tmpG = G.impl[..., i].flatten() - tmpF = self.Pspace.dot(tmpG) - F.impl[..., i] = tmpF.reshape(self.fine_prob.nvars) - tmpG = G.expl[..., i].flatten() - tmpF = self.Rspace.dot(tmpG) - F.expl[..., i] = tmpF.reshape(self.fine_prob.nvars) - else: - tmpG = G.impl.flatten() - tmpF = self.Pspace.dot(tmpG) - F.impl[:] = tmpF.reshape(self.fine_prob.nvars) - tmpG = G.expl.flatten() - tmpF = self.Pspace.dot(tmpG) - F.expl[:] = tmpF.reshape(self.fine_prob.nvars) - elif isinstance(G, comp2_mesh): - F = self.fine_prob.dtype_f(self.fine_prob.init) + F = type(G)(self.fine_prob.init) + + def _prolong(coarse, fine): if hasattr(self.fine_prob, 'ncomp'): for i in range(self.fine_prob.ncomp): - tmpG = G.comp1[..., i].flatten() - tmpF = self.Pspace.dot(tmpG) - F.comp1[..., i] = tmpF.reshape(self.fine_prob.nvars) - tmpG = G.comp2[..., i].flatten() - tmpF = self.Rspace.dot(tmpG) - F.comp2[..., i] = tmpF.reshape(self.fine_prob.nvars) + if coarse.shape[-1] == self.fine_prob.ncomp: + tmpG = coarse[..., i].flatten() + tmpF = self.Pspace.dot(tmpG) + fine[..., i] = tmpF.reshape(self.fine_prob.nvars) + elif coarse.shape[0] == self.fine_prob.ncomp: + tmpG = coarse[i, ...].flatten() + tmpF = self.Pspace.dot(tmpG) + fine[i, ...] = tmpF.reshape(self.fine_prob.nvars) + else: + raise TransferError('Don\'t know how to prolong for this problem with multiple components') else: - tmpG = G.comp1.flatten() - tmpF = self.Pspace.dot(tmpG) - F.comp1[:] = tmpF.reshape(self.fine_prob.nvars) - tmpG = G.comp2.flatten() + tmpG = coarse.flatten() tmpF = self.Pspace.dot(tmpG) - F.comp2[:] = tmpF.reshape(self.fine_prob.nvars) + fine[:] = tmpF.reshape(self.fine_prob.nvars) + return fine + + if hasattr(type(F), 'components'): + for comp in G.components: + _prolong(G.__getattr__(comp), F.__getattr__(comp)) + elif type(G).__name__ == 'mesh': + F[:] = _prolong(G, F) else: raise TransferError('Wrong data type for prolongation, got %s' % type(G)) return F
diff --git a/_modules/implementations/transfer_classes/TransferMesh_FFT.html b/_modules/implementations/transfer_classes/TransferMesh_FFT.html index 21ea11fc7b..5083d9f232 100644 --- a/_modules/implementations/transfer_classes/TransferMesh_FFT.html +++ b/_modules/implementations/transfer_classes/TransferMesh_FFT.html @@ -41,7 +41,6 @@

Source code for implementations.transfer_classes.TransferMesh_FFT

from pySDC.core.Errors import TransferError from pySDC.core.SpaceTransfer import space_transfer -from pySDC.implementations.datatype_classes.mesh import mesh, imex_mesh
@@ -67,9 +66,9 @@

Source code for implementations.transfer_classes.TransferMesh_FFT

params: parameters for the transfer operators """ # invoke super initialization - super(mesh_to_mesh_fft, self).__init__(fine_prob, coarse_prob, params) + super().__init__(fine_prob, coarse_prob, params) - self.ratio = int(self.fine_prob.params.nvars / self.coarse_prob.params.nvars) + self.ratio = int(self.fine_prob.nvars / self.coarse_prob.nvars)
[docs] @@ -80,11 +79,11 @@

Source code for implementations.transfer_classes.TransferMesh_FFT

Args: F: the fine level data (easier to access than via the fine attribute) """ - if isinstance(F, mesh): - G = mesh(self.coarse_prob.init, val=0.0) + G = type(F)(self.coarse_prob.init, val=0.0) + + if type(F).__name__ == 'mesh': G[:] = F[:: self.ratio] - elif isinstance(F, imex_mesh): - G = imex_mesh(self.coarse_prob.init, val=0.0) + elif type(F).__name__ == 'imex_mesh': G.impl[:] = F.impl[:: self.ratio] G.expl[:] = F.expl[:: self.ratio] else: @@ -101,28 +100,21 @@

Source code for implementations.transfer_classes.TransferMesh_FFT

Args: G: the coarse level data (easier to access than via the coarse attribute) """ - if isinstance(G, mesh): - F = mesh(self.fine_prob.init, val=0.0) - tmpG = np.fft.rfft(G) - tmpF = np.zeros(self.fine_prob.init[0] // 2 + 1, dtype=np.complex128) - halfG = int(self.coarse_prob.init[0] / 2) - tmpF[0:halfG] = tmpG[0:halfG] - tmpF[-1] = tmpG[-1] - F[:] = np.fft.irfft(tmpF) * self.ratio - elif isinstance(G, imex_mesh): - F = imex_mesh(G) - tmpG_impl = np.fft.rfft(G.impl) - tmpF_impl = np.zeros(self.fine_prob.init[0] // 2 + 1, dtype=np.complex128) - halfG = int(self.coarse_prob.init[0] / 2) - tmpF_impl[0:halfG] = tmpG_impl[0:halfG] - tmpF_impl[-1] = tmpG_impl[-1] - F.impl[:] = np.fft.irfft(tmpF_impl) * self.ratio - tmpG_expl = np.fft.rfft(G.expl) - tmpF_expl = np.zeros(self.fine_prob.init[0] // 2 + 1, dtype=np.complex128) - halfG = int(self.coarse_prob.init[0] / 2) - tmpF_expl[0:halfG] = tmpG_expl[0:halfG] - tmpF_expl[-1] = tmpG_expl[-1] - F.expl[:] = np.fft.irfft(tmpF_expl) * self.ratio + F = type(G)(self.fine_prob.init, val=0.0) + + def _prolong(coarse): + coarse_hat = np.fft.rfft(coarse) + fine_hat = np.zeros(self.fine_prob.init[0] // 2 + 1, dtype=np.complex128) + half_idx = self.coarse_prob.init[0] // 2 + fine_hat[0:half_idx] = coarse_hat[0:half_idx] + fine_hat[-1] = coarse_hat[-1] + return np.fft.irfft(fine_hat) * self.ratio + + if type(G).__name__ == 'mesh': + F[:] = _prolong(G) + elif type(G).__name__ == 'imex_mesh': + F.impl[:] = _prolong(G.impl) + F.expl[:] = _prolong(G.expl) else: raise TransferError('Unknown data type, got %s' % type(G)) return F
diff --git a/_modules/implementations/transfer_classes/TransferMesh_MPIFFT.html b/_modules/implementations/transfer_classes/TransferMesh_MPIFFT.html index 031f206bc3..38e699458c 100644 --- a/_modules/implementations/transfer_classes/TransferMesh_MPIFFT.html +++ b/_modules/implementations/transfer_classes/TransferMesh_MPIFFT.html @@ -47,7 +47,7 @@

Source code for implementations.transfer_classes.TransferMesh_MPIFFT

[docs] class fft_to_fft(space_transfer): """ - Custon base_transfer class, implements Transfer.py + Custom base_transfer class, implements Transfer.py This implementation can restrict and prolong between PMESH datatypes meshes with FFT for periodic boundaries @@ -63,7 +63,7 @@

Source code for implementations.transfer_classes.TransferMesh_MPIFFT

params: parameters for the transfer operators """ # invoke super initialization - super(fft_to_fft, self).__init__(fine_prob, coarse_prob, params) + super().__init__(fine_prob, coarse_prob, params) assert self.fine_prob.spectral == self.coarse_prob.spectral @@ -92,24 +92,38 @@

Source code for implementations.transfer_classes.TransferMesh_MPIFFT

Args: F: the fine level data (easier to access than via the fine attribute) """ - if isinstance(F, mesh): + G = type(F)(self.coarse_prob.init) + + def _restrict(fine, coarse): if self.spectral: - G = self.coarse_prob.dtype_u(self.coarse_prob.init) if hasattr(self.fine_prob, 'ncomp'): for i in range(self.fine_prob.ncomp): - tmpF = newDistArray(self.fine_prob.fft, False) - tmpF = self.fine_prob.fft.backward(F[..., i], tmpF) - tmpG = tmpF[:: int(self.ratio[0]), :: int(self.ratio[1])] - G[..., i] = self.coarse_prob.fft.forward(tmpG, G[..., i]) + if fine.shape[-1] == self.fine_prob.ncomp: + tmpF = newDistArray(self.fine_prob.fft, False) + tmpF = self.fine_prob.fft.backward(fine[..., i], tmpF) + tmpG = tmpF[:: int(self.ratio[0]), :: int(self.ratio[1])] + coarse[..., i] = self.coarse_prob.fft.forward(tmpG, coarse[..., i]) + elif fine.shape[0] == self.fine_prob.ncomp: + tmpF = newDistArray(self.fine_prob.fft, False) + tmpF = self.fine_prob.fft.backward(fine[i, ...], tmpF) + tmpG = tmpF[:: int(self.ratio[0]), :: int(self.ratio[1])] + coarse[i, ...] = self.coarse_prob.fft.forward(tmpG, coarse[i, ...]) + else: + raise TransferError('Don\'t know how to restrict for this problem with multiple components') else: - tmpF = self.fine_prob.fft.backward(F) + tmpF = self.fine_prob.fft.backward(fine) tmpG = tmpF[:: int(self.ratio[0]), :: int(self.ratio[1])] - G[:] = self.coarse_prob.fft.forward(tmpG, G) + coarse[:] = self.coarse_prob.fft.forward(tmpG, coarse) else: - G = self.coarse_prob.dtype_u(self.coarse_prob.init) - G[:] = F[:: int(self.ratio[0]), :: int(self.ratio[1])] + coarse[:] = fine[:: int(self.ratio[0]), :: int(self.ratio[1])] + + if hasattr(type(F), 'components'): + for comp in F.components: + _restrict(F.__getattr__(comp), G.__getattr__(comp)) + elif type(F).__name__ == 'mesh': + _restrict(F, G) else: - raise TransferError('Unknown data type, got %s' % type(F)) + raise TransferError('Wrong data type for restriction, got %s' % type(F)) return G
@@ -123,52 +137,39 @@

Source code for implementations.transfer_classes.TransferMesh_MPIFFT

Args: G: the coarse level data (easier to access than via the coarse attribute) """ - if isinstance(G, mesh): - if self.spectral: - F = self.fine_prob.dtype_u(self.fine_prob.init) - if hasattr(self.fine_prob, 'ncomp'): - for i in range(self.fine_prob.ncomp): - tmpF = self.fft_pad.backward(G[..., i]) - F[..., i] = self.fine_prob.fft.forward(tmpF, F[..., i]) - else: - tmpF = self.fft_pad.backward(G) - F[:] = self.fine_prob.fft.forward(tmpF, F) - else: - F = self.fine_prob.dtype_u(self.fine_prob.init) - if hasattr(self.fine_prob, 'ncomp'): - for i in range(self.fine_prob.ncomp): - G_hat = self.coarse_prob.fft.forward(G[..., i]) - F[..., i] = self.fft_pad.backward(G_hat, F[..., i]) - else: - G_hat = self.coarse_prob.fft.forward(G) - F[:] = self.fft_pad.backward(G_hat, F) - elif isinstance(G, imex_mesh): + F = type(G)(self.fine_prob.init) + + def _prolong(coarse, fine): if self.spectral: - F = self.fine_prob.dtype_f(self.fine_prob.init) if hasattr(self.fine_prob, 'ncomp'): for i in range(self.fine_prob.ncomp): - tmpF = self.fft_pad.backward(G.impl[..., i]) - F.impl[..., i] = self.fine_prob.fft.forward(tmpF, F.impl[..., i]) - tmpF = self.fft_pad.backward(G.expl[..., i]) - F.expl[..., i] = self.fine_prob.fft.forward(tmpF, F.expl[..., i]) + if coarse.shape[-1] == self.fine_prob.ncomp: + tmpF = self.fft_pad.backward(coarse[..., i]) + fine[..., i] = self.fine_prob.fft.forward(tmpF, fine[..., i]) + elif coarse.shape[0] == self.fine_prob.ncomp: + tmpF = self.fft_pad.backward(coarse[i, ...]) + fine[i, ...] = self.fine_prob.fft.forward(tmpF, fine[i, ...]) + else: + raise TransferError('Don\'t know how to prolong for this problem with multiple components') + else: - tmpF = self.fft_pad.backward(G.impl) - F.impl[:] = self.fine_prob.fft.forward(tmpF, F.impl) - tmpF = self.fft_pad.backward(G.expl) - F.expl[:] = self.fine_prob.fft.forward(tmpF, F.expl) + tmpF = self.fft_pad.backward(coarse) + fine[:] = self.fine_prob.fft.forward(tmpF, fine) else: - F = self.fine_prob.dtype_f(self.fine_prob.init) if hasattr(self.fine_prob, 'ncomp'): for i in range(self.fine_prob.ncomp): - G_hat = self.coarse_prob.fft.forward(G.impl[..., i]) - F.impl[..., i] = self.fft_pad.backward(G_hat, F.impl[..., i]) - G_hat = self.coarse_prob.fft.forward(G.expl[..., i]) - F.expl[..., i] = self.fft_pad.backward(G_hat, F.expl[..., i]) + G_hat = self.coarse_prob.fft.forward(coarse[..., i]) + fine[..., i] = self.fft_pad.backward(G_hat, fine[..., i]) else: - G_hat = self.coarse_prob.fft.forward(G.impl) - F.impl[:] = self.fft_pad.backward(G_hat, F.impl) - G_hat = self.coarse_prob.fft.forward(G.expl) - F.expl[:] = self.fft_pad.backward(G_hat, F.expl) + G_hat = self.coarse_prob.fft.forward(coarse) + fine[:] = self.fft_pad.backward(G_hat, fine) + + if hasattr(type(F), 'components'): + for comp in F.components: + _prolong(G.__getattr__(comp), F.__getattr__(comp)) + elif type(G).__name__ == 'mesh': + _prolong(G, F) + else: raise TransferError('Unknown data type, got %s' % type(G)) diff --git a/coverage/class_index.html b/coverage/class_index.html index 1928e5f341..6146027b8c 100644 --- a/coverage/class_index.html +++ b/coverage/class_index.html @@ -11,7 +11,7 @@

Coverage report: - 80% + 81%

@@ -1595,10 +1595,10 @@

pySDC/implementations/problem_classes/Brusselator.py Brusselator - 34 + 35 6 22 - 82% + 83% pySDC/implementations/problem_classes/Brusselator.py @@ -1835,30 +1835,30 @@

pySDC/implementations/problem_classes/GrayScott_MPIFFT.py grayscott_imex_diffusion - 53 + 54 0 0 - 100% + 100% - pySDC/implementations/problem_classes/GrayScott_MPIFFT.py - grayscott_imex_linear + pySDC/implementations/problem_classes/GrayScott_MPIFFT.py + grayscott_imex_linear 25 0 0 100% - pySDC/implementations/problem_classes/GrayScott_MPIFFT.py - grayscott_mi_diffusion + pySDC/implementations/problem_classes/GrayScott_MPIFFT.py + grayscott_mi_diffusion 80 2 1 98% - pySDC/implementations/problem_classes/GrayScott_MPIFFT.py - grayscott_mi_linear + pySDC/implementations/problem_classes/GrayScott_MPIFFT.py + grayscott_mi_linear 80 2 1 @@ -2723,10 +2723,10 @@

pySDC/implementations/sweeper_classes/imex_1st_order.py imex_1st_order - 62 + 63 1 2 - 98% + 98% pySDC/implementations/sweeper_classes/imex_1st_order.py @@ -2833,36 +2833,36 @@

100% - pySDC/implementations/transfer_classes/TransferMesh.py - mesh_to_mesh - 135 - 90 - 8 - 33% + pySDC/implementations/transfer_classes/TransferMesh.py + mesh_to_mesh + 92 + 25 + 10 + 73% pySDC/implementations/transfer_classes/TransferMesh.py (no class) - 10 + 9 0 0 - 100% + 100% - pySDC/implementations/transfer_classes/TransferMesh_FFT.py - mesh_to_mesh_fft - 33 - 33 + pySDC/implementations/transfer_classes/TransferMesh_FFT.py + mesh_to_mesh_fft + 23 + 0 2 - 0% + 100% pySDC/implementations/transfer_classes/TransferMesh_FFT.py (no class) - 8 - 8 + 7 0 - 0% + 0 + 100% pySDC/implementations/transfer_classes/TransferMesh_FFT2D.py @@ -2883,10 +2883,10 @@

pySDC/implementations/transfer_classes/TransferMesh_MPIFFT.py fft_to_fft - 64 - 24 - 2 - 62% + 58 + 8 + 4 + 86% pySDC/implementations/transfer_classes/TransferMesh_MPIFFT.py @@ -5309,10 +5309,10 @@

Total   - 17230 - 3389 - 1760 - 80% + 17172 + 3267 + 1764 + 81% @@ -5325,7 +5325,7 @@

coverage.py v7.5.0, - created at 2024-04-26 10:16 +0000 + created at 2024-04-27 18:43 +0000

diff --git a/coverage/z_020efe120a771d8a_hamiltonian_and_energy_output_py.html b/coverage/z_020efe120a771d8a_hamiltonian_and_energy_output_py.html index 30c9af6e3d..379cef2e70 100644 --- a/coverage/z_020efe120a771d8a_hamiltonian_and_energy_output_py.html +++ b/coverage/z_020efe120a771d8a_hamiltonian_and_energy_output_py.html @@ -65,7 +65,7 @@

» next       coverage.py v7.5.0, - created at 2024-04-26 10:16 +0000 + created at 2024-04-27 18:43 +0000

diff --git a/coverage/z_020efe120a771d8a_hamiltonian_output_py.html b/coverage/z_020efe120a771d8a_hamiltonian_output_py.html index 8a9af2be84..98ca7228f6 100644 --- a/coverage/z_020efe120a771d8a_hamiltonian_output_py.html +++ b/coverage/z_020efe120a771d8a_hamiltonian_output_py.html @@ -65,7 +65,7 @@

» next       coverage.py v7.5.0, - created at 2024-04-26 10:16 +0000 + created at 2024-04-27 18:43 +0000

diff --git a/coverage/z_020efe120a771d8a_harmonic_oscillator_py.html b/coverage/z_020efe120a771d8a_harmonic_oscillator_py.html index 125aa08f22..f0586dd65b 100644 --- a/coverage/z_020efe120a771d8a_harmonic_oscillator_py.html +++ b/coverage/z_020efe120a771d8a_harmonic_oscillator_py.html @@ -65,7 +65,7 @@

» next       coverage.py v7.5.0, - created at 2024-04-26 10:16 +0000 + created at 2024-04-27 18:43 +0000

diff --git a/coverage/z_020efe120a771d8a_simple_problems_py.html b/coverage/z_020efe120a771d8a_simple_problems_py.html index ad72af6b02..c82d297410 100644 --- a/coverage/z_020efe120a771d8a_simple_problems_py.html +++ b/coverage/z_020efe120a771d8a_simple_problems_py.html @@ -65,7 +65,7 @@

» next       coverage.py v7.5.0, - created at 2024-04-26 10:16 +0000 + created at 2024-04-27 18:43 +0000

diff --git a/coverage/z_020efe120a771d8a_solar_system_py.html b/coverage/z_020efe120a771d8a_solar_system_py.html index ffca91c7c6..ee7577b5d6 100644 --- a/coverage/z_020efe120a771d8a_solar_system_py.html +++ b/coverage/z_020efe120a771d8a_solar_system_py.html @@ -65,7 +65,7 @@

» next       coverage.py v7.5.0, - created at 2024-04-26 10:16 +0000 + created at 2024-04-27 18:43 +0000

diff --git a/coverage/z_020efe120a771d8a_stop_at_error_hook_py.html b/coverage/z_020efe120a771d8a_stop_at_error_hook_py.html index 3da3a7210a..2a15597ed0 100644 --- a/coverage/z_020efe120a771d8a_stop_at_error_hook_py.html +++ b/coverage/z_020efe120a771d8a_stop_at_error_hook_py.html @@ -65,7 +65,7 @@

» next       coverage.py v7.5.0, - created at 2024-04-26 10:16 +0000 + created at 2024-04-27 18:43 +0000

diff --git a/coverage/z_04cb75334c2a5eef_data_management_py.html b/coverage/z_04cb75334c2a5eef_data_management_py.html index ea1a8f2269..ab4aba07b9 100644 --- a/coverage/z_04cb75334c2a5eef_data_management_py.html +++ b/coverage/z_04cb75334c2a5eef_data_management_py.html @@ -65,7 +65,7 @@

» next       coverage.py v7.5.0, - created at 2024-04-26 10:16 +0000 + created at 2024-04-27 18:43 +0000

diff --git a/coverage/z_064a9f2a35945611_FaultHooks_py.html b/coverage/z_064a9f2a35945611_FaultHooks_py.html index e745f03db1..60d0aad458 100644 --- a/coverage/z_064a9f2a35945611_FaultHooks_py.html +++ b/coverage/z_064a9f2a35945611_FaultHooks_py.html @@ -65,7 +65,7 @@

» next       coverage.py v7.5.0, - created at 2024-04-26 10:16 +0000 + created at 2024-04-27 18:43 +0000

diff --git a/coverage/z_064a9f2a35945611_generate_statistics_py.html b/coverage/z_064a9f2a35945611_generate_statistics_py.html index 822798692a..7ee01af57e 100644 --- a/coverage/z_064a9f2a35945611_generate_statistics_py.html +++ b/coverage/z_064a9f2a35945611_generate_statistics_py.html @@ -65,7 +65,7 @@

» next       coverage.py v7.5.0, - created at 2024-04-26 10:16 +0000 + created at 2024-04-27 18:43 +0000

diff --git a/coverage/z_064a9f2a35945611_implicit_sweeper_faults_py.html b/coverage/z_064a9f2a35945611_implicit_sweeper_faults_py.html index 5e145fc442..95e9872ed2 100644 --- a/coverage/z_064a9f2a35945611_implicit_sweeper_faults_py.html +++ b/coverage/z_064a9f2a35945611_implicit_sweeper_faults_py.html @@ -65,7 +65,7 @@

» next       coverage.py v7.5.0, - created at 2024-04-26 10:16 +0000 + created at 2024-04-27 18:43 +0000

diff --git a/coverage/z_064a9f2a35945611_visualization_helper_py.html b/coverage/z_064a9f2a35945611_visualization_helper_py.html index 455f1bbd3e..763913a164 100644 --- a/coverage/z_064a9f2a35945611_visualization_helper_py.html +++ b/coverage/z_064a9f2a35945611_visualization_helper_py.html @@ -65,7 +65,7 @@

» next       coverage.py v7.5.0, - created at 2024-04-26 10:16 +0000 + created at 2024-04-27 18:43 +0000