Palabos源码:ForcedD3Q19Descriptor

latticeTemplates3D.h

在src/latticeBoltzmann/latticeTemplates3D.h

这部分来源于latticeTemplates3D.h文件,可以预见主要是在lattice上的操作

template<typename T>
struct latticeTemplates<T, descriptors::ForcedD3Q19Descriptor> {

static void swapAndStreamCell (
      Cell<T,descriptors::ForcedD3Q19Descriptor> ***grid,
      plint iX, plint iY, plint iZ, plint nX, plint nY, plint nZ, plint iPop, T& fTmp )
{
    fTmp                     = grid[iX][iY][iZ][iPop];
    grid[iX][iY][iZ][iPop]   = grid[iX][iY][iZ][iPop+9];
    grid[iX][iY][iZ][iPop+9] = grid[nX][nY][nZ][iPop];
    grid[nX][nY][nZ][iPop]   = fTmp;
}

static void swapAndStream3D(Cell<T,descriptors::ForcedD3Q19Descriptor> ***grid,
                            plint iX, plint iY, plint iZ)
{
    T fTmp;
    swapAndStreamCell(grid, iX, iY, iZ, iX-1, iY,   iZ,   1, fTmp);
    swapAndStreamCell(grid, iX, iY, iZ, iX,   iY-1, iZ,   2, fTmp);
    swapAndStreamCell(grid, iX, iY, iZ, iX,   iY  , iZ-1, 3, fTmp);
    swapAndStreamCell(grid, iX, iY, iZ, iX-1, iY-1, iZ,   4, fTmp);
    swapAndStreamCell(grid, iX, iY, iZ, iX-1, iY+1, iZ,   5, fTmp);
    swapAndStreamCell(grid, iX, iY, iZ, iX-1, iY  , iZ-1, 6, fTmp);
    swapAndStreamCell(grid, iX, iY, iZ, iX-1, iY  , iZ+1, 7, fTmp);
    swapAndStreamCell(grid, iX, iY, iZ, iX  , iY-1, iZ-1, 8, fTmp);
    swapAndStreamCell(grid, iX, iY, iZ, iX  , iY-1, iZ+1, 9, fTmp);
}

};
externalForceTemplates3D.h(主体部分)

在src/latticeBoltzmann/externalForceTemplates3D.h
则涉及到了分布函数的算法。
其中力是如下方法处理的,可见是由externalScalars与forceBeginsAt相加而成。

static const int forceBeginsAt
    = descriptors::ForcedD3Q19Descriptor<T>::ExternalField::forceBeginsAt;
T* force = externalScalars + forceBeginsAt;
T& fx = force[0];
T& fy = force[1];
T& fz = force[2];

在这里插入图片描述

nearestNeighborLattices3D.hh

在该文件夹的nearestNeighborLattices3D.hh可以找到参数定义的信息

// D3Q19 ///
// 代码部分
    template<typename T>
    const T D3Q19Constants<T>::invD = (T)1 / (T) d;

    template<typename T>
    const int D3Q19Constants<T>::vicinity = 1;

    template<typename T>
    const int D3Q19Constants<T>::c
        [D3Q19Constants<T>::q][D3Q19Constants<T>::d] =
        {
            { 0, 0, 0},

            {-1, 0, 0}, { 0,-1, 0}, { 0, 0,-1},
            {-1,-1, 0}, {-1, 1, 0}, {-1, 0,-1},
            {-1, 0, 1}, { 0,-1,-1}, { 0,-1, 1},

            { 1, 0, 0}, { 0, 1, 0}, { 0, 0, 1},
            { 1, 1, 0}, { 1,-1, 0}, { 1, 0, 1},
            { 1, 0,-1}, { 0, 1, 1}, { 0, 1,-1}
        }; 
nearestNeighborLattices3D.h
/// D3Q19 lattice
template <typename T> struct D3Q19Constants
{
    enum { d = 3, q = 19 };       ///< number of dimensions/distr. functions
    static const T invD;          ///< 1 / (number of dimensions)
    static const int vicinity;    ///< size of neighborhood
    static const int c[q][d];     ///< lattice directions
    static const int cNormSqr[q]; ///< norm-square of the vector c
    static const T t[q];          ///< lattice weights
    static const T cs2;           ///< lattice constant cs2 (in BGK, this is the square-speed-of-sound)
    static const T invCs2;        ///< 1 / cs2
};

template <typename T> struct D3Q19DescriptorBase
    : public D3Q19Constants<T>, public DefaultRoundOffPolicy<T>
{
    typedef D3Q19DescriptorBase<T> BaseDescriptor;
    enum { numPop=D3Q19Constants<T>::q };
};
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值