-
Hi, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
Hi, the user can access the PeleC member function |
Beta Was this translation helpful? Give feedback.
-
Hi @marchdf, Based on your inputs, I worked out a more digestible and general version of this function. Just posting it for the clarity of other users. void
PeleC::problem_post_restart()
{
amrex::MultiFab& S_new = get_new_data(State_Type);
for (amrex::MFIter mfi(S_new, amrex::TilingIfNotGPU()); mfi.isValid();
++mfi) {
const amrex::Box& box = mfi.tilebox();
auto state = S_new.array(mfi);
const auto geomdata = geom.data();
const amrex::Real* prob_lo = geomdata.ProbLo();
const amrex::Real* dx = geomdata.CellSize();
const ProbParmDevice* lprobparm = d_prob_parm_device;
#ifdef _OPENMP
#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
#endif
amrex::ParallelFor(box, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
// compute the local coordinates
amrex::Real x[3];
x[0] = prob_lo[0] + (i + 0.5) * dx[0];
x[1] = prob_lo[1] + (j + 0.5) * dx[1];
x[2] = prob_lo[2] + (k + 0.5) * dx[2];
pc_post_restart(i, j, k, x, state, lprobparm);
});
}
} Where we define the function AMREX_GPU_DEVICE
AMREX_FORCE_INLINE
void
pc_post_restart(int i, int j, int k,
const amrex::Real x[AMREX_SPACEDIM],
const amrex::Array4<amrex::Real>& state,
const ProbParmDevice* const prob_parm)
{
// custom function on the lines of pc_initdata
} Example: let's say in AMREX_GPU_DEVICE
AMREX_FORCE_INLINE
void
pc_post_restart(int i, int j, int k,
const amrex::Real x[AMREX_SPACEDIM],
const amrex::Array4<amrex::Real>& state,
const ProbParmDevice* const prob_parm)
{
if (x[0]>7.0 && x[0]<10.0 && x[1]>2 && x[1]<4)
{
std::cout<<"\n I am here!";
amrex::Real p = 1013250.0;
amrex::Real T = 1000; //set a large temperature value
amrex::Real rho, e;
auto eos = pele::physics::PhysicsType::eos();
eos.PYT2RE(
p, PeleC::h_prob_parm_device->massfrac.begin(),
T, rho, e);
state(i, j, k, UTEMP) = T;
state(i, j, k, URHO) = rho;
state(i, j, k, UEINT) = rho*e;
state(i, j, k, UEDEN) = rho*
(e + 0.5 * (prob_parm->vx_in * prob_parm->vx_in +
prob_parm->vy_in * prob_parm->vy_in));
}
} Thanks once again! |
Beta Was this translation helpful? Give feedback.
Hi, the user can access the PeleC member function
problem_post_restart()
. It is defined empty in almost all problems right now. Presumably, one could grab the state multifab in there, and then write anMFIter
loop and modify the state. That might work.