aboutsummaryrefslogtreecommitdiff
path: root/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianCKCAlgorithm.H
diff options
context:
space:
mode:
Diffstat (limited to 'Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianCKCAlgorithm.H')
-rw-r--r--Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianCKCAlgorithm.H17
1 files changed, 17 insertions, 0 deletions
diff --git a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianCKCAlgorithm.H b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianCKCAlgorithm.H
index 9c52327e3..bb480364a 100644
--- a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianCKCAlgorithm.H
+++ b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianCKCAlgorithm.H
@@ -8,6 +8,8 @@
#ifndef WARPX_FINITE_DIFFERENCE_ALGORITHM_CARTESIAN_CKC_H_
#define WARPX_FINITE_DIFFERENCE_ALGORITHM_CARTESIAN_CKC_H_
+#include "Utils/WarpXConst.H"
+
#include <AMReX_REAL.H>
#include <AMReX_Array4.H>
#include <AMReX_Gpu.H>
@@ -15,6 +17,7 @@
#include <algorithm>
#include <array>
+
/**
* This struct contains only static functions to initialize the stencil coefficients
* and to compute finite-difference derivatives for the Cartesian CKC algorithm.
@@ -91,6 +94,20 @@ struct CartesianCKCAlgorithm {
}
/**
+ * Compute the maximum timestep, for which the scheme remains stable
+ * (Courant-Friedrichs-Levy limit) */
+ static amrex::Real ComputeMaxDt ( amrex::Real const * const dx ) {
+#if (defined WARPX_DIM_XZ)
+ // - In Cartesian 2D geometry: determined by the minimum cell size in all direction
+ amrex::Real const delta_t = std::min( dx[0], dx[1] )/PhysConst::c;
+#else
+ // - In Cartesian 3D geometry: determined by the minimum cell size in all direction
+ amrex::Real const delta_t = std::min( dx[0], std::min( dx[1], dx[2] ) ) / PhysConst::c;
+#endif
+ return delta_t;
+ }
+
+ /**
* Perform derivative along x on a cell-centered grid, from a nodal field `F` */
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
static amrex::Real UpwardDx (