Skip to content

Commit

Permalink
init tweaks to w2a
Browse files Browse the repository at this point in the history
  • Loading branch information
mbkuhn committed Nov 22, 2024
1 parent 96d8b3e commit ca4db7a
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions amr-wind/ocean_waves/relaxation_zones/waves2amr_ops.H
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,13 @@ struct InitDataOp<W2AWaves>
// Fill ow fields, then populate flow fields according to setup
auto& ow_levelset = sim.repo().get_field("ow_levelset");
auto& ow_velocity = sim.repo().get_field("ow_velocity");
auto& levelset = sim.repo().get_field("levelset");
auto& velocity = sim.repo().get_field("velocity");

Field* levelset{nullptr};
if (multiphase_mode) {
levelset = &sim.repo().get_field("levelset");
}

const auto& problo = geom.ProbLoArray();
const auto& probhi = geom.ProbHiArray();
const auto& dx = geom.CellSizeArray();
Expand All @@ -449,18 +453,21 @@ struct InitDataOp<W2AWaves>
ow_velocity(level), ow_levelset(level), dx);

// Populate flow fields according to intended forcing and init setup
for (amrex::MFIter mfi(levelset(level)); mfi.isValid(); ++mfi) {
for (amrex::MFIter mfi(velocity(level)); mfi.isValid(); ++mfi) {
const auto& ow_phi = ow_levelset(level).array(mfi);
const auto& ow_vel = ow_velocity(level).array(mfi);
const auto& phi = levelset(level).array(mfi);
const auto& vel = velocity(level).array(mfi);
const auto& phi_arr = multiphase_mode
? (*levelset)(level).array(mfi)
: amrex::Array4<amrex::Real>();

const amrex::Real gen_length = wdata.gen_length;
const amrex::Real beach_length = wdata.beach_length;
const amrex::Real zero_sea_level = wdata.zsl;

const bool has_beach = wdata.has_beach;
const bool init_wave_field = wdata.init_wave_field;
const bool has_beach = wdata.has_beach && multiphase_mode;
const bool init_wave_field =
wdata.init_wave_field || !multiphase_mode;
const auto& gbx3 = mfi.growntilebox(3);

amrex::ParallelFor(
Expand All @@ -484,14 +491,17 @@ struct InitDataOp<W2AWaves>
x, problo[0], gen_length, probhi[0], beach_length,
wave_sol, bulk, outlet);

phi(i, j, k) = local_profile[3] - z;
const amrex::Real phi = local_profile[3] - z;
const amrex::Real cell_length_2D =
std::sqrt(dx[0] * dx[0] + dx[2] * dx[2]);
if (phi(i, j, k) + cell_length_2D >= 0) {
if (phi + cell_length_2D >= 0) {
vel(i, j, k, 0) = local_profile[0];
vel(i, j, k, 1) = local_profile[1];
vel(i, j, k, 2) = local_profile[2];
}
if (multiphase_mode) {
phi_arr(i, j, k) = phi;
}
});
}

Expand Down

0 comments on commit ca4db7a

Please sign in to comment.