Non-diffusion volume heat source settings
Posted: Sat May 14, 2022 2:34 pm
Dear all,
I am a newbie to code-saturne,recently,I'm learning how to set the non-diffusion volume heat source.
For example, I define a temp source terms zone(1<x<2,1<z<2) on the GUI page, and name it "cooler". In the "cs_user_source_terms-base .c" file, I did the following . However,this volumetric heat source is diffuse,which could affect the temperature of the area around it. I want this volume heat source to remain in the area I defined, and it will not affect the temperature of the surrounding area. Only when the fluid passes through the area, the effect of the volume heat source will be reflected, which will change the fluid temperature passing through the area.
Can anyone give me some code modification suggestions if it is convenient?
Besides,If it is convenient, can you tell me how to call the current time step, such as using "ttcabs" in Fortran, and how to express it in C language.
Thank you very much for any ideas on this matter
Kind regards
Steven
-----------------------------------------------
#include "cs_defs.h"
#include <assert.h>
#include <math.h>
#include <ple_coupling.h>
#include "cs_headers.h"
BEGIN_C_DECLS
void
cs_user_source_terms(cs_domain_t *domain,
int f_id,
cs_real_t *st_exp,
cs_real_t *st_imp)
{
CS_NO_WARN_IF_UNUSED(domain);
const cs_field_t *f = cs_field_by_id(f_id);
const cs_lnum_t n_cells = cs_glob_mesh->n_cells;
const cs_real_t *cell_f_vol = cs_glob_mesh_quantities->cell_vol;
int var_f_id = cs_field_get_key_int(f, cs_field_key_id("first_moment_id"));
const cs_real_t *cpro_rom = CS_F_(rho)->val;
if (f == CS_F_(t)) {
const cs_var_cal_opt_t *var_cal_opt
= cs_field_get_key_struct_const_ptr(f,
cs_field_key_id("var_cal_opt"));
if (var_cal_opt->iwarni >= 1)
bft_printf(" User source terms for variable %s\n",
cs_field_get_label(f));
/*************************************************************************************/
// main code here!!!!!!!!!!!!!!!!!!!!!!!!
const cs_zone_t *z1 = cs_volume_zone_by_name_try("cooler");
if (z1 != NULL) {
for (cs_lnum_t i = 0; i < z1->n_elts; i++) {
cs_lnum_t c_id = z1->elt_ids;
st_imp[c_id] = -100;
}
}
/************************************************************************************/
}
}
END_C_DECLS
I am a newbie to code-saturne,recently,I'm learning how to set the non-diffusion volume heat source.
For example, I define a temp source terms zone(1<x<2,1<z<2) on the GUI page, and name it "cooler". In the "cs_user_source_terms-base .c" file, I did the following . However,this volumetric heat source is diffuse,which could affect the temperature of the area around it. I want this volume heat source to remain in the area I defined, and it will not affect the temperature of the surrounding area. Only when the fluid passes through the area, the effect of the volume heat source will be reflected, which will change the fluid temperature passing through the area.
Can anyone give me some code modification suggestions if it is convenient?
Besides,If it is convenient, can you tell me how to call the current time step, such as using "ttcabs" in Fortran, and how to express it in C language.
Thank you very much for any ideas on this matter
Kind regards
Steven
-----------------------------------------------
#include "cs_defs.h"
#include <assert.h>
#include <math.h>
#include <ple_coupling.h>
#include "cs_headers.h"
BEGIN_C_DECLS
void
cs_user_source_terms(cs_domain_t *domain,
int f_id,
cs_real_t *st_exp,
cs_real_t *st_imp)
{
CS_NO_WARN_IF_UNUSED(domain);
const cs_field_t *f = cs_field_by_id(f_id);
const cs_lnum_t n_cells = cs_glob_mesh->n_cells;
const cs_real_t *cell_f_vol = cs_glob_mesh_quantities->cell_vol;
int var_f_id = cs_field_get_key_int(f, cs_field_key_id("first_moment_id"));
const cs_real_t *cpro_rom = CS_F_(rho)->val;
if (f == CS_F_(t)) {
const cs_var_cal_opt_t *var_cal_opt
= cs_field_get_key_struct_const_ptr(f,
cs_field_key_id("var_cal_opt"));
if (var_cal_opt->iwarni >= 1)
bft_printf(" User source terms for variable %s\n",
cs_field_get_label(f));
/*************************************************************************************/
// main code here!!!!!!!!!!!!!!!!!!!!!!!!
const cs_zone_t *z1 = cs_volume_zone_by_name_try("cooler");
if (z1 != NULL) {
for (cs_lnum_t i = 0; i < z1->n_elts; i++) {
cs_lnum_t c_id = z1->elt_ids;
st_imp[c_id] = -100;
}
}
/************************************************************************************/
}
}
END_C_DECLS