aboutsummaryrefslogtreecommitdiff
path: root/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianNodalAlgorithm.H
diff options
context:
space:
mode:
authorGravatar Remi Lehe <remi.lehe@normalesup.org> 2020-07-22 17:29:51 -0700
committerGravatar GitHub <noreply@github.com> 2020-07-22 17:29:51 -0700
commit324115542740ca838d645b1f1d01cb50bd17e584 (patch)
treecc129d47d6cc1e5c56735b60b8f35cc02eefcabf /Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianNodalAlgorithm.H
parentfd8a4bc0af84f9b5b074b18554becd92d22cb9e4 (diff)
downloadWarpX-324115542740ca838d645b1f1d01cb50bd17e584.tar.gz
WarpX-324115542740ca838d645b1f1d01cb50bd17e584.tar.zst
WarpX-324115542740ca838d645b1f1d01cb50bd17e584.zip
Cleaner calculation of the simulation timestep (#1031)
* Cleaner calculation of the simulation timestep * Fix compilation errors * Remove specification of CKC solver in PSATD test * Correct calculation of dt * Fix compilation error * Cleaner calculation of the simulation timestep * Fix compilation errors * Remove specification of CKC solver in PSATD test * Correct calculation of dt * Fix compilation error * Cleanup for cylindrical * Change input of automated tests to preserve previous results * Fix import statement for cylindrical * Preserve dt for PML test * Move function documentation to WarpX.H * Update CMakeList * Update CFL in some tests * Apply suggestions from code review Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja> * Fix compilation errors * Revert "Fix compilation errors" This reverts commit 56ef67f228269b266876629f49789d3afdbbc00b. * Fix compilation error * Add cmath headers Add directly used header files. * Fix Include Order Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
Diffstat (limited to 'Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianNodalAlgorithm.H')
-rw-r--r--Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianNodalAlgorithm.H17
1 files changed, 17 insertions, 0 deletions
diff --git a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianNodalAlgorithm.H b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianNodalAlgorithm.H
index e5f89ff98..99510cc52 100644
--- a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianNodalAlgorithm.H
+++ b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianNodalAlgorithm.H
@@ -8,11 +8,15 @@
#ifndef WARPX_FINITE_DIFFERENCE_ALGORITHM_CARTESIAN_NODAL_H_
#define WARPX_FINITE_DIFFERENCE_ALGORITHM_CARTESIAN_NODAL_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
@@ -38,6 +42,19 @@ struct CartesianNodalAlgorithm {
}
/**
+ * 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
* (For a solver on a staggered grid, `UpwardDx` and `DownwardDx` take into
* account the staggering; but for `CartesianNodalAlgorithm`, they are equivalent) */