Initialize a problem-specific terrain profile on the nodal terrain FAB.
28 bool test_mapfactor =
false;
29 pp.queryAdd(
"test_mapfactor",test_mapfactor);
39 auto dx = geom.CellSizeArray();
40 auto ProbLoArr = geom.ProbLoArray();
41 auto ProbHiArr = geom.ProbHiArray();
43 const amrex::Box& domain = geom.Domain();
44 int domlo_x = domain.smallEnd(0);
int domhi_x = domain.bigEnd(0) + 1;
45 int domlo_y = domain.smallEnd(1);
int domhi_y = domain.bigEnd(1) + 1;
46 int domlo_z = domain.smallEnd(2);
50 Real
num = Real(8.) * a * a * a;
51 Real xcen =
myhalf * (ProbLoArr[0] + ProbHiArr[0]) / mf_m;
52 Real ycen =
myhalf * (ProbLoArr[1] + ProbHiArr[1]) / mf_m;
57 std::string custom_terrain_type =
"None";
58 ParmParse
pp_prob(
"prob");
pp_prob.queryAdd(
"custom_terrain_type", custom_terrain_type);
60 amrex::Box zbx = terrain_fab.box();
61 if (zbx.smallEnd(2) <= k0)
63 amrex::Array4<Real>
const& z_arr = terrain_fab.array();
65 if (custom_terrain_type ==
"WoA") {
68 int dir = 0;
pp_prob.queryAdd(
"dir", dir);
70 Real L = Real(100.0);
pp_prob.queryAdd(
"L" , L);
71 Real z_offset =
zero;
pp_prob.queryAdd(
"z_offset" , z_offset);
78 ParallelFor(zbx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int)
81 int ii = amrex::min(amrex::max(i,domlo_x),domhi_x);
84 Real
x = (ProbLoArr[0] + ii *
dx[0] - xcen) * mf_m;
88 z_arr(i,j,k0) =
num / (
x*
x + 4 * a * a);
91 z_arr(i,j,k0) = hm / (1 + x_L*x_L) + z_offset;
94 }
else if (dir == 1) {
95 ParallelFor(zbx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int)
98 int jj = amrex::min(amrex::max(j,domlo_y),domhi_y);
101 Real
y = (ProbLoArr[1] + jj *
dx[1] - ycen) * mf_m;
105 z_arr(i,j,k0) =
num / (
y*
y + Real(4.0) * a * a);
108 z_arr(i,j,k0) = hm / (
one + y_L*y_L) + z_offset;
111 }
else if (dir == 2) {
112 ParallelFor(zbx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int)
115 int ii = amrex::min(amrex::max(i,domlo_x),domhi_x);
116 int jj = amrex::min(amrex::max(j,domlo_y),domhi_y);
119 Real
x = (ProbLoArr[0] + ii *
dx[0] - xcen) * mf_m;
120 Real
y = (ProbLoArr[1] + jj *
dx[1] - ycen) * mf_m;
121 Real r = std::sqrt(x*x + y*y);
125 z_arr(i,j,k0) =
num / (r*r + Real(4.0) * a * a);
128 z_arr(i,j,k0) = hm / (
one + r_L*r_L) + z_offset;
132 amrex::Abort(
"Unknown dir in ERF_Prob.cpp");
135 }
else if (custom_terrain_type ==
"ScharMountain") {
137 Real a_mtn = Real(5000.0);
pp_prob.queryAdd(
"a" , a_mtn);
138 Real Hm = Real(250.0);
pp_prob.queryAdd(
"hm" , Hm);
139 Real lambda = Real(4000.0);
pp_prob.queryAdd(
"lambda", lambda);
140 Real asq = a_mtn * a_mtn;
142 ParallelFor(zbx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int)
145 int ii = amrex::min(amrex::max(i,domlo_x),domhi_x);
148 Real
x = (ProbLoArr[0] + ii *
dx[0] - xcen);
150 Real cosx = std::cos(
PI * x / lambda);
152 z_arr(i,j,k0) = Hm * std::exp(-x*x/asq) * cosx * cosx;
155 }
else if (custom_terrain_type ==
"HalfCylinder") {
159 ParallelFor(zbx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int)
162 int ii = amrex::min(amrex::max(i,domlo_x),domhi_x);
165 Real
x = (ProbLoArr[0] + ii *
dx[0] - xcen);
170 z_arr(i,j,k0) = std::sqrt(asq - rsq);
172 z_arr(i,j,k0) =
zero;
176 }
else if (custom_terrain_type ==
"Hemisphere") {
180 ParallelFor(zbx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int)
183 int ii = amrex::min(amrex::max(i,domlo_x),domhi_x);
184 int jj = amrex::min(amrex::max(j,domlo_y),domhi_y);
187 Real
x = (ProbLoArr[0] + ii *
dx[0] - xcen);
188 Real
y = (ProbLoArr[1] + jj *
dx[1] - ycen);
190 Real rsq =
x*
x +
y*
y;
193 z_arr(i,j,k0) = std::pow(asq-rsq,
myhalf);
195 z_arr(i,j,k0) =
zero;
199 }
else if (custom_terrain_type ==
"MovingSineWave") {
209 Real time =
static_cast<Real
>(time_d);
211 ParallelFor(zbx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int)
214 int ii = amrex::min(amrex::max(i,domlo_x),domhi_x);
218 Real
x = ProbLoArr[0] + ii *
dx[0];
227 }
else if (custom_terrain_type ==
"WindFarmTest") {
229 ParallelFor(zbx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int)
232 int ii = amrex::min(amrex::max(i,domlo_x),domhi_x);
233 int jj = amrex::min(amrex::max(j,domlo_y),domhi_y);
236 Real
x = (ProbLoArr[0] + ii *
dx[0] - xcen);
237 Real
y = (ProbLoArr[1] + jj *
dx[1] - ycen);
239 Real x_L =
x/Real(100.0);
240 Real y_L =
y/Real(100.0);
242 z_arr(i,j,k0) = Real(100.0) / (
one + x_L*x_L + y_L*y_L);
245 }
else if (custom_terrain_type ==
"RaisedFlat") {
246 Real z_offset =
zero;
pp_prob.queryAdd(
"z_offset" , z_offset);
247 ParallelFor(zbx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int)
249 z_arr(i,j,k0) = z_offset;
251 }
else if (custom_terrain_type ==
"Cos4Hill") {
255 Real L = Real(100.0);
pp_prob.queryAdd(
"L", L);
256 Real z_offset =
zero;
pp_prob.queryAdd(
"z_offset", z_offset);
257 Real fourL =
four * L;
259 ParallelFor(zbx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int)
263 int ii = amrex::min(amrex::max(i,domlo_x),domhi_x);
264 int jj = amrex::min(amrex::max(j,domlo_y),domhi_y);
267 Real
x = (ProbLoArr[0] + ii *
dx[0] - xcen);
268 Real
y = (ProbLoArr[1] + jj *
dx[1] - ycen);
269 Real r = std::sqrt(x*x + y*y);
272 z_arr(i,j,k0) = z_offset + hm * Real(0.0625) * std::pow(
one + std::cos(
PI*r/fourL),
four);
274 z_arr(i,j,k0) = z_offset;
278 }
else if (custom_terrain_type ==
"None") {
280 Real z_bot = ProbLoArr[2];
281 ParallelFor(zbx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int)
283 z_arr(i,j,k0) = z_bot;
286 Abort(
"Don't know this custom_terrain_type");
GpuArray< Real, AMREX_SPACEDIM > dx
Definition: ERF_ActuatorSpreading.cpp:131
constexpr amrex::Real CONST_GRAV
Definition: ERF_Constants.H:72
@ num
Definition: ERF_DataStruct.H:40
ParmParse pp_prob("prob")
AMREX_ALWAYS_ASSERT_WITH_MESSAGE(axis >=0 &&axis< AMREX_SPACEDIM, "prob.axis must be 0, 1 or 2")
Real Ampl
Definition: ERF_InitCustomPert_MovingTerrain.H:4
Real wavelength
Definition: ERF_InitCustomPert_MovingTerrain.H:5
Real kp
Definition: ERF_InitCustomPert_MovingTerrain.H:9
Real height
Definition: ERF_InitCustomPert_SquallLine.H:37
ParallelFor(fab_box, [=] AMREX_GPU_DEVICE(int i, int j, int k) { qrcuten_arr(i, j, k)=Real(0);qscuten_arr(i, j, k)=Real(0);qicuten_arr(i, j, k)=Real(0);})
constexpr amrex::Real four
Definition: ERF_NumericalConstants.H:40
constexpr amrex::Real two
Definition: ERF_NumericalConstants.H:38
constexpr amrex::Real one
Definition: ERF_NumericalConstants.H:37
constexpr amrex::Real zero
Definition: ERF_NumericalConstants.H:36
constexpr amrex::Real myhalf
Definition: ERF_NumericalConstants.H:41
constexpr amrex::Real PI
Definition: ERF_NumericalConstants.H:46
@ omega
Definition: ERF_Morrison.H:57
real(c_double), parameter g
Definition: ERF_module_model_constants.F90:19