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

Method get_old_grav_vector

Source/gravity/Gravity.cpp:853–928  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

851}
852
853void
854Gravity::get_old_grav_vector(int level, MultiFab& grav_vector, Real time)
855{
856 BL_PROFILE("Gravity::get_old_grav_vector()");
857
858 int ng = grav_vector.nGrow();
859
860 // Fill data from the level below if we're not doing a solve on this level.
861
862 if (level > gravity::max_solve_level) {
863
864 LevelData[level]->FillCoarsePatch(grav_vector,0,time,Gravity_Type,0,3,ng);
865
866 return;
867
868 }
869
870 // Note that grav_vector coming into this routine always has three components.
871 // So we'll define a temporary MultiFab with AMREX_SPACEDIM dimensions.
872 // Then at the end we'll copy in all AMREX_SPACEDIM dimensions from this into
873 // the outgoing grav_vector, leaving any higher dimensions unchanged.
874
875 MultiFab grav(grids[level], dmap[level], AMREX_SPACEDIM, ng);
876 grav.setVal(0.0,ng);
877
878 const Geometry& geom = parent->Geom(level);
879
880 if (gravity::gravity_type == "ConstantGrav") {
881
882 if (AMREX_SPACEDIM == 2 && geom.Coord() == 2) {
883 // 2D spherical r-theta, we want g in the radial direction
884 grav.setVal(gravity::const_grav, 0, 1, ng);
885 } else {
886 // Set to constant value in the AMREX_SPACEDIM direction and zero in all others.
887 grav.setVal(gravity::const_grav, AMREX_SPACEDIM-1, 1, ng);
888 }
889
890 } else if (gravity::gravity_type == "MonopoleGrav") {
891
892 const Real prev_time = LevelData[level]->get_state_data(State_Type).prevTime();
893 make_radial_gravity(level,prev_time,radial_grav_old[level]);
894 interpolate_monopole_grav(level,radial_grav_old[level],grav);
895
896 } else if (gravity::gravity_type == "PoissonGrav") {
897
898 amrex::average_face_to_cellcenter(grav, amrex::GetVecOfConstPtrs(grad_phi_prev[level]), geom);
899 grav.mult(-1.0, ng); // g = - grad(phi)
900
901 } else {
902 amrex::Abort("Unknown gravity_type in get_old_grav_vector");
903 }
904
905 // Do the copy to the output vector.
906
907 for (int dir = 0; dir < 3; dir++) {
908 if (dir < AMREX_SPACEDIM) {
909 MultiFab::Copy(grav_vector, grav, dir, dir, 1, ng);
910 } else {

Callers 1

construct_old_gravityMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected