diff --git a/scripts/Embedded/Bugs/change_domain_bug.jl b/scripts/Embedded/Bugs/change_domain_bug.jl index 9977b7e9..4f1be679 100644 --- a/scripts/Embedded/Bugs/change_domain_bug.jl +++ b/scripts/Embedded/Bugs/change_domain_bug.jl @@ -23,7 +23,12 @@ dΓ = Measure(Γ,2order) ∫(vh)dΓ ∫(2vh)dΓ -Γ = DifferentiableTriangulation(EmbeddedBoundary(cutgeo)) + +_Γ = EmbeddedBoundary(cutgeo) +Γ = DifferentiableTriangulation(_Γ) dΓ = Measure(Γ,2order) ∫(vh)dΓ -∫(2vh)dΓ \ No newline at end of file +∫(2vh)dΓ + +cf = CellField(1,_Γ) +change_domain(cf,Γ,ReferenceDomain()) diff --git a/src/Embedded/DifferentiableTriangulations.jl b/src/Embedded/DifferentiableTriangulations.jl index ed754d15..97b6a67e 100644 --- a/src/Embedded/DifferentiableTriangulations.jl +++ b/src/Embedded/DifferentiableTriangulations.jl @@ -74,7 +74,8 @@ end function CellData.get_cell_points(ttrian::DifferentiableTriangulation) if isnothing(ttrian.cell_values) - return get_cell_points(ttrian.trian) + pts = get_cell_points(ttrian.trian) + return CellPoint(CellData.get_data(pts),ttrian,DomainStyle(pts)) end c = ttrian.caches cell_values = ttrian.cell_values @@ -127,6 +128,32 @@ function Geometry.get_glue(ttrian::DifferentiableTriangulation,val::Val{D}) wher ) end +function Geometry.is_change_possible( + strian::A,ttrian::DifferentiableTriangulation{Dc,Dp,A} +) where {Dc,Dp,A <: Union{SubCellTriangulation,SubFacetTriangulation}} + return strian === ttrian.trian +end + +function Geometry.best_target( + strian::A,ttrian::DifferentiableTriangulation{Dc,Dp,A} +) where {Dc,Dp,A <: Union{SubCellTriangulation,SubFacetTriangulation}} + return ttrian +end + +for tdomain in (:ReferenceDomain,:PhysicalDomain) + for sdomain in (:ReferenceDomain,:PhysicalDomain) + @eval begin + function CellData.change_domain( + a::CellField,strian::A,::$sdomain,ttrian::DifferentiableTriangulation{Dc,Dp,A},::$tdomain + ) where {Dc,Dp,A <: Union{SubCellTriangulation,SubFacetTriangulation}} + @assert is_change_possible(strian,ttrian) + b = change_domain(a,$(tdomain)()) + return CellData.similar_cell_field(a,CellData.get_data(b),ttrian,$(tdomain)()) + end + end + end +end + function FESpaces.get_cell_fe_data(fun,f,ttrian::DifferentiableTriangulation) FESpaces.get_cell_fe_data(fun,f,ttrian.trian) end