view src/Grids/multiblockgrids.jl @ 2025:d35a4cb170ff feature/grids/multiblock_grids

Add some notes and comments
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 10 Apr 2025 08:45:08 +0200
parents 3fb33f00dab2
children 1b6f150d95c5
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?

# function min_spacing end
# function refine end
# function coarsen 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?