void VelocityBufferReadStencil::applyBackWall (FlowField & flowField, int i, int j, int k){ const int index = 3 * (i + (flowField.getNx()+3) * j); flowField.getVelocity().getVector(i, j, flowField.getNz()+2)[0] = _backBufferIn[ index ]; flowField.getVelocity().getVector(i, j, flowField.getNz()+2)[1] = _backBufferIn[index+1]; flowField.getVelocity().getVector(i, j, flowField.getNz()+2)[2] = _backBufferIn[index+2]; }
void VelocityBufferFillStencil::applyFrontWall (FlowField & flowField, int i, int j, int k){ const int index = 3 * (i + (flowField.getNx()+3) * j); _frontBufferOut[ index ] = flowField.getVelocity().getVector(i, j, 2)[0]; _frontBufferOut[index+1] = flowField.getVelocity().getVector(i, j, 2)[1]; _frontBufferOut[index+2] = flowField.getVelocity().getVector(i, j, 2)[2]; }
void VelocityBufferReadStencil::applyLeftWall (FlowField & flowField, int i, int j){ flowField.getVelocity().getVector(0, j)[0] = _leftBufferIn[ 2*j ]; flowField.getVelocity().getVector(1, j)[1] = _leftBufferIn[2*j+1]; }
void PressureBufferReadStencil::applyBackWall (FlowField & flowField, int i, int j, int k){ const int index = i + (flowField.getNx()+3) * j; flowField.getPressure().getScalar(i, j, flowField.getNz()+2) = _backBufferIn[index]; }
void VelocityBufferFillStencil::applyRightWall (FlowField & flowField, int i, int j, int k){ const int index = 3 * (j + (flowField.getNy()+3) * k); _rightBufferOut[ index ] = flowField.getVelocity().getVector(flowField.getNx(), j, k)[0]; _rightBufferOut[index+1] = flowField.getVelocity().getVector(flowField.getNx()+1, j, k)[1]; _rightBufferOut[index+2] = flowField.getVelocity().getVector(flowField.getNx()+1, j, k)[2]; }
void PressureBufferReadStencil::applyBottomWall (FlowField & flowField, int i, int j, int k){ const int index = i + (flowField.getNx()+3) * k; flowField.getPressure().getScalar(i, 1, k) = _bottomBufferIn[index]; }
void PressureBufferReadStencil::applyTopWall (FlowField & flowField, int i, int j, int k){ const int index = i + (flowField.getNx()+3) * k; flowField.getPressure().getScalar(i, flowField.getNy()+2, k) = _topBufferIn[index]; }
void PressureBufferFillStencil::applyRightWall (FlowField & flowField, int i, int j, int k){ const int index = j + (flowField.getNy()+3) * k; _rightBufferOut[index] = flowField.getPressure().getScalar(flowField.getNx()+1, j, k); }
void PressureBufferFillStencil::applyBottomWall (FlowField & flowField, int i, int j, int k){ const int index = i + (flowField.getNx()+3) * k; _bottomBufferOut[index] = flowField.getPressure().getScalar(i, 2, k); }
void PressureBufferFillStencil::applyBottomWall (FlowField & flowField, int i, int j){ _bottomBufferOut[i] = flowField.getPressure().getScalar(i, 2); }
void PressureBufferFillStencil::applyTopWall (FlowField & flowField, int i, int j){ _topBufferOut[i] = flowField.getPressure().getScalar(i, flowField.getNy()+1); }
void PressureBufferFillStencil::applyRightWall (FlowField & flowField, int i, int j){ _rightBufferOut[j] = flowField.getPressure().getScalar(flowField.getNx()+1, j); }
void VelocityBufferFillStencil::applyLeftWall (FlowField & flowField, int i, int j){ _leftBufferOut[ 2*j ] = flowField.getVelocity().getVector(2, j)[0]; _leftBufferOut[2*j+1] = flowField.getVelocity().getVector(2, j)[1]; }
void PressureBufferFillStencil::applyLeftWall (FlowField & flowField, int i, int j){ _leftBufferOut[j] = flowField.getPressure().getScalar(2, j); }
void PressureBufferReadStencil::applyTopWall (FlowField & flowField, int i, int j){ flowField.getPressure().getScalar(i, flowField.getNy()+2) = _topBufferIn[i]; }
void PressureBufferFillStencil::applyTopWall (FlowField & flowField, int i, int j, int k){ const int index = i + (flowField.getNx()+3) * k; _topBufferOut[index] = flowField.getPressure().getScalar(i, flowField.getNy()+1, k); }
void PressureBufferReadStencil::applyRightWall (FlowField & flowField, int i, int j, int k){ const int index = j + (flowField.getNy()+3) * k; flowField.getPressure().getScalar(flowField.getNx()+2, j, k) = _rightBufferIn[index]; }
void PressureBufferFillStencil::applyFrontWall (FlowField & flowField, int i, int j, int k){ const int index = i + (flowField.getNx()+3) * j; _frontBufferOut[index] = flowField.getPressure().getScalar(i, j, 2); }
void VelocityBufferFillStencil::applyBottomWall (FlowField & flowField, int i, int j){ _bottomBufferOut[ 2*i ] = flowField.getVelocity().getVector(i, 2)[0]; _bottomBufferOut[2*i+1] = flowField.getVelocity().getVector(i, 2)[1]; }
void PressureBufferFillStencil::applyBackWall (FlowField & flowField, int i, int j, int k){ const int index = i + (flowField.getNx()+3) * j; _backBufferOut[index] = flowField.getPressure().getScalar(i, j, flowField.getNz()+1); }
void PressureBufferReadStencil::applyFrontWall (FlowField & flowField, int i, int j, int k){ const int index = i + (flowField.getNx()+3) * j; flowField.getPressure().getScalar(i, j, 1) = _frontBufferIn[index]; }
void VelocityBufferFillStencil::applyRightWall (FlowField & flowField, int i, int j){ _rightBufferOut[ 2*j ] = flowField.getVelocity().getVector(flowField.getNx() , j)[0]; _rightBufferOut[2*j+1] = flowField.getVelocity().getVector(flowField.getNx()+1, j)[1]; }
void VelocityBufferFillStencil::applyTopWall (FlowField & flowField, int i, int j){ _topBufferOut[ 2*i ] = flowField.getVelocity().getVector(i, flowField.getNy()+1)[0]; _topBufferOut[2*i+1] = flowField.getVelocity().getVector(i, flowField.getNy() )[1]; }
void PressureBufferReadStencil::applyLeftWall (FlowField & flowField, int i, int j){ flowField.getPressure().getScalar(1, j) = _leftBufferIn[j]; }
void VelocityBufferFillStencil::applyTopWall (FlowField & flowField, int i, int j, int k){ const int index = 3 * (i + (flowField.getNx()+3) * k); _topBufferOut[ index ] = flowField.getVelocity().getVector(i, flowField.getNy()+1, k)[0]; _topBufferOut[index+1] = flowField.getVelocity().getVector(i, flowField.getNy() , k)[1]; _topBufferOut[index+2] = flowField.getVelocity().getVector(i, flowField.getNy()+1, k)[2]; }
void PressureBufferReadStencil::applyRightWall (FlowField & flowField, int i, int j){ flowField.getPressure().getScalar(flowField.getNx()+2, j) = _rightBufferIn[j]; }
void VelocityBufferFillStencil::applyBackWall (FlowField & flowField, int i, int j, int k){ const int index = 3 * (i + (flowField.getNx()+3) * j); _backBufferOut[ index ] = flowField.getVelocity().getVector(i, j, flowField.getNz()+1)[0]; _backBufferOut[index+1] = flowField.getVelocity().getVector(i, j, flowField.getNz()+1)[1]; _backBufferOut[index+2] = flowField.getVelocity().getVector(i, j, flowField.getNz() )[2]; }
void PressureBufferReadStencil::applyBottomWall (FlowField & flowField, int i, int j){ flowField.getPressure().getScalar(i, 1) = _bottomBufferIn[i]; }
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; } } }
void VelocityBufferReadStencil::applyFrontWall (FlowField & flowField, int i, int j, int k){ const int index = 3 * (i + (flowField.getNx()+3) * j); flowField.getVelocity().getVector(i, j, 1)[0] = _frontBufferIn[ index ]; flowField.getVelocity().getVector(i, j, 1)[1] = _frontBufferIn[index+1]; flowField.getVelocity().getVector(i, j, 0)[2] = _frontBufferIn[index+2]; }