Skip to content

Commit

Permalink
Merge branch 'xrb_layered' of github.com:zingale/Castro into xrb_layered
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale committed Sep 14, 2023
2 parents 01074af + 6a61340 commit 78e47e9
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Exec/Make.Castro
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ ifeq ($(USE_CXX_MODEL_PARSER), TRUE)
DEFINES += -DCXX_MODEL_PARSER -DNPTS_MODEL=$(MAX_NPTS_MODEL) -DNUM_MODELS=$(NUM_MODELS)
endif

ifeq ($(USE_RNG_STATE_INIT), TRUE)
DEFINES += -DRNG_STATE_INIT
endif

# add / define any special physics we need

ifeq ($(USE_MHD), TRUE)
Expand Down
1 change: 1 addition & 0 deletions Exec/science/xrb_layered/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ USE_GRAV = TRUE
USE_REACT = TRUE

USE_CXX_MODEL_PARSER = TRUE
USE_RNG_STATE_INIT = TRUE

CASTRO_HOME = ../../..

Expand Down
5 changes: 3 additions & 2 deletions Exec/science/xrb_layered/problem_initialize_state_data.H
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
AMREX_GPU_HOST_DEVICE AMREX_INLINE
void problem_initialize_state_data (int i, int j, int k,
Array4<Real> const& state,
const GeometryData& geomdata)
const GeometryData& geomdata,
amrex::RandomEngine const& engine)
{

const Real* dx = geomdata.CellSize();
Expand Down Expand Up @@ -78,7 +79,7 @@ void problem_initialize_state_data (int i, int j, int k,

// mean of 1, std dev of 1.e-3

state(i,j,k,UTEMP) *= amrex::RandomNormal(1.0, 0.001);
state(i,j,k,UTEMP) *= amrex::RandomNormal(1.0, 0.001, engine);
eos_state.T = state(i,j,k,UTEMP);

// recompute the density with this new temperature
Expand Down
9 changes: 9 additions & 0 deletions Source/driver/Castro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1105,12 +1105,21 @@ Castro::initData ()
auto s = S_new[mfi].array();
auto geomdata = geom.data();

#ifdef RNG_STATE_INIT
amrex::ParallelForRNG(box,
[=] AMREX_GPU_HOST_DEVICE (int i, int j, int k, amrex::RandomEngine const& engine) noexcept
{
// problem initialization
problem_initialize_state_data(i, j, k, s, geomdata, engine);
});
#else
amrex::ParallelFor(box,
[=] AMREX_GPU_HOST_DEVICE (int i, int j, int k)
{
// problem initialization
problem_initialize_state_data(i, j, k, s, geomdata);
});
#endif
}


Expand Down
5 changes: 5 additions & 0 deletions Source/driver/Castro_advance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,9 @@ Castro::initialize_advance(Real time, Real dt, int amr_iteration)
auto s = S_old[mfi].array();
auto geomdata = geom.data();

#ifdef RNG_STATE_INIT
amrex::Error("drive initial convection not yet supported for random initialization");
#else
amrex::ParallelFor(box,
[=] AMREX_GPU_HOST_DEVICE (int i, int j, int k)
{
Expand All @@ -449,6 +452,8 @@ Castro::initialize_advance(Real time, Real dt, int amr_iteration)
(vx_orig * vx_orig + vy_orig * vy_orig + vz_orig * vz_orig);

});
#endif

}

}
Expand Down
4 changes: 4 additions & 0 deletions Source/driver/Castro_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,17 @@ Castro::restart (Amr& papa,
auto s = S_new[mfi].array();
auto geomdata = geom.data();

#ifdef RNG_STATE_INIT
amrex::Error("Error: random initialization not yet supported with grown factor");
#else
amrex::ParallelFor(bx,
[=] AMREX_GPU_HOST_DEVICE (int i, int j, int k)
{
// C++ problem initialization; has no effect if not implemented
// by a problem setup (defaults to an empty routine).
problem_initialize_state_data(i, j, k, s, geomdata);
});
#endif
}
}
}
Expand Down

0 comments on commit 78e47e9

Please sign in to comment.