From ca4db7a81add969d585d90cac31cc0c26201b299 Mon Sep 17 00:00:00 2001 From: Michael Kuhn Date: Fri, 22 Nov 2024 14:17:35 -0700 Subject: [PATCH] init tweaks to w2a --- .../relaxation_zones/waves2amr_ops.H | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/amr-wind/ocean_waves/relaxation_zones/waves2amr_ops.H b/amr-wind/ocean_waves/relaxation_zones/waves2amr_ops.H index 4fc396e58a..4645ca7c72 100644 --- a/amr-wind/ocean_waves/relaxation_zones/waves2amr_ops.H +++ b/amr-wind/ocean_waves/relaxation_zones/waves2amr_ops.H @@ -420,9 +420,13 @@ struct InitDataOp // 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(); @@ -449,18 +453,21 @@ struct InitDataOp 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(); 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( @@ -484,14 +491,17 @@ struct InitDataOp 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; + } }); }