![]() |
Code_Saturne
CFD tool
|
#include "cs_defs.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <bft_mem.h>
#include <bft_error.h>
#include <bft_printf.h>
#include "cs_log.h"
#include "cs_map.h"
#include "cs_parall.h"
#include "cs_mesh_location.h"
#include "cs_field.h"
Functions | |
void | fldps2 (void) |
void | fldps3 (const cs_int_t *nval, cs_real_t *val) |
void | fldpv2 (void) |
void | fldpv3 (const cs_int_t *nval1, const cs_int_t *nval2, cs_real_t *val) |
void | fldde1 (const char *name, const cs_int_t *lname, const cs_int_t *iexten, const cs_int_t *itycat, const cs_int_t *ityloc, const cs_int_t *idim, const cs_int_t *ilved, const cs_int_t *iprev, cs_int_t *ifield CS_ARGF_SUPP_CHAINE) |
void | fldalo (const cs_int_t *ifield) |
void | fldmap (const cs_int_t *ifield, cs_real_t *val, cs_real_t *valp) |
void | fldbcm (const cs_int_t *ifield, cs_real_t *a, cs_real_t *b, cs_real_t *af, cs_real_t *bf) |
void | fldama (void) |
void | fldps1 (const cs_int_t *ifield, const cs_int_t *iprev) |
void | fldpv1 (const cs_int_t *ifield, const cs_int_t *iprev) |
void | fldfi1 (const char *name, const cs_int_t *lname, cs_int_t *ifield CS_ARGF_SUPP_CHAINE) |
void | fldki1 (const char *name, const cs_int_t *lname, cs_int_t *ikey CS_ARGF_SUPP_CHAINE) |
void | fldski (const cs_int_t *ifield, const cs_int_t *ikey, cs_int_t *value) |
void | fldgki (const cs_int_t *ifield, const cs_int_t *ikey, cs_int_t *value) |
void | fldskd (const cs_int_t *ifield, const cs_int_t *ikey, cs_real_t *value) |
void | fldgkd (const cs_int_t *ifield, const cs_int_t *ikey, cs_real_t *value) |
void | fldsk1 (const cs_int_t *ifield, const cs_int_t *ikey, const char *str, const cs_int_t *lstr CS_ARGF_SUPP_CHAINE) |
void | fldgk1 (const cs_int_t *ifield, const cs_int_t *ikey, char *str, const cs_int_t *lstr CS_ARGF_SUPP_CHAINE) |
int | cs_field_n_fields (void) |
Return the number of defined fields. More... | |
cs_field_t * | cs_field_create (const char *name, int type_flag, int location_id, int dim, bool interleaved, bool has_previous) |
Create a field descriptor. More... | |
void | cs_field_allocate_values (cs_field_t *f) |
Allocate arrays for field values. More... | |
void | cs_field_map_values (cs_field_t *f, cs_real_t *val, cs_real_t *val_pre) |
Map existing values to field descriptor. More... | |
void | cs_field_allocate_bc_coeffs (cs_field_t *f, bool have_flux_bc) |
Allocate boundary condition coefficients arrays. More... | |
void | cs_field_map_bc_coeffs (cs_field_t *f, cs_real_t *a, cs_real_t *b, cs_real_t *af, cs_real_t *bf) |
Map existing field boundary condition coefficient arrays. More... | |
void | cs_field_destroy_all (void) |
Destroy all defined fields. More... | |
void | cs_field_allocate_or_map_all (void) |
Allocate arrays for all defined fields based on their location. More... | |
cs_field_t * | cs_field_by_id (int id) |
Return a pointer to a field based on its id. More... | |
cs_field_t * | cs_field_by_name (const char *name) |
Return a pointer to a field based on its name. More... | |
cs_field_t * | cs_field_by_name_try (const char *name) |
Return a pointer to a field based on its name if present. More... | |
int | cs_field_key_id (const char *name) |
Return an id associated with a given key name. More... | |
int | cs_field_key_id_try (const char *name) |
Return an id associated with a given key name if present. More... | |
int | cs_field_define_key_int (const char *name, int default_value, int type_flag) |
Define a key for an integer value by its name and return an associated id. More... | |
int | cs_field_define_key_double (const char *name, double default_value, int type_flag) |
Define a key for an floating point value by its name and return an associated id. More... | |
int | cs_field_define_key_str (const char *name, const char *default_value, int type_flag) |
Define a key for an floating point value by its name and return an associated id. More... | |
int | cs_field_define_sub_key (const char *name, int parent_id) |
Define a sub key. More... | |
void | cs_field_destroy_all_keys (void) |
Destroy all defined field keys and associated values. More... | |
int | cs_field_key_flag (int key_id) |
Get the type flag associated with a given key id. More... | |
int | cs_field_set_key_int (cs_field_t *f, int key_id, int value) |
Assign a integer value for a given key to a field. More... | |
int | cs_field_get_key_int (const cs_field_t *f, int key_id) |
Return a integer value for a given key associated with a field. More... | |
int | cs_field_set_key_double (cs_field_t *f, int key_id, double value) |
Assign a floating point value for a given key to a field. More... | |
double | cs_field_get_key_double (const cs_field_t *f, int key_id) |
Return a floating point value for a given key associated with a field. More... | |
int | cs_field_set_key_str (cs_field_t *f, int key_id, const char *str) |
Assign a character string for a given key to a field. More... | |
const char * | cs_field_get_key_str (const cs_field_t *f, int key_id) |
Return a string for a given key associated with a field. More... | |
void | cs_field_log_defs (void) |
Print info relative to all field definitions to log file. More... | |
void | cs_field_log_info (const cs_field_t *f, int log_keywords) |
Print info relative to a given field to log file. More... | |
void | cs_field_log_fields (int log_keywords) |
Print info relative to all defined fields to log file. More... | |
void | cs_field_log_key_defs (void) |
Print info relative to all key definitions to log file. More... | |
void | cs_field_log_key_vals (int key_id, bool log_defaults) |
Print info relative to a given field key to log file. More... | |
void | cs_field_log_all_key_vals (bool log_defaults) |
Print info relative to all given field keys to log file. More... | |
void | cs_field_define_keys_base (void) |
Define base keys. More... | |
void cs_field_allocate_bc_coeffs | ( | cs_field_t * | f, |
bool | have_flux_bc | ||
) |
Allocate boundary condition coefficients arrays.
For fields on location CS_MESH_LOCATION_CELLS, boundary conditions are located on CS_MESH_LOCATION_BOUNDARY_FACES.
Boundary condition coefficients are not currently supported for other locations (though support could be added by mapping a boundary->location indirection array in the cs_mesh_location_t structure).
For multidimensional fields, arrays are assumed to have the same interleaving behavior as the field, unless components are coupled.
For multidimensional fields with coupled components, interleaving is the norm, and implicit coefficients arrays are arrays of block matrices, not vectors, so the number of entries for each boundary face is dim*dim instead of dim.
[in,out] | f | pointer to field structure |
[in] | have_flux_bc | if true, flux bc coefficients (af and bf) are added |
void cs_field_allocate_or_map_all | ( | void | ) |
Allocate arrays for all defined fields based on their location.
Location sized must thus be known.
Fields that do not own their data should all have been mapped at this stage, and are checked.
void cs_field_allocate_values | ( | cs_field_t * | f | ) |
Allocate arrays for field values.
[in,out] | f | pointer to field structure |
cs_field_t* cs_field_by_id | ( | int | id | ) |
Return a pointer to a field based on its id.
This function requires that a field of the given id is defined.
[in] | id | field id |
cs_field_t* cs_field_by_name | ( | const char * | name | ) |
Return a pointer to a field based on its name.
This function requires that a field of the given name is defined.
[in] | name | field name |
cs_field_t* cs_field_by_name_try | ( | const char * | name | ) |
Return a pointer to a field based on its name if present.
If no field of the given name is defined, NULL is returned.
[in] | name | field name |
cs_field_t* cs_field_create | ( | const char * | name, |
int | type_flag, | ||
int | location_id, | ||
int | dim, | ||
bool | interleaved, | ||
bool | has_previous | ||
) |
Create a field descriptor.
For fields with a dimension greater than 1, components are interleaved.
[in] | name | field name |
[in] | type_flag | mask of field property and category values |
[in] | location_id | id of associated location |
[in] | dim | field dimension (number of components) |
[in] | interleaved | indicate if values ar interleaved (ignored if number of components < 2) |
[in] | has_previous | maintain values at the previous time step ? |
int cs_field_define_key_double | ( | const char * | name, |
double | default_value, | ||
int | type_flag | ||
) |
Define a key for an floating point value by its name and return an associated id.
If the key has already been defined, its previous default value is replaced by the current value, and its id is returned.
[in] | name | key name |
[in] | default_value | default value associated with key |
[in] | type_flag | mask associated with field types with which the key may be associated, or 0 |
int cs_field_define_key_int | ( | const char * | name, |
int | default_value, | ||
int | type_flag | ||
) |
Define a key for an integer value by its name and return an associated id.
If the key has already been defined, its previous default value is replaced by the current value, and its id is returned.
[in] | name | key name |
[in] | default_value | default value associated with key |
[in] | type_flag | mask associated with field types with which the key may be associated, or 0 |
int cs_field_define_key_str | ( | const char * | name, |
const char * | default_value, | ||
int | type_flag | ||
) |
Define a key for an floating point value by its name and return an associated id.
If the key has already been defined, its previous default value is replaced by the current value, and its id is returned.
[in] | name | key name |
[in] | default_value | default value associated with key |
[in] | type_flag | mask associated with field types with which the key may be associated, or 0 |
void cs_field_define_keys_base | ( | void | ) |
Define base keys.
Keys defined by this function are: "label" (string) "post_vis" (integer) "coupled" (integer, restricted to CS_FIELD_VARIABLE) "moment_dt" (integer, restricted to CS_FIELD_PROPERTY);
A recommened practice for different submodules would be to use "cs_<module>_key_init() functions to define keys specific to those modules.
int cs_field_define_sub_key | ( | const char * | name, |
int | parent_id | ||
) |
Define a sub key.
The sub key is the same type as the parent key.
For a given field, when querying a sub key's value and that value has not been set, the query will return the value of the parent key.
[in] | name | key name |
[in] | parent_id | parent key id |
void cs_field_destroy_all | ( | void | ) |
Destroy all defined fields.
void cs_field_destroy_all_keys | ( | void | ) |
Destroy all defined field keys and associated values.
double cs_field_get_key_double | ( | const cs_field_t * | f, |
int | key_id | ||
) |
Return a floating point value for a given key associated with a field.
If the key id is not valid, or the value type or field category is not compatible, a fatal error is provoked.
[in] | f | pointer to field structure |
[in] | key_id | id of associated key |
int cs_field_get_key_int | ( | const cs_field_t * | f, |
int | key_id | ||
) |
Return a integer value for a given key associated with a field.
If the key id is not valid, or the value type or field category is not compatible, a fatal error is provoked.
[in] | f | pointer to field structure |
[in] | key_id | id of associated key |
const char* cs_field_get_key_str | ( | const cs_field_t * | f, |
int | key_id | ||
) |
Return a string for a given key associated with a field.
If the key id is not valid, or the value type or field category is not compatible, a fatal error is provoked.
[in] | f | pointer to field structure |
[in] | key_id | id of associated key |
int cs_field_key_flag | ( | int | key_id | ) |
Get the type flag associated with a given key id.
If the key has not been defined previously, -1 is returned.
[in] | key_id | id of associated key |
int cs_field_key_id | ( | const char * | name | ) |
Return an id associated with a given key name.
The key must have been defined previously.
[in] | name | key name |
int cs_field_key_id_try | ( | const char * | name | ) |
Return an id associated with a given key name if present.
If the key has not been defined previously, -1 is returned.
[in] | name | key name |
void cs_field_log_all_key_vals | ( | bool | log_defaults | ) |
Print info relative to all given field keys to log file.
[in] | log_defaults | if true, log default field values in addition to defined field values |
void cs_field_log_defs | ( | void | ) |
Print info relative to all field definitions to log file.
void cs_field_log_fields | ( | int | log_keywords | ) |
Print info relative to all defined fields to log file.
[in] | log_keywords | log level for keywords (0: do not log, 1: log non-default values, 2: log all) |
void cs_field_log_info | ( | const cs_field_t * | f, |
int | log_keywords | ||
) |
Print info relative to a given field to log file.
[in] | f | pointer to field structure |
[in] | log_keywords | log level for keywords (0: do not log, 1: log non-default values, 2: log all) |
void cs_field_log_key_defs | ( | void | ) |
Print info relative to all key definitions to log file.
void cs_field_log_key_vals | ( | int | key_id, |
bool | log_defaults | ||
) |
Print info relative to a given field key to log file.
[in] | key_id | id of associated key |
[in] | log_defaults | if true, log default field values in addition to defined field values |
void cs_field_map_bc_coeffs | ( | cs_field_t * | f, |
cs_real_t * | a, | ||
cs_real_t * | b, | ||
cs_real_t * | af, | ||
cs_real_t * | bf | ||
) |
Map existing field boundary condition coefficient arrays.
For fields on location CS_MESH_LOCATION_CELLS, boundary conditions are located on CS_MESH_LOCATION_BOUNDARY_FACES.
Boundary condition coefficients are not currently supported for other locations (though support could be added by mapping a boundary->location indirection array in the cs_mesh_location_t structure).
For multidimensional fields, arrays are assumed to have the same interleaving behavior as the field, unless components are coupled.
For multidimensional fields with coupled components, interleaving is the norm, and implicit coefficients arrays are arrays of block matrices, not vectors, so the number of entris for each boundary face is dim*dim instead of dim.
[in,out] | f | pointer to field structure |
[in] | a | explicit BC coefficients array |
[in] | b | implicit BC coefficients array |
[in] | af | explicit flux BC coefficients array, or NULL |
[in] | bf | implicit flux BC coefficients array, or NULL |
void cs_field_map_values | ( | cs_field_t * | f, |
cs_real_t * | val, | ||
cs_real_t * | val_pre | ||
) |
Map existing values to field descriptor.
[in,out] | f | pointer to field structure |
[in] | val | pointer to array of values |
[in] | val_pre | pointer to array of previous values, or NULL |
int cs_field_n_fields | ( | void | ) |
Return the number of defined fields.
int cs_field_set_key_double | ( | cs_field_t * | f, |
int | key_id, | ||
double | value | ||
) |
Assign a floating point value for a given key to a field.
If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned. If the field category is not compatible with the key (as defined by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
[in] | f | pointer to field structure |
[in] | key_id | id of associated key |
[in] | value | value associated with key |
int cs_field_set_key_int | ( | cs_field_t * | f, |
int | key_id, | ||
int | value | ||
) |
Assign a integer value for a given key to a field.
If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned. If the field category is not compatible with the key (as defined by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
[in] | f | pointer to field structure |
[in] | key_id | id of associated key |
[in] | value | value associated with key |
int cs_field_set_key_str | ( | cs_field_t * | f, |
int | key_id, | ||
const char * | str | ||
) |
Assign a character string for a given key to a field.
If the key id is not valid, CS_FIELD_INVALID_KEY_ID is returned. If the field category is not compatible with the key (as defined by its type flag), CS_FIELD_INVALID_CATEGORY is returned.
[in] | f | pointer to field structure |
[in] | key_id | id of associated key |
[in] | str | string associated with key |
void fldalo | ( | const cs_int_t * | ifield | ) |
void fldama | ( | void | ) |
void fldbcm | ( | const cs_int_t * | ifield, |
cs_real_t * | a, | ||
cs_real_t * | b, | ||
cs_real_t * | af, | ||
cs_real_t * | bf | ||
) |
void fldde1 | ( | const char * | name, |
const cs_int_t * | lname, | ||
const cs_int_t * | iexten, | ||
const cs_int_t * | itycat, | ||
const cs_int_t * | ityloc, | ||
const cs_int_t * | idim, | ||
const cs_int_t * | ilved, | ||
const cs_int_t * | iprev, | ||
cs_int_t *ifield | CS_ARGF_SUPP_CHAINE | ||
) |
void fldgk1 | ( | const cs_int_t * | ifield, |
const cs_int_t * | ikey, | ||
char * | str, | ||
const cs_int_t *lstr | CS_ARGF_SUPP_CHAINE | ||
) |
void fldps2 | ( | void | ) |
void fldpv2 | ( | void | ) |
void fldsk1 | ( | const cs_int_t * | ifield, |
const cs_int_t * | ikey, | ||
const char * | str, | ||
const cs_int_t *lstr | CS_ARGF_SUPP_CHAINE | ||
) |