Skip to content

Commit feff528

Browse files
committed
Drafting NonConformingGridTopology
1 parent a227644 commit feff528

File tree

4 files changed

+147
-0
lines changed

4 files changed

+147
-0
lines changed

Project.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
1414
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
1515
Gridap = "56d4f2e9-7ea1-5844-9cf6-b9c51ca7ce8e"
1616
GridapDistributed = "f9701e48-63b3-45aa-9a63-9bc6c271f355"
17+
GridapP4est = "c2c8e14b-f5fd-423d-9666-1dd9ad120af9"
1718
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1819
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
1920
MiniQhull = "978d7f02-9e05-4691-894f-ae31a51d76ca"
21+
P4est_wrapper = "3743d7c0-8adf-11ea-380b-7d33b0ecc1da"
2022
PartitionedArrays = "5a9dfac6-5c52-46f7-8278-5e2210713be9"
2123
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
2224
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
@@ -34,8 +36,10 @@ ForwardDiff = "0.10.38, 1"
3436
Graphs = "1.12.0"
3537
Gridap = "0.18.12, 0.19"
3638
GridapDistributed = "0.3, 0.4"
39+
GridapP4est = "0.3.11"
3740
MPI = "0.20"
3841
MiniQhull = "0.1.0, 0.2, 0.3, 0.4"
42+
P4est_wrapper = "0.2.4"
3943
PartitionedArrays = "0.3.4"
4044
julia = "1.3"
4145

test/dev/eric_dev.jl

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
module DistributedAggregationP4estMeshes
2+
3+
using Gridap
4+
using GridapEmbedded
5+
using GridapDistributed
6+
using PartitionedArrays
7+
using MPI
8+
9+
using P4est_wrapper
10+
using GridapP4est
11+
12+
using Gridap.Arrays: Table
13+
using Gridap.Geometry: get_grid_topology
14+
using Gridap.Geometry: get_faces
15+
16+
function run(distribute)
17+
18+
ranks = distribute(LinearIndices((MPI.Comm_size(MPI.COMM_WORLD),)))
19+
coarse_model = CartesianDiscreteModel((-1,1,-1,1),(1,1))
20+
num_uniform_refinements = 1
21+
num_ghost_layers = 2
22+
D = num_dims(coarse_model)
23+
24+
dmodel = OctreeDistributedDiscreteModel(ranks,
25+
coarse_model,
26+
num_uniform_refinements;
27+
num_ghost_layers=num_ghost_layers)
28+
29+
fmodel_refine_coarsen_flags =
30+
map(ranks,partition(get_cell_gids(dmodel.dmodel))) do rank,indices
31+
flags = zeros(Int,length(indices))
32+
flags .= nothing_flag
33+
flags[1] = refine_flag
34+
flags
35+
end
36+
fmodel,_ = Gridap.Adaptivity.adapt(dmodel,fmodel_refine_coarsen_flags);
37+
38+
map(local_views(fmodel)) do m
39+
gt = get_grid_topology(m)
40+
@show get_faces(gt,1,2)
41+
@show get_faces(gt,2,1)
42+
end
43+
44+
map(fmodel.non_conforming_glue) do ncg
45+
@show ncg.num_regular_faces
46+
@show ncg.num_hanging_faces
47+
@show ncg.hanging_faces_glue
48+
@show ncg.hanging_faces_to_cell
49+
@show ncg.hanging_faces_to_lface
50+
@show ncg.owner_faces_pindex
51+
@show ncg.owner_faces_lids
52+
end
53+
54+
cell_to_hanging_faces =
55+
map(local_views(fmodel),fmodel.non_conforming_glue) do m,ncg
56+
# hanging_face_to_owner_cell =
57+
# map(Broadcasting(first),ncg.hanging_faces_glue)
58+
# cell_to_hanging_faces_data =
59+
# map(sortperm,hanging_face_to_owner_cell)
60+
# cell_to_hanging_faces_data =
61+
# map(Broadcasting(+),cell_to_hanging_faces_data,ncg.num_regular_faces)
62+
63+
# Only for facets
64+
hanging_face_to_owner_cell = first.(ncg.hanging_faces_glue[D])
65+
cell_to_hanging_faces_data = sortperm(hanging_face_to_owner_cell)
66+
67+
cell_to_hanging_faces_ptr = zeros(Int32,num_cells(m)+1)
68+
owner_cells_ptr = unique(hanging_face_to_owner_cell) .+ 1
69+
# Alternatively, for owner_cells_ptr evaluate every 2^(D-1) entries
70+
# But with unique I can do it for every dimension
71+
72+
cell_to_hanging_faces_ptr[owner_cells_ptr] .= 2^(D-1)
73+
length_to_ptrs!(cell_to_hanging_faces_ptr)
74+
75+
cell_to_hanging_faces_data =
76+
cell_to_hanging_faces_data .+ ncg.num_regular_faces[D]
77+
78+
@show cell_to_hanging_faces_ptr
79+
@show cell_to_hanging_faces_data
80+
81+
Table(cell_to_hanging_faces_ptr,cell_to_hanging_faces_data)
82+
end
83+
84+
@show typeof(cell_to_hanging_faces)
85+
86+
end
87+
88+
end

test/dev/mpi/eric_dev.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using MPI
2+
using PartitionedArrays
3+
4+
include("../eric_dev.jl")
5+
import .DistributedAggregationP4estMeshes as TestModule
6+
7+
if !MPI.Initialized()
8+
MPI.Init()
9+
end
10+
11+
with_mpi() do distribute
12+
TestModule.run(distribute)
13+
end
14+
15+
# MPI.Finalize()
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""
2+
struct NonConformingGridTopology{Dc,Dp,T,O} <: GridTopology{Dc,Dp}
3+
# private fields
4+
end
5+
"""
6+
struct NonConformingGridTopology{Dc,Dp,T,O,A,B,C,D,E,F,G} <: GridTopology{Dc,Dp}
7+
ugt::UnstructuredGridTopology{Dc,Dp,T,O}
8+
ncg::NonConformingGlue{Dc,A,B,C,D,E,F,G}
9+
cell_to_hanging_faces::Table{Int32,Int32}
10+
end
11+
12+
# Implementation of abstract API
13+
14+
OrientationStyle(
15+
::Type{<:NonConformingGridTopology{Dc,Dp,T,O,A,B,C,D,E,F,G}}) where
16+
{Dc,Dp,T,O,A,B,C,D,E,F,G} = O()
17+
18+
RegularityStyle(
19+
::Type{<:NonConformingGridTopology{Dc,Dp,T,O,A,B,C,D,E,F,G}}) where
20+
{Dc,Dp,T,O,A,B,C,D,E,F,G} = Irregular()
21+
22+
get_vertex_coordinates(ncgt::NonConformingGridTopology) = ncgt.ugt.vertex_coordinates
23+
24+
get_cell_type(ncgt::NonConformingGridTopology) = ncgt.ugt.cell_type
25+
26+
get_polytopes(ncgt::NonConformingGridTopology) = collect1d(ncgt.ugt.polytopes)
27+
28+
# Can I do this?
29+
30+
function get_faces(ncgt::NonConformingGridTopology{Dc,Dp,T,O,A,B,C,D,E,F,G},
31+
::Val{Dc}, ::Val{Dc-1}) where {Dc,Dp,T,O,A,B,C,D,E,F,G}
32+
33+
end
34+
35+
function get_faces(ncgt::NonConformingGridTopology{Dc,Dp,T,O,A,B,C,D,E,F,G},
36+
::Val{Dc-1}, ::Val{Dc}) where {Dc,Dp,T,O,A,B,C,D,E,F,G}
37+
38+
end
39+
40+
# What other procs do I need? Review CA (e.g., facet_to_inoutcut)

0 commit comments

Comments
 (0)