ARTEMIS
CustomDensityProb.H
Go to the documentation of this file.
1 /* Copyright 2019 Maxence Thevenet, Weiqun Zhang
2  *
3  * This file is part of WarpX.
4  *
5  * License: BSD-3-Clause-LBNL
6  */
7 #ifndef CUSTOM_DENSITY_PROB_H_
8 #define CUSTOM_DENSITY_PROB_H_
9 
10 #include "Utils/TextMsg.H"
12 
13 #include <AMReX_Arena.H>
14 #include <AMReX_Dim3.H>
15 #include <AMReX_Gpu.H>
16 #include <AMReX_ParmParse.H>
17 
18 // An example of Custom Density Profile
19 
20 // struct whose getDensity returns density at a given position computed from
21 // a custom function, with runtime input parameters.
23 {
24  InjectorDensityCustom (std::string const& species_name)
25  {
26  // Read parameters for custom density profile from file
27  amrex::ParmParse pp_species_name(species_name);
28  std::vector<amrex::Real> v;
30  "Too many parameters for InjectorDensityCustom");
32  pp_species_name, "custom_profile_params", v);
33  for (int i = 0; i < static_cast<int>(v.size()); ++i) {
34  p[i] = v[i];
35  }
36  }
37 
38  // Return density at given position, using user-defined parameters
39  // stored in p.
41  amrex::Real
42  getDensity (amrex::Real, amrex::Real, amrex::Real) const noexcept
43  {
44  return p[0];
45  }
46 
47  // Note that we are not allowed to have non-trivial destructor.
48  // So we rely on clear() to free memory if needed.
49  void clear () {}
50 
51 private:
53 };
54 
55 #endif
#define AMREX_GPU_HOST_DEVICE
#define WARPX_ALWAYS_ASSERT_WITH_MESSAGE(EX, MSG)
Definition: TextMsg.H:13
i
Definition: check_interp_points_and_weights.py:174
void getArrWithParser(const amrex::ParmParse &a_pp, char const *const str, std::vector< T > &val)
Definition: ParserUtils.H:240
Definition: CustomDensityProb.H:23
AMREX_GPU_HOST_DEVICE amrex::Real getDensity(amrex::Real, amrex::Real, amrex::Real) const noexcept
Definition: CustomDensityProb.H:42
void clear()
Definition: CustomDensityProb.H:49
amrex::GpuArray< amrex::Real, 6 > p
Definition: CustomDensityProb.H:52
InjectorDensityCustom(std::string const &species_name)
Definition: CustomDensityProb.H:24