From c1afc1ee78aebb0fbcb558cff2849130315cc618 Mon Sep 17 00:00:00 2001 From: David Schneider Date: Fri, 30 Aug 2024 10:46:27 +0200 Subject: [PATCH] Special treatment for batch size of zero --- src/modes.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/modes.cpp b/src/modes.cpp index 2b4a55b5..0b459246 100644 --- a/src/modes.cpp +++ b/src/modes.cpp @@ -290,18 +290,23 @@ void aste::runMapperMode(const aste::ExecutionContext &context, const OptionMap int nVertices = coordinates.size() / dim; meshdata.dataVector.resize(nVertices * meshdata.numcomp); - for (int i = 0; i < nVertices; i += batchSize) { - int batchEnd = std::min(i + batchSize, nVertices); - int coordStart = i * dim; - int coordEnd = batchEnd * dim; - int dataStart = i * meshdata.numcomp; - int dataEnd = batchEnd * meshdata.numcomp; - - ::precice::span coordinateBatch(coordinates.data() + coordStart, coordEnd - coordStart); - ::precice::span dataBatch(meshdata.dataVector.data() + dataStart, dataEnd - dataStart); - - // Call the API function with the current batch - preciceInterface.mapAndreadData(asteInterface.meshName, "Data", coordinateBatch, dt, dataBatch); + // pass everything in one go + if (batchSize == 0) { + preciceInterface.mapAndreadData(asteInterface.meshName, "Data", coordinates, dt, meshdata.dataVector); + } else { // pass in batches + for (int i = 0; i < nVertices; i += batchSize) { + int availableVertices = std::min(i + batchSize, nVertices); + int coordStart = i * dim; + int coordEnd = availableVertices * dim; + int dataStart = i * meshdata.numcomp; + int dataEnd = availableVertices * meshdata.numcomp; + + ::precice::span coordinateBatch(coordinates.data() + coordStart, coordEnd - coordStart); + ::precice::span dataBatch(meshdata.dataVector.data() + dataStart, dataEnd - dataStart); + + // Call the API function with the current batch + preciceInterface.mapAndreadData(asteInterface.meshName, "Data", coordinateBatch, dt, dataBatch); + } } } ASTE_DEBUG << "Data read: " << asteInterface.mesh.previewData(meshdata);