Skip to content

Commit

Permalink
Merge branch 'development' into cxx-compute-lamborder
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale authored Sep 25, 2023
2 parents 88b1f11 + 55e143f commit ec61f78
Show file tree
Hide file tree
Showing 12 changed files with 272 additions and 401 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,58 @@
time = 0.000901
variables minimum value maximum value
density 499999.99996 1003267.4037
xmom -1.6405409458e+12 1.6405409458e+12
ymom -1.6405409458e+12 1.6405409458e+12
xmom -1.64054094e+12 1.64054094e+12
ymom -1.64054094e+12 1.64054094e+12
zmom 0 0
rho_E 2.263117857e+22 7.0166374758e+22
rho_e 2.263117857e+22 7.0166358804e+22
Temp 300032898.05 454530912.93
rho_He4 499997.75752 1002591.9749
rho_C12 2.2423384483 675.42842495
rho_O16 5.0001038346e-05 0.00023067823575
rho_E 2.263117857e+22 7.0166374851e+22
rho_e 2.263117857e+22 7.0166358897e+22
Temp 300032898.05 454530914.06
rho_He4 499997.75752 1002591.9748
rho_C12 2.2423384483 675.42858349
rho_O16 5.0001038346e-05 0.00023067858795
rho_Fe56 4.9999999996e-05 0.00010032674037
rho_enuc 1.4565745423e+21 4.5249964745e+23
density_sdc_source -544925.80758 78513.247869
xmom_sdc_source -1.8266340546e+15 1.8266340546e+15
ymom_sdc_source -1.8266340546e+15 1.8266340546e+15
rho_enuc 1.4565745423e+21 4.5249954871e+23
density_sdc_source -544925.79275 78513.247889
xmom_sdc_source -1.8266340469e+15 1.8266340469e+15
ymom_sdc_source -1.8266340469e+15 1.8266340469e+15
zmom_sdc_source 0 0
rho_E_sdc_source -6.1992501236e+22 7.5781242663e+21
rho_e_sdc_source -6.1984110404e+22 6.3082607836e+21
rho_E_sdc_source -6.1992456785e+22 7.5781242406e+21
rho_e_sdc_source -6.1984065959e+22 6.3082607681e+21
Temp_sdc_source 0 0
rho_He4_sdc_source -543231.23569 78510.973875
rho_C12_sdc_source -1694.5620221 10.07378628
rho_O16_sdc_source -0.0098098270645 7.1506434889e-06
rho_Fe56_sdc_source -5.4492580758e-05 7.8513247869e-06
pressure 1.4155320805e+22 4.2608130805e+22
kineng 2.4519179612e-13 1.6647276308e+18
soundspeed 212069503.63 257404342.05
rho_He4_sdc_source -543231.29383 78510.973919
rho_C12_sdc_source -1694.4890575 10.073635147
rho_O16_sdc_source -0.0098093776861 7.1506350196e-06
rho_Fe56_sdc_source -5.4492579275e-05 7.8513247889e-06
pressure 1.4155320805e+22 4.2608130858e+22
kineng 3.2091279198e-13 1.6647276226e+18
soundspeed 212069503.63 257404342.21
Gamma_1 1.5601126452 1.5885713572
MachNumber 4.669869489e-18 0.008698277168
entropy 348439780.9 349209883.38
magvort 0 0.00018541051834
divu -0.11633879117 0.55816307483
eint_E 4.5262357143e+16 6.9937847586e+16
eint_e 4.5262357143e+16 6.9937843636e+16
MachNumber 5.3425093423e-18 0.0086982771596
entropy 348439780.9 349209883.57
magvort 0 0.00018541051835
divu -0.1163387912 0.55816306007
eint_E 4.5262357143e+16 6.9937847678e+16
eint_e 4.5262357143e+16 6.9937843728e+16
logden 5.6989700043 6.0014167022
StateErr_0 499999.99996 1003267.4037
StateErr_1 300032898.05 454530912.93
StateErr_2 0.99932677096 0.99999551512
X(He4) 0.99932677096 0.99999551512
X(C12) 4.484676897e-06 0.00067322871496
X(O16) 1.000020767e-10 2.2992697152e-10
StateErr_1 300032898.05 454530914.06
StateErr_2 0.9993267708 0.99999551512
X(He4) 0.9993267708 0.99999551512
X(C12) 4.484676897e-06 0.00067322887298
X(O16) 1.000020767e-10 2.2992732257e-10
X(Fe56) 1e-10 1e-10
abar 4.0000119598 4.0017960838
abar 4.0000119598 4.0017960842
Ye 0.5 0.5
x_velocity -2064636.8156 2064636.8156
y_velocity -2064636.8156 2064636.8156
x_velocity -2064636.8122 2064636.8122
y_velocity -2064636.8122 2064636.8122
z_velocity 0 0
t_sound_t_enuc 0.00023710316663 0.019573273608
enuc 2.9131490847e+15 4.5102596355e+17
magvel 9.9033690456e-10 2067446.1392
radvel -0.00067838913019 2067446.1391
circvel 0 11.820185992
magmom 0.00049516845224 1.6422547294e+12
t_sound_t_enuc 0.00023710316663 0.0195732693
enuc 2.9131490847e+15 4.5102586513e+17
magvel 1.1329833044e-09 2067446.1363
radvel -0.00067837531107 2067446.1363
circvel 0 11.820124028
magmom 0.00056649165215 1.6422547233e+12
angular_momentum_x -0 -0
angular_momentum_y -0 -0
angular_momentum_z -1.2410867567e+14 1.2410867593e+14
angular_momentum_y 0 0
angular_momentum_z -1.2410862711e+14 1.2410862711e+14

2 changes: 1 addition & 1 deletion Source/problems/Castro_bc_fill_nd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void ca_statefill(Box const& bx, FArrayBox& data,
// valid data is always present.

Vector<BCRec> bcr_noinflow{bcr};
for (auto bc : bcr_noinflow) {
for (auto & bc : bcr_noinflow) {
for (int dir = 0; dir < AMREX_SPACEDIM; ++dir) {
if (bc.lo(dir) == EXT_DIR) {
bc.setLo(dir, FOEXTRAP);
Expand Down
203 changes: 203 additions & 0 deletions Source/radiation/HABEC.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
#ifndef _HABEC_H_
#define _HABEC_H_

#include <AMReX_Array4.H>
#include <AMReX_REAL.H>

using namespace amrex;

namespace HABEC
{
// habec is Hypre abec, where abec is the form of the linear equation
// we are solving:
//
// alpha*phi - div(beta*grad phi) + div(\vec{c}*phi)

AMREX_INLINE
void hbflx (Array4<Real> const flux,
Array4<Real> const er,
const Box& reg,
int cdir, int bct, int bho, Real bcl,
Array4<Real const> const bcval,
Array4<int const> const mask,
Array4<Real const> const b,
Real beta, const Real* dx, int inhom)
{
Real h;

bool x_left = false;
bool x_right = false;
bool y_left = false;
bool y_right = false;
bool z_left = false;
bool z_right = false;

#if AMREX_SPACEDIM == 1
if (cdir == 0) {
h = dx[0];
x_left= true;
}
else if (cdir == 1) {
h = dx[0];
x_right= true;
}
#elif AMREX_SPACEDIM == 2
if (cdir == 0) {
h = dx[0];
x_left= true;
}
else if (cdir == 2) {
h = dx[0];
x_right= true;
}
else if (cdir == 1) {
h = dx[1];
y_left= true;
}
else if (cdir == 3) {
h = dx[1];
y_right= true;
}
#else
if (cdir == 0) {
h = dx[0];
x_left= true;
}
else if (cdir == 3) {
h = dx[0];
x_right= true;
}
else if (cdir == 1) {
h = dx[1];
y_left = true;
}
else if (cdir == 4) {
h = dx[1];
y_right = true;
}
else if (cdir == 2) {
h = dx[2];
z_left = true;
}
else if (cdir == 5) {
h = dx[2];
z_right = true;
}
#endif

Real bfv, bfm, bfm2;

if (bct == LO_DIRICHLET) {
if (bho >= 1) {
Real h2 = 0.5e0_rt * h;
Real th2 = 3.e0_rt * h2;
bfv = 2.e0_rt * beta * h / ((bcl + h2) * (bcl + th2));
bfm = (beta / h) * (th2 - bcl) / (bcl + h2);
bfm2 = (beta / h) * (bcl - h2) / (bcl + th2);
}
else {
bfv = beta / (0.5e0_rt * h + bcl);
bfm = bfv;
}
}
else {
amrex::Error("hbflx: unsupported boundary type");
}

if (inhom == 0) {
bfv = 0.e0_rt;
}

int reg_ilo = reg.loVect3d()[0];
int reg_ihi = reg.hiVect3d()[0];
int reg_jlo = reg.loVect3d()[1];
int reg_jhi = reg.hiVect3d()[1];
int reg_klo = reg.loVect3d()[2];
int reg_khi = reg.hiVect3d()[2];

if (x_left) {
int i = reg_ilo;
for (int k = reg_klo; k <= reg_khi; ++k) {
for (int j = reg_jlo; j <= reg_jhi; ++j) {
if (mask(i-1,j,k) > 0) {
flux(i,j,k) = b(i,j,k) * (bfv * bcval(i-1,j,k) - bfm * er(i,j,k));
if (bho >= 1) {
flux(i,j,k) = flux(i,j,k) - b(i,j,k) * bfm2 * er(i+1,j,k);
}
}
}
}
}
else if (x_right) {
int i = reg_ihi;
for (int k = reg_klo; k <= reg_khi; ++k) {
for (int j = reg_jlo; j <= reg_jhi; ++j) {
if (mask(i+1,j,k) > 0) {
flux(i+1,j,k) = -b(i+1,j,k) * (bfv * bcval(i+1,j,k) - bfm * er(i,j,k));
if (bho >= 1) {
flux(i+1,j,k) = flux(i+1,j,k) + b(i+1,j,k) * bfm2 * er(i-1,j,k);
}
}
}
}
}
else if (y_left) {
int j = reg_jlo;
for (int k = reg_klo; k <= reg_khi; ++k) {
for (int i = reg_ilo; i <= reg_ihi; ++i) {
if (mask(i,j-1,k) > 0) {
flux(i,j,k) = b(i,j,k) * (bfv * bcval(i,j-1,k) - bfm * er(i,j,k));
if (bho >= 1) {
flux(i,j,k) = flux(i,j,k) - b(i,j,k) * bfm2 * er(i,j+1,k);
}
}
}
}
}
else if (y_right) {
int j = reg_jhi;
for (int k = reg_klo; k <= reg_khi; ++k) {
for (int i = reg_ilo; i <= reg_ihi; ++i) {
if (mask(i,j+1,k) > 0) {
flux(i,j+1,k) = -b(i,j+1,k) * (bfv * bcval(i,j+1,k) - bfm * er(i,j,k));
if (bho >= 1) {
flux(i,j+1,k) = flux(i,j+1,k) + b(i,j+1,k) * bfm2 * er(i,j-1,k);
}
}
}
}
}
else if (z_left) {
int k = reg_klo;
for (int j = reg_jlo; j <= reg_jhi; ++j) {
for (int i = reg_ilo; i <= reg_ihi; ++i) {
if (mask(i,j,k-1) > 0) {
flux(i,j,k) = b(i,j,k) * (bfv * bcval(i,j,k-1) - bfm * er(i,j,k));
if (bho >= 1) {
flux(i,j,k) = flux(i,j,k) - b(i,j,k) * bfm2 * er(i,j,k+1);
}
}
}
}
}
else if (z_right) {
int k = reg_khi;
for (int j = reg_jlo; j <= reg_jhi; ++j) {
for (int i = reg_ilo; i <= reg_ihi; ++i) {
if (mask(i,j,k+1) > 0) {
flux(i,j,k+1) = -b(i,j,k+1) * (bfv * bcval(i,j,k+1) - bfm * er(i,j,k));
if (bho >= 1) {
flux(i,j,k+1) = flux(i,j,k+1) + b(i,j,k+1) * bfm2 * er(i,j,k-1);
}
}
}
}
}
else {
std::cout << "hbflx: impossible face orientation" << std::endl;
}
}

} // namespace HABEC

#endif
69 changes: 0 additions & 69 deletions Source/radiation/HABEC_1D.F90
Original file line number Diff line number Diff line change
Expand Up @@ -13,75 +13,6 @@ module habec_module

contains

subroutine hbflx(flux, &
DIMS(fbox), &
er, DIMS(ebox), &
DIMS(reg), &
cdir, bct, bho, bcl, &
bcval, DIMS(bcv), &
mask, DIMS(msk), &
b, DIMS(bbox), &
beta, dx, inhom) bind(C, name="hbflx")

use amrex_fort_module, only : rt => amrex_real
integer :: DIMDEC(fbox)
integer :: DIMDEC(ebox)
integer :: DIMDEC(reg)
integer :: DIMDEC(bcv)
integer :: DIMDEC(msk)
integer :: DIMDEC(bbox)
integer :: cdir, bct, bho, inhom
real(rt) :: bcl, beta, dx(1)
real(rt) :: flux(DIMV(fbox))
real(rt) :: er(DIMV(ebox))
real(rt) :: bcval(DIMV(bcv))
integer :: mask(DIMV(msk))
real(rt) :: b(DIMV(bbox))
real(rt) :: h, bfm, bfv
real(rt) :: bfm2, h2, th2
integer :: i
h = dx(1)
if (bct == LO_DIRICHLET) then
if (bho >= 1) then
h2 = 0.5e0_rt * h
th2 = 3.e0_rt * h2
bfv = 2.e0_rt * beta * h / ((bcl + h2) * (bcl + th2))
bfm = (beta / h) * (th2 - bcl) / (bcl + h2)
bfm2 = (beta / h) * (bcl - h2) / (bcl + th2)
else
bfv = beta / (0.5e0_rt * h + bcl)
bfm = bfv
endif
else
print *, "hbflx: unsupported boundary type"
stop
endif
if (inhom == 0) then
bfv = 0.e0_rt
endif
if (cdir == 0) then
! Left face of grid
i = reg_l1
if (mask(i-1) > 0) then
flux(i) = b(i) * (bfv * bcval(i-1) - bfm * er(i))
if (bho >= 1) then
flux(i) = flux(i) - b(i) * bfm2 * er(i+1)
endif
endif
else if (cdir == 1) then
! Right face of grid
i = reg_h1
if (mask(i+1) > 0) then
flux(i+1) = -b(i+1) * (bfv * bcval(i+1) - bfm * er(i))
if (bho >= 1) then
flux(i+1) = flux(i+1) + b(i+1) * bfm2 * er(i-1)
endif
endif
else
print *, "hbflx: impossible face orientation"
endif
end subroutine hbflx

subroutine hbflx3(flux, &
DIMS(fbox), &
er, DIMS(ebox), &
Expand Down
Loading

0 comments on commit ec61f78

Please sign in to comment.