# [转载]LBM：PalaBos 几何与边界的处理

1. 所使用的类：OnLatticeBoundaryConditionXD （XD，中的X选取为2或3，针对于2维或3维）。

OnLatticeBoundaryCondition3D<T,DESCRIPTOR>* boundaryCondition =
createZouHeBoundaryCondition3D<T,DESCRIPTOR>();

Regularized BC     createLocalBoundaryConditionXD

Skordos BC     createInterpBoundaryConditionXD

Zou/He BC     createZouHeBoundaryConditionXD

Inamuro BC     createInamuroBoundaryConditionXD

2. 简单的边界设置方法给出如下：
Box2D boundaryBox(x0,x1, y0,y1);
boundaryCondition->setVelocityConditionOnBlockBoundaries (
lattice, boundaryBox, locationOfBoundaryNodes );

boundaryCondition->setVelocityConditionOnBlockBoundaries(lattice, locationOfBoundaryNodes);

boundaryCondition->setVelocityConditionOnBlockBoundaries(lattice);

Box2D inlet(0, 0, 2, ny-2);
Box2D outlet(nx-1, nx-1, 2, ny-2);
Box2D bottomWall(0, nx-1, 0, 0);
Box2D topWall(0, nx-1, ny-1, ny-1);

boundaryCondition->setVelocityConditionOnBlockBoundaries ( lattice, inlet );
boundaryCondition->setVelocityConditionOnBlockBoundaries (
lattice, outlet, boundary::outflow );
boundaryCondition->setVelocityConditionOnBlockBoundaries (
lattice, bottomWall, boundary::freeslip );
boundaryCondition->setVelocityConditionOnBlockBoundaries (
lattice, topWall, boundary::freeslip );

boundary::outflow指0速度梯度边界条件；boundary::freeslip滑移边界条件。在上面的定义中，所有的边界点都落在外部的矩形上，所以不需要特殊的处理。

boundary::dirichlet (default value)     Dirichlet边界条件
boundary::outflow 或 boundary::neumann     指0速度梯度边界条件
boundary::freeslip                     速度在切向的投影为0
boundary::normalOutflow             法向0速度梯度边界条件

3. 压力边界条件安的选择
boundary::dirichlet (default value)     Dirichlet设定压力的取值，切向速度为0。
boundary::neumann                     0压力梯度，切向速度为0。

1. 最直接的定义是：
Box2D topWall(0, nx-1, ny-1, ny-1);
boundaryCondition->setVelocityConditionOnBlockBoundaries (
topWall, lattice, boundary::freeslip );

Box2D topLid(1, nx-2, ny-1, ny-1);
boundaryCondition->addExternalVelocityCornerNP( 0, ny-1, lattice, boundary::freeslip );
boundaryCondition->addExternalVelocityCornerPP( nx-1, ny-1, lattice, boundary::freeslip );

2. 对于3D平面采用使用如现的方法处理:

addVelocityBoundaryDO 这里 D可以是 0（x）, （1）y, （2）z；后面字符O可以取P和N表示沿着D的正向还是负向。 对于内部和外部边的定义，示例如下:

＊其解释于2D相同

1. 处理方式如下：

lattice.periodicity.toggle(0, true);      表示所有的量周期性沿着x
scalarField.periodicity.toggle(0, true);  表示标量沿着x周期

lattice.periodicity.toggleAll(true);

1. 在这类边界条件的处理中，边界点不再被看作是需要进行统计格点，仅仅就是算法层次，计算精度于网格尺度同阶。这种边界适合复杂几何体中流动的计算。下面给出一个示例：

template<typename T>
class CylinderShapeDomain2D : public DomainFunctional2D {
public:
CylinderShapeDomain2D(plint cx_, plint cy_, plint radius)
: cx(cx_),
cy(cy_),
{ }
virtual bool operator() (plint iX, plint iY) const {
return util::sqr(iX-cx) + util::sqr(iY-cy) <= radiusSqr;
}
virtual CylinderShapeDomain2D<T>* clone() const {
return new CylinderShapeDomain2D<T>(*this);
}
private:
plint cx, cy;
};

defineDynamics( lattice, lattice.getBoundingBox(),
new BounceBack<T,DESCRIPTOR> );

plb_ifstream ifile("geometry.dat");

2. 当然采用Bounce-back定义边界条件也不失为一种好方法：如下：

Box2D top(   0,    nx-1, ny-1, ny-1);
Box2D bottom(0,    nx-1, 0,    0);
Box2D left(  0,    0,    1,    ny-2);
Box2D right( nx-1, nx-1, 1,    ny-2);

defineDynamics(lattice, top, new BounceBack<T,DESCRIPTOR>());
defineDynamics(lattice, bottom, new BounceBack<T,DESCRIPTOR>());
defineDynamics(lattice, right, new BounceBack<T,DESCRIPTOR>());
defineDynamics(lattice, left, new BounceBack<T,DESCRIPTOR>());

http://blog.sciencenet.cn/blog-250582-513842.html

## 全部精选博文导读

GMT+8, 2019-10-22 01:51