Skip to content

Commit

Permalink
Added distributed SubFacetBoundaryTriangulations
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiManyer committed Nov 14, 2024
1 parent 9e32233 commit b8c09c0
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
73 changes: 73 additions & 0 deletions scripts/Embedded/MWEs/distributed.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using GridapTopOpt
using Gridap

using GridapDistributed, PartitionedArrays

using GridapEmbedded
using GridapEmbedded.LevelSetCutters
using Gridap.Geometry, Gridap.FESpaces, Gridap.CellData, Gridap.Adaptivity

using GridapTopOpt: get_subfacet_normal_vector, get_ghost_normal_vector
using GridapTopOpt: get_conormal_vector, get_tangent_vector

order = 1
n = 8
N = 8

parts = (2,2)
ranks = DebugArray(LinearIndices((prod(parts),)))

_model = CartesianDiscreteModel(ranks,parts,(0,1,0,1),(n,n))
#_model = CartesianDiscreteModel((0,1,0,1,0,1),(n,n,n))

base_model = UnstructuredDiscreteModel(_model)
ref_model = refine(base_model, refinement_method = "barycentric")
model = Gridap.Adaptivity.get_model(ref_model)

Ω = Triangulation(model)
= Measure(Ω,2*order)

reffe = ReferenceFE(lagrangian,Float64,order)
V_φ = TestFESpace(model,reffe)

φh = interpolate(x->sqrt((x[1]-0.5)^2+(x[2]-0.5)^2)-0.5223,V_φ) # Circle
fh = interpolate(x->cos(x[1]*x[2]),V_φ)

geo = DiscreteGeometry(φh,model)
cutgeo = cut(model,geo)

Γ = EmbeddedBoundary(cutgeo)
Λ = Skeleton(Γ)
Σ = Boundary(Γ)

############################################################################################

writevtk(
Ω,"results/background",
cellfields=[
"φh"=>φh,
],
append=false
)
writevtk(
Triangulation(cutgeo,PHYSICAL_IN),"results/trian_in";
append=false
)
writevtk(
Triangulation(cutgeo,PHYSICAL_OUT),"results/trian_out";
append=false
)
writevtk(
Γ,"results/gamma";
append=false
)
writevtk(
Λ,
"results/lambda",
append=false
)
writevtk(
Σ,
"results/sigma",
append=false
)
14 changes: 14 additions & 0 deletions src/Embedded/SubFacetBoundaryTriangulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,20 @@ for func in (:(Gridap.get_normal_vector),:get_tangent_vector)
end
end

# Distributed
# Until we merge, we need changes in
# - GridapDistributed#master
# - GridapEmbedded#distributed

function GridapDistributed.remove_ghost_cells(
trian::Union{<:SubFacetBoundaryTriangulation,<:SubFacetSkeletonTriangulation},gids
)
model = get_background_model(trian)
Dm = num_cell_dims(model)
glue = get_glue(trian,Val(Dm))
GridapDistributed.remove_ghost_cells(glue,trian,gids)
end

############################################################################################
# This will go to Gridap

Expand Down

0 comments on commit b8c09c0

Please sign in to comment.