-
Notifications
You must be signed in to change notification settings - Fork 22
Implement owned cells strategy #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6b2b06c
Implemented OwnedCellsStrategy extension of AssemblyStrategy
amartinhuertas ad9319f
Merge branch 'master' of github.com:gridap/GridapDistributed.jl into …
amartinhuertas 259bb4b
+ Addressed @fverdugo remarks for pull request #15:
amartinhuertas cbe9d3a
Add a function barrier to:
amartinhuertas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -250,5 +250,3 @@ function _fill_max_part_around!(lid_to_owner,cell_to_owner,cell_to_lids) | |
| end | ||
| end | ||
| end | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,88 +1,64 @@ | ||
|
|
||
| function remove_ghost_cells(trian::Triangulation,part::Integer,gids::IndexSet) | ||
| function filter_cells_when_needed(strategy::AssemblyStrategy, trian::Triangulation) | ||
| @abstractmethod | ||
| end | ||
|
|
||
| function filter_cells_when_needed(strategy::RowsComputedLocally, trian::Triangulation) | ||
| trian | ||
| end | ||
|
|
||
| function filter_cells_when_needed(strategy::OwnedCellsStrategy, trian::Triangulation) | ||
| remove_ghost_cells(trian,strategy.part,strategy.cell_gids) | ||
| end | ||
|
|
||
| function Gridap.Geometry.Triangulation(strategy::AssemblyStrategy,model::DiscreteModel,args...) | ||
| trian = Triangulation(model,args...) | ||
| filter_cells_when_needed(strategy,trian) | ||
| end | ||
|
|
||
| function Gridap.Geometry.BoundaryTriangulation(strategy::AssemblyStrategy,model::DiscreteModel,args...) | ||
| trian = BoundaryTriangulation(model,args...) | ||
| filter_cells_when_needed(strategy,trian) | ||
| end | ||
|
|
||
| function Gridap.Geometry.SkeletonTriangulation(strategy::AssemblyStrategy,model::DiscreteModel,args...) | ||
| trian = SkeletonTriangulation(model,args...) | ||
| filter_cells_when_needed(strategy,trian) | ||
| end | ||
|
|
||
| function remove_ghost_cells(trian::Triangulation, part::Integer, gids::IndexSet) | ||
| tcell_to_mcell = get_cell_id(trian) | ||
| mcell_to_isowned = gids.lid_to_owner .== part | ||
| tcell_to_isowned = reindex(mcell_to_isowned,tcell_to_mcell) | ||
| ocell_to_tcell = findall(tcell_to_isowned) | ||
| TriangulationPortion(trian,ocell_to_tcell) | ||
| ocell_to_tcell = | ||
| findall((x) -> (gids.lid_to_owner[x] == part), tcell_to_mcell) | ||
| TriangulationPortion(trian, ocell_to_tcell) | ||
| end | ||
|
|
||
| function include_ghost_cells(trian::TriangulationPortion) | ||
| trian.oldtrian | ||
| function remove_ghost_cells( | ||
| trian::SkeletonTriangulation, | ||
| part::Integer, | ||
| gids::IndexSet, | ||
| ) | ||
| cell_id_left = get_cell_id(trian.left) | ||
| cell_id_right = get_cell_id(trian.right) | ||
| @assert length(cell_id_left) == length(cell_id_right) | ||
| facets_to_old_facets = | ||
| _compute_facets_to_old_facets(cell_id_left, cell_id_right, part, gids) | ||
| TriangulationPortion(trian, facets_to_old_facets) | ||
| end | ||
|
|
||
| # | ||
| # | ||
| # | ||
| #struct DistributedTriangulation | ||
| # trians::ScatteredVector{<:Triangulation} | ||
| #end | ||
| # | ||
| #function get_distributed_data(dtrian::DistributedTriangulation) | ||
| # dtrian.trians | ||
| #end | ||
| # | ||
| #function Gridap.writevtk(dtrian::DistributedTriangulation,filebase::String;cellfields=Dict()) | ||
| # | ||
| # d = Dict(cellfields) | ||
| # thevals = values(d) | ||
| # thekeys = keys(d) | ||
| # | ||
| # do_on_parts(dtrian,thevals...) do part, trian, thevals... | ||
| # filebase_part = filebase*"_$(part)" | ||
| # cellfields = [ k=>v for (k,v) in zip(thekeys, thevals) ] | ||
| # writevtk(trian,filebase_part,cellfields=cellfields) | ||
| # end | ||
| # | ||
| #end | ||
| function _compute_facets_to_old_facets(cell_id_left, cell_id_right, part, gids) | ||
| facets_to_old_facets = eltype(cell_id_right)[] | ||
| for i = 1:length(cell_id_left) | ||
| part_left = gids.lid_to_owner[cell_id_left[i]] | ||
| part_right = gids.lid_to_owner[cell_id_right[i]] | ||
| max_part_id = max(part_left, part_right) | ||
| if (max_part_id == part) | ||
| push!(facets_to_old_facets, i) | ||
| end | ||
| end | ||
| facets_to_old_facets | ||
| end | ||
|
|
||
| # | ||
| #function Gridap.Triangulation(dmodel::DistributedDiscreteModel,args...) | ||
| # comm = get_comm(dmodel) | ||
| # trians = ScatteredVector(comm,dmodel.models) do part, model | ||
| # Triangulation(model,args...) | ||
| # end | ||
| # DistributedTriangulation(trians) | ||
| #end | ||
| # | ||
| #function Gridap.BoundaryTriangulation(dmodel::DistributedDiscreteModel,args...) | ||
| # comm = get_comm(dmodel) | ||
| # trians = ScatteredVector(comm,dmodel.models) do part, model | ||
| # BoundaryTriangulation(model,args...) | ||
| # end | ||
| # DistributedTriangulation(trians) | ||
| #end | ||
| # | ||
| #function Gridap.SkeletonTriangulation(dmodel::DistributedDiscreteModel,args...) | ||
| # comm = get_comm(dmodel) | ||
| # trians = ScatteredVector(comm,dmodel.models) do part, model | ||
| # SkeletonTriangulation(model,args...) | ||
| # end | ||
| # DistributedTriangulation(trians) | ||
| #end | ||
| # | ||
| # | ||
| #function remove_ghost_cells(dtrian::DistributedTriangulation,dmodel) | ||
| # | ||
| # trians = ScatteredVector(dtrian,dmodel.gids) do part, trian, gids | ||
| # | ||
| # tcell_to_mcell = get_cell_id(trian) | ||
| # mcell_to_isowned = gids.lid_to_owner .== part | ||
| # tcell_to_isowned = reindex(mcell_to_isowned,tcell_to_mcell) | ||
| # ocell_to_tcell = findall(tcell_to_isowned) | ||
| # TriangulationPortion(trian,ocell_to_tcell) | ||
| # end | ||
| # | ||
| # DistributedTriangulation(trians) | ||
| # | ||
| #end | ||
| # | ||
| #function include_ghost_cells(dtrian::DistributedTriangulation) | ||
| # | ||
| # trians = ScatteredVector(dtrian) do part, trian | ||
| # trian.oldtrian | ||
| # end | ||
| # | ||
| # DistributedTriangulation(trians) | ||
| #end | ||
| # | ||
| function include_ghost_cells(trian::TriangulationPortion) | ||
| trian.oldtrian | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amartinhuertas I am not sure if this function is 100% type stable. Perhaps a function barrier for the loop will help. The
trianobject could be type in-stable (now or in the future) since it is a quite high-level object.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Damm! I always forget about the issue of type instability. I will definitely add the function barrier. But I do not understand why do u say that
triancould be typeinstableas it is declared to be of typeSkeletonTriangulation.trian.leftandtrian.righttypes are also known. So I do not see whats wrong in this particular scenario.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my understanding, I ran the type inference algorithm (in the debugger), and as I expected, there is no particular type instability (now). Results below. Can you think of a future scenario in which there might be type instability? May be for a different implementation of
SkeletonTriangulation?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trian.leftortrian.rightcan potentially be a type in-stable specialization of Triangulation. For now it is not the case, but who knows in the future...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. This is what I was thinking. Thanks for confirming!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in cbe9d3a