@@ -2,6 +2,7 @@ module DistributedAggregationP4estMeshes
22
33 using Gridap
44 using GridapEmbedded
5+ using GridapEmbedded. Interfaces: CUT
56 using GridapDistributed
67 using PartitionedArrays
78 using MPI
@@ -27,16 +28,72 @@ module DistributedAggregationP4estMeshes
2728 num_uniform_refinements;
2829 num_ghost_layers= num_ghost_layers)
2930
31+ geo1 = quadrilateral (;x0= Point (- 0.9 ,- 0.9 ),
32+ d1= VectorValue (1.8 ,0.0 ),
33+ d2= VectorValue (0.0 ,1.8 ))
34+ geo2 = ! disk (0.4 )
35+ geo = intersect (geo1,geo2)
36+
37+ cutgeo = cut (dmodel, geo)
38+ cell_to_inoutcut = compute_bgcell_to_inoutcut (cutgeo,geo)
3039 fmodel_refine_coarsen_flags =
31- map (ranks,partition (get_cell_gids (dmodel. dmodel))) do rank,indices
40+ map (ranks,
41+ partition (get_cell_gids (dmodel. dmodel)),
42+ cell_to_inoutcut) do rank,indices,cell_to_inoutcut
3243 flags = zeros (Int,length (indices))
33- flags .= nothing_flag
34- flags[1 ] = refine_flag
44+ flags .= nothing_flag
45+ toref = findall (c-> c== CUT,cell_to_inoutcut)
46+ flags[toref] .= refine_flag
3547 flags
3648 end
3749 fmodel,_ = Gridap. Adaptivity. adapt (dmodel,fmodel_refine_coarsen_flags);
3850
51+ for i in 1 : 4
52+ cutgeo = cut (fmodel, geo)
53+ cell_to_inoutcut = compute_bgcell_to_inoutcut (cutgeo,geo)
54+ fmodel_refine_coarsen_flags =
55+ map (ranks,
56+ partition (get_cell_gids (fmodel)),
57+ cell_to_inoutcut) do rank,indices,cell_to_inoutcut
58+ flags = zeros (Int,length (indices))
59+ flags .= nothing_flag
60+ toref = findall (c-> c== CUT,cell_to_inoutcut)
61+ flags[toref] .= refine_flag
62+ flags
63+ end
64+ fmodel,_ = Gridap. Adaptivity. adapt (fmodel,fmodel_refine_coarsen_flags);
65+ end
66+
67+ writevtk (EmbeddedBoundary (cutgeo)," data/quad_bnd" );
68+ # The next line fails unless I comment out the assertion
69+ # in the constructor of AppendedTriangulations.jl:
70+ # @assert get_background_model(a) === get_background_model(b)
71+ writevtk (Triangulation (cutgeo,PHYSICAL_IN)," data/quad_phys" );
72+
73+ cell_gids = get_cell_gids (fmodel)
74+ cell_indices = partition (cell_gids)
75+
76+ cutgeo = cut (fmodel, geo)
3977 ncgt = NonConformingGridTopology (fmodel)
78+ strategy = AggregateCutCellsByThreshold (1.0 )
79+ lcell_to_lroot, lcell_to_root, lcell_to_value =
80+ map (local_views (cutgeo),cell_indices,ncgt) do cutgeo,cell_indices,ncgt
81+ lid_to_gid = local_to_global (cell_indices)
82+ aggregate (strategy,cutgeo,geo,lid_to_gid,IN,grid_topology= ncgt)
83+ end |> tuple_of_arrays
84+
85+ # Output for verification of lcell_to_root map
86+ ocell_to_root = map (lcell_to_root,own_to_local (cell_gids)) do agg,o_to_l
87+ map (Reindex (agg),o_to_l)
88+ end
89+
90+ writevtk (EmbeddedBoundary (cutgeo)," data/quad_bnd" );
91+ writevtk (Triangulation (cutgeo,PHYSICAL)," data/quad_phys" );
92+ writevtk (
93+ Triangulation (fmodel), " data/quad_aggregates" ,
94+ celldata = [" aggregate" => ocell_to_root],
95+ );
96+
4097 map (ncgt) do ncgt
4198 get_faces (ncgt,D,0 )
4299 get_faces (ncgt,0 ,D)
0 commit comments