/* This file implements different flux and slope limiters Copyright (C) 2016, 2017, 2018 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 . */ #pragma once /** * Reconstructs a slope using the generalized minmod limiter based on three * consecutive values */ __device__ __inline__ float minmodSlope(float left, float center, float right, float theta) { const float backward = (center - left) * theta; const float central = (right - left) * 0.5f; const float forward = (right - center) * theta; return 0.25f *copysign(1.0f, backward) *(copysign(1.0f, backward) + copysign(1.0f, central)) *(copysign(1.0f, central) + copysign(1.0f, forward)) *min( min(fabs(backward), fabs(central)), fabs(forward) ); } /** * Reconstructs a minmod slope for a whole block along the abscissa */ template __device__ void minmodSlopeX(float Q[vars][block_height+2*ghost_cells][block_width+2*ghost_cells], float Qx[vars][block_height+2*(ghost_cells-1)][block_width+2*(ghost_cells-1)], const float theta_) { //Index of thread within block const int tx = threadIdx.x; const int ty = threadIdx.y; const int j = ty; const int l = j + ghost_cells; //Skip ghost cells //Reconstruct slopes along x axis for (int i=tx; i __device__ void minmodSlopeY(float Q[vars][block_height+2*ghost_cells][block_width+2*ghost_cells], float Qy[vars][block_height+2*(ghost_cells-1)][block_width+2*(ghost_cells-1)], const float theta_) { //Index of thread within block const int tx = threadIdx.x; const int ty = threadIdx.y; const int i = tx; const int k = i + ghost_cells; //Skip ghost cells //Reconstruct slopes along y axis for (int j=ty; j