XGCa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
charge.hpp
Go to the documentation of this file.
1 #ifndef CHARGE_HPP
2 #define CHARGE_HPP
3 #include "space_settings.hpp"
4 #include "electric_field.hpp"
5 
6 // Charge class
7 template<class Device>
8 class Charge {
9  public:
10 
11  // Constructor
12  Charge(bool use_current, int nnode, int nphi, int nrho, int npsi00, int nthreads, bool is_electrons);
13 
14  // Default constructor
15  Charge(){}
16 
18  bool use_current;
19 
20  // Host views
21  View<double**,CLayout,HostType> density_h;
22  View<double*,CLayout,HostType> density0_h;
23  View<double*,CLayout,HostType> den00_1d_h;
24 
25  View<double**,CLayout,HostType> jpar_h;
26  View<double*,CLayout,HostType> jpar0_h;
27 
28  View<double**,CLayout,HostType> den_f0_h;
29 
30  // ions only
31  View<double***,CLayout,HostType> den_rho_ff_h;
32  View<double***,CLayout,HostType> jpar_rho_ff_h;
33 
34  // Device views
35  View<double****,CLayout,Device> density;
36 
37  // EXPLICIT_EM
38  View<double****,CLayout,Device> jpar;
39 
40  void reset_to_zero();
41 };
42 
43 struct Charges{
46 
48 #ifdef USE_ARRAY_REPLICATION
49  int nthreads = sml.nthreads;
50 #else
51  int nthreads = 1;
52 #endif
53  int nphi = (sml.is_XGCa ? 1 : 2);
54  electron = Charge<DeviceType>(sml.explicit_electromagnetic, grid.nnode, nphi, 0, grid.npsi00, nthreads, true);
55  ion = Charge<DeviceType>(sml.explicit_electromagnetic, grid.nnode, nphi, grid.nrho, grid.npsi00, nthreads, false);
56  }
57 
58  // Probably temporary: constructor that doesn't require Grid or PerturbedBField as inputs so that it can be constructed independently
59  Charges(const Simulation<DeviceType>& sml, int nnode, int npsi00, int nrho){
60 #ifdef USE_ARRAY_REPLICATION
61  int nthreads = sml.nthreads;
62 #else
63  int nthreads = 1;
64 #endif
65  int nphi = (sml.is_XGCa ? 1 : 2);
66  electron = Charge<DeviceType>(sml.explicit_electromagnetic, nnode, nphi, 0, npsi00, nthreads, true);
67  ion = Charge<DeviceType>(sml.explicit_electromagnetic, nnode, nphi, nrho, npsi00, nthreads, false);
68  }
69 };
70 
71 #include "charge.tpp"
72 
73 #endif
bool is_electrons
Definition: charge.hpp:17
Charges(const Grid< DeviceType > &grid, const Simulation< DeviceType > &sml)
Definition: charge.hpp:47
void reset_to_zero()
Definition: charge.tpp:46
Definition: charge.hpp:43
const bool explicit_electromagnetic
Equivalent to the preprocessor flag for now.
Definition: sml.hpp:29
View< double ***, CLayout, HostType > jpar_rho_ff_h
Definition: charge.hpp:32
View< double **, CLayout, HostType > jpar_h
Definition: charge.hpp:25
Definition: sml.hpp:8
Charge< DeviceType > ion
Definition: charge.hpp:45
bool use_current
Whether the class will handle current in addition to charge density.
Definition: charge.hpp:18
View< double ***, CLayout, HostType > den_rho_ff_h
Definition: charge.hpp:31
int nrho
Definition: grid.hpp:129
Charge< DeviceType > electron
Definition: charge.hpp:44
View< double ****, CLayout, Device > jpar
Electron current distribution.
Definition: charge.hpp:38
int npsi00
Definition: grid.hpp:114
int nthreads
Number of OMP threads on the host.
Definition: sml.hpp:52
View< double *, CLayout, HostType > den00_1d_h
Definition: charge.hpp:23
Charges(const Simulation< DeviceType > &sml, int nnode, int npsi00, int nrho)
Definition: charge.hpp:59
View< double **, CLayout, HostType > density_h
Definition: charge.hpp:21
View< double *, CLayout, HostType > jpar0_h
Definition: charge.hpp:26
View< double ****, CLayout, Device > density
Electron density distribution.
Definition: charge.hpp:35
const bool is_XGCa
Equivalent to the preprocessor flag for now.
Definition: sml.hpp:15
Definition: charge.hpp:8
int nnode
Number of grid nodes.
Definition: grid.hpp:83
View< double **, CLayout, HostType > den_f0_h
Definition: charge.hpp:28
View< double *, CLayout, HostType > density0_h
Definition: charge.hpp:22
Charge()
Definition: charge.hpp:15