From b483222125b5d1364f0204c16583bd29407a570b Mon Sep 17 00:00:00 2001 From: Anna Wellmann <a.wellmann@tu-bs.de> Date: Wed, 30 Nov 2022 15:52:02 +0100 Subject: [PATCH] Add some consts --- .../IndexRearrangementForStreams.cpp | 52 +++++++++---------- .../IndexRearrangementForStreams.h | 52 +++++++++---------- .../IndexRearrangementForStreamsTest.cpp | 23 ++++---- 3 files changed, 62 insertions(+), 65 deletions(-) diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.cpp b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.cpp index d2cda5c7c..841c76ca3 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.cpp +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.cpp @@ -17,7 +17,7 @@ IndexRearrangementForStreams::IndexRearrangementForStreams(std::shared_ptr<Param void IndexRearrangementForStreams::initCommunicationArraysForCommAfterFinetoCoarseX(uint level, int indexOfProcessNeighbor, - int direction) + int direction) const { std::cout << "communication: reorder send indices X "; std::vector<uint> sendIndicesForCommAfterFtoCPositions = @@ -37,7 +37,7 @@ void IndexRearrangementForStreams::initCommunicationArraysForCommAfterFinetoCoar void IndexRearrangementForStreams::initCommunicationArraysForCommAfterFinetoCoarseY(uint level, int indexOfProcessNeighbor, - int direction) + int direction) const { std::cout << "communication: reorder send indices Y "; std::vector<uint> sendIndicesForCommAfterFtoCPositions = @@ -57,7 +57,7 @@ void IndexRearrangementForStreams::initCommunicationArraysForCommAfterFinetoCoar void IndexRearrangementForStreams::initCommunicationArraysForCommAfterFinetoCoarseZ(uint level, int indexOfProcessNeighbor, - int direction) + int direction) const { std::cout << "communication: reorder send indices Z "; std::vector<uint> sendIndicesForCommAfterFtoCPositions = @@ -76,7 +76,7 @@ void IndexRearrangementForStreams::initCommunicationArraysForCommAfterFinetoCoar } std::vector<uint> IndexRearrangementForStreams::initSendIndicesForCommAfterFToCX(uint level, int indexOfProcessNeighbor, - int direction) + int direction) const { para->initProcessNeighborsAfterFtoCX(level); std::vector<uint> sendIndicesForCommAfterFtoCPositions; @@ -88,7 +88,7 @@ std::vector<uint> IndexRearrangementForStreams::initSendIndicesForCommAfterFToCX } std::vector<uint> IndexRearrangementForStreams::initSendIndicesForCommAfterFToCY(uint level, int indexOfProcessNeighbor, - int direction) + int direction) const { para->initProcessNeighborsAfterFtoCY(level); std::vector<uint> sendIndicesForCommAfterFtoCPositions; @@ -100,7 +100,7 @@ std::vector<uint> IndexRearrangementForStreams::initSendIndicesForCommAfterFToCY } std::vector<uint> IndexRearrangementForStreams::initSendIndicesForCommAfterFToCZ(uint level, int indexOfProcessNeighbor, - int direction) + int direction) const { para->initProcessNeighborsAfterFtoCZ(level); std::vector<uint> sendIndicesForCommAfterFtoCPositions; @@ -113,7 +113,7 @@ std::vector<uint> IndexRearrangementForStreams::initSendIndicesForCommAfterFToCZ std::vector<uint> IndexRearrangementForStreams::exchangeIndicesForCommAfterFtoCX(uint level, int indexOfProcessNeighbor, int direction, - std::vector<uint> &sendIndicesForCommAfterFtoCPositions) + std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const { // fill the receive vector with zeros as placeholders (0 is never a valid fluid node) // give vector an arbitrary size (larger than needed) // TODO: Find a better way @@ -134,7 +134,7 @@ IndexRearrangementForStreams::exchangeIndicesForCommAfterFtoCX(uint level, int i std::vector<uint> IndexRearrangementForStreams::exchangeIndicesForCommAfterFtoCY(uint level, int indexOfProcessNeighbor, int direction, - std::vector<uint> &sendIndicesForCommAfterFtoCPositions) + std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const { // fill the receive vector with zeros as placeholders (0 is never a valid fluid node) // give vector an arbitrary size (larger than needed) // TODO: Find a better way @@ -155,7 +155,7 @@ IndexRearrangementForStreams::exchangeIndicesForCommAfterFtoCY(uint level, int i std::vector<uint> IndexRearrangementForStreams::exchangeIndicesForCommAfterFtoCZ(uint level, int indexOfProcessNeighbor, int direction, - std::vector<uint> &sendIndicesForCommAfterFtoCPositions) + std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const { // fill the receive vector with zeros as placeholders (0 is never a valid fluid node) // give vector an arbitrary size (larger than needed) // TODO: Find a better way @@ -175,7 +175,7 @@ IndexRearrangementForStreams::exchangeIndicesForCommAfterFtoCZ(uint level, int i } void IndexRearrangementForStreams::initRecvIndicesForCommAfterFToCX( - uint level, int indexOfProcessNeighbor, int direction, std::vector<uint> &recvIndicesForCommAfterFtoCPositions) + uint level, int indexOfProcessNeighbor, int direction, std::vector<uint> &recvIndicesForCommAfterFtoCPositions) const { reorderRecvIndicesForCommAfterFtoCX(direction, level, indexOfProcessNeighbor, recvIndicesForCommAfterFtoCPositions); para->setRecvProcessNeighborsAfterFtoCX( @@ -184,7 +184,7 @@ void IndexRearrangementForStreams::initRecvIndicesForCommAfterFToCX( } void IndexRearrangementForStreams::initRecvIndicesForCommAfterFToCY( - uint level, int indexOfProcessNeighbor, int direction, std::vector<uint> &recvIndicesForCommAfterFtoCPositions) + uint level, int indexOfProcessNeighbor, int direction, std::vector<uint> &recvIndicesForCommAfterFtoCPositions) const { reorderRecvIndicesForCommAfterFtoCY(direction, level, indexOfProcessNeighbor, recvIndicesForCommAfterFtoCPositions); para->setRecvProcessNeighborsAfterFtoCY( @@ -192,7 +192,7 @@ void IndexRearrangementForStreams::initRecvIndicesForCommAfterFToCY( indexOfProcessNeighbor); } void IndexRearrangementForStreams::initRecvIndicesForCommAfterFToCZ( - uint level, int indexOfProcessNeighbor, int direction, std::vector<uint> &recvIndicesForCommAfterFtoCPositions) + uint level, int indexOfProcessNeighbor, int direction, std::vector<uint> &recvIndicesForCommAfterFtoCPositions) const { reorderRecvIndicesForCommAfterFtoCZ(direction, level, indexOfProcessNeighbor, recvIndicesForCommAfterFtoCPositions); para->setRecvProcessNeighborsAfterFtoCZ( @@ -200,7 +200,7 @@ void IndexRearrangementForStreams::initRecvIndicesForCommAfterFToCZ( indexOfProcessNeighbor); } -void IndexRearrangementForStreams::copyProcessNeighborToCommAfterFtoCX(uint level, int indexOfProcessNeighbor) +void IndexRearrangementForStreams::copyProcessNeighborToCommAfterFtoCX(uint level, int indexOfProcessNeighbor) const { // init f[0]* para->getParD(level)->sendProcessNeighborsAfterFtoCX[indexOfProcessNeighbor].f[0] = @@ -229,7 +229,7 @@ void IndexRearrangementForStreams::copyProcessNeighborToCommAfterFtoCX(uint leve para->getParH(level)->recvProcessNeighborX[indexOfProcessNeighbor].rankNeighbor; } -void IndexRearrangementForStreams::copyProcessNeighborToCommAfterFtoCY(uint level, int indexOfProcessNeighbor) +void IndexRearrangementForStreams::copyProcessNeighborToCommAfterFtoCY(uint level, int indexOfProcessNeighbor) const { // init f[0]* para->getParD(level)->sendProcessNeighborsAfterFtoCY[indexOfProcessNeighbor].f[0] = @@ -258,7 +258,7 @@ void IndexRearrangementForStreams::copyProcessNeighborToCommAfterFtoCY(uint leve para->getParH(level)->recvProcessNeighborY[indexOfProcessNeighbor].rankNeighbor; } -void IndexRearrangementForStreams::copyProcessNeighborToCommAfterFtoCZ(uint level, int indexOfProcessNeighbor) +void IndexRearrangementForStreams::copyProcessNeighborToCommAfterFtoCZ(uint level, int indexOfProcessNeighbor) const { // init f[0]* para->getParD(level)->sendProcessNeighborsAfterFtoCZ[indexOfProcessNeighbor].f[0] = @@ -288,7 +288,7 @@ void IndexRearrangementForStreams::copyProcessNeighborToCommAfterFtoCZ(uint leve } void IndexRearrangementForStreams::reorderSendIndicesForCommAfterFtoCX( - int direction, int level, int indexOfProcessNeighbor, std::vector<uint> &sendIndicesForCommAfterFtoCPositions) + int direction, int level, int indexOfProcessNeighbor, std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const { int *sendIndices = para->getParH(level)->sendProcessNeighborX[indexOfProcessNeighbor].index; int &numberOfSendNodesAfterFtoC = @@ -298,7 +298,7 @@ void IndexRearrangementForStreams::reorderSendIndicesForCommAfterFtoCX( } void IndexRearrangementForStreams::reorderSendIndicesForCommAfterFtoCY( - int direction, int level, int indexOfProcessNeighbor, std::vector<uint> &sendIndicesForCommAfterFtoCPositions) + int direction, int level, int indexOfProcessNeighbor, std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const { int *sendIndices = para->getParH(level)->sendProcessNeighborY[indexOfProcessNeighbor].index; int &numberOfSendNodesAfterFtoC = @@ -308,7 +308,7 @@ void IndexRearrangementForStreams::reorderSendIndicesForCommAfterFtoCY( } void IndexRearrangementForStreams::reorderSendIndicesForCommAfterFtoCZ( - int direction, int level, int indexOfProcessNeighbor, std::vector<uint> &sendIndicesForCommAfterFtoCPositions) + int direction, int level, int indexOfProcessNeighbor, std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const { int *sendIndices = para->getParH(level)->sendProcessNeighborZ[indexOfProcessNeighbor].index; int &numberOfSendNodesAfterFtoC = @@ -319,7 +319,7 @@ void IndexRearrangementForStreams::reorderSendIndicesForCommAfterFtoCZ( void IndexRearrangementForStreams::reorderSendIndicesForCommAfterFtoC( int *sendIndices, int &numberOfSendNodesAfterFtoC, int direction, int level, - std::vector<uint> &sendIndicesForCommAfterFtoCPositions) + std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const { *logging::out << logging::Logger::INFO_INTERMEDIATE << "reorder send indices for communication after fine to coarse: level: " << level @@ -375,7 +375,7 @@ void IndexRearrangementForStreams::reorderSendIndicesForCommAfterFtoC( } } -bool IndexRearrangementForStreams::isSparseIndexInICellFCC(uint sizeOfICellFCC, int sparseIndex, int level) +bool IndexRearrangementForStreams::isSparseIndexInICellFCC(uint sizeOfICellFCC, int sparseIndex, int level) const { for (uint j = 0; j < sizeOfICellFCC; j++) { if (sparseIndex < 0) @@ -387,7 +387,7 @@ bool IndexRearrangementForStreams::isSparseIndexInICellFCC(uint sizeOfICellFCC, return false; } -void IndexRearrangementForStreams::aggregateNodesInICellCFC(int level, std::vector<uint> &nodesCFC) +void IndexRearrangementForStreams::aggregateNodesInICellCFC(int level, std::vector<uint> &nodesCFC) const { uint sparseIndex; uint *neighborX = para->getParH(level)->neighborX; @@ -442,7 +442,7 @@ void IndexRearrangementForStreams::findIfSparseIndexIsInSendIndicesAndAddToCommV void IndexRearrangementForStreams::findIndicesNotInCommAfterFtoC(const uint &numberOfSendOrRecvIndices, int *sendOrReceiveIndices, std::vector<int> &sendOrReceiveIndicesAfterFtoC, - std::vector<int> &sendOrIndicesOther) + std::vector<int> &sendOrIndicesOther) const { int sparseIndexSend; for (uint posInSendIndices = 0; posInSendIndices < numberOfSendOrRecvIndices; posInSendIndices++) { @@ -454,7 +454,7 @@ void IndexRearrangementForStreams::findIndicesNotInCommAfterFtoC(const uint &num } void IndexRearrangementForStreams::reorderRecvIndicesForCommAfterFtoCX( - int direction, int level, int indexOfProcessNeighbor, std::vector<uint> &sendIndicesForCommAfterFtoCPositions) + int direction, int level, int indexOfProcessNeighbor, std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const { int *recvIndices = para->getParH(level)->recvProcessNeighborX[indexOfProcessNeighbor].index; int &numberOfRecvNodesAfterFtoC = para->getParH(level)->recvProcessNeighborsAfterFtoCX[indexOfProcessNeighbor].numberOfNodes; @@ -463,7 +463,7 @@ void IndexRearrangementForStreams::reorderRecvIndicesForCommAfterFtoCX( } void IndexRearrangementForStreams::reorderRecvIndicesForCommAfterFtoCY( - int direction, int level, int indexOfProcessNeighbor, std::vector<uint> &sendIndicesForCommAfterFtoCPositions) + int direction, int level, int indexOfProcessNeighbor, std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const { int *recvIndices = para->getParH(level)->recvProcessNeighborY[indexOfProcessNeighbor].index; int &numberOfRecvNodesAfterFtoC = para->getParH(level)->recvProcessNeighborsAfterFtoCY[indexOfProcessNeighbor].numberOfNodes; @@ -472,7 +472,7 @@ void IndexRearrangementForStreams::reorderRecvIndicesForCommAfterFtoCY( } void IndexRearrangementForStreams::reorderRecvIndicesForCommAfterFtoCZ( - int direction, int level, int indexOfProcessNeighbor, std::vector<uint> &sendIndicesForCommAfterFtoCPositions) + int direction, int level, int indexOfProcessNeighbor, std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const { int *recvIndices = para->getParH(level)->recvProcessNeighborZ[indexOfProcessNeighbor].index; int &numberOfRecvNodesAfterFtoC = @@ -483,7 +483,7 @@ void IndexRearrangementForStreams::reorderRecvIndicesForCommAfterFtoCZ( void IndexRearrangementForStreams::reorderRecvIndicesForCommAfterFtoC( int *recvIndices, int &numberOfRecvNodesAfterFtoC, int direction, int level, - std::vector<uint> &sendIndicesForCommAfterFtoCPositions) + std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const { *logging::out << logging::Logger::INFO_INTERMEDIATE << "reorder receive indices for communication after fine to coarse: level: " << level diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.h b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.h index 7ae754e82..2f262468b 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.h +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreams.h @@ -35,13 +35,13 @@ public: //! \details Only the nodes involved in the interpolation need to be exchanged. Therefore in this method all nodes, //! which are part of the interpolation as well as the communication, are identified. //!See [master thesis of Anna Wellmann (p. 59-62: "Reduzieren der auszutauschenden Knoten")] - void initCommunicationArraysForCommAfterFinetoCoarseX(uint level, int j, int direction); + void initCommunicationArraysForCommAfterFinetoCoarseX(uint level, int j, int direction) const; //! \brief Initialize the arrays for the communication after the interpolation from fine to coarse in y direction //! \details --> see x direction - void initCommunicationArraysForCommAfterFinetoCoarseY(uint level, int j, int direction); + void initCommunicationArraysForCommAfterFinetoCoarseY(uint level, int j, int direction) const; //! \brief Initialize the arrays for the communication after the interpolation from fine to coarse in z direction //! \details --> see x direction - void initCommunicationArraysForCommAfterFinetoCoarseZ(uint level, int j, int direction); + void initCommunicationArraysForCommAfterFinetoCoarseZ(uint level, int j, int direction) const; protected: ////////////////////////////////////////////////////////////////////////// @@ -49,37 +49,37 @@ protected: ////////////////////////////////////////////////////////////////////////// //! \brief Initializes the send indices for the communication after the interpolation from fine to coarse - std::vector<uint> initSendIndicesForCommAfterFToCX(uint level, int indexOfProcessNeighbor, int direction); - std::vector<uint> initSendIndicesForCommAfterFToCY(uint level, int indexOfProcessNeighbor, int direction); - std::vector<uint> initSendIndicesForCommAfterFToCZ(uint level, int indexOfProcessNeighbor, int direction); + std::vector<uint> initSendIndicesForCommAfterFToCX(uint level, int indexOfProcessNeighbor, int direction) const; + std::vector<uint> initSendIndicesForCommAfterFToCY(uint level, int indexOfProcessNeighbor, int direction) const; + std::vector<uint> initSendIndicesForCommAfterFToCZ(uint level, int indexOfProcessNeighbor, int direction) const; //! \brief send sendIndicesForCommAfterFtoCPositions to receiving process and receive //! recvIndicesForCommAfterFtoCPositions from neighboring process std::vector<uint> exchangeIndicesForCommAfterFtoCX(uint level, int indexOfProcessNeighbor, int direction, - std::vector<uint> &sendIndicesForCommAfterFtoCPositions); + std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const; std::vector<uint> exchangeIndicesForCommAfterFtoCY(uint level, int indexOfProcessNeighbor, int direction, - std::vector<uint> &sendIndicesForCommAfterFtoCPositions); + std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const; std::vector<uint> exchangeIndicesForCommAfterFtoCZ(uint level, int indexOfProcessNeighbor, int direction, - std::vector<uint> &sendIndicesForCommAfterFtoCPositions); + std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const; //! \brief Initializes the send indices for the communication after the interpolation from fine to coarse - void initRecvIndicesForCommAfterFToCX(uint level, int indexOfProcessNeighbor, int direction, std::vector<uint>& recvIndicesForCommAfterFtoCPositions); - void initRecvIndicesForCommAfterFToCY(uint level, int indexOfProcessNeighbor, int direction, std::vector<uint>& recvIndicesForCommAfterFtoCPositions); - void initRecvIndicesForCommAfterFToCZ(uint level, int indexOfProcessNeighbor, int direction, std::vector<uint>& recvIndicesForCommAfterFtoCPositions); + void initRecvIndicesForCommAfterFToCX(uint level, int indexOfProcessNeighbor, int direction, std::vector<uint>& recvIndicesForCommAfterFtoCPositions) const; + void initRecvIndicesForCommAfterFToCY(uint level, int indexOfProcessNeighbor, int direction, std::vector<uint>& recvIndicesForCommAfterFtoCPositions) const; + void initRecvIndicesForCommAfterFToCZ(uint level, int indexOfProcessNeighbor, int direction, std::vector<uint>& recvIndicesForCommAfterFtoCPositions) const; //! \brief Initializes pointers for reduced communication after the interpolation from fine to coarse by copying //! them from "normal" communication - void copyProcessNeighborToCommAfterFtoCX(uint level, int indexOfProcessNeighbor); - void copyProcessNeighborToCommAfterFtoCY(uint level, int indexOfProcessNeighbor); - void copyProcessNeighborToCommAfterFtoCZ(uint level, int indexOfProcessNeighbor); + void copyProcessNeighborToCommAfterFtoCX(uint level, int indexOfProcessNeighbor) const; + void copyProcessNeighborToCommAfterFtoCY(uint level, int indexOfProcessNeighbor) const; + void copyProcessNeighborToCommAfterFtoCZ(uint level, int indexOfProcessNeighbor) const; //! \brief --> see reorderSendIndicesForCommAfterFtoC void reorderSendIndicesForCommAfterFtoCX(int direction, int level, int indexOfProcessNeighbor, - std::vector<uint> &sendIndicesForCommAfterFtoCPositions); + std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const; void reorderSendIndicesForCommAfterFtoCY(int direction, int level, int indexOfProcessNeighbor, - std::vector<uint> &sendIndicesForCommAfterFtoCPositions); + std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const; void reorderSendIndicesForCommAfterFtoCZ(int direction, int level, int indexOfProcessNeighbor, - std::vector<uint> &sendIndicesForCommAfterFtoCPositions); + std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const; //! \brief The send indices are reordered for the communication after the interpolation from fine to coarse //! \details The indices of nodes which are part of the interpolation are moved to the front of vector with the send @@ -89,13 +89,13 @@ protected: //! \param numberOfSendNodesAfterFtoC will be set in this method //! \param sendIndicesForCommAfterFtoCPositions stores each sendIndex's positions before reordering void reorderSendIndicesForCommAfterFtoC(int *sendIndices, int &numberOfSendNodesAfterFtoC, int direction, - int level, std::vector<uint> &sendIndicesForCommAfterFtoCPositions); + int level, std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const; //! \brief Check if a sparse index occurs in the ICellFCC - bool isSparseIndexInICellFCC(uint sizeOfICellFCC, int sparseIndexSend, int level); + bool isSparseIndexInICellFCC(uint sizeOfICellFCC, int sparseIndexSend, int level) const; //! \brief Aggregate all nodes in the coarse cells for the interpolation in coarse to fine //! \details For the coarse cells in the interpolation from coarse to fine only one node is stored. This methods //! looks for the other nodes of each cell and puts them into vector. Duplicate nodes are only stored once. - void aggregateNodesInICellCFC(int level, std::vector<uint> &nodesCFC); + void aggregateNodesInICellCFC(int level, std::vector<uint> &nodesCFC) const; //! \brief Add index to sendIndicesAfterFtoC and sendIndicesForCommAfterFtoCPositions, but omit indices which are already in sendIndicesAfterFtoC void addUniqueIndexToCommunicationVectors(std::vector<int> &sendIndicesAfterFtoC, int &sparseIndexSend, std::vector<unsigned int> &sendIndicesForCommAfterFtoCPositions, @@ -108,15 +108,15 @@ protected: //! \brief Find all indices which are not part of the communication after the interpolation from fine to coarse void findIndicesNotInCommAfterFtoC(const uint &numberOfSendOrRecvIndices, int *sendOrReceiveIndices, std::vector<int> &sendOrReceiveIndicesAfterFtoC, - std::vector<int> &sendOrIndicesOther); + std::vector<int> &sendOrIndicesOther) const; //! \brief --> see reorderRecvIndicesForCommAfterFtoC void reorderRecvIndicesForCommAfterFtoCX(int direction, int level, int indexOfProcessNeighbor, - std::vector<uint> &sendIndicesForCommAfterFtoCPositions); + std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const; void reorderRecvIndicesForCommAfterFtoCY(int direction, int level, int indexOfProcessNeighbor, - std::vector<uint> &sendIndicesForCommAfterFtoCPositions); + std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const; void reorderRecvIndicesForCommAfterFtoCZ(int direction, int level, int indexOfProcessNeighbor, - std::vector<uint> &sendIndicesForCommAfterFtoCPositions); + std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const; //! \brief Reorder the receive indices in the same way that the send indices were reordered. //! \details When the send indices are reordered, the receive indices need to be reordered accordingly. @@ -125,7 +125,7 @@ protected: //! \param numberOfRecvNodesAfterFtoC will be set in this function //! \param sendIndicesForCommAfterFtoCPositions stores each sendIndex's positions before reordering and is used to reorder the receive indices in the same way void reorderRecvIndicesForCommAfterFtoC(int *recvIndices, int &numberOfRecvNodesAfterFtoC, int direction, - int level, std::vector<uint> &sendIndicesForCommAfterFtoCPositions); + int level, std::vector<uint> &sendIndicesForCommAfterFtoCPositions) const; private: std::shared_ptr<GridBuilder> builder; diff --git a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreamsTest.cpp b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreamsTest.cpp index 50d27cab9..583f0a904 100644 --- a/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreamsTest.cpp +++ b/src/gpu/VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreamsTest.cpp @@ -19,7 +19,7 @@ #include "gpu/VirtualFluids_GPU/Communication/Communicator.cpp" template <typename T> -bool vectorsAreEqual(T *vector1, std::vector<T> vectorExpected) +bool vectorsAreEqual(const T * vector1, const std::vector<T> vectorExpected) { for (uint i = 0; i < vectorExpected.size(); i++) { if (vector1[i] != vectorExpected[i]) @@ -94,15 +94,15 @@ public: struct SendIndicesForCommAfterFtoCX { // data to work on std::vector<int> sendIndices = { 10, 11, 12, 13, 14, 15, 16 }; - int level = 0; - int direction = CommunicationDirections::MX; - int numberOfProcessNeighbors = 1; - int indexOfProcessNeighbor = 0; + const int level = 0; + const int direction = CommunicationDirections::MX; + const int numberOfProcessNeighbors = 1; + const int indexOfProcessNeighbor = 0; std::vector<uint> iCellCFC = { 8, 10, 12 }; std::vector<uint> iCellFCC = { 14, 16, 18 }; - uint kCF = (uint)iCellCFC.size(); - uint kFC = (uint)iCellFCC.size(); + const uint kCF = (uint)iCellCFC.size(); + const uint kFC = (uint)iCellFCC.size(); uint neighborX[18] = { 0u }; uint neighborY[18] = { 0u }; uint neighborZ[18] = { 0u }; @@ -111,9 +111,9 @@ struct SendIndicesForCommAfterFtoCX { std::vector<uint> sendIndicesForCommAfterFtoCPositions; // expected data - std::vector<uint> sendIndicesForCommAfterFtoCPositions_expected = { 4, 6, 0, 2 }; - std::vector<int> sendProcessNeighborX_expected = { 14, 16, 10, 12, 11, 13, 15 }; - int numberOfSendNodesAfterFtoC_expected = (int)sendIndicesForCommAfterFtoCPositions_expected.size(); + const std::vector<uint> sendIndicesForCommAfterFtoCPositions_expected = { 4, 6, 0, 2 }; + const std::vector<int> sendProcessNeighborX_expected = { 14, 16, 10, 12, 11, 13, 15 }; + const int numberOfSendNodesAfterFtoC_expected = (int)sendIndicesForCommAfterFtoCPositions_expected.size(); }; class IndexRearrangementForStreamsTest_reorderSendIndices : public testing::Test @@ -221,7 +221,6 @@ public: protected: std::vector<uint> act() { - return sut->exchangeIndicesForCommAfterFtoCX(level, indexOfProcessNeighbor, CommunicationDirections::PX, sendIndicesForCommAfterFtoCPositions); } @@ -329,7 +328,6 @@ public: protected: std::vector<uint> act() { - return sut->exchangeIndicesForCommAfterFtoCY(level, indexOfProcessNeighbor, CommunicationDirections::PY, sendIndicesForCommAfterFtoCPositions); } @@ -437,7 +435,6 @@ public: protected: std::vector<uint> act() { - return sut->exchangeIndicesForCommAfterFtoCZ(level, indexOfProcessNeighbor, CommunicationDirections::PZ, sendIndicesForCommAfterFtoCPositions); } -- GitLab