FourierFlows.jl
FourierFlows.jl copied to clipboard
Mix-match variables of different dimensions
We should have the ability to solve coupled equations that involve variables of different dimensionality.
E.g., variables φ₁(x, t), φ₂(x, y, t) that evolve under
∂φ₁/∂t = - φ₁ + ∫φ₂(x, y', t) dy ∂φ₂/∂t = - φ₂ + f(x, y, t)
A proper field abstraction might solve this problem.
Should we do it? Do you have the capability @glwagner? Isn't there any good compelling alternative shortcut to that?
I think it depends on the question here. If you're just trying to use the FourierFlows time-steppers then you don't need a Field abstraction. You could possibly support tuples of variables / RHS for the purpose of time-stepping, and then let module-writers handle broadcasting properly within calcN!.
As far as I can tell, you can implement support for tuples of solutions by dispatching on the time-stepper, eg:
https://github.com/FourierFlows/FourierFlows.jl/blob/20a68daaa00ffb2d88d95935f6efff4d86e378e7/src/timesteppers.jl#L107-L113
for when sol::NamedTuple.
The difference is between
@. sol += clock.dt * (eq.L * sol + ts.N)
and
for (i, sol) in enumerate(sol_tuple)
@. sol += clock.dt * (eq.L[i] * sol + ts.N[i])
end
so we need to dispatch separately for every time stepper?
I don't know. It seems the simplest solution, unless you can figure out how to "double broadcast" these arithmetic operations.
Basically you're asking whether you can write an operation so it does the same thing for
a = rand(3, 3)
b = rand(3, 3)
very_general_arithmetic(a, b)
or
c = (x=rand(3, 3), y=rand(3, 3))
d = (x=rand(3, 3), y=rand(3, 3))
very_general_arithmetic(c, d)
such an abstraction is possible for sure. But you'd have to design a new type (not vanilla NamedTuple) and define the appropriate broadcasting behavior using Julia's broadcasting interface to get that to work with existing arithmetic operators, I think.
OK, dispatching each time stepper would be good enough for now :) I'll draft a PR...
You also don't have to support every single time-stepper at first. Can support just 1 or 2 and experiment with the interface, and then when we're happy that it makes sense generalize.
Yes of course! Let's start with sane ForwardEuler :)