8.0
general documentation
cs_function.c File Reference

Function objects management. More...

#include "cs_defs.h"
#include <assert.h>
#include <stdarg.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "bft_error.h"
#include "bft_mem.h"
#include "cs_base.h"
#include "cs_log.h"
#include "cs_mesh.h"
#include "cs_mesh_location.h"
#include "cs_mesh_quantities.h"
#include "cs_time_step.h"
#include "cs_function.h"
+ Include dependency graph for cs_function.c:

Functions

cs_function_tcs_function_define_by_func (const char *name, int location_id, int dim, bool is_intensive, cs_datatype_t datatype, cs_eval_at_location_t *data_func, void *data_input)
 Define a function whose data values will be computed using the provided evaluation function. More...
 
cs_function_tcs_function_define_by_analytic_func (const char *name, int location_id, int dim, bool is_intensive, cs_analytic_func_t *data_func, void *data_input)
 Define a function whose data values will be computed using the provided "degree of freedom" type evaluation function. More...
 
cs_function_tcs_function_define_by_dof_func (const char *name, int location_id, int dim, bool is_intensive, cs_dof_func_t *data_func, void *data_input)
 Define a function whose data values will be computed using the provided "degree of freedom" type evaluation function. More...
 
void cs_function_destroy_all (void)
 Destroy all functions management metadata. More...
 
int cs_function_n_functions (void)
 Return the number of defined functions. More...
 
cs_function_tcs_function_by_id (int id)
 Return a pointer to a function object based on its id. More...
 
cs_function_tcs_function_by_name (const char *name)
 Return a pointer to a function object based on its name. More...
 
cs_function_tcs_function_by_name_try (const char *name)
 Return a pointer to a function object based on its name if present. More...
 
void cs_function_set_label (cs_function_t *f, const char *label)
 Assig a label to a function object. More...
 
void cs_function_log_defs (void)
 Log function definition setup information. More...
 
void cs_function_log_all_settings (void)
 Print info relative to all given function object settings to log file. More...
 
void cs_function_evaluate (const cs_function_t *f, const cs_time_step_t *ts, int location_id, cs_lnum_t n_elts, const cs_lnum_t *elt_ids, void *vals)
 Evaluate function values. More...
 

Detailed Description

Function objects management.

Function objects can have various roles. Their main use is to unify handling of expression evaluations for mesh-location based data that can be re-evaluated on the fly (rather than requiring persistent storage such as field data), mostly for logging and post-processing.

Function Documentation

◆ cs_function_by_id()

cs_function_t* cs_function_by_id ( int  id)

Return a pointer to a function object based on its id.

This function requires that a function of the given id is defined.

Parameters
[in]idfunction id
Returns
pointer to the function structure

◆ cs_function_by_name()

cs_function_t* cs_function_by_name ( const char *  name)

Return a pointer to a function object based on its name.

This function requires that a function of the given name is defined.

Parameters
[in]namefunction name
Returns
pointer to the function structure

◆ cs_function_by_name_try()

cs_function_t* cs_function_by_name_try ( const char *  name)

Return a pointer to a function object based on its name if present.

If no function of the given name is defined, NULL is returned.

Parameters
[in]namefunction name
Returns
pointer to the function structure, or NULL

◆ cs_function_define_by_analytic_func()

cs_function_t* cs_function_define_by_analytic_func ( const char *  name,
int  location_id,
int  dim,
bool  is_intensive,
cs_analytic_func_t data_func,
void *  data_input 
)

Define a function whose data values will be computed using the provided "degree of freedom" type evaluation function.

The provided function and optional associated input is of the same form as and may be shared with some boundary condition or property definitions.

Parameters
[in]namename of associated function
[in]location_idid of associated mesh location
[in]dimdimension associated with element data
[in]is_intensiveis the function intensive?
[in]data_funcfunction used to define data values
[in]data_inputpointer to optional (untyped) value or structure to be used by data_func
Returns
pointer to the associated function object in case of success, or NULL in case of error

◆ cs_function_define_by_dof_func()

cs_function_t* cs_function_define_by_dof_func ( const char *  name,
int  location_id,
int  dim,
bool  is_intensive,
cs_dof_func_t data_func,
void *  data_input 
)

Define a function whose data values will be computed using the provided "degree of freedom" type evaluation function.

The provided function and optional associated input is of the same form as and may be shared with some boundary condition or property definitions.

Parameters
[in]namename of associated function
[in]location_idid of associated mesh location
[in]dimdimension associated with element data
[in]is_intensiveis the function intensive?
[in]data_funcfunction used to define data values
[in]data_inputpointer to optional (untyped) value or structure to be used by data_func
Returns
pointer to the associated function object in case of success, or NULL in case of error

◆ cs_function_define_by_func()

cs_function_t* cs_function_define_by_func ( const char *  name,
int  location_id,
int  dim,
bool  is_intensive,
cs_datatype_t  datatype,
cs_eval_at_location_t data_func,
void *  data_input 
)

Define a function whose data values will be computed using the provided evaluation function.

If of dimension > 1, the evaluated values are always interleaved.

Parameters
[in]namename of associated function
[in]location_idid of associated mesh location
[in]dimdimension associated with element data
[in]is_intensiveis the function intensive?
[in]datatypeassociated data values type
[in]data_funcfunction used to define data values
[in]data_inputpointer to optional (untyped) value or structure to be used by data_func
Returns
pointer to the associated function object in case of success, or NULL in case of error

◆ cs_function_destroy_all()

void cs_function_destroy_all ( void  )

Destroy all functions management metadata.

◆ cs_function_evaluate()

void cs_function_evaluate ( const cs_function_t f,
const cs_time_step_t ts,
int  location_id,
cs_lnum_t  n_elts,
const cs_lnum_t elt_ids,
void *  vals 
)

Evaluate function values.

If the matching values are multidimensional, they must be interleaved. The output values are assumed to use a dense storage (i.e. of size n_elts *

for the associated data type, in the same order as elt_ids if present.)

Parameters
[in]fpointer to associated function handle
[in]location_idbase associated mesh location id
[in]n_eltsnumber of associated elements
[in]elt_idsids of associated elements, or NULL if no filtering is required
[in,out]valspointer to output values (size: n_elts*dimension)

◆ cs_function_log_all_settings()

void cs_function_log_all_settings ( void  )

Print info relative to all given function object settings to log file.

◆ cs_function_log_defs()

void cs_function_log_defs ( void  )

Log function definition setup information.

◆ cs_function_n_functions()

int cs_function_n_functions ( void  )

Return the number of defined functions.

Returns
number of defined functions

◆ cs_function_set_label()

void cs_function_set_label ( cs_function_t f,
const char *  label 
)

Assig a label to a function object.

Parameters
[in,out]fpointer to associated function handle
[in]labelassociated label