Skip to content
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

Enhance cmesh testing #871

Merged
merged 36 commits into from
Feb 13, 2024
Merged

Enhance cmesh testing #871

merged 36 commits into from
Feb 13, 2024

Conversation

Davknapp
Copy link
Collaborator

@Davknapp Davknapp commented Nov 29, 2023

This is a draft PR to discuss further needed changes of this new feature.

This branch provides a way to iterate over all of our cmeshes using googletest functionality.
It basically consists of two classes.

  • The base class cmesh_creator, a class to create cmeshes of similar type (for example all cmeshes that only need a communicator). It also holds the cmesh.
  • The class cmesh_generator, iterates over all cmesh_creators and all of the parameter-sets usable by each cmesh_creator. Overloads the +and < to be usable by testing::Range(start, end, step)` of the GoogleTestSuite.

I implemented two examples of a cmesh_creator, one for cmesh-examples that only get a communicator and one for examples that get a communicator and a number of trees.

Goal of this feature is to provide a way to test cmeshes, that is easily extendable by new testcases.
In the current setup one would either:
a) Add the new cmesh function to one of the existing cmesh_creators or
b) Implement a new 'cmesh_creator' and add it to the 'cmesh_generator'

As soon as this PR is merged, we would also be able to provide a MAKRO to iterate over all cmeshes and a customized assertion to check the equality of two cmeshes.

I will be happy about your opinion on this new feature!

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 Makefiles

  • The code is well documented

  • All function declarations, structs/classes and their members have a proper doxygen documentation

  • 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

Github action

  • The code compiles without warning in debugging and release mode, with and without MPI (this should be executed automatically in a github action)

  • All tests pass (in various configurations, this should be executed automatically in a github action)

    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/tutorial and a Wiki article.

Licence

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

@Davknapp Davknapp added enhancement Enhances already existing code New feature Adds a new feature to the code tests discussion draft Enhance the visibility that this is a draft. labels Nov 29, 2023
@Davknapp Davknapp marked this pull request as draft November 29, 2023 15:25
Copy link
Collaborator

@jmark jmark left a comment

Choose a reason for hiding this comment

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

Thanks for the interesting contribution @Davknapp !

I like the idea very much and we should definitely consider to migrate to this testing scheme soon!

However, in my view creating three C++ classes for this rather simple logic is shooting birds with guns. I suggest to consider a refactor.

As also noted in the line attached comments I suggest to simply create one C++ iterator class which spits out one cmesh after the other. Very simple, easy to comprehend and quick to extend with lots of cmesh variants.

Here some links. Probably just implement an output iterator. One proably does not need to implement all operators. We do not need to apply sort or random access or such fancy stuff.

https://www.internalpointers.com/post/writing-custom-iterators-modern-cpp
https://www.programiz.com/cpp-programming/iterators

test/t8_cmesh/t8_gtest_cmesh_copy.cxx Outdated Show resolved Hide resolved
test/t8_cmesh/t8_gtest_cmesh_copy.cxx Outdated Show resolved Hide resolved
test/t8_cmesh/t8_gtest_cmesh_copy.cxx Outdated Show resolved Hide resolved
@jmark jmark assigned Davknapp and unassigned jmark Jan 15, 2024
@Davknapp
Copy link
Collaborator Author

Thanks for the interesting contribution @Davknapp !

I like the idea very much and we should definitely consider to migrate to this testing scheme soon!

However, in my view creating three C++ classes for this rather simple logic is shooting birds with guns. I suggest to consider a refactor.

As also noted in the line attached comments I suggest to simply create one C++ iterator class which spits out one cmesh after the other. Very simple, easy to comprehend and quick to extend with lots of cmesh variants.

Here some links. Probably just implement an output iterator. One proably does not need to implement all operators. We do not need to apply sort or random access or such fancy stuff.

https://www.internalpointers.com/post/writing-custom-iterators-modern-cpp https://www.programiz.com/cpp-programming/iterators

The goal is to be able to run tests over a sum of cmeshes. I agree, for a single set of cmeshes (for example all cmeshes that only need a communicator, or all cmeshes that get a communicator and a number of trees to generate) it will be better to implement an iterator.
We want to iterate over varying number of parameters (not all functions creating a cmesh have the same number of arguments), this we way, we are able to specify how we iterate over a subset. Furthermore not all functions create valid cmeshes for all parameters, this way we are able to prevent such cmeshes. Additionally we can use the step to skip entire subsets of cmeshes. Maybe it is a good idea to have a call about this subject ;)

@Davknapp Davknapp marked this pull request as ready for review February 8, 2024 08:26
@Davknapp Davknapp assigned jmark and unassigned Davknapp Feb 8, 2024
Copy link
Collaborator

@jmark jmark left a comment

Choose a reason for hiding this comment

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

Let's have a direct telco about this PR. It is pretty tedious to get an overview over the interdependence of classes you use here and how and where they are used.

@jmark jmark assigned Davknapp and unassigned jmark Feb 8, 2024
@Davknapp Davknapp assigned jmark and unassigned Davknapp Feb 9, 2024
@jmark jmark merged commit b6d76b8 into main Feb 13, 2024
8 checks passed
@jmark jmark deleted the enhance-cmesh-testing branch February 13, 2024 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion draft Enhance the visibility that this is a draft. enhancement Enhances already existing code New feature Adds a new feature to the code tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants