Mercurial > repos > public > sbplib_julia
view src/Grids/multiblockgrids.jl @ 2026:1b6f150d95c5 feature/grids/multiblock_grids
Implement min_spacing, coarsen, refine
| author | Jonatan Werpers <jonatan@werpers.com> |
|---|---|
| date | Thu, 10 Apr 2025 16:20:22 +0200 |
| parents | d35a4cb170ff |
| children | 06f4b2ab43e8 |
line wrap: on
line source
struct MultiBlockGrid{T,D,GT, CT} <: Grid{T,D} grids::GT connections::CT end function MultiBlockGrid(grids, connections) T = eltype(valtype(grids)) D = ndims(valtype(grids)) MultiBlockGrid{T,D,typeof(grids), typeof(connections)}(grids,connections) end grids(g::MultiBlockGrid) = g.grids connections(g::MultiBlockGrid) = g.connections Base.getindex(g::MultiBlockGrid, I...) = g.grids[I...] # function boundary_identifiers end # Requires function from manifolds? # function boundary_grid end # Should return a MultiBlockGrid with the right connections? min_spacing(g::MultiBlockGrid) = minimum(min_spacing, grids(g)) function refine(g::MultiBlockGrid, n) gs = map(grids(g)) do gᵢ refine(gᵢ,n) end return MultiBlockGrid(gs, connections(g)) end function coarsen(g::MultiBlockGrid, n) gs = map(grids(g)) do gᵢ coarsen(gᵢ,n) end return MultiBlockGrid(gs, connections(g)) end # function boundary_indices end # Need to figure out the grid functions first? # function eval_on end # Need to figure out the grid functions first? # function Base.map end # Need to figure out the grid functions first? Should only have to implement the iterator interface # Plotting recipes """ MultiBlockBoundary{N, BID} <: BoundaryIdentifier A boundary identifier for a multiblock grids. `N` Specifies which grid and `BID` which boundary on that grid. """ struct MultiBlockBoundary{N, BID} <: BoundaryIdentifier end grid_id(::MultiBlockBoundary{N, BID}) where {N, BID} = N boundary_id(::MultiBlockBoundary{N, BID}) where {N, BID} = BID() function connection(k1, b1::BoundaryIdentifier, k2, b2::BoundaryIdentifier) return ( MultiBlockBoundary{k1,typeof(b1)}(), MultiBlockBoundary{k2,typeof(b2)}(), ) end connection(t::Tuple) = connection(t...) # Nested indices?? # motsvarande eachindex # Kolla notebooks med experiment # IteratorSize # nogot slags shape?
