From c81964d5676d10910a3802a8a291a9891ac406c7 Mon Sep 17 00:00:00 2001 From: Soeren Peters <peters@irmb.tu-bs.de> Date: Thu, 1 Oct 2020 16:28:54 +0200 Subject: [PATCH] Update LBM, Parallel and Utilities. --- .../NonReflectingOutflowBCAlgorithm.cpp | 2 + .../PressureCoefficientCoProcessor.h | 1 + .../CoProcessors/QCriterionCoProcessor.h | 1 + .../WriteMQFromSelectionCoProcessor.h | 2 + .../VirtualFluidsCore/LBM/BGKLBMKernel.cpp | 1 + ...ibleCumulant4thOrderViscosityLBMKernel.cpp | 2 + .../LBM/CompressibleCumulantLBMKernel.cpp | 2 + ...mpressibleOffsetInterpolationProcessor.cpp | 2 +- ...bleOffsetMomentsInterpolationProcessor.cpp | 2 +- ...etSquarePressureInterpolationProcessor.cpp | 2 +- src/cpu/VirtualFluidsCore/LBM/D3Q27System.cpp | 2 + src/cpu/VirtualFluidsCore/LBM/D3Q27System.h | 247 ++++-------------- src/cpu/VirtualFluidsCore/LBM/ILBMKernel.h | 35 ++- .../LBM/IncompressibleCumulantLBMKernel.cpp | 2 + ...ssibleCumulantWithSpongeLayerLBMKernel.cpp | 4 +- .../LBM/InitDensityLBMKernel.cpp | 2 + src/cpu/VirtualFluidsCore/LBM/LBMKernel.cpp | 33 +++ src/cpu/VirtualFluidsCore/LBM/LBMKernel.h | 37 ++- .../LBM/LBMKernelETD3Q27BGK.cpp | 2 + src/cpu/VirtualFluidsCore/LBM/LBMSystem.cpp | 33 +++ src/cpu/VirtualFluidsCore/LBM/LBMSystem.h | 69 ++--- .../Parallel/Communicator.cpp | 33 +++ .../VirtualFluidsCore/Parallel/Communicator.h | 34 +++ .../Parallel/NullCommunicator.cpp | 34 +++ .../Parallel/NullCommunicator.h | 35 +++ .../VirtualFluidsCore/Utilities/MemoryUtil.h | 55 +++- 26 files changed, 435 insertions(+), 239 deletions(-) diff --git a/src/cpu/VirtualFluidsCore/BoundaryConditions/NonReflectingOutflowBCAlgorithm.cpp b/src/cpu/VirtualFluidsCore/BoundaryConditions/NonReflectingOutflowBCAlgorithm.cpp index 149824f17..d02daf91e 100644 --- a/src/cpu/VirtualFluidsCore/BoundaryConditions/NonReflectingOutflowBCAlgorithm.cpp +++ b/src/cpu/VirtualFluidsCore/BoundaryConditions/NonReflectingOutflowBCAlgorithm.cpp @@ -29,6 +29,8 @@ void NonReflectingOutflowBCAlgorithm::addDistributions(SPtr<DistributionArray3D> void NonReflectingOutflowBCAlgorithm::applyBC() { using namespace D3Q27System; + using namespace UbMath; + LBMReal f[ENDF+1]; LBMReal ftemp[ENDF+1]; diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/PressureCoefficientCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/PressureCoefficientCoProcessor.h index 5738ec642..c1d5685c5 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/PressureCoefficientCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/PressureCoefficientCoProcessor.h @@ -7,6 +7,7 @@ #include "CoProcessor.h" #include "LBMSystem.h" +#include "UbTuple.h" class GbCuboid3D; diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.h index 1a1f53d9a..1a817601c 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/QCriterionCoProcessor.h @@ -12,6 +12,7 @@ #include "CoProcessor.h" #include "LBMSystem.h" +#include "UbTuple.h" class Communicator; class Grid3D; diff --git a/src/cpu/VirtualFluidsCore/CoProcessors/WriteMQFromSelectionCoProcessor.h b/src/cpu/VirtualFluidsCore/CoProcessors/WriteMQFromSelectionCoProcessor.h index 886fed0f8..12b8f6caf 100644 --- a/src/cpu/VirtualFluidsCore/CoProcessors/WriteMQFromSelectionCoProcessor.h +++ b/src/cpu/VirtualFluidsCore/CoProcessors/WriteMQFromSelectionCoProcessor.h @@ -8,6 +8,8 @@ #include "CoProcessor.h" #include "LBMSystem.h" +#include "UbTuple.h" + class Communicator; class Grid3D; diff --git a/src/cpu/VirtualFluidsCore/LBM/BGKLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/BGKLBMKernel.cpp index f91a4197a..5735fa5d4 100644 --- a/src/cpu/VirtualFluidsCore/LBM/BGKLBMKernel.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/BGKLBMKernel.cpp @@ -42,6 +42,7 @@ SPtr<LBMKernel> BGKLBMKernel::clone() void BGKLBMKernel::calculate(int step) { using namespace D3Q27System; + using namespace UbMath; //initializing of forcing stuff if (withForcing) diff --git a/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulant4thOrderViscosityLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulant4thOrderViscosityLBMKernel.cpp index dfcec6ec2..897793c94 100644 --- a/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulant4thOrderViscosityLBMKernel.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulant4thOrderViscosityLBMKernel.cpp @@ -9,6 +9,8 @@ #define PROOF_CORRECTNESS +using namespace UbMath; + ////////////////////////////////////////////////////////////////////////// CompressibleCumulant4thOrderViscosityLBMKernel::CompressibleCumulant4thOrderViscosityLBMKernel() { diff --git a/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.cpp index dd9725b1e..d6c0d8279 100644 --- a/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/CompressibleCumulantLBMKernel.cpp @@ -8,6 +8,8 @@ #define PROOF_CORRECTNESS +using namespace UbMath; + ////////////////////////////////////////////////////////////////////////// CompressibleCumulantLBMKernel::CompressibleCumulantLBMKernel() { diff --git a/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetInterpolationProcessor.cpp b/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetInterpolationProcessor.cpp index 36910694c..7716a246e 100644 --- a/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetInterpolationProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetInterpolationProcessor.cpp @@ -1,7 +1,7 @@ #include "CompressibleOffsetInterpolationProcessor.h" #include "D3Q27System.h" - +using namespace UbMath; CompressibleOffsetInterpolationProcessor::CompressibleOffsetInterpolationProcessor() : omegaC(0.0), omegaF(0.0) diff --git a/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetMomentsInterpolationProcessor.cpp b/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetMomentsInterpolationProcessor.cpp index d9d986851..a6823042e 100644 --- a/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetMomentsInterpolationProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetMomentsInterpolationProcessor.cpp @@ -1,7 +1,7 @@ #include "CompressibleOffsetMomentsInterpolationProcessor.h" #include "D3Q27System.h" - +using namespace UbMath; CompressibleOffsetMomentsInterpolationProcessor::CompressibleOffsetMomentsInterpolationProcessor() : omegaC(0.0), omegaF(0.0) diff --git a/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetSquarePressureInterpolationProcessor.cpp b/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetSquarePressureInterpolationProcessor.cpp index 44be4234f..4f3822b2b 100644 --- a/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetSquarePressureInterpolationProcessor.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/CompressibleOffsetSquarePressureInterpolationProcessor.cpp @@ -1,7 +1,7 @@ #include "CompressibleOffsetSquarePressureInterpolationProcessor.h" #include "D3Q27System.h" - +using namespace UbMath; CompressibleOffsetSquarePressureInterpolationProcessor::CompressibleOffsetSquarePressureInterpolationProcessor() : omegaC(0.0), omegaF(0.0) diff --git a/src/cpu/VirtualFluidsCore/LBM/D3Q27System.cpp b/src/cpu/VirtualFluidsCore/LBM/D3Q27System.cpp index c56164ab3..07a4528b7 100644 --- a/src/cpu/VirtualFluidsCore/LBM/D3Q27System.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/D3Q27System.cpp @@ -1,6 +1,8 @@ #include "D3Q27System.h" namespace D3Q27System { + using namespace UbMath; + //index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18//falsch //f: ZERO, E, W, N, S, T, B, NE, SW, SE, NW, TE, BW, BE, TW, TN, BS, BN, TS, TNE TNW TSE TSW BNE BNW BSE BSW //const int EX1[] = { 0, 1, -1, 0, 0, 0, 0, 1, -1, 1, -1, 1, -1, 1, -1, 0, 0, 0, 0, 1, -1, 1, -1, 1, -1, 1, -1 }; diff --git a/src/cpu/VirtualFluidsCore/LBM/D3Q27System.h b/src/cpu/VirtualFluidsCore/LBM/D3Q27System.h index 6ae3bf70e..921ee65a8 100644 --- a/src/cpu/VirtualFluidsCore/LBM/D3Q27System.h +++ b/src/cpu/VirtualFluidsCore/LBM/D3Q27System.h @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file D3Q27System.h +//! \ingroup LBM +//! \author Konstantin Kutscher, Sebastian Geller, Soeren Freudiger +//======================================================================================= + #ifndef D3Q27SYSTEM_H #define D3Q27SYSTEM_H @@ -5,135 +38,23 @@ #include <string> #include <iostream> -#ifdef RCF_USE_SF_SERIALIZATION - #include <SF/Serializer.hpp> - - #if CAB_RCF <= 903 - #include <SF/SerializeEnum.hpp> - #endif -#endif //RCF_USE_SF_SERIALIZATION - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbTuple.h> -#include <basics/utilities/UbMath.h> -#include <basics/utilities/UbSystem.h> -//#include "Patch3DSystem.h" +#include "UbException.h" +#include "UbMath.h" #include "LBMSystem.h" - -/*=========================================================================*/ -/* D3Q27System */ -/* */ -/** -class for global system-functions -<BR><BR> -@author <A HREF="mailto:kucher@irmb.tu-bs.de">K. Kucher</A> -@version 1.0 - 22.10.09 -*/ - -/* -usage: ... -*/ - - -#ifndef SWIG - using namespace UbMath; -#endif +//! \brief namespace for global system-functions namespace D3Q27System { - //enum COLLISIONMODEL { UNDEFINED, INCOMPLBGKMODEL, COMPLBGKMODEL, COMPLBGKWTMODEL, INCOMPLBGKLESMODEL, INCOMPLBGKNONNEWTONIANMODEL - // , INCOMPGLBEJTMODEL, COMPGLBEJTMODEL, COMPGLBEJTWTMODEL, INCOMPGLBEJTLESMODEL, INCOMPGLBEJTWALEMODEL - // , CASCADEDMODEL}; - // - // #if defined(RCF_USE_SF_SERIALIZATION) && (CAB_RCF <= 903) - // SF_SERIALIZE_ENUM(COLLISIONMODEL) //muss im namespace stehen, sonst funzt es nicht! - // #endif - - ///*=====================================================================*/ - //std::string toString(const COLLISIONMODEL& model); - ///*=====================================================================*/ - //COLLISIONMODEL getCollModelByString(const std::string& str); - ///*=====================================================================*/ - - ///*=====================================================================*/ - //static bool isCompModel(const COLLISIONMODEL& model) - //{ - // switch(model) - // { - // case COMPLBGKMODEL : return true; - // case COMPLBGKWTMODEL : return true; - // case COMPGLBEJTWTMODEL : return true; - // case COMPGLBEJTMODEL : return true; - // case CASCADEDMODEL : return true; - // - // case INCOMPLBGKMODEL : return false; - // case INCOMPGLBEJTMODEL : return false; - // case INCOMPLBGKLESMODEL : return false; - // case INCOMPGLBEJTLESMODEL : return false; - // case INCOMPGLBEJTWALEMODEL : return false; - // case INCOMPLBGKNONNEWTONIANMODEL : return false; - - // default: throw UbException(UB_EXARGS,"unknown model"); - // } - //} - ///*=====================================================================*/ - //static bool isGLBEModel(const COLLISIONMODEL& model) - //{ - // switch(model) - // { - // case COMPGLBEJTWTMODEL : return true; - // case COMPGLBEJTMODEL : return true; - // case INCOMPGLBEJTMODEL : return true; - // case INCOMPGLBEJTLESMODEL : return true; - // case INCOMPGLBEJTWALEMODEL : return false; - - // case COMPLBGKMODEL : return false; - // case COMPLBGKWTMODEL : return false; - // case INCOMPLBGKMODEL : return false; - // case INCOMPLBGKLESMODEL : return false; - // case INCOMPLBGKNONNEWTONIANMODEL : return false; - - // default: throw UbException(UB_EXARGS,"unknown model"); - // } - //} - //static bool isLESModel(const COLLISIONMODEL& model) - //{ - // switch(model) - // { - // case INCOMPGLBEJTLESMODEL : return true; - // case INCOMPLBGKLESMODEL : return true; - // case INCOMPGLBEJTWALEMODEL : return true; - // - // case COMPGLBEJTWTMODEL : return false; - // case COMPGLBEJTMODEL : return false; - // case INCOMPGLBEJTMODEL : return false; - // case COMPLBGKMODEL : return false; - // case COMPLBGKWTMODEL : return false; - // case INCOMPLBGKMODEL : return false; - // case INCOMPLBGKNONNEWTONIANMODEL : return false; - - // default: throw UbException(UB_EXARGS,"unknown model"); - // } - //} - - ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// //DIRECTION STUFF static const int FSTARTDIR = 0; static const int FENDDIR = 25; //D3Q27 - //static const int FSTARTDIR = 1; - //static const int FENDDIR = 26; //D3Q27 - static const int STARTF = 0; static const int ENDF = 26; //D3Q27 - //extern const int EX1[ENDF+1]; - //extern const int EX2[ENDF+1]; - //extern const int EX3[ENDF+1]; - static const int STARTDIR = 0; - static const int ENDDIR = 26; //alle geometrischen richtungen + static const int ENDDIR = 26; extern const int DX1[ENDDIR+1]; extern const int DX2[ENDDIR+1]; @@ -290,10 +211,10 @@ namespace D3Q27System +(f[T] + f[B]))+f[ZERO]; } /*=====================================================================*/ - //ACHTUNG: gilt nicht fuer alle modelle -> praedikat verwenden anstelle static! toDo + //ATTENTION: does not apply to all models -> use certificate instead of static! to do static LBMReal getPressure(const LBMReal* const& f/*[27]*/) { - return REAL_CAST( c1o3 )*getDensity(f); + return REAL_CAST( UbMath::c1o3 )*getDensity(f); } /*=====================================================================*/ static LBMReal getIncompVelocityX1(const LBMReal* const& f/*[27]*/) @@ -404,7 +325,7 @@ namespace D3Q27System D3Q27System::calcIncompVelocityX1(f, vx1); D3Q27System::calcIncompVelocityX2(f, vx2); D3Q27System::calcIncompVelocityX3(f, vx3); - LBMReal rho = drho+one; + LBMReal rho = drho+UbMath::c1; vx1/=rho; vx2/=rho; vx3/=rho; @@ -412,43 +333,11 @@ namespace D3Q27System ////////////////////////////////////////////////////////////////////////// static LBMReal getCompFeqForDirection(const int& direction, const LBMReal& drho,const LBMReal& vx1,const LBMReal& vx2,const LBMReal& vx3) { + using namespace UbMath; LBMReal cu_sq=1.5*(vx1*vx1+vx2*vx2+vx3*vx3); - //switch(direction) - //{ - // case ZERO : return REAL_CAST( c8o27*rho*(1.0-cu_sq)); - // case E : return REAL_CAST( c2o27*rho*(1.0+3.0*( vx1 )+c9o2*( vx1 )*( vx1 )-cu_sq)); - // case W : return REAL_CAST( c2o27*rho*(1.0+3.0*(-vx1 )+c9o2*(-vx1 )*(-vx1 )-cu_sq)); - // case N : return REAL_CAST( c2o27*rho*(1.0+3.0*( vx2)+c9o2*( vx2)*( vx2)-cu_sq)); - // case S : return REAL_CAST( c2o27*rho*(1.0+3.0*( -vx2)+c9o2*( -vx2)*( -vx2)-cu_sq)); - // case T : return REAL_CAST( c2o27*rho*(1.0+3.0*( vx3 )+c9o2*( vx3)*( vx3)-cu_sq)); - // case B : return REAL_CAST( c2o27*rho*(1.0+3.0*( -vx3)+c9o2*( -vx3)*( -vx3)-cu_sq)); - // case NE : return REAL_CAST( c1o54*rho*(1.0+3.0*( vx1+vx2)+c9o2*( vx1+vx2)*( vx1+vx2)-cu_sq)); - // case SW : return REAL_CAST( c1o54*rho*(1.0+3.0*(-vx1-vx2)+c9o2*(-vx1-vx2)*(-vx1-vx2)-cu_sq)); - // case SE : return REAL_CAST( c1o54*rho*(1.0+3.0*( vx1-vx2)+c9o2*( vx1-vx2)*( vx1-vx2)-cu_sq)); - // case NW : return REAL_CAST( c1o54*rho*(1.0+3.0*(-vx1+vx2)+c9o2*(-vx1+vx2)*(-vx1+vx2)-cu_sq)); - // case TE : return REAL_CAST( c1o54*rho*(1.0+3.0*( vx1+vx3)+c9o2*( vx1+vx3)*( vx1+vx3)-cu_sq)); - // case BW : return REAL_CAST( c1o54*rho*(1.0+3.0*(-vx1-vx3)+c9o2*(-vx1-vx3)*(-vx1-vx3)-cu_sq)); - // case BE : return REAL_CAST( c1o54*rho*(1.0+3.0*( vx1-vx3)+c9o2*( vx1-vx3)*( vx1-vx3)-cu_sq)); - // case TW : return REAL_CAST( c1o54*rho*(1.0+3.0*(-vx1+vx3)+c9o2*(-vx1+vx3)*(-vx1+vx3)-cu_sq)); - // case TN : return REAL_CAST( c1o54*rho*(1.0+3.0*( vx2+vx3)+c9o2*( vx2+vx3)*( vx2+vx3)-cu_sq)); - // case BS : return REAL_CAST( c1o54*rho*(1.0+3.0*(-vx2-vx3)+c9o2*(-vx2-vx3)*(-vx2-vx3)-cu_sq)); - // case BN : return REAL_CAST( c1o54*rho*(1.0+3.0*( vx2-vx3)+c9o2*( vx2-vx3)*( vx2-vx3)-cu_sq)); - // case TS : return REAL_CAST( c1o54*rho*(1.0+3.0*(-vx2+vx3)+c9o2*(-vx2+vx3)*(-vx2+vx3)-cu_sq)); - // case TNE : return REAL_CAST(c1o216*rho*(1.0+3.0*( vx1+vx2+vx3)+c9o2*( vx1+vx2+vx3)*( vx1+vx2+vx3)-cu_sq)); - // case BSW : return REAL_CAST(c1o216*rho*(1.0+3.0*(-vx1-vx2-vx3)+c9o2*(-vx1-vx2-vx3)*(-vx1-vx2-vx3)-cu_sq)); - // case BNE : return REAL_CAST(c1o216*rho*(1.0+3.0*( vx1+vx2-vx3)+c9o2*( vx1+vx2-vx3)*( vx1+vx2-vx3)-cu_sq)); - // case TSW : return REAL_CAST(c1o216*rho*(1.0+3.0*(-vx1-vx2+vx3)+c9o2*(-vx1-vx2+vx3)*(-vx1-vx2+vx3)-cu_sq)); - // case TSE : return REAL_CAST(c1o216*rho*(1.0+3.0*( vx1-vx2+vx3)+c9o2*( vx1-vx2+vx3)*( vx1-vx2+vx3)-cu_sq)); - // case BNW : return REAL_CAST(c1o216*rho*(1.0+3.0*(-vx1+vx2-vx3)+c9o2*(-vx1+vx2-vx3)*(-vx1+vx2-vx3)-cu_sq)); - // case BSE : return REAL_CAST(c1o216*rho*(1.0+3.0*( vx1-vx2-vx3)+c9o2*( vx1-vx2-vx3)*( vx1-vx2-vx3)-cu_sq)); - // case TNW : return REAL_CAST(c1o216*rho*(1.0+3.0*(-vx1+vx2+vx3)+c9o2*(-vx1+vx2+vx3)*(-vx1+vx2+vx3)-cu_sq)); - // default: throw UbException(UB_EXARGS,"unknown dir"); - //} - - ////----- - LBMReal rho = drho+one; + LBMReal rho = drho+c1; switch (direction) { case ZERO: return REAL_CAST(c8o27*(drho+rho*(-cu_sq))); @@ -485,40 +374,10 @@ namespace D3Q27System ////////////////////////////////////////////////////////////////////////// static void calcCompFeq(LBMReal* const& feq/*[27]*/,const LBMReal& drho,const LBMReal& vx1,const LBMReal& vx2,const LBMReal& vx3) { - //LBMReal cu_sq=1.5*(vx1*vx1+vx2*vx2+vx3*vx3); - - //feq[ZERO] = c8o27*rho*(1.0-cu_sq); - //feq[E] = c2o27*rho*(1.0+3.0*( vx1 )+c9o2*( vx1 )*( vx1 )-cu_sq); - //feq[W] = c2o27*rho*(1.0+3.0*(-vx1 )+c9o2*(-vx1 )*(-vx1 )-cu_sq); - //feq[N] = c2o27*rho*(1.0+3.0*( vx2)+c9o2*( vx2)*( vx2)-cu_sq); - //feq[S] = c2o27*rho*(1.0+3.0*( -vx2)+c9o2*( -vx2)*( -vx2)-cu_sq); - //feq[T] = c2o27*rho*(1.0+3.0*( vx3 )+c9o2*( vx3)*( vx3)-cu_sq); - //feq[B] = c2o27*rho*(1.0+3.0*( -vx3)+c9o2*( -vx3)*( -vx3)-cu_sq); - //feq[NE] = c1o54*rho*(1.0+3.0*( vx1+vx2)+c9o2*( vx1+vx2)*( vx1+vx2)-cu_sq); - //feq[SW] = c1o54*rho*(1.0+3.0*(-vx1-vx2)+c9o2*(-vx1-vx2)*(-vx1-vx2)-cu_sq); - //feq[SE] = c1o54*rho*(1.0+3.0*( vx1-vx2)+c9o2*( vx1-vx2)*( vx1-vx2)-cu_sq); - //feq[NW] = c1o54*rho*(1.0+3.0*(-vx1+vx2)+c9o2*(-vx1+vx2)*(-vx1+vx2)-cu_sq); - //feq[TE] = c1o54*rho*(1.0+3.0*( vx1+vx3)+c9o2*( vx1+vx3)*( vx1+vx3)-cu_sq); - //feq[BW] = c1o54*rho*(1.0+3.0*(-vx1-vx3)+c9o2*(-vx1-vx3)*(-vx1-vx3)-cu_sq); - //feq[BE] = c1o54*rho*(1.0+3.0*( vx1-vx3)+c9o2*( vx1-vx3)*( vx1-vx3)-cu_sq); - //feq[TW] = c1o54*rho*(1.0+3.0*(-vx1+vx3)+c9o2*(-vx1+vx3)*(-vx1+vx3)-cu_sq); - //feq[TN] = c1o54*rho*(1.0+3.0*( vx2+vx3)+c9o2*( vx2+vx3)*( vx2+vx3)-cu_sq); - //feq[BS] = c1o54*rho*(1.0+3.0*(-vx2-vx3)+c9o2*(-vx2-vx3)*(-vx2-vx3)-cu_sq); - //feq[BN] = c1o54*rho*(1.0+3.0*( vx2-vx3)+c9o2*( vx2-vx3)*( vx2-vx3)-cu_sq); - //feq[TS] = c1o54*rho*(1.0+3.0*(-vx2+vx3)+c9o2*(-vx2+vx3)*(-vx2+vx3)-cu_sq); - //feq[TNE] = c1o216*rho*(1.0+3.0*( vx1+vx2+vx3)+c9o2*( vx1+vx2+vx3)*( vx1+vx2+vx3)-cu_sq); - //feq[BSW] = c1o216*rho*(1.0+3.0*(-vx1-vx2-vx3)+c9o2*(-vx1-vx2-vx3)*(-vx1-vx2-vx3)-cu_sq); - //feq[BNE] = c1o216*rho*(1.0+3.0*( vx1+vx2-vx3)+c9o2*( vx1+vx2-vx3)*( vx1+vx2-vx3)-cu_sq); - //feq[TSW] = c1o216*rho*(1.0+3.0*(-vx1-vx2+vx3)+c9o2*(-vx1-vx2+vx3)*(-vx1-vx2+vx3)-cu_sq); - //feq[TSE] = c1o216*rho*(1.0+3.0*( vx1-vx2+vx3)+c9o2*( vx1-vx2+vx3)*( vx1-vx2+vx3)-cu_sq); - //feq[BNW] = c1o216*rho*(1.0+3.0*(-vx1+vx2-vx3)+c9o2*(-vx1+vx2-vx3)*(-vx1+vx2-vx3)-cu_sq); - //feq[BSE] = c1o216*rho*(1.0+3.0*( vx1-vx2-vx3)+c9o2*( vx1-vx2-vx3)*( vx1-vx2-vx3)-cu_sq); - //feq[TNW] = c1o216*rho*(1.0+3.0*(-vx1+vx2+vx3)+c9o2*(-vx1+vx2+vx3)*(-vx1+vx2+vx3)-cu_sq); - - ////////////////////////////////////////////////////////////////////////// + using namespace UbMath; LBMReal cu_sq = 1.5*(vx1*vx1+vx2*vx2+vx3*vx3); - LBMReal rho = drho+one; + LBMReal rho = drho+c1; feq[ZERO] = c8o27*(drho+rho*(-cu_sq)); feq[E] = c2o27*(drho+rho*(3.0*(vx1)+c9o2*(vx1)*(vx1)-cu_sq)); @@ -550,7 +409,9 @@ namespace D3Q27System } ////////////////////////////////////////////////////////////////////////// static LBMReal getIncompFeqForDirection(const int& direction,const LBMReal& drho, const LBMReal& vx1,const LBMReal& vx2,const LBMReal& vx3) - { + { + using namespace UbMath; + LBMReal cu_sq=1.5f*(vx1*vx1+vx2*vx2+vx3*vx3); switch(direction) @@ -588,6 +449,8 @@ namespace D3Q27System ////////////////////////////////////////////////////////////////////////// static void calcIncompFeq(LBMReal* const& feq/*[27]*/,const LBMReal& drho,const LBMReal& vx1,const LBMReal& vx2,const LBMReal& vx3) { + using namespace UbMath; + LBMReal cu_sq=1.5*(vx1*vx1+vx2*vx2+vx3*vx3); feq[ZERO] = c8o27*(drho-cu_sq); @@ -621,6 +484,8 @@ namespace D3Q27System ////////////////////////////////////////////////////////////////////////// static inline float getBoundaryVelocityForDirection(const int& direction, const float& bcVelocityX1,const float& bcVelocityX2,const float& bcVelocityX3) { + using namespace UbMath; + switch(direction) { case E: return (float)( UbMath::c4o9*(+bcVelocityX1) ); @@ -732,6 +597,8 @@ namespace D3Q27System ////////////////////////////////////////////////////////////////////////// static inline void initRayVectors(double* const& rayX1, double* const& rayX2, double* const& rayX3) { + using namespace UbMath; + int fdir; double c1oS2 = UbMath::one_over_sqrt2; double c1oS3 = UbMath::one_over_sqrt3; @@ -765,10 +632,10 @@ namespace D3Q27System ////////////////////////////////////////////////////////////////////////// static inline LBMReal calcPress(const LBMReal* const f, LBMReal rho, LBMReal vx1, LBMReal vx2, LBMReal vx3) { - LBMReal op=1.0; - return ((f[E]+f[W]+f[N]+f[S]+f[T]+f[B]+2.*(f[NE]+f[SW]+f[SE]+f[NW]+f[TE]+f[BW]+f[BE]+f[TW]+f[TN]+f[BS]+f[BN]+f[TS])+ - 3.*(f[TNE]+f[TSW]+f[TSE]+f[TNW]+f[BNE]+f[BSW]+f[BSE]+f[BNW])-(vx1*vx1+vx2*vx2+vx3*vx3))*(1-0.5*op)+op*0.5*(rho))*c1o3; - + using namespace UbMath; + LBMReal OxxPyyPzz = c1; + return ((f[E]+f[W]+f[N]+f[S]+f[T]+f[B]+c2*(f[NE]+f[SW]+f[SE]+f[NW]+f[TE]+f[BW]+f[BE]+f[TW]+f[TN]+f[BS]+f[BN]+f[TS])+ + c3*(f[TNE]+f[TSW]+f[TSE]+f[TNW]+f[BNE]+f[BSW]+f[BSE]+f[BNW])-(vx1*vx1+vx2*vx2+vx3*vx3))*(c1-c1o2*OxxPyyPzz)+OxxPyyPzz*c1o2*(rho))*c1o3; } } diff --git a/src/cpu/VirtualFluidsCore/LBM/ILBMKernel.h b/src/cpu/VirtualFluidsCore/LBM/ILBMKernel.h index dcd47af52..89e68accd 100644 --- a/src/cpu/VirtualFluidsCore/LBM/ILBMKernel.h +++ b/src/cpu/VirtualFluidsCore/LBM/ILBMKernel.h @@ -1,12 +1,45 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file ILBMKernel.h +//! \ingroup LBM +//! \author Konstantin Kutscher +//======================================================================================= + #ifndef I_LBMKERNEL_H #define I_LBMKERNEL_H #include <PointerDefinitions.h> - class BCProcessor; class DataSet3D; +//! Abstract class provides interface for LBM kernel class ILBMKernel { public: diff --git a/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantLBMKernel.cpp index a5e082a2c..1620dc656 100644 --- a/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantLBMKernel.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantLBMKernel.cpp @@ -8,6 +8,8 @@ #define PROOF_CORRECTNESS +using namespace UbMath; + ////////////////////////////////////////////////////////////////////////// IncompressibleCumulantLBMKernel::IncompressibleCumulantLBMKernel() { diff --git a/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantWithSpongeLayerLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantWithSpongeLayerLBMKernel.cpp index 7c8c2d94e..c84776771 100644 --- a/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantWithSpongeLayerLBMKernel.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/IncompressibleCumulantWithSpongeLayerLBMKernel.cpp @@ -8,6 +8,8 @@ #define PROOF_CORRECTNESS +using namespace UbMath; + ////////////////////////////////////////////////////////////////////////// IncompressibleCumulantWithSpongeLayerLBMKernel::IncompressibleCumulantWithSpongeLayerLBMKernel() { @@ -306,7 +308,7 @@ void IncompressibleCumulantWithSpongeLayerLBMKernel::calculate(int step) //muX2 = (double)(x2-1+ix2*maxX2); //muX3 = (double)(x3-1+ix3*maxX3); //} - //spongeFactor ist von Funktion in muSpongeLayer abhängich und variiert zwischen 1 (nix tun) und 0.5 (collFactor etwa auf 1); + //spongeFactor ist von Funktion in muSpongeLayer abh�ngich und variiert zwischen 1 (nix tun) und 0.5 (collFactor etwa auf 1); //lk //LBMReal spongeFactor = muSpongeLayer.Eval(); //if (spongeFactor == 0.5) diff --git a/src/cpu/VirtualFluidsCore/LBM/InitDensityLBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/InitDensityLBMKernel.cpp index 53b533508..addba756e 100644 --- a/src/cpu/VirtualFluidsCore/LBM/InitDensityLBMKernel.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/InitDensityLBMKernel.cpp @@ -4,6 +4,8 @@ #include "DataSet3D.h" #include "BCArray3D.h" +using namespace UbMath; + InitDensityLBMKernel::InitDensityLBMKernel() { this->compressible = false; diff --git a/src/cpu/VirtualFluidsCore/LBM/LBMKernel.cpp b/src/cpu/VirtualFluidsCore/LBM/LBMKernel.cpp index 256443790..7be2e79a5 100644 --- a/src/cpu/VirtualFluidsCore/LBM/LBMKernel.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/LBMKernel.cpp @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file LBMKernel.cpp +//! \ingroup LBM +//! \author Konstantin Kutscher +//======================================================================================= + #include "LBMKernel.h" #include "DataSet3D.h" #include "BCProcessor.h" diff --git a/src/cpu/VirtualFluidsCore/LBM/LBMKernel.h b/src/cpu/VirtualFluidsCore/LBM/LBMKernel.h index a4578a00a..d07e5031b 100644 --- a/src/cpu/VirtualFluidsCore/LBM/LBMKernel.h +++ b/src/cpu/VirtualFluidsCore/LBM/LBMKernel.h @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file LBMKernel.h +//! \ingroup LBM +//! \author Konstantin Kutscher +//======================================================================================= + #ifndef LBMKERNEL_H #define LBMKERNEL_H @@ -5,12 +38,14 @@ #include "LBMSystem.h" #include "ILBMKernel.h" #include <array> +#include <limits> #include <muParser.h> class BCProcessor; class DataSet3D; class Block3D; +//! \brief A base class provides basic functionality for LBM kernel class LBMKernel : public ILBMKernel, public enableSharedFromThis<LBMKernel> { public: @@ -70,7 +105,7 @@ public: bool isInsideOfDomain(const int &x1, const int &x2, const int &x3) const; - void swapDistributions(); + void swapDistributions() override; void setNX(std::array<int, 3> nx); std::array<int, 3> getNX(); diff --git a/src/cpu/VirtualFluidsCore/LBM/LBMKernelETD3Q27BGK.cpp b/src/cpu/VirtualFluidsCore/LBM/LBMKernelETD3Q27BGK.cpp index 55c370e83..3560fd833 100644 --- a/src/cpu/VirtualFluidsCore/LBM/LBMKernelETD3Q27BGK.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/LBMKernelETD3Q27BGK.cpp @@ -8,6 +8,8 @@ //#define PROOF_CORRECTNESS +using namespace UbMath; + ////////////////////////////////////////////////////////////////////////// LBMKernelETD3Q27BGK::LBMKernelETD3Q27BGK() { diff --git a/src/cpu/VirtualFluidsCore/LBM/LBMSystem.cpp b/src/cpu/VirtualFluidsCore/LBM/LBMSystem.cpp index ccb983807..34a9d7818 100644 --- a/src/cpu/VirtualFluidsCore/LBM/LBMSystem.cpp +++ b/src/cpu/VirtualFluidsCore/LBM/LBMSystem.cpp @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file LBMSystem.cpp +//! \ingroup LBM +//! \author Sebastian Geller +//======================================================================================= + #include "LBMSystem.h" namespace LBMSystem diff --git a/src/cpu/VirtualFluidsCore/LBM/LBMSystem.h b/src/cpu/VirtualFluidsCore/LBM/LBMSystem.h index 6aae53040..84037637f 100644 --- a/src/cpu/VirtualFluidsCore/LBM/LBMSystem.h +++ b/src/cpu/VirtualFluidsCore/LBM/LBMSystem.h @@ -1,3 +1,35 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file LBMSystem.h +//! \ingroup LBM +//! \author Sebastian Geller +//======================================================================================= #ifndef LBMSYSTEM_H #define LBMSYSTEM_H @@ -5,38 +37,11 @@ #include <string> #include <iostream> -#ifdef RCF_USE_SF_SERIALIZATION -#include <SF/Serializer.hpp> -#if CAB_RCF <= 903 -#include <SF/SerializeEnum.hpp> -#endif -#endif //RCF_USE_SF_SERIALIZATION - -#include <basics/utilities/UbException.h> -#include <basics/utilities/UbTuple.h> -#include <basics/utilities/UbMath.h> -#include <basics/utilities/UbSystem.h> - -/*=========================================================================*/ -/* LBMSystem */ -/* */ -/** -namespace for global system-functions -<BR><BR> -@author <A HREF="mailto:geller@irmb.tu-bs.de">S. Geller</A> -@version 1.0 - 07.01.11 -*/ - -/* -usage: ... -*/ +//! \brief namespace for global system-functions namespace LBMSystem { -#ifndef SWIG - using namespace UbMath; -#endif //#define SINGLEPRECISION @@ -71,12 +76,12 @@ namespace LBMSystem return REAL_CAST(1.0/(3.0*viscosity/(1.0/REAL_CAST(1<<level))+0.5)); } - //bulk viscosity + //!bulk viscosity static real calcOmega2(real viscosity, int level) { return REAL_CAST(1.0/(4.5*viscosity/(1.0/REAL_CAST(1<<level))+0.5)); } - + //!bulk viscosity static real calcOmega2(real viscosity, real deltaT) { return REAL_CAST(1.0/(4.5*viscosity/deltaT+0.5)); @@ -86,9 +91,5 @@ namespace LBMSystem //some typedefs for global namespace typedef LBMSystem::real LBMReal; -//#define LBMSystem::real LBMReal - - - #endif diff --git a/src/cpu/VirtualFluidsCore/Parallel/Communicator.cpp b/src/cpu/VirtualFluidsCore/Parallel/Communicator.cpp index 72f8bc076..34146b347 100644 --- a/src/cpu/VirtualFluidsCore/Parallel/Communicator.cpp +++ b/src/cpu/VirtualFluidsCore/Parallel/Communicator.cpp @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Communicator.cpp +//! \ingroup Parallel +//! \author Konstantin Kutscher +//======================================================================================= + #include "Communicator.h" #include <basics/utilities/UbException.h> diff --git a/src/cpu/VirtualFluidsCore/Parallel/Communicator.h b/src/cpu/VirtualFluidsCore/Parallel/Communicator.h index d75ae2241..347b211f7 100644 --- a/src/cpu/VirtualFluidsCore/Parallel/Communicator.h +++ b/src/cpu/VirtualFluidsCore/Parallel/Communicator.h @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Communicator.h +//! \ingroup Parallel +//! \author Konstantin Kutscher +//======================================================================================= + #ifndef COMMUNICATOR_H #define COMMUNICATOR_H @@ -6,6 +39,7 @@ #include <PointerDefinitions.h> +//! \brief An abstract class for communication between processes in parallel computation class Communicator { public: diff --git a/src/cpu/VirtualFluidsCore/Parallel/NullCommunicator.cpp b/src/cpu/VirtualFluidsCore/Parallel/NullCommunicator.cpp index 527dc8753..e21bddc45 100644 --- a/src/cpu/VirtualFluidsCore/Parallel/NullCommunicator.cpp +++ b/src/cpu/VirtualFluidsCore/Parallel/NullCommunicator.cpp @@ -1,5 +1,39 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file NullCommunicator.cpp +//! \ingroup Parallel +//! \author Konstantin Kutscher +//======================================================================================= + #include "NullCommunicator.h" + NullCommunicator::NullCommunicator() { } diff --git a/src/cpu/VirtualFluidsCore/Parallel/NullCommunicator.h b/src/cpu/VirtualFluidsCore/Parallel/NullCommunicator.h index ada19144d..bea39e603 100644 --- a/src/cpu/VirtualFluidsCore/Parallel/NullCommunicator.h +++ b/src/cpu/VirtualFluidsCore/Parallel/NullCommunicator.h @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file NullCommunicator.h +//! \ingroup Parallel +//! \author Konstantin Kutscher +//======================================================================================= + #ifndef NullCommunicator_H #define NullCommunicator_H @@ -5,6 +38,8 @@ #include <PointerDefinitions.h> +//! \brief A class implements Communicator for shared memory. +//! \details NullCommunicator is only a place-holder. It is only one process in shared memory. class NullCommunicator : public Communicator { public: diff --git a/src/cpu/VirtualFluidsCore/Utilities/MemoryUtil.h b/src/cpu/VirtualFluidsCore/Utilities/MemoryUtil.h index b1dd85885..1102acac0 100644 --- a/src/cpu/VirtualFluidsCore/Utilities/MemoryUtil.h +++ b/src/cpu/VirtualFluidsCore/Utilities/MemoryUtil.h @@ -1,3 +1,36 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// This file is part of VirtualFluids. VirtualFluids is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file MemoryUtil.h +//! \ingroup Utilities +//! \author Konstantin Kutscher +//======================================================================================= + #ifndef _MEMORYUTIL_H_ #define _MEMORYUTIL_H_ @@ -13,7 +46,7 @@ #include "stdlib.h" #include "stdio.h" #include "string.h" -#elif (defined(__amd64) || defined(__amd64__) || defined(__unix__) || defined(__CYGWIN__)) && !defined(__AIX__) +#elif (defined(__amd64) || defined(__amd64__) || defined(__unix__) || defined(__CYGWIN__)) && !defined(__AIX__) #define MEMORYUTIL_LINUX #include "sys/types.h" #include "sys/sysinfo.h" @@ -23,6 +56,10 @@ #else #error "MemoryUtil::UnknownMachine" #endif + +#if defined(__CYGWIN__) + #define MEMORYUTIL_CYGWIN +#endif ////////////////////////////////////////////////////////////////////////// //MemoryUtil ////////////////////////////////////////////////////////////////////////// @@ -31,7 +68,7 @@ namespace Utilities ////////////////////////////////////////////////////////////////////////// static long long getTotalPhysMem() { - #if defined MEMORYUTIL_WINDOWS + #if defined(MEMORYUTIL_WINDOWS) MEMORYSTATUSEX memInfo; memInfo.dwLength = sizeof(MEMORYSTATUSEX); GlobalMemoryStatusEx(&memInfo); @@ -50,7 +87,7 @@ namespace Utilities if(sysctl(mib, 2, &totalPhysMem, &length, nullptr, 0) == -1) return 0; #else - #error "MemoryUtil::getTotalPhysMem - UnknownMachine" + #error "MemoryUtil::getTotalPhysMem - UnknownMachine" #endif return (long long)totalPhysMem; @@ -58,7 +95,7 @@ namespace Utilities ////////////////////////////////////////////////////////////////////////// static long long getPhysMemUsed() { - #if defined MEMORYUTIL_WINDOWS + #if defined(MEMORYUTIL_WINDOWS) MEMORYSTATUSEX memInfo; memInfo.dwLength = sizeof(MEMORYSTATUSEX); GlobalMemoryStatusEx(&memInfo); @@ -69,16 +106,16 @@ namespace Utilities long long physMemUsed = memInfo.totalram - memInfo.freeram; //Multiply in next statement to avoid int overflow on right hand side... physMemUsed *= memInfo.mem_unit; - #elif defined(MEMORYUTIL_APPLE) + #elif defined(MEMORYUTIL_APPLE) long long physMemUsed = 0; #else - #error "MemoryUtil::getPhysMemUsed - UnknownMachine" + #error "MemoryUtil::getPhysMemUsed - UnknownMachine" #endif return (long long)physMemUsed; } ////////////////////////////////////////////////////////////////////////// -#if defined(MEMORYUTIL_LINUX) || defined(MEMORYUTIL_APPLE) +#if defined(MEMORYUTIL_LINUX) || defined(MEMORYUTIL_APPLE) || defined(MEMORYUTIL_CYGWIN) static int parseLine(char* line){ int i = strlen(line); while (*line < '0' || *line > '9') line++; @@ -106,11 +143,11 @@ namespace Utilities ////////////////////////////////////////////////////////////////////////// static long long getPhysMemUsedByMe() { - #if defined MEMORYUTIL_WINDOWS + #if defined(MEMORYUTIL_WINDOWS) && !defined(__CYGWIN__) PROCESS_MEMORY_COUNTERS pmc; GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc)); SIZE_T physMemUsedByMe = pmc.WorkingSetSize; - #elif defined(MEMORYUTIL_LINUX) || defined(MEMORYUTIL_APPLE) + #elif defined(MEMORYUTIL_LINUX) || defined(MEMORYUTIL_APPLE) || defined(MEMORYUTIL_CYGWIN) long long physMemUsedByMe = (long long)getValue() * (long long)1024; #else #error "MemoryUtil::getPhysMemUsedByMe - UnknownMachine" -- GitLab