|
17 | 17 | from dedalus.core.field import Field |
18 | 18 |
|
19 | 19 |
|
| 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 | +# ----------------------------------------------------------------------------- |
20 | 74 | def State(cls, fields): |
21 | 75 | return [f.copy() for f in fields] |
22 | 76 |
|
|
0 commit comments