Skip to content

Commit

Permalink
Merge pull request #81 from pmartorell/distributed
Browse files Browse the repository at this point in the history
Distributed GridapEmbedded and AgFEM
  • Loading branch information
santiagobadia authored Apr 25, 2024
2 parents c05204e + d3e6079 commit 8f22018
Show file tree
Hide file tree
Showing 19 changed files with 1,524 additions and 14 deletions.
7 changes: 6 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,27 @@ Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
CxxWrap = "1f15a43c-97ca-5a2a-ae31-89f07a497df4"
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
Gridap = "56d4f2e9-7ea1-5844-9cf6-b9c51ca7ce8e"
GridapDistributed = "f9701e48-63b3-45aa-9a63-9bc6c271f355"
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
MiniQhull = "978d7f02-9e05-4691-894f-ae31a51d76ca"
PartitionedArrays = "5a9dfac6-5c52-46f7-8278-5e2210713be9"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
algoimWrapper_jll = "3c43aa7b-5398-51f3-8d75-8f051e6faa4d"

[compat]
Algoim = "0.2"
AbstractTrees = "0.3.3, 0.4"
Algoim = "0.2"
Combinatorics = "1"
CxxWrap = "0.14"
FillArrays = "0.10, 0.11, 0.12, 0.13, 1"
GridapDistributed = "0.3, 0.4"
Gridap = "0.17, 0.18"
LightGraphs = "1.3.3"
MiniQhull = "0.1.0, 0.2, 0.3, 0.4"
PartitionedArrays = "0.3.4"
julia = "1.3"

[extras]
Expand Down
29 changes: 21 additions & 8 deletions src/AgFEM/AgFEMSpaces.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@

function AgFEMSpace(f::SingleFieldFESpace,bgcell_to_bgcellin::AbstractVector,g::SingleFieldFESpace=f)
function AgFEMSpace(
f::SingleFieldFESpace,
bgcell_to_bgcellin::AbstractVector,
g::SingleFieldFESpace=f,
args...)

@assert get_triangulation(f) === get_triangulation(g)
AgFEMSpace(f,bgcell_to_bgcellin,get_fe_basis(g),get_fe_dof_basis(g))
AgFEMSpace(f,bgcell_to_bgcellin,get_fe_basis(g),get_fe_dof_basis(g),args...)
end

# Note: cell is in fact bgcell in this function since f will usually be an ExtendedFESpace
function AgFEMSpace(
f::SingleFieldFESpace,
bgcell_to_bgcellin::AbstractVector,
shfns_g::CellField,
dofs_g::CellDof)
dofs_g::CellDof,
bgcell_to_gcell::AbstractVector=1:length(bgcell_to_bgcellin))

# Triangulation made of active cells
trian_a = get_triangulation(f)
Expand All @@ -21,6 +27,7 @@ function AgFEMSpace(
bgcell_to_acell = glue.mface_to_tface
acell_to_bgcellin = lazy_map(Reindex(bgcell_to_bgcellin),acell_to_bgcell)
acell_to_acellin = collect(lazy_map(Reindex(bgcell_to_acell),acell_to_bgcellin))
acell_to_gcell = lazy_map(Reindex(bgcell_to_gcell),acell_to_bgcell)

# Build shape funs of g by replacing local funs in cut cells by the ones at the root
# This needs to be done with shape functions in the physical domain
Expand All @@ -41,7 +48,8 @@ function AgFEMSpace(
acell_to_acellin,
acell_to_dof_ids,
acell_to_coeffs,
acell_to_proj)
acell_to_proj,
acell_to_gcell)

FESpaceWithLinearConstraints(aggdof_to_fdof,aggdof_to_dofs,aggdof_to_coeffs,f)
end
Expand All @@ -51,7 +59,8 @@ function _setup_agfem_constraints(
acell_to_acellin,
acell_to_dof_ids,
acell_to_coeffs,
acell_to_proj)
acell_to_proj,
acell_to_gcell)

n_acells = length(acell_to_acellin)
fdof_to_isagg = fill(true,n_fdofs)
Expand All @@ -62,12 +71,16 @@ function _setup_agfem_constraints(
acellin = acell_to_acellin[acell]
iscut = acell != acellin
dofs = getindex!(cache,acell_to_dof_ids,acell)
gcell = acell_to_gcell[acell]
for (ldof,dof) in enumerate(dofs)
if dof > 0
fdof = dof
fdof_to_isagg[fdof] = iscut && fdof_to_isagg[fdof]
fdof_to_acell[fdof] = acell
fdof_to_ldof[fdof] = ldof
acell_dof = fdof_to_acell[fdof]
if acell_dof == 0 || gcell > acell_to_gcell[acell_dof]
fdof_to_acell[fdof] = acell
fdof_to_isagg[fdof] = iscut && fdof_to_isagg[fdof]
fdof_to_ldof[fdof] = ldof
end
end
end
end
Expand Down
59 changes: 59 additions & 0 deletions src/Distributed/Distributed.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
module Distributed

using Gridap
using GridapDistributed
using PartitionedArrays
using FillArrays

using Gridap.Arrays
using Gridap.CellData
using Gridap.Geometry
using Gridap.Helpers
using Gridap.ReferenceFEs

using GridapEmbedded.CSG
using GridapEmbedded.LevelSetCutters
using GridapEmbedded.Interfaces
using GridapEmbedded.Interfaces: Cutter
using GridapEmbedded.Interfaces: ActiveInOrOut
using GridapEmbedded.Interfaces: SubFacetTriangulation
using GridapEmbedded.Interfaces: SubCellData
using GridapEmbedded.Interfaces: SubFacetData
using GridapEmbedded.Interfaces: AbstractEmbeddedDiscretization
using GridapEmbedded.AgFEM: _touch_aggregated_cells!
using GridapEmbedded.AgFEM: AggregateCutCellsByThreshold
using GridapEmbedded.MomentFittedQuadratures: MomentFitted
using Gridap.Geometry: AppendedTriangulation
using Gridap.Geometry: get_face_to_parent_face
using GridapDistributed: DistributedDiscreteModel
using GridapDistributed: DistributedTriangulation
using GridapDistributed: DistributedFESpace
using GridapDistributed: DistributedSingleFieldFESpace
using GridapDistributed: DistributedMeasure
using GridapDistributed: add_ghost_cells
using GridapDistributed: generate_gids
using GridapDistributed: generate_cell_gids
using GridapDistributed: _find_vector_type

import GridapEmbedded.AgFEM: aggregate
import GridapEmbedded.AgFEM: AgFEMSpace
import GridapEmbedded.Interfaces: cut
import GridapEmbedded.Interfaces: cut_facets
import GridapEmbedded.Interfaces: EmbeddedBoundary
import GridapEmbedded.Interfaces: compute_bgfacet_to_inoutcut
import GridapEmbedded.Interfaces: compute_bgcell_to_inoutcut
import GridapEmbedded.CSG: get_geometry
import Gridap.Geometry: Triangulation
import Gridap.Geometry: SkeletonTriangulation
import Gridap.Geometry: BoundaryTriangulation
import Gridap.Geometry: get_background_model
import GridapDistributed: local_views
import GridapDistributed: remove_ghost_cells

include("DistributedDiscretizations.jl")

include("DistributedAgFEM.jl")

include("DistributedQuadratures.jl")

end # module
Loading

0 comments on commit 8f22018

Please sign in to comment.