Commit 415329ea authored by Alice MAISON's avatar Alice MAISON

Upload src

parent 5da19067
/*----------------------------------------------------------------------------*/
/*
This file is generated by Code_Saturne, a general-purpose CFD tool.
*/
/*----------------------------------------------------------------------------*/
#include "cs_defs.h"
/*----------------------------------------------------------------------------
* Standard C library headers
*----------------------------------------------------------------------------*/
#include <assert.h>
#include <math.h>
#if defined(HAVE_MPI)
#include <mpi.h>
#endif
/*----------------------------------------------------------------------------
* Local headers
*----------------------------------------------------------------------------*/
#include "cs_headers.h"
/*----------------------------------------------------------------------------*/
BEGIN_C_DECLS
/*----------------------------------------------------------------------------*/
cs_real_t *
cs_meg_boundary_function(const cs_zone_t *zone,
const char *field_name,
const char *condition)
{
cs_real_t *new_vals = NULL;
/*--------------------------------------------------*/
/* User defined formula for "velocity" over BC=BC_2 */
if (strcmp(field_name, "velocity") == 0 &&
strcmp(condition, "norm_formula") == 0 &&
strcmp(zone->name, "BC_2") == 0) {
const cs_real_3_t *xyz = (cs_real_3_t *)cs_glob_mesh_quantities->b_face_cog;
const int vals_size = zone->n_elts * 1;
BFT_MALLOC(new_vals, vals_size, cs_real_t);
const cs_real_t H = cs_notebook_parameter_value_by_name("H");
const cs_real_t zref = cs_notebook_parameter_value_by_name("zref");
const cs_real_t Uref = cs_notebook_parameter_value_by_name("Uref");
const cs_real_t z0 = cs_notebook_parameter_value_by_name("z0");
const cs_real_t k = cs_notebook_parameter_value_by_name("k");
for (cs_lnum_t e_id = 0; e_id < zone->n_elts; e_id++) {
cs_lnum_t f_id = zone->elt_ids[e_id];
const cs_real_t z = xyz[f_id][2];
cs_real_t ustar = k * Uref / log((zref - H + z0) / z0) ;
new_vals[0 * zone->n_elts + e_id] = ustar / k * log((z - H + z0) / z0) ;
}
}
/*--------------------------------------------------*/
/*---------------------------------------------------*/
/* User defined formula for "direction" over BC=BC_2 */
if (strcmp(field_name, "direction") == 0 &&
strcmp(condition, "formula") == 0 &&
strcmp(zone->name, "BC_2") == 0) {
const int vals_size = zone->n_elts * 3;
BFT_MALLOC(new_vals, vals_size, cs_real_t);
const cs_real_t phi = cs_notebook_parameter_value_by_name("phi");
const cs_real_t pi = cs_math_pi;
for (cs_lnum_t e_id = 0; e_id < zone->n_elts; e_id++) {
cs_lnum_t f_id = zone->elt_ids[e_id];
new_vals[0 * zone->n_elts + e_id] = sin(phi * pi / 180) ;
new_vals[1 * zone->n_elts + e_id] = cos(phi * pi / 180) ;
new_vals[2 * zone->n_elts + e_id] = 0 ;
}
}
/*---------------------------------------------------*/
/*-------------------------------------------------------*/
/* User defined formula for "turbulence_ke" over BC=BC_2 */
if (strcmp(field_name, "turbulence_ke") == 0 &&
strcmp(condition, "formula") == 0 &&
strcmp(zone->name, "BC_2") == 0) {
const cs_real_3_t *xyz = (cs_real_3_t *)cs_glob_mesh_quantities->b_face_cog;
const int vals_size = zone->n_elts * 2;
BFT_MALLOC(new_vals, vals_size, cs_real_t);
const cs_real_t H = cs_notebook_parameter_value_by_name("H");
const cs_real_t zref = cs_notebook_parameter_value_by_name("zref");
const cs_real_t Uref = cs_notebook_parameter_value_by_name("Uref");
const cs_real_t z0 = cs_notebook_parameter_value_by_name("z0");
for (cs_lnum_t e_id = 0; e_id < zone->n_elts; e_id++) {
cs_lnum_t f_id = zone->elt_ids[e_id];
const cs_real_t z = xyz[f_id][2];
cs_real_t ustar = 0.41 * Uref / log((zref - H + z0) / z0) ;
new_vals[0 * zone->n_elts + e_id] = (cs_math_pow2((ustar))) / (pow(0.09, 0.5)) ;
new_vals[1 * zone->n_elts + e_id] = (cs_math_pow3((ustar))) / (0.41 * (z - H + z0)) ;
}
}
/*-------------------------------------------------------*/
return new_vals;
}
/*----------------------------------------------------------------------------*/
END_C_DECLS
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment