 |
6.3
general documentation
|
|
Injection of mass directly in the volume (based on mass source terms) can be defined for selected volume zones. Appropriate zones may be defined in the usual manner, using the GUI, or in the cs_user_zones user-defined function (see examples).
The equation for mass conservation becomes: 
The equation for a variable
becomes:
discretized as 
is the value of
associated to the injected mass.
Two options are available:
- the mass flux is injected with the local value of variable
:
(the equation for
is therefore not modified, and no value needs to be assigned)
- the mass flux is injected with a specific value for
:
is specified by the user
Variables to be specified by the user
Simulation of an inlet condition by mass source terms
When using constant values per zone, an inlet condition can easily be defined adding code similar to the following snipped in the cs_user_finalize_setup function (in cs_user_parameters.c):
const char z_name[] = "mass_injection";
double mass_in[1] = {30000};
double vel_in[3] = {0, wind, 0};
(z_name,
cs_math_sq(wind),
for (int f_id = 0; f_id < n_fields; f_id++) {
double val = 1;
}
}
The value assigned to the pressure is the mass injection rate. For other variables, it is the injected value itself. Note that turbulence variable values based on a hydraulic diameter can and reference velocity easily be set using the function cs_turbulence_inflow_volume_mass_injection_ke_hyd_diam.
Advanced definitions
It is also possible to define more complex injection mass flows using an analytical function. This first requires defining a function matching the cs_analytic_func_t template, such as the one below:
static void
bool dense_output,
void *input,
{
"In function %s: volume of zone %d (%s) is %g.",
if (dense_output == false)
"Function %s currently only handles dense output.",
__func__);
res[i] = xgamma;
}
static bool _logged_mass_flux = false;
if (eqp->
verbosity >= 1 || _logged_mass_flux ==
false) {
}
(" Mass rate generated in the domain: %14.5e\n"
" ----------------------------------\n"),
flucel);
_logged_mass_flux = true;
}
}
}
}
Note that this function injects mass uniformly, but also computes and logs the mass rate generated in the domain.
To use this function for a given volume injection, we define the injection as follows:
z_name,
_define_injection,
f);
In this example, we have assigned the field pointer to the function input, so the function can query the field used for a given call, and could be adapted to handle different variables (which avoids requiring a different function for each variable).
Note that in an actual application, the mass balance can be checked using the balance_by_zone_compute or balance_by_zone_compute functions, so using a more complex injection function is useful only when trying to replicate the mass source terms user function behavior used in previous versions of code_saturne.
Simulation of suction by a pump
In the following example, we simulate the suction (by a pump for instance) with a total rate of 80 000 kg/s. The suction rate is supposed to be uniformly distributed on all the cells in the "suction_pump" zone.
double mass_out[1] = {-80000};
As mass is removed, there is no need to define the values for variables other than pressure. Using cs_equation_add_volume_mass_injection_by_qov, ("quantity over a volume"), the prescribed value is automatically distributed over the associated zone.
@ vel
Definition: cs_field_pointer.h:68
void cs_turbulence_inflow_volume_mass_injection_ke_hyd_diam(const char *zone_name, double uref2, double dh, double rho, double mu)
Define mass injection for turbulent quantities based on a hydraulic diameter and reference velocity.
cs_mesh_quantities_t * cs_glob_mesh_quantities
double precision, dimension(:), pointer cell_f_vol
fluid volume of each cell
Definition: mesh.f90:156
int cs_log_printf(cs_log_t log, const char *format,...)
Print log info to a given log type.
Definition: cs_log.c:501
const cs_turb_model_t * cs_glob_turb_model
cs_real_t measure
Definition: cs_zone.h:74
int verbosity
Definition: cs_equation_param.h:220
#define CS_REAL_TYPE
Definition: cs_defs.h:436
int itytur
Definition: cs_turbulence_model.h:138
@ CS_LOG_DEFAULT
Definition: cs_log.h:50
const cs_zone_t * cs_volume_zone_by_name(const char *name)
Return a pointer to a volume zone based on its name if present.
Definition: cs_volume_zone.c:695
double cs_real_t
Floating-point value.
Definition: cs_defs.h:304
int type
Definition: cs_field.h:130
bool cs_log_default_is_active(void)
Update "active" or "inactive" flag of default log.
Definition: cs_log.c:277
cs_equation_param_t * cs_field_get_equation_param(cs_field_t *f)
Access a field's equation parameters for read only.
Definition: cs_field_default.c:233
Definition: cs_mesh_quantities.h:89
const cs_fluid_properties_t * cs_glob_fluid_properties
Definition: cs_physical_constants.c:385
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_real_t * cell_f_vol
Definition: cs_mesh_quantities.h:93
double precision, dimension(nozppm), save dh
hydraulic diameter
Definition: ppincl.f90:758
cs_xdef_t * cs_equation_add_volume_mass_injection_by_analytic(cs_equation_param_t *eqp, const char *z_name, cs_analytic_func_t *func, void *input)
Add a new volume mass injection definition source term by initializing a cs_xdef_t structure,...
Definition: cs_equation_param.c:3964
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources.
Definition: cs_equation_param.h:201
const void * cs_field_get_key_struct_const_ptr(const cs_field_t *f, int key_id)
Return a read-only pointer to a simple structure for a given key to a field.
Definition: cs_field.c:3565
int iturb
Definition: cs_turbulence_model.h:116
const cs_real_t cs_math_epzero
int cs_field_get_key_int(const cs_field_t *f, int key_id)
Return a integer value for a given key associated with a field.
Definition: cs_field.c:2991
const char * name
Definition: cs_zone.h:57
#define CS_F_(e)
Macro used to return a field pointer by its enumerated value.
Definition: cs_field_pointer.h:51
double viscl0
Definition: cs_physical_constants.h:73
int scalar_id
Definition: keywords.h:127
integer(c_int), pointer, save itytur
Class of turbulence model (integer value iturb/10)
Definition: optcal.f90:524
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
cs_field_t * cs_field_by_id(int id)
Return a pointer to a field based on its id.
Definition: cs_field.c:2314
int id
Definition: cs_zone.h:59
#define CS_UNUSED(x)
Definition: cs_defs.h:478
cs_xdef_t * cs_equation_add_volume_mass_injection_by_qov(cs_equation_param_t *eqp, const char *z_name, double *quantity)
Add a new volume mass injection definition source term by initializing a cs_xdef_t structure,...
Definition: cs_equation_param.c:3916
double ro0
Definition: cs_physical_constants.h:72
int cs_field_key_id(const char *name)
Return an id associated with a given key name.
Definition: cs_field.c:2497
cs_turb_model_type_t
Definition: cs_turbulence_model.h:52
integer(c_int), pointer, save iturb
turbulence model
Definition: optcal.f90:521
#define CS_FIELD_VARIABLE
Definition: cs_field.h:63
Field descriptor.
Definition: cs_field.h:125
int cs_field_n_fields(void)
Return the number of defined fields.
Definition: cs_field.c:1528
cs_xdef_t * cs_equation_add_volume_mass_injection_by_value(cs_equation_param_t *eqp, const char *z_name, double *val)
Add a new volume mass injection definition source term by initializing a cs_xdef_t structure,...
Definition: cs_equation_param.c:3868
@ p
Definition: cs_field_pointer.h:67