|
My Project
programmer's documentation
|
By default, probes and profile values are "P0" interpolated, that is their value is that of the containing cell or face, or closest vertex.
For cell-based values, a "P1" piecewise linear interpolation may be defined, using gradient reconstruction..
The following example shows how intepolation may be used in the cs_user_postprocess_values function.
First, we define an interpolation function:
static void
_cs_interpolate_from_location_p1(
void *
input,
int val_dim,
const void *location_vals,
void *point_vals)
{
|| (val_dim != 1 && val_dim != 3 && val_dim != 6)) {
datatype,
val_dim,
n_points,
point_location,
point_coords,
location_vals,
point_vals);
return;
}
&gradient_type,
&halo_type);
const char *name =
input;
}
switch(val_dim) {
case 1:
{
if (f != NULL)
false,
1,
true,
else
gradient_type,
halo_type,
1,
true,
100,
0,
0,
0,
0,
-1,
1e-5,
0,
1.5,
NULL,
NULL,
NULL,
c_vals,
NULL,
NULL,
if (c_id > -1) {
cs_real_t d[3] = {point_coords[i][0] - cell_cen[c_id][0],
point_coords[i][1] - cell_cen[c_id][1],
point_coords[i][2] - cell_cen[c_id][2]};
p_vals[i] = c_vals[c_id] +
grad[c_id][0]*d[0]
}
else
p_vals[i] = 0;
}
}
break;
case 3:
{
if (f != NULL)
false,
1,
else
gradient_type,
halo_type,
1,
100,
0,
-1,
1e-5,
1.5,
NULL,
NULL,
c_vals,
NULL,
NULL,
if (c_id > -1) {
cs_real_t d[3] = {point_coords[i][0] - cell_cen[c_id][0],
point_coords[i][1] - cell_cen[c_id][1],
point_coords[i][2] - cell_cen[c_id][2]};
p_vals[i][j] = c_vals[c_id][j] +
grad[c_id][j][0]*d[0]
}
}
else {
p_vals[i][j] = 0;
}
}
}
break;
case 6:
{
if (f != NULL)
false,
1,
else
gradient_type,
halo_type,
1,
100,
0,
-1,
1e-5,
1.5,
NULL,
NULL,
c_vals,
if (c_id > -1) {
cs_real_t d[3] = {point_coords[i][0] - cell_cen[c_id][0],
point_coords[i][1] - cell_cen[c_id][1],
point_coords[i][2] - cell_cen[c_id][2]};
p_vals[i][j] = c_vals[c_id][j] +
grad[c_id][j][0]*d[0]
}
}
else {
p_vals[i][j] = 0;
}
}
}
break;
default:
assert(0);
}
}
Note the the gradient reconstruction used here assumes ghost cell values are synchronized, which should be the case for field values at this calling stage.
This interpolation function may the be passed to the probe values output function (in cs_user_postprocess_values):
int n_p_fields = 2;
const char *p_field_names[] = {"velocity", "temperature"};
for (int i = 0; i < n_p_fields; i++) {
if (f != NULL) {
char p_name[64];
snprintf(p_name, 63,
"%s_p", f->
name); p_name[63] =
'\0';
(mesh_id,
p_name,
1,
_cs_interpolate_from_location_p1,
}
}
}
In this case, selected outputs are named by appending "_p" to the field name to allow combining default probe outputs with interpolated outputs of specific fields.
For simplicity here, values are output to the main probe set and writer, which is assumed to be defined using the GUI in this example.
Note also that interpolation could be also used in some cs_user_extra_operations cases.
int dim
Definition: cs_field.h:131
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:5619
cs_mesh_quantities_t * cs_glob_mesh_quantities
void cs_gradient_tensor_synced_input(const char *var_name, cs_gradient_type_t gradient_type, cs_halo_type_t halo_type, int inc, int n_r_sweeps, int verbosity, int clip_mode, double epsilon, double clip_coeff, const cs_real_t bc_coeff_a[][6], const cs_real_t bc_coeff_b[][6][6], const cs_real_t var[restrict][6], cs_real_63_t *restrict grad)
Compute cell gradient of tensor.
Definition: cs_gradient.c:7936
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:315
void cs_field_gradient_tensor(const cs_field_t *f, bool use_previous_t, int inc, cs_real_63_t *restrict grad)
Compute cell gradient of tensor field.
Definition: cs_field_operator.c:791
const cs_space_disc_t * cs_glob_space_disc
int imrgra
Definition: cs_parameters.h:179
void const cs_int_t *const const cs_int_t *const const cs_int_t *const const cs_int_t *const const cs_int_t *const const cs_int_t *const const cs_int_t *const const cs_int_t *const const cs_int_t *const const cs_real_t *const const cs_real_t *const const cs_real_t *const cs_real_3_t const cs_real_t const cs_real_t cs_real_t cs_real_t cs_real_3_t grad[]
Definition: cs_gradient.h:93
#define CS_REAL_TYPE
Definition: cs_defs.h:407
const char * name
Definition: cs_field.h:126
double cs_real_t
Floating-point value.
Definition: cs_defs.h:302
#define CS_POST_WRITER_ALL_ASSOCIATED
Definition: cs_post.h:66
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:2357
void cs_gradient_scalar_synced_input(const char *var_name, cs_gradient_type_t gradient_type, cs_halo_type_t halo_type, int inc, bool recompute_cocg, int n_r_sweeps, int tr_dim, int hyd_p_flag, int w_stride, int verbosity, int clip_mode, double epsilon, double extrap, double clip_coeff, cs_real_t f_ext[][3], const cs_real_t bc_coeff_a[], const cs_real_t bc_coeff_b[], const cs_real_t var[restrict], const cs_real_t c_weight[restrict], const cs_internal_coupling_t *cpl, cs_real_t grad[restrict][3])
Compute cell gradient of scalar field or component of vector or tensor field.
Definition: cs_gradient.c:7748
void cs_field_gradient_scalar(const cs_field_t *f, bool use_previous_t, int inc, bool recompute_cocg, cs_real_3_t *restrict grad)
Compute cell gradient of scalar field or component of vector or tensor field.
Definition: cs_field_operator.c:529
Definition: cs_gradient.h:56
cs_lnum_t n_cells_with_ghosts
Definition: cs_mesh.h:127
cs_datatype_t
Definition: cs_defs.h:260
cs_real_t * val
Definition: cs_field.h:145
void cs_gradient_vector_synced_input(const char *var_name, cs_gradient_type_t gradient_type, cs_halo_type_t halo_type, int inc, int n_r_sweeps, int verbosity, int clip_mode, double epsilon, double clip_coeff, const cs_real_t bc_coeff_a[][3], const cs_real_t bc_coeff_b[][3][3], const cs_real_t var[restrict][3], const cs_real_t c_weight[restrict], const cs_internal_coupling_t *cpl, cs_real_33_t *restrict grad)
Compute cell gradient of vector field.
Definition: cs_gradient.c:7856
cs_real_t * cell_cen
Definition: cs_mesh_quantities.h:92
#define BFT_MALLOC(_ptr, _ni, _type)
Allocate memory for _ni elements of type _type.
Definition: bft_mem.h:62
#define BFT_FREE(_ptr)
Free allocated memory.
Definition: bft_mem.h:101
cs_real_t cs_real_6_t[6]
vector of 6 floating-point values
Definition: cs_defs.h:317
void cs_gradient_type_by_imrgra(int imrgra, cs_gradient_type_t *gradient_type, cs_halo_type_t *halo_type)
Definition: cs_gradient.c:8000
void cs_int_t cs_int_t cs_int_t cs_real_t * ts
Definition: cs_at_plugin.h:63
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
cs_real_t cs_real_33_t[3][3]
3x3 matrix of floating-point values
Definition: cs_defs.h:321
void cs_interpolate_from_location_p0(void *input, cs_datatype_t datatype, int val_dim, cs_lnum_t n_points, const cs_lnum_t point_location[], const cs_real_3_t point_coords[], const void *location_vals, void *point_vals)
Interpolate values defined on a mesh location at a given set of points using a P0 interpolation.
Definition: cs_interpolate.c:119
cs_halo_type_t
Definition: cs_halo.h:50
Field descriptor.
Definition: cs_field.h:124
cs_real_t cs_real_63_t[6][3]
Definition: cs_defs.h:327
void cs_field_gradient_vector(const cs_field_t *f, bool use_previous_t, int inc, cs_real_33_t *restrict grad)
Compute cell gradient of vector field.
Definition: cs_field_operator.c:713
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:538
cs_gradient_type_t
Definition: cs_gradient.h:54