13#include "AMReX_MultiFabUtil.H"
14#include "AMReX_REAL.H"
16using namespace amrex::literals;
18#ifdef KYNEMA_SGF_USE_W2A
20int evaluate_read_resize(
27 const amrex::Real wtinit,
28 const amrex::Real wdt,
29 const amrex::Real time)
34 if (new_ntime != ntime) {
38 if (new_ntime > ntime + 1) {
45 wtime = new_ntime * wdt - wtinit;
47 if (double_data == 1 && std::abs(wtime - time) <= 1.0e-10_rt) {
53 if (t_last < -1.0e-10_rt) {
60 if (std::abs(wtime - time) > 1.0e-10_rt) {
68 }
else if (std::abs(t_last) < 1.0e-10_rt) {
83int update_offset_timestep(
const int ntime,
const int n0)
92void populate_fields_all_levels(
94 amrex::Vector<amrex::Geometry>& geom_all,
103 ? wdata.c_rmodes.get_data(
106 : wdata.r_rmodes.get_data(
114 amrex::Print() <<
"WARNING (waves2amr_ops): end of mode data file "
115 "detected, resetting to beginning of mode data.\n";
118 ? wdata.c_rmodes.get_data(
121 : wdata.r_rmodes.get_data(
127 "waves2amr_ops: end of mode data file detected after "
128 "resetting to beginning; please evaluate HOS_init_time "
129 "or HOS_init_timestep and check the length of the mode "
136 modes_hosgrid::copy_complex(
137 wdata.
n0, wdata.
n1, wdata.
c_mFS, wdata.c_eta_mptr);
138 modes_hosgrid::populate_hos_eta(
139 wdata.c_rmodes, wdata.plan_vector, wdata.c_eta_mptr,
142 modes_hosgrid::copy_real(
143 wdata.
n0, wdata.
n1, wdata.
r_mFS, wdata.r_eta_mptr);
144 modes_hosgrid::populate_hos_eta(
145 wdata.r_rmodes, wdata.plan_vector, wdata.r_eta_mptr,
149 for (
int iht = 0; iht < wdata.
indvec.size(); ++iht) {
151 amrex::Real ht = wdata.
hvec[wdata.
indvec[iht]];
154 modes_hosgrid::populate_hos_vel(
155 wdata.c_rmodes, ht, wdata.
zsl, wdata.
c_mX, wdata.
c_mY,
156 wdata.
c_mZ, wdata.plan_vector, wdata.c_u_mptr, wdata.c_v_mptr,
158 iht * wdata.
n0 * wdata.
n1);
160 modes_hosgrid::populate_hos_vel(
161 wdata.r_rmodes, ht, wdata.
zsl, wdata.
r_mX, wdata.
r_mY,
162 wdata.
r_mZ, wdata.
r_mAdd, wdata.plan_vector, wdata.r_u_mptr,
163 wdata.r_v_mptr, wdata.r_w_mptr, wdata.au_mptr, wdata.av_mptr,
165 iht * wdata.
n0 * wdata.
n1);
170 interp_to_mfab::interp_eta_to_levelset_field(
174 interp_to_mfab::interp_velocity_to_field(
180void time_interpolate_wave_fields(
185 const amrex::Real t_old,
186 const amrex::Real t_new,
187 const amrex::Real t_future)
189 const amrex::Real b =
191 (t_future - t_old + std::numeric_limits<amrex::Real>::epsilon());
192 const amrex::Real a = 1.0_rt - b;
194 lvs_field, a, lvs_field, 0, b, future_lvs_field, 0, 0, 1,
197 vel_field, a, vel_field, 0, b, future_vel_field, 0, 0, AMREX_SPACEDIM,
213#ifndef KYNEMA_SGF_USE_W2A
216 "ocean_waves/W2AWaves: Kynema-SGF was not built with Waves2AMR "
217 "support; associated wave data cannot be processed for relaxation "
220 amrex::ignore_unused(data, pp);
222 auto& wdata = data.
meta();
223 auto& info = data.
info();
228 "Current is specified as nonzero, but current is not yet "
229 "implemented for W2A Waves.");
232 pp.get(
"HOS_modes_filename", wdata.
modes_file);
233 pp.query(
"HOS_simulation_is_ocean", wdata.
is_ocean);
234 pp.query(
"HOS_init_timestep", wdata.
ntime);
235 if (!pp.contains(
"HOS_init_timestep")) {
236 pp.query(
"HOS_init_time", wdata.
t_winit);
238 pp.query(
"HOS_domain_offset_x", wdata.
xlo0);
239 pp.query(
"HOS_domain_offset_y", wdata.
xlo1);
242 std::string fftw_planner_flag{
"estimate"};
243 pp.query(
"fftw_planner_flag", fftw_planner_flag);
245 amrex::Vector<amrex::Real> prob_lo_input(AMREX_SPACEDIM);
246 amrex::ParmParse pp_geom(
"geometry");
247 pp_geom.getarr(
"prob_lo", prob_lo_input);
252 amrex::Real dz0 = 0.0_rt;
253 pp.get(
"number_interp_points_in_z", nheights);
254 pp.get(
"interp_spacing_at_surface", dz0);
255 pp.query(
"number_interp_above_surface", nh_above);
258 bool file_exists{
false};
260 file_exists = wdata.c_rmodes.initialize(wdata.
modes_file,
true);
262 file_exists = wdata.r_rmodes.initialize(wdata.
modes_file,
false);
268 "Waves2AMR ReadInputsOp: modes file requested does not exist");
273 : wdata.r_rmodes.get_dtout();
295 amrex::Print() <<
"OceanWaves: Initializing Waves2AMR profile at time "
300 amrex::Real depth{0.0_rt};
302 int vsize = wdata.c_rmodes.get_vector_size();
303 amrex::Real initval = 0.0_rt;
304 wdata.
c_mX.resize(vsize, initval);
305 wdata.
c_mY.resize(vsize, initval);
306 wdata.
c_mZ.resize(vsize, initval);
307 wdata.
c_mFS.resize(vsize, initval);
310 wdata.
n0 = wdata.c_rmodes.get_first_fft_dimension();
311 wdata.
n1 = wdata.c_rmodes.get_second_fft_dimension();
312 wdata.
n0_sp = wdata.c_rmodes.get_first_spatial_dimension();
313 wdata.
n1_sp = wdata.c_rmodes.get_second_spatial_dimension();
315 wdata.
dx0 = wdata.c_rmodes.get_xlen() / wdata.
n0_sp;
316 wdata.
dx1 = wdata.c_rmodes.get_ylen() / wdata.
n1_sp;
318 depth = wdata.c_rmodes.get_depth();
320 wdata.
dimL = wdata.c_rmodes.get_L();
322 wdata.
n_wstop =
static_cast<int>(
323 (wdata.c_rmodes.get_Tstop() + 1.0e-8_rt) / wdata.
dt_modes);
326 <<
"OceanWaves: Waves2AMR parameters from HOS-Ocean file: \n"
327 <<
" nx " << wdata.
n0_sp <<
" dx " << wdata.
dx0 <<
" Lx "
328 << wdata.c_rmodes.get_xlen() << std::endl
329 <<
" ny " << wdata.
n1_sp <<
" dy " << wdata.
dx1 <<
" Ly "
330 << wdata.c_rmodes.get_ylen() << std::endl
331 <<
" depth " << depth << std::endl
332 <<
" output time interval " << wdata.
dt_modes
336 int vsize = wdata.r_rmodes.get_vector_size();
337 int vasize = wdata.r_rmodes.get_addl_vector_size();
338 amrex::Real initval = 0.0_rt;
339 wdata.
r_mX.resize(vsize, initval);
340 wdata.
r_mY.resize(vsize, initval);
341 wdata.
r_mZ.resize(vsize, initval);
342 wdata.
r_mFS.resize(vsize, initval);
343 wdata.
r_mAdd.resize(vasize, initval);
346 wdata.
n0 = wdata.r_rmodes.get_first_fft_dimension();
347 wdata.
n1 = wdata.r_rmodes.get_second_fft_dimension();
348 wdata.
n2 = wdata.r_rmodes.get_third_dimension();
349 wdata.
n0_sp = wdata.r_rmodes.get_first_spatial_dimension();
350 wdata.
n1_sp = wdata.r_rmodes.get_second_spatial_dimension();
352 wdata.
dx0 = wdata.r_rmodes.get_xlen() / (wdata.
n0_sp - 1);
354 wdata.r_rmodes.get_ylen() / amrex::max(wdata.
n1_sp - 1, 1);
356 depth = wdata.r_rmodes.get_depth();
358 wdata.
dimL = wdata.r_rmodes.get_L();
360 wdata.
n_wstop =
static_cast<int>(
361 (wdata.r_rmodes.get_Tstop() + 1.0e-8_rt) / wdata.
dt_modes);
364 <<
"OceanWaves: Waves2AMR parameters from HOS-NWT file: \n"
365 <<
" nx " << wdata.
n0_sp <<
" dx " << wdata.
dx0 <<
" Lx "
366 << wdata.r_rmodes.get_xlen() << std::endl
367 <<
" ny " << wdata.
n1_sp <<
" dy " << wdata.
dx1 <<
" Ly "
368 << wdata.r_rmodes.get_ylen() << std::endl
369 <<
" nz " << wdata.
n2 <<
" depth " << depth << std::endl
370 <<
" output time interval " << wdata.
dt_modes
381 <<
"WARNING (waves2amr_ops): available mode data exceeded, "
382 "resetting to beginning of mode data.\n";
386 if (std::abs(depth - (wdata.
zsl - prob_lo_input[2])) >
389 <<
"WARNING: Mismatch between water depths from Kynema-SGF "
390 "domain and HOS data interpreted by Waves2AMR. \n ^This "
391 "warning is not a concern when using waves as terrain.\n";
397 modes_hosgrid::allocate_complex(wdata.
n0, wdata.
n1);
399 modes_hosgrid::allocate_complex(wdata.
n0, wdata.
n1);
401 modes_hosgrid::allocate_complex(wdata.
n0, wdata.
n1);
403 modes_hosgrid::allocate_complex(wdata.
n0, wdata.
n1);
405 wdata.r_eta_mptr = modes_hosgrid::allocate_real(wdata.
n0, wdata.
n1);
406 wdata.r_u_mptr = modes_hosgrid::allocate_real(wdata.
n0, wdata.
n1);
407 wdata.r_v_mptr = modes_hosgrid::allocate_real(wdata.
n0, wdata.
n1);
408 wdata.r_w_mptr = modes_hosgrid::allocate_real(wdata.
n0, wdata.
n1);
409 wdata.au_mptr = modes_hosgrid::allocate_real(wdata.
n0, 1);
410 wdata.av_mptr = modes_hosgrid::allocate_real(wdata.
n0, 1);
411 wdata.aw_mptr = modes_hosgrid::allocate_real(wdata.
n0, 1);
413 wdata.plan_out = modes_hosgrid::allocate_real(wdata.
n0, wdata.
n1);
416 auto plan_f = modes_hosgrid::planner_flags::estimate;
417 if (fftw_planner_flag ==
"patient") {
418 plan_f = modes_hosgrid::planner_flags::patient;
419 }
else if (fftw_planner_flag ==
"exhaustive") {
420 plan_f = modes_hosgrid::planner_flags::exhaustive;
421 }
else if (fftw_planner_flag ==
"measure") {
422 plan_f = modes_hosgrid::planner_flags::measure;
423 }
else if (!(fftw_planner_flag ==
"estimate")) {
425 <<
"WARNING (waves2amr_ops): invalid fftw_planner_flag "
426 "specified; defaulting to estimate (FFTW_ESTIMATE).\n";
430 wdata.plan_vector.emplace_back(
431 modes_hosgrid::plan_ifftw(
432 wdata.
n0, wdata.
n1, wdata.c_eta_mptr, wdata.plan_out,
435 modes_hosgrid::plan_ifftw_nwt(
436 wdata.
n0, wdata.
n1, wdata.plan_vector, wdata.r_eta_mptr,
437 wdata.plan_out, plan_f);
442 int flag = interp_to_mfab::create_height_vector(
443 wdata.
hvec, nheights, dz0, wdata.
zsl, prob_lo_input[2], nh_above);
447 "Waves2AMR ReadInputsOp: create_height_vector error, failure "
449 std::to_string(flag));
452 amrex::Real z_double{0.0_rt};
453 bool found_z_double{
false};
454 for (
int n = 0; n < wdata.
hvec.size() - 1; ++n) {
455 const amrex::Real dz = wdata.
hvec[n] - wdata.
hvec[n + 1];
456 if (!found_z_double && dz >= 2.0_rt * dz0) {
457 z_double = 0.5_rt * (wdata.
hvec[n] + wdata.
hvec[n + 1]);
458 found_z_double =
true;
463 <<
"OceanWaves: Waves2AMR height vector for interpolation: \n"
464 <<
" start " << wdata.
hvec[0] <<
" end "
465 << wdata.
hvec[wdata.
hvec.size() - 1] <<
" num points "
466 << wdata.
hvec.size() << std::endl
467 <<
" initial dz " << wdata.
hvec[0] - wdata.
hvec[1]
468 <<
" first two grown dz "
469 << wdata.
hvec[nh_above] - wdata.
hvec[nh_above + 1] <<
" "
470 << wdata.
hvec[nh_above + 1] - wdata.
hvec[nh_above + 2]
472 << wdata.
hvec[wdata.
hvec.size() - 2] -
476 if (found_z_double) {
478 <<
" interp spacing reaches double that of surface at "
479 << z_double << std::endl;
481 amrex::Print() <<
" interp spacing remains less than double "
489 ? wdata.c_rmodes.get_data(
492 : wdata.r_rmodes.get_data(
500 <<
"WARNING (waves2amr_ops): end of mode data file "
501 "detected, resetting to beginning of mode data.\n";
505 ? wdata.c_rmodes.get_data(
508 : wdata.r_rmodes.get_data(
514 "waves2amr_ops: end of mode data file detected after "
515 "resetting to beginning; please evaluate HOS_init_time "
516 "or HOS_init_timestep and check the length of the mode "
523 modes_hosgrid::copy_complex(
524 wdata.
n0, wdata.
n1, wdata.
c_mFS, wdata.c_eta_mptr);
526 static_cast<size_t>(wdata.
n0) *
static_cast<size_t>(wdata.
n1),
528 modes_hosgrid::populate_hos_eta(
529 wdata.c_rmodes, wdata.plan_vector, wdata.c_eta_mptr,
532 const auto n_hts = wdata.
hvec.size();
534 static_cast<size_t>(wdata.
n0 * wdata.
n1) * n_hts);
536 static_cast<size_t>(wdata.
n0 * wdata.
n1) * n_hts);
538 static_cast<size_t>(wdata.
n0 * wdata.
n1) * n_hts);
539 for (
int iht = 0; iht < static_cast<int>(n_hts); ++iht) {
541 amrex::Real ht = wdata.
hvec[iht];
543 modes_hosgrid::populate_hos_vel(
544 wdata.c_rmodes, ht, wdata.
zsl, wdata.
c_mX, wdata.
c_mY,
545 wdata.
c_mZ, wdata.plan_vector, wdata.c_u_mptr,
546 wdata.c_v_mptr, wdata.c_w_mptr, wdata.
sp_u_vec,
550 modes_hosgrid::copy_real(
551 wdata.
n0, wdata.
n1, wdata.
r_mFS, wdata.r_eta_mptr);
553 static_cast<size_t>(wdata.
n0) *
static_cast<size_t>(wdata.
n1),
555 modes_hosgrid::populate_hos_eta(
556 wdata.r_rmodes, wdata.plan_vector, wdata.r_eta_mptr,
559 const auto n_hts = wdata.
hvec.size();
561 static_cast<size_t>(wdata.
n0 * wdata.
n1) * n_hts);
563 static_cast<size_t>(wdata.
n0 * wdata.
n1) * n_hts);
565 static_cast<size_t>(wdata.
n0 * wdata.
n1) * n_hts);
566 for (
int iht = 0; iht < static_cast<int>(n_hts); ++iht) {
568 amrex::Real ht = wdata.
hvec[iht];
570 modes_hosgrid::populate_hos_vel(
571 wdata.r_rmodes, ht, wdata.
zsl, wdata.
r_mX, wdata.
r_mY,
572 wdata.
r_mZ, wdata.
r_mAdd, wdata.plan_vector, wdata.r_u_mptr,
573 wdata.r_v_mptr, wdata.r_w_mptr, wdata.au_mptr,
574 wdata.av_mptr, wdata.aw_mptr, wdata.
sp_u_vec,
583 "w2a_velocity", AMREX_SPACEDIM, 3, 2);
587 w2a_velocity.set_default_fillpatch_bc(data.
sim().
time());
598 const amrex::Geometry& geom,
599 bool multiphase_mode)
602#ifdef KYNEMA_SGF_USE_W2A
603 auto& wdata = data.
meta();
605 auto& sim = data.
sim();
619 Field* levelset{
nullptr};
620 if (multiphase_mode) {
624 const auto& problo = geom.ProbLoArray();
625 const auto& probhi = geom.ProbHiArray();
626 const auto& dx = geom.CellSizeArray();
632 amrex::Vector<int> indvec(wdata.
hvec.size());
633 std::iota(indvec.begin(), indvec.end(), 0);
635 interp_to_mfab::interp_eta_to_levelset_multifab(
638 ow_levelset(level), problo, dx);
639 interp_to_mfab::interp_velocity_to_multifab(
645 const auto& ow_phi = ow_levelset(level).const_arrays();
646 const auto& ow_vel = ow_velocity(level).const_arrays();
647 const auto& vel = velocity(level).arrays();
648 const auto& phi_arrs = multiphase_mode
649 ? (*levelset)(level).arrays()
650 : amrex::MultiArray4<amrex::Real>();
652 const auto& w2a_phi = w2a_levelset(level).arrays();
653 const auto& w2a_vel = w2a_velocity(level).arrays();
654 const auto& w2a_phi_o = w2a_lvs_old(level).arrays();
655 const auto& w2a_vel_o = w2a_vel_old(level).arrays();
657 const amrex::Real gen_length = wdata.
gen_length;
660 const amrex::Real zero_sea_level = wdata.
zsl;
662 const bool has_beach = wdata.
has_beach && multiphase_mode;
663 const bool init_wave_field = wdata.
init_wave_field || !multiphase_mode;
665 amrex::MultiFab phi_tmp_fab(
666 velocity(level).boxArray(), velocity(level).DistributionMap(), 1,
668 amrex::MultiFab vel_tmp_fab(
669 velocity(level).boxArray(), velocity(level).DistributionMap(),
672 const auto& phi_tmp = phi_tmp_fab.arrays();
673 const auto& vel_tmp = vel_tmp_fab.arrays();
676 velocity(level), amrex::IntVect(3),
677 [=] AMREX_GPU_DEVICE(
int nbx,
int i,
int j,
int k) {
678 const amrex::Real x = problo[0] + (i + 0.5_rt) * dx[0];
679 const amrex::Real y = problo[1] + (j + 0.5_rt) * dx[1];
680 const amrex::Real z = problo[2] + (k + 0.5_rt) * dx[2];
684 ow_vel[nbx](i, j, k, 0), ow_vel[nbx](i, j, k, 1),
685 ow_vel[nbx](i, j, k, 2), ow_phi[nbx](i, j, k) + z};
688 0.0_rt, 0.0_rt, 0.0_rt, zero_sea_level};
691 const auto bulk = init_wave_field ? wave_sol : quiescent;
692 const auto outlet = has_beach ? quiescent : wave_sol;
695 x, y, problo[0], gen_length, probhi[0], beach_length,
696 problo[1], probhi[1], y_length, wave_sol, bulk, outlet);
698 phi_tmp[nbx](i, j, k) = local_profile[3] - z;
699 vel_tmp[nbx](i, j, k, 0) = local_profile[0];
700 vel_tmp[nbx](i, j, k, 1) = local_profile[1];
701 vel_tmp[nbx](i, j, k, 2) = local_profile[2];
703 if (multiphase_mode) {
704 phi_arrs[nbx](i, j, k) = phi_tmp[nbx](i, j, k);
709 w2a_phi_o[nbx](i, j, k) = wave_sol[3] - z;
710 w2a_vel_o[nbx](i, j, k, 0) = wave_sol[0];
711 w2a_vel_o[nbx](i, j, k, 1) = wave_sol[1];
712 w2a_vel_o[nbx](i, j, k, 2) = wave_sol[2];
715 w2a_phi[nbx](i, j, k) = quiescent[3] - z;
716 w2a_vel[nbx](i, j, k, 0) = quiescent[0];
717 w2a_vel[nbx](i, j, k, 1) = quiescent[1];
718 w2a_vel[nbx](i, j, k, 2) = quiescent[2];
720 amrex::Gpu::streamSynchronize();
723 velocity(level), amrex::IntVect(2),
724 [=] AMREX_GPU_DEVICE(
int nbx,
int i,
int j,
int k) {
725 const amrex::Real eps =
726 2.0_rt * std::cbrt(dx[0] * dx[1] * dx[2]);
727 const amrex::Real vof_local =
732 vel[nbx](i, j, k, 0) = vel_tmp[nbx](i, j, k, 0);
733 vel[nbx](i, j, k, 1) = vel_tmp[nbx](i, j, k, 1);
734 vel[nbx](i, j, k, 2) = vel_tmp[nbx](i, j, k, 2);
735 }
else if (vof_local > 1.0e-3_rt) {
739 const amrex::Real z_cell = problo[2] + (k + 0.5_rt) * dx[2];
740 const amrex::Real z_cell_below = z_cell - dx[2];
741 const amrex::Real z_cell_bottom = z_cell - 0.5_rt * dx[2];
742 const amrex::Real z_liq_center =
743 z_cell_bottom + 0.5_rt * vof_local * dx[2];
744 for (
int n = 0; n < AMREX_SPACEDIM; ++n) {
745 vel[nbx](i, j, k, n) =
746 vel_tmp[nbx](i, j, k - 1, n) +
747 (vel_tmp[nbx](i, j, k, n) -
748 vel_tmp[nbx](i, j, k - 1, n)) *
749 ((z_liq_center - z_cell_below) /
754 amrex::Gpu::streamSynchronize();
756 amrex::ignore_unused(data, level, geom, multiphase_mode);
767#ifdef KYNEMA_SGF_USE_W2A
768 auto& wdata = data.
meta();
769 auto& sim = data.
sim();
784 auto nlevels = sim.repo().num_active_levels();
785 auto geom = sim.mesh().Geom();
788 amrex::Real t_last = wdata.
t_last;
791 bool read_flag =
false;
795 ? wdata.c_rmodes.time2step(time + wdata.
t_winit, wdata.
ntime)
796 : wdata.r_rmodes.time2step(time + wdata.
t_winit, wdata.
ntime);
797 int double_data = evaluate_read_resize(
809 <<
"WARNING (waves2amr_ops): available mode data exceeded, "
810 "resetting to beginning of mode data.\n";
823 amrex::Print() <<
"OceanWaves: Waves2AMR reading from file: step "
824 << wdata.
ntime << std::endl
825 <<
" last interp time " << t_last << std::endl
826 <<
" simulation time " << time << std::endl
827 <<
" new data time " << wdata.
t << std::endl
828 <<
" double data read " << double_data
836 bool flag_xlo =
false;
837 bool flag_xhi =
false;
838 bool flag_ylo =
false;
839 bool flag_yhi =
false;
842 (interp_to_mfab::get_local_height_indices(
843 wdata.
indvec, wdata.
hvec, ow_velocity.vec_ptrs(),
849 (interp_to_mfab::check_lateral_overlap_lo(
850 wdata.
gen_length, 0, ow_velocity.vec_ptrs(), geom) ==
856 (interp_to_mfab::check_lateral_overlap_hi(
863 (interp_to_mfab::check_lateral_overlap_lo(
867 (interp_to_mfab::check_lateral_overlap_hi(
879 if (flag_z && (flag_xlo || flag_xhi || flag_ylo || flag_yhi)) {
884 static_cast<size_t>(wdata.
n0) *
885 static_cast<size_t>(wdata.
n1),
888 static_cast<size_t>(wdata.
n0 * wdata.
n1) *
891 static_cast<size_t>(wdata.
n0 * wdata.
n1) *
894 static_cast<size_t>(wdata.
n0 * wdata.
n1) *
905 amrex::ParallelDescriptor::ReduceIntMax(wdata.
n_offset);
910 if (double_data == 0) {
913 w2a_lvs_old, w2a_levelset, 0, 0, 1,
914 w2a_levelset.num_grow());
916 w2a_vel_old, w2a_velocity, 0, 0, AMREX_SPACEDIM,
917 w2a_velocity.num_grow());
918 }
else if (double_data == 1) {
921 populate_fields_all_levels(
922 wdata, geom, w2a_lvs_old, w2a_vel_old, -1);
927 for (
int lev = nlevels - 1; lev > 0; --lev) {
929 w2a_vel_old(lev), w2a_vel_old(lev - 1), 0,
930 AMREX_SPACEDIM, sim.mesh().refRatio(lev - 1));
932 w2a_lvs_old(lev), w2a_lvs_old(lev - 1), 0, 1,
933 sim.mesh().refRatio(lev - 1));
936 w2a_vel_old.fillpatch(sim.time().new_time());
937 w2a_lvs_old.fillpatch(sim.time().new_time());
943 populate_fields_all_levels(
944 wdata, geom, w2a_levelset, w2a_velocity);
949 for (
int lev = nlevels - 1; lev > 0; --lev) {
951 w2a_velocity(lev), w2a_velocity(lev - 1), 0, AMREX_SPACEDIM,
952 sim.mesh().refRatio(lev - 1));
953 w2a_velocity(lev - 1).FillBoundary(geom[lev - 1].periodicity());
955 w2a_levelset(lev), w2a_levelset(lev - 1), 0, 1,
956 sim.mesh().refRatio(lev - 1));
957 w2a_levelset(lev - 1).FillBoundary(geom[lev - 1].periodicity());
962 time_interpolate_wave_fields(
963 w2a_lvs_old, w2a_vel_old, w2a_levelset, w2a_velocity, t_last, time,
967 ow_levelset, w2a_lvs_old, 0, 0, 1, ow_levelset.num_grow());
969 ow_velocity, w2a_vel_old, 0, 0, AMREX_SPACEDIM,
970 ow_velocity.num_grow());
972 amrex::ignore_unused(data, time);
FieldRepo & repo()
Return the field repository.
Definition CFDSim.H:76
SimTime & time()
Return simulation time control.
Definition CFDSim.H:66
const amrex::IntVect & num_grow() const
Ghost cells.
Definition Field.H:139
Field & state(FieldState fstate)
Return field at a different time state.
Definition Field.cpp:118
amrex::Vector< amrex::MultiFab * > vec_ptrs()
Return a vector of MultiFab pointers for all levels.
Definition Field.cpp:146
void set_default_fillpatch_bc(const SimTime &time, amrex::BCType::mathematicalBndryTypes bctype=amrex::BCType::hoextrap)
Definition Field.cpp:539
FieldRepo & repo() const
FieldRepo instance that manages this field.
Definition Field.H:164
Field & get_field(const std::string &name, FieldState fstate=FieldState::New) const
Definition FieldRepo.cpp:152
bool field_exists(const std::string &name, FieldState fstate=FieldState::New) const
Query if field uniquely identified by name and time state exists in repository.
Definition FieldRepo.cpp:218
Field & declare_field(const std::string &name, int ncomp=1, int ngrow=0, int nstates=1, FieldLoc floc=FieldLoc::CELL)
Definition FieldRepo.cpp:86
OceanWavesTrait::InfoType & info()
Definition OceanWavesTypes.H:86
OceanWavesTrait::MetaType & meta()
Definition OceanWavesTypes.H:92
CFDSim & sim()
Definition OceanWavesTypes.H:83
void copy(T1 &dst, const T2 &src, const int srccomp, const int dstcomp, const int numcomp, const amrex::IntVect &nghost)
Definition field_ops.H:157
void lincomb(T1 &dst, const amrex::Real a, const T2 &x, const int xcomp, const amrex::Real b, const T3 &y, const int ycomp, const int dstcomp, const int numcomp, const amrex::IntVect &nghost)
Definition field_ops.H:320
@ Old
Same as FieldState::N.
Definition FieldDescTypes.H:23
static constexpr amrex::Real VOF_TOL
Tolerance for vof determining presence of liquid.
Definition constants.H:34
static constexpr amrex::Real TIGHT_TOL
A tight tolerance.
Definition constants.H:17
static constexpr amrex::Real EPS
A number very close to zero.
Definition constants.H:13
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real levelset_to_vof(const int i, const int j, const int k, const amrex::Real eps, amrex::Array4< amrex::Real const > const &phi)
Definition volume_fractions.H:567
Definition OceanWavesOps.H:8
void read_inputs(RelaxZonesBaseData &wdata, OceanWavesInfo &, const ::kynema_sgf::utils::MultiParser &pp)
Definition relaxation_zones_ops.cpp:17
amrex::GpuArray< amrex::Real, 4 > WaveVec
Definition wave_utils_K.H:14
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE WaveVec harmonize_profiles_2d(const amrex::Real x, const amrex::Real y, const amrex::Real left_bdy, const amrex::Real left_length, const amrex::Real right_bdy, const amrex::Real right_length, const amrex::Real lo_y_bdy, const amrex::Real hi_y_bdy, const amrex::Real y_length, const WaveVec left, const WaveVec bulk, const WaveVec right)
Definition wave_utils_K.H:110
bool regrid_occurred
Definition RelaxationZones.H:45
bool has_beach
Definition RelaxationZones.H:41
amrex::Real zone_length_y
Definition RelaxationZones.H:33
amrex::Real zsl
Definition RelaxationZones.H:20
amrex::Real gen_length
Definition RelaxationZones.H:28
bool init_wave_field
Definition RelaxationZones.H:37
amrex::Real current
Definition RelaxationZones.H:35
amrex::Real beach_length
Definition RelaxationZones.H:30
bool resize_flag
Definition W2AWaves.H:85
amrex::Real dx1
Definition W2AWaves.H:29
int n_winit
Definition W2AWaves.H:44
int ntime
Definition W2AWaves.H:42
amrex::Gpu::DeviceVector< amrex::Real > sp_w_vec
Definition W2AWaves.H:88
std::vector< std::complex< amrex::Real > > c_mY
Definition W2AWaves.H:57
std::vector< std::complex< amrex::Real > > c_mX
Definition W2AWaves.H:57
std::string modes_file
Definition W2AWaves.H:19
std::vector< amrex::Real > r_mAdd
Definition W2AWaves.H:58
amrex::Real dt_modes
Definition W2AWaves.H:36
amrex::Real xlo1
Definition W2AWaves.H:32
amrex::Real dx0
Definition W2AWaves.H:28
int n2
Definition W2AWaves.H:23
int n1_sp
Definition W2AWaves.H:26
std::vector< amrex::Real > r_mFS
Definition W2AWaves.H:58
int n1
Definition W2AWaves.H:22
int n0_sp
Definition W2AWaves.H:25
amrex::Real xlo0
Definition W2AWaves.H:31
amrex::Real t_last
Definition W2AWaves.H:52
amrex::Real t_winit
Definition W2AWaves.H:40
std::vector< amrex::Real > r_mX
Definition W2AWaves.H:58
amrex::Gpu::DeviceVector< amrex::Real > sp_eta_vec
Definition W2AWaves.H:87
amrex::Gpu::DeviceVector< amrex::Real > sp_u_vec
Definition W2AWaves.H:87
bool do_interp
Definition W2AWaves.H:83
int n_wstop
Definition W2AWaves.H:46
amrex::Real dimL
Definition W2AWaves.H:34
amrex::Real t
Definition W2AWaves.H:54
int n0
Definition W2AWaves.H:21
amrex::Vector< int > indvec
Definition W2AWaves.H:79
std::vector< std::complex< amrex::Real > > c_mFS
Definition W2AWaves.H:57
bool is_ocean
Definition W2AWaves.H:81
std::vector< std::complex< amrex::Real > > c_mZ
Definition W2AWaves.H:57
std::vector< amrex::Real > r_mZ
Definition W2AWaves.H:58
std::vector< amrex::Real > r_mY
Definition W2AWaves.H:58
int n_offset
Definition W2AWaves.H:48
amrex::Vector< amrex::Real > hvec
Definition W2AWaves.H:77
amrex::Gpu::DeviceVector< amrex::Real > sp_v_vec
Definition W2AWaves.H:87
Definition W2AWaves.H:138
OceanWavesDataHolder< W2AWaves > DataType
Definition W2AWaves.H:141
W2AWavesData MetaType
Definition W2AWaves.H:140
void operator()(W2AWaves::DataType &data, int level, const amrex::Geometry &geom, bool multiphase_mode)
Definition waves2amr_ops.H:595
Definition OceanWavesOps.H:14
void operator()(W2AWaves::DataType &data, const amrex::Real time)
Definition waves2amr_ops.H:764
Definition OceanWavesOps.H:17