コード例 #1
0
ファイル: VelocityStencil.cpp プロジェクト: muyan93/Euler-EOF
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;
        }
    } 
}
コード例 #2
0
void PressureBufferFillStencil::applyRightWall ( FlowField & flowField, int i, int j, int k) {
  /* _lowOffset = 2; _highOffset = -1;
   * from ParallelBoundaryIterater:  i = _flowField.getCellsX()+_highOffset-1 ; j = _lowOffset ; k = _lowOffset;
   */
  rightPressureFillBuffer[0+2*((k)+((localSize[2]+3)*(j)))] = flowField.getPressure().getScalar(i-2,j,k);
  rightPressureFillBuffer[1+2*((k)+((localSize[2]+3)*(j)))] = flowField.getPressure().getScalar(i-1,j,k);
}
コード例 #3
0
void PressureBufferFillStencil::applyTopWall ( FlowField & flowField, int i, int j, int k) {
  /* _lowOffset = 2; _highOffset = -1;
   * from ParallelBoundaryIterater:  i = _lowOffset ; j = Iterator<FlowField>::_flowField.getCellsY()+_highOffset-1 ; k = _lowOffset;
   */ 
  topPressureFillBuffer[0+2*((k)+((localSize[2]+3)*(i)))] = flowField.getPressure().getScalar(i,j-2,k);
  topPressureFillBuffer[1+2*((k)+((localSize[2]+3)*(i)))] = flowField.getPressure().getScalar(i,j-1,k);
}
コード例 #4
0
void PressureBufferFillStencil::applyBackWall ( FlowField & flowField, int i, int j, int k) {
  /* _lowOffset = 2; _highOffset = -1;
   * from ParallelBoundaryIterater:  i = _lowOffset ; j = _lowOffset ; k = Iterator<FlowField>::_flowField.getCellsZ()+_highOffset-1 ;
   */   
  backPressureFillBuffer[0+2*((j)+((localSize[1]+3)*(i)))] = flowField.getPressure().getScalar(i,j,k-2);
  backPressureFillBuffer[1+2*((j)+((localSize[1]+3)*(i)))] = flowField.getPressure().getScalar(i,j,k-1);
}
コード例 #5
0
ファイル: VelocityStencil.cpp プロジェクト: muyan93/Euler-EOF
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;
        }
    }
}
コード例 #6
0
ファイル: vtk_test.cpp プロジェクト: EvaBr/CFD-Lab
int main () {
    std::cout << "Starting VTK test" << std::endl;
    FlowField flowField ( 10, 10, 10 );

    clock_t start = clock();

    FLOAT velocity [3] = {1,1,1};

    for (int k = 0; k < flowField.getNz() + 3; k++ ){
        for (int j = 0; j < flowField.getNy() + 3; j++ ){
            for (int i = 0; i < flowField.getNx() + 3; i++ ){
                flowField.getPressure().getScalar(i,j,k) = (double) k;
                flowField.getVelocity().setVector(velocity, i,j,k);
            }
        }
    }

    std::cout << "Initialization time: " << (double) (clock() - start) / CLOCKS_PER_SEC
        << std::endl;
    start = clock();

    Parameters parameters;

    parameters.dx = 1;
    parameters.dy = 1;
    parameters.dz = 1;

    VTKStencil stencil( "/tmp/some_file", parameters );

    std::cout << "Stencil creation time: " << (double) (clock() - start) / CLOCKS_PER_SEC << std::endl;
    start = clock();

    stencil.openFile ( flowField, 5.0/3 );

    std::cout << "File-openning and grid data writing time: " << (double) (clock() - start) / CLOCKS_PER_SEC << std::endl;
    start = clock();

    FieldIterator iterator( flowField, stencil );
    iterator.iterateInnerCells();

    std::cout << "Iteration time: " << (double) (clock() - start) / CLOCKS_PER_SEC << std::endl;
    start = clock();

    stencil.write( flowField );
    std::cout << "Writing time: " << (double) (clock() - start) / CLOCKS_PER_SEC << std::endl;

    stencil.closeFile();

}
コード例 #7
0
ファイル: CheckpointReadStencil.cpp プロジェクト: tonyqd/HPC
void CheckpointReadStencil::apply ( FlowField & flowField, int i, int j ){


	FLOAT pressure_tmp;
	FLOAT velocity_tmp[3];

	FLOAT & pressure = flowField.getPressure().getScalar(i,j);
	FLOAT * velocity = flowField.getVelocity().getVector(i,j);

	fread(velocity_tmp, sizeof(FLOAT), 3, inputFile);
	fread(&pressure_tmp, sizeof(FLOAT), 1, inputFile);

	pressure = pressure_tmp;
	velocity[0] = velocity_tmp[0];
	velocity[1] = velocity_tmp[1];
	velocity[2] = velocity_tmp[2];

}
コード例 #8
0
ファイル: BufferStencils.cpp プロジェクト: EvaBr/CFD-Lab
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);
}
コード例 #9
0
void PressureBufferFillStencil::applyBottomWall ( FlowField & flowField, int i, int j, int k) {
  /* _lowOffset = 2; _highOffset = -1;
   * from ParallelBoundaryIterater:  i = _lowOffset ; j = _lowOffset ; k = _lowOffset;
   */
  bottomPressureFillBuffer[(k)+((localSize[2]+3)*(i))] = flowField.getPressure().getScalar(i,j+2,k);
}
コード例 #10
0
ファイル: BufferStencils.cpp プロジェクト: EvaBr/CFD-Lab
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);
}
コード例 #11
0
void PressureBufferFillStencil::applyLeftWall ( FlowField & flowField, int i, int j, int k) {
  /* _lowOffset = 0; _highOffset = 0;
   * from ParallelBoundaryIterater:  i = _lowOffset ; j = _lowOffset ; k = _lowOffset; 
   */
	leftPressureFillBuffer[(k)+((localSize[2]+3)*(j))] = flowField.getPressure().getScalar(i+2,j,k);
}
コード例 #12
0
ファイル: BufferStencils.cpp プロジェクト: EvaBr/CFD-Lab
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);
}
コード例 #13
0
ファイル: BufferStencils.cpp プロジェクト: EvaBr/CFD-Lab
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);
}
コード例 #14
0
ファイル: BufferStencils.cpp プロジェクト: EvaBr/CFD-Lab
void PressureBufferReadStencil::applyLeftWall   (FlowField & flowField, int i, int j){
    flowField.getPressure().getScalar(1, j) = _leftBufferIn[j];
}
コード例 #15
0
void PressureBufferFillStencil::applyBottomWall ( FlowField & flowField, int i, int j) {
	bottomPressureFillBuffer[i] = flowField.getPressure().getScalar(i,j+2);
}
コード例 #16
0
ファイル: BufferStencils.cpp プロジェクト: EvaBr/CFD-Lab
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];
}
コード例 #17
0
/*2D
 */
void PressureBufferFillStencil::applyLeftWall ( FlowField & flowField, int i, int j) {
	leftPressureFillBuffer[j] = flowField.getPressure().getScalar(i+2,j);
}
コード例 #18
0
ファイル: BufferStencils.cpp プロジェクト: EvaBr/CFD-Lab
void PressureBufferReadStencil::applyTopWall    (FlowField & flowField, int i, int j){
    flowField.getPressure().getScalar(i, flowField.getNy()+2) = _topBufferIn[i];
}
コード例 #19
0
ファイル: BufferStencils.cpp プロジェクト: EvaBr/CFD-Lab
void PressureBufferReadStencil::applyBottomWall (FlowField & flowField, int i, int j){
    flowField.getPressure().getScalar(i, 1) = _bottomBufferIn[i];
}
コード例 #20
0
ファイル: BufferStencils.cpp プロジェクト: EvaBr/CFD-Lab
void PressureBufferReadStencil::applyRightWall  (FlowField & flowField, int i, int j){
    flowField.getPressure().getScalar(flowField.getNx()+2, j) = _rightBufferIn[j];
}
コード例 #21
0
void PressureBufferFillStencil::applyFrontWall ( FlowField & flowField, int i, int j, int k) {
  /* _lowOffset = 2; _highOffset = -1;
   * from ParallelBoundaryIterater:  i = _lowOffset ; j = _lowOffset ; k = _lowOffset;
   */
  frontPressureFillBuffer[(j)+((localSize[1]+3)*(i))] = flowField.getPressure().getScalar(i,j,k+2);
}
コード例 #22
0
ファイル: BufferStencils.cpp プロジェクト: EvaBr/CFD-Lab
void PressureBufferFillStencil::applyTopWall    (FlowField & flowField, int i, int j){
    _topBufferOut[i] = flowField.getPressure().getScalar(i, flowField.getNy()+1);
}
コード例 #23
0
ファイル: BufferStencils.cpp プロジェクト: EvaBr/CFD-Lab
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];
}
コード例 #24
0
ファイル: BufferStencils.cpp プロジェクト: EvaBr/CFD-Lab
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);
}
コード例 #25
0
void PressureBufferFillStencil::applyRightWall ( FlowField & flowField, int i, int j) {
	rightPressureFillBuffer[0+2*j] = flowField.getPressure().getScalar(i-2,j);
	rightPressureFillBuffer[1+2*j] = flowField.getPressure().getScalar(i-1,j);
}
コード例 #26
0
ファイル: BufferStencils.cpp プロジェクト: EvaBr/CFD-Lab
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];
}
コード例 #27
0
void PressureBufferFillStencil::applyTopWall ( FlowField & flowField, int i, int j) {
	topPressureFillBuffer[0+2*i] = flowField.getPressure().getScalar(i,j-2);
	topPressureFillBuffer[1+2*i] = flowField.getPressure().getScalar(i,j-1);
}
コード例 #28
0
ファイル: BufferStencils.cpp プロジェクト: EvaBr/CFD-Lab
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];
}
コード例 #29
0
ファイル: BufferStencils.cpp プロジェクト: EvaBr/CFD-Lab
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];
}
コード例 #30
0
ファイル: BufferStencils.cpp プロジェクト: EvaBr/CFD-Lab
void PressureBufferFillStencil::applyBottomWall (FlowField & flowField, int i, int j){
    _bottomBufferOut[i] = flowField.getPressure().getScalar(i, 2);
}