Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Less noisy PointEvalHandler #1086

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/PointEvalHandler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@
end
break
end
if calculate_detJ(J) ≤ 0.0
# Report if the element is geometrically broken at the converged point
if converged && calculate_detJ(J) ≤ 0.0
converged = false

Check warning on line 145 in src/PointEvalHandler.jl

View check run for this annotation

Codecov / codecov/patch

src/PointEvalHandler.jl#L145

Added line #L145 was not covered by tests
warn && @warn "det(J) negative! Aborting! $(calculate_detJ(J))"
break
end
Expand Down
10 changes: 10 additions & 0 deletions test/test_pointevaluation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function test_pe_scalar_field()
projector_vals = project(projector, qp_vals, qr)

# set up PointEvalHandler and retrieve values
@test_logs min_level=Logging.Warn PointEvalHandler(mesh, points)
ph = PointEvalHandler(mesh, points)
@test all(x -> x !== nothing, ph.cells)

Expand Down Expand Up @@ -76,6 +77,7 @@ function test_pe_embedded()
projector_vals = project(projector, qp_vals, qr)

# set up PointEvalHandler and retrieve values
@test_logs min_level=Logging.Warn PointEvalHandler(mesh, points)
ph = PointEvalHandler(mesh, points)
@test all(x -> x !== nothing, ph.cells)

Expand Down Expand Up @@ -115,6 +117,7 @@ function test_pe_vector_field()
points = [Vec((x, 0.52)) for x in range(0.0; stop=1.0, length=100)]

# set up PointEvalHandler and retrieve values
@test_logs min_level=Logging.Warn PointEvalHandler(mesh, points)
ph = PointEvalHandler(mesh, points)
@test all(x -> x !== nothing, ph.cells)
vals = evaluate_at_points(ph, projector, projector_vals)
Expand Down Expand Up @@ -152,6 +155,7 @@ function test_pe_superparametric()
points = [Vec((x, 0.52)) for x in range(0.0; stop=1.0, length=100)]

# set up PointEvalHandler and retrieve values
@test_logs min_level=Logging.Warn PointEvalHandler(mesh, points)
ph = PointEvalHandler(mesh, points)
@test all(x -> x !== nothing, ph.cells)
vals = evaluate_at_points(ph, projector, projector_vals)
Expand All @@ -170,6 +174,7 @@ function test_pe_dofhandler()
add!(dh, :s, Lagrange{RefQuadrilateral,1}()) # a scalar field
close!(dh)

@test_logs min_level=Logging.Warn PointEvalHandler(mesh, points)
ph = PointEvalHandler(mesh, points)
@test all(x -> x !== nothing, ph.cells)
vals = evaluate_at_points(ph, dh, dof_vals, :s)
Expand Down Expand Up @@ -254,6 +259,7 @@ function test_pe_dofhandler2(;three_dimensional=true)
v_dofs = dof_range(dh, :v)
uh = _pointeval_dofhandler2_manual_projection(dh, csv, cvv, f_s, f_v)

@test_logs min_level=Logging.Warn PointEvalHandler(mesh, points)
ph = PointEvalHandler(mesh, points)
@test all(x -> x !== nothing, ph.cells)
psv = PointValues(ip_f)
Expand Down Expand Up @@ -333,6 +339,7 @@ function test_pe_mixed_grid()

# first alternative: L2Projection to dofs
projector_values = project(projector, qp_vals_quads, qr)
@test_logs min_level=Logging.Warn PointEvalHandler(mesh, points)
ph = PointEvalHandler(mesh, points)
@test all(x -> x !== nothing, ph.cells)
vals = evaluate_at_points(ph, projector, projector_values)
Expand All @@ -349,6 +356,7 @@ function test_pe_mixed_grid()

dof_vals = [1., 1., 2., 2., 4., 4., 3., 3., 6., 6., 5., 5.]
points = [node.x for node in mesh.nodes]
@test_logs min_level=Logging.Warn PointEvalHandler(mesh, points)
ph = PointEvalHandler(mesh, points)
@test all(x -> x !== nothing, ph.cells)
vals = evaluate_at_points(ph, dh, dof_vals, :v)
Expand Down Expand Up @@ -384,6 +392,7 @@ function test_pe_oneD()
points = [Vec((x,)) for x in range(-1.0; stop=1.0, length=5)]

# set up PointEvalHandler and retrieve values
@test_logs min_level=Logging.Warn PointEvalHandler(mesh, points)
ph = PointEvalHandler(mesh, points)
@test all(x -> x !== nothing, ph.cells)
vals = evaluate_at_points(ph, projector, projector_values)
Expand All @@ -398,6 +407,7 @@ end
function test_pe_first_point_missing()
mesh = generate_grid(Quadrilateral, (1, 1))
points = [Vec(2.0, 0.0), Vec(0.0, 0.0)]
@test_logs min_level=Logging.Warn PointEvalHandler(mesh, points; warn=false)
ph = PointEvalHandler(mesh, points; warn=false)

@test isnothing(ph.local_coords[1])
Expand Down