Skip to content

improve code reuse in tests - #352

Open
jacobmerson wants to merge 1 commit into
SCOREC:developfrom
jacobmerson:test-utils-reuse
Open

improve code reuse in tests#352
jacobmerson wants to merge 1 commit into
SCOREC:developfrom
jacobmerson:test-utils-reuse

Conversation

@jacobmerson

Copy link
Copy Markdown
Collaborator

Factor the repeated mesh construction, function-space creation, field sampling and evaluation boilerplate out of the individual test translation units and into field_test_utils.h:

  • BuildUnitSquare / MakeP1Space / MakeP0Space for the unit-square simplex meshes used across the transfer and evaluation tests
  • IntegrateP0Field / IntegrateP1Field for conservation checks
  • EvaluateAndAssemble for the sample-then-assemble pattern shared by the linear form integrator tests
  • StandardOutsideCoords2D for out-of-bounds policy tests

SetField now dispatches on the arity of the supplied callable so the same helper covers 2D and 3D layouts, and it samples the layout's DOF coordinates directly instead of copying them into a fixed-rank view. The evaluation helpers use rank-2 output views through MakeRank2View rather than hand-built Rank2Views over rank-1 storage.

Factor the repeated mesh construction, function-space creation, field
sampling and evaluation boilerplate out of the individual test
translation units and into field_test_utils.h:

  - BuildUnitSquare / MakeP1Space / MakeP0Space for the unit-square
    simplex meshes used across the transfer and evaluation tests
  - IntegrateP0Field / IntegrateP1Field for conservation checks
  - EvaluateAndAssemble for the sample-then-assemble pattern shared by
    the linear form integrator tests
  - StandardOutsideCoords2D for out-of-bounds policy tests

SetField now dispatches on the arity of the supplied callable so the
same helper covers 2D and 3D layouts, and it samples the layout's DOF
coordinates directly instead of copying them into a fixed-rank view.
The evaluation helpers use rank-2 output views through MakeRank2View
rather than hand-built Rank2Views over rank-1 storage.

No behavioral change to the tests themselves.
@jacobmerson jacobmerson changed the title test: share common setup helpers via field_test_utils.h improve code reuse in tests Aug 6, 2026
@jacobmerson
jacobmerson marked this pull request as ready for review August 6, 2026 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant