REMORA
Regional Modeling of Oceans Refined Adaptively
Loading...
Searching...
No Matches
REMORA_curvilinear.cpp
Go to the documentation of this file.
1#include <REMORA.H>
2
3using namespace amrex;
4
5/**
6 * @param[in ] bx box to update on
7 * @param[in ] xbx nodal-x box to update on
8 * @param[in ] ybx nodal-y box to update on
9 * @param[in ] uold u-direction velocity
10 * @param[in ] vold v-direction velocity
11 * @param[inout] ru u-direction velocity RHS
12 * @param[inout] rv v-direction velocity RHS
13 * @param[in ] Hz vertical cell height
14 * @param[in ] dndx d(1/n)/d(xi)
15 * @param[in ] dmde d(1/m)/d(eta)
16 * @param[in ] nrhs which velocity component to use
17 * @param[in ] nr which RHS component to update
18 */
19
20void
21REMORA::curvilinear (const Box& bx,
22 const Box& xbx,
23 const Box& ybx,
24 const Array4<Real const>& uold,
25 const Array4<Real const>& vold,
26 const Array4<Real >& ru,
27 const Array4<Real >& rv,
28 const Array4<Real const>& Hz,
29 const Array4<Real const>& dndx,
30 const Array4<Real const>& dmde,
31 int nrhs, int nr)
32{
33 BL_PROFILE("REMORA::curvilinear()");
34 //
35 //-----------------------------------------------------------------------
36 // Add in curvilinear transformation terms.
37 //-----------------------------------------------------------------------
38 //
39
40 int ncomp = 0;
41 int UFx_comp = ncomp++;
42 int VFe_comp = ncomp++;
43
44 FArrayBox fab(grow(bx,IntVect(1,1,0)),ncomp,The_Async_Arena());
45
46 auto UFx = fab.array(UFx_comp);
47 auto VFe = fab.array(VFe_comp);
48
49 ParallelFor(grow(bx,IntVect(1,1,0)),
50 [=] AMREX_GPU_DEVICE (int i, int j, int k)
51 {
52 Real cff1 = 0.5_rt * (vold(i,j,k,nrhs) + vold(i ,j+1,k,nrhs));
53 Real cff2 = 0.5_rt * (uold(i,j,k,nrhs) + uold(i+1,j ,k,nrhs));
54 Real cff3 = cff1 * dndx(i,j,0);
55 Real cff4 = cff2 * dmde(i,j,0);
56 Real cff = Hz(i,j,k) * (cff3 - cff4);
57 UFx(i,j,k) = cff * cff1;
58 VFe(i,j,k) = cff * cff2;
59 });
60
61 ParallelFor(xbx,
62 [=] AMREX_GPU_DEVICE (int i, int j, int k)
63 {
64 ru(i,j,k,nr) += 0.5_rt * (UFx(i,j,k) + UFx(i-1,j,k));
65 });
66
67 ParallelFor(ybx,
68 [=] AMREX_GPU_DEVICE (int i, int j, int k)
69 {
70 rv(i,j,k,nr) -= 0.5_rt * (VFe(i,j,k) + VFe(i,j-1,k));
71 });
72}
void curvilinear(const amrex::Box &bx, const amrex::Box &xbx, const amrex::Box &ybx, const amrex::Array4< amrex::Real const > &uold, const amrex::Array4< amrex::Real const > &vold, const amrex::Array4< amrex::Real > &ru, const amrex::Array4< amrex::Real > &rv, const amrex::Array4< amrex::Real const > &Hz, const amrex::Array4< amrex::Real const > &dndx, const amrex::Array4< amrex::Real const > &dmde, int nrhs, int nr)
Calculate curvilinear advection terms.