Skip to content

Commit

Permalink
Merge pull request #987 from gridap/fixes_evaluation_cellstate
Browse files Browse the repository at this point in the history
Fixes evaluation cellstate
  • Loading branch information
JordiManyer authored Mar 27, 2024
2 parents 92f38a2 + df86051 commit 4cf9e8a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/CellData/CellFields.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/CellData/CellStates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions test/CellDataTests/CellStatesTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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(Ω)
= Measure(Ω,0)
= Measure(Γ,0)
a = CellState(1.0,dΩ)
b = CellState(1.0,dΓ)
id(z)=z
@test sum(((ida))dΩ) == sum((a)dΩ)
@test sum(((idb))dΓ) == sum((b)dΓ)

end # module

0 comments on commit 4cf9e8a

Please sign in to comment.