AdH Kraken 0.0.0
Next generation Adaptive Hydraulics
Loading...
Searching...
No Matches
assemble_jacobian.c File Reference
#include "adh.h"

Functions

void assemble_jacobian (SMODEL_SUPER *sm)
 This function assembles the global FE Jacobian matrix elementwise, using F-D approximation to Jacobian designed to work within Newton method: $ \frac{\partial R (U^{i})}{\partial U^{i}} \delta U^{i} = -R(U^{i}) $ With update formula: $ U^{i+1} = U^{i} + \delta U^{i}$. More...
 
void load_global_mat_split_CSR (double *vals, int *indptr, int *indices, double *off_diag_vals, int *off_diag_indptr, int *off_diag_indices, double **elem_mat, int ndofs_ele, int *dofs, int *global_dofs, int *local_range)
 This function takes an elemental stiffness matrix and loads it to the full sparse matrix in split CSR format. More...
 
void load_global_mat_CSR (double *vals, int *indptr, int *indices, double **elem_mat, int ndofs_ele, int *global_dofs, int *local_range)
 This function takes an elemental stiffness matrix and loads it to the full sparse matrix in standard CSR format. More...
 
void perturb_var (double **elem_mat, SMODEL_SUPER *sm, SMODEL *model, int ie, int nodes_on_element, int nvar_ele, int *elem_vars, int perturb_var_code, int nsubModels, int ele_var_no, int *NodeIDs, int DEBUG)
 Computes elemental Jacobian based on central F-D technique w.r.t one variable (thus filling out one column of the elemental Jacobian). More...
 
void elem_matrix_deriv (double **mat, int node_no, int var_no, int nnodes, int elem_nvars, double *local1, double *local2, double diff_ep)
 Calculates a scond order finite difference of a column within the Jacobian matrix elemental block. More...
 

Detailed Description

This file collections functions responsible for assembling the Jacobian matrix based on central finite difference

Function Documentation

◆ assemble_jacobian()

void assemble_jacobian ( SMODEL_SUPER sm)

This function assembles the global FE Jacobian matrix elementwise, using F-D approximation to Jacobian designed to work within Newton method: $ \frac{\partial R (U^{i})}{\partial U^{i}} \delta U^{i} = -R(U^{i}) $ With update formula: $ U^{i+1} = U^{i} + \delta U^{i}$.

Author
Count Corey J. Trahan
Mark Loveland
Bug:
none
Warning
none
Parameters
[in,out]sm(SMODEL_SUPER*) - pointer to an instant of the SMODEL_SUPER struct - contains pointers to sparse matrix
Note

◆ elem_matrix_deriv()

void elem_matrix_deriv ( double **  mat,
int  node_no,
int  var_no,
int  nnodes,
int  elem_nvars,
double *  local1,
double *  local2,
double  diff_ep 
)
inline

Calculates a scond order finite difference of a column within the Jacobian matrix elemental block.

Author
Corey Trahan, Ph.D.
Gaurav Savant, Ph.D.
Mark Loveland, Ph.D.
Bug:
none
Warning
none
Parameters
[in,out]mat(double**) - the 2D array storing the values of the elemental stiffness matrix
[in]node_no(int) - local node number (local to element)
[in]var_no(int) - the solution variable number (local to element)
[in]nnodes(int) - number of nodes on the element
[in]elem_nvars(int) - number of solution variables active on the element
[in]local1(double*) - elemental residual vector with a (+) perturbation
[in]local2(double*) - elemental residual vector with a (-) perturbation
[in]diff_ep(double) - two times the perturbations size
Note

◆ load_global_mat_CSR()

void load_global_mat_CSR ( double *  vals,
int *  indptr,
int *  indices,
double **  elem_mat,
int  ndofs_ele,
int *  global_dofs,
int *  local_range 
)

This function takes an elemental stiffness matrix and loads it to the full sparse matrix in standard CSR format.

Author
Count Corey J. Trahan
Mark Loveland
Bug:
none
Warning
none
Parameters
[in,out]vals(double*) - pointer to the double array containing all nonzero values in the diagonal block (local to process) part of the sparse matrix
[in]indptr(int*) - pointer to the array containing indeces to start/end of each row in the diagonal block (local to process) part of the sparse matrix
[in]indices(int*) - pointer to the array containing local column numbers of each nonzero entry in the diagonal block (local to process) part of the sparse matrix
[in]elem_mat(double**) - 2D array containing computed values from an elemental stiffness matrix
[in]ndofs_ele(int) - number of degrees of freedom on the element
[in]global_dofs(int*) - the global degrees of freedom present in the element
[in]local_range(int*) - an array of 2 integers that gives global start and end equation number
Note
This function does depend on a binary search algorithm

assembles global residual

◆ load_global_mat_split_CSR()

void load_global_mat_split_CSR ( double *  vals,
int *  indptr,
int *  indices,
double *  off_diag_vals,
int *  off_diag_indptr,
int *  off_diag_indices,
double **  elem_mat,
int  ndofs_ele,
int *  dofs,
int *  global_dofs,
int *  local_range 
)

This function takes an elemental stiffness matrix and loads it to the full sparse matrix in split CSR format.

Author
Count Corey J. Trahan
Mark Loveland
Bug:
none
Warning
none
Parameters
[in,out]vals(double*) - pointer to the double array containing all nonzero values in the diagonal block (local to process) part of the sparse matrix
[in]indptr(int*) - pointer to the array containing indeces to start/end of each row in the diagonal block (local to process) part of the sparse matrix
[in]indices(int*) - pointer to the array containing local column numbers of each nonzero entry in the diagonal block (local to process) part of the sparse matrix
[in,out]off_diag_vals(double*) - pointer to the values of the off-diagonal block (local to process) part of the sparse matrix
[in]off_diag_indptr(int*) - pointer to the array containing indeces to start/end of each row in the off-diagonal block (local to process) part of the sparse matrix
[in]off_diag_indices(int*) - pointer to the array containing global column numbers of each nonzero entry in the off-diagonal block (local to process) part of the sparse matrix
[in]elem_mat(double**) - 2D array containing computed values from an elemental stiffness matrix
[in]ndofs_ele(int) - number of degrees of freedom on the element
[in]dofs(int*) - the degrees of freedom present in the element (local to the process)
[in]global_dofs(int*) - the global degrees of freedom present in the element
[in]local_range(int*) - an array of 2 integers that gives global start and end equation number
Note
This function does depend on a binary search algorithm

assembles global residual

◆ perturb_var()

void perturb_var ( double **  elem_mat,
SMODEL_SUPER sm,
SMODEL model,
int  ie,
int  nodes_on_element,
int  nvar_ele,
int *  elem_vars,
int  perturb_var_code,
int  nsubModels,
int  ele_var_no,
int *  NodeIDs,
int  DEBUG 
)

Computes elemental Jacobian based on central F-D technique w.r.t one variable (thus filling out one column of the elemental Jacobian).

Author
Gaurav Savant, Ph.D.
Corey Trahan, Ph.D.
Mark Loveland, Ph.D.
Bug:
none
Warning
none
Parameters
[in,out]elem_mat(double**) - stores the Jacobian, elemental matrix
[in]sm(SMODEL_SUPER*) - a pointer to the SMODEL_SUPER structure, needed for residual routines
[in]model(SMODEL*) - an array of SMODEL structures, needed to get proper residual routines
[in]ie(int) - the element number (local to process)
[in]nodes_on_element(int) - the number of nodes on the element
[in]nvar_ele(int) - the total number of variables active on element across all residual routines
[in]elem_vars(int*) - the variable codes, an array of length nvar_ele
[in]perturb_var_code(int) - the variable that is being differentiated
[in]nsubModels(int) - number of residual routines to be called on this element
[in]ele_var_no(int) - the index of the variable that is being differentiated (not the var code)
[in]NodeIDs(int*) - the node numbers within the cell (local to the process)
[in]DEBUG(int) - the debug code for more robust output
[in]DEBUGa debug option
Note
The F-D spacing is based on magnitude of solution with lower limit hard coded as 1e-4. Catch is too small small of F-D space leads to large truncation error (division by very small number) but higher F-D space incurs large truncation error especially the more nonlinear the residual is