#include "cs_defs.h"#include <assert.h>#include <ctype.h>#include <float.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include "bft_mem.h"#include "cs_array.h"#include "cs_boundary_zone.h"#include "cs_cdo_toolbox.h"#include "cs_evaluate.h"#include "cs_field.h"#include "cs_log.h"#include "cs_math.h"#include "cs_mesh_location.h"#include "cs_param_cdo.h"#include "cs_reco.h"#include "cs_volume_zone.h"#include "cs_xdef.h"#include "cs_zone.h"#include "cs_advection_field.h" Include dependency graph for cs_advection_field.c:
 Include dependency graph for cs_advection_field.c:| Macros | |
| #define | _dp3 cs_math_3_dot_product | 
| #define | CS_ADVECTION_FIELD_DBG 0 | 
| #define | CS_ADVECTION_FIELD_ID_NOT_SET -1 | 
| #define | CS_ADVECTION_FIELD_ID_TO_BE_SET -2 | 
| Functions | |
| static int | _get_dim_def (const cs_adv_field_t *adv) | 
| Return the required dimension for the definition of an advection field.  More... | |
| static void | _fill_uniform_boundary_flux (const cs_cdo_quantities_t *const cdoq, const cs_adjacency_t *const f2e, const cs_adjacency_t *const e2v, cs_lnum_t bf_id, cs_real_t face_flux, cs_real_t *fluxes) | 
| Update the contribution of the flux.  More... | |
| static void | _cw_fill_uniform_boundary_flux (const cs_cell_mesh_t *cm, short int f, cs_real_t face_flux, cs_real_t *fluxes) | 
| Update the contribution of the flux for each vertex.  More... | |
| static void | _compute_adv_vector_at_vertices (cs_xdef_t *def, cs_real_t *vtx_values) | 
| Compute a vector-valued reconstruction of the advection field at vertices from the definition of the advection field.  More... | |
| void | cs_advection_field_init_sharing (const cs_cdo_quantities_t *quant, const cs_cdo_connect_t *connect) | 
| Set shared pointers to main domain members.  More... | |
| int | cs_advection_field_get_n_fields (void) | 
| Get the number of allocated cs_adv_field_t structures.  More... | |
| cs_adv_field_t * | cs_advection_field_by_name (const char *name) | 
| Search in the array of advection field structures which one has the name given in argument.  More... | |
| cs_adv_field_t * | cs_advection_field_by_id (int id) | 
| Search in the array of advection field structures which one has the id given in argument.  More... | |
| cs_adv_field_t * | cs_advection_field_add_user (const char *name) | 
| Add and initialize a new user-defined advection field structure.  More... | |
| cs_adv_field_t * | cs_advection_field_add (const char *name, cs_advection_field_status_t status) | 
| Add and initialize a new advection field structure.  More... | |
| void | cs_advection_field_destroy_all (void) | 
| Free all allocated cs_adv_field_t structures and its related array.  More... | |
| bool | cs_advection_field_check_name (const cs_adv_field_t *adv, const char *ref_name) | 
| Check if the given advection field has the name ref_name.  More... | |
| void | cs_advection_field_log_setup (void) | 
| Print all setup information related to cs_adv_field_t structures.  More... | |
| void | cs_advection_field_set_postprocess (cs_adv_field_t *adv, cs_flag_t post_flag) | 
| Set optional post-processings.  More... | |
| void | cs_advection_field_def_by_value (cs_adv_field_t *adv, cs_real_t *values) | 
| Define the value of a cs_adv_field_t structure.  More... | |
| void | cs_advection_field_def_by_analytic (cs_adv_field_t *adv, cs_analytic_func_t *func, void *input) | 
| Define a cs_adv_field_t structure thanks to an analytic function.  More... | |
| void | cs_advection_field_def_by_dof_func (cs_adv_field_t *adv, cs_flag_t dof_location, cs_dof_func_t *func, void *input) | 
| Define a cs_adv_field_t structure using a cs_dof_func_t.  More... | |
| cs_xdef_t * | cs_advection_field_def_by_array (cs_adv_field_t *adv, cs_flag_t val_location, cs_real_t *array, bool is_owner) | 
| Define a cs_adv_field_t structure thanks to an array of values. If an advanced usage of the definition by array is needed, then call cs_xdef_array_set_sublist or cs_xdef_array_set_adjacency.  More... | |
| void | cs_advection_field_def_by_field (cs_adv_field_t *adv, cs_field_t *field) | 
| Define a cs_adv_field_t structure thanks to a field structure.  More... | |
| void | cs_advection_field_def_boundary_flux_by_value (cs_adv_field_t *adv, const char *zname, cs_real_t normal_flux) | 
| Define the value of the boundary normal flux for the given cs_adv_field_t structure.  More... | |
| void | cs_advection_field_def_boundary_flux_by_analytic (cs_adv_field_t *adv, const char *zname, cs_analytic_func_t *func, void *input) | 
| Define the value of the boundary normal flux for the given cs_adv_field_t structure using an analytic function.  More... | |
| cs_xdef_t * | cs_advection_field_def_boundary_flux_by_array (cs_adv_field_t *adv, const char *zname, cs_flag_t val_loc, cs_real_t *array, bool is_owner, bool full_length) | 
| Define the value of the boundary normal flux for the given cs_adv_field_t structure using an array of values.  More... | |
| void | cs_advection_field_def_boundary_flux_by_field (cs_adv_field_t *adv, cs_field_t *field) | 
| Define the value of the boundary normal flux for the given cs_adv_field_t structure using a field structure.  More... | |
| void | cs_advection_field_create_fields (void) | 
| Create all needed cs_field_t structures related to an advection field.  More... | |
| void | cs_advection_field_finalize_setup (void) | 
| Last stage of the definition of an advection field based on several definitions (i.e. definition by subdomains on the boundary)  More... | |
| void | cs_advection_field_get_cell_vector (cs_lnum_t c_id, const cs_adv_field_t *adv, cs_nvec3_t *vect) | 
| Compute the value of the advection field at the cell center.  More... | |
| void | cs_advection_field_cw_eval_at_xyz (const cs_adv_field_t *adv, const cs_cell_mesh_t *cm, const cs_real_3_t xyz, cs_real_t time_eval, cs_nvec3_t *eval) | 
| Compute the vector-valued interpolation of the advection field at a given location inside a cell.  More... | |
| void | cs_advection_field_in_cells (const cs_adv_field_t *adv, cs_real_t time_eval, cs_real_t *cell_values) | 
| Compute the mean-value of the vector-valued field related to the advection field inside each cell.  More... | |
| void | cs_advection_field_at_vertices (const cs_adv_field_t *adv, cs_real_t time_eval, cs_real_t *vtx_values) | 
| Compute the value of the advection field at vertices.  More... | |
| void | cs_advection_field_across_boundary (const cs_adv_field_t *adv, cs_real_t time_eval, cs_real_t *flx_values) | 
| Compute the value of the normal flux of the advection field across the boundary faces.  More... | |
| cs_real_t | cs_advection_field_cw_boundary_face_flux (const cs_real_t time_eval, const short int f, const cs_cell_mesh_t *cm, const cs_adv_field_t *adv) | 
| Compute the value of the normal flux of the advection field across a boundary face f (cellwise version)  More... | |
| void | cs_advection_field_cw_boundary_f2v_flux (const cs_cell_mesh_t *cm, const cs_adv_field_t *adv, short int f, cs_real_t time_eval, cs_real_t *fluxes) | 
| Compute the value of the normal flux of the advection field across the closure of the dual cell related to each vertex belonging to the boundary face f.  More... | |
| void | cs_advection_field_cw_face_flux (const cs_cell_mesh_t *cm, const cs_adv_field_t *adv, cs_real_t time_eval, cs_real_t *fluxes) | 
| Compute the value of the flux of the advection field across the the (primal) faces of a cell.  More... | |
| void | cs_advection_field_cw_dface_flux (const cs_cell_mesh_t *cm, const cs_adv_field_t *adv, cs_real_t time_eval, cs_real_t *fluxes) | 
| Compute the value of the flux of the advection field across the the dual faces of a cell.  More... | |
| void | cs_advection_field_update (cs_real_t t_eval, bool cur2prev) | 
| For each cs_adv_field_t structures, update the values of the related field(s)  More... | |
| void | cs_advection_get_peclet (const cs_adv_field_t *adv, const cs_property_t *diff, cs_real_t t_eval, cs_real_t peclet[]) | 
| Compute the Peclet number in each cell.  More... | |
| void | cs_advection_get_courant (const cs_adv_field_t *adv, cs_real_t dt_cur, cs_real_t courant[]) | 
| Compute the Courant number in each cell.  More... | |
| cs_real_t * | cs_advection_field_divergence_at_vertices (const cs_adv_field_t *adv, cs_real_t t_eval) | 
| Compute the divergence of the advection field at vertices Useful for CDO Vertex-based schemes.  More... | |
| Variables | |
| static const char | _err_empty_adv [] | 
| static const cs_cdo_quantities_t * | cs_cdo_quant | 
| static const cs_cdo_connect_t * | cs_cdo_connect | 
| static int | _n_adv_fields = 0 | 
| static cs_adv_field_t ** | _adv_fields = NULL | 
| #define _dp3 cs_math_3_dot_product | 
| #define CS_ADVECTION_FIELD_DBG 0 | 
| #define CS_ADVECTION_FIELD_ID_NOT_SET -1 | 
| #define CS_ADVECTION_FIELD_ID_TO_BE_SET -2 | 
Compute a vector-valued reconstruction of the advection field at vertices from the definition of the advection field.
| [in] | def | pointer to a cs_xdef_t struct. | 
| [in,out] | vtx_values | values of the reconstruction | 
| 
 | static | 
Update the contribution of the flux for each vertex.
| [in] | cm | pointer to a cs_cell_mesh_t structure | 
| [in] | f | face id in the cellwise numbering | 
| [in] | face_flux | value of the normal flux across the face | 
| [in,out] | fluxes | normal boundary flux for each vertex of the face | 
| 
 | static | 
Update the contribution of the flux.
| [in] | cdoq | pointer to a cs_cdo_quantities_t structure | 
| [in] | f2e | face --> edge connectivity | 
| [in] | e2v | edge --> vertices connectivity | 
| [in] | bf_id | boundary face id | 
| [in] | face_flux | value of the normal flux across the face | 
| [in,out] | fluxes | array of values to update | 
| 
 | inlinestatic | 
Return the required dimension for the definition of an advection field.
| [in] | adv | pointer to an advection field structure | 
| void cs_advection_field_across_boundary | ( | const cs_adv_field_t * | adv, | 
| cs_real_t | time_eval, | ||
| cs_real_t * | flx_values | ||
| ) | 
Compute the value of the normal flux of the advection field across the boundary faces.
| [in] | adv | pointer to a cs_adv_field_t structure | 
| [in] | time_eval | physical time at which one evaluates the term | 
| [in,out] | flx_values | array storing the results | 
| cs_adv_field_t* cs_advection_field_add | ( | const char * | name, | 
| cs_advection_field_status_t | status | ||
| ) | 
Add and initialize a new advection field structure.
| [in] | name | name of the advection field | 
| [in] | status | status of the advection field to create | 
| cs_adv_field_t* cs_advection_field_add_user | ( | const char * | name | ) | 
Add and initialize a new user-defined advection field structure.
| [in] | name | name of the advection field | 
| void cs_advection_field_at_vertices | ( | const cs_adv_field_t * | adv, | 
| cs_real_t | time_eval, | ||
| cs_real_t * | vtx_values | ||
| ) | 
Compute the value of the advection field at vertices.
| [in] | adv | pointer to a cs_adv_field_t structure | 
| [in] | time_eval | physical time at which one evaluates the term | 
| [in,out] | vtx_values | array storing the results | 
| cs_adv_field_t* cs_advection_field_by_id | ( | int | id | ) | 
Search in the array of advection field structures which one has the id given in argument.
| [in] | id | identification number | 
| cs_adv_field_t* cs_advection_field_by_name | ( | const char * | name | ) | 
Search in the array of advection field structures which one has the name given in argument.
| [in] | name | name of the advection field | 
| bool cs_advection_field_check_name | ( | const cs_adv_field_t * | adv, | 
| const char * | ref_name | ||
| ) | 
Check if the given advection field has the name ref_name.
| [in] | adv | pointer to a cs_adv_field_t structure to test | 
| [in] | ref_name | name of the advection field to find | 
| void cs_advection_field_create_fields | ( | void | ) | 
Create all needed cs_field_t structures related to an advection field.
| void cs_advection_field_cw_boundary_f2v_flux | ( | const cs_cell_mesh_t * | cm, | 
| const cs_adv_field_t * | adv, | ||
| short int | f, | ||
| cs_real_t | time_eval, | ||
| cs_real_t * | fluxes | ||
| ) | 
Compute the value of the normal flux of the advection field across the closure of the dual cell related to each vertex belonging to the boundary face f.
| [in] | cm | pointer to a cs_cell_mesh_t structure | 
| [in] | adv | pointer to a cs_adv_field_t structure | 
| [in] | f | face id in the cellwise numbering | 
| [in] | time_eval | physical time at which one evaluates the term | 
| [in,out] | fluxes | normal boundary flux for each vertex of the face | 
| cs_real_t cs_advection_field_cw_boundary_face_flux | ( | const cs_real_t | time_eval, | 
| const short int | f, | ||
| const cs_cell_mesh_t * | cm, | ||
| const cs_adv_field_t * | adv | ||
| ) | 
Compute the value of the normal flux of the advection field across a boundary face f (cellwise version)
| [in] | time_eval | physical time at which one evaluates the term | 
| [in] | f | face id in the cellwise numbering | 
| [in] | cm | pointer to a cs_cell_mesh_t structure | 
| [in] | adv | pointer to a cs_adv_field_t structure | 
| void cs_advection_field_cw_dface_flux | ( | const cs_cell_mesh_t * | cm, | 
| const cs_adv_field_t * | adv, | ||
| cs_real_t | time_eval, | ||
| cs_real_t * | fluxes | ||
| ) | 
Compute the value of the flux of the advection field across the the dual faces of a cell.
| [in] | cm | pointer to a cs_cell_mesh_t structure | 
| [in] | adv | pointer to a cs_adv_field_t structure | 
| [in] | time_eval | physical time at which one evaluates the term | 
| [in,out] | fluxes | array of values attached to dual faces of a cell | 
| void cs_advection_field_cw_eval_at_xyz | ( | const cs_adv_field_t * | adv, | 
| const cs_cell_mesh_t * | cm, | ||
| const cs_real_3_t | xyz, | ||
| cs_real_t | time_eval, | ||
| cs_nvec3_t * | eval | ||
| ) | 
Compute the vector-valued interpolation of the advection field at a given location inside a cell.
| [in] | adv | pointer to a cs_adv_field_t structure | 
| [in] | cm | pointer to a cs_cell_mesh_t structure | 
| [in] | xyz | location where to perform the evaluation | 
| [in] | time_eval | physical time at which one evaluates the term | 
| [in,out] | eval | pointer to a cs_nvec3_t | 
| void cs_advection_field_cw_face_flux | ( | const cs_cell_mesh_t * | cm, | 
| const cs_adv_field_t * | adv, | ||
| cs_real_t | time_eval, | ||
| cs_real_t * | fluxes | ||
| ) | 
Compute the value of the flux of the advection field across the the (primal) faces of a cell.
| [in] | cm | pointer to a cs_cell_mesh_t structure | 
| [in] | adv | pointer to a cs_adv_field_t structure | 
| [in] | time_eval | physical time at which one evaluates the term | 
| [in,out] | fluxes | array of values attached to primal faces of a cell | 
| void cs_advection_field_def_boundary_flux_by_analytic | ( | cs_adv_field_t * | adv, | 
| const char * | zname, | ||
| cs_analytic_func_t * | func, | ||
| void * | input | ||
| ) | 
Define the value of the boundary normal flux for the given cs_adv_field_t structure using an analytic function.
| [in,out] | adv | pointer to a cs_adv_field_t structure | 
| [in] | zname | name of the boundary zone to consider | 
| [in] | func | pointer to a function | 
| [in] | input | NULL or pointer to a structure cast on-the-fly | 
| cs_xdef_t* cs_advection_field_def_boundary_flux_by_array | ( | cs_adv_field_t * | adv, | 
| const char * | zname, | ||
| cs_flag_t | val_loc, | ||
| cs_real_t * | array, | ||
| bool | is_owner, | ||
| bool | full_length | ||
| ) | 
Define the value of the boundary normal flux for the given cs_adv_field_t structure using an array of values.
| [in,out] | adv | pointer to a cs_adv_field_t structure | 
| [in] | zname | name of the boundary zone to consider | 
| [in] | val_loc | information to know where are located values | 
| [in] | array | pointer to an array | 
| [in] | is_owner | transfer the lifecycle to the cs_xdef_t struct. (true or false) | 
| [in] | full_length | if true, the size of "array" should be allocated to the total numbers of entities related to the given location. If false, a new list is allocated and filled with the related subset indirection. | 
| void cs_advection_field_def_boundary_flux_by_field | ( | cs_adv_field_t * | adv, | 
| cs_field_t * | field | ||
| ) | 
Define the value of the boundary normal flux for the given cs_adv_field_t structure using a field structure.
| [in,out] | adv | pointer to a cs_adv_field_t structure | 
| [in] | field | pointer to a cs_field_t structure | 
| void cs_advection_field_def_boundary_flux_by_value | ( | cs_adv_field_t * | adv, | 
| const char * | zname, | ||
| cs_real_t | normal_flux | ||
| ) | 
Define the value of the boundary normal flux for the given cs_adv_field_t structure.
| [in,out] | adv | pointer to a cs_adv_field_t structure | 
| [in] | zname | name of the boundary zone to consider | 
| [in] | normal_flux | value to set | 
| void cs_advection_field_def_by_analytic | ( | cs_adv_field_t * | adv, | 
| cs_analytic_func_t * | func, | ||
| void * | input | ||
| ) | 
Define a cs_adv_field_t structure thanks to an analytic function.
| [in,out] | adv | pointer to a cs_adv_field_t structure | 
| [in] | func | pointer to a function | 
| [in] | input | NULL or pointer to a structure cast on-the-fly | 
| cs_xdef_t* cs_advection_field_def_by_array | ( | cs_adv_field_t * | adv, | 
| cs_flag_t | val_location, | ||
| cs_real_t * | array, | ||
| bool | is_owner | ||
| ) | 
Define a cs_adv_field_t structure thanks to an array of values. If an advanced usage of the definition by array is needed, then call cs_xdef_array_set_sublist or cs_xdef_array_set_adjacency.
| [in,out] | adv | pointer to a cs_adv_field_t structure | 
| [in] | val_location | information to know where are located values | 
| [in] | array | pointer to an array | 
| [in] | is_owner | transfer the lifecycle to the cs_xdef_t struc. (true or false) | 
| void cs_advection_field_def_by_dof_func | ( | cs_adv_field_t * | adv, | 
| cs_flag_t | dof_location, | ||
| cs_dof_func_t * | func, | ||
| void * | input | ||
| ) | 
Define a cs_adv_field_t structure using a cs_dof_func_t.
| [in,out] | adv | pointer to a cs_adv_field_t structure | 
| [in] | dof_location | location where values are computed | 
| [in] | func | pointer to a cs_dof_func_t function | 
| [in] | input | NULL or pointer to a structure cast on-the-fly | 
| void cs_advection_field_def_by_field | ( | cs_adv_field_t * | adv, | 
| cs_field_t * | field | ||
| ) | 
Define a cs_adv_field_t structure thanks to a field structure.
| [in,out] | adv | pointer to a cs_adv_field_t structure | 
| [in] | field | pointer to a cs_field_t structure | 
| void cs_advection_field_def_by_value | ( | cs_adv_field_t * | adv, | 
| cs_real_t * | values | ||
| ) | 
Define the value of a cs_adv_field_t structure.
| [in,out] | adv | pointer to a cs_adv_field_t structure | 
| [in] | values | values to set | 
| void cs_advection_field_destroy_all | ( | void | ) | 
Free all allocated cs_adv_field_t structures and its related array.
Free all alllocated cs_adv_field_t structures and its related array.
| cs_real_t* cs_advection_field_divergence_at_vertices | ( | const cs_adv_field_t * | adv, | 
| cs_real_t | t_eval | ||
| ) | 
Compute the divergence of the advection field at vertices Useful for CDO Vertex-based schemes.
| [in] | adv | pointer to the advection field struct. | 
| [in] | t_eval | time at which one evaluates the advection field | 
| void cs_advection_field_finalize_setup | ( | void | ) | 
Last stage of the definition of an advection field based on several definitions (i.e. definition by subdomains on the boundary)
| void cs_advection_field_get_cell_vector | ( | cs_lnum_t | c_id, | 
| const cs_adv_field_t * | adv, | ||
| cs_nvec3_t * | vect | ||
| ) | 
Compute the value of the advection field at the cell center.
| [in] | c_id | id of the current cell | 
| [in] | adv | pointer to a cs_adv_field_t structure | 
| [in,out] | vect | pointer to a cs_nvec3_t structure (meas + unitv) | 
| int cs_advection_field_get_n_fields | ( | void | ) | 
Get the number of allocated cs_adv_field_t structures.
| void cs_advection_field_in_cells | ( | const cs_adv_field_t * | adv, | 
| cs_real_t | time_eval, | ||
| cs_real_t * | cell_values | ||
| ) | 
Compute the mean-value of the vector-valued field related to the advection field inside each cell.
| [in] | adv | pointer to a cs_adv_field_t structure | 
| [in] | time_eval | physical time at which one evaluates the term | 
| [in,out] | cell_values | array of values at cell centers | 
| void cs_advection_field_init_sharing | ( | const cs_cdo_quantities_t * | quant, | 
| const cs_cdo_connect_t * | connect | ||
| ) | 
Set shared pointers to main domain members.
| [in] | quant | additional mesh quantities struct. | 
| [in] | connect | pointer to a cs_cdo_connect_t struct. | 
| void cs_advection_field_log_setup | ( | void | ) | 
Print all setup information related to cs_adv_field_t structures.
| void cs_advection_field_set_postprocess | ( | cs_adv_field_t * | adv, | 
| cs_flag_t | post_flag | ||
| ) | 
Set optional post-processings.
| [in,out] | adv | pointer to a cs_adv_field_t structure | 
| [in] | post_flag | flag to set | 
| void cs_advection_field_update | ( | cs_real_t | t_eval, | 
| bool | cur2prev | ||
| ) | 
For each cs_adv_field_t structures, update the values of the related field(s)
| [in] | t_eval | physical time at which one evaluates the term | 
| [in] | cur2prev | true or false | 
| void cs_advection_get_courant | ( | const cs_adv_field_t * | adv, | 
| cs_real_t | dt_cur, | ||
| cs_real_t | courant[] | ||
| ) | 
Compute the Courant number in each cell.
| [in] | adv | pointer to the advection field struct. | 
| [in] | dt_cur | current time step | 
| [in,out] | courant | pointer to an array storing the Courant number | 
| void cs_advection_get_peclet | ( | const cs_adv_field_t * | adv, | 
| const cs_property_t * | diff, | ||
| cs_real_t | t_eval, | ||
| cs_real_t | peclet[] | ||
| ) | 
Compute the Peclet number in each cell.
| [in] | adv | pointer to the advection field struct. | 
| [in] | diff | pointer to the diffusion property struct. | 
| [in] | t_eval | time at which one evaluates the advection field | 
| [in,out] | peclet | pointer to an array storing the Peclet number | 
| 
 | static | 
| 
 | static | 
| 
 | static | 
| 
 | static | 
| 
 | static |