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

Ghost interface #1278

Open
wants to merge 62 commits into
base: main
Choose a base branch
from
Open

Ghost interface #1278

wants to merge 62 commits into from

Conversation

antjeHP
Copy link
Collaborator

@antjeHP antjeHP commented Oct 24, 2024

Describe your changes here:

Design and implementation of the feature Ghost Interface.
Creating a class design for a Ghost interface with abstract base class and derived classes for specific ghost-types (Definitions of neighborhoods).
The type of ghost-algorithm (befor only face-neighborhoods supported), was stored in the forest struct until yet.
Now the forest struct stores a pointer to a Ghost-Interface class.
Not finished yet

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.

License

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

@antjeHP antjeHP added New feature Adds a new feature to the code draft Enhance the visibility that this is a draft. labels Oct 24, 2024
T8_GHOST_FACES, /**< Consider all face (codimension 1) neighbors. */
T8_GHOST_EDGES, /**< Consider all edge (codimension 2) and face neighbors. */
T8_GHOST_VERTICES, /**< Consider all vertex (codimension 3) and edge and face neighbors. */
T8_GHOST_USERDEFINED /** If the user define by his self a step_1 or step_2 function*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
T8_GHOST_USERDEFINED /** If the user define by his self a step_1 or step_2 function*/
T8_GHOST_USER_DEFINED /** If the user define by his self a step_1 or step_2 function*/

forest->ghost_type = ghost_type;
forest->ghost_algorithm = ghost_version;
t8_forest_ghost_definition_c *ghost_definition = t8_forest_ghost_definition_face_new (ghost_version);
t8_forest_set_ghost_ext_new (forest, do_ghost, ghost_definition);
Copy link
Collaborator

Choose a reason for hiding this comment

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

ext_new is not a good function name, can we just overwrite the t8_forest_set_ghost_ext function instead?

Comment on lines 2143 to 2158
const t8_gloidx_t global_num_elements = t8_forest_get_global_num_elements (forest);
const t8_linearidx_t lin_id
= eclass_scheme->t8_element_get_linear_id (element, eclass_scheme->t8_element_level (element));

const t8_linearidx_t b_0 = global_num_elements / forest->mpisize;
const t8_linearidx_t r = global_num_elements % forest->mpisize;

const int p_guess = lin_id / b_0;
if (p_guess < 2 || r == 0) {
return p_guess;
}
const int x = (p_guess * r) / forest->mpisize;

const int owner = (lin_id - x) / b_0;

return owner;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Some comments would be nice

Comment on lines 32 to 74
/**
* Satisfy the C interface of forest
* Create a new ghost_definition of type face with given version
*/
t8_forest_ghost_definition_c *
t8_forest_ghost_definition_face_new (const int version);

/**
* Satisfy the C interface of forest
* Create a new ghost_definition of type stencil
*/
t8_forest_ghost_definition_c *
t8_forest_ghost_definition_stencil_new ();

/**
* Satisfy the C interface of forest
* Return for a ghost_definition of Type FACE the ghost_algorithm / ghost_version (1, 2 or 3)
* \param [in] ghost_definition Pointer to object of class t8_forest_ghost_face
*/
int
t8_forest_ghost_definition_face_version (t8_forest_ghost_definition_c *ghost_definition);

/**
* Satisfy the C interface of forest
* Return the type of a ghost_definition
* \param [in] ghost_definition Pointer to object of class t8_forest_ghost_definition or a derivet class
*/
t8_ghost_type_t
t8_forest_ghost_definition_get_type (const t8_forest_ghost_definition_c *ghost_definition);

/**
* Satisfy the C interface of forest
* Do a ref on the ghost_definition
* Needed in t8_forest_commit
*/
void
t8_forest_ghost_definition_ref (t8_forest_ghost_definition_c *ghost_definition);

/**
* Satisfy the C interface of forest
* Do a unref on the ghost_definition
* Needed in t8_forest_commit and t8_forest_set_ghost_ext_new
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please user proper docstrings

@antjeHP antjeHP assigned sandro-elsweijer and unassigned antjeHP Feb 12, 2025
@antjeHP antjeHP removed the draft Enhance the visibility that this is a draft. label Feb 12, 2025
@sandro-elsweijer sandro-elsweijer marked this pull request as ready for review February 13, 2025 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New feature Adds a new feature to the code priority: medium Should be solved within half a year workload: medium Would take a week or less
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants