Skip to content

Commit cadb312

Browse files
committed
added data types to problem classes (WIP)
1 parent 0f25135 commit cadb312

32 files changed

+229
-327
lines changed

pySDC/core/Step.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,12 @@ def __generate_hierarchy(self, descr):
8585
descr (dict): dictionary containing the description of the levels as list per key
8686
"""
8787

88-
assert 'dtype_u' not in descr
89-
assert 'dtype_f' not in descr
88+
if 'dtype_u' in descr:
89+
raise ParameterError('Deprecated parameter dtype_u, please remove from description dictionary and specify'
90+
'directly in the problem class')
91+
if 'dtype_f' in descr:
92+
raise ParameterError('Deprecated parameter dtype_f, please remove from description dictionary and specify'
93+
'directly in the problem class')
9094

9195
# assert the existence of all the keys we need to set up at least on level
9296
essential_keys = ['problem_class', 'sweeper_class', 'sweeper_params', 'level_params']

pySDC/implementations/problem_classes/AcousticAdvection_1D_FD_imex.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import numpy as np
22
from scipy.sparse.linalg import spsolve
33

4+
from pySDC.implementations.datatype_classes.mesh import mesh, rhs_imex_mesh
5+
46
from pySDC.implementations.problem_classes.acoustic_helpers.buildWave1DMatrix import getWave1DMatrix, \
57
getWave1DAdvectionMatrix
68
from pySDC.core.Problem import ptype
@@ -22,7 +24,7 @@ class acoustic_1d_imex(ptype):
2224
2325
"""
2426

25-
def __init__(self, problem_params, dtype_u, dtype_f):
27+
def __init__(self, problem_params, dtype_u=mesh, dtype_f=rhs_imex_mesh):
2628
"""
2729
Initialization routine
2830

pySDC/implementations/problem_classes/AdvectionDiffusionEquation_1D_FFT.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import numpy as np
22
import pyfftw
33

4+
from pySDC.implementations.datatype_classes.mesh import mesh, rhs_imex_mesh
5+
46
from pySDC.core.Problem import ptype
57
from pySDC.core.Errors import ParameterError, ProblemError
68

@@ -19,14 +21,14 @@ class advectiondiffusion1d_imex(ptype):
1921
irfft_object: planned IFFT for backward transformation, real-valued output
2022
"""
2123

22-
def __init__(self, problem_params, dtype_u, dtype_f):
24+
def __init__(self, problem_params, dtype_u=mesh, dtype_f=rhs_imex_mesh):
2325
"""
2426
Initialization routine
2527
2628
Args:
2729
problem_params (dict): custom parameters for the example
28-
dtype_u: mesh data type (will be passed parent class)
29-
dtype_f: mesh data type (will be passed parent class)
30+
dtype_u: mesh data type (will be passed to parent class)
31+
dtype_f: mesh data type with implicit and explicit component (will be passed to parent class)
3032
"""
3133

3234
if 'L' not in problem_params:
@@ -141,6 +143,20 @@ class advectiondiffusion1d_implicit(advectiondiffusion1d_imex):
141143
fully-implicit time-stepping
142144
"""
143145

146+
def __init__(self, problem_params, dtype_u=mesh, dtype_f=mesh):
147+
"""
148+
Initialization routine
149+
150+
Args:
151+
problem_params (dict): custom parameters for the example
152+
dtype_u: mesh data type (will be passed to parent class)
153+
dtype_f: mesh data type (will be passed to parent class)
154+
"""
155+
156+
# invoke super init, passing number of dofs, dtype_u and dtype_f
157+
super(advectiondiffusion1d_implicit, self).__init__(problem_params=problem_params, dtype_u=dtype_u,
158+
dtype_f=dtype_f)
159+
144160
def eval_f(self, u, t):
145161
"""
146162
Routine to evaluate the RHS

pySDC/implementations/problem_classes/AdvectionDiffusion_1D_FEniCS_matrix_periodic.py

Lines changed: 0 additions & 215 deletions
This file was deleted.

pySDC/implementations/problem_classes/AdvectionEquation_1D_FD.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import scipy.sparse as sp
33
from scipy.sparse.linalg import splu
44

5+
from pySDC.implementations.datatype_classes.mesh import mesh
6+
57
from pySDC.core.Problem import ptype
68
from pySDC.core.Errors import ParameterError, ProblemError
79

@@ -17,7 +19,7 @@ class advection1d(ptype):
1719
dx: distance between two spatial nodes
1820
"""
1921

20-
def __init__(self, problem_params, dtype_u, dtype_f):
22+
def __init__(self, problem_params, dtype_u=mesh, dtype_f=mesh):
2123
"""
2224
Initialization routine
2325

pySDC/implementations/problem_classes/AdvectionEquation_1D_FD_dirichlet.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import scipy.sparse as sp
33
from scipy.sparse.linalg import splu
44

5+
from pySDC.implementations.datatype_classes.mesh import mesh
6+
57
from pySDC.core.Problem import ptype
68
from pySDC.core.Errors import ParameterError, ProblemError
79

@@ -17,7 +19,7 @@ class advection1d_dirichlet(ptype):
1719
dx: distance between two spatial nodes
1820
"""
1921

20-
def __init__(self, problem_params, dtype_u, dtype_f):
22+
def __init__(self, problem_params, dtype_u=mesh, dtype_f=mesh):
2123
"""
2224
Initialization routine
2325

0 commit comments

Comments
 (0)