XGCa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Classes | Functions
velocity_interpolate.hpp File Reference
#include <Kokkos_Core.hpp>
#include "space_settings.hpp"
#include "sml.hpp"
#include "plasma.hpp"
#include "DM_wrapper.hpp"
#include <petscversion.h>
#include <petscsys.h>
#include <petscdmplex.h>
#include <petscds.h>
#include "petscdmswarm.h"
#include "petscksp.h"
Include dependency graph for velocity_interpolate.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  PseudoInversePetscObjects
 
class  Pseudo_inverse< Device >
 For description see source file. More...
 

Functions

PetscInt pseudo_inverse_interpolate_particles_to_velocity_grid (const DM &dm, Kokkos::View< PetscReal *, Kokkos::LayoutRight, Kokkos::HostSpace > particle_coords, Kokkos::View< PetscReal *, Kokkos::LayoutRight, Kokkos::HostSpace > particle_weights, const PetscInt Nparticles, PetscInt order, const PetscInt Nspecies, Kokkos::View< PetscReal *, Kokkos::LayoutRight, Kokkos::HostSpace > grid_coords, Kokkos::View< PetscReal *, Kokkos::LayoutRight, Kokkos::HostSpace > grid_weights)
 For description see source file. More...
 
PetscErrorCode pseudo_inv_create_Swarm (const DM dm, DM *sw)
 For description see source file. More...
 
PetscErrorCode pseudo_inv_create_projection (const DM dm, DM sw, const PetscInt thread_id, const PetscInt target_id, Kokkos::View< PetscReal *, Kokkos::LayoutRight, Kokkos::HostSpace > particle_coords, Kokkos::View< PetscReal *, Kokkos::LayoutRight, Kokkos::HostSpace > particle_weights, const PetscInt Nparticles, Vec rho, Mat *Mp_out)
 For description see source file. More...
 
PetscErrorCode pseudo_inv_set_rhs (const DM dm, Mat MM, Kokkos::View< PetscReal *, Kokkos::LayoutRight, Kokkos::HostSpace > grid_weights, const PetscInt Ngrid, Vec rho, Vec rhs)
 For description see source file. More...
 
PetscErrorCode pseudo_inv_grid_to_particles (const DM dm, DM sw, Vec rhs, Mat M_p, Mat PM_p, const PetscInt Ngrid, const PetscInt Nparticles, Kokkos::View< PetscReal *, Kokkos::LayoutRight, Kokkos::HostSpace > particle_weights, bool &ksp_converged)
 For description see source file. More...
 
void pseudo_inv_allocate (const Simulation< DeviceType > &sml, const Grid< DeviceType > &grid, const MagneticField< DeviceType > &magnetic_field, Plasma &plasma, const VelocityGrid &vgrid, const DomainDecomposition< DeviceType > &pol_decomp, Pseudo_inverse< DeviceType > &pseudo_inv)
 For description see source file. More...
 
void all_species_update_pseudo_inv_weights (const Simulation< DeviceType > &sml, const Grid< DeviceType > &grid, const MagneticField< DeviceType > &magnetic_field, Plasma &plasma, const VelocityGrid &vgrid, const DomainDecomposition< DeviceType > &pol_decomp, DMWrapper &pseudo_inv_dm, Pseudo_inverse< DeviceType > &pseudo_inv)
 
int max_n_ptl_on_node_and_vgrid_filled (const Simulation< DeviceType > &sml, const Grid< DeviceType > &grid, const MagneticField< DeviceType > &magnetic_field, Plasma &plasma, const VelocityGrid &vgrid, const DomainDecomposition< DeviceType > &pol_decomp, int n_non_adi_species, Kokkos::View< bool **, Kokkos::LayoutRight, DeviceType > vgrid_filled)
 < For description see source file More...
 
template<class Device >
KOKKOS_INLINE_FUNCTION bool pseudo_inv_do_node (const Pseudo_inverse< Device > &pseudo_inv, int isp_non_ad, int node)
 
bool pseudo_inv_do_node_h (Pseudo_inverse< DeviceType > &pseudo_inv, int isp_non_ad, int node)
 

Detailed Description

1.0 A. Mollen, M. Adams, M. Knepley Apr 2022

DESCRIPTION

Header file to velocity_interpolate.cpp Also contains the Pseudo_inverse class which stores arrays to perform the pseudo-inverse mapping.

Function Documentation

void all_species_update_pseudo_inv_weights ( const Simulation< DeviceType > &  sml,
const Grid< DeviceType > &  grid,
const MagneticField< DeviceType > &  magnetic_field,
Plasma plasma,
const VelocityGrid vgrid,
const DomainDecomposition< DeviceType > &  pol_decomp,
DMWrapper pseudo_inv_dm,
Pseudo_inverse< DeviceType > &  pseudo_inv 
)

Update pseudo-inverse full weights (not alpha weights) of all non-adiabatic species.

Parameters
[in]smlcontains simulation control parameters
[in]gridspatial grid object
[in]magnetic_fieldmagnetic field object
[in]plasmaplasma object
[in]vgridcontains the velocity grid dimensions
[in]pol_decompcontains poloidal decomposition info
[in]pseudo_inv_dmpseudo-inverse mesh object
[in,out]pseudo_invpseudo-inverse object (contains pseudo-inverse arrays)
Returns
void

Here is the call graph for this function:

Here is the caller graph for this function:

int max_n_ptl_on_node_and_vgrid_filled ( const Simulation< DeviceType > &  sml,
const Grid< DeviceType > &  grid,
const MagneticField< DeviceType > &  magnetic_field,
Plasma plasma,
const VelocityGrid vgrid,
const DomainDecomposition< DeviceType > &  pol_decomp,
int  n_non_adi_species,
Kokkos::View< bool **, Kokkos::LayoutRight, DeviceType vgrid_filled 
)

< For description see source file

Obtain maximum number of particles on any mesh node for any non-adiabatic species and which nodes are filled in velocity space for all non-adiabatic species (used for pseudo-inverse memory allocation).

Parameters
[in]smlcontains simulation control parameters
[in]gridspatial grid object
[in]magnetic_fieldmagnetic field object
[in]plasmaplasma object
[in]vgridcontains the velocity grid dimensions
[in]pol_decompcontains poloidal decomposition info
[in]n_non_adi_speciesnumber of non-adiabatic species
[in,out]vgrid_filledempty velocity cells array (non-adiabatic species, node)
Returns
maximum number of particles on any mesh node for any non-adiabatic species

Here is the call graph for this function:

Here is the caller graph for this function:

void pseudo_inv_allocate ( const Simulation< DeviceType > &  sml,
const Grid< DeviceType > &  grid,
const MagneticField< DeviceType > &  magnetic_field,
Plasma plasma,
const VelocityGrid vgrid,
const DomainDecomposition< DeviceType > &  pol_decomp,
Pseudo_inverse< DeviceType > &  pseudo_inv 
)

For description see source file.

Set up and allocate pseudo-inverse object.

Parameters
[in]smlcontains simulation control parameters
[in]gridspatial grid object
[in]magnetic_fieldmagnetic field object
[in]plasmaplasma object
[in]vgridcontains the velocity grid dimensions
[in]pol_decompcontains poloidal decomposition info
[in,out]pseudo_invpseudo-inverse object (contains pseudo-inverse arrays)
Returns
void

Here is the call graph for this function:

Here is the caller graph for this function:

PetscErrorCode pseudo_inv_create_projection ( const DM  dm,
DM  sw,
const PetscInt  thread_id,
const PetscInt  target_id,
Kokkos::View< PetscReal *, Kokkos::LayoutRight, Kokkos::HostSpace >  particle_coords,
Kokkos::View< PetscReal *, Kokkos::LayoutRight, Kokkos::HostSpace >  particle_weights,
const PetscInt  Nparticles,
Vec  rho,
Mat *  Mp_out 
)

For description see source file.

Creates a PETSc projection matrix used for the pseudo-inverse velocity interpolation from particle coordinates and weights, based on the PETSc DM velocity grid object containing the velocity grid coordinates and the element (interpolation) order.

Parameters
[in]dmPETSc DM velocity grid object.
[in]swPETSc DM Swarm object.
[in]thread_idID of thread if using OpenMP.
[in]target_idID of thread for visualization if using OpenMP (normally not used, needs PETSc input flags).
[in]particle_coords2*Nparticles-sized array containing the particle coordinates.
[in]particle_weightsNparticles-sized array containing the particle weights.
[in]NparticlesNumber of particles being interpolated.
[out]rhoPETSc helper vector.
[out]Mp_outPETSc projection matrix created.
Returns
PetscErrorCode

Here is the caller graph for this function:

PetscErrorCode pseudo_inv_create_Swarm ( const DM  dm,
DM *  sw 
)

For description see source file.

Creates a PETSc DM Swarm object used for the pseudo-inverse velocity interpolation, based on the PETSc DM velocity grid object containing the velocity grid coordinates and the element (interpolation) order.

Parameters
[in]dmPETSc DM velocity grid object.
[out]swPETSc DM Swarm object created.
Returns
PetscErrorCode

Here is the caller graph for this function:

template<class Device >
KOKKOS_INLINE_FUNCTION bool pseudo_inv_do_node ( const Pseudo_inverse< Device > &  pseudo_inv,
int  isp_non_ad,
int  node 
)

Here is the caller graph for this function:

bool pseudo_inv_do_node_h ( Pseudo_inverse< DeviceType > &  pseudo_inv,
int  isp_non_ad,
int  node 
)
inline

Here is the caller graph for this function:

PetscErrorCode pseudo_inv_grid_to_particles ( const DM  dm,
DM  sw,
Vec  rhs,
Mat  M_p,
Mat  PM_p,
const PetscInt  Ngrid,
const PetscInt  Nparticles,
Kokkos::View< PetscReal *, Kokkos::LayoutRight, Kokkos::HostSpace >  particle_weights,
bool &  ksp_converged 
)

For description see source file.

Performs the velocity grid -> particles interpolation by solving the linear system containing the pseudo-inverse and gives the updated particle weights, based on the PETSc DM velocity grid object containing the velocity grid coordinates and the element (interpolation) order.

Parameters
[in]dmPETSc DM velocity grid object.
[in]swPETSc DM Swarm object.
[in]rhsPETSc right-hand side vector.
[in]M_pPETSc projection matrix.
[in]PM_pPETSc preconditioner matrix.
[in]NgridNumber of velocity grid points.
[in]NparticlesNumber of particles being interpolated.
[out]particle_weightsNparticles-sized array containing the particle weights.
[out]ksp_convergedtrue if the pseudo-inverse calculation converged, otherwise false.
Returns
PetscErrorCode

Here is the call graph for this function:

Here is the caller graph for this function:

PetscErrorCode pseudo_inv_set_rhs ( const DM  dm,
Mat  MM,
Kokkos::View< PetscReal *, Kokkos::LayoutRight, Kokkos::HostSpace >  grid_weights,
const PetscInt  Ngrid,
Vec  rho,
Vec  rhs 
)

For description see source file.

Sets the right-hand side used for the pseudo-inverse velocity interpolation from new grid weights, based on the PETSc DM velocity grid object containing the velocity grid coordinates and the element (interpolation) order.

Parameters
[in]dmPETSc DM velocity grid object.
[in]MMPETSc mass matrix velocity grid object.
[in]grid_weightsNgrid-sized array containing the new velocity grid weights.
[in]NgridNumber of velocity grid points.
[out]rhoPETSc helper vector.
[out]rhsPETSc right-hand side vector.
Returns
PetscErrorCode

Here is the caller graph for this function:

PetscInt pseudo_inverse_interpolate_particles_to_velocity_grid ( const DM &  dm,
Kokkos::View< PetscReal *, Kokkos::LayoutRight, Kokkos::HostSpace >  particle_coords,
Kokkos::View< PetscReal *, Kokkos::LayoutRight, Kokkos::HostSpace >  particle_weights,
const PetscInt  Nparticles,
PetscInt  order,
const PetscInt  Nspecies,
Kokkos::View< PetscReal *, Kokkos::LayoutRight, Kokkos::HostSpace >  grid_coords,
Kokkos::View< PetscReal *, Kokkos::LayoutRight, Kokkos::HostSpace >  grid_weights 
)

For description see source file.

Performs the particles -> velocity grid interpolation of marker particle weights to 2D velocity grid weights.

Parameters
[in]dmis the PETSc DM object created by initialize_pseudo_inverse_interpolation.
[in]particle_coordsis a 2*Nparticles-sized array containing the particle coordinates.
[in]particle_weightsis a Nparticles-sized array containing the particle weights.
[in]Nparticlesis the number of particles being interpolated.
[in]orderis the interpolation order (1 = linear), (2 = quadratic).
[in]Nspeciesis the number of species being interpolated, typically 1.
[in,out]grid_coordsis a 2*NGridPoints-sized array containing the velocity grid coordinates.
[in,out]grid_weightsis a NGridPoints-sized array containing the velocity grid weights.
Returns
the number of grid points.

Here is the call graph for this function:

Here is the caller graph for this function: