diff --git a/src/CellData/CellFields.jl b/src/CellData/CellFields.jl index ba988ff8f..9d613498b 100644 --- a/src/CellData/CellFields.jl +++ b/src/CellData/CellFields.jl @@ -57,6 +57,13 @@ function get_cell_points(trian::Triangulation) CellPoint(cell_ref_coords,cell_phys_coords,trian,ReferenceDomain()) end +function Base.:(==)(a::CellPoint,b::CellPoint) + a.trian == b.trian && + a.cell_ref_point == b.cell_ref_point && + a.cell_phys_point == b.cell_phys_point && + a.domain_style == b.domain_style +end + """ """ abstract type CellField <: CellDatum end diff --git a/src/CellData/CellStates.jl b/src/CellData/CellStates.jl index b4d4c956a..3fa59aec3 100644 --- a/src/CellData/CellStates.jl +++ b/src/CellData/CellStates.jl @@ -52,8 +52,10 @@ end get_triangulation(f::CellState) = get_triangulation(f.points) DomainStyle(::Type{CellState{T,P}}) where {T,P} = DomainStyle(P) +_get_cell_points(a::CellState) = a.points + function evaluate!(cache,f::CellState,x::CellPoint) - if f.points === x + if f.points == x f.values else @unreachable """\n diff --git a/test/CellDataTests/CellStatesTests.jl b/test/CellDataTests/CellStatesTests.jl index e1422c911..74368a7bc 100644 --- a/test/CellDataTests/CellStatesTests.jl +++ b/test/CellDataTests/CellStatesTests.jl @@ -58,4 +58,16 @@ r = r1*r2*h #using Gridap.Visualization #writevtk(x,"x",cellfields=["f"=>f,"g"=>g]) +# Test for evaluating operations involving cellstates +model = CartesianDiscreteModel((0.0,1.0,0,1.0,0,1),(2,1,1)) +Ω = Interior(model,[1,2]) +Γ = Boundary(Ω) +dΩ = Measure(Ω,0) +dΓ = Measure(Γ,0) +a = CellState(1.0,dΩ) +b = CellState(1.0,dΓ) +id(z)=z +@test sum(∫((id∘a))dΩ) == sum(∫(a)dΩ) +@test sum(∫((id∘b))dΓ) == sum(∫(b)dΓ) + end # module