XGCa
|
#include <grid.hpp>
Public Member Functions | |
Grid (NLReader::NamelistReader &nlr, const GridFiles &grid_files, const DomainDecomposition< DeviceType > &pol_decomp, const MagneticField< DeviceType > &magnetic_field) | |
Grid () | |
template<class Device2 > | |
Grid< Device2 > | mirror () const |
void | write_to_file (const DomainDecomposition< DeviceType > &pol_decomp, MagneticEquilFiles::Ptr equil_files_ptr, bool is_stellarator) const |
KOKKOS_INLINE_FUNCTION void | psi_search (double psi, double &wp, int &ip) const |
template<PhiInterpType PIT> | |
KOKKOS_INLINE_FUNCTION void | nearest_node (const SimdGridWeights< Order::One, PIT > &grid_wts, SimdGridWeights< Order::Zero, PIT > &grid_wts0) const |
template<PhiInterpType PIT> | |
KOKKOS_INLINE_FUNCTION void | get_grid_weights (const MagneticField< Device > &magnetic_field, const SimdVector &v, const Simd< double > &psi, SimdVector2D &xff, SimdGridWeights< Order::One, PIT > &grid_wts) const |
template<PhiInterpType PIT> | |
KOKKOS_INLINE_FUNCTION void | get_grid_weights (const MagneticField< Device > &magnetic_field, const SimdVector &v, SimdVector2D &xff, SimdGridWeights< Order::One, PIT > &grid_wts) const |
template<PhiInterpType PIT> | |
KOKKOS_INLINE_FUNCTION void | get_grid_weights (const MagneticField< Device > &magnetic_field, const SimdVector &v, const Simd< double > &psi_in, SimdGridWeights< Order::Zero, PIT > &grid_wts) const |
template<PhiInterpType PIT> | |
KOKKOS_INLINE_FUNCTION void | get_grid_weights (const MagneticField< Device > &magnetic_field, const SimdVector &v, const Simd< double > &psi_in, SimdGridWeights< Order::One, PIT > &grid_wts) const |
template<PhiInterpType PIT> | |
KOKKOS_INLINE_FUNCTION void | get_grid_weights (const MagneticField< Device > &magnetic_field, const SimdVector &v, SimdGridWeights< Order::Zero, PIT > &grid_wts) const |
template<PhiInterpType PIT> | |
KOKKOS_INLINE_FUNCTION void | get_grid_weights (const MagneticField< Device > &magnetic_field, const SimdVector &v, SimdGridWeights< Order::One, PIT > &grid_wts) const |
KOKKOS_INLINE_FUNCTION void | get_wall_index (const Simd< bool > &just_left_the_grid, const SimdVector2D &x, const SimdGridWeights< Order::One, PIT_GLOBAL > &grid_wts, Simd< int > &widx) const |
KOKKOS_INLINE_FUNCTION void | wedge_modulo_phi (Simd< double > &phi_mod) const |
KOKKOS_INLINE_FUNCTION double | wedge_modulo_phi (double phi) const |
KOKKOS_INLINE_FUNCTION bool | node_is_inside_psi_range (const MagneticField< Device > &magnetic_field, const int node) const |
KOKKOS_INLINE_FUNCTION int | get_plane_index (double phi) const |
Bounds | get_local_wedge_bounds () const |
KOKKOS_INLINE_FUNCTION int | get_node_index (int triangle_index, int tri_vertex_index) const |
KOKKOS_INLINE_FUNCTION double | node_area_to_volume (const MagneticField< Device > &magnetic_field, double area, int node_index) const |
KOKKOS_INLINE_FUNCTION void | get_triangle_area_and_volume (const MagneticField< Device > &magnetic_field, int i, double &area, double &volume) const |
KOKKOS_INLINE_FUNCTION bool | node_is_in_region_1_or_2_no_wall (const int inode) const |
KOKKOS_INLINE_FUNCTION bool | node_is_in_region_2_or_3_no_wall (const int inode) const |
KOKKOS_INLINE_FUNCTION bool | node_is_in_private_region_no_wall (const int inode) const |
KOKKOS_INLINE_FUNCTION bool | node_is_in_included_region (const int inode, const bool exclude_private_region) const |
KOKKOS_INLINE_FUNCTION bool | node_is_in_region_1_or_2 (const MagneticField< Device > &magnetic_field, const int inode) const |
KOKKOS_INLINE_FUNCTION int | uses_rz_basis (const int inode) const |
KOKKOS_INLINE_FUNCTION double | get_r (const int inode) const |
KOKKOS_INLINE_FUNCTION void | get_rz_coordinates (const int inode, double &r, double &z) const |
KOKKOS_INLINE_FUNCTION void | get_rz_coordinates (const Simd< int > &grid_inds, SimdVector2D &x) const |
KOKKOS_INLINE_FUNCTION RZPair | get_wall_rz (int i_wall) const |
template<> | |
void | write_to_file (const DomainDecomposition< DeviceType > &pol_decomp, MagneticEquilFiles::Ptr equil_files_ptr, bool is_stellarator) const |
Public Attributes | |
bool | axisymmetric |
Plane< Device > | midplane |
Plane< Device > | lplane |
Plane< Device > | rplane |
int | ntriangle |
Number of grid triangles. More... | |
int | nnode |
Number of grid nodes. More... | |
int | nplanes |
Number of planes. More... | |
double | wedge_angle |
The size of the wedge (the model is periodic in phi, a angle of e.g. pi means half the tokamak is modeled) More... | |
double | delta_phi |
Distance between planes. More... | |
double | inv_delta_phi |
1/delta_phi More... | |
int | nwall |
int | npsi_surf2 |
double | minval_psi_surf2 |
double | maxval_psi_surf2 |
UniformRange | psi00 |
Kokkos::View< double *, Kokkos::LayoutRight, Device > | psi |
An array of psi coordinates. More... | |
Kokkos::View< double *, Kokkos::LayoutRight, Device > | bfield |
Magnetic field magnitude at nodes. More... | |
Kokkos::View< double *, Kokkos::LayoutRight, Device > | psi_surf2 |
Kokkos::View< int *, Kokkos::LayoutRight, Device > | wall_nodes |
VolumesAndAreas | volumes_and_areas |
Projection< HostType > | half_plane_ff |
Projection< HostType > | ff_rplane_to_neighbors |
Projection< HostType > | ff_lplane_to_neighbors |
Projection< HostType > | ff_to_midplane |
FluxSurfaceAverage< Device > | fsa_matrices |
Private Member Functions | |
template<> | |
Grid (NLReader::NamelistReader &nlr, const GridFiles &grid_files, const DomainDecomposition< DeviceType > &pol_decomp, const MagneticField< DeviceType > &magnetic_field) | |
Friends | |
template<class Device2 > | |
class | Grid |
Grid< Device >::Grid | ( | NLReader::NamelistReader & | nlr, |
const GridFiles & | grid_files, | ||
const DomainDecomposition< DeviceType > & | pol_decomp, | ||
const MagneticField< DeviceType > & | magnetic_field | ||
) |
|
private |
< Calculate node volume using Monte-Carlo method (true), or analytic method (false)
KOKKOS_INLINE_FUNCTION void Grid< Device >::get_grid_weights | ( | const MagneticField< Device > & | magnetic_field, |
const SimdVector & | v, | ||
const Simd< double > & | psi_in, | ||
SimdVector2D & | xff, | ||
SimdGridWeights< Order::One, PIT > & | grid_wts | ||
) | const |
Get the grid triangle and vertex weights for a vector of locations.
[in] | magnetic_field | The magnetic field object (currently global so technically unnecessary) |
[in] | v | Vector of (r,z, phi) coordinates |
[in] | phi | Vector of phi coordinates |
[in] | psi_in | Vector of psi coordinates |
[out] | xff | Vector of (r,z) coordinates mapped along B-field to midplane |
[out] | itr | Vector of grid triangles |
[out] | p | Vector of triangle vertex weights |
KOKKOS_INLINE_FUNCTION void Grid< Device >::get_grid_weights | ( | const MagneticField< Device > & | magnetic_field, |
const SimdVector & | v, | ||
SimdVector2D & | xff, | ||
SimdGridWeights< Order::One, PIT > & | grid_wts | ||
) | const |
KOKKOS_INLINE_FUNCTION void Grid< Device >::get_grid_weights | ( | const MagneticField< Device > & | magnetic_field, |
const SimdVector & | v, | ||
const Simd< double > & | psi_in, | ||
SimdGridWeights< Order::Zero, PIT > & | grid_wts | ||
) | const |
KOKKOS_INLINE_FUNCTION void Grid< Device >::get_grid_weights | ( | const MagneticField< Device > & | magnetic_field, |
const SimdVector & | v, | ||
const Simd< double > & | psi, | ||
SimdGridWeights< Order::One, PIT > & | grid_wts | ||
) | const |
Get the grid triangle and vertex weights for a vector of locations.
[in] | magnetic_field | The magnetic field object |
[in] | v | Vector of (r,z,phi) coordinates |
[in] | psi | Vector of psi coordinates |
[out] | itr | Vector of grid triangles |
[out] | p | Vector of triangle vertex weights |
KOKKOS_INLINE_FUNCTION void Grid< Device >::get_grid_weights | ( | const MagneticField< Device > & | magnetic_field, |
const SimdVector & | v, | ||
SimdGridWeights< Order::Zero, PIT > & | grid_wts | ||
) | const |
KOKKOS_INLINE_FUNCTION void Grid< Device >::get_grid_weights | ( | const MagneticField< Device > & | magnetic_field, |
const SimdVector & | v, | ||
SimdGridWeights< Order::One, PIT > & | grid_wts | ||
) | const |
Get the grid triangle and vertex weights for a vector of locations.
[in] | magnetic_field | The magnetic field object |
[in] | v | Vector of (r,z,phi) coordinates |
[out] | itr | Vector of grid triangles |
[out] | p | Vector of triangle vertex weights |
Returns the phi bounds of the local wedge.
[in] | plane_index | the plane index/offset |
KOKKOS_INLINE_FUNCTION int Grid< Device >::get_node_index | ( | int | triangle_index, |
int | tri_vertex_index | ||
) | const |
Returns the index of the node (0-indexed), for a given triangle and triangle vertex index
[in] | triangle_index | the index of the triangle (1-indexed) |
[in] | tri_vertex_index | the index of the requested vertex on the triangle |
KOKKOS_INLINE_FUNCTION int Grid< Device >::get_plane_index | ( | double | phi | ) | const |
Returns the index of the plane, rounded down.
[in] | phi | the phi value |
KOKKOS_INLINE_FUNCTION double Grid< Device >::get_r | ( | const int | inode | ) | const |
Accesses the r coordinate of the grid node
[in] | inode | grid node to check |
KOKKOS_INLINE_FUNCTION void Grid< Device >::get_rz_coordinates | ( | const int | inode, |
double & | r, | ||
double & | z | ||
) | const |
Returns rz coordinates of a single node
[in] | inode | node index |
[out] | r | r coordinate |
[out] | z | z coordinate |
KOKKOS_INLINE_FUNCTION void Grid< Device >::get_rz_coordinates | ( | const Simd< int > & | grid_inds, |
SimdVector2D & | x | ||
) | const |
Returns vector of rz coordinates of the input node indices
[in] | grid_inds | Vector of node indices |
[out] | x | Vector of rz coordinates |
KOKKOS_INLINE_FUNCTION void Grid< Device >::get_triangle_area_and_volume | ( | const MagneticField< Device > & | magnetic_field, |
int | i, | ||
double & | area, | ||
double & | volume | ||
) | const |
Returns analytical calculation of triangle area and projected volume
[in] | magnetic_field | is the magnetic field |
[in] | i | is the triangle index (0-indexed) |
[out] | area | is the triangle area |
[out] | volume | is the triangle projected volume |
KOKKOS_INLINE_FUNCTION void Grid< Device >::get_wall_index | ( | const Simd< bool > & | just_left_the_grid, |
const SimdVector2D & | x, | ||
const SimdGridWeights< Order::One, PIT_GLOBAL > & | grid_wts, | ||
Simd< int > & | widx | ||
) | const |
Find nearest wall point for a vector of locations.
[in] | just_left_the_grid | Vector of whether particles have left the grid |
[in] | x | Vector of (r,z) coordinates |
[in] | itr | Vector of grid triangles the particles were last in |
[in] | p | Vector of the vertex weighting in those triangles |
[out] | widx | Vector of wall point indices |
KOKKOS_INLINE_FUNCTION RZPair Grid< Device >::get_wall_rz | ( | int | i_wall | ) | const |
Returns the (r,z) coordinates of a wall vertex given the index in wall_nodes
[in] | i_wall | is the wall index requested |
|
inline |
KOKKOS_INLINE_FUNCTION void Grid< Device >::nearest_node | ( | const SimdGridWeights< Order::One, PIT > & | grid_wts, |
SimdGridWeights< Order::Zero, PIT > & | grid_wts0 | ||
) | const |
KOKKOS_INLINE_FUNCTION double Grid< Device >::node_area_to_volume | ( | const MagneticField< Device > & | magnetic_field, |
double | area, | ||
int | node_index | ||
) | const |
Returns analytical calculation of node volume by projecting the node area into the toroidal direction Assumes the center of mass is the node
[in] | magnetic_field | is the magnetic field |
[in] | area | is the area of the node |
[in] | node_index | is the node index |
KOKKOS_INLINE_FUNCTION bool Grid< Device >::node_is_in_included_region | ( | const int | inode, |
const bool | exclude_private_region | ||
) | const |
Checks if a grid node lies within an included region. This excludes wall nodes and the private region if specified.
[in] | inode | grid node to check |
[in] | exclude_private_region | whether to private region is excluded |
KOKKOS_INLINE_FUNCTION bool Grid< Device >::node_is_in_private_region_no_wall | ( | const int | inode | ) | const |
KOKKOS_INLINE_FUNCTION bool Grid< Device >::node_is_in_region_1_or_2 | ( | const MagneticField< Device > & | magnetic_field, |
const int | inode | ||
) | const |
Checks if a grid node lies within region 1 or 2. Note this is subtly different from rgn, because rgn also has a wall option
[in] | magnetic_field | the magnetic field object |
[in] | inode | grid node to check |
KOKKOS_INLINE_FUNCTION bool Grid< Device >::node_is_in_region_1_or_2_no_wall | ( | const int | inode | ) | const |
Checks if a grid node lies within region 1 or 2. Excludes wall since rgn is a different value there
[in] | inode | grid node to check |
KOKKOS_INLINE_FUNCTION bool Grid< Device >::node_is_in_region_2_or_3_no_wall | ( | const int | inode | ) | const |
KOKKOS_INLINE_FUNCTION bool Grid< Device >::node_is_inside_psi_range | ( | const MagneticField< Device > & | magnetic_field, |
const int | node | ||
) | const |
Checks if a grid node lies within the simulation domain (radially).
[in] | magnetic_field | the magnetic field object (currently global so technically unnecessary) |
[in] | node | grid node to check (0-indexed) |
KOKKOS_INLINE_FUNCTION void Grid< Device >::psi_search | ( | double | psi, |
double & | wp, | ||
int & | ip | ||
) | const |
KOKKOS_INLINE_FUNCTION int Grid< Device >::uses_rz_basis | ( | const int | inode | ) | const |
Whether the field uses an r-z or a psi-theta basis.
[in] | inode | grid node to check |
KOKKOS_INLINE_FUNCTION void Grid< Device >::wedge_modulo_phi | ( | Simd< double > & | phi_mod | ) | const |
Modulo phi in place: Keep phi between 0 and wedge_angle. Best algorithm as long as the particles haven't left the wedge multiple times over
[in,out] | phi_mod | Vector of phi coordinates |
KOKKOS_INLINE_FUNCTION double Grid< Device >::wedge_modulo_phi | ( | double | phi | ) | const |
Modulo phi in place: Keep phi between 0 and wedge_angle. Best algorithm as long as the particles haven't left the wedge multiple times over
[in,out] | phi_mod | Vector of phi coordinates |
void Grid< Device >::write_to_file | ( | const DomainDecomposition< DeviceType > & | pol_decomp, |
MagneticEquilFiles::Ptr | equil_files_ptr, | ||
bool | is_stellarator | ||
) | const |
void Grid< HostType >::write_to_file | ( | const DomainDecomposition< DeviceType > & | pol_decomp, |
MagneticEquilFiles::Ptr | equil_files_ptr, | ||
bool | is_stellarator | ||
) | const |
bool Grid< Device >::axisymmetric |
Kokkos::View<double*,Kokkos::LayoutRight,Device> Grid< Device >::bfield |
Magnetic field magnitude at nodes.
double Grid< Device >::delta_phi |
Distance between planes.
Projection<HostType> Grid< Device >::ff_lplane_to_neighbors |
Projection<HostType> Grid< Device >::ff_rplane_to_neighbors |
Projection<HostType> Grid< Device >::ff_to_midplane |
FluxSurfaceAverage<Device> Grid< Device >::fsa_matrices |
Projection<HostType> Grid< Device >::half_plane_ff |
double Grid< Device >::inv_delta_phi |
1/delta_phi
double Grid< Device >::maxval_psi_surf2 |
double Grid< Device >::minval_psi_surf2 |
int Grid< Device >::nnode |
Number of grid nodes.
int Grid< Device >::nplanes |
Number of planes.
int Grid< Device >::npsi_surf2 |
int Grid< Device >::ntriangle |
Number of grid triangles.
int Grid< Device >::nwall |
Kokkos::View<double*,Kokkos::LayoutRight,Device> Grid< Device >::psi |
An array of psi coordinates.
UniformRange Grid< Device >::psi00 |
Kokkos::View<double*,Kokkos::LayoutRight,Device> Grid< Device >::psi_surf2 |
VolumesAndAreas Grid< Device >::volumes_and_areas |
Kokkos::View<int*,Kokkos::LayoutRight,Device> Grid< Device >::wall_nodes |
double Grid< Device >::wedge_angle |
The size of the wedge (the model is periodic in phi, a angle of e.g. pi means half the tokamak is modeled)