Fix: Grid(ReferenceFE{d}, model::MappedDiscreteModel) returning cell grid for all dimensions instead of face grid
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
Research direction
Start in src/Geometry/MappedDiscreteModels.jl at Grid(::Type{ReferenceFE{d}}, model::MappedDiscreteModel), then inspect the existing DiscreteModel fallback for lower-dimensional requests. Run the BoundaryTriangulation(model) minimal example from the issue; done means the mapped model returns a face grid for lower dimensions while retaining the cell grid at the model dimension.
Written by the indexing model from the issue text.
Description
Description
In src/Geometry/MappedDiscreteModels.jl, the method
Grid(::Type{ReferenceFE{d}}, model::MappedDiscreteModel)
is implemented as:
function Grid(::Type{ReferenceFE{d}}, model::MappedDiscreteModel) where {d}
get_grid(model)
end
This implementation matches all values of d and always returns the full cell grid of the model.
However, when d < Dc (for example when constructing boundary or skeleton triangulations), the function should return the corresponding lower-dimensional grid instead of the cell grid.
MappedDiscreteModel is commonly used for mapped geometries, and operations such as
BoundaryTriangulation(model)
SkeletonTriangulation(model)
internally request lower-dimensional grids through calls like:
Grid(ReferenceFE{D-1}, model)
With the current implementation, the method still returns the cell grid, which can lead to incorrect behavior or runtime errors when building boundary or skeleton triangulations.
Expected behavior
Grid(::Type{ReferenceFE{d}}, model::MappedDiscreteModel) should only return the cell grid when d equals the topological dimension of the model.
For lower dimensions, the existing fallback defined for DiscreteModel should handle the request.
This can be achieved by constraining the method signature:
function Grid(::Type{ReferenceFE{d}}, model::MappedDiscreteModel{d}) where {d}
get_grid(model)
end
so that the method only applies when d matches the model dimension.
Minimal example
using Gridap
using Gridap.Geometry
model0 = CartesianDiscreteModel((0,1,0,1), (4,4))
phi(x) = VectorValue(x[1] + 0.1*x[1]*x[2], x[2])
model = MappedDiscreteModel(model0, phi)
Γ = BoundaryTriangulation(model)
This call should construct the boundary triangulation correctly using the face grid.
- Dominant language
- Julia
- Stars
- 879
- Forks
- 120
- Avg merge
- 6d 3h
- Merged PRs (30d)
- 4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from gridap/Gridap.jl
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Difficulty 5/5 Over a week Newbie friendliness 28/100
-
performance
Difficulty 4/5 3-5 days Newbie friendliness 45/100
All issues in gridap/Gridap.jl
Similar issues
-
bug 🐞 distributed 🕸️
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
CliMA/Oceananigans.jl#6049 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
JuliaGPU/GPUArrays.jl#780 ·
-
Difficulty 2/5 Half a day Newbie friendliness 76/100
epiforecasts/EpiBranch.jl#304 ·