void VelocityStencil::apply ( FlowField & flowField, int i, int j ){

    const FLOAT dt = _parameters.timestep.dt;
    const int obstacle = flowField.getFlags().getValue(i, j);
    VectorField & velocity = flowField.getVelocity();

    if ((obstacle & OBSTACLE_SELF) == 0){ // If this is a fluid cell
        if ((obstacle & OBSTACLE_RIGHT) == 0){  // Check whether the neighbor is also fluid
            // we require a spatial finite difference expression for the pressure gradient, evaluated
            // at the location of the u-component. We therefore compute the distance of neighbouring
            // pressure values (dx) and use this as sort-of central difference expression. This will
            // yield second-order accuracy for uniform meshsizes.
            const FLOAT dx = 0.5*(_parameters.meshsize->getDx(i,j)+_parameters.meshsize->getDx(i+1,j));
            velocity.getVector(i,j)[0] = flowField.getFGH().getVector(i,j)[0] - dt/dx *
                (flowField.getPressure().getScalar(i+1,j) - flowField.getPressure().getScalar(i,j));

        } else {    // Otherwise, set to zero
            velocity.getVector(i,j)[0] = 0;
        }   // Note that we only set one direction per cell. The neighbor at the left is
            // responsible for the other side
        if ((obstacle & OBSTACLE_TOP) == 0){
            const FLOAT dy = 0.5*(_parameters.meshsize->getDy(i,j)+_parameters.meshsize->getDy(i,j+1));
            velocity.getVector(i,j)[1] = flowField.getFGH().getVector(i,j)[1] - dt/dy *
                (flowField.getPressure().getScalar(i,j+1) - flowField.getPressure().getScalar(i,j));

        } else {
            velocity.getVector(i,j)[1] = 0;
        }
    } 
}
void VelocityStencil::apply ( FlowField & flowField, int i, int j, int k ){

    const FLOAT dt = _parameters.timestep.dt;
    const int obstacle = flowField.getFlags().getValue(i, j, k);
    VectorField & velocity = flowField.getVelocity();

    if ((obstacle & OBSTACLE_SELF) == 0) {
        if ((obstacle & OBSTACLE_RIGHT) == 0) {
            const FLOAT dx = 0.5*(_parameters.meshsize->getDx(i,j,k)+_parameters.meshsize->getDx(i+1,j,k));
            velocity.getVector(i,j,k)[0] = flowField.getFGH().getVector(i,j,k)[0] - dt/dx *
                (flowField.getPressure().getScalar(i+1,j,k) - flowField.getPressure().getScalar(i,j,k));
        } else {
            velocity.getVector(i, j, k)[0] = 0.0;
        }
        if ((obstacle & OBSTACLE_TOP) == 0) {
            const FLOAT dy = 0.5*(_parameters.meshsize->getDy(i,j,k)+_parameters.meshsize->getDy(i,j+1,k));
            velocity.getVector(i,j,k)[1] = flowField.getFGH().getVector(i,j,k)[1] - dt/dy *
                (flowField.getPressure().getScalar(i,j+1,k) - flowField.getPressure().getScalar(i,j,k));
        } else {
            velocity.getVector(i, j, k)[1] = 0.0;
        }
        if ((obstacle & OBSTACLE_BACK) == 0) {
            const FLOAT dz = 0.5*(_parameters.meshsize->getDz(i,j,k)+_parameters.meshsize->getDz(i,j,k+1));
            velocity.getVector(i,j,k)[2] = flowField.getFGH().getVector(i,j,k)[2] - dt/dz *
                (flowField.getPressure().getScalar(i,j,k+1) - flowField.getPressure().getScalar(i,j,k));
        } else {
            velocity.getVector(i, j, k)[2] = 0.0;
        }
    }
}
Exemple #3
0
void RHSStencil::apply(FlowField& flowField, int i, int j) {
  flowField.getRHS().getScalar(i, j) =
      1.0 / _parameters.timestep.dt *
      ((flowField.getFGH().getVector(i, j)[0] -
        flowField.getFGH().getVector(i - 1, j)[0]) /
           _parameters.meshsize->getDx(i, j) +
       (flowField.getFGH().getVector(i, j)[1] -
        flowField.getFGH().getVector(i, j - 1)[1]) /
           _parameters.meshsize->getDy(i, j));
}
void MovingWallFGHStencil::applyRightWall ( FlowField & flowField, int i, int j , int k ){

    flowField.getFGH().getVector(i-1, j, k)[0] = _parameters.walls.vectorRight[0];
/*    if ( (i == 22) && ( j == 10 ) && ( k == 10 )){
    	std::cout<<"atleast here FGh "<<    flowField.getVelocity().getVector(i-1, j, k)[0]<<std::endl;
    }*/
}
Exemple #5
0
void MovingWallFGHStencil::applyBackWall ( FlowField & flowField, int i, int j, int k ){
    flowField.getFGH().getVector(i, j, k-1)[2] = _parameters.walls.vectorBack[2];
}
Exemple #6
0
void MovingWallFGHStencil::applyFrontWall ( FlowField & flowField, int i, int j, int k ){
    flowField.getFGH().getVector(i, j, k)[2] = _parameters.walls.vectorFront[2];
}
Exemple #7
0
void MovingWallFGHStencil::applyTopWall ( FlowField & flowField, int i, int j, int k ){
    flowField.getFGH().getVector(i, j-1, k)[1] = _parameters.walls.vectorTop[1];
}
Exemple #8
0
void MovingWallFGHStencil::applyBottomWall ( FlowField & flowField, int i, int j, int k ){
    flowField.getFGH().getVector(i, j, k)[1] = _parameters.walls.vectorBottom[1];
}
Exemple #9
0
void MovingWallFGHStencil::applyRightWall ( FlowField & flowField, int i, int j , int k ){
    flowField.getFGH().getVector(i-1, j, k)[0] = _parameters.walls.vectorRight[0];
}
Exemple #10
0
void MovingWallFGHStencil::applyLeftWall ( FlowField & flowField, int i, int j ){
    flowField.getFGH().getVector(i, j)[0] = _parameters.walls.vectorLeft[0];
}
void BFInputFGHStencil::applyLeftWall  ( FlowField & flowField, int i, int j, int k ){
    flowField.getFGH().getVector(i,j,k)[0] =
        computeVelocity3D (flowField, i, j, k, _stepSize, _parameters);
}