Skip to content

Remove Multi- and BiCouplingScheme#1432

Closed
BenjaminRodenberg wants to merge 19 commits intoprecice:develop-v3.0.0from
BenjaminRodenberg:remove-bi-and-multi-coupling-scheme
Closed

Remove Multi- and BiCouplingScheme#1432
BenjaminRodenberg wants to merge 19 commits intoprecice:develop-v3.0.0from
BenjaminRodenberg:remove-bi-and-multi-coupling-scheme

Conversation

@BenjaminRodenberg
Copy link
Copy Markdown
Contributor

Main changes of this PR

  • Merge Multi- and ParallelCouplingScheme
  • Remove BiCouplingScheme in favor of SerialCouplingScheme
  • Simplifies class hierarchy and limits amount of duplicate code

Motivation and additional information

Removes a lot of code and reduces the implementation effort necessary for #1414. On the long run I assume that the MultiCouplingScheme will also profit from this change, because it gets automatically tested by the ParallelCouplingScheme.

Author's checklist

  • I added a changelog file with make changelog if there are user-observable changes since the last release.
  • I added a test to cover the proposed changes in our test suite.
  • I ran make format to ensure everything is formatted correctly.
  • I sticked to C++17 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?

BenjaminRodenberg and others added 9 commits August 22, 2022 21:47
* Remove mapReadDataTo and mapWriteDataFrom.
* Remove tests using removed API.
* Merge initialize and initializeData in SolverInterfaceImpl.
* Merge initialize and initializeData in CouplingScheme.
* Update tests correspondingly
* Allow to check actions before initialize, especially checking whether initial data has to be written
* Check for sending and receiving of initial data during coupling scheme configuration
* Code simplification w.r.t waveform.
* Use dt=0.0 in actions in initialize.

Co-authored-by: Benjamin Uekermann <[email protected]>
Co-authored-by: Frédéric Simonis <[email protected]>
…recice#1352)

* Get tests and configs for serial implicit waveform interpolation from precice#1029.
* Differentiate between received initial data and data (from advance).
* Split data communication for SerialCouplingScheme and store initial data in waveform.
* Move common functionality of serial and parallel coupling scheme into BiCouplingScheme.

Co-authored-by: Benjamin Uekermann <[email protected]>
* Add test Integration/Serial/InitializeData/ImplicitBoth where both participants initialize.
* Allow initialize=true for both participants in serial-implicit coupling scheme.
* Raise warning, if first participant in serial coupling scheme initializes data with waveform order zero.
* Remove check for write data, because participant does not know about waveform order.

Co-authored-by: Benjamin Uekermann <[email protected]>
* Make read mapping conditional to avoid unnecessary mappings.
* Update corresponding tests.

Co-authored-by: Benjamin Uekermann <[email protected]>
* Merge Multi- and ParallelCouplingScheme
* Remove BiCouplingScheme in favor of SerialCouplingScheme
* Simplifies class hierarchy and limits amount of duplicate code
@BenjaminRodenberg BenjaminRodenberg added the maintainability Working on this will make our lives easier in the long run as preCICE gets easier to maintain. label Sep 10, 2022
@BenjaminRodenberg BenjaminRodenberg self-assigned this Sep 10, 2022
BenjaminRodenberg and others added 8 commits September 15, 2022 20:30
* Remove mapReadDataTo and mapWriteDataFrom.
* Remove tests using removed API.
* Merge initialize and initializeData in SolverInterfaceImpl.
* Merge initialize and initializeData in CouplingScheme.
* Update tests correspondingly
* Allow to check actions before initialize, especially checking whether initial data has to be written
* Check for sending and receiving of initial data during coupling scheme configuration
* Code simplification w.r.t waveform.
* Use dt=0.0 in actions in initialize.

Co-authored-by: Benjamin Uekermann <[email protected]>
Co-authored-by: Frédéric Simonis <[email protected]>
…recice#1352)

* Get tests and configs for serial implicit waveform interpolation from precice#1029.
* Differentiate between received initial data and data (from advance).
* Split data communication for SerialCouplingScheme and store initial data in waveform.
* Move common functionality of serial and parallel coupling scheme into BiCouplingScheme.

Co-authored-by: Benjamin Uekermann <[email protected]>
* Add test Integration/Serial/InitializeData/ImplicitBoth where both participants initialize.
* Allow initialize=true for both participants in serial-implicit coupling scheme.
* Raise warning, if first participant in serial coupling scheme initializes data with waveform order zero.
* Remove check for write data, because participant does not know about waveform order.

Co-authored-by: Benjamin Uekermann <[email protected]>
* Make read mapping conditional to avoid unnecessary mappings.
* Update corresponding tests.

Co-authored-by: Benjamin Uekermann <[email protected]>
@BenjaminRodenberg BenjaminRodenberg added this to the Version 3.0.0 milestone Sep 17, 2022
Copy link
Copy Markdown
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.

I see the motivation behind this step (parallel cpl scheme and multi cpl scheme have some similarities), but I must admit I am not too convinced that this step will help us in the long run 😟

The suggested changes reduce some duplicated code (but not that much), but make the new version harder to understand (why does a serial cpl scheme have a single m2n, but a parallel cpl scheme many?).

I my opinion, the old version was easier to read and understand. Sometimes code duplication is good if it makes things more understandable.

Additional disadvantage: configuration and classes are no longer alligned (there is a cplscheme::multi but no MultiCouplingScheme.

/// Local participant name.
std::string _localParticipant = "unknown";

/// name of the controller participant ( = second participant in serial bi coupling scheme)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
/// name of the controller participant ( = second participant in serial bi coupling scheme)
/// name of the controller participant ( = second participant in serial or parallel coupling scheme)


std::vector<PtrCouplingData> allReceiveCouplingData();

std::vector<PtrCouplingData> allCouplingDataWithId(DataID dataId);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can there be multiple data with the same data id? I guess the name is a bit confusing. And we have getSendData and getReceiveData already.

* @brief Checks whether any CouplingData in dataMap requires initialization
* @param dataMap map containing CouplingData
* @return true, if any CouplingData in dataMap requires initialization
* @brief Checks whether any CouplingData in vector requires initialization
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
* @brief Checks whether any CouplingData in vector requires initialization
* @brief Checks whether any CouplingData requires initialization

* @return true, if any CouplingData in vector requires initialization
*/
bool anyDataRequiresInitialization(DataMap &dataMap) const;
bool anyDataRequiresInitialization(std::vector<PtrCouplingData> datas) const;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
bool anyDataRequiresInitialization(std::vector<PtrCouplingData> datas) const;
bool anyDataRequiresInitialization(std::vector<PtrCouplingData> dataVector) const;

"Maximal iteration limit has to be larger than zero.");

if (_controller == _localParticipant) {
// Controller participant never does the first step, because it is never the first participant
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
// Controller participant never does the first step, because it is never the first participant

A does A because it is A ... not needed I guess.

Comment on lines +270 to +271
/// Sets the values
CouplingData *getSendData(DataID dataID);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment wrong?

Comment on lines +637 to +639
auto dataWithId = allCouplingDataWithId(dataID);
PRECICE_ASSERT(dataWithId.size() >= 1, "Data with given data ID must exist!");
for (auto &data : dataWithId) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why should there be multiple ones?

// @todo implement ParallelCouplingScheme with multi coupling for explicit coupling
PRECICE_ASSERT(isImplicitCouplingScheme(), "ParallelCouplingScheme with multi coupling is always Implicit.");
}
PRECICE_DEBUG("MultiCoupling scheme is created for {}.", localParticipant);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
PRECICE_DEBUG("MultiCoupling scheme is created for {}.", localParticipant);


bool ParallelCouplingScheme::exchangeDataAndAccelerate()
{
PRECICE_DEBUG("Computed full length of iteration");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What do you mean with "full length of iteration"?

const std::string &accessor) const;

PtrCouplingScheme createMultiCouplingScheme(
PtrCouplingScheme createParallelMultiCouplingScheme(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
PtrCouplingScheme createParallelMultiCouplingScheme(
PtrCouplingScheme createParallelCouplingScheme(

@BenjaminRodenberg
Copy link
Copy Markdown
Contributor Author

After discussion with @uekerman: Let's keep this PR as it is for the moment. The change is definitely not a clear thing, but useful during the development on #1414 (it reduces code duplication and simplifies changes in BenjaminRodenberg#13). As soon as BenjaminRodenberg#13 has converged, we can either include the refactoring of #1432 or drop it (and implement the relevant changes from BenjaminRodenberg#13 in #1414).

@BenjaminRodenberg BenjaminRodenberg force-pushed the develop-v3.0.0 branch 2 times, most recently from 721976f to c5c7b50 Compare November 4, 2022 16:43
@fsimonis fsimonis marked this pull request as draft November 17, 2022 12:17
@uekerman
Copy link
Copy Markdown
Member

Closing for now as we decided against this refactoring.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainability Working on this will make our lives easier in the long run as preCICE gets easier to maintain.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants