Skip to content

Commit

Permalink
Merge pull request #95 from pmartorell/add_p4est_functions
Browse files Browse the repository at this point in the history
Adding redistribute flags and adaptive weights
  • Loading branch information
pmartorell authored Aug 1, 2024
2 parents d579786 + 1185b7d commit 134b905
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Adding `compute_redistribute_weights` and `compute_adaptive_flags` functions for load balancing and adaptive mesh refinement, respectively. Since PR [#95](https://github.com/gridap/GridapEmbedded.jl/pull/95).


## [0.9.4] - 2024-07-09

### Added
Expand Down
53 changes: 53 additions & 0 deletions src/Distributed/DistributedDiscretizations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,56 @@ function remove_ghost_subfacets(cut::EmbeddedFacetDiscretization,facet_gids)
cut.oid_to_ls,
cut.geo)
end

function compute_redistribute_wights(
cut::DistributedEmbeddedDiscretization,
args...)

geo = get_geometry(cut)
compute_redistribute_wights(cut,geo,args...)
end

function compute_redistribute_wights(
cut::DistributedEmbeddedDiscretization,
geo::CSG.Geometry,
args...)

compute_redistribute_wights(compute_bgcell_to_inoutcut(cut,geo),args...)
end

function compute_redistribute_wights(cell_to_inoutcut,in_or_out=IN)
map(cell_to_inoutcut) do cell_to_inoutcut
map(cell_to_inoutcut) do inoutcut
Int( inoutcut (CUT,in_or_out) )
end
end
end

function compute_adaptive_flags(
cut::DistributedEmbeddedDiscretization,
args...)

geo = get_geometry(cut)
compute_adaptive_flags(cut,geo,args...)
end

function compute_adaptive_flags(
cut::DistributedEmbeddedDiscretization,
geo::CSG.Geometry,
args...)

compute_adaptive_flags(compute_bgcell_to_inoutcut(cut,geo),args...)
end

function compute_adaptive_flags(cell_to_inoutcut)
map(cell_to_inoutcut) do c_to_ioc
flags = zeros(Cint,length(c_to_ioc))
flags .= nothing_flag
for (c,ioc) in enumerate(c_to_ioc)
if ioc == CUT
flags[c] = refine_flag
end
end
flags
end
end

0 comments on commit 134b905

Please sign in to comment.