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

Configure gradient data requirement automatically #1371

Merged
merged 14 commits into from Jul 20, 2022

Conversation

davidscn
Copy link
Member

@davidscn davidscn commented Jul 12, 2022

Main changes of this PR

Removes the <data: ... gradient="on" /> flag from the xml configuration and deduces the information automatically based on the configured mappings. Currently, only the nearest-neighbor-gradient-mapping requires gradient data.

Motivation and additional information

Improves the usability, as the user doesn't have to change obvious things in different places and prevents unnecessary gradient data allocation due to global gradient enabling/disabling. Related to #1252.
Note that this change is non-breaking as this feature is still experimental.

EDIT: This also resolved part two of #1252, i.e., gradients are now only communicated if it is really required by the mapping configuration.

Author's checklist

  • I added a changelog file with make changelog if there are user-observable changes since the last release.
  • I ran make format to ensure everything is formatted correctly.
  • I sticked to C++14 features.
  • I sticked to CMake version 3.16.3.
  • I squashed / am about to squash all commits that should be seen as one.

Reviewers' checklist

  • Does the changelog entry make sense? Is it formatted correctly?
  • Do you understand the code changes?

@davidscn davidscn added enhancement A new feature, a new functionality of preCICE (from user perspective) usability This issue will make preCICE easier for non-expert users labels Jul 12, 2022
@davidscn davidscn requested a review from uekerman July 12, 2022 14:36
Copy link
Member

@BenjaminRodenberg BenjaminRodenberg left a comment

Choose a reason for hiding this comment

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

Please try to avoid long call chains. This makes it hard to change the code and leads to spaghettification ( https://en.wikipedia.org/wiki/Law_of_Demeter).

src/precice/config/ParticipantConfiguration.cpp Outdated Show resolved Hide resolved
src/precice/config/ParticipantConfiguration.cpp Outdated Show resolved Hide resolved
@@ -86,7 +86,7 @@ void MeshConfiguration::xmlTagCallback(
bool found = false;
for (const DataConfiguration::ConfiguredData &data : _dataConfig->data()) {
if (data.name == name) {
_meshes.back()->createData(data.name, data.dimensions, _dataIDManager.getFreeID(), data.hasGradient);
_meshes.back()->createData(data.name, data.dimensions, _dataIDManager.getFreeID());
Copy link
Member

Choose a reason for hiding this comment

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

I know, this is not your design, but this is difficult to understand. Why is _meshes a vector? I guess only the last Mesh _meshes.back() is the "active" one where data is created. Creating a function currentMesh() that only calls _meshes.back() would make this easier to read. This would also allow us to change the underlying datastructure (not sure if this is really necessary, but to me the vector looks not fitting).

Copy link
Member

Choose a reason for hiding this comment

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

I quickly skimmed over the places where _meshes or meshes() are used and overall I have the impression that at most places replacing the vector with a dict would help. One could also introduce some more high-level functions in MeshConfiguration to avoid call-chains like meshConfig->meshes().at(0)->createVertex(Eigen::Vector3d(1.0, 1.0, 1.0)); in the client code.

Copy link
Member Author

Choose a reason for hiding this comment

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

What is a dict? Do you mean map? I agree that there are several places, which are just confusing. If we can boil down 'problem classes' we should open an issue and discuss how to adapt things. I would prefer to avoid adding such changes in this PR.

Copy link
Member

@uekerman uekerman left a comment

Choose a reason for hiding this comment

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

Nicely simplifies thing 👍
I only have a few concerns concerning naming.

docs/changelog/1371.md Outdated Show resolved Hide resolved
src/mapping/Mapping.hpp Outdated Show resolved Hide resolved
src/mapping/NearestNeighborGradientMapping.cpp Outdated Show resolved Hide resolved
src/mesh/Data.hpp Outdated Show resolved Hide resolved
src/mesh/Data.hpp Outdated Show resolved Hide resolved
src/mesh/Data.hpp Outdated Show resolved Hide resolved
src/mesh/Data.cpp Outdated Show resolved Hide resolved
src/mesh/Data.cpp Outdated Show resolved Hide resolved
src/mesh/Data.cpp Outdated Show resolved Hide resolved
src/precice/impl/MappingContext.hpp Outdated Show resolved Hide resolved
@davidscn davidscn merged commit 8931247 into precice:develop Jul 20, 2022
@davidscn davidscn deleted the auto-conf-grads branch July 20, 2022 10:44
@davidscn davidscn added this to the Version 2.5.0 milestone Aug 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A new feature, a new functionality of preCICE (from user perspective) usability This issue will make preCICE easier for non-expert users
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants