XGCa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes | List of all members
LineOfSight Class Reference

Represents a two-dimensional line-of-sight in cylindrical coordinates. More...

#include <line_of_sight.hpp>

Public Member Functions

 LineOfSight ()
 Default constructor. More...
 
 LineOfSight (const Plane< DeviceType > &plane, const double &r0_in, const double &z0_in, const double &theta_in, const double &step_size_in)
 Constructs a line-of-sight based on a given grid and parameters. More...
 
double get_r0 () const
 Returns the R-coordinate of the line-of-sight's origin. More...
 
double get_z0 () const
 Returns the Z-coordinate of the line-of-sight's origin. More...
 
double get_phi0 () const
 Returns the toroidal angle of the line-of-sight's origin. More...
 
double get_theta () const
 Returns the direction angle ( \(\theta\)) of the line-of-sight. More...
 
int get_samples () const
 Returns the number of sample points along the line-of-sight. More...
 
bool is_valid () const
 Indicates whether the line-of-sight is valid. More...
 
void sample_points (const MagneticField< DeviceType > &magnetic_field, View< double *, CLayout, DeviceType > r_los, View< double *, CLayout, DeviceType > z_los, View< double *, CLayout, DeviceType > psi_los) const
 Computes the sample points \((R,Z)\), and the poloidal flux \((\psi)\) along the line-of-sight. More...
 
KOKKOS_INLINE_FUNCTION double interpolate_single (const Plane< DeviceType > &plane, const Kokkos::View< double *, CLayout, DeviceType > &field_in, const int i) const
 Interpolates the field value at a single sample point along the line-of-sight. More...
 
KOKKOS_INLINE_FUNCTION double interpolate_single (const Plane< DeviceType > &plane, const ScalarGridField &field_in, const int i) const
 Interpolates the field value at a single sample point along the line-of-sight. More...
 
View< double *, CLayout,
DeviceType
interpolate_to_los (const Plane< DeviceType > &plane, const ScalarGridField &field_in) const
 Interpolates a ScalarGridField to the sample points on the line-of-sight. More...
 
Kokkos::View< double
*, CLayout, DeviceType
interpolate_to_los (const Plane< DeviceType > &plane, const Kokkos::View< double *, CLayout, DeviceType > &field_in) const
 Interpolates a 1D double view (field data at grid nodes) to the sample points on the line-of-sight. More...
 

Private Attributes

bool valid
 Indicates whether the line-of-sight has been instantiated correctly. More...
 
double r0
 Major radius coordinate of the line-of-sight's origin. More...
 
double z0
 Vertical coordinate (height) of the line-of-sight's origin. More...
 
double phi0
 Toroidal angle of the plane on which the line-of-sight is defined. More...
 
double theta
 Direction of the line of sight. This angle must satisfy \(-\pi<\theta<\pi\). More...
 
double step_size
 Step size or resolution along the line-of-sight in meters. More...
 
int samples
 Number of sample points. More...
 

Detailed Description

Represents a two-dimensional line-of-sight in cylindrical coordinates.

This class defines a two-dimensional line-of-sight in cylindrical coordinates \((R,\varphi,Z)\) with a constant toroidal angle ( \(\varphi\)). The line-of-sight is specified by an origin \((R_0,Z_0)\), a direction angle ( \(\theta\)) measured in radians (with \(-\pi<\theta<\pi\), where \(\theta=0\) corresponds to \(Z=Z_0\)), and a spatial resolution (step_size) in meters. Upon construction, the class determines the number of valid sample points along the line-of-sight based on the provided grid.

If the origin is not on the mesh, the line-of-sight is marked as invalid.

Note
All Kokkos kernels execute on the DeviceType execution space and output results on DeviceType. Copying between Host and Device can be handled externally if needed.

Constructor & Destructor Documentation

LineOfSight::LineOfSight ( )
inline

Default constructor.

Initializes an invalid line-of-sight with all parameters set to zero.

LineOfSight::LineOfSight ( const Plane< DeviceType > &  plane,
const double &  r0_in,
const double &  z0_in,
const double &  theta_in,
const double &  step_size_in 
)

Constructs a line-of-sight based on a given grid and parameters.

This constructor verifies that the specified origin (r0_in, z0_in) lies on the provided grid. If the origin is not on the mesh, the line-of-sight remains invalid. Otherwise, it computes the number of valid sample points along the line-of-sight by stepping from the origin in the direction given by theta_in with increments of step_size_in until a sample point falls outside the grid.

Parameters
[in]planePlane (mesh) object used for determining mesh boundaries and number of samples.
[in]r0_inR-coordinate of the line-of-sight's origin.
[in]z0_inZ-coordinate of the line-of-sight's origin.
[in]theta_inDirection angle (in radians) of the line-of-sight.
[in]step_size_inSpacing (in meters) between consecutive sample points.

Here is the call graph for this function:

Member Function Documentation

double LineOfSight::get_phi0 ( ) const
inline

Returns the toroidal angle of the line-of-sight's origin.

Returns
Origin Z-coordinate.
double LineOfSight::get_r0 ( ) const
inline

Returns the R-coordinate of the line-of-sight's origin.

Returns
Origin R-coordinate.
int LineOfSight::get_samples ( ) const
inline

Returns the number of sample points along the line-of-sight.

Returns
Number of valid sample points.
double LineOfSight::get_theta ( ) const
inline

Returns the direction angle ( \(\theta\)) of the line-of-sight.

Returns
Direction angle in radians.
double LineOfSight::get_z0 ( ) const
inline

Returns the Z-coordinate of the line-of-sight's origin.

Returns
Origin Z-coordinate.
KOKKOS_INLINE_FUNCTION double LineOfSight::interpolate_single ( const Plane< DeviceType > &  plane,
const Kokkos::View< double *, CLayout, DeviceType > &  field_in,
const int  i 
) const

Interpolates the field value at a single sample point along the line-of-sight.

This function computes the interpolated field value at the i-th sample point along the line-of-sight. It first calculates the current position (R, Z) using the line-of-sight parameters (origin, step_size, theta), then performs a grid search using plane.search_tr2_no_precheck to determine the containing triangle and its barycentric weights. Finally, the function gathers the field values from field_in at the nodes of the triangle, weighting them appropriately, and returns the resulting interpolated field value.

Parameters
[in]planeThe plane (mesh) object used for the grid search and retrieving node indices.
[in]field_inA 1D Kokkos::View of doubles containing field data defined on grid nodes.
[in]iThe index of the sample point along the line-of-sight.
Returns
The interpolated field value at the i-th sample point.

Here is the call graph for this function:

Here is the caller graph for this function:

KOKKOS_INLINE_FUNCTION double LineOfSight::interpolate_single ( const Plane< DeviceType > &  plane,
const ScalarGridField field_in,
const int  i 
) const

Interpolates the field value at a single sample point along the line-of-sight.

This function computes the interpolated field value at the i-th sample point along the line-of-sight. It first calculates the current position (R, Z) using the line-of-sight parameters (origin, step_size, theta), then performs a grid search using plane.search_tr2_no_precheck to determine the containing triangle and its barycentric weights. Finally, the function gathers the field values from field_in at the nodes of the triangle, weighting them appropriately, and returns the resulting interpolated field value.

Parameters
[in]planeThe plane (mesh) object used for the grid search and retrieving node indices.
[in]field_inA ScalarGridField containing field data defined on grid nodes.
[in]iThe index of the sample point along the line-of-sight.
Returns
The interpolated field value at the i-th sample point.

Here is the call graph for this function:

View< double *, CLayout, DeviceType > LineOfSight::interpolate_to_los ( const Plane< DeviceType > &  plane,
const ScalarGridField field_in 
) const

Interpolates a ScalarGridField to the sample points on the line-of-sight.

This function interpolates a ScalarGridField (defined on grid nodes) to the sample points along the line-of-sight using barycentric weights. The interpolation is performed on the DeviceType, and the resulting field values are returned as a 1D Kokkos::View.

Parameters
[in]planePlane (mesh) object.
[in]field_inScalarGridField containing field data on the grid (on DeviceType).
Returns
A Kokkos::View<double*, CLayout, DeviceType> containing the interpolated field values.

Here is the call graph for this function:

Kokkos::View< double *, CLayout, DeviceType > LineOfSight::interpolate_to_los ( const Plane< DeviceType > &  plane,
const Kokkos::View< double *, CLayout, DeviceType > &  field_in 
) const

Interpolates a 1D double view (field data at grid nodes) to the sample points on the line-of-sight.

This overload accepts a 1D Kokkos::View containing double values representing field data on grid nodes. The function performs interpolation at each sample point along the line-of-sight using the corresponding barycentric weights computed from the grid.

Parameters
[in]planePlane (mesh) object.
[in]field_in1D Kokkos::View<double*, CLayout, DeviceType> containing field data at grid nodes.
Returns
A Kokkos::View<double*, CLayout, DeviceType> containing the interpolated field values.

Here is the call graph for this function:

bool LineOfSight::is_valid ( ) const
inline

Indicates whether the line-of-sight is valid.

Returns
True if valid; false otherwise.
void LineOfSight::sample_points ( const MagneticField< DeviceType > &  magnetic_field,
View< double *, CLayout, DeviceType r_los,
View< double *, CLayout, DeviceType z_los,
View< double *, CLayout, DeviceType psi_los 
) const

Computes the sample points \((R,Z)\), and the poloidal flux \((\psi)\) along the line-of-sight.

This function allocates and populates three 1D Kokkos::Views (r_los, z_los, psi_los) on the DeviceType. For each sample point, the function computes the (R, Z) coordinates based on the origin, direction, and step size, and then interpolates the poloidal flux using the provided MagneticField.

Parameters
[in]magnetic_fieldMagneticField object used for psi interpolation.
[out]r_losOutput view for R coordinates.
[out]z_losOutput view for Z coordinates.
[out]psi_losOutput view for psi values.

Here is the call graph for this function:

Member Data Documentation

double LineOfSight::phi0
private

Toroidal angle of the plane on which the line-of-sight is defined.

double LineOfSight::r0
private

Major radius coordinate of the line-of-sight's origin.

int LineOfSight::samples
private

Number of sample points.

double LineOfSight::step_size
private

Step size or resolution along the line-of-sight in meters.

double LineOfSight::theta
private

Direction of the line of sight. This angle must satisfy \(-\pi<\theta<\pi\).

bool LineOfSight::valid
private

Indicates whether the line-of-sight has been instantiated correctly.

double LineOfSight::z0
private

Vertical coordinate (height) of the line-of-sight's origin.


The documentation for this class was generated from the following files: