Skip to content

Commit

Permalink
Merge branch 'development' into updated_scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale authored Jul 9, 2024
2 parents c90d2ce + b373e92 commit 62995f7
Show file tree
Hide file tree
Showing 18 changed files with 59 additions and 47 deletions.
2 changes: 0 additions & 2 deletions Diagnostics/DustCollapse/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ USE_OMP = FALSE

USE_REACT = FALSE

USE_ACC = FALSE

# programs to be compiled
ALL: dustcollapse_$(DIM)d.ex

Expand Down
2 changes: 0 additions & 2 deletions Diagnostics/Radiation/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ USE_OMP = FALSE

USE_REACT = FALSE

USE_ACC = FALSE

ALL: radhelp

radhelp:
Expand Down
2 changes: 0 additions & 2 deletions Diagnostics/Sedov/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ USE_OMP = FALSE

USE_REACT = FALSE

USE_ACC = FALSE

# programs to be compiled
ALL: sedov_$(DIM)d.ex

Expand Down
6 changes: 0 additions & 6 deletions Exec/Make.Castro
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,6 @@ build_status:
# The default is to include the sponge functionality
DEFINES += -DSPONGE

# OpenACC support
ifeq ($(USE_ACC), TRUE)
DEFINES += -DACC
endif



#------------------------------------------------------------------------------
# Castro directories
Expand Down
10 changes: 9 additions & 1 deletion Exec/science/Detonation/problem_initialize_state_data.H
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ void problem_initialize_state_data (int i, int j, int k,

state(i,j,k,URHO) = problem::dens;

Real sigma = 1.0_rt / (1.0_rt + std::exp(-(c_T - xcen)/ width));
Real sigma_arg = -(c_T - xcen) / width;
Real sigma;
// need to avoid FP overflow for sigma_arg >= 709
// 1/(1 + exp(100)) ~= 3e-44, which is much smaller than machine epsilon
if (sigma_arg < 100) {
sigma = 1.0_rt / (1.0_rt + std::exp(sigma_arg));
} else {
sigma = 0.0_rt;
}

state(i,j,k,UTEMP) = problem::T_l + (problem::T_r - problem::T_l) * (1.0_rt - sigma);

Expand Down
1 change: 0 additions & 1 deletion Exec/unit_tests/model_burner/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ COMP = gnu

USE_MPI = TRUE
USE_OMP = FALSE
USE_ACC = FALSE

USE_DIFFUSION = FALSE
USE_GRAV = FALSE
Expand Down
4 changes: 0 additions & 4 deletions Source/driver/Castro.H
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ using namespace castro;

#include <fundamental_constants.H>

constexpr int HISTORY_SIZE=40;
constexpr int PSTAR_BISECT_FACTOR = 5;


#include <AMReX_BC_TYPES.H>
#include <AMReX_AmrLevel.H>
#include <AMReX_iMultiFab.H>
Expand Down
4 changes: 3 additions & 1 deletion Source/driver/Castro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
#include <ambient.H>
#include <castro_limits.H>

#include <riemann_constants.H>

using namespace amrex;

bool Castro::signalStopJob = false;
Expand Down Expand Up @@ -392,7 +394,7 @@ Castro::read_params ()
#endif

if (riemann_solver == 1) {
if (riemann_shock_maxiter > HISTORY_SIZE) {
if (riemann_shock_maxiter > riemann_constants::HISTORY_SIZE) {
amrex::Error("riemann_shock_maxiter > HISTORY_SIZE");
}

Expand Down
1 change: 1 addition & 0 deletions Source/hydro/Make.package
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ CEXE_sources += riemann.cpp
CEXE_headers += HLL_solvers.H
CEXE_headers += riemann_solvers.H
CEXE_headers += riemann_2shock_solvers.H
CEXE_headers += riemann_constants.H
CEXE_headers += riemann_type.H
CEXE_headers += slope.H
CEXE_headers += reconstruction.H
Expand Down
11 changes: 6 additions & 5 deletions Source/hydro/riemann_2shock_solvers.H
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

using namespace amrex::literals;

#include <riemann_constants.H>
#include <riemann_type.H>
#ifdef RADIATION
#include <Radiation.H>
Expand Down Expand Up @@ -60,7 +61,7 @@ namespace TwoShock {
const amrex::Real gdot, const amrex::Real gmin, const amrex::Real gmax,
const int lriemann_shock_maxiter, const amrex::Real lriemann_pstar_tol,
amrex::Real& pstar, amrex::Real& gamstar,
bool& converged, amrex::GpuArray<amrex::Real, PSTAR_BISECT_FACTOR*HISTORY_SIZE>& pstar_hist_extra) {
bool& converged, amrex::GpuArray<amrex::Real, riemann_constants::PSTAR_BISECT_FACTOR * riemann_constants::HISTORY_SIZE>& pstar_hist_extra) {

// we want to zero
// f(p*) = u*_l(p*) - u*_r(p*)
Expand Down Expand Up @@ -106,7 +107,7 @@ namespace TwoShock {
converged = false;
amrex::Real pstar_c = 0.0;

for (int iter = 0; iter < PSTAR_BISECT_FACTOR * lriemann_shock_maxiter; iter++) {
for (int iter = 0; iter < riemann_constants::PSTAR_BISECT_FACTOR * lriemann_shock_maxiter; iter++) {

pstar_c = 0.5_rt * (pstar_lo + pstar_hi);
pstar_hist_extra[iter] = pstar_c;
Expand Down Expand Up @@ -167,7 +168,7 @@ namespace TwoShock {
constexpr amrex::Real weakwv = 1.e-3_rt;

#ifndef AMREX_USE_GPU
amrex::GpuArray<amrex::Real, HISTORY_SIZE> pstar_hist;
amrex::GpuArray<amrex::Real, riemann_constants::HISTORY_SIZE> pstar_hist;
#endif


Expand Down Expand Up @@ -336,7 +337,7 @@ namespace TwoShock {
pstarl = amrex::max(pstarl, small_pres);
pstaru = amrex::max(pstaru, small_pres);

amrex::GpuArray<amrex::Real, PSTAR_BISECT_FACTOR*HISTORY_SIZE> pstar_hist_extra;
amrex::GpuArray<amrex::Real, riemann_constants::PSTAR_BISECT_FACTOR * riemann_constants::HISTORY_SIZE> pstar_hist_extra;

pstar_bisection(pstarl, pstaru,
ql.un, ql.p, taul, gamel, clsql,
Expand All @@ -352,7 +353,7 @@ namespace TwoShock {
std::cout << iter_l << " " << pstar_hist[iter_l] << std::endl;
}
std::cout << "pstar extra history: " << std::endl;
for (int iter_l = 0; iter_l < PSTAR_BISECT_FACTOR * riemann_shock_maxiter; iter_l++) {
for (int iter_l = 0; iter_l < riemann_constants::PSTAR_BISECT_FACTOR * riemann_shock_maxiter; iter_l++) {
std::cout << iter_l << " " << pstar_hist_extra[iter_l] << std::endl;
}

Expand Down
16 changes: 16 additions & 0 deletions Source/hydro/riemann_constants.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef RIEMANN_CONSTANTS_H
#define RIEMANN_CONSTANTS_H

#include <AMReX_REAL.H>

using namespace amrex::literals;

namespace riemann_constants {
constexpr amrex::Real smlp1 = 1.e-10_rt;
constexpr amrex::Real small = 1.e-8_rt;
constexpr amrex::Real smallu = 1.e-12_rt;
constexpr int HISTORY_SIZE=40;
constexpr int PSTAR_BISECT_FACTOR = 5;
}

#endif
7 changes: 0 additions & 7 deletions Source/hydro/riemann_type.H
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@

using namespace amrex::literals;

namespace riemann_constants {
const amrex::Real smlp1 = 1.e-10_rt;
const amrex::Real small = 1.e-8_rt;
const amrex::Real smallu = 1.e-12_rt;
}


struct RiemannState
{
amrex::Real rho;
Expand Down
3 changes: 1 addition & 2 deletions Source/sdc/sdc_newton_solve.H
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ sdc_newton_solve(const Real dt_m,

// solve the linear system: Jac dU = -f
#ifdef NEW_NETWORK_IMPLEMENTATION
RHS::dgefa(Jac);
info = 0;
info = RHS::dgefa(Jac);
#else
IArray1D ipvt;
dgefa<NumSpec+1>(Jac, ipvt, info);
Expand Down
2 changes: 1 addition & 1 deletion Util/exact_riemann/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ Blocs := .

# we explicitly want runtime_parameters.H so we have access to
# Castro's runtime parameter system
Blocs += $(CASTRO_HOME)/Source/driver
Blocs += $(CASTRO_HOME)/Source/driver $(CASTRO_HOME)/Source/hydro

include $(CASTRO_HOME)/Exec/Make.Castro
11 changes: 11 additions & 0 deletions Util/exact_riemann/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,14 @@ https://ui.adsabs.harvard.edu/abs/2015ApJS..216...31Z/abstract
and more details are given there.

To build the solver, simply type 'make' in this directory.


Notes:

* ``test2`` is a vacuum

The velocity in the star region should be 0, but it seems that
slight differences in the rarefaction integration from the left and
from the right give different roundoff, resulting in a small, finite
velocity. This can be controlled a bit by tightening the tolerance
in the rarefaction integration.
4 changes: 1 addition & 3 deletions Util/exact_riemann/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ int main(int argc, char *argv[]) {
network_init();
#endif

amrex::Real small_temp = 1.e-200;
amrex::Real small_dens = 1.e-200;
eos_init(small_temp, small_dens);
eos_init(castro::small_temp, castro::small_dens);

exact_riemann();

Expand Down
11 changes: 6 additions & 5 deletions Util/exact_riemann/riemann_shock.H
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <eos_type.H>
#include <eos.H>

#include <riemann_constants.H>

AMREX_INLINE
void
Expand Down Expand Up @@ -62,7 +63,7 @@ newton_shock(amrex::Real& W_s, const amrex::Real pstar,
converged = false;

int iter = 1;
while (! converged && iter < riemann_solver::max_iters) {
while (! converged && iter < castro::riemann_shock_maxiter) {

amrex::Real rhostar_s, f, fprime;

Expand All @@ -71,7 +72,7 @@ newton_shock(amrex::Real& W_s, const amrex::Real pstar,

amrex::Real dW = -f / fprime;

if (std::abs(dW) < riemann_solver::tol * W_s) {
if (std::abs(dW) < castro::riemann_pstar_tol * W_s) {
converged = true;
}

Expand All @@ -96,7 +97,7 @@ shock(const amrex::Real pstar,

amrex::ignore_unused(u_s);

amrex::Real rhostar_hist[riemann_solver::max_iters], Ws_hist[riemann_solver::max_iters];
amrex::Real rhostar_hist[riemann_constants::HISTORY_SIZE], Ws_hist[riemann_constants::HISTORY_SIZE];

// compute the Z_s function for a shock following C&G Eq. 20 and
// 23. Here the "_s" variables are the state (L or R) that we are
Expand Down Expand Up @@ -147,7 +148,7 @@ shock(const amrex::Real pstar,
amrex::Real rhostar_s;

if (taustar_s < 0.0_rt) {
rhostar_s = riemann_solver::smallrho;
rhostar_s = riemann_constants::small;
W_s = std::sqrt((pstar - p_s) / (1.0_rt / rho_s - 1.0_rt / rhostar_s));
}

Expand All @@ -162,7 +163,7 @@ shock(const amrex::Real pstar,
// now did we converge?

if (! converged) {
for (int i = 0; i < riemann_solver::max_iters; ++i) {
for (int i = 0; i < castro::riemann_shock_maxiter; ++i) {
std::cout << i << " " << rhostar_hist[i] << " " << Ws_hist[i] << std::endl;
}

Expand Down
9 changes: 4 additions & 5 deletions Util/exact_riemann/riemann_star_state.H
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,11 @@ riemann_star_state(const amrex::Real rho_l, const amrex::Real u_l, const amrex::

amrex::Real pstar_new = pstar - Z_l * Z_r * (ustar_r - ustar_l) / (Z_l + Z_r);

// estimate the error in the current star solution
amrex::Real err1 = std::abs(ustar_r - ustar_l);
amrex::Real err2 = pstar_new - pstar;
// estimate the error in the current pstar solution

if (err1 < tol * amrex::max(std::abs(ustar_l), std::abs(ustar_r)) &&
err2 < tol * pstar) {
amrex::Real error = std::abs(pstar_new - pstar);

if (error < tol * pstar) {
converged = true;
}

Expand Down

0 comments on commit 62995f7

Please sign in to comment.