Skip to content

Commit 35d66bb

Browse files
committed
Updated bb_diam computation to account for different cell sizes
1 parent 021e992 commit 35d66bb

File tree

3 files changed

+30
-20
lines changed

3 files changed

+30
-20
lines changed

src/AgFEM/CellAggregation.jl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,19 @@ function _find_best_neighbor(
254254
if neigh_cell != cell && cell_to_touched[neigh_cell]
255255
cellin = cell_to_cellin[neigh_cell]
256256
j_to_coords = getindex!(c4,cell_to_coords,cellin)
257-
# d := diam of box bounding target cell and neighbour root cell
257+
# bb_diam := diam of box bounding target cell and neighbour root cell
258258
bb_diam = 0.0
259-
for p in i_to_coords
260-
for q in j_to_coords
261-
bb_diam = max(bb_diam,Float64(norm(p-q)))
262-
end
259+
for p in i_to_coords, q in j_to_coords
260+
bb_diam = max(bb_diam,Float64(norm(p-q)))
261+
end
262+
# rc_diam := diam of box bounding neighbour root cell
263+
rc_diam = 0.0
264+
for p in j_to_coords, q in j_to_coords
265+
rc_diam = max(rc_diam,Float64(norm(p-q)))
263266
end
267+
# bb_diam is scaled with 1/rc_diam to account for different cell sizes
268+
# See Definition 2.2 in https://arxiv.org/pdf/2006.05373
269+
bb_diam = bb_diam / rc_diam
264270
# Evaluate objective function and update best values
265271
bit_iter = bitstring(Int8(iter))
266272
bit_bb_diam = bitstring(Float32(round(bb_diam,sigdigits=6)))

test/dev/NonConformingGridTopologies.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module NonConformingGridTopologies
4545
map(_ones_on_hanging_faces!,hanging_faces_to_cell_ptrs,
4646
ncg.num_hanging_faces)
4747
map(length_to_ptrs!,hanging_faces_to_cell_ptrs)
48-
48+
4949
cell_to_hanging_faces_data =
5050
map(sortperm,hanging_faces_to_cell_data)
5151
cell_to_hanging_faces_data =

test/dev/eric_dev.jl

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module DistributedAggregationP4estMeshes
2020
ranks = distribute(LinearIndices((MPI.Comm_size(MPI.COMM_WORLD),)))
2121
coarse_model = CartesianDiscreteModel((-1,1,-1,1),(1,1))
2222
num_uniform_refinements = 1
23-
num_ghost_layers = 2
23+
num_ghost_layers = 1
2424
D = num_dims(coarse_model)
2525

2626
dmodel = OctreeDistributedDiscreteModel(ranks,
@@ -48,7 +48,7 @@ module DistributedAggregationP4estMeshes
4848
end
4949
fmodel,_ = Gridap.Adaptivity.adapt(dmodel,fmodel_refine_coarsen_flags);
5050

51-
for i in 1:4
51+
for i in 1:5
5252
cutgeo = cut(fmodel, geo)
5353
cell_to_inoutcut = compute_bgcell_to_inoutcut(cutgeo,geo)
5454
fmodel_refine_coarsen_flags =
@@ -63,17 +63,19 @@ module DistributedAggregationP4estMeshes
6363
end
6464
fmodel,_ = Gridap.Adaptivity.adapt(fmodel,fmodel_refine_coarsen_flags);
6565
end
66+
fmodel, _ = GridapDistributed.redistribute(fmodel)
6667

68+
cutgeo = cut(fmodel, geo)
6769
writevtk(EmbeddedBoundary(cutgeo),"data/quad_bnd");
6870
# The next line fails unless I comment out the assertion
6971
# in the constructor of AppendedTriangulations.jl:
7072
# @assert get_background_model(a) === get_background_model(b)
71-
writevtk(Triangulation(cutgeo,PHYSICAL_IN),"data/quad_phys");
73+
writevtk(Triangulation(cutgeo,ACTIVE_IN),"data/quad_phys");
74+
# writevtk(Triangulation(cutgeo,PHYSICAL_IN),"data/quad_phys");
7275

7376
cell_gids = get_cell_gids(fmodel)
7477
cell_indices = partition(cell_gids)
7578

76-
cutgeo = cut(fmodel, geo)
7779
ncgt = NonConformingGridTopology(fmodel)
7880
strategy = AggregateCutCellsByThreshold(1.0)
7981
lcell_to_lroot, lcell_to_root, lcell_to_value =
@@ -94,16 +96,18 @@ module DistributedAggregationP4estMeshes
9496
celldata = ["aggregate" => ocell_to_root],
9597
);
9698

97-
map(ncgt) do ncgt
98-
get_faces(ncgt,D,0)
99-
get_faces(ncgt,0,D)
100-
get_faces(ncgt,D,1)
101-
get_faces(ncgt,1,D)
102-
get_faces(ncgt,D,2)
103-
get_faces(ncgt,2,D)
104-
# get_faces(ncgt,D,3)
105-
# get_faces(ncgt,3,D)
106-
end
99+
# map(ncgt) do ncgt
100+
# get_faces(ncgt,D,0)
101+
# get_faces(ncgt,0,D)
102+
# get_faces(ncgt,D,1)
103+
# get_faces(ncgt,1,D)
104+
# get_faces(ncgt,D,2)
105+
# get_faces(ncgt,2,D)
106+
# # get_faces(ncgt,D,3)
107+
# # get_faces(ncgt,3,D)
108+
# end
109+
110+
return nothing
107111

108112
end
109113

0 commit comments

Comments
 (0)