REMORA
Regional Modeling of Oceans Refined Adaptively
Loading...
Searching...
No Matches
REMORA_InitAnalyticProb_ChannelTest.H
Go to the documentation of this file.
1
2 // Whether this run carries a passive dye tracer. nComp() cannot answer this: with
3 // biology active and no dye, Tracer_comp is the first biology component, so testing
4 // nComp() would write the dye initial value into NO3.
5 const bool l_do_dye = (remora.num_passive_scalars() > 0);
6 bool l_use_salt = m_solverChoice.use_salt;
7
8 auto geomdata = geom.data();
9 const int khi = geomdata.Domain().bigEnd()[2];
10
11 [[maybe_unused]] bool EWPeriodic = geomdata.isPeriodic(1);
12 [[maybe_unused]] bool NSPeriodic = geomdata.isPeriodic(0);
13
14 // Uniform tracers and no initial jet, which a test needs if its exact solution is rest.
15 // Pairs with remora.prob.quiescent in the surface stress, which drops the wind.
16 amrex::ParmParse pp_prob("remora.prob");
17 bool quiescent = false;
18 pp_prob.query("quiescent", quiescent);
19 const bool l_quiescent = quiescent;
20
21 auto T0 = m_solverChoice.T0;
22 auto S0 = m_solverChoice.S0;
23 for (MFIter mfi(mf_cons, TilingIfNotGPU()); mfi.isValid(); ++mfi)
24 {
25 const Box &bx = mfi.tilebox();
26 AMREX_ALWAYS_ASSERT(bx.length()[2] == khi+1);
27
28 Array4< Real> const& state = mf_cons.array(mfi);
29 Array4< Real> const& x_vel = mf_xvel.array(mfi);
30 Array4< Real> const& y_vel = mf_yvel.array(mfi);
31
32 Array4<const Real> const& z_r = coords.z_r->const_array(mfi);
33
34 ParallelFor(grow(grow(bx,0,1),1,1), [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
35 {
36 const auto prob_lo = geomdata.ProbLo();
37 const auto prob_hi = geomdata.ProbHi();
38 const auto dx = geomdata.CellSize();
39
40 const Real z = z_r(i,j,k);
41
42 // Create bounding box for x and y to make spatially-dependent T and S
43 const Real xcent = Real(0.5)*(prob_lo[0] + prob_hi[0]);
44 [[maybe_unused]] const Real ycent = Real(0.5)*(prob_lo[1] + prob_hi[1]);
45
46 [[maybe_unused]] const Real x = prob_lo[0] + (i + Real(0.5)) * dx[0] - xcent;
47 const Real y = prob_lo[1] + (j + Real(0.5)) * dx[1];
48
50 : T0 + z / (Real(9.8) * Real(1.7));
51 if (l_use_salt) {
53 : S0 + y / (Real(9.8) * Real(760.0));
54 }
55
56 // Set tracer = 0 everywhere
57 if (l_do_dye) { state(i, j, k,Tracer_comp) = zero; }
58 });
59
60 const Box& xbx = surroundingNodes(bx,0);
61 const Box& ybx = surroundingNodes(bx,1);
62 ParallelFor(grow(grow(xbx,1,1),0,1), [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
63 {
64 // Create bounding box for x and y to make spatially-dependent T and S
65 const auto prob_lo = geomdata.ProbLo();
66 const auto prob_hi = geomdata.ProbHi();
67 const auto dx = geomdata.CellSize();
68
69 [[maybe_unused]] const Real xcent = Real(0.5)*(prob_lo[0] + prob_hi[0]);
70 [[maybe_unused]] const Real ycent = Real(0.5)*(prob_lo[1] + prob_hi[1]);
71
72 const Real z = z_r(i,j,k);
73 // h(i,j,0) = -geomdata.ProbLo(2);
74 const Real depth = Real(50.0);
75
76 const Real x = prob_lo[0] + (i + Real(0.5)) * dx[0];// - xcent;
77 const Real y = prob_lo[1] + (j + Real(0.5)) * dx[1];// - ycent;
78
79 const Real val1 = x * Real(6.28318530718) * Real(1.0e-5);
80 const Real val2 = y * Real(6.28318530718) * Real(1.0e-5);
81 x_vel(i, j, k) = l_quiescent ? zero
82 : (depth + z) * Real(0.01) + Real(0.05) * std::sin(val1) * std::sin(val2);
83 });
84 ParallelFor(ybx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept
85 {
86 y_vel(i, j, k) = zero;
87 });
88 }
89 Gpu::streamSynchronize();
constexpr amrex::Real zero
#define Temp_comp
#define Tracer_comp
#define Salt_comp
mf_h setVal(geomdata.ProbHi(2))
AMREX_ALWAYS_ASSERT(!NSPeriodic||!EWPeriodic)
amrex::ParmParse pp_prob("remora.prob")