Skip to content

Commit

Permalink
Merge pull request #146 from WIAS-PDELib/fix/show_physics
Browse files Browse the repository at this point in the history
Fix/show physics
  • Loading branch information
j-fu authored Nov 16, 2024
2 parents 86ff2cf + a62c891 commit b386621
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 34 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
- Try to remove type piracies
- Remove `params` from edge, node structs (appearantly never used)

## v2.5.0 November 17, 2024
- update show methods for physics, grid

## v2.4.0 November 11, 2024
- Use `precs` based linear solver API, see https://github.com/SciML/LinearSolve.jl/pull/514 with ExtendableSparse 1.6
- Deprecate VoronoiFVM solver strategies
Expand Down
6 changes: 4 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "VoronoiFVM"
uuid = "82b139dc-5afc-11e9-35da-9b9bdfd336f3"
authors = ["Jürgen Fuhrmann <[email protected]>", "Patrick Jaap", "Daniel Runge", "Dilara Abdel", "Jan Weidner", "Alexander Seiler", "Patricio Farrell", "Matthias Liero"]
version = "2.4.0"
version = "2.5.0"

[deps]
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
Expand All @@ -27,6 +27,7 @@ SparseDiffTools = "47a9eef4-7e08-11e9-0b38-333d64bd3804"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
TextWrap = "b718987f-49a8-5099-9789-dcd902bef87d"

[weakdeps]
ExtendableFEMBase = "12fb9182-3d4c-4424-8fd1-727a0899810c"
Expand All @@ -41,7 +42,7 @@ CommonSolve = "0.2"
DiffResults = "1"
DocStringExtensions = "0.8,0.9"
ExtendableFEMBase = "0.7,0.8"
ExtendableGrids = "1.10.1"
ExtendableGrids = "1.11.0"
ExtendableSparse = "1.6"
ForwardDiff = "0.10.35"
GridVisualize = "0.5.2,0.6.1,1"
Expand All @@ -59,4 +60,5 @@ SparseDiffTools = "^1.19, 2"
StaticArrays = "0.12,1"
Statistics = "1.9"
Symbolics = "4.2,5,6"
TextWrap= "1.0.2"
julia = "1.9"
2 changes: 1 addition & 1 deletion src/VoronoiFVM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ using SparseDiffTools: SparseDiffTools, forwarddiff_color_jacobian!,
using StaticArrays: StaticArrays, @MVector, @SArray, @SMatrix
using Statistics: Statistics, mean
using Symbolics: Symbolics

using TextWrap: print_wrapped

"""
$(TYPEDEF)
Expand Down
49 changes: 22 additions & 27 deletions src/vfvm_physics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,13 @@ Re-exported from ForwardDiff.
#
# Dummy callbacks
#
function nofunc(f, u, node, data=nothing)
end
function nofunc(args...) end

function nosrc(f, node, data=nothing)
end

function default_storage(f, u, node, data=nothing)
function default_storage(f, u, node, data)
f .= u
end

function nofunc_generic(f, u, sys)
end

function nofunc_generic_sparsity(sys)
end


##########################################################
"""
Expand Down Expand Up @@ -200,7 +191,7 @@ mutable struct Physics{Flux <: Function,
data::Data

"""
Number of species including boundary species.
Number of species including boundary species. Meaningless & deprecated.
"""
num_species::Int8
end
Expand Down Expand Up @@ -236,15 +227,15 @@ function Physics(; num_species = 0,
reaction::Function = nofunc,
edgereaction::Function = nofunc,
storage::Function = default_storage,
source::Function = nosrc,
source::Function = nofunc,
bflux::Function = nofunc,
breaction::Function = nofunc,
bsource::Function = nosrc,
bsource::Function = nofunc,
bstorage::Function = nofunc,
boutflow::Function = nofunc,
outflowboundaries::Vector{Int} = Int[],
generic::Function = nofunc_generic,
generic_sparsity::Function = nofunc_generic_sparsity,
generic::Function = nofunc,
generic_sparsity::Function = nofunc,
kwargs...)
return Physics(flux,
storage,
Expand Down Expand Up @@ -296,23 +287,27 @@ $(SIGNATURES)
Show physics object
"""
function Base.show(io::IO, physics::AbstractPhysics)
str = @sprintf("VoronoiFVM.Physics(num_species=%d", physics.num_species)
str = "Physics("
if isdata(physics.data)
str = str * ", data=$(typeof(physics.data))"
end
function addfunc(func, name)
if func != nofunc
str = str * ", $(name)=$(nameof(func))"
end
str = str * "data=$(typeof(physics.data)), "
end


# function addfunc(func, name)
# if func != nofunc
# str = str * ", $(name)=$(nameof(func))"
# end
# end

for name in fieldnames(typeof(physics))
if (name != :num_species) && (name != :data) && getfield(physics, name) != nofunc
str = str * ", $(name)=$(nameof(getfield(physics,name)))"
if (name != :num_species) && (name != :data) && (name != :outflowboundaries) && getfield(physics, name) != nofunc
str = str * "$(name)=$(nameof(getfield(physics,name))), "
end
end
if length(physics.outflowboundaries)>0
str=str * "outflowboundaries=$(physics.outflowboundaries)"
end
str = str * ")"
println(io, str)
print(io, str)
end

"""
Expand Down
9 changes: 5 additions & 4 deletions src/vfvm_system.jl
Original file line number Diff line number Diff line change
Expand Up @@ -996,13 +996,14 @@ function _initialize_inactive_dof!(U::DenseSolutionArray, system::DenseSystem)
end

function Base.show(io::IO, sys::AbstractSystem)
str = @sprintf("%s(num_species=%d)", typeof(sys), num_species(sys))
println(io, str)
str = "$(typeof(sys))(\n grid = $(sys.grid),\n physics = $(sys.physics),\n num_species = $(num_species(sys)))"
sz=displaysize(io)
print_wrapped(io, str; replace_whitespace=false, subsequent_indent=" ", width=sz[2])
end

#####################################################
has_generic_operator(sys::AbstractSystem) = sys.physics.generic_operator != nofunc_generic
has_generic_operator_sparsity(sys::AbstractSystem) = sys.physics.generic_operator_sparsity != nofunc_generic_sparsity
has_generic_operator(sys::AbstractSystem) = sys.physics.generic_operator != nofunc
has_generic_operator_sparsity(sys::AbstractSystem) = sys.physics.generic_operator_sparsity != nofunc

##################################################################
"""
Expand Down

2 comments on commit b386621

@j-fu
Copy link
Member Author

@j-fu j-fu commented on b386621 Nov 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/119580

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v2.5.0 -m "<description of version>" b386621b6fd3b3b26d718f471c72bc15c701d800
git push origin v2.5.0

Please sign in to comment.