1//=======================================================================================
2// ____ ____ __ ______ __________ __ __ __ __
3// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
4// \ \ | | | | | |_) | | | | | | | / \ | |
5// \ \ | | | | | _ / | | | | | | / /\ \ | |
6// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
7// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
8// \ \ | | ________________________________________________________________
9// \ \ | | | ______________________________________________________________|
10// \ \| | | | __ __ __ __ ______ _______
11// \ | | |_____ | | | | | | | | | _ \ / _____)
12// \ | | _____| | | | | | | | | | | \ \ \_______
13// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
14// \ _____| |__| |________| \_______/ |__| |______/ (_______/
16// This file is part of VirtualFluids. VirtualFluids is free software: you can
17// redistribute it and/or modify it under the terms of the GNU General Public
18// License as published by the Free Software Foundation, either version 3 of
19// the License, or (at your option) any later version.
21// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT
22// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26// SPDX-License-Identifier: GPL-3.0-or-later
27// SPDX-FileCopyrightText: Copyright © VirtualFluids Project contributors, see AUTHORS.md in root folder
29#include "CoriolisForce.h"
33#include <basics/DataTypes.h>
34#include <basics/constants/NumericConstants.h>
36#include "cuda_helper/CudaGrid.h"
37#include <cuda_helper/CudaIndexCalculation.h>
41__global__ void computeCoriolis(unsigned long long numberOfNodes, const real* velocityX, const real* velocityY, real* forceX,
42 real* forceY, const real geostrophicWindX, const real geostrophicWindY,
43 const real coriolisParameter)
45 const uint nodeIndex = vf::cuda::get1DIndexFrom2DBlock();
46 if (nodeIndex >= numberOfNodes)
48 forceX[nodeIndex] += -(geostrophicWindY - velocityY[nodeIndex]) * coriolisParameter;
49 forceY[nodeIndex] += (geostrophicWindX - velocityX[nodeIndex]) * coriolisParameter;
52void CoriolisForce::interact(int level, uint /**/)
54 auto parD = para->getParD(level);
55 const real velocityRatio = para->getScaledVelocityRatio(level);
56 const real timeRatio = para->getScaledTimeRatio(level);
57 vf::cuda::CudaGrid grid(parD->numberofthreads, parD->numberOfNodes);
58 computeCoriolis<<<grid.grid, grid.threads>>>(parD->numberOfNodes, parD->velocityX, parD->velocityY, parD->forceX_SP,
59 parD->forceY_SP, geostrophicWindX / velocityRatio,
60 geostrophicWindY / velocityRatio, coriolisParameter * timeRatio);