/* This file implements the Central upwind flux 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 . */ /** * Central upwind flux function */ __device__ float3 CentralUpwindFlux(const float3 Qm, float3 Qp, const float g) { const float3 Fp = F_func(Qp, g); const float up = Qp.y / Qp.x; // hu / h const float cp = sqrt(g*Qp.x); // sqrt(g*h) const float3 Fm = F_func(Qm, g); const float um = Qm.y / Qm.x; // hu / h const float cm = sqrt(g*Qm.x); // sqrt(g*h) const float am = min(min(um-cm, up-cp), 0.0f); // largest negative wave speed const float ap = max(max(um+cm, up+cp), 0.0f); // largest positive wave speed return ((ap*Fm - am*Fp) + ap*am*(Qp-Qm))/(ap-am); }