Skip to content

Commit 6d230da

Browse files
authored
Merge pull request #1149 from gridap/polytopal
Minor changes to PolytopalQuadrature constructors
2 parents 0ae19be + dc01bb7 commit 6d230da

File tree

9 files changed

+93
-69
lines changed

9 files changed

+93
-69
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ jobs:
4444
- uses: julia-actions/julia-processcoverage@v1
4545
- uses: codecov/codecov-action@v5
4646
with:
47-
file: lcov.info
4847
verbose: true
4948
token: ${{ secrets.CODECOV_TOKEN }}
49+
flags: tests
5050

5151
drivers:
5252
name: Drivers ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
@@ -69,8 +69,12 @@ jobs:
6969
- uses: julia-actions/cache@v2
7070
- uses: julia-actions/julia-buildpkg@v1
7171
- run: |
72-
julia --color=yes --project=. --check-bounds=yes --depwarn=error -e '
73-
using Pkg; Pkg.instantiate()'
72+
julia --color=yes --project=. --depwarn=yes -e 'using Pkg; Pkg.instantiate()'
7473
- run: |
75-
julia --color=yes --project=. --check-bounds=yes --depwarn=error -e '
76-
include("test/GridapTests/runtests.jl")'
74+
julia --color=yes --project=. --depwarn=yes -e 'include("test/GridapTests/runtests.jl")'
75+
- uses: julia-actions/julia-processcoverage@v1
76+
- uses: codecov/codecov-action@v5
77+
with:
78+
verbose: true
79+
token: ${{ secrets.CODECOV_TOKEN }}
80+
flags: drivers

NEWS.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [Unreleased]
8+
## [0.19.4] - 2025-08-09
99

1010
### Added
1111

1212
- Added low-level API `Arrays.invalidate_cache!(cache)` that forces the re-computation of values in `LazyArray` caches. Since PR[#1137](https://github.com/gridap/Gridap.jl/pull/1137).
1313
- Added support for star-patch integration, i.e patch integration with masked patch boundaries. Since PR[#1138](https://github.com/gridap/Gridap.jl/pull/1138).
14+
- Added compatibility for `DataStructures.jl` v0.19.0. Since PR[#1149](https://github.com/gridap/Gridap.jl/pull/1149).
15+
16+
### Changed
17+
18+
- Small modifications to `PolytopalQuadrature` to make it more flexible. Since PR[#1149](https://github.com/gridap/Gridap.jl/pull/1149).
1419

1520
### Fixed
1621

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Gridap"
22
uuid = "56d4f2e9-7ea1-5844-9cf6-b9c51ca7ce8e"
33
authors = ["Santiago Badia <santiago.badia@monash.edu>", "Francesc Verdugo <f.verdugo.rojano@vu.nl>", "Alberto F. Martin <alberto.f.martin@anu.edu.au>"]
4-
version = "0.19.3"
4+
version = "0.19.4"
55

66
[deps]
77
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
@@ -37,7 +37,7 @@ Aqua = "0.8"
3737
BSON = "0.3.4"
3838
BlockArrays = "1"
3939
Combinatorics = "1"
40-
DataStructures = "0.18.13"
40+
DataStructures = "0.18.13, 0.19"
4141
DocStringExtensions = "0.8.1, 0.9"
4242
FastGaussQuadrature = "0.4.5, 1"
4343
FileIO = "1.5"

src/Adaptivity/EdgeBasedRefinement.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,9 @@ function setup_edge_based_rrules(
421421
# Propagate red/green flags
422422
# Queue invariant: Cells in queue are RED, every RED cell is only touched once
423423
q = Queue{Int}()
424-
map(c->enqueue!(q,c),cells_to_refine)
424+
map(c->push!(q,c),cells_to_refine)
425425
while !isempty(q)
426-
c = dequeue!(q)
426+
c = popfirst!(q)
427427
c_edges = c2e_map[c]
428428

429429
# For each non-red neighboring cell
@@ -439,7 +439,7 @@ function setup_edge_based_rrules(
439439
cell_color[nbor] = RED + Int8(cell_types[nbor]-1)
440440
is_red[nbor] = true
441441
is_refined[nbor_edges] .= true
442-
enqueue!(q,nbor)
442+
push!(q,nbor)
443443
end
444444
end
445445
end

src/Adaptivity/PolytopalRefinement.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11

2+
# Notes:
3+
# We need to restrict the input to PolytopalDiscreteModel. This would not be strictly
4+
# necessary (we can still aggregate other models), but we are currently limited
5+
# because we need that all polytopes are positively-oriented rotation systems (like GeneralPolytopes).
6+
# Unfortunately our ExtrusionPolytopes are not.
7+
# To make it work for any model, we would have to reindex the face nodes to ensure the faces
8+
# are correctly oriented.
9+
210
function coarsen(model::Geometry.PolytopalDiscreteModel,ptopo::Geometry.PatchTopology)
311
new_polys, new_connectivity = generate_patch_polytopes(model,ptopo)
412

src/FESpaces/Assemblers.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ function collect_and_merge_cell_matrix_and_vector(contributions...)
571571
end
572572

573573
function merge_assembly_data(data...)
574-
@assert allequal(length,data)
574+
@assert allequal(map(length,data))
575575
map(vcat,data...)
576576
end
577577

src/ReferenceFEs/ExtrusionPolytopes.jl

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -305,25 +305,25 @@ function positive_simplexify_hypercube(dim::Integer)
305305
end
306306

307307
function simplexify_hypercube(dim::Int)
308-
@assert dim 0
309-
# Determine simplices recursively
310-
simplices = Vector{Int}[]
311-
corner = 0
312-
vertices = [corner]
313-
next_corner!(simplices, dim, vertices, corner)
314-
# Correct vertex numbering
315-
for s in simplices
316-
s .+= 1
308+
@assert dim 0
309+
# Determine simplices recursively
310+
simplices = Vector{Int}[]
311+
corner = 0
312+
vertices = [corner]
313+
next_corner!(simplices, dim, vertices, corner)
314+
# Correct vertex numbering
315+
for s in simplices
316+
s .+= 1
317+
end
318+
# Check output
319+
@assert length(simplices) == factorial(dim)
320+
for s in simplices
321+
@assert length(s) == dim+1
322+
for v in s
323+
@assert 1 v 2^dim
317324
end
318-
# Check output
319-
@assert length(simplices) == factorial(dim)
320-
for s in simplices
321-
@assert length(s) == dim+1
322-
for v in s
323-
@assert 1 v 2^dim
324-
end
325-
end
326-
return simplices
325+
end
326+
return simplices
327327
end
328328

329329
"""
@@ -346,22 +346,22 @@ the top. The algorithm below finds all possible paths.
346346
"""
347347
function next_corner!(simplices::Vector{Vector{Int}}, dim::Int,
348348
vertices::Vector{Int}, corner::Int)
349-
@assert count_ones(corner) == length(vertices) - 1
350-
if length(vertices) == dim + 1
351-
# We have all vertices; save the simplex
352-
push!(simplices, vertices)
353-
return
354-
end
355-
# Loop over all neighbouring corners
356-
for d in 1:dim
357-
bit = 1 << (d-1)
358-
if (corner & bit) == 0
359-
new_corner = corner | bit
360-
new_vertices = [vertices; new_corner]
361-
next_corner!(simplices, dim, new_vertices, new_corner)
362-
end
363-
end
349+
@assert count_ones(corner) == length(vertices) - 1
350+
if length(vertices) == dim + 1
351+
# We have all vertices; save the simplex
352+
push!(simplices, vertices)
364353
return
354+
end
355+
# Loop over all neighbouring corners
356+
for d in 1:dim
357+
bit = 1 << (d-1)
358+
if (corner & bit) == 0
359+
new_corner = corner | bit
360+
new_vertices = [vertices; new_corner]
361+
next_corner!(simplices, dim, new_vertices, new_corner)
362+
end
363+
end
364+
return
365365
end
366366

367367
function Base.show(io::IO,p::ExtrusionPolytope)

src/ReferenceFEs/PolytopalQuadratures.jl

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,36 @@
11

2-
struct PolytopalQuadrature{D,T,P<:GeneralPolytope{D},Q<:Quadrature{D,T}} <: Quadrature{D,T}
3-
poly :: P
4-
quad :: Q
5-
conn :: Vector{Vector{Int32}}
2+
struct PolytopalQuadrature{D,Dp,T,Q<:Quadrature{D,T}} <: Quadrature{D,T}
3+
quad :: Q
4+
conn :: Vector{Vector{Int32}}
5+
coords :: Vector{Point{Dp,T}}
6+
function PolytopalQuadrature(
7+
quad::Quadrature{D,T},
8+
conn::Vector{Vector{Int32}},
9+
coords::Vector{Point{Dp,T}}
10+
) where {D,Dp,T}
11+
Q = typeof(quad)
12+
new{D,Dp,T,Q}(quad, conn, coords)
13+
end
614
end
715

816
function Quadrature(poly::GeneralPolytope{D},args...;kwargs...) where D
917
conn, simplex = simplexify(poly)
1018
quad = Quadrature(simplex,args...;kwargs...)
11-
PolytopalQuadrature(poly,quad,conn)
19+
coords = get_vertex_coordinates(poly)
20+
PolytopalQuadrature(quad,conn,coords)
1221
end
1322

1423
function Quadrature(poly::GeneralPolytope{D},quad::Quadrature{D}) where D
1524
conn, simplex = simplexify(poly)
25+
coords = get_vertex_coordinates(poly)
1626
@check get_polytope(quad) == simplex
17-
PolytopalQuadrature(poly,quad,conn)
27+
PolytopalQuadrature(quad,conn,coords)
1828
end
1929

2030
# Quadrature API
2131

22-
function get_name(q::PolytopalQuadrature{D,T,P,Q}) where {D,T,P,Q}
23-
"PolytopalQuadrature{$(D),$(T),$(P),$(Q)}"
32+
function get_name(q::PolytopalQuadrature{D,T,Q}) where {D,T,Q}
33+
"PolytopalQuadrature{$(D),$(T),$(Q)}"
2434
end
2535

2636
get_coordinates(q::PolytopalQuadrature) = evaluate(PQuadCoordsMap(),q)
@@ -40,8 +50,7 @@ end
4050
struct PQuadCoordsMap <: Map end
4151

4252
function Arrays.return_cache(::PQuadCoordsMap, q::PolytopalQuadrature)
43-
conn = q.conn
44-
coords = get_vertex_coordinates(q.poly)
53+
conn, coords = q.conn, q.coords
4554
cmap = affine_map(Tuple(coords[first(conn)]))
4655

4756
x = get_coordinates(q.quad)
@@ -54,8 +63,7 @@ end
5463

5564
function Arrays.evaluate!(cache,::PQuadCoordsMap, q::PolytopalQuadrature)
5665
y_cache, cmap_cache = cache
57-
coords = get_vertex_coordinates(q.poly)
58-
conn = q.conn
66+
conn, coords = q.conn, q.coords
5967

6068
x = get_coordinates(q.quad)
6169
setsize!(y_cache,(length(x)*length(conn),))
@@ -78,8 +86,7 @@ function Arrays.return_cache(::PQuadWeightsMap, q::PolytopalQuadrature)
7886
end
7987

8088
function Arrays.evaluate!(cache,::PQuadWeightsMap, q::PolytopalQuadrature)
81-
conn = q.conn
82-
coords = get_vertex_coordinates(q.poly)
89+
conn, coords = q.conn, q.coords
8390

8491
w = get_weights(q.quad)
8592
setsize!(cache,(length(w)*length(conn),))

src/ReferenceFEs/TensorProductQuadratures.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ end
1919
# Low level constructor
2020

2121
function _tensor_product_legendre(degrees;T::Type{<:AbstractFloat}=Float64)
22-
D = length(degrees)
23-
npoints = [ ceil(Int,(degrees[i]+1.0)/2.0) for i in 1:D ]
24-
quads = [ gauss(T, npoints[i]) for i in 1:D ]
25-
for i in 1:D
26-
quads[i][1] .+= 1;
27-
quads[i][1] .*= 1.0/2.0
28-
quads[i][2] .*= 1.0/2.0
29-
end
30-
(coords, weights) = _tensor_product(Point{D,T},quads,npoints)
31-
GenericQuadrature(coords,weights,"Tensor product of 1d Gauss-Legendre quadratures of degrees $degrees")
22+
D = length(degrees)
23+
npoints = [ ceil(Int,(degrees[i]+1.0)/2.0) for i in 1:D ]
24+
quads = [ gauss(T, npoints[i]) for i in 1:D ]
25+
for i in 1:D
26+
quads[i][1] .+= 1;
27+
quads[i][1] .*= 1.0/2.0
28+
quads[i][2] .*= 1.0/2.0
29+
end
30+
(coords, weights) = _tensor_product(Point{D,T},quads,npoints)
31+
GenericQuadrature(coords,weights,"Tensor product of 1d Gauss-Legendre quadratures of degrees $degrees")
3232
end
3333

3434
# Helpers

0 commit comments

Comments
 (0)