From 9db99f3624b70441dc3dd8f791d41263ed0a7dd8 Mon Sep 17 00:00:00 2001 From: Hkorb <henry.korb@geo.uu.se> Date: Thu, 16 Sep 2021 09:54:31 +0200 Subject: [PATCH] small addititons to probe --- apps/gpu/LBM/ActuatorLine/ActuatorLine.cpp | 3 +- src/gpu/VirtualFluids_GPU/Visitor/Probe.cu | 36 +++++++++++++++++----- src/gpu/VirtualFluids_GPU/Visitor/Probe.h | 1 + 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/apps/gpu/LBM/ActuatorLine/ActuatorLine.cpp b/apps/gpu/LBM/ActuatorLine/ActuatorLine.cpp index 383fd24d4..54010de95 100644 --- a/apps/gpu/LBM/ActuatorLine/ActuatorLine.cpp +++ b/apps/gpu/LBM/ActuatorLine/ActuatorLine.cpp @@ -230,7 +230,8 @@ void multipleLevel(const std::string& configPath) std::vector<real> probeCoordsX = {D,2*D,5*D}; std::vector<real> probeCoordsY = {3*D,3*D,3*D}; std::vector<real> probeCoordsZ = {3*D,3*D,3*D}; - probe->setProbePointsFromList(probeCoordsX,probeCoordsY,probeCoordsZ); + // probe->setProbePointsFromList(probeCoordsX,probeCoordsY,probeCoordsZ); + probe->setProbePointsFromXNormalPlane(2*D, 0.0, 0.0, L_y, L_z, dx, dx); probe->addPostProcessingVariable(PostProcessingVariable::Means); probe->addPostProcessingVariable(PostProcessingVariable::Variances); para->addProbe( probe ); diff --git a/src/gpu/VirtualFluids_GPU/Visitor/Probe.cu b/src/gpu/VirtualFluids_GPU/Visitor/Probe.cu index a4c30fc31..48c3e726d 100644 --- a/src/gpu/VirtualFluids_GPU/Visitor/Probe.cu +++ b/src/gpu/VirtualFluids_GPU/Visitor/Probe.cu @@ -95,9 +95,6 @@ void Probe::init(Parameter* para, GridProvider* gridProvider, CudaMemoryManager* this->postProcessingVariables.assign(s.begin(), s.end()); this->addPostProcessingVariable(PostProcessingVariable::LAST); - - - for(int level=0; level<=para->getMaxLevel(); level++) { std::vector<int> probeIndices_level; @@ -128,9 +125,9 @@ void Probe::init(Parameter* para, GridProvider* gridProvider, CudaMemoryManager* pointCoordsX_level.push_back( pointCoordX ); pointCoordsY_level.push_back( pointCoordY ); pointCoordsZ_level.push_back( pointCoordZ ); - printf("Found Point %i, x: %f, y: %f,z: %f, \n For %f %f %f, \n distx: %f, disty: %f, distz: %f \n", j, para->getParH(level)->coordX_SP[j],para->getParH(level)->coordY_SP[j],para->getParH(level)->coordZ_SP[j], - this->pointCoordsX[point], this->pointCoordsY[point], this->pointCoordsZ[point], - distX, distY, distZ); + // printf("Found Point %i, x: %f, y: %f,z: %f, \n For %f %f %f, \n distx: %f, disty: %f, distz: %f \n", j, para->getParH(level)->coordX_SP[j],para->getParH(level)->coordY_SP[j],para->getParH(level)->coordZ_SP[j], + // this->pointCoordsX[point], this->pointCoordsY[point], this->pointCoordsZ[point], + // distX, distY, distZ); } } } @@ -172,6 +169,7 @@ void Probe::init(Parameter* para, GridProvider* gridProvider, CudaMemoryManager* cudaManager->cudaAllocProbeQuantityArray(this, level); std::copy(this->postProcessingVariables.begin(), this->postProcessingVariables.end(), probeParams[level]->quantitiesH); cudaManager->cudaCopyProbeQuantitiesHtoD(this, level); + for(int arr=0; arr<probeParams[level]->nArrays; arr++) { for( int point=0; point<probeParams[level]->nPoints; point++) @@ -179,6 +177,7 @@ void Probe::init(Parameter* para, GridProvider* gridProvider, CudaMemoryManager* probeParams[level]->quantitiesArrayH[arr*probeParams[level]->nPoints+point] = 0.0f; } } + cudaManager->cudaCopyProbeQuantityArrayHtoD(this, level); } } @@ -224,7 +223,30 @@ void Probe::setProbePointsFromList(std::vector<real> &_pointCoordsX, std::vector this->pointCoordsY = _pointCoordsY; this->pointCoordsZ = _pointCoordsZ; this->nProbePoints = _pointCoordsX.size(); - printf("Added list of %u points", this->nProbePoints ); + printf("Added list of %u points \n", this->nProbePoints ); +} + +void Probe::setProbePointsFromXNormalPlane(real pos_x, real pos0_y, real pos0_z, real pos1_y, real pos1_z, real delta_y, real delta_z) +{ + int n_points_y = int((pos1_y-pos0_y)/delta_y); + int n_points_z = int((pos1_z-pos0_z)/delta_z); + int n_points = n_points_y*n_points_z; + + std::vector<real> pointCoordsXtmp, pointCoordsYtmp, pointCoordsZtmp; + pointCoordsXtmp.reserve(n_points); + pointCoordsYtmp.reserve(n_points); + pointCoordsZtmp.reserve(n_points); + + for(int n_y=0; n_y<n_points_y; n_y++) + { + for(int n_z=0; n_z<n_points_z; n_z++) + { + pointCoordsXtmp.push_back(pos_x); + pointCoordsYtmp.push_back(pos0_y+delta_y*n_y); + pointCoordsZtmp.push_back(pos0_z+delta_z*n_z); + } + } + this->setProbePointsFromList(pointCoordsXtmp, pointCoordsYtmp, pointCoordsZtmp); } void Probe::addPostProcessingVariable(PostProcessingVariable _variable) diff --git a/src/gpu/VirtualFluids_GPU/Visitor/Probe.h b/src/gpu/VirtualFluids_GPU/Visitor/Probe.h index 577784de8..2893595e6 100644 --- a/src/gpu/VirtualFluids_GPU/Visitor/Probe.h +++ b/src/gpu/VirtualFluids_GPU/Visitor/Probe.h @@ -53,6 +53,7 @@ public: std::vector<PostProcessingVariable> getPostProcessingVariables(){return this->postProcessingVariables; } void setProbePointsFromList(std::vector<real> &_pointCoordsX, std::vector<real> &_pointCoordsY, std::vector<real> &_pointCoordsZ); + void setProbePointsFromXNormalPlane(real pos_x, real pos0_y, real pos0_z, real pos1_y, real pos1_z, real delta_y, real delta_z); void addPostProcessingVariable(PostProcessingVariable _variable); void write(Parameter* para, int level, int t); -- GitLab