Skip to content

Commit

Permalink
Tweak to fast integrator (erf-model#1435)
Browse files Browse the repository at this point in the history
* minor tweak to fast substepping to be consistent with notes

* slight tweak to fast integrator to make it consistent with the notes
  • Loading branch information
asalmgren authored Feb 14, 2024
1 parent 8007bd4 commit 38a9b4a
Show file tree
Hide file tree
Showing 44 changed files with 73 additions and 1,987 deletions.
8 changes: 4 additions & 4 deletions Source/TimeIntegration/ERF_fast_rhs_MT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void erf_fast_rhs_MT (int step, int nrk,
const Vector<MultiFab>& S_prev, // if step == 0, this is S_old, else the previous solution
Vector<MultiFab>& S_stg_data, // at last RK stg: S^n, S^* or S^**
const MultiFab& S_stg_prim, // Primitive version of S_stg_data[IntVar::cons]
const MultiFab& pi_stg, // Exner function evaluated at last RK stg
const MultiFab& pi_stage, // Exner function evaluated at last RK stg
const MultiFab& fast_coeffs, // Coeffs for tridiagonal solve
Vector<MultiFab>& S_data, // S_sum = state at end of this substep
Vector<MultiFab>& S_scratch, // S_sum_old at most recent fast timestep for (rho theta)
Expand Down Expand Up @@ -173,7 +173,7 @@ void erf_fast_rhs_MT (int step, int nrk,

const Array4< Real>& omega_arr = Omega.array(mfi);

const Array4<const Real>& pi_stg_ca = pi_stg.const_array(mfi);
const Array4<const Real>& pi_stage_ca = pi_stage.const_array(mfi);

const Array4<Real>& theta_extrap = extrap.array(mfi);

Expand Down Expand Up @@ -261,7 +261,7 @@ void erf_fast_rhs_MT (int step, int nrk,
gpx /= (1.0 + q);
}

Real pi_c = 0.5 * (pi_stg_ca(i-1,j,k,0) + pi_stg_ca(i ,j,k,0));
Real pi_c = 0.5 * (pi_stage_ca(i-1,j,k,0) + pi_stage_ca(i ,j,k,0));
Real fast_rhs_rho_u = -Gamma * R_d * pi_c * gpx;

// We have already scaled the source terms to have the extra factor of dJ
Expand All @@ -288,7 +288,7 @@ void erf_fast_rhs_MT (int step, int nrk,
gpy /= (1.0 + q);
}

Real pi_c = 0.5 * (pi_stg_ca(i,j-1,k,0) + pi_stg_ca(i,j ,k,0));
Real pi_c = 0.5 * (pi_stage_ca(i,j-1,k,0) + pi_stage_ca(i,j ,k,0));
Real fast_rhs_rho_v = -Gamma * R_d * pi_c * gpy;

// We have already scaled the source terms to have the extra factor of dJ
Expand Down
2 changes: 1 addition & 1 deletion Source/TimeIntegration/ERF_fast_rhs_T.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ using namespace amrex;
* @param[in] S_prev previous solution
* @param[in] S_stage_data solution at previous RK stage
* @param[in] S_stage_prim primitive variables at previous RK stage
* @param[in] pi_stage Exner function at previous RK stage
* @param[in] pi_stage Exner function at previous RK stage
* @param[in] fast_coeffs coefficients for the tridiagonal solve used in the fast integrator
* @param[out] S_data current solution
* @param[in] S_scratch scratch space
Expand Down
31 changes: 16 additions & 15 deletions Source/TimeIntegration/ERF_make_fast_coeffs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ void make_fast_coeffs (int /*level*/,
const Array4<const Real>& detJ = l_use_terrain ? detJ_cc->const_array(mfi) : Array4<const Real>{};

const Array4<const Real>& r0_ca = r0->const_array(mfi);
const Array4<const Real>& pi0_ca = pi0->const_array(mfi); const Array4<const Real>& pi_stage_ca = pi_stage.const_array(mfi);
const Array4<const Real>& pi0_ca = pi0->const_array(mfi);
const Array4<const Real>& pi_stage_ca = pi_stage.const_array(mfi);

FArrayBox gam_fab; gam_fab.resize(surroundingNodes(bx,2),1,The_Async_Arena());

Expand Down Expand Up @@ -117,20 +118,20 @@ void make_fast_coeffs (int /*level*/,
pibar_lo = pi0_ca(i,j,k-1);
pibar_hi = pi0_ca(i,j,k );

Real pi_lo = pi_stage_ca(i,j,k-1,0);
Real pi_hi = pi_stage_ca(i,j,k ,0);
Real pi_c = 0.5 * (pi_lo + pi_hi);
Real pi_c = 0.5 * (pi_stage_ca(i,j,k-1,0) + pi_stage_ca(i,j,k,0));

Real detJ_on_kface = 0.5 * (detJ(i,j,k) + detJ(i,j,k-1));
Real inv_detJ_on_kface = 1. / detJ_on_kface;

Real coeff_P = -Gamma * R_d * pi_c * dzi * inv_detJ_on_kface
+ halfg * R_d * rhobar_hi * pi_hi /
Real coeff_P = -Gamma * R_d * dzi * inv_detJ_on_kface
+ halfg * R_d * rhobar_hi /
( c_v * pibar_hi * stage_cons(i,j,k,RhoTheta_comp) );
coeff_P *= pi_c;

Real coeff_Q = Gamma * R_d * pi_c * dzi * inv_detJ_on_kface
+ halfg * R_d * rhobar_lo * pi_lo /
Real coeff_Q = Gamma * R_d * dzi * inv_detJ_on_kface
+ halfg * R_d * rhobar_lo /
( c_v * pibar_lo * stage_cons(i,j,k-1,RhoTheta_comp) );
coeff_Q *= pi_c;

coeffP_a(i,j,k) = coeff_P;
coeffQ_a(i,j,k) = coeff_Q;
Expand Down Expand Up @@ -164,17 +165,17 @@ void make_fast_coeffs (int /*level*/,
pibar_lo = pi0_ca(i,j,k-1);
pibar_hi = pi0_ca(i,j,k );

Real pi_lo = pi_stage_ca(i,j,k-1,0);
Real pi_hi = pi_stage_ca(i,j,k ,0);
Real pi_c = 0.5 * (pi_lo + pi_hi);
Real pi_c = 0.5 * (pi_stage_ca(i,j,k-1,0) + pi_stage_ca(i,j,k,0));

Real coeff_P = -Gamma * R_d * pi_c * dzi
+ halfg * R_d * rhobar_hi * pi_hi /
Real coeff_P = -Gamma * R_d * dzi
+ halfg * R_d * rhobar_hi /
( c_v * pibar_hi * stage_cons(i,j,k,RhoTheta_comp) );
coeff_P *= pi_c;

Real coeff_Q = Gamma * R_d * pi_c * dzi
+ halfg * R_d * rhobar_lo * pi_lo /
Real coeff_Q = Gamma * R_d * dzi
+ halfg * R_d * rhobar_lo /
( c_v * pibar_lo * stage_cons(i,j,k-1,RhoTheta_comp) );
coeff_Q *= pi_c;

coeffP_a(i,j,k) = coeff_P;
coeffQ_a(i,j,k) = coeff_Q;
Expand Down
2 changes: 1 addition & 1 deletion Source/TimeIntegration/TI_headers.H
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void erf_fast_rhs_MT (int step, int nrk, int level, int finest_level,
const amrex::Vector<amrex::MultiFab >& S_prev,
amrex::Vector<amrex::MultiFab >& S_stg_data,
const amrex::MultiFab& S_stg_prim,
const amrex::MultiFab& pi_stg,
const amrex::MultiFab& pi_stage,
const amrex::MultiFab& fast_coeffs,
amrex::Vector<amrex::MultiFab >& S_data,
amrex::Vector<amrex::MultiFab >& S_scratch,
Expand Down
12 changes: 3 additions & 9 deletions Tests/ERFGoldFiles/DensityCurrent/Header
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,12 @@ pressure
100 25 100
0
0
0 4 10
0 2 10
10
-12800 -6400
-12800 0
0 100
0 6400
-6400 0
0 100
0 6400
0 6400
0 100
0 6400
6400 12800
0 12800
0 100
0 6400
Level_0/Cell
Binary file modified Tests/ERFGoldFiles/DensityCurrent/Level_0/Cell_D_00000
Binary file not shown.
Binary file modified Tests/ERFGoldFiles/DensityCurrent/Level_0/Cell_D_00001
Binary file not shown.
Binary file not shown.
Binary file not shown.
28 changes: 10 additions & 18 deletions Tests/ERFGoldFiles/DensityCurrent/Level_0/Cell_H
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,19 @@
1
8
0
(4 0
((0,0,0) (63,3,63) (0,0,0))
((64,0,0) (127,3,63) (0,0,0))
((128,0,0) (191,3,63) (0,0,0))
((192,0,0) (255,3,63) (0,0,0))
(2 0
((0,0,0) (127,3,63) (0,0,0))
((128,0,0) (255,3,63) (0,0,0))
)
4
2
FabOnDisk: Cell_D_00000 0
FabOnDisk: Cell_D_00001 0
FabOnDisk: Cell_D_00002 0
FabOnDisk: Cell_D_00003 0

4,8
6.5098892847193790e-01,-2.0418835990748977e-03,0.0000000000000000e+00,-4.4803493663859122e-04,2.9999999984644018e+02,4.4463890028261158e+04,6.5098892858777935e-01,4.4463890017184007e+04,
6.4836893180468114e-01,-7.9260529722221518e-01,0.0000000000000000e+00,-2.1904806103671612e+00,2.8340212496085053e+02,4.4463890028261158e+04,6.5098892858777935e-01,4.4213560173266931e+04,
6.4836893180468114e-01,-9.5512978283271610e-01,0.0000000000000000e+00,-2.1904806103671257e+00,2.8340212496085059e+02,4.4463890028261158e+04,6.5098892858777935e-01,4.4213560173266931e+04,
6.5098892847193790e-01,-1.5670219933390387e-03,0.0000000000000000e+00,-4.4803493663859122e-04,2.9999999984644018e+02,4.4463890028261158e+04,6.5098892858777935e-01,4.4463890017184007e+04,
2,8
6.4836893187956446e-01,-7.9260530344048652e-01,0.0000000000000000e+00,-2.1904806070931810e+00,2.8340212496087150e+02,4.4463890028261158e+04,6.5098892858777935e-01,4.4213560180415923e+04,
6.4836893187956446e-01,-9.5512978921753067e-01,0.0000000000000000e+00,-2.1904806070931708e+00,2.8340212496087162e+02,4.4463890028261158e+04,6.5098892858777935e-01,4.4213560180415923e+04,

4,8
1.1567295136790348e+00,1.5670219933390387e-03,0.0000000000000000e+00,7.4403897400177922e-04,3.0000000000000006e+02,9.9432624223818915e+04,1.1567294111744995e+00,9.9432636559645209e+04,
1.1615310052856855e+00,9.5512978283270333e-01,0.0000000000000000e+00,3.2286310089996639e-01,3.0002669784914963e+02,9.9432624223818915e+04,1.1567294111744995e+00,1.0001094754834003e+05,
1.1615310052856855e+00,7.9260529722218953e-01,0.0000000000000000e+00,3.2286310089996428e-01,3.0002669784914963e+02,9.9432624223818915e+04,1.1567294111744995e+00,1.0001094754834003e+05,
1.1567295136790348e+00,2.0418835990748977e-03,0.0000000000000000e+00,7.4403897400177922e-04,3.0000000000000006e+02,9.9432624223818915e+04,1.1567294111744995e+00,9.9432636559645209e+04,
2,8
1.1615310052895498e+00,9.5512978921752978e-01,0.0000000000000000e+00,3.2286309960014881e-01,3.0002669784915173e+02,9.9432624223818915e+04,1.1567294111744995e+00,1.0001094754880578e+05,
1.1615310052895496e+00,7.9260530344048652e-01,0.0000000000000000e+00,3.2286309960014881e-01,3.0002669784915167e+02,9.9432624223818915e+04,1.1567294111744995e+00,1.0001094754880578e+05,

159 changes: 0 additions & 159 deletions Tests/ERFGoldFiles/DensityCurrent/job_info

This file was deleted.

12 changes: 3 additions & 9 deletions Tests/ERFGoldFiles/DensityCurrent_detJ2/Header
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,12 @@ pressure
100 25 50
0
0
0 4 10
0 2 10
10
-12800 -6400
-12800 0
0 100
0 3200
-6400 0
0 100
0 3200
0 6400
0 100
0 3200
6400 12800
0 12800
0 100
0 3200
Level_0/Cell
Expand Down
Binary file modified Tests/ERFGoldFiles/DensityCurrent_detJ2/Level_0/Cell_D_00000
Binary file not shown.
Binary file modified Tests/ERFGoldFiles/DensityCurrent_detJ2/Level_0/Cell_D_00001
Binary file not shown.
Binary file not shown.
Binary file not shown.
28 changes: 10 additions & 18 deletions Tests/ERFGoldFiles/DensityCurrent_detJ2/Level_0/Cell_H
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,19 @@
1
8
0
(4 0
((0,0,0) (63,3,63) (0,0,0))
((64,0,0) (127,3,63) (0,0,0))
((128,0,0) (191,3,63) (0,0,0))
((192,0,0) (255,3,63) (0,0,0))
(2 0
((0,0,0) (127,3,63) (0,0,0))
((128,0,0) (255,3,63) (0,0,0))
)
4
2
FabOnDisk: Cell_D_00000 0
FabOnDisk: Cell_D_00001 0
FabOnDisk: Cell_D_00002 0
FabOnDisk: Cell_D_00003 0

4,8
6.5098892847193790e-01,-2.0418835990748977e-03,0.0000000000000000e+00,-4.4803493663859111e-04,2.9999999984644018e+02,4.4463890028261158e+04,6.5098892858777935e-01,4.4463890017184007e+04,
6.4836893180468103e-01,-7.9260529722220729e-01,0.0000000000000000e+00,-2.1904806103670982e+00,2.8340212496085059e+02,4.4463890028261158e+04,6.5098892858777935e-01,4.4213560173266902e+04,
6.4836893180468103e-01,-9.5512978283271521e-01,0.0000000000000000e+00,-2.1904806103670786e+00,2.8340212496085053e+02,4.4463890028261158e+04,6.5098892858777935e-01,4.4213560173266902e+04,
6.5098892847193790e-01,-1.5670219933390387e-03,0.0000000000000000e+00,-4.4803493663859111e-04,2.9999999984644018e+02,4.4463890028261158e+04,6.5098892858777935e-01,4.4463890017184007e+04,
2,8
6.4836893187956446e-01,-7.9260530344057234e-01,0.0000000000000000e+00,-2.1904806070931024e+00,2.8340212496087162e+02,4.4463890028261158e+04,6.5098892858777935e-01,4.4213560180415923e+04,
6.4836893187956446e-01,-9.5512978921752367e-01,0.0000000000000000e+00,-2.1904806070931024e+00,2.8340212496087162e+02,4.4463890028261158e+04,6.5098892858777935e-01,4.4213560180415923e+04,

4,8
1.1567295136790348e+00,1.5670219933390387e-03,0.0000000000000000e+00,7.4403897400177922e-04,3.0000000000000006e+02,9.9432624223818915e+04,1.1567294111744995e+00,9.9432636559645209e+04,
1.1615310052856853e+00,9.5512978283271521e-01,0.0000000000000000e+00,3.2286310089999748e-01,3.0002669784914968e+02,9.9432624223818915e+04,1.1567294111744995e+00,1.0001094754834003e+05,
1.1615310052856853e+00,7.9260529722220729e-01,0.0000000000000000e+00,3.2286310089999748e-01,3.0002669784914968e+02,9.9432624223818915e+04,1.1567294111744995e+00,1.0001094754834003e+05,
1.1567295136790348e+00,2.0418835990748977e-03,0.0000000000000000e+00,7.4403897400177922e-04,3.0000000000000006e+02,9.9432624223818915e+04,1.1567294111744995e+00,9.9432636559645209e+04,
2,8
1.1615310052895504e+00,9.5512978921752367e-01,0.0000000000000000e+00,3.2286309960015219e-01,3.0002669784915173e+02,9.9432624223818915e+04,1.1567294111744995e+00,1.0001094754880582e+05,
1.1615310052895504e+00,7.9260530344057378e-01,0.0000000000000000e+00,3.2286309960015935e-01,3.0002669784915173e+02,9.9432624223818915e+04,1.1567294111744995e+00,1.0001094754880582e+05,

Binary file modified Tests/ERFGoldFiles/DensityCurrent_detJ2/Level_0/Nu_nd_D_00000
Binary file not shown.
Binary file modified Tests/ERFGoldFiles/DensityCurrent_detJ2/Level_0/Nu_nd_D_00001
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 38a9b4a

Please sign in to comment.