aboutsummaryrefslogtreecommitdiff
path: root/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms
diff options
context:
space:
mode:
authorGravatar Revathi Jambunathan <41089244+RevathiJambunathan@users.noreply.github.com> 2020-09-09 19:58:24 -0700
committerGravatar GitHub <noreply@github.com> 2020-09-09 19:58:24 -0700
commit614dc2962f9b5b576b4f734532c969b89f1316c0 (patch)
tree3a8374e6c9bdfba514c7e970a747eaef398801c9 /Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms
parent5165e43dea54d3a57d8648075c1597710644b3e9 (diff)
downloadWarpX-614dc2962f9b5b576b4f734532c969b89f1316c0.tar.gz
WarpX-614dc2962f9b5b576b4f734532c969b89f1316c0.tar.zst
WarpX-614dc2962f9b5b576b4f734532c969b89f1316c0.zip
Variation of macroscopic properties for E-update (#1016)
* Adding macro-E Push and new file * Add macroEvolveE, call it, and include algo selection in utils * fix eol * Fixing bug in macroE for sigma method 1 * changing MacroEvolveE to MacroscopicEvolveE * add class for macroscopicproperties and an object in WarpX class * fix eol * adding templated ckc call with comment that EvolveE is same for yee and ckc * add header file pointing to ckc algorithm * adding obejct m_macroscopic_properties to access sigma,eps,mu * some cleaning * Adding comments * adding documentation * spelling wandroff to wendroff * fixing eol * eol * const in the right place. Thanks bot! * profiler for macroscopic evolveE * MultiFab macroproperties with constant init, templated macroEvolveE, * call macroparameter init * eol fix * add parser for macroscopic properties * fix eol * adding input file * __device__ lambda cannot be private in class * fix grown tilebox declaration for init data * [skip ci] some more merge conflicts * some comments * removing redundant calls to Macroscopic EvolveE * [skip ci] fix growntilebox for initializing macro mf * clean and fix BackwardEuler call for ckc * commenting out old alpha and beta implementations * temporarily commiting local changes with calls in Interp. * fixing a typo * clean and add documentation * remove the test input file * fix typo * eol fix * Update Docs/source/running_cpp/parameters.rst Co-authored-by: Andy Nonaka <AJNonaka@lbl.gov> * PR suggestions * Update Source/FieldSolver/WarpXPushFieldsEM.cpp Co-authored-by: Andy Nonaka <AJNonaka@lbl.gov> * removing unnecessary includes * adding 2D initialization for stag arrays * removing init_style input parameter for material properties * eol fix * Adding dE/dt eq curl of (B/mu) * PhysConst ep0 and mu0 * Add functor for field access for macro and vacuum (B/mu) * fix eol * Update Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/FieldAccessorFunctors.H Co-authored-by: Remi Lehe <remi.lehe@normalesup.org> * Apply suggestions from code review Co-authored-by: Remi Lehe <remi.lehe@normalesup.org> * Update Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianCKCAlgorithm.H Co-authored-by: Remi Lehe <remi.lehe@normalesup.org> * Apply suggestions from code review Co-authored-by: Remi Lehe <remi.lehe@normalesup.org> * fixing compilation errors and removing Gpu ManagedVector Co-authored-by: Andy Nonaka <AJNonaka@lbl.gov> Co-authored-by: Remi Lehe <remi.lehe@normalesup.org>
Diffstat (limited to 'Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms')
-rw-r--r--Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianCKCAlgorithm.H13
-rw-r--r--Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H10
-rw-r--r--Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/FieldAccessorFunctors.H40
3 files changed, 55 insertions, 8 deletions
diff --git a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianCKCAlgorithm.H b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianCKCAlgorithm.H
index ef6d53416..b688110b7 100644
--- a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianCKCAlgorithm.H
+++ b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianCKCAlgorithm.H
@@ -143,9 +143,10 @@ struct CartesianCKCAlgorithm {
/**
* Perform derivative along x on a nodal grid, from a cell-centered field `F` */
+ template< typename T_Field>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
static amrex::Real DownwardDx (
- amrex::Array4<amrex::Real> const& F,
+ T_Field const& F,
amrex::Real const * const coefs_x, int const /*n_coefs_x*/,
int const i, int const j, int const k, int const ncomp=0 ) {
@@ -189,15 +190,16 @@ struct CartesianCKCAlgorithm {
/**
* Perform derivative along y on a nodal grid, from a cell-centered field `F` */
+ template< typename T_Field>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
static amrex::Real DownwardDy (
- amrex::Array4<amrex::Real> const& F,
+ T_Field const& F,
amrex::Real const * const coefs_y, int const n_coefs_y,
int const i, int const j, int const k, int const ncomp=0 ) {
using namespace amrex;
#if defined WARPX_DIM_3D
- Real const inv_dy = coefs_y[0];
+ amrex::Real const inv_dy = coefs_y[0];
return inv_dy*( F(i,j,k,ncomp) - F(i,j-1,k,ncomp) );
amrex::ignore_unused(n_coefs_y);
#elif (defined WARPX_DIM_XZ)
@@ -248,11 +250,12 @@ struct CartesianCKCAlgorithm {
/**
* Perform derivative along z on a nodal grid, from a cell-centered field `F` */
+ template< typename T_Field>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
static amrex::Real DownwardDz (
- amrex::Array4<amrex::Real> const& F,
+ T_Field const& F,
amrex::Real const * const coefs_z, int const /*n_coefs_z*/,
- int const i, int const j, int const k, int const ncomp=0 ) {
+ int const i, int const j, int const k, int const ncomp=0) {
amrex::Real const inv_dz = coefs_z[0];
#if defined WARPX_DIM_3D
diff --git a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H
index 305fb3507..2ec6a3d22 100644
--- a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H
+++ b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/CartesianYeeAlgorithm.H
@@ -9,6 +9,7 @@
#define WARPX_FINITE_DIFFERENCE_ALGORITHM_CARTESIAN_YEE_H_
#include "Utils/WarpXConst.H"
+#include "FieldAccessorFunctors.H"
#include <AMReX.H>
#include <AMReX_REAL.H>
@@ -68,9 +69,10 @@ struct CartesianYeeAlgorithm {
/**
* Perform derivative along x on a nodal grid, from a cell-centered field `F`*/
+ template< typename T_Field>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
static amrex::Real DownwardDx (
- amrex::Array4<amrex::Real> const& F,
+ T_Field const& F,
amrex::Real const * const coefs_x, int const /*n_coefs_x*/,
int const i, int const j, int const k, int const ncomp=0 ) {
@@ -103,9 +105,10 @@ struct CartesianYeeAlgorithm {
/**
* Perform derivative along y on a nodal grid, from a cell-centered field `F`*/
+ template< typename T_Field>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
static amrex::Real DownwardDy (
- amrex::Array4<amrex::Real> const& F,
+ T_Field const& F,
amrex::Real const * const coefs_y, int const n_coefs_y,
int const i, int const j, int const k, int const ncomp=0 ) {
@@ -143,9 +146,10 @@ struct CartesianYeeAlgorithm {
/**
* Perform derivative along z on a nodal grid, from a cell-centered field `F`*/
+ template< typename T_Field>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
static amrex::Real DownwardDz (
- amrex::Array4<amrex::Real> const& F,
+ T_Field const& F,
amrex::Real const * const coefs_z, int const /*n_coefs_z*/,
int const i, int const j, int const k, int const ncomp=0 ) {
diff --git a/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/FieldAccessorFunctors.H b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/FieldAccessorFunctors.H
new file mode 100644
index 000000000..3ba6de335
--- /dev/null
+++ b/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceAlgorithms/FieldAccessorFunctors.H
@@ -0,0 +1,40 @@
+#ifndef WARPX_FIELD_ACCESSOR_FUNCTORS_H
+#define WARPX_FIELD_ACCESSOR_FUNCTORS_H
+#include "WarpX.H"
+/**
+ * \brief Functor that returns the division of the source m_field Array4 value
+ by macroparameter, m_parameter value at the respective (i,j,k,ncomp).
+ */
+struct FieldAccessorMacroscopic
+{
+ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
+ FieldAccessorMacroscopic ( amrex::Array4<amrex::Real const> const a_field,
+ amrex::Array4<amrex::Real const> const a_parameter )
+ : m_field(a_field), m_parameter(a_parameter) {}
+
+ /**
+ * \brief return field value at (i,j,k,ncomp) scaled by (1/m_parameters(i,j,k,ncomp))
+ * \param[in] i index along x of the Array4, m_field and m_parameter.
+ * \param[in] j index along y of the Array4, m_field and m_parameter.
+ * \param[in] k index along z of the Array4, m_field and m_parameter.
+ * \param[in] ncomp index along fourth component of the Array4, containing field-data
+ to be returned after diving with zero-th component
+ of m_paramter.
+ *
+ * \return m_field/m_paramter at (i,j,k,ncomp)
+ */
+ AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
+ amrex::Real operator() (int const i, int const j,
+ int const k, int const ncomp) const noexcept
+ {
+ return ( m_field(i, j, k, ncomp) / m_parameter(i, j, k, 0) ) ;
+ }
+private:
+ /** Array4 of the source field to be scaled and returned by the operator() */
+ amrex::Array4<amrex::Real const> const m_field;
+ /** Array4 of the macroscopic parameter used to divide m_field in the operator() */
+ amrex::Array4<amrex::Real const> const m_parameter;
+};
+
+
+#endif