From 5cc9e0bb7121f3567e485e4a22f97a362c3df7e8 Mon Sep 17 00:00:00 2001 From: Oriol Colomes Date: Wed, 31 Jan 2024 13:05:15 +0100 Subject: [PATCH 1/2] fixes in CellStates --- src/CellData/CellFields.jl | 7 +++++++ src/CellData/CellStates.jl | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) 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 From df86051a8849a4319f4552c96e7180dc3f984cb6 Mon Sep 17 00:00:00 2001 From: Oriol Colomes Date: Wed, 27 Mar 2024 20:51:36 +0100 Subject: [PATCH 2/2] Added tests --- test/CellDataTests/CellStatesTests.jl | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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