I want to calculate the derivatives of velocity field and store them.
For example, I want this expression in every iteration:

(∂u/∂y + ∂v/∂x)
How can I get this expression from the code?
Thanks
Code: Select all
call field_gradient_scalar (ivarfl(ivar), 0, imrgra, inc, iccocg, grad)
! - Compute reconstructed value in boundary cells
do ifac = 1, nfabor
iel = ifabor(ifac)
treco(ifac) = cvar_scal(iel) &
+ diipb(1,ifac)*grad(1,iel) &
+ diipb(2,ifac)*grad(2,iel) &
+ diipb(3,ifac)*grad(3,iel)
enddo
Code: Select all
void
cs_user_postprocess_values(const char *mesh_name,
int mesh_id,
int cat_id,
cs_probe_set_t *probes,
cs_lnum_t n_cells,
cs_lnum_t n_i_faces,
cs_lnum_t n_b_faces,
cs_lnum_t n_vertices,
const cs_lnum_t cell_list[],
const cs_lnum_t i_face_list[],
const cs_lnum_t b_face_list[],
const cs_lnum_t vertex_list[],
const cs_time_step_t *ts)
{
/* cs_lnumt is local mesh id*/
cs_real_t *s_cell;
cs_real_33_t *gradv; //
BFT_MALLOC(s_cell, n_cells, cs_real_t);
BFT_MALLOC(gradv, n_cells, cs_real_33_t);
cs_field_gradient_vector(CS_F_(u),
false, //use_previous_t,
CS_GRADIENT_ITER, //gradient type
CS_HALO_STANDARD, //HALO type
1, //inc
gradv);
for (cs_lnum_t i = 0; i < n_cells; i++) {
cs_lnum_t iel = cell_list[i];
s_cell[i] = (gradv[iel][0][0] + gradv[iel][1][1] + gradv[iel][2][2]);
}
cs_post_write_var(mesh_id,
CS_POST_WRITER_ALL_ASSOCIATED, /* writer id filter */
"ugrad", /* var_name */
1, /* var_dim */
true, /* interlace, */
false, /* use_parent */
CS_POST_TYPE_cs_real_t, /* var_type */
s_cell, /* cel_vals */
NULL, /* i_face_vals */
NULL, /* b_face_vals */
ts);
BFT_FREE(s_cell);
}
Code: Select all
#include "cs_defs.h"
#include "cs_field.h"
#include "cs_gradient.h"
#include "cs_halo.h"
#include "cs_field_operator.h"
Code: Select all
****************************
Saving calculation results
****************************
Error in calculation stage.
Code: Select all
IGSEGV signal (forbidden memory area access) intercepted!
Call stack:
1: 0x7f1e920b9818 <+0x312818> (libsaturne.so.5)
2: 0x7f1e8f5dbecf <GOMP_parallel+0x3f> (libgomp.so.1)
3: 0x7f1e920c68c8 <+0x31f8c8> (libsaturne.so.5)
4: 0x7f1e920caac4 <cs_gradient_scalar+0x334> (libsaturne.so.5)
5: 0x7f1e91eb8757 <cs_field_gradient_scalar+0x127> (libsaturne.so.5)
6: 0x5582d41cc6bc <cs_user_postprocess_values+0x8c> (cs_solver)
7: 0x7f1e91ee7c82 <cs_post_time_step_output+0xaa2> (libsaturne.so.5)
8: 0x7f1e91ee8801 <cs_post_write_vars+0x11> (libsaturne.so.5)
9: 0x7f1e91e40921 <caltri_+0x208c> (libsaturne.so.5)
10: 0x7f1e91e1d58d <cs_run+0x57d> (libsaturne.so.5)
11: 0x7f1e91e1cee5 <main+0x125> (libsaturne.so.5)
12: 0x7f1e90f68b97 <__libc_start_main+0xe7> (libc.so.6)
13: 0x5582d41cc2ba <_start+0x2a> (cs_solver)
End of stack