 |
6.3
general documentation
|
|
Additional post-processing variables
For the mesh parts defined using the GUI or in cs_user_postprocess.c, the cs_user_postprocess_values function of the cs_user_postprocess.c file may be used to specify the variables to post-process (called for each postprocess output mesh, at every active time step of an associated writer).
The output of a given variable is generated by means of a call to the cs_post_write_var for cell or face values, cs_post_write_vertex_var for vertex values, cs_post_write_particle_values for particle or trajectory values, and cs_post_write_probe_values for probe or profile values.
The examples of post-processing given below use meshes defined in the examples for cs_user_postprocess_meshes above.
Output a given field or component with a given mesh
To output specific field values on a given postprocessing mesh, that field may be attached (associated) to that mesh.
In the following example, the pressure is output on mesh 4, for all associated writers:
In this second example, the velocity's z component is ouput on mesh 4, only for writer 1:
If the mesh has the auto_variables
option enabled, and a field is already selected for "standard" postprocessing (i.e. selected for output in the GUI, or post_vis
key value includes the CS_POST_ON_LOCATION
bit), it will not be output an additional time, so this option should be safely usable even with limited precautions.
Output of the turbulent kinetic energy for the Rij-Epsilon model on the volume mesh
One can define, compute and post-process the turbulent kinetic energy for the Rij-Epsilon as shown in the following example:
s_cell[i] = 0.5* ( cvar_r[cell_id][0]
+ cvar_r[cell_id][1]
+ cvar_r[cell_id][2]);
}
}
else {
s_cell[i] = 0.5* ( cvar_r11[cell_id]
+ cvar_r22[cell_id]
+ cvar_r33[cell_id]);
}
}
"Turb energy",
1,
true,
false,
s_cell,
NULL,
NULL,
ts);
}
}
Output of a variable on a surface mesh
Values can also be output on a surface mesh, possibly containing a mix of boundary and internal faces. In the following example, we simply average or project adjacent cell values on faces, but more precise techniques could be used:
if (strcmp(mesh_name, "pressure_surface") == 0) {
cs_real_t *s_i_faces = NULL, *s_b_faces = NULL;
if (n_i_faces > 0) {
s_i_faces[i] = 0.5 * (cvar_p[
c1] + cvar_p[
c2]);
}
}
if (n_b_faces > 0) {
s_b_faces[i] = cvar_p[cell_id];
}
}
"Pressure",
1,
true,
false,
NULL,
s_i_faces,
s_b_faces,
ts);
}
Simple output of an existing field or array
For fields or arrays already defined on the full mesh, the "use_parent" option of cs_post_write_var may be used to simply reference the values on the parent (i.e. full) mesh when requesting an output. Note that the example below can also be used with probes or profiles:
if (f != NULL)
1,
true,
true,
NULL,
NULL,
ts);
}
Single output of time-independent values
Finally, a minor modification f the above example shows how it is possible to output time-independent values to a writer also used for time-dependent fields without requiring multiple outputs of those values:
if (f != NULL) {
1,
true,
true,
NULL,
NULL,
&ts0);
}
}
}
Additional profile variables
The following examples match the advanced profile definitions given in Advanced profile definitions.
The first section is common to both profile series:
bool is_profile = false;
NULL,
NULL,
&is_profile,
NULL,
NULL,
NULL,
NULL,
NULL);
ts = NULL;
For the profiles along fixed x, the following code is used. Note that this code's complexity is mainly due to extracting Reynolds stresses for different turbulence models and options. Specific values are then computed for each colum, in the switch statement:
if (strncmp(name, "buicesat", strlen("buicesat")) == 0) {
char var_name[64];
x_sum[0] += cell_cen[c_id][0];
}
x_sum[1] = n_cells;
assert(turb_mdl != NULL);
assert(turb_rans_mdl != NULL);
n_cells,
cell_list,
NULL,
}
else if (turb_mdl->
itytur == 3 && turb_rans_mdl->
irijco == 0) {
}
}
else if (turb_mdl->
itytur == 3) {
rij[i][j] = cvar_rij[c_id][j];
}
}
for (int col = 0; col < 7; col++) {
switch(col) {
case 0:
{
strncpy(var_name, "U*10+x/h", 64);
}
}
break;
case 1:
{
strncpy(var_name, "Y/H", 64);
val[i] = mq->
cell_cen[c_id*3 + 1] / href;
}
}
break;
case 2:
{
strncpy(var_name, "U/Uc", 64);
}
}
break;
case 3:
{
strncpy(var_name, "uu/Uc^2", 64);
val[i] =
rij[i][0] / uref2;
}
}
break;
case 4:
{
strncpy(var_name, "uv/Uc^2", 64);
val[i] =
rij[i][3] / uref2;
}
}
break;
case 5:
{
strncpy(var_name, "vv/Uc^2", 64);
val[i] =
rij[i][1] / uref2;
}
}
break;
case 6:
{
strncpy(var_name, "X", 64);
val[i] = cell_cen[c_id][0];
}
}
break;
}
(mesh_id,
var_name,
1,
0,
NULL,
NULL,
val,
ts_post);
}
}
For the profile defined all around a foil, the following code is used to compute the pressure coefficient and output its values:
val[i] = b_face_cog[face_id][0];
}
(mesh_id,
"X",
1,
0,
NULL,
NULL,
val,
ts);
val[i] = (val[i] -
p0) * div_half_ro0_uref2;
(mesh_id,
"CP",
1,
0,
NULL,
NULL,
val,
ts);
For the last profiles series, values for each column are also computed, requiring a reference pressure based on the mesh point closest to a given point, and computation of tangential stresses, so as to determine drag coefficients.
else if ( strcmp(name, "buicstr") == 0
|| strcmp(name, "buicinc") == 0) {
cs_real_t div_half_ro0_uref2 = 1. / (0.5 * phys_pro->
ro0 * uref2);
char var_name[64];
int pref_rank;
xyz_ref,
&pref_id,
&pref_rank);
pref = pres[pref_id];
for (int col = 0; col < 5; col++) {
switch(col) {
case 0:
{
strncpy(var_name, "X/H", 64);
val[i] = face_cog[f_id][0] / href;
}
}
break;
case 1:
{
strncpy(var_name, "CP", 64);
val[i] = (pres[c_id] - pref) * div_half_ro0_uref2;
}
}
break;
case 2:
{
strncpy(var_name, "CF", 64);
val[i] = cs_math_3_norm(stresses[i]) * div_half_ro0_uref2;
}
}
break;
case 3:
{
strncpy(var_name, "U/UREF", 64);
val[i] = copysign(val[i], stresses[i][0]);
}
}
break;
case 4:
{
strncpy(var_name, "YPLUS", 64);
}
}
break;
}
(mesh_id,
var_name,
1,
0,
NULL,
NULL,
val,
ts_post);
}
}
cs_lnum_t n_cells
Definition: cs_mesh.h:96
void cs_post_b_pressure(cs_lnum_t n_b_faces, const cs_lnum_t b_face_ids[], cs_real_t pres[])
Compute pressure on a specific boundary region.
Definition: cs_post_util.c:956
double precision, dimension(ncharm), save c2
Definition: cpincl.f90:233
@ vel
Definition: cs_field_pointer.h:68
#define CS_POST_MESH_VOLUME
Definition: cs_post.h:75
cs_fluid_properties_t * cs_get_glob_fluid_properties(void)
Definition: cs_physical_constants.c:598
void cs_post_write_probe_values(int mesh_id, int writer_id, const char *var_name, int var_dim, cs_post_type_t var_type, int parent_location_id, cs_interpolate_from_location_t *interpolate_func, void *interpolate_input, const void *vals, const cs_time_step_t *ts)
Output a variable defined at cells or faces of a post-processing mesh using associated writers.
Definition: cs_post.c:6051
cs_mesh_quantities_t * cs_glob_mesh_quantities
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:317
real(c_double), pointer, save ro0
reference density.
Definition: cstphy.f90:151
const cs_turb_model_t * cs_glob_turb_model
void cs_post_evm_reynolds_stresses(cs_field_interpolate_t interpolation_type, cs_lnum_t n_cells, const cs_lnum_t cell_ids[], const cs_real_3_t *coords, cs_real_6_t *rst)
Compute Reynolds stresses in case of Eddy Viscosity Models.
Definition: cs_post_util.c:1044
double precision, dimension(:), pointer distb
For every boundary face, dot product between the vectors and . I is the center of the neighboring ce...
Definition: mesh.f90:188
cs_real_t * b_face_cog
Definition: cs_mesh_quantities.h:104
@ r22
Definition: cs_field_pointer.h:74
#define CS_REAL_TYPE
Definition: cs_defs.h:436
cs_field_interpolate_t
Field interpolation modes.
Definition: cs_field_operator.h:54
void cs_post_mesh_attach_field(int mesh_id, int writer_id, int field_id, int comp_id)
Associate a writer to a postprocessing mesh.
Definition: cs_post.c:4619
@ rij
Definition: cs_field_pointer.h:79
int itytur
Definition: cs_turbulence_model.h:138
const char * name
Definition: cs_field.h:127
@ CS_POST_TYPE_cs_real_t
Definition: cs_post.h:93
int nt_cur
Definition: cs_time_step.h:74
double cs_real_t
Floating-point value.
Definition: cs_defs.h:304
cs_lnum_t * b_face_cells
Definition: cs_mesh.h:111
cs_lnum_2_t * i_face_cells
Definition: cs_mesh.h:110
#define CS_POST_WRITER_ALL_ASSOCIATED
Definition: cs_post.h:63
cs_field_t * cs_field_by_name_try(const char *name)
Return a pointer to a field based on its name if present.
Definition: cs_field.c:2364
double uref
Definition: cs_turbulence_model.h:166
const cs_turb_ref_values_t * cs_glob_turb_ref_values
Definition: cs_mesh_quantities.h:89
@ r23
Definition: cs_field_pointer.h:77
#define CS_POST_MESH_PROBES
Definition: cs_post.h:79
void cs_geom_closest_point(cs_lnum_t n_points, const cs_real_t point_coords[][3], const cs_real_t query_coords[3], cs_lnum_t *point_id, int *rank_id)
find the closest point of a set to a given point in space.
Definition: cs_geom.c:162
cs_turb_model_t * cs_get_glob_turb_model(void)
Provide write access to turbulence model structure.
Definition: cs_turbulence_model.c:1389
real(c_double), pointer, save p0
reference pressure for the total pressure.
Definition: cstphy.f90:168
real(c_double), pointer, save uref
the characteristic flow velocity, used for the initialization of the turbulence. Negative value: not ...
Definition: cstphy.f90:624
const cs_turb_rans_model_t * cs_glob_turb_rans_model
cs_real_t * val
Definition: cs_field.h:146
cs_real_t * cell_cen
Definition: cs_mesh_quantities.h:91
Turbulence model general options descriptor.
Definition: cs_turbulence_model.h:114
#define BFT_MALLOC(_ptr, _ni, _type)
Allocate memory for _ni elements of type _type.
Definition: bft_mem.h:62
RANS turbulence model descriptor.
Definition: cs_turbulence_model.h:173
time step descriptor
Definition: cs_time_step.h:64
#define BFT_FREE(_ptr)
Free allocated memory.
Definition: bft_mem.h:101
#define CS_F_(e)
Macro used to return a field pointer by its enumerated value.
Definition: cs_field_pointer.h:51
@ CS_FIELD_INTERPOLATE_MEAN
Definition: cs_field_operator.h:56
@ r13
Definition: cs_field_pointer.h:78
cs_real_t cs_real_6_t[6]
vector of 6 floating-point values
Definition: cs_defs.h:319
@ r33
Definition: cs_field_pointer.h:75
double viscl0
Definition: cs_physical_constants.h:73
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
int nt_prev
Definition: cs_time_step.h:72
int cs_glob_rank_id
Definition: cs_defs.c:174
void cs_probe_set_get_post_info(const cs_probe_set_t *pset, bool *time_varying, bool *on_boundary, bool *on_curve, bool *auto_variables, bool *auto_curve_coo, bool *auto_cart_coo, int *n_writers, int *writer_ids[])
Retrieve information useful for the postprocessing step.
Definition: cs_probe.c:768
@ r12
Definition: cs_field_pointer.h:76
void cs_post_write_var(int mesh_id, int writer_id, const char *var_name, int var_dim, bool interlace, bool use_parent, cs_post_type_t var_type, const void *cel_vals, const void *i_face_vals, const void *b_face_vals, const cs_time_step_t *ts)
Output a variable defined at cells or faces of a post-processing mesh using associated writers.
Definition: cs_post.c:5513
double ro0
Definition: cs_physical_constants.h:72
void cs_post_stress_tangential(cs_lnum_t n_b_faces, const cs_lnum_t b_face_ids[], cs_real_3_t stress[])
Compute tangential stress on a specific boundary.
Definition: cs_post_util.c:918
void cs_mesh_sync_var_scal(cs_real_t *var)
Definition: cs_mesh.c:3271
int cs_field_id_by_name(const char *name)
Return the id of a defined field based on its name.
Definition: cs_field.c:2387
@ r11
Definition: cs_field_pointer.h:73
Fluid properties descriptor.
Definition: cs_physical_constants.h:61
int irijco
Definition: cs_turbulence_model.h:211
double precision, dimension(:,:), allocatable xpos
Positions.
Definition: atimbr.f90:103
int nt_max
Definition: cs_time_step.h:75
double p0
Definition: cs_physical_constants.h:76
Field descriptor.
Definition: cs_field.h:125
cs_real_t * b_dist
Definition: cs_mesh_quantities.h:123
const char * cs_probe_set_get_name(cs_probe_set_t *pset)
Retrieve the name related to a cs_probe_set_t structure.
Definition: cs_probe.c:740
@ p
Definition: cs_field_pointer.h:67
double precision, dimension(ncharm), save c1
Definition: cpincl.f90:233