diff --git a/src/gpu/VirtualFluids_GPU/Factories/BoundaryConditionFactoryTest.cpp b/src/gpu/VirtualFluids_GPU/Factories/BoundaryConditionFactoryTest.cpp index 599f927504fa93945cdca23a5ae527b1aa170710..612f9be4fec0da00b989bc29b77c064e7d50123e 100644 --- a/src/gpu/VirtualFluids_GPU/Factories/BoundaryConditionFactoryTest.cpp +++ b/src/gpu/VirtualFluids_GPU/Factories/BoundaryConditionFactoryTest.cpp @@ -55,6 +55,8 @@ TEST(BoundaryConditionFactoryTest, defaultStressBC) EXPECT_THROW(bc(nullptr, nullptr, 0), std::bad_function_call); } +// tests for boundary conditions which are set by the user (tests both set and get functions) + bcFunction getVelocityBcTarget(BoundaryConditionFactory &bcFactory) { auto bc = bcFactory.getVelocityBoundaryConditionPost(); @@ -63,8 +65,6 @@ bcFunction getVelocityBcTarget(BoundaryConditionFactory &bcFactory) return bcTarget; } -// tests for boundary conditions which are set by the user (tests both set and get functions) - TEST(BoundaryConditionFactoryTest, velocityBC) { auto bcFactory = BoundaryConditionFactory(); diff --git a/src/gpu/VirtualFluids_GPU/KernelManager/BCKernelManagerTest.cpp b/src/gpu/VirtualFluids_GPU/KernelManager/BCKernelManagerTest.cpp index 790eeb63437a4dcf627747304ab1c08f067b8b74..5b7e19c930454c90415b47654ae8b09befd59455 100644 --- a/src/gpu/VirtualFluids_GPU/KernelManager/BCKernelManagerTest.cpp +++ b/src/gpu/VirtualFluids_GPU/KernelManager/BCKernelManagerTest.cpp @@ -1,5 +1,4 @@ -#include <gmock/gmock-function-mocker.h> -#include <gmock/gmock-matchers.h> + #include <gmock/gmock.h> #include <stdexcept> diff --git a/src/gpu/VirtualFluids_GPU/KernelManager/GridScalingKernelManager.cpp b/src/gpu/VirtualFluids_GPU/KernelManager/GridScalingKernelManager.cpp index 18e617697894c4be4942717d9a91dab3da887982..1b2c699fe64e1f5c93febc6957ea58211db57e41 100644 --- a/src/gpu/VirtualFluids_GPU/KernelManager/GridScalingKernelManager.cpp +++ b/src/gpu/VirtualFluids_GPU/KernelManager/GridScalingKernelManager.cpp @@ -49,10 +49,10 @@ GridScalingKernelManager::GridScalingKernelManager(SPtr<Parameter> parameter, Gr } checkScalingFunction(gridScalingFactory->getGridScalingFC(), this->para->getParD(0)->intFC, "scalingFineToCoarse"); this->scalingFineToCoarse = gridScalingFactory->getGridScalingFC(); + } else{ + if (gridScalingFactory && gridScalingFactory->getGridScalingFC() != nullptr) + VF_LOG_WARNING("A scaling function for fine to coarse was provided, although there is only one level."); } - - if(this->scalingFineToCoarse == nullptr) - VF_LOG_TRACE("Function for scalingFineToCoarse is nullptr"); } void GridScalingKernelManager::runFineToCoarseKernelLB(const int level, InterpolationCellFC* icellFC, int streamIndex) const{ diff --git a/src/gpu/VirtualFluids_GPU/KernelManager/GridScalingKernelManager.h b/src/gpu/VirtualFluids_GPU/KernelManager/GridScalingKernelManager.h index 964ba78c2a5a0a3652241b5bfcf08ba4a3266977..9f2b18bd02dd630cdb849a06e76d484d2e04ff5a 100644 --- a/src/gpu/VirtualFluids_GPU/KernelManager/GridScalingKernelManager.h +++ b/src/gpu/VirtualFluids_GPU/KernelManager/GridScalingKernelManager.h @@ -84,7 +84,7 @@ private: if (!scalingFunctionFC && scalingStruct.kFC > 0) throw std::runtime_error("The scaling function " + scalingName + " was not set!"); if (scalingFunctionFC && scalingStruct.kFC == 0) - VF_LOG_WARNING("The scaling function {} was set, although there is no refinement", scalingName); + VF_LOG_WARNING("The scaling function {} was provided, although there is no refinement.", scalingName); } SPtr<Parameter> para; diff --git a/src/gpu/VirtualFluids_GPU/KernelManager/GridScalingKernelManagerTest.cpp b/src/gpu/VirtualFluids_GPU/KernelManager/GridScalingKernelManagerTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..217ebd6f5b4c404f5614f3bd46c9c910caf25a1f --- /dev/null +++ b/src/gpu/VirtualFluids_GPU/KernelManager/GridScalingKernelManagerTest.cpp @@ -0,0 +1,74 @@ +#include <gmock/gmock.h> +#include <stdexcept> + +#include "GridScalingKernelManager.h" +#include "Factories/GridScalingFactory.h" +#include "Parameter/Parameter.h" +#include "PointerDefinitions.h" + +class GridScalingKernelManagerTest_Initialization : public testing::Test +{ +protected: + GridScalingFactory scalingFactory; + SPtr<Parameter> para = std::make_shared<Parameter>(); + + void SetUp() override + { + para->setGridX({2, 8}); + para->setGridY({2, 8}); + para->setGridZ({2, 8}); + para->setDistX({0, 0}); + para->setDistY({0, 0}); + para->setDistZ({0, 0}); + } +}; + +TEST_F(GridScalingKernelManagerTest_Initialization, singleLevel) +{ + // only one level --> no scaling factory needed --> no error + para->initLBMSimulationParameter(); + para->getParD(0)->intFC.kFC = 100; + EXPECT_NO_THROW(GridScalingKernelManager(para, nullptr)); + + // only one level --> no scaling function needed --> no error + para->initLBMSimulationParameter(); + para->getParD(0)->intFC.kFC = 100; + EXPECT_NO_THROW(GridScalingKernelManager(para, &scalingFactory)); + + // only one level, but the user provided a scaling function anyway --> no error + para->initLBMSimulationParameter(); + scalingFactory.setScalingFactory(GridScalingFactory::GridScaling::ScaleK17); + EXPECT_NO_THROW(GridScalingKernelManager(para, &scalingFactory)); +} + +TEST_F(GridScalingKernelManagerTest_Initialization, multipleLevelNoScalingFunction) +{ + // multiple levels, but no interpolation nodes specified --> no scaling function needed --> no error + para->setMaxLevel(2); + para->initLBMSimulationParameter(); + EXPECT_NO_THROW(GridScalingKernelManager(para, &scalingFactory)); + + // multiple levels and interpolation nodes specified, but the user forgot to set the scalingFunction --> error + para->setMaxLevel(2); + para->initLBMSimulationParameter(); + para->getParD(0)->intFC.kFC = 100; + EXPECT_THROW(GridScalingKernelManager(para, &scalingFactory), std::runtime_error); +} + +TEST_F(GridScalingKernelManagerTest_Initialization, multipleLevelNoScalingFactory) +{ + // multiple levels, but the user forgot the scaling factory --> error + para->setMaxLevel(2); + para->initLBMSimulationParameter(); + EXPECT_THROW(GridScalingKernelManager(para, nullptr), std::runtime_error); +} + +TEST_F(GridScalingKernelManagerTest_Initialization, multipleLevelUnnecessaryScalingFunction) +{ + // multiple levels and NO interpolation nodes specified, but the user provided a scaling function anyway --> no error + para->setMaxLevel(2); + para->initLBMSimulationParameter(); + scalingFactory.setScalingFactory(GridScalingFactory::GridScaling::ScaleRhoSq); + EXPECT_NO_THROW(GridScalingKernelManager(para, &scalingFactory)); +} +