REMORA
Regional Modeling of Oceans Refined Adaptively
Loading...
Searching...
No Matches
REMORA_InitAnalyticBathymetry_Upwelling_ML.H
Go to the documentation of this file.
1
2 int rrx = remora.refRatio(0)[0];
3 int rry = remora.refRatio(0)[1];
4
5 // Must not be doubly periodic, and must have terrain
6 //AMREX_ALWAYS_ASSERT( !NSPeriodic || !EWPeriodic);
7
8 mf_h.setVal(geomdata.ProbHi(2));
9
10 if (lev==0 && m_solverChoice.init_l1ad_T) {
11 const int Lm = geom.Domain().size()[0] * rrx;
12 const int Mm = geom.Domain().size()[1] * rry;
13 BoxArray old_ba(mf_h.boxArray());
14 BoxArray tmp_ba = old_ba.refine(IntVect(rrx,rry,1));
15 DistributionMapping tmp_dm(tmp_ba);
16 MultiFab mf_h_hires(tmp_ba, tmp_dm, 2, mf_h.nGrow());
17 mf_h_hires.setVal(geomdata.ProbHi(2));
18
19 for ( MFIter mfi(mf_h_hires, TilingIfNotGPU()); mfi.isValid(); ++mfi )
20 {
21 Array4<Real> const& h = (mf_h_hires).array(mfi);
22
23 Box bx = mfi.tilebox();
24 Box gbx3 = bx;
25 gbx3.grow(IntVect(NGROW+1,NGROW+1,0));
26
27 Box gbx3D = gbx3;
28 gbx3D.makeSlab(2,0);
29
30 Gpu::streamSynchronize();
31
32 if (EWPeriodic) {
33
34 ParallelFor(gbx3D, [=] AMREX_GPU_DEVICE (int i, int j, int )
35 {
36 int jFort = j+1; // (+1 is to match the Fortran indexing in ROMS)
37
38 Real val1 = (jFort<=Mm/two) ? jFort : Mm+1-jFort;
39 val1 -= Real(0.5);
40 Real adj = geomdata.CellSize()[1]/(Real(1000.0) * rry);
41
42 h(i,j,0) = std::min(-geomdata.ProbLo(2),(Real(84.5)+Real(66.526)*std::tanh((val1*adj-Real(10.0))/Real(7.0))));
43 });
44 } else if (NSPeriodic) {
45
46 ParallelFor(gbx3D, [=] AMREX_GPU_DEVICE (int i, int j, int )
47 {
48 int iFort = i+1; // (+1 is to match the Fortran indexing in ROMS)
49
50 Real val1 = (iFort <= Lm/two) ? iFort : Lm+1-iFort;
51 val1 -= Real(0.5);
52 Real adj = geomdata.CellSize()[0]/(Real(1000.0) * rrx);
53
54 h(i,j,0) = std::min(-geomdata.ProbLo(2),(Real(84.5)+Real(66.526)*std::tanh((val1*adj-Real(10.0))/Real(7.0))));
55 });
56 }
57 } // mfi
58 average_down(mf_h_hires, mf_h, 0, mf_h.nComp(), IntVect(rrx,rry,1));
59 } else {
60 const int Lm = geom.Domain().size()[0];
61 const int Mm = geom.Domain().size()[1];
62 for ( MFIter mfi(mf_h, TilingIfNotGPU()); mfi.isValid(); ++mfi )
63 {
64 Array4<Real> const& h = (mf_h).array(mfi);
65
66 Box bx = mfi.tilebox();
67 Box gbx3 = bx;
68 gbx3.grow(IntVect(NGROW+1,NGROW+1,0));
69
70 Box gbx3D = gbx3;
71 gbx3D.makeSlab(2,0);
72
73 Gpu::streamSynchronize();
74
75 if (EWPeriodic) {
76
77 ParallelFor(gbx3D, [=] AMREX_GPU_DEVICE (int i, int j, int )
78 {
79 int jFort = j+1; // (+1 is to match the Fortran indexing in ROMS)
80
81 Real val1 = (jFort<=Mm/two) ? jFort : Mm+1-jFort;
82 val1 -= Real(0.5);
83 Real adj = geomdata.CellSize()[1]/Real(1000.0);
84
85 h(i,j,0) = std::min(-geomdata.ProbLo(2),(Real(84.5)+Real(66.526)*std::tanh((val1*adj-Real(10.0))/Real(7.0))));
86 });
87 } else if (NSPeriodic) {
88
89 ParallelFor(gbx3D, [=] AMREX_GPU_DEVICE (int i, int j, int )
90 {
91 int iFort = i+1; // (+1 is to match the Fortran indexing in ROMS)
92
93 Real val1 = (iFort <= Lm/two) ? iFort : Lm+1-iFort;
94 val1 -= Real(0.5);
95 Real adj = geomdata.CellSize()[0]/Real(1000.0);
96
97 h(i,j,0) = std::min(-geomdata.ProbLo(2),(Real(84.5)+Real(66.526)*std::tanh((val1*adj-Real(10.0))/Real(7.0))));
98 });
99 }
100 } // mfi
101 }
constexpr amrex::Real two
#define NGROW
mf_h setVal(geomdata.ProbHi(2))