diff --git a/CHANGELOG.md b/CHANGELOG.md index dabd8e390..d78496ad9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ solve!(solution,inival, system::VoronoiFVM.AbstractSystem; kwargs...) ```` - History is now a field of the solution but not system, to be accessed with ``history(sol)``, both for stationary and transient solutions + - [`VoronoiFVM.Physics`](@ref) callbacks (`flux`, `storage`, etc.) need a provided `data` argument + ### Added - Introduced ``SystemState`` which contains entries (matrix, residuals) which before were part of ``System`` @@ -19,7 +21,7 @@ - Stationary solutions are now subtypes of AbstractNoTimeSolution - Changelog now in package root -## upcoming release +## v1.25.0, Sept 9, 2024 - [`VoronoiFVM.Physics`](@ref) callbacks (`flux`, `storage`, etc.) without `data` argument are now deprecated ## v1.24.0 August 20, 2024 diff --git a/src/vfvm_physics.jl b/src/vfvm_physics.jl index 693c76c22..38ca78ae7 100644 --- a/src/vfvm_physics.jl +++ b/src/vfvm_physics.jl @@ -60,14 +60,6 @@ function nofunc_generic_sparsity(sys) end -# -# Dummy data type that represents data or not -# We need this for the `data` deprecation phase -# -@kwdef mutable struct MaybeData - isdata=false -end - ########################################################## """ ```` @@ -200,7 +192,6 @@ end ########################################################## isdata(::Nothing) = false -isdata(d::MaybeData) = d.isdata isdata(::Any) = true """ @@ -224,7 +215,7 @@ Physics(;num_species=0, Constructor for physics data. For the meaning of the optional keyword arguments, see [`VoronoiFVM.System(grid::ExtendableGrid; kwargs...)`](@ref). """ function Physics(; num_species = 0, - data = MaybeData(isdata=false), + data = nothing, flux::Function = nofunc, reaction::Function = nofunc, edgereaction::Function = nofunc, @@ -239,30 +230,6 @@ function Physics(; num_species = 0, generic::Function = nofunc_generic, generic_sparsity::Function = nofunc_generic_sparsity, kwargs...) - if !isdata(data) - # deprecation check: callbacks without a `data` argument are not supported in future versions - callbacks = [flux, reaction, edgereaction, storage, source, bflux, breaction, bsource, bstorage, boutflow] - callbacks_seem_fine = true - for f in callbacks - # ignore dummy functions - if !(f in [nofunc, default_storage, nosrc]) - # check whether the callbacks have a method with 3 or 4 arguments, respectively - nn = nothing - if ( f in [flux, reaction, edgereaction, storage, bflux, breaction, bstorage, boutflow] && applicable(f,nn,nn,nn) ) || - ( f in [source, bsource] && applicable(f,nn,nn) ) - @warn "using VoronoiFVM.Physics callback $(nameof(f)) without a `data` argument is now deprecated" - callbacks_seem_fine = false - end - end - end - - # it looks like all callbacks can be called with a `data` argument ⇒ enable a dummy data attribute - if callbacks_seem_fine - data.isdata = true - end - - end - return Physics(flux, storage, reaction, @@ -376,36 +343,18 @@ function ResEvaluator(physics, data, symb::Symbol, uproto::Vector{Tv}, geom, nsp # source functions need special handling here if symb == :source || symb == :bsource - if isdata(physics.data) - fwrap = function (y) - y .= 0 - func(rhs(geom, y), geom, data) - nothing - end - else - fwrap = function (y) - y .= 0 - func(rhs(geom, y), geom) - nothing - end + fwrap = function (y) + y .= 0 + func(rhs(geom, y), geom, data) + nothing end else # Normal functions wihth u as parameter - if isdata(physics.data) - fwrap = function (y, u) - y .= 0 - ## for ii in .. uu[geom.speclist[ii]]=u[ii] - func(rhs(geom, y), unknowns(geom, u), geom, data) - ## for ii in .. y[ii]=y[geom.speclist[ii]] - nothing - end - else - fwrap = function (y, u) - y .= 0 - ## for ii in .. uu[geom.speclist[ii]]=u[ii] - func(rhs(geom, y), unknowns(geom, u), geom) - ## for ii in .. y[ii]=y[geom.speclist[ii]] - nothing - end + fwrap = function (y, u) + y .= 0 + ## for ii in .. uu[geom.speclist[ii]]=u[ii] + func(rhs(geom, y), unknowns(geom, u), geom, data) + ## for ii in .. y[ii]=y[geom.speclist[ii]] + nothing end end isnontrivial = (func != nofunc) @@ -478,22 +427,12 @@ Constructor for ResJEvaluator function ResJacEvaluator(physics, data, symb::Symbol, uproto::Vector{Tv}, geom, nspec) where {Tv} func = getproperty(physics, symb) - if isdata(physics.data) - fwrap = function (y, u) - y .= 0 - ## for ii in .. uu[geom.speclist[ii]]=u[ii] - func(rhs(geom, y), unknowns(geom, u), geom, data) - ## for ii in .. y[ii]=y[geom.speclist[ii]] - nothing - end - else - fwrap = function (y, u) - y .= 0 - ## for ii in .. uu[geom.speclist[ii]]=u[ii] - func(rhs(geom, y), unknowns(geom, u), geom) - ## for ii in .. y[ii]=y[geom.speclist[ii]] - nothing - end + fwrap = function (y, u) + y .= 0 + ## for ii in .. uu[geom.speclist[ii]]=u[ii] + func(rhs(geom, y), unknowns(geom, u), geom, data) + ## for ii in .. y[ii]=y[geom.speclist[ii]] + nothing end isnontrivial = (func != nofunc) diff --git a/src/vfvm_postprocess.jl b/src/vfvm_postprocess.jl index c20e85e6c..5777ea90f 100644 --- a/src/vfvm_postprocess.jl +++ b/src/vfvm_postprocess.jl @@ -23,10 +23,6 @@ function integrate(system::AbstractSystem{Tv, Tc, Ti, Tm}, F::Function, U::Abstr if boundary bnode = BNode(system) - bnodeparams = (bnode,) - if isdata(data) - bnodeparams = (bnode, data) - end #!!! bnode.time=time #!!! bnode.embedparam=embedparam @@ -38,17 +34,13 @@ function integrate(system::AbstractSystem{Tv, Tc, Ti, Tm}, F::Function, U::Abstr for ibnode in noderange(system.boundary_assembly_data, item) _fill!(bnode, system.boundary_assembly_data, ibnode, item) res .= zero(Tv) - @views F(rhs(bnode, res), unknowns(bnode, U[:, bnode.index]), bnodeparams...) + @views F(rhs(bnode, res), unknowns(bnode, U[:, bnode.index]), bnode, data) asm_res(idof, ispec) = integral[ispec, bnode.region] += bnode.fac * res[ispec] assemble_res(bnode, system, asm_res) end end else node = Node(system) - nodeparams = (node,) - if isdata(data) - nodeparams = (node, data) - end #!!! node.time=time #!!! node.embedparam=embedparam cellregions = grid[CellRegions] @@ -58,7 +50,7 @@ function integrate(system::AbstractSystem{Tv, Tc, Ti, Tm}, F::Function, U::Abstr for inode in noderange(system.assembly_data, item) _fill!(node, system.assembly_data, inode, item) res .= zero(Tv) - @views F(rhs(node, res), unknowns(node, U[:, node.index]), nodeparams...) + @views F(rhs(node, res), unknowns(node, U[:, node.index]), node, data) asm_res(idof, ispec) = integral[ispec, node.region] += node.fac * res[ispec] assemble_res(node, system, asm_res) end @@ -104,10 +96,6 @@ function edgeintegrate(system::AbstractSystem{Tv, Tc, Ti, Tm}, F::Function, U::A error("missing implementation of boundary edge integrals") else edge = Edge(system) - edgeparams = (edge,) - if isdata(data) - edgeparams = (edge, data) - end cellregions = grid[CellRegions] ncellregions = maximum(cellregions) integral = zeros(Tu, nspecies, ncellregions) @@ -117,7 +105,7 @@ function edgeintegrate(system::AbstractSystem{Tv, Tc, Ti, Tm}, F::Function, U::A @views UKL[1:nspecies] .= U[:, edge.node[1]] @views UKL[(nspecies + 1):(2 * nspecies)] .= U[:, edge.node[2]] res .= zero(Tv) - @views F(rhs(edge, res), unknowns(edge, UKL), edgeparams...) + @views F(rhs(edge, res), unknowns(edge, UKL), edge, data) function asm_res(idofK, idofL, ispec) h = meas(edge) # This corresponds to the multiplication with the diamond volume. diff --git a/src/vfvm_system.jl b/src/vfvm_system.jl index c0b7cfb70..e75fd511f 100644 --- a/src/vfvm_system.jl +++ b/src/vfvm_system.jl @@ -975,11 +975,7 @@ function _initialize_dirichlet!(U::AbstractMatrix, system::AbstractSystem{Tv, Tc # set up bnode bnode = BNode(system, time, λ, params) - bnodeparams = (bnode,) data = system.physics.data - if isdata(data) - bnodeparams = (bnode, data) - end # setup unknowns to be passed UK = zeros(Tv, num_species(system) + length(params)) @@ -999,7 +995,7 @@ function _initialize_dirichlet!(U::AbstractMatrix, system::AbstractSystem{Tv, Tc bnode.dirichlet_value .= Inf # set up solution vector, call boundary reaction @views UK[1:nspecies] .= U[:, bnode.index] - system.physics.breaction(y, u, bnodeparams...) + system.physics.breaction(y, u, bnode, data) # Check for Dirichlet bc for ispec = 1:nspecies