Skip to content

Reduce number of references to Data::values() #1645

@BenjaminRodenberg

Description

@BenjaminRodenberg

Currently all packages of preCICE reference Data::values() to read or write data. Mapping, acceleration, communication and actions operate on the data in Data::values(). For time interpolation we recently introduced a write data buffer and a storage (#1612) in Data. In #1612 data has to be moved from the storage to Data::values() and vice-versa when mapping, acceleration, communication or actions are executed to not interfere with the currently existing implementation. In the future, we should, however avoid using Data::values() and instead use the data from the storage (see example below).

The following packages need a review:

Note that this issue is mainly meant as an overview.

Example for mapping

Current state (#1612)

for (auto &stample : context.fromData->getStamples()) {
// Put data from storage into mapping buffer
context.fromData->sample() = stample.sample;
// Reset the toData before executing the mapping
context.toData->toZero();
const DataID fromDataID = context.fromData->getID();
const DataID toDataID = context.toData->getID();
context.mapping->map(fromDataID, toDataID);
// Store data from mapping buffer in storage
context.toData->setSampleAtTime(stample.timestamp, context.toData->sample());
PRECICE_DEBUG("Mapped values = {}", utils::previewRange(3, context.toData->values()));
}

map accesses Data::values() using fromDataID and toDataID.

Proposed implementation:

 for (auto &stample : context.fromData->getStamples()) { 
   const Eigen::VectorXd fromData = stample.sample.values;
   const Eigen::VectorXd toData = context.mapping->map(fromData); 
   // Store data from mapping buffer in storage 
   context.toData->setSampleAtTime(stample.timestamp, toData);
 } 

map does not need to access Data::values(), because it would just operate on Eigen::VectorXd.

Benefits:

  • No need for moving data back and forth
  • Better encapsulation of packages

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions