/**
This OpenCL kernel implements part of the Centered in Time, Centered
in Space (leapfrog) numerical scheme for the shallow water equations,
described in
L. P. Røed, "Documentation of simple ocean models for use in ensemble
predictions", Met no report 2012/3 and 2012/5.
Copyright (C) 2016 SINTEF ICT
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
#include "common.opencl"
/**
* Kernel that evolves V one step in time.
*/
__kernel void computeVKernel(
//Discretization parameters
int nx_, int ny_,
float dx_, float dy_, float dt_,
//Physical parameters
float g_, //< Gravitational constant
float f_, //< Coriolis coefficient
float r_, //< Bottom friction coefficient
//Numerical diffusion
float A_,
//Data
__global float* H_ptr_, int H_pitch_,
__global float* eta1_ptr_, int eta1_pitch_, // eta^n
__global float* U1_ptr_, int U1_pitch_, // U^n
__global float* V0_ptr_, int V0_pitch_, // V^n-1, also output V^n+1
__global float* V1_ptr_, int V1_pitch_, // V^n
// Wind stress parameters
int wind_stress_type_,
float tau0_, float rho_, float alpha_, float xm_, float Rc_,
float x0_, float y0_,
float u0_, float v0_,
float t_) {
__local float H_shared[block_height+1][block_width+2];
__local float eta1_shared[block_height+1][block_width+2];
__local float U1_shared[block_height+1][block_width+1];
__local float V1_shared[block_height+2][block_width+2];
//Index of thread within block
const int tx = get_local_id(0);
const int ty = get_local_id(1);
//Start of block within domain
const int bx = get_local_size(0) * get_group_id(0) + 1; //Skip global ghost cells
const int by = get_local_size(1) * get_group_id(1) + 1; //Skip global ghost cells
//Index of cell within domain
const int ti = bx + tx;
const int tj = by + ty;
//Compute pointer to current row in the V array
__global float* const V0_row = (__global float*) ((__global char*) V0_ptr_ + V0_pitch_*tj);
//Read current V
float V0 = 0.0f;
if (ti > 0 && ti < nx_+1 && tj > 0 && tj < ny_) {
V0 = V0_row[ti];
}
//Read H and eta into shared memory: (nx+2)*(ny+1) cells
for (int j=ty; j 0 && ti < nx_+1 && tj > 0 && tj < ny_) {
V0_row[ti] = V2;
}
}