#include "cs_defs.h"
#include <assert.h>
#include <ctype.h>
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <bft_mem.h>
#include "cs_array.h"
#include "cs_cdo_toolbox.h"
#include "cs_cdocb_scaleq.h"
#include "cs_cdoeb_vecteq.h"
#include "cs_cdofb_scaleq.h"
#include "cs_cdofb_vecteq.h"
#include "cs_cdovb_scaleq.h"
#include "cs_cdovb_vecteq.h"
#include "cs_cdovcb_scaleq.h"
#include "cs_equation_bc.h"
#include "cs_equation_priv.h"
#include "cs_evaluate.h"
#include "cs_field_default.h"
#include "cs_hho_scaleq.h"
#include "cs_hho_vecteq.h"
#include "cs_log.h"
#include "cs_macfb_vecteq.h"
#include "cs_parall.h"
#include "cs_parameters.h"
#include "cs_post.h"
#include "cs_prototypes.h"
#include "cs_range_set.h"
#include "cs_sles.h"
#include "cs_timer_stats.h"
#include "cs_equation.h"
Macros | |
#define | CS_EQUATION_DBG 0 |
Functions | |
int | cs_equation_get_n_equations (void) |
Retrieve the number of equations. More... | |
cs_equation_t * | cs_equation_by_name (const char *eqname) |
Find the cs_equation_t structure with name eqname Return null if not find. More... | |
cs_equation_t * | cs_equation_by_field_name (const char *field_name) |
Return the pointer to a cs_equation_t structure thanks to the field name of the variable field associated to a cs_equation_t structure. More... | |
bool | cs_equation_has_field_name (const cs_equation_t *eq, const char *fld_name) |
Check if the asociated field to a cs_equation_t structure has name equal to fld_name. More... | |
cs_equation_param_t * | cs_equation_param_by_name (const char *eqname) |
Return the cs_equation_param_t structure associated to a cs_equation_t structure based on the equation name. More... | |
cs_equation_param_t * | cs_equation_param_by_field_name (const char *field_name) |
Return the cs_equation_param_t structure related to a cs_equation_t structure thanks to the field name of the variable field associated to a cs_equation_t structure. More... | |
cs_equation_param_t * | cs_equation_get_param (const cs_equation_t *eq) |
Return the cs_equation_param_t structure associated to a cs_equation_t structure. More... | |
cs_equation_t * | cs_equation_by_id (int eq_id) |
Find the cs_equation_t structure with id eq_id Return null if not find. More... | |
const char * | cs_equation_get_name (const cs_equation_t *eq) |
Return the name related to the given cs_equation_t structure. More... | |
int | cs_equation_get_id (const cs_equation_t *eq) |
Return the id number related to the given cs_equation_t structure. More... | |
cs_field_t * | cs_equation_get_field (const cs_equation_t *eq) |
Return the field structure associated to a cs_equation_t structure. More... | |
int | cs_equation_get_field_id (const cs_equation_t *eq) |
Return the id related to the variable field structure associated to the cs_equation_t structure. More... | |
const cs_range_set_t * | cs_equation_get_range_set (const cs_equation_t *eq) |
Return the range set structure associated to a cs_equation_t structure. One assumes that there is only one block (it could be a split block) otherwise this means that one handles systems of equations. More... | |
cs_gnum_t | cs_equation_get_global_n_dofs (const cs_equation_t *eq, const cs_cdo_quantities_t *cdoq) |
Return the global number of degrees of freedom associated to this cs_equation_t structure. More... | |
cs_field_t * | cs_equation_get_boundary_flux (const cs_equation_t *eq) |
Return the field structure for the (normal) boundary flux associated to a cs_equation_t structure. More... | |
cs_equation_builder_t * | cs_equation_get_builder (const cs_equation_t *eq) |
Return the cs_equation_builder_t structure associated to a cs_equation_t structure. Only for an advanced usage. More... | |
void * | cs_equation_get_scheme_context (const cs_equation_t *eq) |
Return a pointer to a structure useful to handle low-level operations for the given equation. More... | |
cs_equation_core_t | cs_equation_get_core_structure (const cs_equation_t *eq) |
Return a pointer to a structure useful to handle low-level operations for the given equation. More... | |
cs_real_t * | cs_equation_get_source_term_array (const cs_equation_t *eq) |
Return a pointer to an array of values corresponding to the values of the source terms (cumulated values if several source terms are defined) More... | |
cs_property_t * | cs_equation_get_diffusion_property (const cs_equation_t *eq) |
Return a pointer to the cs_property_t structure associated to the diffusion term for this equation (nullptr if not activated). More... | |
cs_property_t * | cs_equation_get_time_property (const cs_equation_t *eq) |
Return a pointer to the cs_property_t structure associated to the unsteady term for this equation (nullptr if not activated). More... | |
cs_property_t * | cs_equation_get_reaction_property (const cs_equation_t *eq, const int reaction_id) |
Return a pointer to the cs_property_t structure associated to the reaction term with id equal to reaction_id and related to this equation. More... | |
cs_param_time_scheme_t | cs_equation_get_time_scheme (const cs_equation_t *eq) |
Return the type of numerical scheme used for the discretization in time. More... | |
cs_real_t | cs_equation_get_theta_time_val (const cs_equation_t *eq) |
Return the value of the theta parameter in theta time scheme discretization. More... | |
cs_param_space_scheme_t | cs_equation_get_space_scheme (const cs_equation_t *eq) |
Return the type of numerical scheme used for the discretization in space. More... | |
int | cs_equation_get_space_poly_degree (const cs_equation_t *eq) |
Return the max. degree used in the polynomial basis for the space discretization. More... | |
int | cs_equation_get_var_dim (const cs_equation_t *eq) |
Return the dimension of the variable solved by this equation. More... | |
cs_equation_type_t | cs_equation_get_type (const cs_equation_t *eq) |
Return the type of equation for the given equation structure. More... | |
double | cs_equation_get_time_eval (const cs_time_step_t *ts, const cs_equation_t *eq) |
Estimate the time at which the evaluation of properties related to the different terms of an equation should be done. More... | |
cs_flag_t | cs_equation_get_flag (const cs_equation_t *eq) |
Return the flag associated to an equation. More... | |
void | cs_equation_set_flag (cs_equation_t *eq, cs_flag_t flag) |
Redefine the flag associated to an equation. More... | |
void | cs_equation_add_build_hook (cs_equation_t *eq, void *context, cs_equation_build_hook_t *func) |
Add a hook function to enable an advanced control during the cellwise system building. Only for an advanced usage. The context may be set to null if there is no need to get additional information. More... | |
bool | cs_equation_is_steady (const cs_equation_t *eq) |
Return true is the given equation is steady otherwise false. More... | |
bool | cs_equation_uses_new_mechanism (const cs_equation_t *eq) |
Return true is the given equation follows the new mechanism otherwise false. More... | |
cs_equation_t * | cs_equation_add (const char *eqname, const char *varname, cs_equation_type_t eqtype, int dim, cs_param_bc_type_t default_bc) |
Add a new equation structure and set a first set of parameters. More... | |
cs_equation_t * | cs_equation_add_user (const char *eqname, const char *varname, int dim, cs_param_bc_type_t default_bc) |
Add a new user equation structure and set a first set of parameters. More... | |
cs_equation_t * | cs_equation_add_user_tracer (const char *eqname, const char *varname, int dim, cs_param_bc_type_t default_bc, cs_property_t *time_pty, cs_adv_field_t *adv, cs_property_t *diff_pty) |
Add a new user transport equation and set a first set of parameters If time_pty is nullptr, then no unsteady term is added. If adv is nullptr, then no advection term is added. If diff_pty is nullptr, then no diffusion term is added. More... | |
void | cs_equation_destroy_all (void) |
Destroy all cs_equation_t structures. More... | |
bool | cs_equation_needs_steady_state_solve (void) |
Check if a steady-state computation is requested according to the setting. More... | |
void | cs_equation_log_monitoring (void) |
Print a synthesis of the monitoring information in the performance file. More... | |
void | cs_equation_get_count (int *n_equations, int *n_predef_equations, int *n_user_equations) |
Get the count of equations of each macro type. More... | |
void | cs_equation_log_setup (void) |
Summarize all cs_equation_t structures. More... | |
void | cs_equation_set_default_param (cs_equation_key_t key, const char *keyval) |
Set a parameter attached to a keyname for the default settigns. More... | |
void | cs_equation_set_sles (void) |
Setup the linear algebra requirements. More... | |
void | cs_equation_init_sharing (const cs_mesh_t *mesh, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *cdoq, const cs_time_step_t *time_step, cs_flag_t cb_scheme_flag, cs_flag_t eb_scheme_flag, cs_flag_t fb_scheme_flag, cs_flag_t vb_scheme_flag, cs_flag_t vcb_scheme_flag, cs_flag_t hho_scheme_flag, cs_flag_t mac_scheme_flag) |
Set shared pointers to the main structures. Associate these structures among the activated class of discretization schemes. More... | |
void | cs_equation_finalize_sharing (cs_flag_t cb_scheme_flag, cs_flag_t eb_scheme_flag, cs_flag_t fb_scheme_flag, cs_flag_t vb_scheme_flag, cs_flag_t vcb_scheme_flag, cs_flag_t hho_scheme_flag, cs_flag_t mac_scheme_flag) |
Free shared local structures among the discretization schemes. More... | |
bool | cs_equation_set_functions (void) |
Assign a set of pointer functions for managing the cs_equation_t structure during the computation. More... | |
void | cs_equation_lock_settings (void) |
After this call, parameters related to an equation are set once for all. More... | |
void | cs_equation_predefined_create_field (int n_previous, cs_equation_t *eq) |
Create a field structure related to the predefined equation given as parameter. This includes an equation associated to all modules and also the wall distance or mesh deformation computations for instance. More... | |
void | cs_equation_user_create_fields (void) |
Create a field structure related to all user-defined equations. More... | |
void | cs_equation_define_builders (const cs_mesh_t *mesh) |
Allocate and define the builder structure. More... | |
void | cs_equation_define_context_structures (void) |
Allocate and define the context structure associated to each equation. More... | |
void | cs_equation_define_core_structure (const cs_equation_t *eq, cs_equation_core_t **p_core) |
Build a pointer to a core structure. If the input core structure is not allocated, then one allocates the structure. More... | |
void | cs_equation_init_field_values (const cs_mesh_t *mesh, const cs_time_step_t *ts) |
Set the initialize condition to all variable fields associated to each cs_equation_t structure. More... | |
void | cs_equation_build_system (const cs_mesh_t *mesh, cs_equation_t *eq) |
Build the linear system for this equation (deprecated). Only for HHO schemes. More... | |
void | cs_equation_solve_deprecated (cs_equation_t *eq) |
Solve the linear system for this equation (deprecated). Only for HHO schemes. More... | |
void | cs_equation_solve_steady_state (const cs_mesh_t *mesh, cs_equation_t *eq) |
Build and then solve the linear system for this equation when the goal is to find the steady state. More... | |
void | cs_equation_solve (bool cur2prev, const cs_mesh_t *mesh, cs_equation_t *eq) |
Build and then solve the linear system for an equation with an unsteady term. More... | |
void | cs_equation_current_to_previous (const cs_equation_t *eq) |
Apply the current to previous to all fields (and potentially arrays) related to an equation. This function fas to be called when a solve step is called with the parameter: cur2prev = false. More... | |
void | cs_equation_get_cellwise_builders (const cs_equation_t *eq, cs_cell_sys_t **csys, cs_cell_builder_t **cb) |
For a given equation, retrieve the related cellwise builder structures: cs_cell_builder_t and cs_cell_system_t structures. More... | |
cs_real_t * | cs_equation_get_cell_values (const cs_equation_t *eq, bool previous) |
For a given equation, retrieve an array of values related to each cell of the mesh for the unknowns. More... | |
cs_real_t * | cs_equation_get_face_values (const cs_equation_t *eq, bool previous) |
For a given equation, retrieve an array of values related to each face of the mesh for the unknowns. More... | |
cs_real_t * | cs_equation_get_edge_values (const cs_equation_t *eq, bool previous) |
For a given equation, retrieve an array of values related to each edge of the mesh for the unknowns. More... | |
cs_real_t * | cs_equation_get_vertex_values (const cs_equation_t *eq, bool previous) |
For a given equation, retrieve an array of values related to each vertex of the mesh for the unknowns. More... | |
void | cs_equation_integrate_variable (const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *cdoq, const cs_equation_t *eq, cs_real_t *result) |
Compute the integral over the domain of the current variable field associated to the given equation. Parallel synchronization is performed in this function. No need to do it outside. More... | |
void | cs_equation_compute_boundary_diff_flux (const cs_equation_t *eq, const cs_equation_param_t *eqp, const cs_property_t *diff_pty, const cs_real_t *dof_vals, const cs_real_t *cell_vals, cs_real_t t_eval, cs_real_t *diff_flux) |
Compute the diffusive flux across all boundary faces According to the space discretization scheme, the size of the resulting array differs. For Vb and VCb schemes, this array relies on the bf2v adjacency. More... | |
void | cs_equation_compute_flux_across_plane (const cs_equation_t *eq, const char *ml_name, const cs_real_3_t direction, cs_real_t *diff_flux, cs_real_t *conv_flux) |
Compute the diffusive and convective flux across a plane defined by a mesh location structure attached to the name ml_name. More... | |
void | cs_equation_compute_diffusive_flux (const cs_equation_t *eq, const cs_equation_param_t *eqp, const cs_property_t *diff_pty, const cs_real_t *dof_vals, const cs_real_t *cell_vals, cs_flag_t location, cs_real_t t_eval, cs_real_t *diff_flux) |
Computation of the diffusive flux across the requested location. If the location is not the "natural" one (which depends on the space discretization scheme) then the diffusive flux is interpolated and thus there is an approximation. The computation is threaded and performed cell-wise. More... | |
void | cs_equation_compute_vtx_field_gradient (const cs_equation_t *eq, cs_real_t *v_gradient) |
Cellwise computation of the discrete gradient at vertices. More... | |
void | cs_equation_compute_peclet (const cs_equation_t *eq, const cs_time_step_t *ts, cs_real_t peclet[]) |
Compute and post-process Peclet number if requested. More... | |
void | cs_equation_read_extra_restart (cs_restart_t *restart) |
Write into the restart file additionnal arrays (not defined as fields) but useful for the checkpoint/restart process. More... | |
void | cs_equation_write_extra_restart (cs_restart_t *restart) |
Write into the restart file additionnal arrays (not defined as fields) but useful for the checkpoint/restart process. More... | |
void | cs_equation_post_balance (const cs_mesh_t *mesh, const cs_cdo_connect_t *connect, const cs_cdo_quantities_t *cdoq, const cs_time_step_t *ts) |
Predefined extra-operations related to all equations. More... | |
void | cs_equation_apply_stiffness (cs_equation_t *eq, const cs_property_t *property, const cs_real_t *pot, cs_flag_t loc_res, cs_real_t *res) |
Compute the cellwise stiffness matrix associated to the property given as a parameter and apply it to the pot array to define the resulting array associated to entities defined at loc_res. More... | |
void | cs_equation_extra_post (void) |
Predefined extra-operations related to equations according to the type of numerical scheme (for the space discretization) More... | |
Variables | |
static int | _n_equations = 0 |
static int | _n_predef_equations = 0 |
static int | _n_user_equations = 0 |
static cs_equation_t ** | _equations = nullptr |
#define CS_EQUATION_DBG 0 |
cs_equation_t * cs_equation_add | ( | const char * | eqname, |
const char * | varname, | ||
cs_equation_type_t | eqtype, | ||
int | dim, | ||
cs_param_bc_type_t | default_bc | ||
) |
Add a new equation structure and set a first set of parameters.
[in] | eqname | name of the equation |
[in] | varname | name of the variable associated to this equation |
[in] | eqtype | type of equation (user, predefined...) |
[in] | dim | dimension of the unknow attached to this equation |
[in] | default_bc | type of boundary condition set by default |
void cs_equation_add_build_hook | ( | cs_equation_t * | eq, |
void * | context, | ||
cs_equation_build_hook_t * | func | ||
) |
Add a hook function to enable an advanced control during the cellwise system building. Only for an advanced usage. The context may be set to null if there is no need to get additional information.
[in,out] | eq | pointer to the cs_equation_t stucture to update |
[in] | context | pointer to a structure for additional information |
[in] | func | pointer to the user function |
cs_equation_t * cs_equation_add_user | ( | const char * | eqname, |
const char * | varname, | ||
int | dim, | ||
cs_param_bc_type_t | default_bc | ||
) |
Add a new user equation structure and set a first set of parameters.
[in] | eqname | name of the equation |
[in] | varname | name of the variable associated to this equation |
[in] | dim | dimension of the unknow attached to this equation |
[in] | default_bc | type of boundary condition set by default |
cs_equation_t * cs_equation_add_user_tracer | ( | const char * | eqname, |
const char * | varname, | ||
int | dim, | ||
cs_param_bc_type_t | default_bc, | ||
cs_property_t * | time_pty, | ||
cs_adv_field_t * | adv, | ||
cs_property_t * | diff_pty | ||
) |
Add a new user transport equation and set a first set of parameters If time_pty is nullptr, then no unsteady term is added. If adv is nullptr, then no advection term is added. If diff_pty is nullptr, then no diffusion term is added.
Add a new user transport equation and set a first set of parameters If time_pty is null, then no unsteady term is added. If adv is null, then no advection term is added. If diff_pty is null, then no diffusion term is added.
[in] | eqname | name of the equation |
[in] | varname | name of the variable associated to this equation |
[in] | dim | dimension of the unknow attached to this equation |
[in] | default_bc | type of boundary condition set by default |
[in] | time_pty | property related to the unsteady term |
[in] | adv | advection field |
[in] | diff_pty | property related to the diffusion term |
void cs_equation_apply_stiffness | ( | cs_equation_t * | eq, |
const cs_property_t * | property, | ||
const cs_real_t * | pot, | ||
cs_flag_t | loc_res, | ||
cs_real_t * | res | ||
) |
Compute the cellwise stiffness matrix associated to the property given as a parameter and apply it to the pot array to define the resulting array associated to entities defined at loc_res.
[in] | eq | pointer to a cs_equation_t structure |
[in] | property | pointer to the property to consider |
[in] | pot | array to multiply with the stiffness matrix |
[in] | loc_res | location of entities in the resulting array |
[in,out] | res | resulting array |
void cs_equation_build_system | ( | const cs_mesh_t * | mesh, |
cs_equation_t * | eq | ||
) |
Build the linear system for this equation (deprecated). Only for HHO schemes.
[in] | mesh | pointer to a cs_mesh_t structure |
[in,out] | eq | pointer to a cs_equation_t structure |
cs_equation_t * cs_equation_by_field_name | ( | const char * | field_name | ) |
Return the pointer to a cs_equation_t structure thanks to the field name of the variable field associated to a cs_equation_t structure.
[in] | field_name | name of the field |
cs_equation_t * cs_equation_by_id | ( | int | eq_id | ) |
Find the cs_equation_t structure with id eq_id Return null if not find.
Find the cs_equation_t structure with id eq_id Return nullptr if not found.
[in] | eq_id | id of the equation to find |
cs_equation_t * cs_equation_by_name | ( | const char * | eqname | ) |
Find the cs_equation_t structure with name eqname Return null if not find.
Find the cs_equation_t structure with name eqname Return nullptr if not found.
[in] | eqname | name of the equation to find |
void cs_equation_compute_boundary_diff_flux | ( | const cs_equation_t * | eq, |
const cs_equation_param_t * | eqp, | ||
const cs_property_t * | diff_pty, | ||
const cs_real_t * | dof_vals, | ||
const cs_real_t * | cell_vals, | ||
cs_real_t | t_eval, | ||
cs_real_t * | diff_flux | ||
) |
Compute the diffusive flux across all boundary faces According to the space discretization scheme, the size of the resulting array differs. For Vb and VCb schemes, this array relies on the bf2v adjacency.
If eqp is set to nullptr, then one uses eq->param. Otherwise, one checks that the given eqp structure is relevant (same space discretization as eq->param) Using a different eqp allows one to build a diffusive flux relying on another property associated to the diffusion term.
If pty is set to nullptr then one considers the diffusion property related to the eqp structure which will be used. Otherwise, one considers the one given.
If dof_vals is set to nullptr (and cell_values too), then one uses the current values of the variable associated to the given equation (cs_equation_get_*_values functions). The calling function has to ensure that the location of the values is relevant with the one expected with the given equation. Using dof_vals (and possibly cell_vals) allows one to compute the diffusive flux for an array of values which is not the one associated to the given equation.
cell_values is not useful for CDO vertex-based schemes while it is mandatory for CDO vertex+cell-based schemes and CDO face-based schemes. For CDO cell-based schemes, the flux is a variable so that neither dof_vals nor cell_vals are used.
Be aware that the boundary conditions are applied through the equation builder structure which has to be consistent with what is used in eqp
[in] | eq | pointer to a cs_equation_t structure |
[in] | eqp | set of equation parameters to use or nullptr |
[in] | diff_pty | diffusion property or nullptr |
[in] | dof_vals | values at the location of the degrees of freedom |
[in] | cell_vals | values at the cell centers or nullptr |
[in] | t_eval | time at which one the property is evaluated |
[in,out] | diff_flux | value of the diffusive part of the flux |
void cs_equation_compute_diffusive_flux | ( | const cs_equation_t * | eq, |
const cs_equation_param_t * | eqp, | ||
const cs_property_t * | diff_pty, | ||
const cs_real_t * | dof_vals, | ||
const cs_real_t * | cell_vals, | ||
cs_flag_t | location, | ||
cs_real_t | t_eval, | ||
cs_real_t * | diff_flux | ||
) |
Computation of the diffusive flux across the requested location. If the location is not the "natural" one (which depends on the space discretization scheme) then the diffusive flux is interpolated and thus there is an approximation. The computation is threaded and performed cell-wise.
If eqp is set to nullptr, then one uses eq->param. Otherwise, one checks that the given eqp structure is relevant (same space discretization as eq->param) Using a different eqp allows one to build a diffusive flux relying on another property associated to the diffusion term.
If pty is set to null then one considers the diffusion property related to the eqp structure which will be used. Otherwise, one considers the one given.
If dof_vals is set to null (and cell_values too), then one uses the current values of the variable associated to the given equation (cs_equation_get_*_values functions). The calling function has to ensure that the location of the values is relevant with the one expected with the given equation. Using dof_vals (and possibly cell_vals) allows one to compute the diffusive flux for an array of values which is not the one associated to the given equation.
cell_values is not useful for CDO vertex-based schemes while it is mandatory for CDO vertex+cell-based schemes and CDO face-based schemes. For CDO cell-based schemes, the flux is a variable so that neither dof_vals nor cell_vals are used.
[in] | eq | pointer to a cs_equation_t structure |
[in] | eqp | set of equation parameters to use or nullptr |
[in] | diff_pty | diffusion property or nullptr |
[in] | dof_vals | values at the location of the degrees of freedom |
[in] | cell_vals | values at the cell centers or nullptr |
[in] | location | indicate where the flux has to be computed |
[in] | t_eval | time at which one performs the evaluation |
[in,out] | diff_flux | value of the diffusive flux (must be allocated) |
void cs_equation_compute_flux_across_plane | ( | const cs_equation_t * | eq, |
const char * | ml_name, | ||
const cs_real_3_t | direction, | ||
cs_real_t * | diff_flux, | ||
cs_real_t * | conv_flux | ||
) |
Compute the diffusive and convective flux across a plane defined by a mesh location structure attached to the name ml_name.
[in] | eq | pointer to a cs_equation_t structure |
[in] | ml_name | name of the related mesh location |
[in] | direction | vector indicating in which direction flux is > 0 |
[in,out] | diff_flux | value of the diffusive part of the flux |
[in,out] | conv_flux | value of the convective part of the flux |
void cs_equation_compute_peclet | ( | const cs_equation_t * | eq, |
const cs_time_step_t * | ts, | ||
cs_real_t | peclet[] | ||
) |
Compute and post-process Peclet number if requested.
[in] | eq | pointer to a cs_equation_t structure |
[in] | ts | pointer to a cs_time_step_t struct. |
[in,out] | peclet | pointer to an array storing the resulting Peclet number in each cell |
void cs_equation_compute_vtx_field_gradient | ( | const cs_equation_t * | eq, |
cs_real_t * | v_gradient | ||
) |
Cellwise computation of the discrete gradient at vertices.
[in] | eq | pointer to a cs_equation_t structure |
[in,out] | v_gradient | gradient at vertices |
void cs_equation_current_to_previous | ( | const cs_equation_t * | eq | ) |
Apply the current to previous to all fields (and potentially arrays) related to an equation. This function fas to be called when a solve step is called with the parameter: cur2prev = false.
[in] | eq | pointer to a cs_equation_t structure |
void cs_equation_define_builders | ( | const cs_mesh_t * | mesh | ) |
Allocate and define the builder structure.
[in] | mesh | pointer to a cs_mesh_t structure |
void cs_equation_define_context_structures | ( | void | ) |
Allocate and define the context structure associated to each equation.
void cs_equation_define_core_structure | ( | const cs_equation_t * | eq, |
cs_equation_core_t ** | p_core | ||
) |
Build a pointer to a core structure. If the input core structure is not allocated, then one allocates the structure.
[in] | eq | pointer to a cs_equation_t structure |
[in,out] | p_core | double pointer to a core structure to build |
void cs_equation_destroy_all | ( | void | ) |
Destroy all cs_equation_t structures.
void cs_equation_extra_post | ( | void | ) |
Predefined extra-operations related to equations according to the type of numerical scheme (for the space discretization)
void cs_equation_finalize_sharing | ( | cs_flag_t | cb_scheme_flag, |
cs_flag_t | eb_scheme_flag, | ||
cs_flag_t | fb_scheme_flag, | ||
cs_flag_t | vb_scheme_flag, | ||
cs_flag_t | vcb_scheme_flag, | ||
cs_flag_t | hho_scheme_flag, | ||
cs_flag_t | mac_scheme_flag | ||
) |
Free shared local structures among the discretization schemes.
[in] | cb_scheme_flag | metadata for Cb schemes |
[in] | eb_scheme_flag | metadata for Eb schemes |
[in] | fb_scheme_flag | metadata for Fb schemes |
[in] | vb_scheme_flag | metadata for Vb schemes |
[in] | vcb_scheme_flag | metadata for V+C schemes |
[in] | hho_scheme_flag | metadata for HHO schemes |
[in] | mac_scheme_flag | metadata for MAC schemes |
cs_field_t * cs_equation_get_boundary_flux | ( | const cs_equation_t * | eq | ) |
Return the field structure for the (normal) boundary flux associated to a cs_equation_t structure.
[in] | eq | pointer to a cs_equation_t structure |
cs_equation_builder_t * cs_equation_get_builder | ( | const cs_equation_t * | eq | ) |
Return the cs_equation_builder_t structure associated to a cs_equation_t structure. Only for an advanced usage.
[in] | eq | pointer to a cs_equation_t structure |
cs_real_t * cs_equation_get_cell_values | ( | const cs_equation_t * | eq, |
bool | previous | ||
) |
For a given equation, retrieve an array of values related to each cell of the mesh for the unknowns.
[in] | eq | pointer to a cs_equation_t structure |
[in] | previous | retrieve the previous state (true/false) |
void cs_equation_get_cellwise_builders | ( | const cs_equation_t * | eq, |
cs_cell_sys_t ** | csys, | ||
cs_cell_builder_t ** | cb | ||
) |
For a given equation, retrieve the related cellwise builder structures: cs_cell_builder_t and cs_cell_system_t structures.
[in] | eq | pointer to a cs_equation_t structure |
[out] | cb | pointer to a pointer on a cs_cell_sys_t structure |
[out] | csys | pointer to a pointer on a cs_cell_builder_t structure |
cs_equation_core_t cs_equation_get_core_structure | ( | const cs_equation_t * | eq | ) |
Return a pointer to a structure useful to handle low-level operations for the given equation.
[in] | eq | pointer to a cs_equation_t structure |
void cs_equation_get_count | ( | int * | n_equations, |
int * | n_predef_equations, | ||
int * | n_user_equations | ||
) |
Get the count of equations of each macro type.
[out] | n_equations | total number of equations |
[out] | n_predef_equations | number of predefined equations |
[out] | n_user_equations | number of user equations |
cs_property_t * cs_equation_get_diffusion_property | ( | const cs_equation_t * | eq | ) |
Return a pointer to the cs_property_t structure associated to the diffusion term for this equation (nullptr if not activated).
Return a pointer to the cs_property_t structure associated to the diffusion term for this equation (null if not activated).
[in] | eq | pointer to a cs_equation_t structure |
cs_real_t * cs_equation_get_edge_values | ( | const cs_equation_t * | eq, |
bool | previous | ||
) |
For a given equation, retrieve an array of values related to each edge of the mesh for the unknowns.
[in] | eq | pointer to a cs_equation_t structure |
[in] | previous | retrieve the previous state (true/false) |
cs_real_t * cs_equation_get_face_values | ( | const cs_equation_t * | eq, |
bool | previous | ||
) |
For a given equation, retrieve an array of values related to each face of the mesh for the unknowns.
[in] | eq | pointer to a cs_equation_t structure |
[in] | previous | retrieve the previous state (true/false) |
cs_field_t * cs_equation_get_field | ( | const cs_equation_t * | eq | ) |
Return the field structure associated to a cs_equation_t structure.
[in] | eq | pointer to a cs_equation_t structure |
int cs_equation_get_field_id | ( | const cs_equation_t * | eq | ) |
Return the id related to the variable field structure associated to the cs_equation_t structure.
[in] | eq | pointer to a cs_equation_t structure |
cs_flag_t cs_equation_get_flag | ( | const cs_equation_t * | eq | ) |
Return the flag associated to an equation.
[in] | eq | pointer to a cs_equation_t structure |
cs_gnum_t cs_equation_get_global_n_dofs | ( | const cs_equation_t * | eq, |
const cs_cdo_quantities_t * | cdoq | ||
) |
Return the global number of degrees of freedom associated to this cs_equation_t structure.
[in] | eq | pointer to a cs_equation_t structure |
[in] | cdoq | pointer to a cs_cdo_quantities_t structure |
int cs_equation_get_id | ( | const cs_equation_t * | eq | ) |
Return the id number related to the given cs_equation_t structure.
[in] | eq | pointer to a cs_equation_t structure |
int cs_equation_get_n_equations | ( | void | ) |
Retrieve the number of equations.
const char * cs_equation_get_name | ( | const cs_equation_t * | eq | ) |
Return the name related to the given cs_equation_t structure.
[in] | eq | pointer to a cs_equation_t structure |
cs_equation_param_t * cs_equation_get_param | ( | const cs_equation_t * | eq | ) |
Return the cs_equation_param_t structure associated to a cs_equation_t structure.
[in] | eq | pointer to a cs_equation_t structure |
const cs_range_set_t * cs_equation_get_range_set | ( | const cs_equation_t * | eq | ) |
Return the range set structure associated to a cs_equation_t structure. One assumes that there is only one block (it could be a split block) otherwise this means that one handles systems of equations.
[in] | eq | pointer to a cs_equation_t structure |
cs_property_t * cs_equation_get_reaction_property | ( | const cs_equation_t * | eq, |
const int | reaction_id | ||
) |
Return a pointer to the cs_property_t structure associated to the reaction term with id equal to reaction_id and related to this equation.
[in] | eq | pointer to a cs_equation_t structure |
[in] | reaction_id | id related to this reaction term |
void * cs_equation_get_scheme_context | ( | const cs_equation_t * | eq | ) |
Return a pointer to a structure useful to handle low-level operations for the given equation.
[in] | eq | pointer to a cs_equation_t structure |
cs_real_t * cs_equation_get_source_term_array | ( | const cs_equation_t * | eq | ) |
Return a pointer to an array of values corresponding to the values of the source terms (cumulated values if several source terms are defined)
[in] | eq | pointer to a cs_equation_t structure |
int cs_equation_get_space_poly_degree | ( | const cs_equation_t * | eq | ) |
Return the max. degree used in the polynomial basis for the space discretization.
[in] | eq | pointer to a cs_equation_t structure |
cs_param_space_scheme_t cs_equation_get_space_scheme | ( | const cs_equation_t * | eq | ) |
Return the type of numerical scheme used for the discretization in space.
[in] | eq | pointer to a cs_equation_t structure |
cs_real_t cs_equation_get_theta_time_val | ( | const cs_equation_t * | eq | ) |
Return the value of the theta parameter in theta time scheme discretization.
[in] | eq | pointer to a cs_equation_t structure |
double cs_equation_get_time_eval | ( | const cs_time_step_t * | ts, |
const cs_equation_t * | eq | ||
) |
Estimate the time at which the evaluation of properties related to the different terms of an equation should be done.
[in] | ts | pointer to a cs_time_step_t structure |
[in] | eq | pointer to an equation structure |
cs_property_t * cs_equation_get_time_property | ( | const cs_equation_t * | eq | ) |
Return a pointer to the cs_property_t structure associated to the unsteady term for this equation (nullptr if not activated).
Return a pointer to the cs_property_t structure associated to the unsteady term for this equation (null if not activated).
[in] | eq | pointer to a cs_equation_t structure |
cs_param_time_scheme_t cs_equation_get_time_scheme | ( | const cs_equation_t * | eq | ) |
Return the type of numerical scheme used for the discretization in time.
[in] | eq | pointer to a cs_equation_t structure |
cs_equation_type_t cs_equation_get_type | ( | const cs_equation_t * | eq | ) |
Return the type of equation for the given equation structure.
[in] | eq | pointer to a cs_equation_t structure |
int cs_equation_get_var_dim | ( | const cs_equation_t * | eq | ) |
Return the dimension of the variable solved by this equation.
[in] | eq | pointer to a cs_equation_t structure |
cs_real_t * cs_equation_get_vertex_values | ( | const cs_equation_t * | eq, |
bool | previous | ||
) |
For a given equation, retrieve an array of values related to each vertex of the mesh for the unknowns.
[in] | eq | pointer to a cs_equation_t structure |
[in] | previous | retrieve the previous state (true/false) |
bool cs_equation_has_field_name | ( | const cs_equation_t * | eq, |
const char * | fld_name | ||
) |
Check if the asociated field to a cs_equation_t structure has name equal to fld_name.
[in] | eq | pointer to a cs_equation_t structure to test |
[in] | fld_name | name of the field |
void cs_equation_init_field_values | ( | const cs_mesh_t * | mesh, |
const cs_time_step_t * | ts | ||
) |
Set the initialize condition to all variable fields associated to each cs_equation_t structure.
[in] | mesh | pointer to a cs_mesh_t structure |
[in] | ts | pointer to a cs_time_step_t structure |
void cs_equation_init_sharing | ( | const cs_mesh_t * | mesh, |
const cs_cdo_connect_t * | connect, | ||
const cs_cdo_quantities_t * | cdoq, | ||
const cs_time_step_t * | time_step, | ||
cs_flag_t | cb_scheme_flag, | ||
cs_flag_t | eb_scheme_flag, | ||
cs_flag_t | fb_scheme_flag, | ||
cs_flag_t | vb_scheme_flag, | ||
cs_flag_t | vcb_scheme_flag, | ||
cs_flag_t | hho_scheme_flag, | ||
cs_flag_t | mac_scheme_flag | ||
) |
Set shared pointers to the main structures. Associate these structures among the activated class of discretization schemes.
[in] | mesh | pointer to a mesh structure |
[in] | connect | pointer to a cs_cdo_connect_t structure |
[in] | cdoq | pointer to additional mesh quantities struct. |
[in] | time_step | pointer to a time step structure |
[in] | cb_scheme_flag | metadata for cell-based schemes |
[in] | eb_scheme_flag | metadata for edge-based schemes |
[in] | fb_scheme_flag | metadata for face_based schemes |
[in] | vb_scheme_flag | metadata for vertex-based schemes |
[in] | vcb_scheme_flag | metadata for vertex+cell-based schemes |
[in] | hho_scheme_flag | metadata for HHO schemes |
[in] | mac_scheme_flag | metadata for MAC schemes |
void cs_equation_integrate_variable | ( | const cs_cdo_connect_t * | connect, |
const cs_cdo_quantities_t * | cdoq, | ||
const cs_equation_t * | eq, | ||
cs_real_t * | result | ||
) |
Compute the integral over the domain of the current variable field associated to the given equation. Parallel synchronization is performed in this function. No need to do it outside.
Compute the integral over the domain of the variable field associated to the given equation. Parallel synchronization is performed in this function. No need to do it outside.
[in] | connect | pointer to a cs_cdo_connect_t structure |
[in] | cdoq | pointer to a cs_cdo_quantities_t structure |
[in] | eq | pointer to a cs_equation_t structure |
[in,out] | result | result of the computation |
bool cs_equation_is_steady | ( | const cs_equation_t * | eq | ) |
Return true is the given equation is steady otherwise false.
[in] | eq | pointer to a cs_equation_t structure |
void cs_equation_lock_settings | ( | void | ) |
After this call, parameters related to an equation are set once for all.
void cs_equation_log_monitoring | ( | void | ) |
Print a synthesis of the monitoring information in the performance file.
void cs_equation_log_setup | ( | void | ) |
Summarize all cs_equation_t structures.
bool cs_equation_needs_steady_state_solve | ( | void | ) |
Check if a steady-state computation is requested according to the setting.
cs_equation_param_t * cs_equation_param_by_field_name | ( | const char * | field_name | ) |
Return the cs_equation_param_t structure related to a cs_equation_t structure thanks to the field name of the variable field associated to a cs_equation_t structure.
[in] | field_name | name of the field |
cs_equation_param_t * cs_equation_param_by_name | ( | const char * | eqname | ) |
Return the cs_equation_param_t structure associated to a cs_equation_t structure based on the equation name.
If no equation matches the given name but a field does, equation parameter structure associated to the field will be returned instead. This allows using this function with non-CDO (legacy) fields.
[in] | eqname | name of the equation |
void cs_equation_post_balance | ( | const cs_mesh_t * | mesh, |
const cs_cdo_connect_t * | connect, | ||
const cs_cdo_quantities_t * | cdoq, | ||
const cs_time_step_t * | ts | ||
) |
Predefined extra-operations related to all equations.
[in] | mesh | pointer to a cs_mesh_t structure |
[in] | connect | pointer to a cs_cdo_connect_t structure |
[in] | cdoq | pointer to a cs_cdo_quantities_t structure |
[in] | ts | pointer to a cs_time_step_t struct. |
void cs_equation_predefined_create_field | ( | int | n_previous, |
cs_equation_t * | eq | ||
) |
Create a field structure related to the predefined equation given as parameter. This includes an equation associated to all modules and also the wall distance or mesh deformation computations for instance.
When an automatic behavior is asked then one checks the flag CS_EQUATION_UNSTEADY to decide. One can force the behavior when handling predefined equations since more complex situations can occur such as a steady computation with non-linearities (in which case one wants a field with a previous state)
[in] | n_previous | number of previous states to keep n_previous equal to -1 means automatic |
[in,out] | eq | pointer to an equation structure |
void cs_equation_read_extra_restart | ( | cs_restart_t * | restart | ) |
Write into the restart file additionnal arrays (not defined as fields) but useful for the checkpoint/restart process.
[in,out] | restart | pointer to a cs_restart_t structure |
void cs_equation_set_default_param | ( | cs_equation_key_t | key, |
const char * | keyval | ||
) |
Set a parameter attached to a keyname for the default settigns.
[in] | key | key related to the member of eq to set |
[in] | keyval | accessor to the value to set |
void cs_equation_set_flag | ( | cs_equation_t * | eq, |
cs_flag_t | flag | ||
) |
Redefine the flag associated to an equation.
[in,out] | eq | pointer to a cs_equation_t structure |
[in] | flag | new flag to set |
bool cs_equation_set_functions | ( | void | ) |
Assign a set of pointer functions for managing the cs_equation_t structure during the computation.
Assign a set of pointer functions for managing the cs_equation_t structure during the computation After this call, parameters related to an equation are set once for all.
void cs_equation_set_sles | ( | void | ) |
Setup the linear algebra requirements.
void cs_equation_solve | ( | bool | cur2prev, |
const cs_mesh_t * | mesh, | ||
cs_equation_t * | eq | ||
) |
Build and then solve the linear system for an equation with an unsteady term.
[in] | cur2prev | true="current to previous" operation is performed |
[in] | mesh | pointer to a cs_mesh_t structure |
[in,out] | eq | pointer to a cs_equation_t structure |
void cs_equation_solve_deprecated | ( | cs_equation_t * | eq | ) |
Solve the linear system for this equation (deprecated). Only for HHO schemes.
[in,out] | eq | pointer to a cs_equation_t structure |
void cs_equation_solve_steady_state | ( | const cs_mesh_t * | mesh, |
cs_equation_t * | eq | ||
) |
Build and then solve the linear system for this equation when the goal is to find the steady state.
[in] | mesh | pointer to a cs_mesh_t structure |
[in,out] | eq | pointer to a cs_equation_t structure |
void cs_equation_user_create_fields | ( | void | ) |
Create a field structure related to all user-defined equations.
bool cs_equation_uses_new_mechanism | ( | const cs_equation_t * | eq | ) |
Return true is the given equation follows the new mechanism otherwise false.
[in] | eq | pointer to a cs_equation_t structure |
void cs_equation_write_extra_restart | ( | cs_restart_t * | restart | ) |
Write into the restart file additionnal arrays (not defined as fields) but useful for the checkpoint/restart process.
[in,out] | restart | pointer to a cs_restart_t structure |
|
static |
|
static |
|
static |
|
static |