XGCa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Functions
charge_sum_and_gyroaverage.cpp File Reference
#include "timer_macro.hpp"
#include "my_subview.hpp"
#include "field_following_coordinates.hpp"
#include "matrix.hpp"
#include "gradient_matrices.hpp"
#include "charge_sum_and_gyroaverage.hpp"
Include dependency graph for charge_sum_and_gyroaverage.cpp:

Functions

double * get_grid_node_vol_loc ()
 
double * get_grid_psi_surf2_loc ()
 
int * get_grid_psi_surf_map_loc ()
 
void get_gyro_avg_mat_data (int ind, int *m, int *n, int *w, int *nnz, int *is_csr_int, int **csr_ridx_or_eindex, int **csr_cidx_or_nelement, double **values)
 
int get_grid_npsi_surf ()
 
void cce_send_receive_density (int x)
 
void cce_send_receive_current (int x)
 
void cce_varpi_grid (double *field_rho_ff)
 
void convert_grid_2_001d_wrap (double *input, double *output)
 
void interpol_1d_wrap (double *x, double *y, int n, double *x1, double *y1, int n1)
 
void smooth_r_wrap (double *input, double *output)
 
void ensure_density_above_zero (const Grid< DeviceType > &grid, Plasma &plasma, bool checking_electrons, View< double **, CLayout, HostType > &field, View< double *, CLayout, HostType > &field0)
 
void gyroaverage_density_field (const DomainDecomposition< DeviceType > &pol_decomp, const std::vector< Matrix< HostType >> &gyro_avg_matrices, View< double ***, CLayout, HostType > &field_rho)
 
void convert_density_field_coordinates (const Grid< DeviceType > &grid, FieldFollowingCoordinates &ff, const View< double **, CLayout, HostType > &input_h, View< double **, CLayout, HostType > &output_h)
 
void reduce_and_normalize_rho0_field (const Grid< DeviceType > &grid, const DomainDecomposition< DeviceType > &pol_decomp, bool use_global_reduction, View< double ***, CLayout, HostType > &field_rho)
 
void average_with_neighbor_planes_and_broadcast (const Grid< DeviceType > &grid, const DomainDecomposition< DeviceType > &pol_decomp, View< double **, CLayout, HostType > &field)
 
void reduce_over_planes_and_broadcast (const Grid< DeviceType > &grid, const DomainDecomposition< DeviceType > &pol_decomp, bool use_global_reduction, const View< double **, CLayout, HostType > &field_in, View< double **, CLayout, HostType > &field)
 
void calculate_density_field (const Grid< DeviceType > &grid, const DomainDecomposition< DeviceType > &pol_decomp, FieldFollowingCoordinates &ff, const std::vector< Matrix< HostType >> &gyro_avg_matrices, bool is_axisymmetric, bool use_global_reduction, View< double ***, CLayout, HostType > &field_rho, View< double **, CLayout, HostType > &field)
 
void calculate_density0_field (const Grid< DeviceType > &grid, const DomainDecomposition< DeviceType > &pol_decomp, bool is_axisymmetric, bool smooth_results, const View< double **, CLayout, HostType > &field, View< double *, CLayout, HostType > &field0)
 
void calculate_den00_1d (const Grid< DeviceType > &grid, const View< double *, CLayout, HostType > density0, View< double *, CLayout, HostType > den00_1d)
 
void add_f0_charge_contribution (const Grid< DeviceType > &grid, bool compute_electrons, Charge< DeviceType > &charge)
 
void cce_all_varpi_grid (bool compute_electrons, const Charge< DeviceType > &charge)
 
void charge_sum_and_gyroaverage (const Simulation< DeviceType > &sml, const Grid< DeviceType > &grid, const DomainDecomposition< DeviceType > &pol_decomp, Charge< DeviceType > &charge, Plasma &plasma, bool compute_electrons)
 

Function Documentation

void add_f0_charge_contribution ( const Grid< DeviceType > &  grid,
bool  compute_electrons,
Charge< DeviceType > &  charge 
)

Adds the grid-based component of the density field to the charge density

Parameters
[in]gridis the grid object
[in]compute_electronsis whether the operation is on electrons or ions
[in,out]chargecontains the computed charge/current densities and the processed charge/current densities
Returns
void

Here is the call graph for this function:

Here is the caller graph for this function:

void average_with_neighbor_planes_and_broadcast ( const Grid< DeviceType > &  grid,
const DomainDecomposition< DeviceType > &  pol_decomp,
View< double **, CLayout, HostType > &  field 
)

Averages the field with the neighboring plane

Parameters
[in]gridis the grid object
[in]pol_decompis the domain decomposition
[in,out]fieldis the density field
Returns
void

Here is the call graph for this function:

Here is the caller graph for this function:

void calculate_den00_1d ( const Grid< DeviceType > &  grid,
const View< double *, CLayout, HostType density0,
View< double *, CLayout, HostType den00_1d 
)

Averages axisymmetric field over flux surfaces and interpolates into flux surface coordinates

Parameters
[in]gridis the grid object
[in]density0is the axisymmetric component of the field
[out]den00_1dis the resulting field
Returns
void

Here is the call graph for this function:

Here is the caller graph for this function:

void calculate_density0_field ( const Grid< DeviceType > &  grid,
const DomainDecomposition< DeviceType > &  pol_decomp,
bool  is_axisymmetric,
bool  smooth_results,
const View< double **, CLayout, HostType > &  field,
View< double *, CLayout, HostType > &  field0 
)

Calculates the axisymmetric component of the field "field0" from the input field "field"

Parameters
[in]gridis the grid object
[in]pol_decompis the domain decomposition
[in]is_axisymmetricis whether the planes can be reduced
[in]smooth_resultsis an option to call a smoothing function
[in]fieldis the input field
[out]field0is the output field
Returns
void

Here is the call graph for this function:

Here is the caller graph for this function:

void calculate_density_field ( const Grid< DeviceType > &  grid,
const DomainDecomposition< DeviceType > &  pol_decomp,
FieldFollowingCoordinates ff,
const std::vector< Matrix< HostType >> &  gyro_avg_matrices,
bool  is_axisymmetric,
bool  use_global_reduction,
View< double ***, CLayout, HostType > &  field_rho,
View< double **, CLayout, HostType > &  field 
)

Takes the field resulting from the scatter, which may have a gyroradius dimension and may be in field-following coordinates. Gyroaverages this field and converts coordinates as needed, and does a reduction on planes if planar data is not needed. Results are written to "field"

Parameters
[in]gridis the grid object
[in]pol_decompis the domain decomposition
[in]ffcontains the field following coordinate conversion matrices
[in]gyro_avg_matricesis the vector of precomputed gyroradius matrices
[in]is_axisymmetricis whether the planes can be reduced
[in]use_global_reductionis an algorithm option that can be used if the field can be reduced and there is no gyroaveraging
[in,out]field_rhois the density field of size (nrho+1, nphi, nnode)
[in,out]fieldis the resulting density field
Returns
void

Here is the call graph for this function:

Here is the caller graph for this function:

void cce_all_varpi_grid ( bool  compute_electrons,
const Charge< DeviceType > &  charge 
)

Core-edge coupling calls fortran routine and provides non-gyroaveraged fields

Parameters
[in]compute_electronsis whether the operation is on electrons or ions
[in]chargecontains the computed charge/current densities and the processed charge/current densities
Returns
void

Here is the call graph for this function:

Here is the caller graph for this function:

void cce_send_receive_current ( int  x)

Here is the caller graph for this function:

void cce_send_receive_density ( int  x)

Here is the caller graph for this function:

void cce_varpi_grid ( double *  field_rho_ff)

Here is the caller graph for this function:

void charge_sum_and_gyroaverage ( const Simulation< DeviceType > &  sml,
const Grid< DeviceType > &  grid,
const DomainDecomposition< DeviceType > &  pol_decomp,
Charge< DeviceType > &  charge,
Plasma plasma,
bool  compute_electrons 
)

Takes the field resulting from the scatter, which may have a gyroradius dimension and may be in field-following coordinates. Gyroaverages this field and converts coordinates as needed, and does a reduction on planes if planar data is not needed. Results are written to "field"

Parameters
[in]smlcontains simulation control parameters
[in]gridis the grid object
[in]pol_decompis the domain decomposition
[in,out]chargecontains the computed charge/current densities and the processed charge/current densities
[in]plasmais needed for the species profile data
[in]is_axisymmetricis whether the planes can be reduced
[in]compute_electronsis whether the operation is on electrons or ions
Returns
void

Here is the call graph for this function:

void convert_density_field_coordinates ( const Grid< DeviceType > &  grid,
FieldFollowingCoordinates ff,
const View< double **, CLayout, HostType > &  input_h,
View< double **, CLayout, HostType > &  output_h 
)

Converts from field-following coordinates to toroidal coordinates. The computation is done on device, so the input/output are copied from/to host

Parameters
[in]gridis the grid object
[in]ffcontains the field following coordinate conversion matrices
[in]input_his the input field, in field-following coordinates
[out]output_his the output field, in toroidal coordinates
Returns
void

Here is the call graph for this function:

Here is the caller graph for this function:

void convert_grid_2_001d_wrap ( double *  input,
double *  output 
)
void ensure_density_above_zero ( const Grid< DeviceType > &  grid,
Plasma plasma,
bool  checking_electrons,
View< double **, CLayout, HostType > &  field,
View< double *, CLayout, HostType > &  field0 
)

Ensures that the total density (calculated density plus the background profile) of [electrons,ions] is not [positive,negative], by adjusting the calculated density to meet this criterion. The axisymmetric field, field0, is checked independently, so the two resulting fields may no longer be consistent.

Parameters
[in]gridis the grid object
[in]plasmacontains the species profile data
[in]checking_electronsis whether this is checking electron density or ion density
[in,out]fieldis the density field
[in,out]field0is the axisymmetric density field
Returns
void

Here is the call graph for this function:

Here is the caller graph for this function:

double* get_grid_node_vol_loc ( )

Here is the caller graph for this function:

int get_grid_npsi_surf ( )

Here is the caller graph for this function:

double* get_grid_psi_surf2_loc ( )

Here is the caller graph for this function:

int* get_grid_psi_surf_map_loc ( )

Here is the caller graph for this function:

void get_gyro_avg_mat_data ( int  ind,
int *  m,
int *  n,
int *  w,
int *  nnz,
int *  is_csr_int,
int **  csr_ridx_or_eindex,
int **  csr_cidx_or_nelement,
double **  values 
)

Here is the caller graph for this function:

void gyroaverage_density_field ( const DomainDecomposition< DeviceType > &  pol_decomp,
const std::vector< Matrix< HostType >> &  gyro_avg_matrices,
View< double ***, CLayout, HostType > &  field_rho 
)

Gyroaverages the field and places the reduced result into the irho=0 component of the field. The calculations are done in a distributed fashion, since different ranks store different gyroradius precomputations

Parameters
[in]pol_decompis the domain decomposition
[in]gyro_avg_matricesis the vector of precomputed gyroradius matrices
[in,out]field_rhois the density field of size (nrho+1, nphi, nnode)
Returns
void

Here is the call graph for this function:

Here is the caller graph for this function:

void interpol_1d_wrap ( double *  x,
double *  y,
int  n,
double *  x1,
double *  y1,
int  n1 
)

Here is the caller graph for this function:

void reduce_and_normalize_rho0_field ( const Grid< DeviceType > &  grid,
const DomainDecomposition< DeviceType > &  pol_decomp,
bool  use_global_reduction,
View< double ***, CLayout, HostType > &  field_rho 
)

Does a normalized intraplane reduction of the fields. If using the "use_global_reduction" algorithm, the reduction is full-domain (i.e. interplane as well)

Parameters
[in]gridis the grid object
[in]pol_decompis the domain decomposition
[in]use_global_reductionis an algorithm option that can be used if the field can be reduced and there is no gyroaveraging
[in,out]field_rhois the density field of size (nrho+1, nphi, nnode)
Returns
void

Here is the call graph for this function:

Here is the caller graph for this function:

void reduce_over_planes_and_broadcast ( const Grid< DeviceType > &  grid,
const DomainDecomposition< DeviceType > &  pol_decomp,
bool  use_global_reduction,
const View< double **, CLayout, HostType > &  field_in,
View< double **, CLayout, HostType > &  field 
)

Does a normalized reduction over planes of the fields, and broadcasts the result. If using the "use_global_reduction" algorithm, no reduction or broadcast is needed here since this was done earlier.

Parameters
[in]gridis the grid object
[in]pol_decompis the domain decomposition
[in]use_global_reductionis an algorithm option that can be used if the field can be reduced and there is no gyroaveraging
[in]field_inis the input field
[in]fieldis the output field
Returns
void

Here is the call graph for this function:

Here is the caller graph for this function:

void smooth_r_wrap ( double *  input,
double *  output 
)