gridap / GridapEmbedded.jl

Embedded finite element methods in Julia
Other
42 stars 14 forks source link

Getting the boundary triangulation from the physical triangulation #66

Closed janmodderman closed 1 year ago

janmodderman commented 1 year ago

Hey all,

When trying to extract a boundary triangulation from the physical triangulation of a cut geometry that intersects the boundary I get an error. I think the error is that the physical triangulation does not have the information about the boundary of the background triangulation. Getting the boundary triangulation of an active triangulation works. Any idea on how to fix this?

@ericneiva @fverdugo

below the error I get:

Stacktrace:
 [1] compute_active_model(t::AppendedTriangulation{2, 2, GridapEmbedded.Interfaces.SubCellTriangulation{2, 2, Float64, CartesianDiscreteModel{2, Float64, typeof(identity)}}, BodyFittedTriangulation{2, 2, CartesianDiscreteModel{2, Float64, typeof(identity)}, GridPortion{2, 2, CartesianGrid{2, Float64, typeof(identity)}}, Vector{Int32}}})
   @ Gridap.Geometry ~/.julia/packages/Gridap/OTENN/src/Geometry/Triangulations.jl:106
 [2] get_active_model(t::AppendedTriangulation{2, 2, GridapEmbedded.Interfaces.SubCellTriangulation{2, 2, Float64, CartesianDiscreteModel{2, Float64, typeof(identity)}}, BodyFittedTriangulation{2, 2, CartesianDiscreteModel{2, Float64, typeof(identity)}, GridPortion{2, 2, CartesianGrid{2, Float64, typeof(identity)}}, Vector{Int32}}})
   @ Gridap.Geometry ~/.julia/packages/Gridap/OTENN/src/Geometry/Triangulations.jl:100
 [3] BoundaryTriangulation(::AppendedTriangulation{2, 2, GridapEmbedded.Interfaces.SubCellTriangulation{2, 2, Float64, CartesianDiscreteModel{2, Float64, typeof(identity)}}, BodyFittedTriangulation{2, 2, CartesianDiscreteModel{2, Float64, typeof(identity)}, GridPortion{2, 2, CartesianGrid{2, Float64, typeof(identity)}}, Vector{Int32}}}; kwargs::Base.Pairs{Symbol, Vector{String}, Tuple{Symbol}, NamedTuple{(:tags,), Tuple{Vector{String}}}})
   @ Gridap.Geometry ~/.julia/packages/Gridap/OTENN/src/Geometry/BoundaryTriangulations.jl:178
 [4] top-level scope
   @ ~/Documents/GridapPF.jl/GridapPF.jl/src/coupling/error_repro_cut.jl:28

Error reproduction code:

using Gridap
using GridapEmbedded
R = 0.5
pmin = Point(1.0, 0.0)
pmax = Point(0.0, -1.0)
partition = (10, 10)
model = CartesianDiscreteModel(pmax, pmin, partition)
pmid = 0.5*(pmax + pmin) + VectorValue(0.0, 0.5)
geo = disk(R, x0=pmid)
cutgeo = cut(model, !(geo))
Ω = Interior(model) 
Ω⁻ = Interior(cutgeo, PHYSICAL_IN)
Ω⁻act = Interior(cutgeo, ACTIVE_IN)

Γf_act = BoundaryTriangulation(Ω⁻act, tags=["boundary"])     # active region cut works
Γf_phy = BoundaryTriangulation(Ω⁻, tags=["boundary"])        # physical region cut does not work
ericneiva commented 1 year ago

Hi, @JanModderman,

Are lines 35-37 here https://github.com/gridap/GridapEmbedded.jl/blob/master/test/InterfacesTests/EmbeddedFacetDiscretizationsTests.jl#L35 what you are looking after?

Γu = EmbeddedBoundary(cutgeo)
Γf = BoundaryTriangulation(cutgeo_facets,PHYSICAL)
Γ = lazy_append(Γu,Γf)
janmodderman commented 1 year ago

Yes! Thanks you very much, cutgeo_facets is exactly what I needed!

ericneiva commented 1 year ago

Good, reopen the issue if needed :)