Ejemplo n.º 1
0
/**
 * Set the boundary type for specific block boundary.
 *
 * @param i_edge location of the edge relative to the SWE_block.
 * @param i_boundaryType type of the boundary condition.
 * @param i_inflow pointer to an SWE_Block1D, which specifies the inflow (should be NULL for WALL or OUTFLOW boundary)
 */
void SWE_Block::setBoundaryType( const BoundaryEdge i_edge,
                                 const BoundaryType i_boundaryType,
                                 const SWE_Block1D* i_inflow) {
  boundary[i_edge] = i_boundaryType;
  neighbour[i_edge] = i_inflow;

  // set bathymetry values in the ghost layer, if necessary
  for(int j=0; j<=ny+1; j++) {
    if( boundary[BND_LEFT] == OUTFLOW || boundary[BND_LEFT] == WALL ) {
      b[0][j] = b[1][j];
    }
    if( boundary[BND_RIGHT] == OUTFLOW || boundary[BND_RIGHT] == WALL ) {
      b[nx+1][j] = b[nx][j];
    }
  }
  for(int i=0; i<=nx+1; i++) {
    if( boundary[BND_BOTTOM] == OUTFLOW || boundary[BND_BOTTOM] == WALL ) {
      b[i][0] = b[i][1];
    }
    if( boundary[BND_TOP] == OUTFLOW || boundary[BND_TOP] == WALL ) {
      b[i][ny+1] = b[i][ny];
    }
  }

  // synchronize after an external update of the bathymetry
  synchBathymetryAfterWrite();
}
Ejemplo n.º 2
0
/**
 * Sets the bathymetry on OUTFLOW or WALL boundaries.
 * Should be called very time a boundary is changed to a OUTFLOW or
 * WALL boundary <b>or</b> the bathymetry changes.
 */
void SWE_Block::setBoundaryBathymetry()
{
	// set bathymetry values in the ghost layer, if necessary
	if( boundary[BND_LEFT] == OUTFLOW || boundary[BND_LEFT] == WALL ) {
		memcpy(b[0], b[1], sizeof(float)*(ny+2));
	}
	if( boundary[BND_RIGHT] == OUTFLOW || boundary[BND_RIGHT] == WALL ) {
		memcpy(b[nx+1], b[nx], sizeof(float)*(ny+2));
	}
	if( boundary[BND_BOTTOM] == OUTFLOW || boundary[BND_BOTTOM] == WALL ) {
		for(int i=0; i<=nx+1; i++) {
			b[i][0] = b[i][1];
		}
	}
	if( boundary[BND_TOP] == OUTFLOW || boundary[BND_TOP] == WALL ) {
		for(int i=0; i<=nx+1; i++) {
			b[i][ny+1] = b[i][ny];
		}
	}


	// set corner values
        b[0][0]       = b[1][1];
        b[0][ny+1]    = b[1][ny];
        b[nx+1][0]    = b[nx][1];
        b[nx+1][ny+1] = b[nx][ny];

	// synchronize after an external update of the bathymetry
	synchBathymetryAfterWrite();
}
Ejemplo n.º 3
0
/**
 * set Bathymetry b in all grid cells (incl. ghost/boundary layers)
 * using the specified bathymetry function;
 * bathymetry source terms are re-computed
 */
void SWE_Block::setBathymetry(float (*_b)(float, float)) {

  for(int i=0; i<nx+2*nghosts; i++)
	for(int j=0; j<ny+2*nghosts; j++)
      b[i][j] = _b(offsetX + (i-nghosts+0.5f)*dx, offsetY + (j-nghosts+0.5f)*dy);

  synchBathymetryAfterWrite();
}
Ejemplo n.º 4
0
/**
 * set Bathymetry b in all grid cells (incl. ghost/boundary layers)
 * to a uniform value
 * bathymetry source terms are re-computed
 */
void SWE_Block::setBathymetry(float _b) {

  for(int i=0; i<nx+2*nghosts; i++)
    for(int j=0; j<ny+2*nghosts; j++)
      b[i][j] = _b;

  synchBathymetryAfterWrite();
}
Ejemplo n.º 5
0
/**
 * set Bathymetry b in all grid cells (incl. ghost/boundary layers)
 * using the specified bathymetry function;
 * bathymetry source terms are re-computed
 */
void SWE_Block::setBathymetry(float (*_b)(float, float)) {

  for(int i=0; i<=nx+1; i++)
    for(int j=0; j<=ny+1; j++)
      b[i][j] = _b(offsetX + (i-0.5f)*dx, offsetY + (j-0.5f)*dy);

  synchBathymetryAfterWrite();
}
Ejemplo n.º 6
0
/**
 * set Bathymetry b in all grid cells (incl. ghost/boundary layers)
 * to a uniform value
 * bathymetry source terms are re-computed
 */
void SWE_Block::setBathymetry(float _b) {

  for(int i=0; i<=nx+1; i++)
    for(int j=0; j<=ny+1; j++)
      b[i][j] = _b;

  synchBathymetryAfterWrite();
}
Ejemplo n.º 7
0
/**
 * set boundary type for a specific block boundary
 * @param edge	specifies boundary (LEFT, RIGHT, BOTTOM, TOP)
 * @param boundtype	type of boundary condition
 * @param inflow	pointer to an SWE_block1D that specifies
 * 			inflow (should be NULL for WALL or OUTFLOW boundary)
 */
void SWE_Block::setBoundaryType(BoundaryEdge edge, BoundaryType boundtype,
                                const SWE_BlockGhost* inflow) {
  boundary[edge] = boundtype;
  neighbour[edge] = inflow;
  // set bathymetry values in the ghost layer, if necessary
  for(int j=0; j<ny+2*nghosts; j++) {
	if( boundary[BND_LEFT] == OUTFLOW || boundary[BND_LEFT] == WALL ) {
	  b[nghosts-1][j] = b[nghosts][j];
	}
	if( boundary[BND_RIGHT] == OUTFLOW || boundary[BND_RIGHT] == WALL ) {
	  b[nx+nghosts][j] = b[nx+nghosts-1][j];
	}
  }
  for(int i=0; i<nx+2*nghosts; i++) {
	if( boundary[BND_BOTTOM] == OUTFLOW || boundary[BND_BOTTOM] == WALL ) {
	  b[i][nghosts-1] = b[i][nghosts];
	}
	if( boundary[BND_TOP] == OUTFLOW || boundary[BND_TOP] == WALL ) {
	  b[i][ny+nghosts] = b[i][ny+nghosts-1];
    }
  }
  // synchronize after an external update of the bathymetry
  synchBathymetryAfterWrite();
}
Ejemplo n.º 8
0
/**
 * Update all temporary and non-local (for heterogeneous computing) variables
 * after an external update of the main variables h, hu, hv, and b.
 */
void SWE_Block::synchAfterWrite() {
   synchWaterHeightAfterWrite();
   synchDischargeAfterWrite();
   synchBathymetryAfterWrite();
}