CAMP 1.0.0
Chemistry Across Multiple Phases
Classes | Macros | Functions
Jacobian.h File Reference

Header for the Jacobian structure and related functions. More...

Include dependency graph for Jacobian.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  JacobianColumnElements
 
struct  Jacobian
 

Macros

#define JACOBIAN_PRODUCTION   0
 
#define JACOBIAN_LOSS   1
 

Functions

int jacobian_initialize_empty (Jacobian *jac, unsigned int num_spec)
 Initialize the Jacobian.
 
int jacobian_initialize (Jacobian *jac, unsigned int num_spec, unsigned int **jac_struct)
 Initialize the Jacobian.
 
void jacobian_register_element (Jacobian *jac, unsigned int dep_id, unsigned int ind_id)
 Adds an element to the sparse matrix.
 
unsigned int jacobian_build_matrix (Jacobian *jac)
 Builds the sparse matrix with the registered elements.
 
unsigned int jacobian_number_of_elements (Jacobian jac)
 Returns the number of elements in the Jacobian.
 
unsigned int jacobian_column_pointer_value (Jacobian jac, unsigned int col_id)
 Returns the value of a column pointer.
 
unsigned int jacobian_row_index (Jacobian jac, unsigned int elem_id)
 Returns the row for a given Jacobian element.
 
unsigned int jacobian_get_element_id (Jacobian jac, unsigned int dep_id, unsigned int ind_id)
 Get an element id in the Jacobian data arrays.
 
void jacobian_reset (Jacobian jac)
 Reset the Jacobian.
 
void jacobian_output (Jacobian jac, double *dest_array)
 Output the Jacobian.
 
void jacobian_add_value (Jacobian jac, unsigned int elem_id, unsigned int prod_or_loss, long double jac_contribution)
 Add a contribution to the Jacobian.
 
void jacobian_print (Jacobian jac)
 Prints the Jacobian structure.
 
void jacobian_column_elements_free (JacobianColumnElements *column)
 Free memory associated with a JacobianColumnElements.
 
void jacobian_free (Jacobian *jac)
 Free memory associated with a Jacobian.
 

Detailed Description

Header for the Jacobian structure and related functions.

Definition in file Jacobian.h.

Macro Definition Documentation

◆ JACOBIAN_LOSS

#define JACOBIAN_LOSS   1

Definition at line 19 of file Jacobian.h.

◆ JACOBIAN_PRODUCTION

#define JACOBIAN_PRODUCTION   0

Definition at line 18 of file Jacobian.h.

Function Documentation

◆ jacobian_add_value()

void jacobian_add_value ( Jacobian  jac,
unsigned int  elem_id,
unsigned int  prod_or_loss,
long double  jac_contribution 
)

Add a contribution to the Jacobian.

Parameters
jacJacobian object
elem_idIndex of the element to update in the data array
prod_or_lossFlag indicating whether to update the (0) production or (1) loss elements
jac_contributionValue to add to the Jacobian element (contributions to loss elements should be positive if the contribution increases the loss)

Definition at line 234 of file Jacobian.c.

Here is the caller graph for this function:

◆ jacobian_build_matrix()

unsigned int jacobian_build_matrix ( Jacobian jac)

Builds the sparse matrix with the registered elements.

Returns
1 on success, 0 otherwise

Definition at line 129 of file Jacobian.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ jacobian_column_elements_free()

void jacobian_column_elements_free ( JacobianColumnElements column)

Free memory associated with a JacobianColumnElements.

Parameters
columnJacobian column elements

Definition at line 274 of file Jacobian.c.

Here is the caller graph for this function:

◆ jacobian_column_pointer_value()

unsigned int jacobian_column_pointer_value ( Jacobian  jac,
unsigned int  col_id 
)

Returns the value of a column pointer.

Parameters
jacJacobian object
col_idColumn index (0...number of columns)
Returns
Column pointer value

Definition at line 192 of file Jacobian.c.

Here is the caller graph for this function:

◆ jacobian_free()

void jacobian_free ( Jacobian jac)

Free memory associated with a Jacobian.

Parameters
jacJacobian object

Definition at line 281 of file Jacobian.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ jacobian_get_element_id()

unsigned int jacobian_get_element_id ( Jacobian  jac,
unsigned int  dep_id,
unsigned int  ind_id 
)

Get an element id in the Jacobian data arrays.

If the element is not included in the sparse matrix, -1 is returned.

Parameters
jacJacobian object
dep_idDependent species index
ind_idIndependent species index
Returns
Index of Jacobian element in the data array

Definition at line 200 of file Jacobian.c.

Here is the caller graph for this function:

◆ jacobian_initialize()

int jacobian_initialize ( Jacobian jac,
unsigned int  num_spec,
unsigned int **  jac_struct 
)

Initialize the Jacobian.

Parameters
jacPointer to the Jacobian object
num_specNumber of species
jac_structDense matrix of flags indicating whether an element is (1) potentially non-zero or (0) not.
Returns
Flag indicating whether the derivative was successfully initialized (0 = false; 1 = true)

Definition at line 46 of file Jacobian.c.

◆ jacobian_initialize_empty()

int jacobian_initialize_empty ( Jacobian jac,
unsigned int  num_spec 
)

Initialize the Jacobian.

Sets up a sparse matrix (num_spec x num_spec) containing zero elements. Elements can be added using the jacobian_register_element function.

Parameters
jacJacobian object
num_specNumber of species
Returns
Flag indicating whether the Jacobian was successfully initialized (0 = false; 1 = true)

Definition at line 20 of file Jacobian.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ jacobian_number_of_elements()

unsigned int jacobian_number_of_elements ( Jacobian  jac)

Returns the number of elements in the Jacobian.

Parameters
jacJacobian object
Returns
Number of Jacobian elements

Definition at line 190 of file Jacobian.c.

Here is the caller graph for this function:

◆ jacobian_output()

void jacobian_output ( Jacobian  jac,
double *  dest_array 
)

Output the Jacobian.

Parameters
jacJacobian object
dest_arrayPointer to the array to save Jacobian data to

Definition at line 223 of file Jacobian.c.

Here is the caller graph for this function:

◆ jacobian_print()

void jacobian_print ( Jacobian  jac)

Prints the Jacobian structure.

Parameters
jacJacobian object

Definition at line 243 of file Jacobian.c.

◆ jacobian_register_element()

void jacobian_register_element ( Jacobian jac,
unsigned int  dep_id,
unsigned int  ind_id 
)

Adds an element to the sparse matrix.

Parameters
jacJacobian object
dep_idDependent species index
ind_idIndependent species index

Definition at line 105 of file Jacobian.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ jacobian_reset()

void jacobian_reset ( Jacobian  jac)

Reset the Jacobian.

Parameters
jacJacobian matrix

Definition at line 216 of file Jacobian.c.

Here is the caller graph for this function:

◆ jacobian_row_index()

unsigned int jacobian_row_index ( Jacobian  jac,
unsigned int  elem_id 
)

Returns the row for a given Jacobian element.

Parameters
jacJacobian object
elem_idJacobian element index (0...number of elements-1)
Returns
Row index for given element

Definition at line 196 of file Jacobian.c.

Here is the caller graph for this function: