XGCa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Functions/Subroutines
fem_ops.F90 File Reference
#include "petsc_version_defs.h"
#include <petsc/finclude/petsc.h>
Include dependency graph for fem_ops.F90:

Functions/Subroutines

subroutine eval_helm_matrix (fu, uu, grid, bc, op_mode)
 Evaluates \(-\nabla\cdot\nabla f(R,Z)\) (op_mode==1), or the FEM mass-matrix projection of a function in a linear finite element discretization. More...
 
subroutine b_dot_grad_u (bdotgradu, b1, b2, uu, grid)
 
subroutine helm_matrix (grid, Amat, solver_data, alpha, beta, bd, bcflag, xgc_petsc, xgc_petsc_bd, bs, idx, jdx, scale_vec, mat_assemble, ierr)
 This routine sets up the matrix for the LHS of a Helmholtz equation of the form \(\nabla\cdot\left( \alpha\nabla_\perp\phi\right) + \beta \phi\). The routine loops over triangles, evaluates the stiffness matrix of the problem for the element and then proceeds to populate the RHS matrix of the Helmholtz equation with the proper entries of the stiffness matrix. In order to limit the computing time spent on this, triangles that are completely outside of the mesh area assigned to an MPI rank are skipped. More...
 
subroutine diff_matrix (grid, Amat, D, psi_hat_in, tri_center_r, bd, bcflag, mass_flag, xgc_petsc, bs, idx, jdx, scale_vec, mat_assemble, ierr)
 Private/abstracted part of the setup routine for the diffusion matrix Sets up the matrix element of the RHS of Fick's law for diffusive transport: dF/dt = div(D_ij.grad(F) with the diffusion tensor D_ij = D(psi,theta) (psi_hat psi_hat), where D(psi,theta) is a scalar function of the radial and poloidal coordinate, and psi_hat=grad(psi)/|grad(psi)|. More...
 

Function/Subroutine Documentation

subroutine b_dot_grad_u ( real (kind=8), dimension(grid%nnode), intent(out)  bdotgradu,
real (kind=8), dimension(grid%nnode), intent(in)  b1,
real (kind=8), dimension(grid%nnode), intent(in)  b2,
real (kind=8), dimension(grid%nnode), intent(in)  uu,
type(grid_type), intent(in)  grid 
)
Parameters
[out]bdotgraduOutput function \(\boldsymbol{B}\cdot\nabla f(R,Z)\) (w/o toroidal component): \(B_R \partial f/\partial R + B_Z \partial f/\partial Z\), real(8)
[in]b1Major radial component of B ( \(B_R\)), real(8)
[in]b2Vertical component of B ( \(B_Z\)), real(8)
[in]uuInput function \(f(R,Z)\), real(8)
[in]gridXGC grid data structure, type(grid_type)

Here is the call graph for this function:

subroutine diff_matrix ( type(grid_type), intent(in)  grid,
intent(inout)  Amat,
real (kind=8), dimension(grid%ntriangle), intent(in)  D,
real (kind=8), dimension(2,grid%ntriangle), intent(in)  psi_hat_in,
real (kind=8), dimension(grid%ntriangle), intent(in)  tri_center_r,
type(boundary2_type), intent(in)  bd,
logical, intent(in)  bcflag,
integer, intent(in)  mass_flag,
dimension(grid%nnode), intent(in)  xgc_petsc,
intent(in)  bs,
intent(in)  idx,
intent(in)  jdx,
  scale_vec,
logical, intent(in)  mat_assemble,
intent(out)  ierr 
)

Private/abstracted part of the setup routine for the diffusion matrix Sets up the matrix element of the RHS of Fick's law for diffusive transport: dF/dt = div(D_ij.grad(F) with the diffusion tensor D_ij = D(psi,theta) (psi_hat psi_hat), where D(psi,theta) is a scalar function of the radial and poloidal coordinate, and psi_hat=grad(psi)/|grad(psi)|.

Parameters
[in]gridXGC grid data structure, type(grid_type)
[out]AmatPETSc matrix to store the diffusion operator, (PETSc Mat)
[in]DDiffusion coefficient, real(8)
[in]psi_hat_inUnit vector in grad(psi) direction - grad(psi)/|grad(psi)|
[in]tri_center_rCenter radius of the triangles, real(8)
[in]bdSolver boundary, type(bc_type)
[in]bcflagWhether inhomogeneous boundary conditions are used, logical
[in]mass_flagWhether the mass matrix or diffusion matrix is computed (0|1), integer
[in]xgc_petscMapping between XGC grid and PETSc equation number
[in]bsBlock size of the big matrix, PetscInt
[in]idxRow number of the target block, PetscInt
[in]jdxColumn number of the target block, PetscInt
[in]scale_vecVector to scale the rows of the final diffusion matrix, PETSc Vec
[in]mat_assembleWhether to run the final matrix assembly, logical
[out]ierrError flag, PETScErrorCode

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine eval_helm_matrix ( real (kind=8), dimension(grid%nnode), intent(out)  fu,
real (kind=8), dimension(grid%nnode), intent(in)  uu,
type(grid_type), intent(in)  grid,
type(boundary2_type), intent(in)  bc,
integer, intent(in)  op_mode 
)

Evaluates \(-\nabla\cdot\nabla f(R,Z)\) (op_mode==1), or the FEM mass-matrix projection of a function in a linear finite element discretization.

Parameters
[out]fuNeg. Divergence of the gradient of the input function \(-\nabla\cdot\nabla f(R,Z)\), or \(\boldsymbol{M}\cdot f(R,Z)\), real(8)
[in]uuInput function \(f(R,Z)\), real(8)
[in]gridXGC grid data structure, type(grid_type)
[in]bcBoundary location, type(boundary2_type)
[in]op_modeWhether to calculate the Div(grad) (1), or mass matrix M.f (2)

Here is the call graph for this function:

Here is the caller graph for this function:

subroutine helm_matrix ( type (grid_type), intent(in)  grid,
intent(inout)  Amat,
type (solver_init_data), intent(in)  solver_data,
real (kind=8), dimension(grid%ntriangle), intent(in)  alpha,
real (kind=8), dimension(grid%ntriangle), intent(in)  beta,
type(boundary2_type), intent(in)  bd,
logical, intent(in)  bcflag,
dimension(grid%nnode), intent(in)  xgc_petsc,
dimension(grid%nnode), intent(in)  xgc_petsc_bd,
intent(in)  bs,
intent(in)  idx,
intent(in)  jdx,
  scale_vec,
logical, intent(in)  mat_assemble,
intent(out)  ierr 
)

This routine sets up the matrix for the LHS of a Helmholtz equation of the form \(\nabla\cdot\left( \alpha\nabla_\perp\phi\right) + \beta \phi\). The routine loops over triangles, evaluates the stiffness matrix of the problem for the element and then proceeds to populate the RHS matrix of the Helmholtz equation with the proper entries of the stiffness matrix. In order to limit the computing time spent on this, triangles that are completely outside of the mesh area assigned to an MPI rank are skipped.

Parameters
[out]AmatHelmholtz matrix, PETSc Mat
[in]solver_dataData required for LHS setup (mag. field, etc.), type(solver_init_data)
[in]alphaFactor \(\alpha\) in Helmholtz operator at triangle center, real(8)
[in]betaFactor \(\beta\) in Helmholtz operator at triangle center, real(8)
[in]gridXGC grid data structure, type(grid_type)
[in]bdSolver boundary, type(boundary2_type)
[in]bcflagFlag indicating the type of boundary condition used, integer
[in]xgc_petscMapping from XGC vertex index to PETSc equation number, integer
[in]xgc_petsc_bdMapping from XGC vertex index on the solver boundary to PETSc equation number
[in]bsBlock size of the matrix in which to add the Helmholtz operator, PETSc int
[in]idxBlock row index at which to add the Helmholtz operator, PETSc int
[in]jdxBlock column index at which to add the Helmholtz operator, PETSc int
[in]scale_vecScaling vector for scaling the rows of Amat, PETSc Vec
[in]mat_assembleWhether to run the final matrix assembly, logical
[in]ierrExit status, PETSc error type

Here is the call graph for this function:

Here is the caller graph for this function: