From 895cd72980d304629b22f2d1b66aaaffe7153954 Mon Sep 17 00:00:00 2001
From: Anna Wellmann <a.wellmann@tu-braunschweig.de>
Date: Thu, 27 Apr 2023 16:25:57 +0200
Subject: [PATCH] Use communicator interface in ParameterTest

---
 src/gpu/VirtualFluids_GPU/CMakeLists.txt      |  1 -
 .../Parameter/ParameterTest.cpp               | 49 ++++++++++++++++++-
 2 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/src/gpu/VirtualFluids_GPU/CMakeLists.txt b/src/gpu/VirtualFluids_GPU/CMakeLists.txt
index ffab484b2..d58210ba6 100644
--- a/src/gpu/VirtualFluids_GPU/CMakeLists.txt
+++ b/src/gpu/VirtualFluids_GPU/CMakeLists.txt
@@ -24,7 +24,6 @@ if(BUILD_VF_UNIT_TESTS)
 	set_source_files_properties(DataStructureInitializer/GridReaderGenerator/IndexRearrangementForStreamsTest.cpp PROPERTIES LANGUAGE CUDA)
     set_source_files_properties(Communication/ExchangeData27Test.cpp PROPERTIES LANGUAGE CUDA)
     set_source_files_properties(BoundaryConditions/BoundaryConditionFactoryTest.cpp PROPERTIES LANGUAGE CUDA)
-    set_source_files_properties(Parameter/ParameterTest.cpp PROPERTIES LANGUAGE CUDA)
     target_include_directories(VirtualFluids_GPUTests PRIVATE "${VF_THIRD_DIR}/cuda_samples/")
     target_include_directories(VirtualFluids_GPUTests PRIVATE "${VF_ROOT_DIR}/src/gpu/GridGenerator/")
 endif()
diff --git a/src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp b/src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp
index adc597cb8..ebbd7b589 100644
--- a/src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp
+++ b/src/gpu/VirtualFluids_GPU/Parameter/ParameterTest.cpp
@@ -11,7 +11,7 @@
 
 #include "Factories/BoundaryConditionFactory.h"
 #include "Factories/GridScalingFactory.h"
-#include "Communication/MpiCommunicator.h"
+#include "Communication/Communicator.h"
 #include "DataStructureInitializer/GridReaderGenerator/GridGenerator.h"
 #include "GPU/CudaMemoryManager.h"
 #include "gpu/GridGenerator/grid/GridBuilder/MultipleGridBuilder.h"
@@ -250,6 +250,51 @@ TEST(ParameterTest, whenCreatingParameterClassWithGridRefinement_afterCallingIni
     EXPECT_THAT(para->getParH(1), testing::Ne(nullptr));
 }
 
+class MockCommunicator : public vf::gpu::Communicator
+{
+public:
+    void waitAll(){};
+    int getPID() const override
+    {
+        return 0;
+    };
+    int getNumberOfProcess() const
+    {
+        return 1;
+    };
+    void exchngData(float *sbuf_t, float *rbuf_t, float *sbuf_b, float *rbuf_b, int count){};
+    //////////////////////////////////////////////////////////////////////////
+    void exchngDataGPU(real *sbuf, int count_s, real *rbuf, int count_r, int nb_rank){};
+    void nbRecvDataGPU(real *rbuf, int count_r, int nb_rank){};
+    void nbSendDataGPU(real *sbuf, int count_s, int nb_rank){};
+    void waitallGPU(){};
+    void sendDataGPU(real *sbuf, int count_s, int nb_rank){};
+    void waitGPU(int id){};
+    void resetRequest(){};
+    //////////////////////////////////////////////////////////////////////////
+    void startTimer(){};
+    void stopTimer(){};
+    double getTime()
+    {
+        return 0.0;
+    };
+    int mapCudaDevice(const int &rank, const int &size, const std::vector<unsigned int> &devices, const int &maxdev)
+    {
+        return 0;
+    };
+    std::vector<double> gatherNUPS(double processNups)
+    {
+        return {};
+    };
+    double sumNups(double processNups)
+    {
+        return 0;
+    };
+    //////////////////////////////////////////////////////////////////////////
+    void receive_send(uint *buffer_receive, int size_buffer_recv, int neighbor_rank_recv, uint *buffer_send, int size_buffer_send, int neighbor_rank_send) const override{};
+
+};
+
 TEST(ParameterTest, whenCreatingParameterClassWithGridRefinement_afterCallingSimulationConstructor_shouldNotThrow)
 {
     spdlog::set_level(spdlog::level::warn); // avoids logger spam in output
@@ -258,7 +303,7 @@ TEST(ParameterTest, whenCreatingParameterClassWithGridRefinement_afterCallingSim
     para->setMaxLevel(2);
 
     SPtr<CudaMemoryManager> cudaMemoryManager = std::make_shared<CudaMemoryManager>(para);
-    vf::gpu::Communicator &communicator = vf::gpu::MpiCommunicator::getInstance();
+    MockCommunicator communicator = MockCommunicator();
     auto gridFactory = GridFactory::make();
     auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory);
     SPtr<GridProvider> gridGenerator =
-- 
GitLab