-
Notifications
You must be signed in to change notification settings - Fork 63
Feature: Add component test for curved geometries #2125
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
Conversation
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>
sandro-elsweijer
left a comment
There was a problem hiding this 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong copyright year
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 6450150.
| * \param eclass Element class of the element. | ||
| * \param degree Polynomial degree for Lagrange interpolation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[ in ] is missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in commit 6450150.
| 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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
| /** | ||
| * 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); | ||
| } |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
| /** | ||
| * 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); | ||
| } |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
| 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); |
There was a problem hiding this comment.
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
| /* 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; | ||
| } |
There was a problem hiding this comment.
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.
|
Oh and you can run the CI by adding |
Co-authored-by: sandro-elsweijer <49643115+sandro-elsweijer@users.noreply.github.com>
Co-authored-by: sandro-elsweijer <49643115+sandro-elsweijer@users.noreply.github.com>
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:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
Yeah okay, when you are iterating over the review you are not checking the results again. But this was a good test run. |
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.cxxvalidates the integration of curved geometries in the complete t8code workflow:t8_forest_new_uniformTests 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.cxxby focusing on component integration rather than mathematical correctness:Implementation Notes
T8_CMESH_LAGRANGE_POLY_DEGREE_KEYattribute, not geometry constructort8_forest_new_uniformfor forest creation with curved geometriesAll these boxes must be checked by the AUTHOR before requesting review:
Documentation:,Bugfix:,Feature:,Improvement:orOther:.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
Tests
If the Pull request introduces code that is not covered by the github action (for example coupling with a new library):
Scripts and Wiki
script/find_all_source_files.scpto check the indentation of these files.License
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.