WarpX
GetVelocity.H
Go to the documentation of this file.
1 /* Copyright 2021 Hannah Klion
2  *
3  * This file is part of WarpX.
4  *
5  * License: BSD-3-Clause-LBNL
6  */
7 
8 #ifndef WARPX_GET_VELOCITY_H_
9 #define WARPX_GET_VELOCITY_H_
10 
11 #include "VelocityProperties.H"
12 
21 {
22  /* Type of velocity initialization */
24 
25  /* Velocity direction */
26  int m_dir;
27  int m_sign_dir;
28 
30  amrex::Real m_velocity{0};
33 
40  GetVelocity (VelocityProperties const& vel) noexcept;
41 
54  amrex::Real operator() (amrex::Real const x, amrex::Real const y, amrex::Real const z) const noexcept
55  {
56  switch (m_type)
57  {
58  case (VelConstantValue):
59  {
60  return m_sign_dir * m_velocity;
61  }
62  case (VelParserFunction):
63  {
64  return m_sign_dir * m_velocity_parser(x,y,z);
65  }
66  default:
67  {
68  amrex::Abort("Get initial velocity: unknown type");
69  return 0.0;
70  }
71  }
72  }
73 
82  [[nodiscard]]
84  int direction () const noexcept
85  {
86  return m_dir;
87  }
88 };
89 #endif //WARPX_GET_VELOCITY_H_
#define AMREX_GPU_HOST_DEVICE
VelocityInitType
Definition: VelocityProperties.H:16
@ VelConstantValue
Definition: VelocityProperties.H:16
@ VelParserFunction
Definition: VelocityProperties.H:16
void Abort(const std::string &msg)
Definition: GetVelocity.H:21
AMREX_GPU_HOST_DEVICE int direction() const noexcept
Returns the index of the direction of the bulk velocity.
Definition: GetVelocity.H:84
int m_dir
Definition: GetVelocity.H:26
int m_sign_dir
Index x=0, y=1, z=2.
Definition: GetVelocity.H:27
VelocityInitType m_type
Definition: GetVelocity.H:23
amrex::ParserExecutor< 3 > m_velocity_parser
Definition: GetVelocity.H:32
AMREX_GPU_HOST_DEVICE amrex::Real operator()(amrex::Real const x, amrex::Real const y, amrex::Real const z) const noexcept
Functor call. Returns the value of velocity at the location (x,y,z)
Definition: GetVelocity.H:54
amrex::Real m_velocity
Sign of the velocity direction positive=1, negative=-1.
Definition: GetVelocity.H:30
GetVelocity(VelocityProperties const &vel) noexcept
Construct the functor with information provided by vel.
Definition: GetVelocity.cpp:10
Struct to store velocity properties, for use in momentum initialization.
Definition: VelocityProperties.H:26