REMORA
Regional Modeling of Oceans Refined Adaptively
Loading...
Searching...
No Matches
REMORA_t3dmix.cpp
Go to the documentation of this file.
1#include <REMORA.H>
2
3using namespace amrex;
4
5/**
6 * @param[in ] bx box to operate on
7 * @param[inout] state scalar data
8 * @param[ out] state_rhs scalar data RHS
9 * @param[in ] diff2 diffusivity
10 * @param[in ] Hz vertical cell height
11 * @param[in ] pm 1/dx
12 * @param[in ] pn 1/dy
13 * @param[in ] msku land-sea mask on u-points
14 * @param[in ] mskv land-sea mask on v-points
15 * @param[in ] dt_lev time step at level
16 * @param[in ] ncomp number of components to do this calculation on
17 */
18void
19REMORA::t3dmix (const Box& bx,
20 const Array4<Real >& state,
21 const Array4<Real >& state_rhs,
22 const Array4<Real const>& diff2,
23 const Array4<Real const>& Hz,
24 const Array4<Real const>& pm,
25 const Array4<Real const>& pn,
26 const Array4<Real const>& msku,
27 const Array4<Real const>& mskv,
28 const Real dt_lev, const int ncomp)
29{
30 BL_PROFILE("REMORA::t3dmix()");
31 //-----------------------------------------------------------------------
32 // Add in harmonic diffusivity s terms.
33 //-----------------------------------------------------------------------
34
35 Box xbx(bx); xbx.surroundingNodes(0);
36 Box ybx(bx); ybx.surroundingNodes(1);
37
38 FArrayBox fab_FX(xbx,ncomp,The_Async_Arena());
39 FArrayBox fab_FE(ybx,ncomp,The_Async_Arena());
40
41 auto FX=fab_FX.array();
42 auto FE=fab_FE.array();
43
44 ParallelFor(xbx, ncomp, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n)
45 {
46 const Real pmon_u = (pm(i-1,j,0)+pm(i,j,0))/(pn(i-1,j,0)+pn(i,j,0));
47
48 const Real cff = 0.25_rt * (diff2(i,j,n) + diff2(i-1,j,n)) * pmon_u;
49 FX(i,j,k,n) = cff * (Hz(i,j,k) + Hz(i-1,j,k)) * (state_rhs(i,j,k,n)-state_rhs(i-1,j,k,n));
50 FX(i,j,k,n) *= msku(i,j,0);
51 });
52
53 ParallelFor(ybx, ncomp, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n)
54 {
55 const Real pnom_v = (pn(i,j-1,0)+pn(i,j,0))/(pm(i,j-1,0)+pm(i,j,0));
56
57 const Real cff = 0.25_rt*(diff2(i,j,n)+diff2(i,j-1,n)) * pnom_v;
58 FE(i,j,k,n) = cff * (Hz(i,j,k) + Hz(i,j-1,k)) * (state_rhs(i,j,k,n) - state_rhs(i,j-1,k,n));
59 FE(i,j,k,n) *= mskv(i,j,0);
60 });
61
62 /*
63 Time-step harmonic, S-surfaces diffusion term.
64 */
65 ParallelFor(bx, ncomp, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n)
66 {
67 const Real cff = dt_lev*pm(i,j,0)*pn(i,j,0);
68
69 state(i,j,k,n) += cff * ( (FX(i+1,j ,k,n)-FX(i,j,k,n))
70 +(FE(i ,j+1,k,n)-FE(i,j,k,n)) );
71 });
72}
void t3dmix(const amrex::Box &bx, const amrex::Array4< amrex::Real > &state, const amrex::Array4< amrex::Real > &state_rhs, const amrex::Array4< amrex::Real const > &diff2, const amrex::Array4< amrex::Real const > &Hz, const amrex::Array4< amrex::Real const > &pm, const amrex::Array4< amrex::Real const > &pn, const amrex::Array4< amrex::Real const > &msku, const amrex::Array4< amrex::Real const > &mskv, const amrex::Real dt_lev, const int ncomp)
Harmonic diffusivity for tracers.