Skip to content

Shift ownership of Waveform into configuration#1133

Closed
BenjaminRodenberg wants to merge 4 commits intoprecice:developfrom
BenjaminRodenberg:transfer-ownership-of-waveforms
Closed

Shift ownership of Waveform into configuration#1133
BenjaminRodenberg wants to merge 4 commits intoprecice:developfrom
BenjaminRodenberg:transfer-ownership-of-waveforms

Conversation

@BenjaminRodenberg
Copy link
Copy Markdown
Contributor

Main changes of this PR

Waveforms are now created during configuration. The resulting object is owned by the configuration class. Other classes only receive a pointer to this object.

This requires us to split creation and initialization of the Waveform object, because valuesSize is not known during configuration.

Motivation and additional information

Main motivation is this observation: https://github.com/BenjaminRodenberg/precice/pull/1/files#r745679418

Collecting waveforms at a central place should help us to avoid duplicates and get a better overview.

Author's checklist

  • I added a changelog file with this PR number in docs/changelog/ if there are noteworthy changes.
  • I ran tools/formatting/check-format and everything is formatted correctly.
  • I sticked to C++14 features.
  • I sticked to CMake version 3.10.
  • 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? @uekerman
  • Do you understand the code changes? @uekerman

@BenjaminRodenberg BenjaminRodenberg added the maintainability Working on this will make our lives easier in the long run as preCICE gets easier to maintain. label Nov 10, 2021
@BenjaminRodenberg
Copy link
Copy Markdown
Contributor Author

@uekerman we could already introduce a WaveformConfiguration.cpp/TimeConfiguration.cpp here. This would be mostly empty, but provides some structure for #1029. What's you opinion?

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.

Goes in the right direction 👍

We could already introduce a WaveformConfiguration.cpp/TimeConfiguration.cpp here. This would be mostly empty, but provides some structure for #1029. What's you opinion?

I would only add it once we know what we want to configure. If we realize that there is not so much to configure, we could also keep it in the coupling scheme configuration.

Let's find a better name for setupDataMatrices.

Comment on lines +53 to +54
const mesh::PtrData & data,
const time::PtrWaveform &ptrWaveform,
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 do we have both data and waveform here? Shouldn't the one replace the other?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think that this is easily possible. The Waveform is currently just a buffer for values to be used for interpolation and extrapolation. The Data also stores the id and the name of the data - and of course the _values itself.

I guess we could replace Data::_values with a pointer to the data stored in the waveform. Then the Waveform will become our only store for values. But this is a big step, because Data::_values are used and updated almost everywhere (also outside of the time or cplscheme package). I am also not sure whether this is a good idea, because then all packages have to interact with the time package and the Waveform.

Currently we are copying Data::_values into the Waveform on demand. Only the cplscheme packages accesses the waveform. Other packages do not have to worry about the waveform at all, because it is wrapped by the cplscheme. Storing data happens here:

_waveforms[pair.first]->store(pair.second->values());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

BenjaminRodenberg#4 actually goes some steps into this direction, but entirely removing the PtrData is, as explained above, a big step.

Comment on lines +952 to +954
time::PtrWaveform ptrWaveform(new time::Waveform(_config.extrapolationOrder));
// @todo store all waveforms in _waveforms? See acceleration config.
scheme.addDataToSend(exchange.data, ptrWaveform, exchange.mesh, requiresInitialization);
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.

Couldn't we create the waveforms closer to the time-stepping part of the config? At some point, we will also get configuration options there. Here, it feels a bit misplaced.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I would rather move this at a later point in time, if necessary. Currently adding the waveform at a different point requires us to add more functions to the CouplingScheme (addWaveformToReceive, addWaveformToSend) and I don't see a clear benefit.

Right now adding everything with a single function enforces the rule "each data has a waveform". This rule might be removed at a later point in time, but currently we are following this rule (because also extrapolation is applied globally to all data).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I started drafting the shift of the ownership of the Waveform into Data. This is also a possible way to go, but still needs some refinement. See BenjaminRodenberg#4.

However, I think it automatically solves this problem.

Comment thread src/time/Waveform.hpp Outdated
@BenjaminRodenberg
Copy link
Copy Markdown
Contributor Author

Let's find a better name for setupDataMatrices.

Renamed it in eb035ff to initializeStorage.

@BenjaminRodenberg
Copy link
Copy Markdown
Contributor Author

I think we can close this PR when #1145 is merged:

Let's keep this PR open until #1145 is merged. Then I will check again and see whether this PR still contains something we want to keep.

@BenjaminRodenberg
Copy link
Copy Markdown
Contributor Author

Closing the PR, because it is outdated. Refer to #1145.

@BenjaminRodenberg BenjaminRodenberg deleted the transfer-ownership-of-waveforms branch December 7, 2021 14:09
@BenjaminRodenberg BenjaminRodenberg added this to the Version 2.4.0 milestone Mar 9, 2022
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