Skip to content

Commit 956a537

Browse files
committed
Added NonIterableCellMaps
1 parent 2c490dc commit 956a537

File tree

4 files changed

+66
-0
lines changed

4 files changed

+66
-0
lines changed

src/CellValues/NonIterableCellMaps.jl

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module NonIterableCellMaps
2+
3+
using Gridap
4+
using Gridap.Helpers
5+
6+
export UnimplementedMap
7+
export NonIterableCellMap
8+
import Base: iterate
9+
import Gridap: evaluate
10+
import Gridap: return_size
11+
12+
struct UnimplementedMap{S,M,T,N} <: Map{S,M,T,N} end
13+
14+
function evaluate!(
15+
this::UnimplementedMap{S,M,T,N},
16+
points::AbstractArray{<:S,M},
17+
v::AbstractArray{T,N}) where {S,M,T,N}
18+
@notimplemented
19+
end
20+
21+
function return_size(::UnimplementedMap{S,M,T,N},::NTuple{M,Int}) where {S,M,T,N}
22+
@notimplemented
23+
end
24+
25+
abstract type NonIterableCellMap{S,M,T,N} <: IterCellValue{UnimplementedMap{S,M,T,N}} end
26+
27+
function iterate(::NonIterableCellMap)
28+
_error()
29+
end
30+
31+
function iterate(::NonIterableCellMap,state)
32+
_error()
33+
end
34+
35+
function _error()
36+
error("Iteration is intentionally disabled for this type.")
37+
end
38+
39+
end # module

src/CellValues/files.jl

+3
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,7 @@ include("ConstantCellValues.jl")
5050
include("CompressedCellValues.jl")
5151
@reexport using Gridap.CompressedCellValues
5252

53+
include("NonIterableCellMaps.jl")
54+
@reexport using Gridap.NonIterableCellMaps
55+
5356

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module NonIterableCellMapsTests
2+
3+
using Test
4+
using Gridap
5+
6+
struct Foo <: NonIterableCellMap{Point{2},1,Int,1} end
7+
8+
foo = Foo()
9+
10+
@test isa(foo,CellMap)
11+
12+
try
13+
iterate(foo)
14+
catch LoadError
15+
end
16+
17+
try
18+
iterate(foo,2)
19+
catch LoadError
20+
end
21+
22+
end # module

test/CellValuesTests/runtests.jl

+2
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,7 @@ include("MapsMocks.jl")
4040

4141
@testset "CompressedCellValues" begin include("CompressedCellValuesTests.jl") end
4242

43+
@testset "NonIterableCellMaps" begin include("NonIterableCellMapsTests.jl") end
44+
4345
end # module
4446

0 commit comments

Comments
 (0)