diff --git a/NEWS.md b/NEWS.md index 8fe85a9..5f6bab6 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added +- Missing distributed functions. Since PR [#92](https://github.com/gridap/GridapEmbedded.jl/pull/92). +- Background models extended with remote ghosts inherit Cartesian labels. Since PR [#93](https://github.com/gridap/GridapEmbedded.jl/pull/93). + ### Fixed - Unused `name` keywork argument in `square` and `quadrilateral` analytical geometries. Since PR [#86](https://github.com/gridap/GridapEmbedded.jl/pull/86). - Gluing of the remote root cells to the local+ghost mesh. Since PR [#91](https://github.com/gridap/GridapEmbedded.jl/pull/91). diff --git a/Project.toml b/Project.toml index 0b74b84..5ccc378 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "GridapEmbedded" uuid = "8838a6a3-0006-4405-b874-385995508d5d" authors = ["Francesc Verdugo ", "Eric Neiva ", "Pere Antoni Martorell ", "Santiago Badia "] -version = "0.9.3" +version = "0.9.4" [deps] AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" diff --git a/src/Distributed/DistributedAgFEM.jl b/src/Distributed/DistributedAgFEM.jl index 89c6ab2..4501ba7 100644 --- a/src/Distributed/DistributedAgFEM.jl +++ b/src/Distributed/DistributedAgFEM.jl @@ -371,10 +371,61 @@ function add_remote_cells(model::DistributedDiscreteModel,remote_cells,remote_pa # Build appended model lgrids = map(get_grid,local_views(model)) - grids = map(lazy_append,lgrids,rgrids) - models = map(UnstructuredDiscreteModel,grids) + _grids = map(lazy_append,lgrids,rgrids) + _models = map(UnstructuredDiscreteModel,_grids) agids = add_remote_ids(gids,remote_cells,remote_parts) - DistributedDiscreteModel(models,agids) |> merge_nodes + amodel = DistributedDiscreteModel(_models,agids) |> merge_nodes + + D = num_cell_dims(model) + grids = map(get_grid,local_views(amodel)) + topos = map(get_grid_topology,local_views(amodel)) + d_to_dface_to_entity = map(topos) do topo + [ fill(Int32(UNSET),num_faces(topo,d)) for d in 0:D ] + end + oldtopos = map(get_grid_topology,local_views(model)) + oldlabels = map(get_face_labeling,local_views(model)) + for d in 0:D + _fill_labels!(d_to_dface_to_entity, + oldlabels, + oldtopos, + topos, + ncells, + d,D, + snd_lids, + rgraph) + end + labels = map(d_to_dface_to_entity,oldlabels) do d_to_dface_to_entity,ol + FaceLabeling(d_to_dface_to_entity,ol.tag_to_entities,ol.tag_to_name) + end + models = map(UnstructuredDiscreteModel,grids,topos,labels) + DistributedDiscreteModel(models,agids) +end + +function _fill_labels!(d_to_dface_to_entity,llabels,ltopos,ntopos,nremotes, + d::Int,D::Int,snd_lids,rgraph) + snd_labels = map(ltopos,llabels,snd_lids) do topo,labels,lids + dface_to_entity = get_face_entity(labels,d) + T = eltype(eltype(dface_to_entity)) + labels = map(lids) do lids + faces = map(Reindex(get_faces(topo,D,d)),lids) + labels = map(Reindex(dface_to_entity),faces) + reduce(append!,labels,init=T[]) + end + Vector{Vector{T}}(labels) + end + rcv_labels = allocate_exchange(snd_labels,rgraph) + exchange!(rcv_labels,snd_labels,rgraph) |> wait + rlabels = map(PartitionedArrays.getdata,rcv_labels) + map(d_to_dface_to_entity,llabels) do d_to_dface_to_entity,l + l_face_entity = get_face_entity(l,d) + d_to_dface_to_entity[d+1][1:length(l_face_entity)] = l_face_entity + end + map(d_to_dface_to_entity,ntopos,nremotes,rlabels) do d_to_dface_to_entity,nt,nr,r + nr > 0 && begin + rf = reduce(vcat,get_faces(nt,D,d)[end-nr+1:end]) + d_to_dface_to_entity[d+1][rf] = r + end + end end function add_remote_aggregates(model::DistributedDiscreteModel,aggregates,aggregate_owner)