Mercurial > repos > public > sbplib_julia
comparison src/Grids/curvilinear_grid.jl @ 1430:9fc3c1af33e5 feature/grids/curvilinear
Add testsets and a few tests
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Wed, 26 Jul 2023 21:00:44 +0200 |
parents | 9c689a627244 |
children | 6adf31ba6cfd |
comparison
equal
deleted
inserted
replaced
1429:e87f3465b770 | 1430:9fc3c1af33e5 |
---|---|
1 struct CurvilinearGrid end | 1 struct CurvilinearGrid{T,D, GT<:Grid{<:Any,D}, CT<:AbstractArray{T,D}, JT<:AbstractArray{<:AbstractArray{<:Any, 2}, D}} <: Grid{T,D} |
2 logicalgrid::GT | |
3 physicalcoordinates::CT | |
4 Jacobian::JT | |
5 end | |
6 | |
7 | |
8 # Indexing interface | |
9 Base.getindex(g::CurvilinearGrid, I...) = g.physicalcoordinates[I...] | |
10 | |
11 # function Base.getindex(g::TensorGrid, I...) | |
12 # szs = ndims.(g.grids) | |
13 | |
14 # Is = LazyTensors.split_tuple(I, szs) | |
15 # ps = map((g,I)->SVector(g[I...]), g.grids, Is) | |
16 | |
17 # return vcat(ps...) | |
18 # end | |
19 | |
20 # function Base.eachindex(g::TensorGrid) | |
21 # szs = LazyTensors.concatenate_tuples(size.(g.grids)...) | |
22 # return CartesianIndices(szs) | |
23 # end | |
24 | |
25 # # Iteration interface | |
26 # Base.iterate(g::TensorGrid) = iterate(Iterators.product(g.grids...)) |> _iterate_combine_coords | |
27 # Base.iterate(g::TensorGrid, state) = iterate(Iterators.product(g.grids...), state) |> _iterate_combine_coords | |
28 # _iterate_combine_coords(::Nothing) = nothing | |
29 # _iterate_combine_coords((next,state)) = combine_coordinates(next...), state | |
30 | |
31 # Base.IteratorSize(::Type{<:TensorGrid{<:Any, D}}) where D = Base.HasShape{D}() | |
32 # Base.eltype(::Type{<:TensorGrid{T}}) where T = T | |
33 # Base.length(g::TensorGrid) = sum(length, g.grids) | |
34 # Base.size(g::TensorGrid) = LazyTensors.concatenate_tuples(size.(g.grids)...) | |
35 | |
36 | |
37 # refine(g::TensorGrid, r::Int) = mapreduce(g->refine(g,r), TensorGrid, g.grids) | |
38 # coarsen(g::TensorGrid, r::Int) = mapreduce(g->coarsen(g,r), TensorGrid, g.grids) | |
39 | |
40 # """ | |
41 # TensorGridBoundary{N, BID} <: BoundaryIdentifier | |
42 | |
43 # A boundary identifier for a tensor grid. `N` Specifies which grid in the | |
44 # tensor product and `BID` which boundary on that grid. | |
45 # """ | |
46 # struct TensorGridBoundary{N, BID} <: BoundaryIdentifier end | |
47 # grid_id(::TensorGridBoundary{N, BID}) where {N, BID} = N | |
48 # boundary_id(::TensorGridBoundary{N, BID}) where {N, BID} = BID() | |
49 | |
50 # """ | |
51 # boundary_identifiers(g::TensorGrid) | |
52 | |
53 # Returns a tuple containing the boundary identifiers of `g`. | |
54 # """ | |
55 # function boundary_identifiers(g::TensorGrid) | |
56 # per_grid = map(eachindex(g.grids)) do i | |
57 # return map(bid -> TensorGridBoundary{i, typeof(bid)}(), boundary_identifiers(g.grids[i])) | |
58 # end | |
59 # return LazyTensors.concatenate_tuples(per_grid...) | |
60 # end | |
61 | |
62 | |
63 # """ | |
64 # boundary_grid(g::TensorGrid, id::TensorGridBoundary) | |
65 | |
66 # The grid for the boundary of `g` specified by `id`. | |
67 # """ | |
68 # function boundary_grid(g::TensorGrid, id::TensorGridBoundary) | |
69 # local_boundary_grid = boundary_grid(g.grids[grid_id(id)], boundary_id(id)) | |
70 # new_grids = Base.setindex(g.grids, local_boundary_grid, grid_id(id)) | |
71 # return TensorGrid(new_grids...) | |
72 # end | |
73 | |
74 | |
75 | |
76 | |
77 | |
78 | |
79 | |
80 | |
81 # Do we add a convenience function `curvilinear_grid`? It could help with | |
82 # creating the logical grid, evaluating functions and possibly calculating the | |
83 # entries in the jacobian. | |
84 |