agdestein / IncompressibleNavierStokes.jl

Incompressible Navier-Stokes solver
https://agdestein.github.io/IncompressibleNavierStokes.jl/dev/
MIT License
48 stars 13 forks source link

Question: how can one save the entire history of the solution obtained via `solve_unsteady` #73

Closed luisaforozco closed 3 months ago

luisaforozco commented 3 months ago

I am using solve_unsteady and wanted to get the entire history solution of u, however, when defining the processor fieldsaver I get an error. Here the code that I am trying to run and the error:

import IncompressibleNavierStokes as INS

Re = 1000.0
n = 256
lims = (0, 1)
x, y = LinRange(lims..., n + 1), LinRange(lims..., n + 1)
setup = INS.Setup(x, y; Re);
ustart = INS.random_field(setup, 0.0);
trange = (0.0, 10.0)
dt = 1e-3

using GLMakie # not really necessary since we are not plotting
state, outputs = INS.solve_unsteady(;
    setup, ustart, tlims = trange, Δt = dt,
    processors = (
        field = INS.fieldsaver(; setup, nupdate=1), # This is what I thought could save the fields
        log = INS.timelogger(; nupdate = 100)
    )
);

Error:

ERROR: type NamedTuple has no field p
Stacktrace:
 [1] getproperty
   @ ./Base.jl:37 [inlined]
 [2] (::IncompressibleNavierStokes.var"#383#385"{…})(::@NamedTuple{…})
   @ IncompressibleNavierStokes ~/.julia/packages/IncompressibleNavierStokes/4GtDC/src/processors.jl:144
 [3] #invokelatest#2
   @ ./essentials.jl:892 [inlined]
 [4] invokelatest
   @ ./essentials.jl:889 [inlined]
 [5] notify
   @ ~/.julia/packages/Observables/YdEbO/src/Observables.jl:206 [inlined]
 [6] setindex!(observable::Observable, val::Any)
   @ Observables ~/.julia/packages/Observables/YdEbO/src/Observables.jl:123
 [7] solve_unsteady(; setup::@NamedTuple{…}, tlims::Tuple{…}, ustart::Tuple{…}, tempstart::Nothing, method::IncompressibleNavierStokes.ExplicitRungeKuttaMethod{…}, psolver::Function, Δt::Float64, cfl::Int64, n_adapt_Δt::Int64, docopy::Bool, processors::@NamedTuple{…}, θ::Nothing)
   @ IncompressibleNavierStokes ~/.julia/packages/IncompressibleNavierStokes/4GtDC/src/solvers/solve_unsteady.jl:87

I suspect this can come from this unpacking of the state that expects p but in my case we do not calculate/need the pressure explicitly.

I am open to help investigating this further if necessary, thanks!

agdestein commented 3 months ago

Thanks! It should be fixed by https://github.com/agdestein/IncompressibleNavierStokes.jl/pull/74

luisaforozco commented 3 months ago

Thanks @agdestein I tried locally and it works 🚀 I am closing this issue.