Repository navigation
Fix NaN in parallel point evaluation with repeated knots - #614
Conversation
At the right bound of the local subdomain, `TensorFemSpace.eval_field` and `eval_field_gradient` moved back by one knot from the span given by `find_span`, which selects an empty knot span (and yields NaN) if the bound is a knot of multiplicity larger than one. Add the option `side='left'` to `psydac.core.bsplines.find_span`, which selects the non-empty knot span on the left of an interior knot of any multiplicity. Use it in the new private method `TensorFemSpace._find_local_span`, which replaces the code duplicated in `eval_field` and `eval_field_gradient`. Add unit tests for `find_span` with `side='left'`, and an MPI test which evaluates a linear field and its gradient on the closed local subdomains with simple, repeated and mixed knot multiplicities. Fixes #612.
Unlike `TensorFemSpace.eval_field`, `eval_field_gradient` did not update the ghost regions of the field coefficients when they were not in sync, and did not check the space of the weights. Add both, and check the weights with `is not None` in both methods. Add helper functions to the tests in `psydac.fem.tests.test_tensor`, and add an MPI test which evaluates the field or its gradient (separately) on the closed local subdomains, starting from coefficients whose ghost regions are not in sync.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 16 |
| Duplication | 4 |
🟢 Coverage 64.36% diff coverage
Metric Results Coverage variation Report missing for 9217e711 Diff coverage ✅ 64.36% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (9217e71) Report Missing Report Missing Report Missing Head commit (b927e26) 104760 67302 64.24% Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#614) 101 65 64.36% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%1 Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
jowezarek
left a comment
There was a problem hiding this comment.
I finally had a look, this PR looks good to me, no comments.
Pull request was converted to draft
Fix NaN values in the parallel point evaluation of fields at subdomain boundaries with repeated knots, as reported in issue #612, and make
TensorFemSpace.eval_field_gradientbehave likeeval_field. Fixes #612.Changes
psydac.core.bsplines.find_span: add the optionside, with values'right'(default, unchanged behavior) or'left'. Withside='left', ifxis an interior knot of any multiplicity, the function selects the non-empty knot span on the left ofx, i.e. such thatknots[span] < x <= knots[span+1]. It does so by skipping back over all copies ofxin the knot sequence.TensorFemSpace._find_local_span: new private method, which replaces the code duplicated ineval_fieldandeval_field_gradient. It moves a point lying outside of the local interval by at most one machine epsilon onto its closest bound, and usesfind_spanwithside='left'on the right bound of the local interval, whose right knot span belongs to the next process. The special case of the domain end is no longer needed.TensorFemSpace.eval_field_gradient: likeeval_field, update the ghost regions of the coefficients if they are not in sync, and check the space of the weights. In both methods, check the weights withis not None.Tests
psydac/core/tests/test_bsplines.py: newtest_find_span_side, for degrees 1 to 3 and simple, repeated, and mixed knot multiplicities.psydac/fem/tests/test_tensor.py:test_TensorFemSpace_eval_field_parallel(MPI): evaluates the linear fieldf(x, y) = x + 2yand its gradient on the closed local subdomains, with simple, repeated, and mixed knot multiplicities. Without the fix, the repeated and mixed cases fail (NaN) on all processes except the last one along each direction.test_TensorFemSpace_eval_field_ghost_regions(MPI): evaluates the field or its gradient (separately), starting from coefficients whose ghost regions are not in sync. Without the change toeval_field_gradient, the gradient case fails.The MPI tests pass on 1, 2, and 4 processes.