Skip to content

Conversation

Copy link

Copilot AI commented Jan 29, 2026

Describe your changes here:

Adds component test suite for curved geometry integration testing using Lagrange interpolation.

Test Coverage

New test file test/t8_geometry/t8_gtest_geometry_curved.cxx validates the integration of curved geometries in the complete t8code workflow:

  • CMesh creation with Lagrange geometry and polynomial degree attributes
  • Forest integration with curved geometries using t8_forest_new_uniform

Tests are parameterized across element types (Quad, Triangle, Hex) and polynomial degrees (1, 2), yielding 12 test cases total.

Test Focus

This test suite complements the existing unit tests in t8_gtest_geometry_lagrange.cxx by focusing on component integration rather than mathematical correctness:

  • Existing Lagrange tests: Verify mathematical correctness of Lagrange geometry mappings using direct element evaluation
  • New component tests: Verify integration workflow - cmesh with curved geometry → forest creation → geometry accessibility

Implementation Notes

  • Polynomial degree stored via T8_CMESH_LAGRANGE_POLY_DEGREE_KEY attribute, not geometry constructor
  • Uses t8_forest_new_uniform for forest creation with curved geometries
  • Tests verify geometry remains accessible through forest's cmesh after creation

All these boxes must be checked by the AUTHOR before requesting review:

  • The PR is small enough to be reviewed easily. If not, consider splitting up the changes in multiple PRs.
  • The title starts with one of the following prefixes: Documentation:, Bugfix:, Feature:, Improvement: or Other:.
  • If the PR is related to an issue, make sure to link it.
  • The author made sure that, as a reviewer, he/she would check all boxes below.

All these boxes must be checked by the REVIEWERS before merging the pull request:

As a reviewer please read through all the code lines and make sure that the code is fully understood, bug free, well-documented and well-structured.

General

  • The reviewer executed the new code features at least once and checked the results manually.
  • The code follows the t8code coding guidelines.
  • New source/header files are properly added to the CMake files.
  • The code is well documented. In particular, all function declarations, structs/classes and their members have a proper doxygen documentation. Make sure to add a file documentation for each file!
  • All new algorithms and data structures are sufficiently optimal in terms of memory and runtime (If this should be merged, but there is still potential for optimization, create a new issue).

Tests

  • The code is covered in an existing or new test case using Google Test.
  • The code coverage of the project (reported in the CI) should not decrease. If coverage is decreased, make sure that this is reasonable and acceptable.
  • Valgrind doesn't find any bugs in the new code. This script can be used to check for errors; see also this wiki article.

If the Pull request introduces code that is not covered by the github action (for example coupling with a new library):

  • Should this use case be added to the github action?
  • If not, does the specific use case compile and all tests pass (check manually).

Scripts and Wiki

  • If a new directory with source files is added, it must be covered by the script/find_all_source_files.scp to check the indentation of these files.
  • If this PR introduces a new feature, it must be covered in an example or tutorial and a Wiki article.

License

  • The author added a BSD statement to doc/ (or already has one).

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 8 commits January 29, 2026 14:57
Co-authored-by: sandro-elsweijer <49643115+sandro-elsweijer@users.noreply.github.com>
Co-authored-by: sandro-elsweijer <49643115+sandro-elsweijer@users.noreply.github.com>
Co-authored-by: sandro-elsweijer <49643115+sandro-elsweijer@users.noreply.github.com>
Co-authored-by: sandro-elsweijer <49643115+sandro-elsweijer@users.noreply.github.com>
Co-authored-by: sandro-elsweijer <49643115+sandro-elsweijer@users.noreply.github.com>
Co-authored-by: sandro-elsweijer <49643115+sandro-elsweijer@users.noreply.github.com>
…espace

Co-authored-by: sandro-elsweijer <49643115+sandro-elsweijer@users.noreply.github.com>
Co-authored-by: sandro-elsweijer <49643115+sandro-elsweijer@users.noreply.github.com>
Copilot AI changed the title [WIP] Add component test for curved geometries Feature: Add component test for curved geometries Jan 29, 2026
Copy link
Member

@sandro-elsweijer sandro-elsweijer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also check, that we already have a test for the lagrange geometry. these tests should complement them and not test the same things

t8code is a C library to manage a collection (a forest) of multiple
connected adaptive space-trees of general element classes in parallel.

Copyright (C) 2024 the developers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong copyright year

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 6450150.

Comment on lines 44 to 45
* \param eclass Element class of the element.
* \param degree Polynomial degree for Lagrange interpolation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ in ] is missing

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 6450150.

Comment on lines 192 to 195
t8_forest_init (&forest);
t8_forest_set_cmesh (forest, cmesh, sc_MPI_COMM_WORLD);
t8_forest_set_scheme (forest, t8_scheme_new_default ());
t8_forest_set_level (forest, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can just use t8_forest_new_uniform for this

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to use t8_forest_new_uniform in commit 6450150.

Comment on lines 208 to 244
/**
* Test forest refinement with curved geometry.
*/
TEST_P (CurvedGeometry, forest_refinement_with_curved_geometry)
{
t8_cmesh_t cmesh;
t8_forest_t forest, forest_refined;

/* Create a single-tree cmesh with Lagrange geometry */
create_curved_cmesh (&cmesh);

/* Create initial forest at level 0 */
t8_forest_init (&forest);
t8_forest_set_cmesh (forest, cmesh, sc_MPI_COMM_WORLD);
t8_forest_set_scheme (forest, t8_scheme_new_default ());
t8_forest_set_level (forest, 0);
t8_forest_commit (forest);

/* Create a refined forest at level 2 */
t8_forest_init (&forest_refined);
t8_forest_set_cmesh (forest_refined, t8_forest_get_cmesh (forest), sc_MPI_COMM_WORLD);
t8_forest_set_scheme (forest_refined, t8_scheme_new_default ());
t8_forest_set_level (forest_refined, 2);

/* Commit the refined forest - this should work with curved geometry */
ASSERT_NO_THROW (t8_forest_commit (forest_refined));

/* Verify refinement worked */
ASSERT_NE (forest_refined, nullptr) << "Forest refinement failed with curved geometry.";
ASSERT_GT (t8_forest_get_local_num_leaf_elements (forest_refined),
t8_forest_get_local_num_leaf_elements (forest))
<< "Refined forest should have more elements than original.";

/* Clean up */
t8_forest_unref (&forest_refined);
t8_forest_unref (&forest);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is testing forest functionality and not geometry functionality

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in commit 6450150. The test now focuses on component integration (cmesh with curved geometry → forest → geometry access) rather than testing forest functionality.

Comment on lines 180 to 206
/**
* Test that a forest can be created from a cmesh with curved geometry.
*/
TEST_P (CurvedGeometry, forest_creation_with_curved_geometry)
{
t8_cmesh_t cmesh;
t8_forest_t forest;

/* Create a single-tree cmesh with Lagrange geometry */
create_curved_cmesh (&cmesh);

/* Create a forest from the curved cmesh */
t8_forest_init (&forest);
t8_forest_set_cmesh (forest, cmesh, sc_MPI_COMM_WORLD);
t8_forest_set_scheme (forest, t8_scheme_new_default ());
t8_forest_set_level (forest, 0);

/* Commit the forest - this should work with curved geometry */
ASSERT_NO_THROW (t8_forest_commit (forest));

/* Verify the forest was created successfully */
ASSERT_NE (forest, nullptr) << "Forest creation failed with curved geometry.";
ASSERT_EQ (t8_forest_get_num_global_trees (forest), 1) << "Forest should have exactly one tree.";

/* Clean up */
t8_forest_unref (&forest);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is testing forest functionality and not geometry functionality

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in commit 6450150. The test now focuses on component integration (cmesh with curved geometry → forest → geometry access) rather than testing forest functionality.

Comment on lines 257 to 262
const t8_geometry *geom = t8_cmesh_get_tree_geometry (cmesh, 0);
ASSERT_NE (geom, nullptr) << "Failed to get geometry from cmesh.";

/* Load tree data before evaluation - this is required for geometries that store per-tree data */
/* Cast to non-const to call load function - this is safe as we're just loading data */
const_cast<t8_geometry *> (geom)->t8_geom_load_tree_data (cmesh, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is all done automatically by the geom handler. no reason to access the geometry directly

Comment on lines 272 to 276
/* Verify output coordinates are reasonable (not NaN or infinity) */
for (int i = 0; i < 3; ++i) {
ASSERT_FALSE (std::isnan (out_coords[i])) << "Geometry evaluation produced NaN at coordinate " << i;
ASSERT_FALSE (std::isinf (out_coords[i])) << "Geometry evaluation produced infinity at coordinate " << i;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not exactly accurate. This catches only if something goes really really wrong. It does not check if the results are correct.

@sandro-elsweijer
Copy link
Member

Oh and you can run the CI by adding [run ci] to your commit messages

Copilot AI and others added 2 commits January 29, 2026 15:34
Co-authored-by: sandro-elsweijer <49643115+sandro-elsweijer@users.noreply.github.com>
Co-authored-by: sandro-elsweijer <49643115+sandro-elsweijer@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jan 29, 2026

Please also check, that we already have a test for the lagrange geometry. these tests should complement them and not test the same things

Updated in commit 6450150. The test now complements the existing Lagrange tests by focusing on component integration testing (cmesh → forest workflow with curved geometry) rather than testing the mathematical correctness of Lagrange mappings (which is already covered in t8_gtest_geometry_lagrange.cxx). The forest-specific tests have been removed.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@sandro-elsweijer
Copy link
Member

Yeah okay, when you are iterating over the review you are not checking the results again. But this was a good test run.

@sandro-elsweijer sandro-elsweijer deleted the copilot/add-curved-geometries-test branch January 29, 2026 15:52
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.

2 participants