Skip to content

Templated tests - #110

Open
jacobmerson wants to merge 19 commits into
SCOREC:mainfrom
jacobmerson:templated-tests
Open

jacobmerson wants to merge 19 commits into
SCOREC:mainfrom
jacobmerson:templated-tests

Conversation

@jacobmerson

Copy link
Copy Markdown
Contributor

This PR is based on #109 and will look much more sensible after that is merged. Please use merge instead of rebase for that PR as otherwise it'll make merging this PR more challenging.

The goal of this PR is to reduce the repeated test code and make the tests more consistent in terms of what's tested across the different backends/element types.

Once #109 is merged, this PR should net roughly -1800 lines of code despite expanding the coverage and making it easier to add tests for new controllers, element types, etc.

jacobmerson and others added 19 commits October 6, 2026 02:48
This performs interpolation to target elements. We use ownership to
avoid having multiple element write to the same dofs on shared entities.
This interpolation capability will be used to support generic coordinate
field initialization for higher order elements.
cannot have lambdas in function with auto return type with cuda
To support non-isoparametic elements, we split the evaluation of the
nodal coefficients and the multiplication with the shape functions
MappedElement composes a field element with a geometry element over the
coordinate field (see SCOREC#100)
In the case of affine (straight sided) and isoparametric elements
we will want to take compile-time optimized code paths so the
performance of a MappedElement is similar to a base FieldElement
The TestHarness runs tests with all available controllers and mesh
types. This will improve generalizability as we add additional mesh
types e.g., mixed and new element types e.g., quads
This combines the jacobian tests into a single test case
@jacobmerson

Copy link
Copy Markdown
Contributor Author

When this gets reviewed, please consider adding Catch2 as a dependency and using a proper test framework rather than this one that Claude and I came up with. Here is the example of what some of those tests look like with Catch2 instead. But Catch2 also has matchers for comparing floating point values, better reporting of expected values, integration with cmake, etc.

// testController.cpp
#ifdef MESHFIELDS_ENABLE_CABANA
#define CONTROLLERS (KokkosRanks, CabanaRanks)
#else
#define CONTROLLERS (KokkosRanks)
#endif

TEMPLATE_PRODUCT_TEST_CASE("fields of each rank", "[controller]",
                           CONTROLLERS, (int, double)) {
  auto c = createRanks<TestType>();          // name: "... - KokkosRanks<int>"
  SECTION("rank 1") { testRank<1>(c, rank1); }
  SECTION("rank 2") { testRank<2>(c, rank2); }
  // ...
}

template <int R, typename Ctrlr> void testRank(Ctrlr &c, Extents n) {
  auto field = MeshField::makeField<Ctrlr, R - 1>(c);
  CHECK(extentMismatches<R>(field, n) == 0);
  fill<R>(field, n);
  CHECK(mismatches<R>(field, n) == 0);       // failure prints "3 == 0"
}

For the case with several axes (reproduction):

template <template <typename...> class C, size_t D, class E> struct Cfg {
  template <typename... Ts> using Controller = C<Ts...>;
  static constexpr size_t dim = D; using Element = E;
};
using Configs = CartesianProduct<Controllers, Dims, Elements>; // std::tuple<Cfg<...>...>

TEMPLATE_LIST_TEST_CASE("reproduction", "[reproduction]", Configs) {
  using C = TestType;
  auto &mesh = cachedMesh<C::dim>();
  SECTION("identity") { testOrders<C>(mesh, MeshField::IdentityCoordinateMap{}); }
  SECTION("shear")    { testOrders<C>(mesh, Shear<C::dim>{}); }
}

This branch was previously deployed

1 inactive deployment
asics — 15e9a342 Deployed Oct 11, 2026 by jacobmerson via build_and_test #19
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