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

Draft
wants to merge 37 commits into
base: main
Choose a base branch
from
Draft

Ghost interface #1278

wants to merge 37 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
@antjeHP antjeHP added priority: medium Should be solved within half a year workload: medium Would take a week or less labels Oct 24, 2024
@antjeHP antjeHP self-assigned this Oct 24, 2024
Comment on lines 2958 to 2959
SC_CHECK_ABORT (do_ghost != 0, "do_ghost == 0 in set_ghost_ext_new.\n");
SC_CHECK_ABORT (ghost_interface != NULL, "invalides ghost interface in set_ghost_ext_new\n");
Copy link
Collaborator

Choose a reason for hiding this comment

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

This negates the possibility to deactivate ghost. One could want to call

t8_forest_set_ghost_ext_new (forest, false, NULL)

to deactivate ghost during a specific part of the simulation.
IMHO

T8_ASSERT (!(do_ghost == 1 && ghost_interface == NULL);

would be a better check

Copy link
Collaborator Author

@antjeHP antjeHP Nov 26, 2024

Choose a reason for hiding this comment

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

I see your point. But a little question, why should we use T8_ASSERT instead of SC_CHECK_ABORT ?
If someone sets the combination 1 and NULL, this can not work.

In the function t8_forest_set_ghost_ext we also use SC_CHECK_ABORT, that was the reason for me to do the same.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see your point. But a little question, why should we use T8_ASSERT instead of SC_CHECK_ABORT ? If someone sets the combination 1 and NULL, this can not work.

In the function t8_forest_set_ghost_ext we also use SC_CHECK_ABORT, that was the reason for me to do the same.

We want to use T8_ASSERT as often as possible, because it does not affect the performance in release mode. In this case a SC_CHECK_ABORT is also okay, because this function is not called that often

src/t8_forest/t8_forest.cxx Outdated Show resolved Hide resolved
Comment on lines 175 to 185
if (forest->set_from->ghosts == NULL) {
forest->set_from->ghost_type = T8_GHOST_FACES;
// forest->set_from->ghost_type = T8_GHOST_FACES;
if (forest->set_from->ghost_interface == NULL) {
forest->set_from->ghost_interface = t8_forest_ghost_interface_face_new (3);
create_ghost_interface = 1;
}
t8_forest_ghost_create_topdown (forest->set_from);
if (create_ghost_interface) {
t8_forest_ghost_interface_unref (&(forest->set_from->ghost_interface));
forest->set_from->ghost_interface = NULL;
}
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

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.

step1 and step2 were renamed

t8_forest_ghost_interface_unref (&(forest->ghost_interface));
}
forest->do_ghost = do_ghost;
forest->ghost_interface = ghost_interface;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we can find a more suitable name. Yes, this is an interface, but in this case the class defines what the ghost algorithm actually does. Maybe ghost_strategy or ghost_recipe?

Copy link
Collaborator Author

@antjeHP antjeHP Nov 26, 2024

Choose a reason for hiding this comment

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

Maybe ghost_creator or ghost_builder is a good name. Because the class contains all what is necessary to build the ghost layer and the only function, that you can call from outside is do_ghost.
If we want to take multiple ghost_algorithms on one forest, the forest will save the handler for them and not longer the ghost_interface class.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see where you are going there, but these names suggest that the class builds another object like the t8_scheme_builder.

Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe ghost_definition

src/t8_forest/t8_forest_ghost_stencil.hxx Show resolved Hide resolved
src/t8_forest/t8_forest_ghost_search.hxx Show resolved Hide resolved
src/t8_forest/t8_forest_ghost_stencil.hxx Show resolved Hide resolved
src/t8_forest/t8_forest_ghost_stencil.hxx Outdated Show resolved Hide resolved
Comment on lines +103 to +105
// t8_ghost_type_t ghost_type; /**< If a ghost layer will be created, the type of neighbors that count as ghost. */
// int ghost_algorithm; /**< Controls the algorithm used for ghost. 1 = balanced only. 2 = also unbalanced
// 3 = top-down search and unbalanced. */
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this still needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, this is no longer necessary. The ghost_type and the ghost_algorithm are part of the class.

@sandro-elsweijer
Copy link
Collaborator

Please also create an author file for your work under t8code/doc/

@antjeHP antjeHP assigned sandro-elsweijer and unassigned antjeHP Dec 5, 2024
@antjeHP antjeHP force-pushed the feature-ghost_interface branch from edd08d5 to b8c3a67 Compare December 17, 2024 12:45
Comment on lines 2045 to 2046
#ifdef T8_ENABLE_DEBUG
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably there once was something between this, but it got removed and somebody forgot to remove this

t8_forest_ghost_interface_unref (&(forest->ghost_interface));
}
forest->do_ghost = do_ghost;
forest->ghost_interface = ghost_interface;
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe ghost_definition


/**
* Satisfy the C interface of forest
* Return for a ghost_interface of Type FACE the ghost_algorithm / ghost_version (1, 2 or 3)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes you can use \note

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
draft Enhance the visibility that this is a draft. 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