XGCa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
velocity_grid.hpp
Go to the documentation of this file.
1 #ifndef VELOCITY_GRID_HPP
2 #define VELOCITY_GRID_HPP
3 
4 #include "lagrange_weights.hpp"
5 
6 // Specifies the dimensions of the velocity grid
7 struct VelocityGrid{
8  int nvp;
9  double vp_max;
10  double dvp;
11 
12  int nmu;
13  double smu_max;
14  double dsmu;
15 
16  double inv_mu0_factor = 1.0/3.0;
17 
18  int nvr;
19  int nvz;
20 
22 
24 
26  // Read in basic velocity grid inputs
27  nlr.use_namelist("f0_param");
28  nvp = nlr.get<int>("f0_nvp", 15);
29  nmu = nlr.get<int>("f0_nmu", 31);
30  vp_max = nlr.get<double>("f0_vp_max", 3.0);
31  smu_max = nlr.get<double>("f0_smu_max", 3.0);
32 
33  // Derived values
34  dvp = vp_max/nvp;
35  dsmu = smu_max/nmu;
36  nvr = nmu+1;
37  nvz = nvp*2+1;
38 
39  // Pseudo inverse
40  pseudo_inv_on = nlr.get<bool>("f0_velocity_interp_use_pseudo_inv", false);
41  if(pseudo_inv_on){
42  element_order = nlr.get<int>("f0_velocity_interp_pseudo_inv_order", 2);
43 #ifdef NO_PETSC
44  exit_XGC("\nError: Cannot run with f0_velocity_interp_use_pseudo_inv = true without using PETSc.\n");
45 #endif
46  if (element_order < 0){
47  exit_XGC("\nError: f0_velocity_interp_pseudo_inv_order must be 0 or larger.\n");
48  }
50  std::string msg = "\nError: Cannot use f0_velocity_interp_pseudo_inv_order larger than ";
51  msg += std::to_string(LAGRANGE_MAX_ORDER);
52  msg += ", if you really want to use that large order then modify LAGRANGE_MAX_ORDER in the code.\n";
53  exit_XGC(msg);
54  }
55  if (element_order > 0){
56  if(nmu % element_order != 0){
57  exit_XGC("\nError: f0_nmu must be divisible by f0_velocity_interp_pseudo_inv_order when f0_velocity_interp_use_pseudo_inv = true.\n");
58  }
59  if(2*nvp % element_order != 0){
60  exit_XGC("\nError: 2*f0_nvp must be divisible by f0_velocity_interp_pseudo_inv_order when f0_velocity_interp_use_pseudo_inv = true.\n");
61  }
62  }
63  }else{
64  element_order = 1;
65  }
66  }
67 };
68 #endif
int element_order
velocity grid finite element order (0 = nearest neighbor), (1 = linear), (2 = quadratic), (3 = cubic), ....
Definition: velocity_grid.hpp:21
double smu_max
max mu
Definition: velocity_grid.hpp:13
int nmu
n points in mu (not including zero)
Definition: velocity_grid.hpp:12
int nvp
n points in parallel velocity (not including zero)
Definition: velocity_grid.hpp:8
T get(const string &param, const T default_val, int val_ind=0)
Definition: NamelistReader.hpp:372
bool pseudo_inv_on
whether pseudo-inverse interpolation is used in velocity space
Definition: velocity_grid.hpp:23
Definition: velocity_grid.hpp:7
Definition: NamelistReader.hpp:193
int nvr
full grid size (including zero)
Definition: velocity_grid.hpp:18
void use_namelist(const string &namelist)
Definition: NamelistReader.hpp:354
#define LAGRANGE_MAX_ORDER
Definition: lagrange_weights.hpp:18
double vp_max
max parallel velocity
Definition: velocity_grid.hpp:9
void exit_XGC(std::string msg)
Definition: globals.hpp:36
VelocityGrid(NLReader::NamelistReader &nlr)
Definition: velocity_grid.hpp:25
double dsmu
grid spacing in mu
Definition: velocity_grid.hpp:14
double inv_mu0_factor
Set value of lowest mu in grid –&gt; 1/mu0_factor.
Definition: velocity_grid.hpp:16
int nvz
full grid size (including negative and zero)
Definition: velocity_grid.hpp:19
double dvp
grid spacing in parallel velocity
Definition: velocity_grid.hpp:10