XGCa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
diffusion.cpp File Reference
#include "timer_macro.hpp"
#include "update_ptl_weights.hpp"
#include "toroidal_average.hpp"
#include "poly_basis.hpp"
#include "moments.hpp"
#include "loadable_buffer.hpp"
#include "flux_surface_average.hpp"
#include "diffusion.hpp"
#include "basic_physics.hpp"
Include dependency graph for diffusion.cpp:

Functions

void smooth_pol_wrap (double *input_array, double *output_array)
 
void fourier_filter_update_analytic (double *alpha)
 
void diffusion_solve (int n, double *buffer, double dt)
 
int get_grid_npsi_surf ()
 
void transpose_moments (Plasma &plasma, const Moments &moments_h, View< double *, CLayout, DeviceType > &den, View< double **, CLayout, DeviceType > &u_para, View< double **, CLayout, DeviceType > &T_para, View< double **, CLayout, DeviceType > &T_perp)
 
void smooth_and_filter (const View< double *, CLayout, DeviceType > &view)
 
void smooth_moments (const DomainDecomposition< DeviceType > &pol_decomp, View< double *, CLayout, DeviceType > &den, View< double **, CLayout, DeviceType > &u_para, View< double **, CLayout, DeviceType > &T_para, View< double **, CLayout, DeviceType > &T_perp, bool is_XGCa)
 
void pack_solve_unpack (View< double *, CLayout, DeviceType > &den, View< double **, CLayout, DeviceType > &u_para, View< double **, CLayout, DeviceType > &T_para, View< double **, CLayout, DeviceType > &T_perp, double dt, bool electron_on)
 
void calculate_df_one_sp (const DomainDecomposition< DeviceType > &pol_decomp, const Species< DeviceType > &species, const PolynomialBasis< DeviceType > &polynomial_basis, const VGridDistribution< DeviceType > &f0_f, const View< double *, CLayout, DeviceType > &den, const View< double *, CLayout, DeviceType > &den_old, const View< double **, CLayout, DeviceType > &u_para, const View< double **, CLayout, DeviceType > &T_para, const View< double **, CLayout, DeviceType > &T_perp, const View< bool *, CLayout, DeviceType > &is_in_bounds, VGridDistribution< DeviceType > &delta_f)
 
VGridDistribution< DeviceTypecalculate_df (Plasma &plasma, const DomainDecomposition< DeviceType > &pol_decomp, const VelocityGrid &vgrid, const VGridDistribution< DeviceType > &f0_f, const View< double *, CLayout, DeviceType > &den, const View< double *, CLayout, DeviceType > &den_old, const View< double **, CLayout, DeviceType > &u_para, const View< double **, CLayout, DeviceType > &T_para, const View< double **, CLayout, DeviceType > &T_perp, const View< bool *, CLayout, DeviceType > &is_in_bounds)
 
void calculate_flux_surface_averaged_diffs (const View< double *, CLayout, DeviceType > &den_old, const View< double *, CLayout, DeviceType > &den, const View< double **, CLayout, DeviceType > &u_para_old, const View< double **, CLayout, DeviceType > &u_para, const View< double **, CLayout, DeviceType > &T_old, const View< double **, CLayout, DeviceType > &T, View< double *, CLayout, DeviceType > &delta_den00, View< double **, CLayout, DeviceType > &delta_u_para00, View< double **, CLayout, DeviceType > &delta_T00)
 
void calculate_dfM (const DomainDecomposition< DeviceType > &pol_decomp, Plasma &plasma, const View< bool *, CLayout, DeviceType > &is_in_bounds, const View< double *, CLayout, DeviceType > &delta_den00, const View< double **, CLayout, DeviceType > &delta_u_para00, const View< double **, CLayout, DeviceType > &delta_T00, VGridDistribution< DeviceType > &dfM)
 
void update_analytic (const DomainDecomposition< DeviceType > &pol_decomp, Plasma &plasma, const ElectricField< DeviceType > &electric_field, const View< bool *, CLayout, DeviceType > &is_in_bounds, const View< double *, CLayout, DeviceType > &delta_den00, const View< double **, CLayout, DeviceType > &delta_u_para00, const View< double **, CLayout, DeviceType > &delta_T00, bool electron_on, bool is_XGCa, double dpot_te_limit)
 
void add_delta_f_to_f0_df0g (VGridDistribution< DeviceType > &f0_df0g, VGridDistribution< DeviceType > &delta_f)
 
void remove_dfM_from_f0_df0g (VGridDistribution< DeviceType > &f0_df0g, VGridDistribution< DeviceType > &dfM)
 
View< bool *, CLayout, DeviceTypecheck_is_in_bounds (const Grid< DeviceType > &grid, const DomainDecomposition< DeviceType > &pol_decomp, double inner_psi_bound, double outer_psi_bound)
 
void calculate_full_T (const View< double **, CLayout, DeviceType > &T_perp, const View< double **, CLayout, DeviceType > &T_para, const View< double **, CLayout, DeviceType > &T)
 

Function Documentation

void add_delta_f_to_f0_df0g ( VGridDistribution< DeviceType > &  f0_df0g,
VGridDistribution< DeviceType > &  delta_f 
)

Adds delta_f to f0_df0g

Parameters
[in,out]f0_df0gOverall change to distribution function
[in]delta_fThe change in distribution function inferred from evolution of the moments

Here is the call graph for this function:

Here is the caller graph for this function:

VGridDistribution<DeviceType> calculate_df ( Plasma plasma,
const DomainDecomposition< DeviceType > &  pol_decomp,
const VelocityGrid vgrid,
const VGridDistribution< DeviceType > &  f0_f,
const View< double *, CLayout, DeviceType > &  den,
const View< double *, CLayout, DeviceType > &  den_old,
const View< double **, CLayout, DeviceType > &  u_para,
const View< double **, CLayout, DeviceType > &  T_para,
const View< double **, CLayout, DeviceType > &  T_perp,
const View< bool *, CLayout, DeviceType > &  is_in_bounds 
)

Calculates delta_f of each species inferred from evolution of the moments

Parameters
[in]plasmaPlasma object used to loop over species
[in]pol_decompDomain decomposition object
[in]vgridVelocity grid information
[in]f0_fInitial distribution function
[out]denDensity moment
[out]den_oldDensity moment before diffusion
[out]u_paraParallel velocity moment
[out]T_paraParallel temperature moment
[out]T_perpPerpendicular temperature moment
[in]is_in_boundsWhether each mesh node is in bounds return The change in distribution function inferred from evolution of the moments

Here is the call graph for this function:

Here is the caller graph for this function:

void calculate_df_one_sp ( const DomainDecomposition< DeviceType > &  pol_decomp,
const Species< DeviceType > &  species,
const PolynomialBasis< DeviceType > &  polynomial_basis,
const VGridDistribution< DeviceType > &  f0_f,
const View< double *, CLayout, DeviceType > &  den,
const View< double *, CLayout, DeviceType > &  den_old,
const View< double **, CLayout, DeviceType > &  u_para,
const View< double **, CLayout, DeviceType > &  T_para,
const View< double **, CLayout, DeviceType > &  T_perp,
const View< bool *, CLayout, DeviceType > &  is_in_bounds,
VGridDistribution< DeviceType > &  delta_f 
)

Calculates delta_f of one species inferred from evolution of the moments

Parameters
[in]pol_decompDomain decomposition object
[in]speciesSpecies object
[in]polynomial_basisBasis functions to represent distribution with polynomials
[in]f0_fInitial distribution function
[out]denDensity moment
[out]den_oldDensity moment before diffusion
[out]u_paraParallel velocity moment
[out]T_paraParallel temperature moment
[out]T_perpPerpendicular temperature moment
[in]is_in_boundsWhether each mesh node is in bounds
[in,out]delta_fThe change in distribution function inferred from evolution of the moments

Here is the call graph for this function:

Here is the caller graph for this function:

void calculate_dfM ( const DomainDecomposition< DeviceType > &  pol_decomp,
Plasma plasma,
const View< bool *, CLayout, DeviceType > &  is_in_bounds,
const View< double *, CLayout, DeviceType > &  delta_den00,
const View< double **, CLayout, DeviceType > &  delta_u_para00,
const View< double **, CLayout, DeviceType > &  delta_T00,
VGridDistribution< DeviceType > &  dfM 
)

Calculates the change to the distribution function that was transferred to f0_delta_n etc

Parameters
[in]pol_decompDomain decomposition object
[in]plasmaPlasma object used to loop over species and for analytic moments
[in]is_in_boundsWhether each mesh node is in bounds
[in]delta_den00Flux surface averaged change in density moment
[in]delta_u_para00Flux surface averaged change in parallel velocity moment
[in]delta_T00Flux surface averaged change in temperature moment
[out]dfMThe change to the distribution function that was transferred to f0_delta_n etc

Here is the call graph for this function:

Here is the caller graph for this function:

void calculate_flux_surface_averaged_diffs ( const View< double *, CLayout, DeviceType > &  den_old,
const View< double *, CLayout, DeviceType > &  den,
const View< double **, CLayout, DeviceType > &  u_para_old,
const View< double **, CLayout, DeviceType > &  u_para,
const View< double **, CLayout, DeviceType > &  T_old,
const View< double **, CLayout, DeviceType > &  T,
View< double *, CLayout, DeviceType > &  delta_den00,
View< double **, CLayout, DeviceType > &  delta_u_para00,
View< double **, CLayout, DeviceType > &  delta_T00 
)

Returns the flux surface average of the difference between the old moments and the updated moments. Most of the code is to copy the moments to CPU and the results back to GPU. This can be streamlined when the flux surface average function is moved to C++.

Parameters
[in]den_oldDensity moment before diffusion
[in]denDensity moment
[in]u_para_oldParallel velocity moment before diffusion
[in]u_paraParallel velocity moment
[in]T_oldTemperature moments before diffusion
[in]TTemperature moment
[out]delta_den00Flux surface averaged change in density moment
[out]delta_u_para00Flux surface averaged change in parallel velocity moment
[out]delta_T00Flux surface averaged change in temperature moment

Here is the call graph for this function:

Here is the caller graph for this function:

void calculate_full_T ( const View< double **, CLayout, DeviceType > &  T_perp,
const View< double **, CLayout, DeviceType > &  T_para,
const View< double **, CLayout, DeviceType > &  T 
)

Here is the call graph for this function:

Here is the caller graph for this function:

View<bool*, CLayout, DeviceType> check_is_in_bounds ( const Grid< DeviceType > &  grid,
const DomainDecomposition< DeviceType > &  pol_decomp,
double  inner_psi_bound,
double  outer_psi_bound 
)

Returns a view marking whether each mesh node is in bounds

Parameters
[in]gridThe grid object
[in]pol_decompThe domain decomposition
[in]inner_psi_boundThe minimum psi value to be in bounds
[in]outer_psi_boundThe maximum psi value to be in bounds return View marking whether each mesh node is in bounds

Here is the call graph for this function:

Here is the caller graph for this function:

void diffusion_solve ( int  n,
double *  buffer,
double  dt 
)
void fourier_filter_update_analytic ( double *  alpha)
int get_grid_npsi_surf ( )
void pack_solve_unpack ( View< double *, CLayout, DeviceType > &  den,
View< double **, CLayout, DeviceType > &  u_para,
View< double **, CLayout, DeviceType > &  T_para,
View< double **, CLayout, DeviceType > &  T_perp,
double  dt,
bool  electron_on 
)

Packs the moments into a buffer formatted for the diffusion solve, calls the solve and unpacks back into the original format. This also transfers the moments from device to host and back

Parameters
[in,out]denDensity moment
[in,out]u_paraParallel velocity moment
[in,out]T_paraParallel temperature moment
[in,out]T_perpPerpendicular temperature moment
[in]dtTime step
[in]electron_onWhether kinetic electrons also need to be solved

Here is the call graph for this function:

Here is the caller graph for this function:

void remove_dfM_from_f0_df0g ( VGridDistribution< DeviceType > &  f0_df0g,
VGridDistribution< DeviceType > &  dfM 
)

Subtracts dfM to f0_df0g since this part of the distribution function has been transferred to the analytic f0 representation (f0_delta_n etc)

Parameters
[in,out]f0_df0gOverall change to distribution function
[in]dfMThe change to the distribution function that was transferred to f0_delta_n etc

Here is the call graph for this function:

Here is the caller graph for this function:

void smooth_and_filter ( const View< double *, CLayout, DeviceType > &  view)

Here is the call graph for this function:

Here is the caller graph for this function:

void smooth_moments ( const DomainDecomposition< DeviceType > &  pol_decomp,
View< double *, CLayout, DeviceType > &  den,
View< double **, CLayout, DeviceType > &  u_para,
View< double **, CLayout, DeviceType > &  T_para,
View< double **, CLayout, DeviceType > &  T_perp,
bool  is_XGCa 
)

Toroidally average, smooth and filter the input moments

Parameters
[in]pol_decompDomain decomposition object for toroidal averaging
[in,out]denDensity moment
[in,out]u_paraParallel velocity moment
[in,out]T_paraParallel temperature moment
[in,out]T_perpPerpendicular temperature moment

Here is the call graph for this function:

Here is the caller graph for this function:

void smooth_pol_wrap ( double *  input_array,
double *  output_array 
)
void transpose_moments ( Plasma plasma,
const Moments moments_h,
View< double *, CLayout, DeviceType > &  den,
View< double **, CLayout, DeviceType > &  u_para,
View< double **, CLayout, DeviceType > &  T_para,
View< double **, CLayout, DeviceType > &  T_perp 
)

Transposes the moments and sends to device. The moments in the Moments class have species as the contiguous index, while the functions in diffusion expect those reversed. The moments class is also only for nonadiabatic species, so adiabatic electrons are handled separately here.

Parameters
[in]plasmaPlasma object used to loop over species
[in]moments_hMoments
[out]denDensity moment
[out]u_paraParallel velocity moment
[out]T_paraParallel temperature moment
[out]T_perpPerpendicular temperature moment

Here is the call graph for this function:

Here is the caller graph for this function:

void update_analytic ( const DomainDecomposition< DeviceType > &  pol_decomp,
Plasma plasma,
const ElectricField< DeviceType > &  electric_field,
const View< bool *, CLayout, DeviceType > &  is_in_bounds,
const View< double *, CLayout, DeviceType > &  delta_den00,
const View< double **, CLayout, DeviceType > &  delta_u_para00,
const View< double **, CLayout, DeviceType > &  delta_T00,
bool  electron_on,
bool  is_XGCa,
double  dpot_te_limit 
)

Updates delta_n, delta_u, and delta_T for each species, based on the flux surface averaged moment changes

Parameters
[in]pol_decompDomain decomposition object
[in,out]plasmaPlasma object to be updated
[in]electric_fieldUsed for dpot to remove adiabatic response
[in]is_in_boundsWhether each mesh node is in bounds
[in]delta_den00Flux surface averaged change in density moment
[in]delta_u_para00Flux surface averaged change in parallel velocity moment
[in]delta_T00Flux surface averaged change in temperature moment
[in]electron_onWhether electrons are kinetic
[in]is_XGCaWhether simulation is XGCa. dpot is toroidally averaged but this is not needed for XGCa due to axisymmetry
[in]dpot_te_limitLimit for dpot. This should be removed eventually (it should be a member variable of a dpot class)

Here is the call graph for this function:

Here is the caller graph for this function: