6.3
general documentation
Postprocessing of results obtained with CDO schemes for a scalar transport equation.

Postprocessing of results obtained with CDO schemes for a scalar transport equation.

This is an example of cs_user_extra_operations allowing to add operations on results produced by CDO schemes. It allows to define advanced postprocessing.

const cs_cdo_connect_t *connect = domain->connect;
const cs_cdo_quantities_t *cdoq = domain->cdo_quantities;
const cs_time_step_t *time_step = domain->time_step;
const char *eqname = cs_equation_get_name(eq);
if (eq == NULL)
bft_error(__FILE__, __LINE__, 0,
" Invalid equation name. Stop extra operations.");
/* Open a file */
char *filename = NULL;
int len = strlen("Resume-.log")+strlen(eqname)+1;
if (eqp->flag & CS_EQUATION_UNSTEADY) {
if (time_step->nt_cur == 0)
return;
if (time_step->nt_cur % domain->output_nt > 0)
return;
len += 9;
BFT_MALLOC(filename, len, char);
sprintf(filename, "Resume-%s-t%.f.log", eqname, time_step->t_cur);
}
else {
if (time_step->nt_cur > 0)
return;
BFT_MALLOC(filename, len, char);
sprintf(filename, "Resume-%s.log", eqname);
}
resume = fopen(filename, "w");
bft_printf(" Extra operations\n");
/* Extra-operation depends on the numerical scheme */
switch (space_scheme) {
_cdovb_post(connect, cdoq, time_step, eq, true);
break;
default:
bft_error(__FILE__, __LINE__, 0,
_("Invalid space scheme. Stop post-processing.\n"));
}
bft_printf("\n");
bft_printf(" >> Equation %s (done)\n", eqname);
printf("\n >> Extra operation for equation: %s\n", eqname);
/* Free */
BFT_FREE(filename);
fclose(resume);
cs_equation_t
Main structure to handle the discretization and the resolution of an equation.
cs_equation_get_name
const char * cs_equation_get_name(const cs_equation_t *eq)
Return the name related to the given cs_equation_t structure.
Definition: cs_equation.c:538
cs_sepline
const char cs_sepline[80]
Definition: cs_param_types.c:69
cs_equation_param_t::flag
cs_flag_t flag
Definition: cs_equation_param.h:228
_
#define _(String)
Definition: cs_defs.h:63
cs_time_step_t::nt_cur
int nt_cur
Definition: cs_time_step.h:74
bft_error
void bft_error(const char *const file_name, const int line_num, const int sys_error_code, const char *const format,...)
Calls the error handler (set by bft_error_handler_set() or default).
Definition: bft_error.c:193
CS_EQUATION_UNSTEADY
#define CS_EQUATION_UNSTEADY
Unsteady term is needed.
Definition: cs_equation_param.h:92
cs_equation_param_t
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources.
Definition: cs_equation_param.h:201
BFT_MALLOC
#define BFT_MALLOC(_ptr, _ni, _type)
Allocate memory for _ni elements of type _type.
Definition: bft_mem.h:62
cs_time_step_t
time step descriptor
Definition: cs_time_step.h:64
BFT_FREE
#define BFT_FREE(_ptr)
Free allocated memory.
Definition: bft_mem.h:101
cs_equation_get_space_scheme
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.
Definition: cs_equation.c:1003
cs_cdo_quantities_t
Definition: cs_cdo_quantities.h:124
cs_time_step_t::t_cur
double t_cur
Definition: cs_time_step.h:80
cs_cdo_connect_t
Definition: cs_cdo_connect.h:76
cs_param_space_scheme_t
cs_param_space_scheme_t
Type of numerical scheme for the discretization in space.
Definition: cs_param_types.h:172
cs_equation_by_name
cs_equation_t * cs_equation_by_name(const char *eqname)
Find the cs_equation_t structure with name eqname Return NULL if not find.
Definition: cs_equation.c:353
CS_SPACE_SCHEME_CDOVB
@ CS_SPACE_SCHEME_CDOVB
Definition: cs_param_types.h:175
cs_equation_get_param
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.
Definition: cs_equation.c:498
bft_printf
int bft_printf(const char *const format,...)
Replacement for printf() with modifiable behavior.
Definition: bft_printf.c:140