/** * set discharge unknowns in all interior grid cells (i.e. except ghost layer) * to a uniform value * Note: unknowns hu and hv represent momentum, while parameters u and v are velocities! * (_u and _v are multiplied with the resp. cell-local value of h) */ void SWE_Block::setDischarge(float _u, float _v) { for(int i=nghosts; i<nx+nghosts; i++) for(int j=nghosts; j<ny+nghosts; j++) { hu[i][j] = h[i][j] * _u; hv[i][j] = h[i][j] * _v; }; synchDischargeAfterWrite(); }
/** * set discharge unknowns in all interior grid cells (i.e. except ghost layer) * to a uniform value * Note: unknowns hu and hv represent momentum, while parameters u and v are velocities! * (_u and _v are multiplied with the resp. cell-local value of h) */ void SWE_Block::setDischarge(float _u, float _v) { for(int i=1; i<=nx; i++) for(int j=1; j<=ny; j++) { hu[i][j] = h[i][j] * _u; hv[i][j] = h[i][j] * _v; }; synchDischargeAfterWrite(); }
/** * set discharge in all interior grid cells (i.e. except ghost layer) * to values specified by parameter functions * Note: unknowns hu and hv represent momentum, while parameters u and v are velocities! */ void SWE_Block::setDischarge(float (*_u)(float, float), float (*_v)(float, float)) { for(int i=nghosts; i<nx+nghosts; i++) for(int j=nghosts; j<ny+nghosts; j++) { float x = offsetX + (i-nghosts+0.5f)*dx; float y = offsetY + (j-nghosts+0.5f)*dy; hu[i][j] = _u(x,y) * h[i][j]; hv[i][j] = _v(x,y) * h[i][j]; }; synchDischargeAfterWrite(); }
/** * set discharge in all interior grid cells (i.e. except ghost layer) * to values specified by parameter functions * Note: unknowns hu and hv represent momentum, while parameters u and v are velocities! */ void SWE_Block::setDischarge(float (*_u)(float, float), float (*_v)(float, float)) { for(int i=1; i<=nx; i++) for(int j=1; j<=ny; j++) { float x = offsetX + (i-0.5f)*dx; float y = offsetY + (j-0.5f)*dy; hu[i][j] = _u(x,y) * h[i][j]; hv[i][j] = _v(x,y) * h[i][j]; }; synchDischargeAfterWrite(); }
/** * 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(); }