Skip to content

Commit bb96543

Browse files
committed
TL: first tentative for a better pySDC coupling
1 parent 4a4cab0 commit bb96543

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
*.pdf
1+
*.pdf
2+
demos/*.png

pySDC/playgrounds/dedalus/interface/problem.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,60 @@
1717
from dedalus.core.field import Field
1818

1919

20+
# -----------------------------------------------------------------------------
21+
# Tentative for a cleaner interface between pySDC and Dedalus
22+
# -----------------------------------------------------------------------------
23+
class Tendencies(object):
24+
25+
def __init__(self):
26+
# TODO : constructor requirements ?
27+
# -> Step.init_step : copy of initial tendency with u[0] = P.dtype_u(u0)
28+
self.terms = []
29+
30+
def __iadd__(self, f:"Tendencies") -> "Tendencies":
31+
# TODO : inplace addition with other full tendencies
32+
pass
33+
34+
def axpy(self, a:float|list[float], x:"Tendencies") -> "Tendencies":
35+
if isinstance(a, float):
36+
# TODO : y += a*x when x contains all tendencies
37+
pass
38+
if isinstance(a, list):
39+
# TODO : y += a1*x1 + a2*x2 + ... when x1, x2 are each tendency
40+
# Note : if some a[i] are zeros, it should be a no-op
41+
pass
42+
raise ValueError("wrong type for a")
43+
44+
45+
class Solution(object):
46+
47+
def __init__(self, init=None, val=0.0):
48+
# TODO : constructor requirements ?
49+
pass
50+
51+
class DProblem(Problem):
52+
53+
dtype_u = Solution
54+
dtype_f = Tendencies
55+
56+
def eval_f(self, u:Solution, t:float, f:Tendencies) -> Tendencies:
57+
# TODO : inplace modify f with the tendencies evaluation
58+
pass
59+
60+
def solve_system(self, rhs:Tendencies, dt:float, u:Solution, t:float) -> Solution:
61+
# TODO : inplace modify u with the system solve
62+
# u + dt*f_I(u, t) = rhs
63+
# using u as initial solution for an eventual iterative solver
64+
pass
65+
66+
def apply_mass_matrix(self, u:Solution, rhs:Tendencies) -> Tendencies:
67+
# TODO : inplace evaluation in rhs of mass-matrix multiplication
68+
pass
69+
70+
71+
# -----------------------------------------------------------------------------
72+
# First interface
73+
# -----------------------------------------------------------------------------
2074
def State(cls, fields):
2175
return [f.copy() for f in fields]
2276

0 commit comments

Comments
 (0)