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

Method construct_new_gravity_source

Source/gravity/Castro_gravity.cpp:454–691  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

452}
453
454void Castro::construct_new_gravity_source(MultiFab& source, MultiFab& state_old, MultiFab& state_new,
455 Real time, Real dt)
456{
457
458 amrex::ignore_unused(time);
459
460 BL_PROFILE("Castro::construct_new_gravity_source()");
461
462 const Real strt_time = ParallelDescriptor::second();
463
464 MultiFab& grav_old = get_old_data(Gravity_Type);
465 MultiFab& grav_new = get_new_data(Gravity_Type);
466
467 if (!do_grav) {
468 return;
469 }
470
471 GpuArray<Real, 3> dx;
472 for (int i = 0; i < AMREX_SPACEDIM; ++i) {
473 dx[i] = geom.CellSizeArray()[i];
474 }
475 for (int i = AMREX_SPACEDIM; i < 3; ++i) {
476 dx[i] = 0.0_rt;
477 }
478
479#ifdef HYBRID_MOMENTUM
480 GeometryData geomdata = geom.data();
481#endif
482
483 AMREX_ALWAYS_ASSERT(castro::grav_source_type >= 1 && castro::grav_source_type <= 4);
484
485#ifdef _OPENMP
486#pragma omp parallel
487#endif
488 {
489 for (MFIter mfi(state_new, TilingIfNotGPU()); mfi.isValid(); ++mfi)
490 {
491 const Box& bx = mfi.tilebox();
492
493 Array4<Real const> const uold = state_old.array(mfi);
494 Array4<Real const> const unew = state_new.array(mfi);
495 Array4<Real const> const gold = grav_old.array(mfi);
496 Array4<Real const> const gnew = grav_new.array(mfi);
497 Array4<Real const> const vol = volume.array(mfi);
498 Array4<Real const> const flux0 = (*mass_fluxes[0]).array(mfi);
499 Array4<Real const> const flux1 = (*mass_fluxes[1]).array(mfi);
500 Array4<Real const> const flux2 = (*mass_fluxes[2]).array(mfi);
501 Array4<Real> const source_arr = source.array(mfi);
502
503 amrex::ParallelFor(bx,
504 [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
505 {
506 GpuArray<Real, NSRC> src{};
507
508 Real hdtInv = 0.5_rt / dt;
509
510 // Gravitational source options for how to add the work to (rho E):
511 // grav_source_type =

Callers

nothing calls this directly

Calls 3

positionFunction · 0.85
isValidMethod · 0.80

Tested by

no test coverage detected