ARTEMIS
Source
Initialization
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
"
11
#include "
Utils/Parser/ParserUtils.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.
22
struct
InjectorDensityCustom
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;
29
WARPX_ALWAYS_ASSERT_WITH_MESSAGE
(v.size() <= 6,
30
"Too many parameters for InjectorDensityCustom"
);
31
utils::parser::getArrWithParser
(
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.
40
AMREX_GPU_HOST_DEVICE
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
:
52
amrex::GpuArray<amrex::Real,6>
p
;
53
};
54
55
#endif
AMReX_Arena.H
AMReX_Dim3.H
AMREX_GPU_HOST_DEVICE
#define AMREX_GPU_HOST_DEVICE
AMReX_Gpu.H
AMReX_ParmParse.H
ParserUtils.H
TextMsg.H
WARPX_ALWAYS_ASSERT_WITH_MESSAGE
#define WARPX_ALWAYS_ASSERT_WITH_MESSAGE(EX, MSG)
Definition:
TextMsg.H:13
amrex::ParmParse
check_interp_points_and_weights.i
i
Definition:
check_interp_points_and_weights.py:174
utils::parser::getArrWithParser
void getArrWithParser(const amrex::ParmParse &a_pp, char const *const str, std::vector< T > &val)
Definition:
ParserUtils.H:240
InjectorDensityCustom
Definition:
CustomDensityProb.H:23
InjectorDensityCustom::getDensity
AMREX_GPU_HOST_DEVICE amrex::Real getDensity(amrex::Real, amrex::Real, amrex::Real) const noexcept
Definition:
CustomDensityProb.H:42
InjectorDensityCustom::clear
void clear()
Definition:
CustomDensityProb.H:49
InjectorDensityCustom::p
amrex::GpuArray< amrex::Real, 6 > p
Definition:
CustomDensityProb.H:52
InjectorDensityCustom::InjectorDensityCustom
InjectorDensityCustom(std::string const &species_name)
Definition:
CustomDensityProb.H:24
amrex::GpuArray< amrex::Real, 6 >
Generated by
1.9.1