MCPcopy Create free account
hub / github.com/AMReX-Astro/Castro / construct_old_gravity_source

Method construct_old_gravity_source

Source/gravity/Castro_gravity.cpp:300–452  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

298}
299
300void Castro::construct_old_gravity_source(MultiFab& source, MultiFab& state_in, Real time, Real dt)
301{
302
303 amrex::ignore_unused(time);
304
305 BL_PROFILE("Castro::construct_old_gravity_source()");
306
307 const Real strt_time = ParallelDescriptor::second();
308
309 const MultiFab& grav_old = get_old_data(Gravity_Type);
310
311 if (!do_grav) {
312 return;
313 }
314
315 // Gravitational source term for the time-level n data.
316
317#ifdef HYBRID_MOMENTUM
318 GeometryData geomdata = geom.data();
319#endif
320
321 AMREX_ALWAYS_ASSERT(castro::grav_source_type >= 1 && castro::grav_source_type <= 4);
322
323#ifdef _OPENMP
324#pragma omp parallel
325#endif
326 for (MFIter mfi(state_in, TilingIfNotGPU()); mfi.isValid(); ++mfi)
327 {
328 const Box& bx = mfi.tilebox();
329
330 Array4<Real const> const uold = state_in.array(mfi);
331 Array4<Real const> const grav = grav_old.array(mfi);
332 Array4<Real> const source_arr = source.array(mfi);
333
334 amrex::ParallelFor(bx,
335 [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
336 {
337 // Temporary array for seeing what the new state would be if the update were applied here.
338
339 GpuArray<Real, NUM_STATE> snew;
340 for (int n = 0; n < NUM_STATE; ++n) {
341 snew[n] = 0.0_rt;
342 }
343
344 // Temporary array for holding the update to the state.
345
346 GpuArray<Real, NSRC> src;
347 for (int n = 0; n < NSRC; ++n) {
348 src[n] = 0.0_rt;
349 }
350
351 // Gravitational source options for how to add the work to (rho E):
352 // grav_source_type =
353 // 1: Original version ("does work")
354 // 2: Modification of type 1 that updates the momentum before constructing the energy corrector
355 // 3: Puts all gravitational work into KE, not (rho e)
356 // 4: Conservative energy formulation
357

Callers 1

update_relaxationMethod · 0.80

Calls 3

positionFunction · 0.85
isValidMethod · 0.80

Tested by

no test coverage detected