![]() |
programmer's documentation
|
#include "cs_defs.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <float.h>
#include <bft_mem.h>
#include "cs_evaluate.h"
#include "cs_log.h"
#include "cs_math.h"
#include "cs_mesh_location.h"
#include "cs_source_term.h"
Macros | |
#define | CS_SOURCE_TERM_DBG 0 |
Functions | |
static char * | _get_name (const char *name, const char *base_name, int id) |
Allocate and initialize a name (copy or generic name) More... | |
static void | _set_mask (const cs_source_term_t *st, int st_id, cs_mask_t *cell_mask) |
Update the mask associated to each cell from the mask related to the given source term structure. More... | |
void | cs_source_term_set_shared_pointers (const cs_cdo_quantities_t *quant, const cs_cdo_connect_t *connect, const cs_time_step_t *time_step) |
Set shared pointers to main domain members. More... | |
cs_source_term_t * | cs_source_term_destroy (int n_source_terms, cs_source_term_t *source_terms) |
Destroy an array of cs_source_term_t structures. More... | |
void | cs_source_term_def_by_value (cs_source_term_t *st, int st_id, const char *name, cs_param_var_type_t var_type, int ml_id, cs_flag_t flag, const char *val) |
Generic way to define a cs_source_term_t structure by value. More... | |
void | cs_source_term_def_by_analytic (cs_source_term_t *st, int st_id, const char *name, cs_param_var_type_t var_type, int ml_id, cs_flag_t flag, cs_analytic_func_t *func) |
Define a cs_source_term_t structure thanks to an analytic function. More... | |
void | cs_source_term_def_by_array (cs_source_term_t *st, int st_id, const char *name, cs_param_var_type_t var_type, int ml_id, cs_flag_t flag, cs_desc_t desc, cs_real_t *array) |
Define a cs_source_term_t structure thanks to an array of values. More... | |
void | cs_source_term_set_quadrature (cs_source_term_t *st, cs_quadra_type_t quad_type) |
Set advanced parameters which are defined by default in a source term structure. More... | |
cs_flag_t | cs_source_term_set_default_flag (cs_space_scheme_t scheme) |
Set the default flag related to a source term according to the numerical scheme chosen for discretizing an equation. More... | |
void | cs_source_term_set_reduction (cs_source_term_t *st, cs_flag_t flag) |
Set advanced parameters which are defined by default in a source term structure. More... | |
cs_flag_t | cs_source_term_get_flag (const cs_source_term_t *st) |
Get metadata related to the given source term structure. More... | |
const char * | cs_source_term_get_name (const cs_source_term_t *st) |
Get the name related to a cs_source_term_t structure. More... | |
void | cs_source_term_summary (const char *eqname, const cs_source_term_t *st) |
Summarize the content of a cs_source_term_t structure. More... | |
cs_flag_t | cs_source_term_init (cs_space_scheme_t space_scheme, const int n_source_terms, const cs_source_term_t *source_terms, cs_source_term_cellwise_t *compute_source[], cs_flag_t *sys_flag, cs_mask_t *source_mask[]) |
Initialize data to build the source terms. More... | |
void | cs_source_term_compute_cellwise (const int n_source_terms, const cs_source_term_t *source_terms, const cs_cell_mesh_t *cm, const cs_flag_t sys_flag, const cs_mask_t *source_mask, cs_source_term_cellwise_t *compute_source[], cs_cell_builder_t *cb, cs_cell_sys_t *csys) |
Compute the local contributions of source terms in a cell. More... | |
void | cs_source_term_compute (cs_desc_t dof_desc, const cs_source_term_t *source, double *p_values[]) |
Compute the contribution related to a source term. More... | |
void | cs_source_term_pvsp_by_value (const cs_source_term_t *source, const cs_cell_mesh_t *cm, cs_cell_builder_t *cb, double *values) |
Compute the contribution for a cell related to a source term and add it the given array of values. Case of a scalar potential defined at primal vertices by a constant value. A discrete Hodge operator has to be computed before this call and stored inside a cs_cell_builder_t structure. More... | |
void | cs_source_term_pvsp_by_analytic (const cs_source_term_t *source, const cs_cell_mesh_t *cm, cs_cell_builder_t *cb, double *values) |
Compute the contribution for a cell related to a source term and add it the given array of values. Case of a scalar potential defined at primal vertices by an analytical function. A discrete Hodge operator has to be computed before this call and stored inside a cs_cell_builder_t structure. More... | |
void | cs_source_term_dcsd_by_value (const cs_source_term_t *source, const cs_cell_mesh_t *cm, cs_cell_builder_t *cb, double *values) |
Compute the contribution for a cell related to a source term and add it the given array of values. Case of a scalar density defined at dual cells by a value. More... | |
void | cs_source_term_dcsd_bary_by_analytic (const cs_source_term_t *source, const cs_cell_mesh_t *cm, cs_cell_builder_t *cb, double *values) |
Compute the contribution for a cell related to a source term and add it the given array of values. Case of a scalar density defined at dual cells by an analytical function. Use the barycentric approximation as quadrature to evaluate the integral. Exact for linear function. More... | |
void | cs_source_term_dcsd_q1o1_by_analytic (const cs_source_term_t *source, const cs_cell_mesh_t *cm, cs_cell_builder_t *cb, double *values) |
Compute the contribution for a cell related to a source term and add it the given array of values. Case of a scalar density defined at dual cells by an analytical function. Use a the barycentric approximation as quadrature to evaluate the integral. Exact for linear function. More... | |
void | cs_source_term_dcsd_q10o2_by_analytic (const cs_source_term_t *source, const cs_cell_mesh_t *cm, cs_cell_builder_t *cb, double *values) |
Compute the contribution for a cell related to a source term and add it the given array of values. Case of a scalar density defined at dual cells by an analytical function. Use a ten-point quadrature rule to evaluate the integral. Exact for quadratic function. More... | |
void | cs_source_term_dcsd_q5o3_by_analytic (const cs_source_term_t *source, const cs_cell_mesh_t *cm, cs_cell_builder_t *cb, double *values) |
Compute the contribution for a cell related to a source term and add it the given array of values. Case of a scalar density defined at dual cells by an analytical function. Use a five-point quadrature rule to evaluate the integral. Exact for cubic function. This function may be expensive since many evaluations are needed. Please use it with care. More... | |
void | cs_source_term_vcsp_by_value (const cs_source_term_t *source, const cs_cell_mesh_t *cm, cs_cell_builder_t *cb, double *values) |
Compute the contribution for a cell related to a source term and add it the given array of values. Case of a scalar potential defined at primal vertices and cells by a constant value. A discrete Hodge operator has to be computed before this call and stored inside a cs_cell_builder_t structure. More... | |
void | cs_source_term_vcsp_by_analytic (const cs_source_term_t *source, const cs_cell_mesh_t *cm, cs_cell_builder_t *cb, double *values) |
Compute the contribution for a cell related to a source term and add it the given array of values. Case of a scalar potential defined at primal vertices and cells by an analytical function. A discrete Hodge operator has to be computed before this call and stored inside a cs_cell_builder_t structure. More... | |
Variables | |
static const char | _err_empty_st [] |
static const cs_cdo_quantities_t * | cs_cdo_quant |
static const cs_cdo_connect_t * | cs_cdo_connect |
static const cs_time_step_t * | cs_time_step |
#define CS_SOURCE_TERM_DBG 0 |
|
inlinestatic |
Allocate and initialize a name (copy or generic name)
[in] | name | input name |
[in] | basename | generic name by default if input name is NULL |
[in] | id | id related to this name |
|
static |
Update the mask associated to each cell from the mask related to the given source term structure.
[in] | st | pointer to a cs_source_term_t structure |
[in] | st_mask | id related to this source term |
[in,out] | cell_mask | mask related to each cell to be updated |
void cs_source_term_compute | ( | cs_desc_t | dof_desc, |
const cs_source_term_t * | source, | ||
double * | p_values[] | ||
) |
Compute the contribution related to a source term.
[in] | dof_desc | description of the associated DoF |
[in] | source | pointer to a cs_source_term_t structure |
[in,out] | p_values | pointer to the computed values (allocated if NULL) |
void cs_source_term_compute_cellwise | ( | const int | n_source_terms, |
const cs_source_term_t * | source_terms, | ||
const cs_cell_mesh_t * | cm, | ||
const cs_flag_t | sys_flag, | ||
const cs_mask_t * | source_mask, | ||
cs_source_term_cellwise_t * | compute_source[], | ||
cs_cell_builder_t * | cb, | ||
cs_cell_sys_t * | csys | ||
) |
Compute the local contributions of source terms in a cell.
[in] | n_source_terms | number of source terms |
[in] | source_terms | pointer to the definitions of source terms |
[in] | cm | pointer to a cs_cell_mesh_t structure |
[in] | sys_flag | metadata about the algebraic system |
[in] | source_mask | array storing in a compact way which source term is defined in a given cell |
[in] | compute_source | array of function pointers |
[in,out] | cb | pointer to a cs_cell_builder_t structure |
[in,out] | csys | cellwise algebraic system |
void cs_source_term_dcsd_bary_by_analytic | ( | const cs_source_term_t * | source, |
const cs_cell_mesh_t * | cm, | ||
cs_cell_builder_t * | cb, | ||
double * | values | ||
) |
Compute the contribution for a cell related to a source term and add it the given array of values. Case of a scalar density defined at dual cells by an analytical function. Use the barycentric approximation as quadrature to evaluate the integral. Exact for linear function.
Compute the contribution for a cell related to a source term and add it the given array of values. Case of a scalar density defined at dual cells by an analytical function. Use a the barycentric approximation as quadrature to evaluate the integral. Exact for linear function.
[in] | source | pointer to a cs_source_term_t structure |
[in] | cm | pointer to a cs_cell_mesh_t structure |
[in,out] | cb | pointer to a cs_cell_builder_t structure |
[in,out] | values | pointer to the computed values |
void cs_source_term_dcsd_by_value | ( | const cs_source_term_t * | source, |
const cs_cell_mesh_t * | cm, | ||
cs_cell_builder_t * | cb, | ||
double * | values | ||
) |
Compute the contribution for a cell related to a source term and add it the given array of values. Case of a scalar density defined at dual cells by a value.
[in] | source | pointer to a cs_source_term_t structure |
[in] | cm | pointer to a cs_cell_mesh_t structure |
[in,out] | cb | pointer to a cs_cell_builder_t structure |
[in,out] | values | pointer to the computed values |
void cs_source_term_dcsd_q10o2_by_analytic | ( | const cs_source_term_t * | source, |
const cs_cell_mesh_t * | cm, | ||
cs_cell_builder_t * | cb, | ||
double * | values | ||
) |
Compute the contribution for a cell related to a source term and add it the given array of values. Case of a scalar density defined at dual cells by an analytical function. Use a ten-point quadrature rule to evaluate the integral. Exact for quadratic function.
[in] | source | pointer to a cs_source_term_t structure |
[in] | cm | pointer to a cs_cell_mesh_t structure |
[in,out] | cb | pointer to a cs_cell_builder_t structure |
[in,out] | values | pointer to the computed values |
void cs_source_term_dcsd_q1o1_by_analytic | ( | const cs_source_term_t * | source, |
const cs_cell_mesh_t * | cm, | ||
cs_cell_builder_t * | cb, | ||
double * | values | ||
) |
Compute the contribution for a cell related to a source term and add it the given array of values. Case of a scalar density defined at dual cells by an analytical function. Use a the barycentric approximation as quadrature to evaluate the integral. Exact for linear function.
[in] | source | pointer to a cs_source_term_t structure |
[in] | cm | pointer to a cs_cell_mesh_t structure |
[in,out] | cb | pointer to a cs_cell_builder_t structure |
[in,out] | values | pointer to the computed values |
void cs_source_term_dcsd_q5o3_by_analytic | ( | const cs_source_term_t * | source, |
const cs_cell_mesh_t * | cm, | ||
cs_cell_builder_t * | cb, | ||
double * | values | ||
) |
Compute the contribution for a cell related to a source term and add it the given array of values. Case of a scalar density defined at dual cells by an analytical function. Use a five-point quadrature rule to evaluate the integral. Exact for cubic function. This function may be expensive since many evaluations are needed. Please use it with care.
[in] | source | pointer to a cs_source_term_t structure |
[in] | cm | pointer to a cs_cell_mesh_t structure |
[in,out] | cb | pointer to a cs_cell_builder_t structure |
[in,out] | values | pointer to the computed values |
void cs_source_term_def_by_analytic | ( | cs_source_term_t * | st, |
int | st_id, | ||
const char * | name, | ||
cs_param_var_type_t | var_type, | ||
int | ml_id, | ||
cs_flag_t | flag, | ||
cs_analytic_func_t * | func | ||
) |
Define a cs_source_term_t structure thanks to an analytic function.
[in,out] | st | pointer to the cs_source_term_t structure to set |
[in] | st_id | id related to source term to define |
[in] | name | name of the source term |
[in] | var_type | type of variable (scalar, vector...) |
[in] | ml_id | id related to the mesh location |
[in] | flag | metadata related to this source term |
[in] | func | pointer to a function |
void cs_source_term_def_by_array | ( | cs_source_term_t * | st, |
int | st_id, | ||
const char * | name, | ||
cs_param_var_type_t | var_type, | ||
int | ml_id, | ||
cs_flag_t | flag, | ||
cs_desc_t | desc, | ||
cs_real_t * | array | ||
) |
Define a cs_source_term_t structure thanks to an array of values.
[in,out] | st | pointer to the cs_source_term_t structure to set |
[in] | st_id | id related to source term to define |
[in] | name | name of the source term |
[in] | var_type | type of variable (scalar, vector...) |
[in] | ml_id | id related to the mesh location |
[in] | flag | metadata related to this source term |
[in] | desc | description of the main feature of this array |
[in] | array | pointer to an array |
void cs_source_term_def_by_value | ( | cs_source_term_t * | st, |
int | st_id, | ||
const char * | name, | ||
cs_param_var_type_t | var_type, | ||
int | ml_id, | ||
cs_flag_t | flag, | ||
const char * | val | ||
) |
Generic way to define a cs_source_term_t structure by value.
[in,out] | st | pointer to the cs_source_term_t structure to set |
[in] | st_id | id related to source term to define |
[in] | name | name of the source term |
[in] | var_type | type of variable (scalar, vector...) |
[in] | ml_id | id related to the mesh location |
[in] | flag | metadata related to this source term |
[in] | val | accessor to the value to set |
cs_source_term_t* cs_source_term_destroy | ( | int | n_source_terms, |
cs_source_term_t * | source_terms | ||
) |
Destroy an array of cs_source_term_t structures.
[in] | n_source_terms | number of source terms |
[in,out] | source_terms | pointer to a cs_source_term_t structure |
cs_flag_t cs_source_term_get_flag | ( | const cs_source_term_t * | st | ) |
Get metadata related to the given source term structure.
[in,out] | st | pointer to a cs_source_term_t structure |
const char* cs_source_term_get_name | ( | const cs_source_term_t * | st | ) |
Get the name related to a cs_source_term_t structure.
[in] | st | pointer to a cs_source_term_t structure |
cs_flag_t cs_source_term_init | ( | cs_space_scheme_t | space_scheme, |
const int | n_source_terms, | ||
const cs_source_term_t * | source_terms, | ||
cs_source_term_cellwise_t * | compute_source[], | ||
cs_flag_t * | sys_flag, | ||
cs_mask_t * | source_mask[] | ||
) |
Initialize data to build the source terms.
[in] | space_scheme | scheme used to discretize in space |
[in] | n_source_terms | number of source terms |
[in] | source_terms | pointer to the definitions of source terms |
[in,out] | compute_source | array of function pointers |
[in,out] | sys_flag | metadata about the algebraic system |
[in,out] | source_mask | pointer to an array storing in a compact way which source term is defined in a given cell |
void cs_source_term_pvsp_by_analytic | ( | const cs_source_term_t * | source, |
const cs_cell_mesh_t * | cm, | ||
cs_cell_builder_t * | cb, | ||
double * | values | ||
) |
Compute the contribution for a cell related to a source term and add it the given array of values. Case of a scalar potential defined at primal vertices by an analytical function. A discrete Hodge operator has to be computed before this call and stored inside a cs_cell_builder_t structure.
[in] | source | pointer to a cs_source_term_t structure |
[in] | cm | pointer to a cs_cell_mesh_t structure |
[in,out] | cb | pointer to a cs_cell_builder_t structure |
[in,out] | values | pointer to the computed values |
void cs_source_term_pvsp_by_value | ( | const cs_source_term_t * | source, |
const cs_cell_mesh_t * | cm, | ||
cs_cell_builder_t * | cb, | ||
double * | values | ||
) |
Compute the contribution for a cell related to a source term and add it the given array of values. Case of a scalar potential defined at primal vertices by a constant value. A discrete Hodge operator has to be computed before this call and stored inside a cs_cell_builder_t structure.
[in] | source | pointer to a cs_source_term_t structure |
[in] | cm | pointer to a cs_cell_mesh_t structure |
[in,out] | cb | pointer to a cs_cell_builder_t structure |
[in,out] | values | pointer to the computed values |
cs_flag_t cs_source_term_set_default_flag | ( | cs_space_scheme_t | scheme | ) |
Set the default flag related to a source term according to the numerical scheme chosen for discretizing an equation.
[in] | scheme | numerical scheme used for the discretization |
void cs_source_term_set_quadrature | ( | cs_source_term_t * | st, |
cs_quadra_type_t | quad_type | ||
) |
Set advanced parameters which are defined by default in a source term structure.
Set the type of quadrature to use for computing the source term.
[in,out] | st | pointer to a cs_source_term_t structure |
[in] | quad_type | type of quadrature to use |
void cs_source_term_set_reduction | ( | cs_source_term_t * | st, |
cs_flag_t | flag | ||
) |
Set advanced parameters which are defined by default in a source term structure.
[in,out] | st | pointer to a cs_source_term_t structure |
[in] | flag | CS_FLAG_DUAL or CS_FLAG_PRIMAL |
void cs_source_term_set_shared_pointers | ( | const cs_cdo_quantities_t * | quant, |
const cs_cdo_connect_t * | connect, | ||
const cs_time_step_t * | time_step | ||
) |
Set shared pointers to main domain members.
[in] | quant | additional mesh quantities struct. |
[in] | connect | pointer to a cs_cdo_connect_t struct. |
[in] | time_step | pointer to a time step structure |
void cs_source_term_summary | ( | const char * | eqname, |
const cs_source_term_t * | st | ||
) |
Summarize the content of a cs_source_term_t structure.
[in] | eqname | name of the related equation |
[in] | st | pointer to a cs_source_term_t structure |
void cs_source_term_vcsp_by_analytic | ( | const cs_source_term_t * | source, |
const cs_cell_mesh_t * | cm, | ||
cs_cell_builder_t * | cb, | ||
double * | values | ||
) |
Compute the contribution for a cell related to a source term and add it the given array of values. Case of a scalar potential defined at primal vertices and cells by an analytical function. A discrete Hodge operator has to be computed before this call and stored inside a cs_cell_builder_t structure.
[in] | source | pointer to a cs_source_term_t structure |
[in] | cm | pointer to a cs_cell_mesh_t structure |
[in,out] | cb | pointer to a cs_cell_builder_t structure |
[in,out] | values | pointer to the computed values |
void cs_source_term_vcsp_by_value | ( | const cs_source_term_t * | source, |
const cs_cell_mesh_t * | cm, | ||
cs_cell_builder_t * | cb, | ||
double * | values | ||
) |
Compute the contribution for a cell related to a source term and add it the given array of values. Case of a scalar potential defined at primal vertices and cells by a constant value. A discrete Hodge operator has to be computed before this call and stored inside a cs_cell_builder_t structure.
[in] | source | pointer to a cs_source_term_t structure |
[in] | cm | pointer to a cs_cell_mesh_t structure |
[in,out] | cb | pointer to a cs_cell_builder_t structure |
[in,out] | values | pointer to the computed values |
|
static |
|
static |
|
static |
|
static |