aboutsummaryrefslogtreecommitdiff
path: root/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H
diff options
context:
space:
mode:
Diffstat (limited to 'Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H')
-rw-r--r--Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H17
1 files changed, 17 insertions, 0 deletions
diff --git a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H
index 3a98bea0e..1c8609dfa 100644
--- a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H
+++ b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H
@@ -8,11 +8,15 @@
#ifndef WARPX_FINITE_DIFFERENCE_ALGORITHM_CARTESIAN_YEE_H_
#define WARPX_FINITE_DIFFERENCE_ALGORITHM_CARTESIAN_YEE_H_
+#include "Utils/WarpXConst.H"
+
#include <AMReX_REAL.H>
#include <AMReX_Array4.H>
#include <AMReX_Gpu.H>
#include <array>
+#include <cmath>
+
/**
* This struct contains only static functions to initialize the stencil coefficients
@@ -37,6 +41,19 @@ struct CartesianYeeAlgorithm {
}
/**
+ * Compute the maximum timestep, for which the scheme remains stable
+ * (Courant-Friedrichs-Levy limit) */
+ static amrex::Real ComputeMaxDt ( amrex::Real const * const dx ) {
+ using namespace amrex::literals;
+ amrex::Real const delta_t = 1._rt / ( std::sqrt( AMREX_D_TERM(
+ 1._rt / (dx[0]*dx[0]),
+ + 1._rt / (dx[1]*dx[1]),
+ + 1._rt / (dx[2]*dx[2])
+ ) ) * PhysConst::c );
+ 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 (