| 1 |
/* |
| 2 |
* Advanced Simulation Library <http://asl.org.il> |
| 3 |
* |
| 4 |
* Copyright 2015 Avtech Scientific <http://avtechscientific.com> |
| 5 |
* |
| 6 |
* |
| 7 |
* This file is part of Advanced Simulation Library (ASL). |
| 8 |
* |
| 9 |
* ASL is free software: you can redistribute it and/or modify it |
| 10 |
* under the terms of the GNU Affero General Public License as |
| 11 |
* published by the Free Software Foundation, version 3 of the License. |
| 12 |
* |
| 13 |
* ASL is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU Affero General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU Affero General Public License |
| 19 |
* along with ASL. If not, see <http://www.gnu.org/licenses/>. |
| 20 |
* |
| 21 |
*/ |
| 22 |
|
| 23 |
|
| 24 |
#ifndef ASLLBGK_H |
| 25 |
#define ASLLBGK_H |
| 26 |
|
| 27 |
#include "aslSingleKernelNM.h" |
| 28 |
#include <acl/aclHardware.h> |
| 29 |
#include <math/aslVectors.h> |
| 30 |
#include "acl/aclMath/aclVectorOfElementsDef.h" |
| 31 |
#include "acl/aclMath/aclMatrixOfElements.h" |
| 32 |
|
| 33 |
namespace asl |
| 34 |
{ |
| 35 |
class Block; |
| 36 |
class VectorTemplate; |
| 37 |
template <typename V> class DataWithGhostNodes; |
| 38 |
typedef DataWithGhostNodes<acl::VectorOfElements> DataWithGhostNodesACL; |
| 39 |
typedef DataWithGhostNodes<acl::VectorOfElementsData> DataWithGhostNodesACLData; |
| 40 |
typedef std::shared_ptr<DataWithGhostNodesACL> SPDataWithGhostNodesACL; |
| 41 |
typedef std::shared_ptr<DataWithGhostNodesACLData> SPDataWithGhostNodesACLData; |
| 42 |
class AbstractDataWithGhostNodes; |
| 43 |
typedef std::shared_ptr<AbstractDataWithGhostNodes> SPAbstractDataWithGhostNodes; |
| 44 |
|
| 45 |
|
| 46 |
/// returns VectorOfElements with values of rho |
| 47 |
/** |
| 48 |
\relates LBGK |
| 49 |
|
| 50 |
\f[ \rho=\sum_i w_i f_i\f] |
| 51 |
where \f$ w_i \f$ is defined by \p vt |
| 52 |
*/ |
| 53 |
acl::VectorOfElements computeRho(acl::VectorOfElements f, const VectorTemplate* vt); |
| 54 |
|
| 55 |
/// returns VectorOfElements with values of velocity |
| 56 |
/** |
| 57 |
\relates LBGK |
| 58 |
|
| 59 |
\f[ \vec m= \sum_i w_i\vec a_i f_i \f] |
| 60 |
where \f$ w_i \f$ is defined by \p vt |
| 61 |
*/ |
| 62 |
acl::VectorOfElements computeMomentum(acl::VectorOfElements f, const VectorTemplate* vt); |
| 63 |
|
| 64 |
/// generates Vector Of Elements with inverce components according to \p vt |
| 65 |
acl::VectorOfElements generateInverceVector(acl::VectorOfElements f, const VectorTemplate* vt); |
| 66 |
|
| 67 |
acl::MatrixOfElements generateLBGKMatrix(acl::VectorOfElements nu); |
| 68 |
acl::MatrixOfElements generateMRTMatrix(acl::VectorOfElements nu); |
| 69 |
|
| 70 |
acl::MatrixOfElements generateDifKinMatrix(acl::VectorOfElements nu); |
| 71 |
|
| 72 |
/// Numerical method for fluid flow |
| 73 |
/** |
| 74 |
\ingroup TransportProcesses |
| 75 |
\ingroup NumMethods |
| 76 |
*/ |
| 77 |
class LBGK: public SingleKernelNM |
| 78 |
{ |
| 79 |
public: |
| 80 |
typedef SPDataWithGhostNodesACL Data; |
| 81 |
typedef SPDataWithGhostNodesACLData DataD; |
| 82 |
typedef acl::VectorOfElements Param; |
| 83 |
|
| 84 |
const VectorTemplate* vectorTemplate; |
| 85 |
protected: |
| 86 |
acl::VectorOfElementsData fPool; |
| 87 |
Data f; |
| 88 |
DataD v; |
| 89 |
DataD rho; |
| 90 |
|
| 91 |
std::shared_ptr<AVec<int>> fShifts; |
| 92 |
std::shared_ptr<AVec<int>> fShiftsIncrement; |
| 93 |
|
| 94 |
std::vector<acl::SPKernel> copyKernels; |
| 95 |
|
| 96 |
Param viscosity; |
| 97 |
Param deltat; |
| 98 |
Param force; |
| 99 |
Param omega; |
| 100 |
|
| 101 |
bool flagComputeVelocity; |
| 102 |
bool flagComputeRho; |
| 103 |
bool flagCompressible; |
| 104 |
|
| 105 |
void createData(Block b, acl::CommandQueue queue, acl::TypeID type); |
| 106 |
void createCopyKernels(); |
| 107 |
/// contains classical moving procedure |
| 108 |
virtual void preProcessing(); |
| 109 |
virtual void init0(); |
| 110 |
|
| 111 |
public: |
| 112 |
LBGK(); |
| 113 |
LBGK(DataD v, Param nu, const VectorTemplate* vT); |
| 114 |
LBGK(Block b, Param nu, const VectorTemplate* vT, |
| 115 |
bool compVel=true, bool compRho=true, |
| 116 |
acl::CommandQueue queue = acl::hardware.defaultQueue); |
| 117 |
void setViscosity(Param nu); |
| 118 |
double getViscosity(unsigned int i = 0); |
| 119 |
/// sets angular velocity for Coriolis term in noninertial reference frame |
| 120 |
void setOmega(Param w); |
| 121 |
void setVectorTemplate(const VectorTemplate* vT); |
| 122 |
inline const VectorTemplate* getVectorTemplate() const; |
| 123 |
|
| 124 |
|
| 125 |
inline Data getF(); |
| 126 |
inline DataD getRho(); |
| 127 |
inline DataD getVelocity(); |
| 128 |
|
| 129 |
inline void setCompressible(bool flag = true); |
| 130 |
inline const bool & getCompressible() const; |
| 131 |
}; |
| 132 |
|
| 133 |
typedef std::shared_ptr<LBGK> SPLBGK; |
| 134 |
|
| 135 |
|
| 136 |
///contains different kernels for preprocessing and posprocessing of data used by LBGK |
| 137 |
class LBGKUtilities |
| 138 |
{ |
| 139 |
private: |
| 140 |
typedef acl::VectorOfElements Param; |
| 141 |
|
| 142 |
SPLBGK num; |
| 143 |
acl::SPKernel kernelComputeV; |
| 144 |
acl::SPKernel kernelComputeRho; |
| 145 |
acl::SPKernel kernelComputeRhoV; |
| 146 |
acl::SPKernel kernelInitF; |
| 147 |
|
| 148 |
Param velocity; |
| 149 |
Param rho; |
| 150 |
|
| 151 |
public: |
| 152 |
LBGKUtilities(SPLBGK lbgk); |
| 153 |
void computeRho(); |
| 154 |
void computeVelocity(); |
| 155 |
void computeRhoVelocity(); |
| 156 |
void initF(Param rho, Param vel); |
| 157 |
/// dencity is suposed to be 1 |
| 158 |
void initF(Param vel); |
| 159 |
}; |
| 160 |
|
| 161 |
typedef std::shared_ptr<LBGKUtilities> SPLBGKUtilities; |
| 162 |
|
| 163 |
class LBGKTurbulence: public LBGK |
| 164 |
{ |
| 165 |
public: |
| 166 |
LBGKTurbulence(DataD v, Param nu, const VectorTemplate* vT); |
| 167 |
LBGKTurbulence(Block b, Param nu, const VectorTemplate* vT, |
| 168 |
bool compVel=true, bool compRho=true, |
| 169 |
acl::CommandQueue queue = acl::hardware.defaultQueue); |
| 170 |
virtual void init0(); |
| 171 |
}; |
| 172 |
|
| 173 |
typedef std::shared_ptr<LBGKTurbulence> SPLBGKTurbulence; |
| 174 |
|
| 175 |
// ------------------------- Implementation ------------------------ |
| 176 |
|
| 177 |
|
| 178 |
inline LBGK::Data LBGK::getF() |
| 179 |
{ |
| 180 |
return f; |
| 181 |
} |
| 182 |
|
| 183 |
inline LBGK::DataD LBGK::getRho() |
| 184 |
{ |
| 185 |
return rho; |
| 186 |
} |
| 187 |
|
| 188 |
inline LBGK::DataD LBGK::getVelocity() |
| 189 |
{ |
| 190 |
return v; |
| 191 |
} |
| 192 |
|
| 193 |
inline const VectorTemplate* LBGK::getVectorTemplate() const |
| 194 |
{ |
| 195 |
return vectorTemplate; |
| 196 |
} |
| 197 |
|
| 198 |
inline void LBGK::setCompressible(bool flag) |
| 199 |
{ |
| 200 |
flagCompressible=flag; |
| 201 |
} |
| 202 |
|
| 203 |
inline const bool & LBGK::getCompressible() const |
| 204 |
{ |
| 205 |
return flagCompressible; |
| 206 |
} |
| 207 |
|
| 208 |
} // asl |
| 209 |
#endif // ASLLBGK_H |