Skip to content

Commit

Permalink
Merge branch 'feature-gridap-embedded-compat' of https://github.com/z…
Browse files Browse the repository at this point in the history
…jwegert/GridapTopOpt.jl into feature-gridap-embedded-compat
  • Loading branch information
zjwegert committed Nov 14, 2024
2 parents 814a2f6 + 35952c2 commit e63e6b6
Show file tree
Hide file tree
Showing 2 changed files with 96 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
)
23 changes: 23 additions & 0 deletions src/Embedded/SubFacetBoundaryTriangulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,29 @@ 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

for func in (:get_subfacet_normal_vector,:get_ghost_normal_vector,:get_conormal_vector,:get_tangent_vector)
@eval begin
function $func(a::DistributedTriangulation)
fields = map($func,local_views(a))
DistributedCellField(fields,a)
end
end
end

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

Expand Down

0 comments on commit e63e6b6

Please sign in to comment.