From 113c8e995d707ad1b665a23efa56351a7ef63be6 Mon Sep 17 00:00:00 2001 From: HenrikAsmuth <henrik.asmuth@geo.uu.se> Date: Wed, 13 Jul 2022 16:16:30 +0200 Subject: [PATCH] replaced asserts with std:runtime_error --- gpu.cmake | 4 ++-- src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp | 2 +- .../PreCollisionInteractor/Probes/PlanarAverageProbe.cu | 3 +-- .../PreCollisionInteractor/Probes/PlanarAverageProbe.h | 5 ++++- .../PreCollisionInteractor/Probes/PlaneProbe.cu | 3 +-- .../PreCollisionInteractor/Probes/PointProbe.cu | 5 ++--- .../PreCollisionInteractor/Probes/Probe.cu | 2 +- .../PreCollisionInteractor/Probes/Probe.h | 5 ++++- .../PreCollisionInteractor/Probes/WallModelProbe.cu | 8 ++++---- 9 files changed, 20 insertions(+), 17 deletions(-) diff --git a/gpu.cmake b/gpu.cmake index b6b46c1e7..6873ea7ea 100644 --- a/gpu.cmake +++ b/gpu.cmake @@ -31,8 +31,8 @@ IF (BUILD_VF_GPU) #add_subdirectory(targets/apps/LBM/BaselNU) #add_subdirectory(targets/apps/LBM/BaselMultiGPU) - add_subdirectory(apps/gpu/LBM/DrivenCavity) - add_subdirectory(apps/gpu/LBM/SphereGPU) + # add_subdirectory(apps/gpu/LBM/DrivenCavity) + # add_subdirectory(apps/gpu/LBM/SphereGPU) #add_subdirectory(apps/gpu/LBM/WTG_RUB) #add_subdirectory(apps/gpu/LBM/gridGeneratorTest) #add_subdirectory(apps/gpu/LBM/TGV_3D) diff --git a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp index b1fdbdb6c..320630031 100644 --- a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp +++ b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp @@ -2274,7 +2274,7 @@ unsigned int Parameter::getTimeDoRestart() //! unsigned int Parameter::getTimeStep(int level, unsigned int t, bool isPostCollision) { - assert(level<=this->getMaxLevel()); + if(level>this->getMaxLevel()) throw std::runtime_error("Parameter::getTimeStep: level>this->getMaxLevel()!"); unsigned int tLevel = t; if(level>0) { diff --git a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlanarAverageProbe.cu b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlanarAverageProbe.cu index c4ce82b24..d762717a4 100644 --- a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlanarAverageProbe.cu +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlanarAverageProbe.cu @@ -189,8 +189,7 @@ std::vector<PostProcessingVariable> PlanarAverageProbe::getPostProcessingVariabl break; default: - printf("Statistic unavailable in PlanarAverageProbe\n"); - assert(false); + throw std::runtime_error("PlanarAverageProbe::getPostProcessingVariables: Statistic unavailable!"); break; } return postProcessingVariables; diff --git a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlanarAverageProbe.h b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlanarAverageProbe.h index d2b629ae1..39e129282 100644 --- a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlanarAverageProbe.h +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlanarAverageProbe.h @@ -40,6 +40,8 @@ #ifndef PlanarAverageProbe_H #define PlanarAverageProbe_H +#include <iostream> + #include "Probe.h" __global__ void moveIndicesInNegNormalDir( uint* pointIndices, uint nPoints, uint* neighborWSB, uint* neighborInplane1, uint* neighborInplane2, real* coordsX, real* coordsY, real* coordsZ ); @@ -72,7 +74,8 @@ public: planeNormal(_planeNormal) { - assert(_planeNormal == 'x' || _planeNormal == 'y' || _planeNormal == 'z'); + if(_planeNormal != 'x' || _planeNormal != 'y' || _planeNormal != 'z') + throw std::runtime_error("PlanarAverageProbe: planeNormal must be 'x', 'y' or 'z'!"); } diff --git a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlaneProbe.cu b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlaneProbe.cu index d2b101bc2..e18de63c7 100644 --- a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlaneProbe.cu +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PlaneProbe.cu @@ -64,8 +64,7 @@ std::vector<PostProcessingVariable> PlaneProbe::getPostProcessingVariables(Stati break; default: - printf("Statistic unavailable in PlaneProbe\n"); - assert(false); + throw std::runtime_error("PlaneProbe::getPostProcessingVariables: Statistic unavailable!"); break; } return postProcessingVariables; diff --git a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PointProbe.cu b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PointProbe.cu index 677710ec8..cebac1700 100644 --- a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PointProbe.cu +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/PointProbe.cu @@ -62,8 +62,7 @@ std::vector<PostProcessingVariable> PointProbe::getPostProcessingVariables(Stati break; default: - printf("Statistic unavailable in PointProbe\n"); - assert(false); + throw std::runtime_error("PointProbe::getPostProcessingVariables: Statistic unavailable!"); break; } return postProcessingVariables; @@ -114,7 +113,7 @@ void PointProbe::calculateQuantities(SPtr<ProbeStruct> probeStruct, Parameter* p void PointProbe::addProbePointsFromList(std::vector<real>& _pointCoordsX, std::vector<real>& _pointCoordsY, std::vector<real>& _pointCoordsZ) { bool isSameLength = ( (_pointCoordsX.size()==_pointCoordsY.size()) && (_pointCoordsY.size()==_pointCoordsZ.size())); - assert("Probe: point lists have different lengths" && isSameLength); + if (!isSameLength) throw std::runtime_error("Probe::addProbePointsFromList(): point lists have different lengths!"); this->pointCoordsX.insert(this->pointCoordsX.end(), _pointCoordsX.begin(), _pointCoordsX.end()); this->pointCoordsY.insert(this->pointCoordsY.end(), _pointCoordsY.begin(), _pointCoordsY.end()); this->pointCoordsZ.insert(this->pointCoordsZ.end(), _pointCoordsZ.begin(), _pointCoordsZ.end()); diff --git a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/Probe.cu b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/Probe.cu index 340c6ccac..39f8d46e5 100644 --- a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/Probe.cu +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/Probe.cu @@ -311,7 +311,7 @@ void Probe::free(Parameter* para, CudaMemoryManager* cudaMemoryManager) void Probe::addStatistic(Statistic variable) { - assert(this->isAvailableStatistic(variable)); + if (!this->isAvailableStatistic(variable)) throw std::runtime_error("Probe::addStatistic(): Statistic not available for this probe type!"); this->quantities[int(variable)] = true; switch(variable) diff --git a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/Probe.h b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/Probe.h index 30a757338..a83f4d2b6 100644 --- a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/Probe.h +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/Probe.h @@ -43,6 +43,8 @@ #ifndef Probe_H #define Probe_H +#include <iostream> + #include <cuda.h> #include "PreCollisionInteractor/PreCollisionInteractor.h" @@ -150,7 +152,8 @@ public: outputTimeSeries(_outputTimeSeries), PreCollisionInteractor() { - assert("Output starts before averaging!" && tStartOut>=tStartAvg); + if (_tStartOut<_tStartAvg) throw std::runtime_error("Probe: tStartOut must be larger than tStartAvg!"); + if (_tStartTmpAvg<_tStartAvg) throw std::runtime_error("Probe: tStartTmpAvg must be larger than tStartAvg!"); } void init(Parameter* para, GridProvider* gridProvider, CudaMemoryManager* cudaMemoryManager) override; diff --git a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/WallModelProbe.cu b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/WallModelProbe.cu index 4bcfce736..eb2afbe8f 100644 --- a/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/WallModelProbe.cu +++ b/src/gpu/VirtualFluids_GPU/PreCollisionInteractor/Probes/WallModelProbe.cu @@ -142,8 +142,7 @@ std::vector<PostProcessingVariable> WallModelProbe::getPostProcessingVariables(S break; default: - printf("Statistic unavailable in WallModelProbe\n"); - assert(false); + throw std::runtime_error("WallModelProbe::getPostProcessingVariables: Statistic unavailable!"); break; } return postProcessingVariables; @@ -156,7 +155,8 @@ void WallModelProbe::findPoints(Parameter* para, GridProvider* gridProvider, std std::vector<real>& pointCoordsX_level, std::vector<real>& pointCoordsY_level, std::vector<real>& pointCoordsZ_level, int level) { - assert( para->getParD(level)->stressBC.numberOfBCnodes > 0 && para->getHasWallModelMonitor() ); + if ( para->getParD(level)->stressBC.numberOfBCnodes < 1) throw std::runtime_error("WallModelProbe::findPoints(): stressBC.numberOfBCnodes < 1 !"); + if ( !para->getHasWallModelMonitor()) throw std::runtime_error("WallModelProbe::findPoints(): !para->getHasWallModelMonitor() !"); real dt = para->getTimeRatio(); uint nt = uint((para->getTEnd()-this->tStartAvg)/this->tAvg); @@ -170,7 +170,7 @@ void WallModelProbe::findPoints(Parameter* para, GridProvider* gridProvider, std if(this->evaluatePressureGradient) { - assert(para->getIsBodyForce()); + if (!para->getIsBodyForce()) throw std::runtime_error("WallModelProbe::findPoints(): bodyforce not allocated!"); // Find all fluid nodes for(uint j=1; j<para->getParH(level)->numberOfNodes; j++ ) { -- GitLab