/*============================================================================
*
* Code_Saturne version 1.3
* ------------------------
*
*
* This file is part of the Code_Saturne Kernel, element of the
* Code_Saturne CFD tool.
*
* Copyright (C) 1998-2007 EDF S.A., France
*
* contact: saturne-support@edf.fr
*
* The Code_Saturne Kernel is free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* The Code_Saturne Kernel is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the Code_Saturne Kernel; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*
*============================================================================*/
/*============================================================================
* Reader of the parameters file: main parameters, boundary conditions
*============================================================================*/
#if defined(_CS_HAVE_XML)
/*----------------------------------------------------------------------------
* Standard C library headers
*----------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <assert.h>
/*----------------------------------------------------------------------------
* BFT library headers
*----------------------------------------------------------------------------*/
#include <bft_mem.h>
#include <bft_error.h>
#include <bft_printf.h>
/*----------------------------------------------------------------------------
* libxml2 library headers
*----------------------------------------------------------------------------*/
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
/*----------------------------------------------------------------------------
* Local headers
*----------------------------------------------------------------------------*/
#include "cs_base.h"
#include "cs_msg.h"
#include "cs_gui_util.h"
/*----------------------------------------------------------------------------
* Header for the current file
*----------------------------------------------------------------------------*/
#include "cs_gui.h"
/*----------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C" {
#if 0
} /* Fake brace to force Emacs auto-indentation back to column 0 */
#endif
#endif /* __cplusplus */
/*=============================================================================
* Local Macro Definitions
*============================================================================*/
/* debugging switch */
#define _XML_DEBUG_ 0
/*============================================================================
* Local Structure Definitions
*============================================================================*/
/*----------------------------------------------------------------------------
* Structure associated to boundary conditions definition
*----------------------------------------------------------------------------*/
typedef struct {
double val1; /* Correspond a RCODCL(.,.,1) */
double val2; /* Correspond a RCODCL(.,.,2) */
double val3; /* Correspond a RCODCL(.,.,3) */
} cs_val_t ;
typedef struct {
double *ratio; /* Ratio for each coal */
} cs_coal_ashes_ratio_t ;
typedef struct {
char **label; /* Pour chaque numéro de label
contient le nom du label */
char **nature; /* Pour chaque numéro de label contient
la nature de la CL */
int *numero_label; /* Pour chaque reference contient *
* le numéro du label associé */
int *nature_fortran; /* Pour chaque reference contient la valeur *
* associee a la nature de la condition *
* limite */
int *ientat; /* Pour chaque numéro de label (equivalent au numéro de zone)contient
la valeur de IENTAT */
int *iqimp; /* Pour chaque numéro de label (equivalent au numéro de zone)contient
la valeur de IQUIMP */
double *qimpat; /* Pour chaque numéro de label (equivalent au numéro de zone)contient
la valeur de QIMPAT */
double *timpat; /* Pour chaque numéro de label (equivalent au numéro de zone)contient
la valeur de TIMPAT */
int *ientcp; /* Pour chaque numéro de label (equivalent au numéro de zone)contient
la valeur de IENTAT */
int *icalke; /* Pour chaque numéro de label (equivalent au numéro de zone)contient
la valeur de ICALKE */
double **qimpcp; /* Pour chaque numéro de label (equivalent au numéro de zone) et pour chaque charbon contient
la valeur de QIMPCP */
double **timpcp; /* Pour chaque numéro de label (equivalent au numéro de zone) et pour chaque charbon contient
la valeur de TIMPCP */
cs_coal_ashes_ratio_t **distch; /* Pour chaque numéro de label et pour chaque charbon(equivalent au numéro de zone)contient
la répartition de classe */
double *dh; /* Pour chaque numéro de label (equivalent au numéro de zone) contient
la valeur de DH */
double *xintur; /* Pour chaque numéro de label (equivalent au numéro de zone) contient
la valeur de XINTUR */
int **type_code; /* Pour chaque reference et chaque variable *
* contient la valeur associée au type de *
* la CL (DIRICHLET, NEUMAN,...) */
cs_val_t **values; /* Pour chaque reference et chaque variable *
* contient la ou les valeurs necessaires */
} cs_boundary_t ;
/*----------------------------------------------------------------------------
* Variables and scalars management structure
*----------------------------------------------------------------------------*/
typedef struct {
int nscapp; /* nombre de scalaires physique particulière */
int nscaus; /* nombre total de scalaires */
int nprop; /* nombre total de proprietes */
int nsalpp; /* nombre de proprietes physiques pour la physique particuliere active */
int nvar; /* nombre de variables utilisees */
int *rtp_ptr; /* Pour chaque enum de la variable, */
/* contient la position de cette variable */
/* dans le tableau RTP, RTPA ..... */
int *rtp_nbr; /* Pour chaque numero de variable, */
/* contient la position de cette variable */
/* dans le tableau RTP, RTPA ..... */
int *name2; /* Pour chaque numéro de variable,
contient l'enum de la variable */
char **char2;
char **label; /* Pour chaque numéro de scalaire
contient le label du scalaire */
int *XMLnumsca; /* Pour chaque scalaire model (numérotation du noyau),
contient le numéro du scalaire dans le XML */
int *XMLnumpp; /* Pour chaque propriete physique de la physique
particuliere active (numérotation du noyau),
contient le numéro du scalaire dans le XML */
} cs_var_t ;
/*============================================================================
* External global variables
*============================================================================*/
/*----------------------------------------------------------------------------
* Gestion du document xml
*----------------------------------------------------------------------------*/
extern xmlXPathContextPtr xpathCtx; /* Pointer on the Contexte */
extern xmlNodePtr node; /* Pointer on the root node */
/*============================================================================
* Private global variables
*============================================================================*/
/*----------------------------------------------------------------------------
* Tableaux de chaines de caractères pour la construction des requetes Xpath
*----------------------------------------------------------------------------*/
static const char *const cs_coal_combustion_scalar[9] =
{ "ENT_CP",
"NP_CP",
"XCH_CP",
"XCK_CP",
"Fr_MV1",
"Fr_MV2",
"Enthalpy",
"Fr_HET",
"Var_AIR"};
static const char *const cs_coal_combustion_properties[19] =
{
"Temp_GAZ",
"ROM_GAZ",
"YM_CHx1m",
"YM_CHx2m",
"YM_CO",
"YM_O2",
"YM_CO2",
"YM_H2O",
"YM_N2",
"XM",
"Temp_CP",
"Frm_CP",
"Rho_CP",
"Dia_CK",
"Ga_DCH",
"Ga_DV1",
"Ga_DV2",
"Ga_HET",
"ntLuminance_4PI"};
static const char * const cs_combustion_variables_name[2] =
{ "temperature", "pressure" };
static const char *const cs_variable[3] =
{ "variable", "scalar", "property" };
static const char *const cs_values_name[18] =
{ "initial_value",
"min_value",
"max_value",
"blending_factor",
"order_scheme",
"slope_test",
"flux_reconstruction",
"time_step_factor",
"max_iter_number",
"solveur_precision",
"gradient_transpose",
"pressure_relaxation",
"wall_pressure_extrapolation",
"velocity_pressure_coupling",
"gradient_reconstruction",
"probe_recording",
"postprocessing_recording",
"listing_printing" };
static const char *const cs_first_path_element[9] =
{ "thermophysical_models", "physical_properties",
"additional_scalars", "lagrangien",
"boundary_conditions", "calcul_management",
"analysis_control", "numerical_parameters",
"matisse" };
static const char *const cs_thermal_scalar_name[3]=
{ "enthalpy",
"temperature_kelvin",
"temperature_celsius" };
static const char *const cs_properties_name[11]=
{ "density",
"molecular_viscosity",
"turb_viscosity",
"smagorinsky_constant",
"specific_heat",
"weight_matrix_X",
"weight_matrix_Y",
"weight_matrix_Z",
"local_time_step",
"diffusion_coefficient",
"thermal_conductivity" };
/*----------------------------------------------------------------------------
* Private global variables for the treatment
* of NOMVAR. NOMVAR is a characters fortran array
*----------------------------------------------------------------------------*/
static int _cs_gui_max_vars = 0;
static int _cs_gui_last_var = 0;
static char ** _cs_gui_var_name = NULL;
/*----------------------------------------------------------------------------
* Private global variables for boundaru conditions
*----------------------------------------------------------------------------*/
static cs_boundary_t *boundaries = NULL;
static cs_var_t *vars = NULL;
/*============================================================================
* Prototypes de fonctions privées
*============================================================================*/
/*----------------------------------------------------------------------------
* Turbulence model parameters.
*
* parameters:
* param --> name of the parameters
* keyword <-- turbulence model parameter
*----------------------------------------------------------------------------*/
void cs_gui_advanced_options_turbulence(const char *const param,
int *const keyword);
/*----------------------------------------------------------------------------
* Fonctions liees a la balise <initialization>
*----------------------------------------------------------------------------*/
int cs_gui_initialization_zones_number(void);
char *cs_gui_initialization_zone_name(const int ith_zone);
char *cs_gui_initialization_zone_description(const char *const name);
void cs_gui_cells_list_building(const char *const description,
int * cells,
int ** cells_list,
const int *const ncel,
const int *const nfml,
const int *const nprfml,
const int *const ifmcel,
const int *const iprfml);
void cs_gui_variable_initial_value(const char *const variable_name,
const char *const zone_name,
double *const initial_value);
void cs_gui_reference_pressure(double *const p0);
void cs_gui_thermal_scalar_initial_value(const char *const model_type,
const char *const zone_name,
double *const initial_value);
void cs_gui_scalar_initial_value(const char *const parent,
const char *const label,
const char *const zone_name,
double *const initial_value);
/*----------------------------------------------------------------------------
* Fonctions liees a la balise <thermophysical_models>
*----------------------------------------------------------------------------*/
void cs_gui_variable_value(const char *const variable_type,
const char *const value_type,
double *const value);
void cs_gui_variable_status(
const char *const variable,
const char *const value,
int *const keyword
);
int cs_gui_variable_number_probes(
const char*const variable
);
char *cs_gui_variable_label(const char *const variable);
int cs_gui_variable_probe_name(
const char *const variable,
int num_probe
);
/*----------------------------------------------------------------------------
* Initialization choice of the turbulente variables parameters.
*
* parameters:
* param --> name of the parameter
* value <-- initialization choice
*----------------------------------------------------------------------------*/
void cs_gui_turbulence_initialization(const char *const param,
double *const value);
/*----------------------------------------------------------------------------
* Return the initialization choice of the turbulente variables.
*----------------------------------------------------------------------------*/
char *cs_gui_turbulence_initialization_choice(void);
/*----------------------------------------------------------------------------
* Fonctions liees aux scalaires
*----------------------------------------------------------------------------*/
/* Scalaire thermique et scalaires lies au physiques particulieres */
int cs_gui_thermal_scalar(void);
void cs_gui_thermal_scalar_number(
int *const iscalt,
int *const iscsth
);
void cs_gui_model_scalar_value(
const char* const model,
const int num_sca,
const cs_values_t value_type,
double *const value
);
int cs_gui_thermal_scalar_number_probes(
const char *const model_type
);
int cs_gui_model_scalar_number_probes(
const char* const model,
const int num_sca
);
int cs_gui_model_property_number_probes(
const char* const model,
const int num_pro
);
char *cs_gui_get_model_property_label
(
const char * const model,
const int num_prop
);
char *cs_gui_get_thermal_scalar_label(
const char *const model_type
);
int cs_gui_thermal_scalar_probe_name(
const char *const model_type,
const int num_probe
);
int cs_gui_model_scalar_probe_name(
const char* const model,
const int num_sca,
const int num_probe
);
int cs_gui_model_property_probe_name(
const char* const model,
const int num_prop,
const int num_probe
);
void cs_gui_thermal_scalar_output_status(
const char *const model_type,
const char *const value_type,
int *const keyword
);
void cs_gui_model_scalar_output_status(
const char* const model,
const int num_sca,
const cs_values_t value_type,
int *const keyword
);
void cs_gui_model_property_output_status(
const char* const model,
const int num_prop,
const cs_values_t value_type,
int *const keyword
);
void cs_gui_model_property_post
(
const char *const model,
const int num_prop,
int *const ihisvr,
int *const ilisvr,
int *const ichrvr,
const int *const ipppro,
const int *const ipproc,
const int *const nvppmx);
char *cs_gui_get_additional_scalar_variance(const int num_sca);
/*----------------------------------------------------------------------------
* Get the text value associated to a child markup from a scalar.
*
* parameters:
* label --> label of the scalar markup
* child --> name of the child markup
* value <-- value of text node contained in the child markup
*----------------------------------------------------------------------------*/
void cs_gui_scalar_value(const char *const label,
const char *const child,
double *const value);
int cs_gui_additional_scalar_number_probes(const int scalar_num);
void cs_gui_add_scalar_diffusion_coeff_value(
const int scalar_num,
const cs_properties_t property,
const cs_values_t value_type,
double *const value
);
int cs_gui_add_scalar_properties_choice(
const int scalar_num,
const char *const property_name,
int *const choice
);
/*----------------------------------------------------------------------------
* Get the attribute value associated to a child markup from a scalar.
*
* parameters:
* label --> label of the scalar markup
* child --> name of the child markup
* value <-- value of attribute node contained in the
* child markup
*----------------------------------------------------------------------------*/
void cs_gui_scalar_attribute(const char *const label,
const char *const child,
int *const keyword);
int cs_gui_additional_scalar_probe_name(
const int scalar_num,
const int num_probe
);
/*-----------------------------------------------------------------------------
* Return the label attribute of scalars.
*
* parameters:
* markup --> parent markup of the scalar
* scalar_num <-- number of the searching scalar
*----------------------------------------------------------------------------*/
char *cs_gui_scalar_label(const char *const markup,
const int scalar_num);
/*-----------------------------------------------------------------------------
* Get time parameters.
*
* parameters:
* param --> time parameter
* keyword <-- new value of the time parameter
*----------------------------------------------------------------------------*/
void cs_gui_time_parameters(const char *const param,
double *const keyword);
/*-----------------------------------------------------------------------------
* Get restart parameters.
*
* parameters:
* param --> restart parameter
* keyword <-- new value of the restart parameter
*----------------------------------------------------------------------------*/
void cs_gui_restart_parameters_status(const char *const param,
int *const keyword);
/*-----------------------------------------------------------------------------
* Get restart files format.
*
* parameters:
* param --> restart file name
* keyword <-- new value of the restart file format
*----------------------------------------------------------------------------*/
void cs_gui_restart_parameters_file_format(const char *const param,
int *const format);
/*-----------------------------------------------------------------------------
* Get gravity parameters.
*
* parameters:
* param --> gravity parameter (GX, GY, GZ)
* keyword <-- new value of the gravity parameter
*----------------------------------------------------------------------------*/
void cs_gui_gravity_value(const char *const param,
double *const value);
/*-----------------------------------------------------------------------------
* Get initial value from property markup.
*
* parameters:
* property_name --> name of the property
* value <-- new initial value of the property
*----------------------------------------------------------------------------*/
void cs_gui_properties_value(const char *const property_name,
double *const value);
/*----------------------------------------------------------------------------
* Get the value of the choice attribute from a property markup.
* Return 1 if the xpath request has succeeded, 0 otherwise.
*
* parameters:
* property_name --> name of the property
* choice <-- value of the attribute choice
*----------------------------------------------------------------------------*/
int cs_gui_properties_choice(const char *const property_name,
int * choice);
void cs_gui_properties_status(const char *const property_name,
const char *const value_type,
int *const keyword);
int cs_gui_properties_number_probes(const char *const property_name);
int cs_gui_properties_probe_name(const char *const property_name,
const int num_probe);
/*-----------------------------------------------------------------------------
* Get the label attribute of a property markup.
*
* parameters:
* property_name --> name of the property
* keyword <-- output control parameter
*----------------------------------------------------------------------------*/
char *cs_gui_properties_label(const char *const property_name);
/*----------------------------------------------------------------------------
* Return the output format and options for postprocessing.
*
* parameters:
* param --> name of the parameter
* keyword <-- output control parameter
* size_key --> keyword string size
*----------------------------------------------------------------------------*/
void cs_gui_output_choice(const char *const param,
char *const keyword,
const int *const size_key);
/*----------------------------------------------------------------------------
* Get output control value parameters.
*
* parameters:
* param --> name of the parameter
* keyword <-- output control parameter
*----------------------------------------------------------------------------*/
void cs_gui_output_value(const char *const param,
int *const keyword);
/*-----------------------------------------------------------------------------
* Return the number of the <probe> markups.
*----------------------------------------------------------------------------*/
int cs_gui_probes_number(void);
/*-----------------------------------------------------------------------------
* Return a single coordinate of a monitoring probe
*
* parameters
* num_probe --> number aka name of the monitoring probe
* probe_coord --> one coordinate of the monitoring probe
*----------------------------------------------------------------------------*/
double cs_gui_probe_coordinate(const int num_probe,
const char *const probe_coor);
void cs_gui_thermophysical_post(const char *const variable,
const int ipp,
int *const ihisvr,
int *const ilisvr,
int *const ichrvr,
const int *const nvppmx);
void cs_gui_thermal_scalar_post(
const char *const model_type,
const int num_sca,
int *const ihisvr,
int *const ilisvr,
int *const ichrvr,
const int *const ipprtp,
const int *const isca,
const int *const nvppmx);
void cs_gui_additional_scalar_post(
const int num_sca,
int *const ihisvr,
int *const ilisvr,
int *const ichrvr,
const int *const ipprtp,
const int *const isca,
const int *const nvppmx);
void cs_gui_properties_post(
const char *const property_name,
const int ipp,
int *const ichrvr,
int *const ilisvr,
int *const ihisvr,
const int *const nvppmx);
/*-----------------------------------------------------------------------------
* Copy a variable name to private variable names array
*
* parameters:
* varname --> name or label of the variable/scalar/property
* ipp --> index from the fortran array associated to varname
*----------------------------------------------------------------------------*/
static void _cs_gui_copy_varname(const char *varname, int ipp);
/*----------------------------------------------------------------------------
* Conditions limites
*----------------------------------------------------------------------------*/
int cs_gui_boundary_code(const cs_boundary_value_t bvalue);
int cs_gui_boundary_zone_reference(const char *const nature,
const char *const label,
const int ith_ref);
int cs_gui_boundary_nature(const char *const nature,
const int *const iindef,
const int *const ientre,
const int *const iparoi,
const int *const isymet,
const int *const isolib);
char *cs_gui_boundary_choice(const char *const nature,
const char *const label,
const char *const var_sca,
const char *const sca_lbl);
void cs_gui_boundary_dirichlet(const char *const nature,
const char *const label,
const char *const var_name,
const int izone,
const int ivar);
void cs_gui_boundary_flow(const char *const label,
const int izone,
const int faces,
int *const faces_list,
const double *const surfbo);
void cs_gui_boundary_turbulence(const char *const choice,
const int *const iturb,
const int izone);
void cs_gui_boundary_value_scalar(const char *const nature,
const char *const thscal,
const int izone,
const int numvar,
const int nscalth,
const int iscal);
void cs_gui_coal_boundary_turbulence(const char *const choice,
const int izone);
void cs_gui_coal_boundary_coalflow(const int izone,
const int *const ncharb,
const int *const nclpch);
/*-----------------------------------------------------------------------------
* Modify double numerical parameters.
*
* parameters:
* param --> label of the numerical parameter
* keyword <-- value of the numerical parameter
*----------------------------------------------------------------------------*/
void cs_gui_numerical_double_parameters(const char *const param,
double *const keyword);
/*-----------------------------------------------------------------------------
* Modify integer numerical parameters.
*
* parameters:
* param --> label of the numerical parameter
* keyword <-- value of the numerical parameter
*----------------------------------------------------------------------------*/
void cs_gui_numerical_int_parameters(const char *const param,
int *const keyword);
/*----------------------------------------------------------------------------
* Fonctions pour les physique particuliere
*----------------------------------------------------------------------------*/
void cs_gui_thermal_scalar_value
(
const char *const model_type, /* Type de modele */
const char *const value_type, /* Type de valeur */
double *const value /* valeur de la variable */
);
void cs_gui_model_scalar_post
(
const char *const model,
const int num_sca,
int *const ihisvr,
int *const ilisvr,
int *const ichrvr,
const int *const ipprtp,
const int *const isca,
const int *const nvppmx);
int cs_gui_get_number_model_scalar(const char* model);
int cs_gui_get_number_user_scalar(void);
int cs_gui_get_number_model_properties(const char* model);
int cs_gui_get_model_scalar_number
(
const char * const model,
const char * const name
);
int cs_gui_get_model_property_number(
const char * const model,
const char * const name
);
char* cs_gui_get_model_scalar_name
(
const char * const model,
const int scalar_num
);
char* cs_gui_get_model_property_name
(
const char * const model,
const int scalar_num
);
int cs_gui_get_combustion_initial_value
(
const char* const model,
const int variable,
double * const value
);
/*============================================================================
* C API public functions
*============================================================================*/
/*-----------------------------------------------------------------------------
* Free memory: clean global private variables and libxml2 variables
*----------------------------------------------------------------------------*/
void cs_gui_clean_memory(void)
{
int i;
int ivar;
int izone;
int zones;
if (boundaries != NULL) {
/* clean memory for global private structure boundaries */
zones = cs_gui_boundary_zones_number();
for (izone=0 ; izone < zones ; izone++) {
BFT_FREE(boundaries->label[izone]);
BFT_FREE(boundaries->nature[izone]);
}
for (i=0; i < vars->nvar; i++) {
ivar = vars->rtp_nbr[i];
BFT_FREE(boundaries->type_code[ivar]);
BFT_FREE(boundaries->values[ivar]);
}
BFT_FREE(boundaries->label);
BFT_FREE(boundaries->nature);
BFT_FREE(boundaries->type_code);
BFT_FREE(boundaries->values);
BFT_FREE(boundaries);
}
if (vars != NULL) {
/* clean memory for global private structure vars */
for (i=0; i < vars->nscaus+vars->nscapp; i++) BFT_FREE(vars->label[i]);
for (i=0; i < vars->nvar -vars->nscaus -vars->nscapp; i++) BFT_FREE(vars->char2[i]);
BFT_FREE(vars->label);
BFT_FREE(vars->rtp_ptr);
BFT_FREE(vars->rtp_nbr);
BFT_FREE(vars->name2);
BFT_FREE(vars->char2);
BFT_FREE(vars);
}
/* clean memory for fortran name of variables */
for (i = 0; i < _cs_gui_max_vars; i++)
BFT_FREE(_cs_gui_var_name[i]);
BFT_FREE(_cs_gui_var_name);
/* clean memory for xml document */
if (xpathCtx != NULL) xmlXPathFreeContext(xpathCtx);
if (node != NULL) xmlFreeNode(node);
/* Shutdown libxml */
xmlCleanupParser();
xmlMemoryDump();
}
/*-----------------------------------------------------------------------------
* Return the name of a thermophysical model.
*
* parameter:
* model_thermo --> thermophysical model
*----------------------------------------------------------------------------*/
char *cs_gui_get_thermophysical_model(const char *const model_thermo)
{
char *model = NULL;
char *path = NULL;
path = cs_xpath_init_path();
cs_xpath_add_elements(&path, 2, "thermophysical_models", model_thermo);
cs_xpath_add_attribute(&path, "model");
model = cs_gui_get_attribute_value(path);
BFT_FREE(path);
return model;
}
/*-----------------------------------------------------------------------------
* Return if a particular physics model is activated.
*
* parameters:
* model <-- thermophysical model
* value <-- model name associated
*----------------------------------------------------------------------------*/
int cs_gui_get_activ_thermophysical_model (char **model, char **value)
{
int isactiv = 0;
*value = NULL;
*model = NULL;
*value = cs_gui_get_thermophysical_model("pulverized_coal");
if (!cs_gui_strcmp(*value, "off")) {
BFT_MALLOC(*model, strlen("pulverized_coal")+1, char);
strcpy(*model, "pulverized_coal");
isactiv = 1;
}
/* modeltmp = cs_gui_get_thermophysical_model(JOULE_EFFECT); */
/* modeltmp = cs_gui_get_thermophysical_model(GAS_COMBUSTION); */
/* modeltmp = cs_gui_get_thermophysical_model(RADIATIVE_TRANSFER); */
return isactiv;
}
/*-----------------------------------------------------------------------------
*
*----------------------------------------------------------------------------*/
void cs_gui_faces_list_building(const char *const nature,
const char *const label,
int * faces,
int ** faces_list,
const int *const nfabor,
const int *const nfml,
const int *const ifmfbr,
const int *const iprfml)
{
int ifbr;
int icpt;
int i, ref, refs;
int ifml;
int icoul;
*faces = 0;
icpt = 0;
refs = cs_gui_boundary_zone_reference_number(nature, label);
for (i=1 ; i < refs+1 ; i++) {
ref = cs_gui_boundary_zone_reference(nature, label, i);
for (ifbr=0 ; ifbr < *nfabor ; ifbr++) {
ifml = ifmfbr[ifbr];
icoul = iprfml[0 * (*nfml) + (ifml-1)];
if (icoul == ref) icpt++;
}
}
if (!icpt) return;
*faces = icpt;
BFT_MALLOC((*faces_list), *faces, int);
icpt = 0;
for (i=1 ; i < refs+1 ; i++) {
ref = cs_gui_boundary_zone_reference(nature, label, i);
for (ifbr=0 ; ifbr < *nfabor ; ifbr++) {
ifml = ifmfbr[ifbr];
icoul = iprfml[0 * (*nfml) + (ifml-1)];
if (icoul == ref) {
(*faces_list)[icpt] = ifbr;
icpt++;
}
}
}
assert(icpt == *faces);
}
/*-----------------------------------------------------------------------------
*
*----------------------------------------------------------------------------*/
int cs_gui_boundary_zone_reference_number(const char *const nature,
const char *const label)
{
int refs = 0;
char *path = NULL;
path = cs_xpath_init_path();
cs_xpath_add_elements(&path, 3, "boundary_conditions",
"boundary_definition",
nature);
cs_xpath_add_test_attribute(&path, "label", label);
cs_xpath_add_all_elements(&path);
refs = cs_gui_get_nb_element(path);
BFT_FREE(path);
return refs;
}
/*-----------------------------------------------------------------------------
*Return number of zones
*----------------------------------------------------------------------------*/
int cs_gui_boundary_zones_number(void)
{
int zones = 0;
char *path = NULL;
path = cs_xpath_init_path();
cs_xpath_add_elements(&path, 2, "boundary_conditions", "boundary_definition");
cs_xpath_add_all_elements(&path);
cs_xpath_add_attribute(&path, "label");
zones = cs_gui_get_nb_element(path);
BFT_FREE(path);
return zones;
}
/*-----------------------------------------------------------------------------
*Return the nature of boundary condition for the given zone
*----------------------------------------------------------------------------*/
char *cs_gui_boundary_zone_nature(const int ith_zone)
{
char *path = NULL;
char *nature = NULL;
path = cs_xpath_init_path();
cs_xpath_add_elements(&path, 2, "boundary_conditions", "boundary_definition");
cs_xpath_add_element_num(&path, "*", ith_zone);
nature = cs_gui_get_node_name(path);
BFT_FREE(path);
return nature;
}
/*-----------------------------------------------------------------------------
*Return the label of boundary condition for the given zone
*----------------------------------------------------------------------------*/
char *cs_gui_boundary_zone_label(const int ith_zone)
{
char *path = NULL;
char *label = NULL;
/* 1) get the label of the ith boundary zone */
path = cs_xpath_init_path();
cs_xpath_add_elements(&path, 2, "boundary_conditions", "boundary_definition");
cs_xpath_add_element_num(&path, "*", ith_zone);
cs_xpath_add_attribute(&path, "label");
label = cs_gui_get_attribute_value(path);
BFT_FREE(path);
return label;
}
/*============================================================================
* Fortran API public functions
*============================================================================*/
/*----------------------------------------------------------------------------
* Turbulence model.
*
* Fortran Interface:
*
* SUBROUTINE CSTURB (ITURB, IDEUCH, IGRAKE, IGRAKI)
* *****************
*
* INTEGER ITURB <-- turbulence model
* INTEGER IDEUCH <-- wall law treatment
* INTEGER IGRAKE <-- k-eps gravity effects
* INTEGER IGRAKI <-- Rij-eps gravity effects
*----------------------------------------------------------------------------*/
void CS_PROCF (csturb, CSTURB) (int *const iturb,
int *const ideuch,
int *const igrake,
int *const igrari)
{
char *model = NULL;
int iphas = 0;
model = cs_gui_get_thermophysical_model("turbulence");
if (model == NULL) return;
if (cs_gui_strcmp(model, "off"))
iturb[iphas] = 0;
else if (cs_gui_strcmp(model, "mixing_length")){
iturb[iphas] = 10;
}
else if (cs_gui_strcmp(model, "k-epsilon")){
iturb[iphas] = 20;
cs_gui_advanced_options_turbulence("scale_model", &ideuch[iphas]);
cs_gui_advanced_options_turbulence("gravity_terms", &igrake[iphas]);
}
else if (cs_gui_strcmp(model, "k-epsilon-PL")){
iturb[iphas] = 21;
cs_gui_advanced_options_turbulence("scale_model", &ideuch[iphas]);
cs_gui_advanced_options_turbulence("gravity_terms", &igrake[iphas]);
}
else if (cs_gui_strcmp(model, "Rij-epsilon")){
iturb[iphas] = 30;
cs_gui_advanced_options_turbulence("scale_model", &ideuch[iphas]);
cs_gui_advanced_options_turbulence("gravity_terms", &igrari[iphas]);
}
else if (cs_gui_strcmp(model, "Rij-SSG")){
iturb[iphas] = 31;
cs_gui_advanced_options_turbulence("scale_model", &ideuch[iphas]);
cs_gui_advanced_options_turbulence("gravity_terms", &igrari[iphas]);
}
else if (cs_gui_strcmp(model, "LES_Smagorinsky")){
iturb[iphas] = 40;
}
else if (cs_gui_strcmp(model, "LES_dynamique")){
iturb[iphas] = 41;
}
else if (cs_gui_strcmp(model, "v2f-phi")){
iturb[iphas] = 50;
cs_gui_advanced_options_turbulence("scale_model", &ideuch[iphas]);
cs_gui_advanced_options_turbulence("gravity_terms", &igrake[iphas]);
}
else if (cs_gui_strcmp(model, "k-omega-SST")){
iturb[iphas] = 60;
cs_gui_advanced_options_turbulence("scale_model", &ideuch[iphas]);
cs_gui_advanced_options_turbulence("gravity_terms", &igrake[iphas]);
}
else
bft_error(__FILE__, __LINE__, 0,
_("Invalid turbulence model: %s.\n"), model);
#if _XML_DEBUG_
bft_printf(_("==>CSTURB\n"));
bft_printf(_("--model: %s\n"), model);
bft_printf(_("--iturb = %i\n"), iturb[iphas]);
bft_printf(_("--igrake = %i\n"), igrake[iphas]);
bft_printf(_("--igrari = %i\n"), igrari[iphas]);
bft_printf(_("--ideuch = %i\n"), ideuch[iphas]);
#endif
BFT_FREE(model);
return;
}
/*----------------------------------------------------------------------------
* Specific heat variable or constant indicator.
*
* Fortran Interface:
*
* SUBROUTINE CSCPVA (ICP)
* *****************
*
* INTEGER ICP <-- specific heat variable or constant indicator
*----------------------------------------------------------------------------*/
void CS_PROCF (cscpva, CSCPVA) (int *const icp)
{
int choice;
int iphas = 0;
if (cs_gui_properties_choice("specific_heat", &choice)) icp[iphas] = choice;
#if _XML_DEBUG_
bft_printf(_("==>CSCPVA\n"));
bft_printf(_("--icp = %i\n"), icp[iphas]);
#endif
}
/*----------------------------------------------------------------------------
* Compte du nombre de scalaires utilisateur
*----------------------------------------------------------------------------*/
void CS_PROCF (csnsca, CSNSCA)
(
int *const nscaus
)
{
int nbt = 0;
int nb = 0;
int n = 0;
char *label = NULL;
/* Etape 1 : Eventuelle récupération du scalaire thermique */
if (cs_gui_thermal_scalar()) nbt++ ;
/* Etape 2 : Récupération du nombre de scalaires utilisateur non thermique */
nb = cs_gui_get_number_user_scalar();
*nscaus = nb + nbt;
BFT_MALLOC(vars, 1, cs_var_t);
vars->nscaus = *nscaus;
BFT_MALLOC(vars->label, *nscaus, char*);
/* Si scalaire thermique, il est mis en premiere position. */
if (nbt != 0) {
label = cs_gui_get_thermal_scalar_label("thermal_scalar");
BFT_MALLOC(vars->label[0], strlen(label)+1, char);
strcpy(vars->label[0], label);
BFT_FREE(label);
}
for (n=0; n<nb; n++) {
label = cs_gui_scalar_label("additional_scalars", n+1);
BFT_MALLOC(vars->label[n+nbt], strlen(label)+1, char);
strcpy(vars->label[n+nbt], label);
BFT_FREE(label);
}
#if _XML_DEBUG_
bft_printf(_("==>CSNSCA\n"));
bft_printf(_("--user scalars number: %i\n"), vars->nscaus);
for (n=0; n<*nscaus; n++)
bft_printf(_("--label of scalar[%i]: %s\n"), n, vars->label[n]);
#endif
return;
}
/*-----------------------------------------------------------------------------
* Determine le type de physique particuliere
*----------------------------------------------------------------------------*/
void CS_PROCF (csppmo, CSPPMO)
(
int *const ippmod, /* ippmod choix de la physique particuliere */
int *const icod3p, /* pointeurs */
int *const icodeq,
int *const icoebu,
int *const icobml,
int *const icolwc,
int *const icp3pl,
int *const icp3pv,
int *const icpl3c,
int *const icompf,
int *const ieljou,
int *const ielarc,
int *const ielion,
int *const indjon, /* indicateur tab enth-temp */
int *const nscapp /* nombre de scalaires */
)
{
int isactiv = 0;
char *model = NULL;
char *value = NULL;
char *label = NULL;
int n;
assert(vars != NULL);
/* init */
ippmod[*icod3p - 1] = -1;
ippmod[*icodeq - 1] = -1;
ippmod[*icoebu - 1] = -1;
ippmod[*icobml - 1] = -1;
ippmod[*icolwc - 1] = -1;
ippmod[*icp3pl - 1] = -1;
ippmod[*icp3pv - 1] = -1;
ippmod[*icpl3c - 1] = -1;
ippmod[*icompf - 1] = -1;
ippmod[*ieljou - 1] = -1;
ippmod[*ielarc - 1] = -1;
ippmod[*ielion - 1] = -1;
*indjon = 1;
*nscapp = 0;
/* cherche la physique particuliere active et donne la valeur de l'attricut model associe */
isactiv = cs_gui_get_activ_thermophysical_model(&model, &value);
if (isactiv) {
if (cs_gui_strcmp(model, "pulverized_coal")) {
if (cs_gui_strcmp(value, "coal_homo")) {
ippmod[*icp3pl - 1] = 1;
} else if (cs_gui_strcmp(value, "coal_lagr")) {
ippmod[*icpl3c - 1] = 1;
} else {
bft_error(__FILE__, __LINE__, 0,
_("Invalid coal model: %s.\n"), value);
}
}
/* si le model est actif on prend les scalaires physique particuliere */
*nscapp = cs_gui_get_number_model_scalar(model);
}
vars->nscapp = *nscapp;
if (vars->nscapp != 0) {
if (vars->nscaus > 0) {
BFT_REALLOC(vars->label, vars->nscapp+vars->nscaus + 1, char*);
} else {
BFT_MALLOC(vars->label, vars->nscapp+vars->nscaus + 1, char*);
}
for (n=vars->nscaus; n< vars->nscaus+vars->nscapp; n++) {
label = cs_gui_scalar_label(model, n - vars->nscaus + 1);
BFT_MALLOC(vars->label[n], strlen(label)+1, char);
strcpy(vars->label[n], label);
BFT_FREE(label);
}
}
BFT_FREE(model);
BFT_FREE(value);
#if _XML_DEBUG_
bft_printf(_("==>CSPPMO\n"));
bft_printf(_("--model scalars number: %i\n"), vars->nscapp);
for (n=vars->nscaus; n< vars->nscaus+vars->nscapp; n++)
bft_printf(_("--label of scalar[%i]: %s\n"), n, vars->label[n]);
#endif
}
/*----------------------------------------------------------------------------
* Initialisation du tableau relatif aux scalaires ISCAVR
*----------------------------------------------------------------------------*/
void CS_PROCF (csisca, CSISCA)
(
int *const iscavr
)
{
int i;
int j;
int ind_thermal_scalar = 0;
char *thermal_scal = NULL;
char *scalar_variance = NULL;
/* Si pas de scalaire on ne fait rien */
if (vars->nscaus == 0) return;
/* Si scalaire thermique on le met en premiere position */
thermal_scal = cs_gui_get_thermophysical_model("thermal_scalar");
if (cs_gui_strcmp(thermal_scal, "on")) {
iscavr[0] = 0;
/* scalar_name[0] = cs_gui_get_thermal_scalar_label(THERMAL_MODEL);*/
ind_thermal_scalar++;
}
BFT_FREE(thermal_scal);
/* Stockage des noms des scalaires dans scalar_name */
/* Si variance stockage du nom du scalaire dont
on calcule la variance dans scalar_variance*/
/* Ceci evite de multiplier les evaluations de requetes couteuses */
/*for (i=0 ; i < cs_gui_get_number_user_scalar() ; i++)
scalar_name[i +ind_thermal_scalar] = cs_gui_scalar_label("additional_scalars", i+1);*/
/* Double boucle pour determiner de quel scalaire la variance est calculee */
for (i=0 ; i < cs_gui_get_number_user_scalar() ; i++) {
scalar_variance = cs_gui_get_additional_scalar_variance(i+1);
for (j=0 ; j < vars->nscaus ; j++) {
/*if (cs_gui_strcmp(scalar_variance, scalar_name[j])) {*/
if (cs_gui_strcmp(scalar_variance, vars->label[j])) {
if ( (i+ind_thermal_scalar) == j ) {
bft_error(__FILE__, __LINE__, 0,
_("Scalar: %i and its variance: %i are the same.\n"), i, j);
}
iscavr[i+ind_thermal_scalar] = j +1 ;
}
}
BFT_FREE(scalar_variance);
}
#if _XML_DEBUG_
bft_printf(_("==>CSISCA\n"));
for (i = 0 ; i < vars->nscaus ; i++)
bft_printf(_("--iscavr[%i] = %i \n"), i, iscavr[i]);
#endif
return;
}
/*----------------------------------------------------------------------------
* Viscosite dynamique des scalaires utilisateurs constante ou variable
* positionnement de la variable IVISLS
*----------------------------------------------------------------------------*/
void CS_PROCF (csivis, CSIVIS)
(
int *const iscavr,
int *const ivisls,
int *const iscalt,
int *const iscsth
)
{
int iphas = 0;
int ind_thermal_scalar = 0;
int i;
int choice1, choice2;
int test1, test2;
if (vars->nscaus > 0) {
/* prise en compte le scalaire thermique pour la position dans le tableau */
if (cs_gui_thermal_scalar()) {
test1 = cs_gui_properties_choice("thermal_conductivity", &choice1);
test2 = cs_gui_properties_choice("specific_heat", &choice2);
if (test1 && test2) {
cs_gui_thermal_scalar_number(iscalt, iscsth);
if (choice1 || choice2)
ivisls[iscalt[iphas]-1] = 1;
else
ivisls[iscalt[iphas]-1] = 0;
}
ind_thermal_scalar++ ;
}
/* Scalaires utilisateurs */
for (i=0 ; i < vars->nscaus-ind_thermal_scalar; i++) {
if (iscavr[i+ind_thermal_scalar] <= 0 ) {
if (cs_gui_add_scalar_properties_choice(i+1,
"diffusion_coefficient",
&choice1))
ivisls[i+ind_thermal_scalar] = choice1;
}
}
#if _XML_DEBUG_
bft_printf(_("==>CSIVIS\n"));
for (i=0 ; i < vars->nscaus ; i++)
bft_printf(_("--ivisls[%i] = %i\n"), i, ivisls[i]);
#endif
}
}
/*----------------------------------------------------------------------------
* Time passing parameter.
*
* Fortran Interface:
*
* SUBROUTINE CSIDTV (IDTVAR)
* *****************
*
* INTEGER IDTVAR <-- fixed or variable time step
*----------------------------------------------------------------------------*/
void CS_PROCF (csidtv, CSIDTV) (int *const idtvar)
{
double param;
param = (double) *idtvar;
cs_gui_time_parameters("time_passing", ¶m);
*idtvar = (int) param;
#if _XML_DEBUG_
bft_printf(_("==>CSIDTV\n"));
bft_printf(_("--idtvar = %i\n"), *idtvar);
#endif
}
/*----------------------------------------------------------------------------
* Hydrostatic pressure parameter.
*
* Fortran Interface:
*
* SUBROUTINE CSIPHY (IPHYDR)
* *****************
*
* INTEGER IPHYDR <-- hydrostatic pressure
*----------------------------------------------------------------------------*/
void CS_PROCF (csiphy, CSIPHY) (int *const iphydr)
{
char *path = NULL;
int result;
path = cs_xpath_short_path();
cs_xpath_add_element(&path, "hydrostatic_pressure");
cs_xpath_add_attribute(&path, "status");
if(cs_gui_get_status(path, &result)) *iphydr = result;
BFT_FREE(path);
#if _XML_DEBUG_
bft_printf(_("==>CSIPHY\n"));
bft_printf(_("--iphydr = %i\n"), *iphydr);
#endif
}
/*-----------------------------------------------------------------------------
* Remplace l'ancien cs_gui_variable_number qui crée les tableaux :
* vars->rtp_ptr, vars->rtp_nbr, et vars->name2
* Est appele juste apres le 3eme appel a VARPOS
*----------------------------------------------------------------------------*/
void CS_PROCF (csvnum, CSVNUM)
(
const int *const nvarmx,
const int *const nvar,
const int *const iu,
const int *const iv,
const int *const iw,
const int *const ipr,
const int *const iturb,
const int *const ik,
const int *const iep,
const int *const ir11,
const int *const ir22,
const int *const ir33,
const int *const ir12,
const int *const ir13,
const int *const ir23,
const int *const iomg,
const int *const iphi,
const int *const ifb,
const int *const isca
)
{
int iphas = 0;
int nbr = 0;
int nm = 0;
int num2 = 0;
int i;
BFT_MALLOC(vars->rtp_ptr, *nvarmx, int);
BFT_MALLOC(vars->rtp_nbr, *nvar, int);
BFT_MALLOC(vars->name2, *nvar, int);
BFT_MALLOC(vars->char2, *nvar, char*);
/* ATTENTION !! vars->nscaus est rempli dans CSNSCA */
/* vars->label est rempli dans CSNSCA */
/* vars->nscapp sera rempli après USPPMO */
vars->nvar = *nvar;
/*vars->nscapp = *nscapp; */
/* provisoire */
vars->rtp_ptr[PRESSURE] = ipr[iphas] -1;
vars->rtp_ptr[VELOCITY_U] = iu[iphas] -1;
vars->rtp_ptr[VELOCITY_V] = iv[iphas] -1;
vars->rtp_ptr[VELOCITY_W] = iw[iphas] -1;
vars->rtp_nbr[nbr++] = ipr[iphas] -1;
vars->rtp_nbr[nbr++] = iu[iphas] -1;
vars->rtp_nbr[nbr++] = iv[iphas] -1;
vars->rtp_nbr[nbr++] = iw[iphas] -1;
vars->name2[num2++] = PRESSURE;
vars->name2[num2++] = VELOCITY_U;
vars->name2[num2++] = VELOCITY_V;
vars->name2[num2++] = VELOCITY_W;
BFT_MALLOC(vars->char2[nm], strlen("pressure")+1, char);
strcpy(vars->char2[nm], "pressure");
nm++;
BFT_MALLOC(vars->char2[nm], strlen("velocity_U")+1, char);
strcpy(vars->char2[nm], "velocity_U");
nm++;
BFT_MALLOC(vars->char2[nm], strlen("velocity_V")+1, char);
strcpy(vars->char2[nm], "velocity_V");
nm++;
BFT_MALLOC(vars->char2[nm], strlen("velocity_W")+1, char);
strcpy(vars->char2[nm], "velocity_W");
nm++;
if (iturb[iphas] == 20 || iturb[iphas] == 21) {
vars->rtp_ptr[TURB_K] = ik[iphas] -1;
vars->rtp_ptr[TURB_EPS] = iep[iphas] -1;
vars->rtp_nbr[nbr++] = ik[iphas] -1;
vars->rtp_nbr[nbr++] = iep[iphas] -1;
vars->name2[num2++] = TURB_K;
vars->name2[num2++] = TURB_EPS;
BFT_MALLOC(vars->char2[nm], strlen("turb_k")+1, char);
strcpy(vars->char2[nm], "turb_k");
nm++;
BFT_MALLOC(vars->char2[nm], strlen("turb_eps")+1, char);
strcpy(vars->char2[nm], "turb_eps");
nm++;
} else if (iturb[iphas] == 30 || iturb[iphas] == 31) {
vars->rtp_ptr[R11] = ir11[iphas] -1;
vars->rtp_ptr[R22] = ir22[iphas] -1;
vars->rtp_ptr[R33] = ir33[iphas] -1;
vars->rtp_ptr[R12] = ir12[iphas] -1;
vars->rtp_ptr[R13] = ir13[iphas] -1;
vars->rtp_ptr[R23] = ir23[iphas] -1;
vars->rtp_ptr[TURB_EPS] = iep[iphas] -1;
vars->rtp_nbr[nbr++] = ir11[iphas] -1;
vars->rtp_nbr[nbr++] = ir22[iphas] -1;
vars->rtp_nbr[nbr++] = ir33[iphas] -1;
vars->rtp_nbr[nbr++] = ir12[iphas] -1;
vars->rtp_nbr[nbr++] = ir13[iphas] -1;
vars->rtp_nbr[nbr++] = ir23[iphas] -1;
vars->rtp_nbr[nbr++] = iep[iphas] -1;
vars->name2[num2++] = R11;
vars->name2[num2++] = R22;
vars->name2[num2++] = R33;
vars->name2[num2++] = R12;
vars->name2[num2++] = R13;
vars->name2[num2++] = R23;
vars->name2[num2++] = TURB_EPS;
BFT_MALLOC(vars->char2[nm], strlen("component_R11")+1, char);
strcpy(vars->char2[nm], "component_R11");
nm++;
BFT_MALLOC(vars->char2[nm], strlen("component_R22")+1, char);
strcpy(vars->char2[nm], "component_R22");
nm++;
BFT_MALLOC(vars->char2[nm], strlen("component_R33")+1, char);
strcpy(vars->char2[nm], "component_R33");
nm++;
BFT_MALLOC(vars->char2[nm], strlen("component_R12")+1, char);
strcpy(vars->char2[nm], "component_R12");
nm++;
BFT_MALLOC(vars->char2[nm], strlen("component_R13")+1, char);
strcpy(vars->char2[nm], "component_R13");
nm++;
BFT_MALLOC(vars->char2[nm], strlen("component_R23")+1, char);
strcpy(vars->char2[nm], "component_R23");
nm++;
BFT_MALLOC(vars->char2[nm], strlen("turb_eps")+1, char);
strcpy(vars->char2[nm], "turb_eps");
nm++;
} else if (iturb[iphas] == 50) {
vars->rtp_ptr[TURB_K] = ik[iphas] -1;
vars->rtp_ptr[TURB_EPS] = iep[iphas] -1;
vars->rtp_ptr[TURB_PHI] = iphi[iphas] -1;
vars->rtp_ptr[TURB_FB] = ifb[iphas] -1;
vars->rtp_nbr[nbr++] = ik[iphas] -1;
vars->rtp_nbr[nbr++] = iep[iphas] -1;
vars->rtp_nbr[nbr++] = iphi[iphas] -1;
vars->rtp_nbr[nbr++] = ifb[iphas] -1;
vars->name2[num2++] = TURB_K;
vars->name2[num2++] = TURB_EPS;
vars->name2[num2++] = TURB_PHI;
vars->name2[num2++] = TURB_FB;
BFT_MALLOC(vars->char2[nm], strlen("turb_k")+1, char);
strcpy(vars->char2[nm], "turb_k");
nm++;
BFT_MALLOC(vars->char2[nm], strlen("turb_eps")+1, char);
strcpy(vars->char2[nm], "turb_eps");
nm++;
BFT_MALLOC(vars->char2[nm], strlen("turb_phi")+1, char);
strcpy(vars->char2[nm], "turb_phi");
nm++;
BFT_MALLOC(vars->char2[nm], strlen("turb_fb")+1, char);
strcpy(vars->char2[nm], "turb_fb");
nm++;
} else if (iturb[iphas] == 60) {
vars->rtp_ptr[TURB_K] = ik[iphas] -1;
vars->rtp_ptr[TURB_OMEGA] = iomg[iphas] -1;
vars->rtp_nbr[nbr++] = ik[iphas] -1;
vars->rtp_nbr[nbr++] = iomg[iphas] -1;
vars->name2[num2++] = TURB_K;
vars->name2[num2++] = TURB_OMEGA;
BFT_MALLOC(vars->char2[nm], strlen("turb_k")+1, char);
strcpy(vars->char2[nm], "turb_k");
nm++;
BFT_MALLOC(vars->char2[nm], strlen("turb_omega")+1, char);
strcpy(vars->char2[nm], "turb_omega");
nm++;
}
for (i=0 ; i<(vars->nscaus + vars->nscapp) ; i++)
vars->rtp_nbr[nbr++] = isca[i] -1;
if (nbr != *nvar)
bft_error(__FILE__, __LINE__, 0,
_("The kernel variables number %i and the "
"calculated one by the reader %i are not the same.\n"),
*nvar, nbr);
#if _XML_DEBUG_
bft_printf(_("==>CSVNUM\n"));
for (i=0 ; i<(vars->nvar - vars->nscapp - vars->nscaus) ; i++)
bft_printf(_("--variables: %s\n"), vars->char2[i]);
for (i=0 ; i<(vars->nscapp + vars->nscaus) ; i++)
bft_printf(_("--scalars: %s\n"), vars->label[i]);
#endif
}
/*----------------------------------------------------------------------------
* Restart files format.
*
* Fortran Interface:
*
* SUBROUTINE CSIFOA (IFOAVA, IFOAVX)
* *****************
*
* INTEGER IFOAVA <-- main restart file format
* INTEGER IFOAVX <-- auxiliary restart file format
*----------------------------------------------------------------------------*/
void CS_PROCF (csifoa, CSIFOA) (int *const ifoava,
int *const ifoavx)
{
cs_gui_restart_parameters_file_format("main_restart", ifoava);
cs_gui_restart_parameters_file_format("auxiliary_restart", ifoavx);
#if _XML_DEBUG_
bft_printf(_("==>CSIFOA\n"));
bft_printf(_("--ifoava = %i\n"), *ifoava);
bft_printf(_("--ifoavx = %i\n"), *ifoavx);
#endif
}
/*----------------------------------------------------------------------------
* Restart parameters.
*
* Fortran Interface:
*
* SUBROUTINE CSISUI (ISUITE, ILEAUX, ICCVFG)
* *****************
*
* INTEGER ISUITE <-- restart
* INTEGER ILEAUX <-- restart with auxiliary
* INTEGER ICCFVG <-- restart with frozen field
*----------------------------------------------------------------------------*/
void CS_PROCF (csisui, CSISUI) (int *const isuite,
int *const ileaux,
int *const iccvfg)
{
cs_gui_restart_parameters_status("restart", isuite);
cs_gui_restart_parameters_status("restart_with_auxiliary", ileaux);
cs_gui_restart_parameters_status("frozen_field", iccvfg);
#if _XML_DEBUG_
bft_printf(_("==>CSISUI\n"));
bft_printf(_("--isuite = %i\n"), *isuite);
bft_printf(_("--ileaux = %i\n"), *ileaux);
bft_printf(_("--iccvfg = %i\n"), *iccvfg);
#endif
}
/*----------------------------------------------------------------------------
* Time passing parameters.
*
* Fortran Interface:
*
* SUBROUTINE CSTIME (INPDT0, IPTLTO, NTMABS, DTREF,
* ***************** DTMIN, DTMAX, COUMAX, FOUMAX, VARRDT)
*
* INTEGER INPDT0 <-- zero time step
* INTEGER IPTLTO <-- thermal time step control
* INTEGER NTMABS <-- iterations numbers
* DOUBLE PRECISION DTREF <-- time step
* DOUBLE PRECISION DTMIN <-- minimal time step
* DOUBLE PRECISION DTMAX <-- maximal time step
* DOUBLE PRECISION COUMAX <-- maximal courant number
* DOUBLE PRECISION FOUMAX <-- maximal fournier number
* DOUBLE PRECISION VARRDT <-- max time step variation between 2 iterations
*----------------------------------------------------------------------------*/
void CS_PROCF (cstime, CSTIME) (int *const inpdt0,
int *const iptlro,
int *const ntmabs,
double *const dtref,
double *const dtmin,
double *const dtmax,
double *const coumax,
double *const foumax,
double *const varrdt)
{
double value;
cs_gui_time_parameters("time_step_ref", dtref);
cs_gui_time_parameters("time_step_min", dtmin);
cs_gui_time_parameters("time_step_max", dtmax);
cs_gui_time_parameters("max_courant_num", coumax);
cs_gui_time_parameters("max_fourier_num", foumax);
cs_gui_time_parameters("time_step_var", varrdt);
value =(double) *ntmabs;
cs_gui_time_parameters("iterations", &value);
*ntmabs = (int) value;
value =(double) *inpdt0;
cs_gui_time_parameters("zero_time_step", &value);
*inpdt0 = (int) value;
value =(double) *iptlro;
cs_gui_time_parameters("thermal_time_step", &value);
*iptlro = (int) value;
#if _XML_DEBUG_
bft_printf(_("==>CSTIME\n"));
bft_printf(_("--inpdt0 = %i\n"), *inpdt0);
bft_printf(_("--iptlro = %i\n"), *iptlro);
bft_printf(_("--ntmabs = %i\n"), *ntmabs);
bft_printf(_("--dtref = %f\n"), *dtref);
bft_printf(_("--dtmin = %f\n"), *dtmin);
bft_printf(_("--dtmax = %f\n"), *dtmax);
bft_printf(_("--coumax = %f\n"), *coumax);
bft_printf(_("--foumax = %f\n"), *foumax);
bft_printf(_("--varrdt = %f\n"), *varrdt);
#endif
}
/*----------------------------------------------------------------------------
* Traitement des tableaux ISCSTH et ISCLAT lies aux scalaires
*----------------------------------------------------------------------------*/
void CS_PROCF (cssca1, CSSCA1)
(
int *const iscalt,
int *const iscsth
)
{
#if _XML_DEBUG_
int i;
int iphas = 0;
#endif
cs_gui_thermal_scalar_number(iscalt, iscsth);
#if _XML_DEBUG_
bft_printf(_("==>CSSCA1\n"));
bft_printf(_("--iscalt[0]=%i \n"), iscalt[iphas]);
for (i = 0 ; i < vars->nscaus ; i++)
bft_printf(_("--iscsth[%i]=%i \n"), i, iscsth[i]);
#endif
}
/*----------------------------------------------------------------------------
* Traitement des aspects numeriques locaux :
* BLENCV, ISCHCV, ISSTPC, IRCFLU, CDTVAR, NITMAX, EPSILO
*----------------------------------------------------------------------------*/
void CS_PROCF (csnum1, CSNUM1)
(
const int *const isca,
double *const blencv,
int *const ischcv,
int *const isstpc,
int *const ircflu,
double *const cdtvar,
int *const nitmax,
double *const epsilo
)
{
int ind_thermal_scalar = 0;
int i;
double temp;
char *model = NULL;
char *modelvalue = NULL;
/* Variables de velocity pressure et de la turbulence */
for (i=1; i < vars->nvar - vars->nscaus - vars->nscapp; i++){
cs_gui_variable_value(vars->char2[i],
"blending_factor",
&blencv[vars->rtp_nbr[i]]);
cs_gui_variable_value(vars->char2[i],
"solveur_precision",
&epsilo[vars->rtp_nbr[i]]);
temp = (double) nitmax[vars->rtp_nbr[i]];
cs_gui_variable_value(vars->char2[i],
"max_iter_number",
&temp);
nitmax[vars->rtp_nbr[i]] = (int) temp;
cs_gui_variable_status(vars->char2[i],
"order_scheme",
&ischcv[vars->rtp_nbr[i]]);
cs_gui_variable_status(vars->char2[i],
"slope_test",
&isstpc[vars->rtp_nbr[i]]);
cs_gui_variable_status(vars->char2[i],
"flux_reconstruction",
&ircflu[vars->rtp_nbr[i]]);
}
/* Scalaires */
/* Scalaires utilisateurs */
if (vars->nscaus > 0 ) {
/* Scalaire thermique */
if (cs_gui_thermal_scalar()) {
ind_thermal_scalar++ ;
i = isca[0]-1;
cs_gui_thermal_scalar_value("thermal_scalar", "blending_factor", &blencv[i]);
cs_gui_thermal_scalar_value("thermal_scalar", "solveur_precision", &epsilo[i]);
cs_gui_thermal_scalar_value("thermal_scalar", "time_step_factor", &cdtvar[i]);
temp = (double) nitmax[i];
cs_gui_thermal_scalar_value("thermal_scalar", "max_iter_number", &temp);
nitmax[i] = (int) temp;
cs_gui_thermal_scalar_output_status("thermal_scalar", "order_scheme", &ischcv[i]);
cs_gui_thermal_scalar_output_status("thermal_scalar", "slope_test", &isstpc[i]);
cs_gui_thermal_scalar_output_status("thermal_scalar", "flux_reconstruction", &ircflu[i]);
}
/* Scalaires utilisateurs */
for (i=0 ; i < vars->nscaus - ind_thermal_scalar; i++) {
cs_gui_scalar_value(vars->label[i+ind_thermal_scalar],
"blending_factor",
&blencv[isca[i+ind_thermal_scalar]-1]);
cs_gui_scalar_value(vars->label[i+ind_thermal_scalar],
"solveur_precision",
&epsilo[isca[i+ind_thermal_scalar]-1]);
cs_gui_scalar_value(vars->label[i+ind_thermal_scalar],
"time_step_factor",
&cdtvar[isca[i+ind_thermal_scalar]-1]);
temp = (double) nitmax[isca[i+ind_thermal_scalar]-1];
cs_gui_scalar_value(vars->label[i+ind_thermal_scalar],
"max_iter_number",
&temp);
nitmax[isca[i+ind_thermal_scalar]-1] = (int) temp;
cs_gui_scalar_attribute(vars->label[i+ind_thermal_scalar],
"order_scheme",
&ischcv[isca[i+ind_thermal_scalar]-1]);
cs_gui_scalar_attribute(vars->label[i+ind_thermal_scalar],
"slope_test",
&isstpc[isca[i+ind_thermal_scalar]-1]);
cs_gui_scalar_attribute(vars->label[i+ind_thermal_scalar],
"flux_reconstruction",
&ircflu[isca[i+ind_thermal_scalar]-1]);
}
}
if (cs_gui_get_activ_thermophysical_model(&model, &modelvalue)) {
if (vars->nscapp > 0 ) {
for (i=vars->nscaus ; i < vars->nscaus + vars->nscapp ; i++) {
cs_gui_model_scalar_value(model, vars->XMLnumsca[i] - vars->nscaus + 1,
BLENDING_FACTOR, &blencv[isca[i]-1]);
cs_gui_model_scalar_value(model, vars->XMLnumsca[i] - vars->nscaus + 1,
SOLVEUR_PRECISION, &epsilo[isca[i]-1]);
cs_gui_model_scalar_value(model, vars->XMLnumsca[i] - vars->nscaus + 1,
TIME_STEP_FACTOR, &cdtvar[isca[i]-1]);
temp = (double) nitmax[isca[i]-1];
cs_gui_model_scalar_value(model, vars->XMLnumsca[i] - vars->nscaus + 1,
MAX_ITER_NUMBER, &temp);
nitmax[isca[i]-1] = (int) temp;
cs_gui_model_scalar_output_status(model, vars->XMLnumsca[i] - vars->nscaus + 1,
ORDER_SCHEME, &ischcv[isca[i]-1]);
cs_gui_model_scalar_output_status(model, vars->XMLnumsca[i] - vars->nscaus + 1,
SLOPE_TEST, &isstpc[isca[i]-1]);
cs_gui_model_scalar_output_status(model, vars->XMLnumsca[i] - vars->nscaus + 1,
FLUX_RECONSTRUCTION, &ircflu[isca[i]-1]);
}
}
}
BFT_FREE(model);
BFT_FREE(modelvalue);
#if _XML_DEBUG_
bft_printf(_("==>CSNUM1\n"));
for (i=0; i < vars->nvar - vars->nscaus - vars->nscapp; i++){
bft_printf(_("-->variable[%i] = %s\n"), i, vars->char2[i]);
bft_printf(_("--blencv = %f\n"), blencv[vars->rtp_nbr[i]]);
bft_printf(_("--epsilo = %g\n"), epsilo[vars->rtp_nbr[i]]);
bft_printf(_("--cdtvar = %g\n"), cdtvar[vars->rtp_nbr[i]]);
bft_printf(_("--nitmax = %i\n"), nitmax[vars->rtp_nbr[i]]);
bft_printf(_("--ischcv = %i\n"), ischcv[vars->rtp_nbr[i]]);
bft_printf(_("--isstpc = %i\n"), isstpc[vars->rtp_nbr[i]]);
bft_printf(_("--ircflu = %i\n"), ircflu[vars->rtp_nbr[i]]);
}
for (i=0 ; i < vars->nscaus + vars->nscapp ; i++) {
bft_printf(_("-->scalar[%i]: %s\n"), isca[i]-1, vars->label[i]);
bft_printf(_("--blencv = %f\n"), blencv[isca[i]-1]);
bft_printf(_("--epsilo = %g\n"), epsilo[isca[i]-1]);
bft_printf(_("--cdtvar = %g\n"), cdtvar[isca[i]-1]);
bft_printf(_("--nitmax = %i\n"), nitmax[isca[i]-1]);
bft_printf(_("--ischvc = %i\n"), ischcv[isca[i]-1]);
bft_printf(_("--isstpc = %i\n"), isstpc[isca[i]-1]);
bft_printf(_("--ircflu = %i\n"), ircflu[isca[i]-1]);
}
#endif
}
/*----------------------------------------------------------------------------
* Global numerical parameters.
*
* Fortran Interface:
*
* SUBROUTINE CSNUM2 (IVISSE, RELAXP, IPUCOU, EXTRAG, IMRGRA)
* *****************
*
* INTEGER IVISSE <-- gradient transpose
* DOUBLE PRECISION RELAXP <-- pressure relaxation
* INTEGER IPUCOU <-- velocity pressure coupling
* DOUBLE PRECISION EXTRAG <-- wall pressure extrapolation
* INTEGER IMRGRA <-- gradient reconstruction
*----------------------------------------------------------------------------*/
void CS_PROCF (csnum2, CSNUM2)( int *const ivisse,
double *const relaxp,
int *const ipucou,
double *const extrag,
int *const imrgra)
{
cs_gui_numerical_int_parameters("gradient_transpose", ivisse);
cs_gui_numerical_int_parameters("velocity_pressure_coupling", ipucou);
cs_gui_numerical_int_parameters("gradient_reconstruction", imrgra);
cs_gui_numerical_double_parameters("wall_pressure_extrapolation", extrag);
cs_gui_numerical_double_parameters("pressure_relaxation", relaxp);
#if _XML_DEBUG_
bft_printf(_("==>CSNUM2\n"));
bft_printf(_("--ivisse = %i\n"), *ivisse);
bft_printf(_("--ipucou = %i\n"), *ipucou);
bft_printf(_("--imrgra = %i\n"), *imrgra);
bft_printf(_("--extrag = %f\n"), *extrag);
bft_printf(_("--relaxp = %f\n"), *relaxp);
#endif
}
/*----------------------------------------------------------------------------
* Traitement de la gravite et des proprietes physiques du fluide
*----------------------------------------------------------------------------*/
void CS_PROCF (csphys, CSPHYS)
(
const int *const nmodpp,
int *const irovar,
int *const ivivar,
double *const gx,
double *const gy,
double *const gz,
double *const ro0,
double *const viscl0,
double *const cp0,
double *const t0,
double *const p0
)
{
int iphas = 0;
int choice;
char *model = NULL;
char *modelvalue = NULL;
double value;
cs_gui_gravity_value("gravity_x", gx);
cs_gui_gravity_value("gravity_y", gy);
cs_gui_gravity_value("gravity_z", gz);
cs_gui_properties_value("density", &ro0[iphas]);
cs_gui_properties_value("molecular_viscosity", &viscl0[iphas]);
cs_gui_properties_value("specific_heat", &cp0[iphas]);
cs_gui_reference_pressure(p0);
/* rho et viscl variables */
if (*nmodpp == 0) {
if (cs_gui_properties_choice("density", &choice))
irovar[iphas] = choice;
if (cs_gui_properties_choice("molecular_viscosity", &choice))
ivivar[iphas] = choice;
}
/* P0 T0 si nécessaire */
if (cs_gui_get_activ_thermophysical_model(&model, &modelvalue)) {
if (cs_gui_get_combustion_initial_value(model, COMBTEMPERATURE, &value)) {
*t0 = value;
}
}
/*if (cs_gui_get_combustion_initial_value(model, COMBPRESSURE, &value)) {
*p0 = value;*/
BFT_FREE(model);
BFT_FREE(modelvalue);
#if _XML_DEBUG_
bft_printf(_("==>CSPHYS\n"));
bft_printf(_("--gx = %f \n"),*gx);
bft_printf(_("--gy = %f \n"),*gy);
bft_printf(_("--gz = %f \n"),*gz);
bft_printf(_("--rho = %g , variable %i\n"), ro0[iphas], irovar[iphas]);
bft_printf(_("--mu = %g , variable %i \n"), viscl0[iphas], ivivar[iphas]);
bft_printf(_("--Cp = %g \n"), cp0[0]);
bft_printf(_("--T0 = %f \n"), *t0);
bft_printf(_("--P0 = %f \n"), *p0);
#endif
}
/*----------------------------------------------------------------------------
* Lecture des valeuurs MIN et MAX des scalaires
*----------------------------------------------------------------------------*/
void CS_PROCF (cssca2, CSSCA2)
(
const int *const iscavr,
double *const scamin,
double *const scamax
)
{
int ind_thermal_scalar = 0;
int i;
if (vars->nscaus > 0 ) {
/* scalaire thermique */
if (cs_gui_thermal_scalar()) {
ind_thermal_scalar++ ;
cs_gui_thermal_scalar_value("thermal_scalar", "min_value", &scamin[0]);
cs_gui_thermal_scalar_value("thermal_scalar", "max_value", &scamax[0]);
}
/* Scalaires utilisateurs */
for (i=0 ; i < vars->nscaus-ind_thermal_scalar; i++) {
if (iscavr[i+ind_thermal_scalar] <= 0 ) {
cs_gui_scalar_value(vars->label[i+ind_thermal_scalar],
"min_value",
&scamin[i+ind_thermal_scalar]);
cs_gui_scalar_value(vars->label[i+ind_thermal_scalar],
"max_value",
&scamax[i+ind_thermal_scalar]);
}
}
#if _XML_DEBUG_
bft_printf(_("==>CSSCA2\n"));
for (i=0 ; i < vars->nscaus ; i++) {
bft_printf(_("--scamin[%i] = %f\n"), i, scamin[i]);
bft_printf(_("--scamax[%i] = %f\n"), i, scamax[i]);
}
#endif
}
}
/*----------------------------------------------------------------------------
* Lecture de la viscosite dynamique de reference des scalaires utilisateurs
*----------------------------------------------------------------------------*/
void CS_PROCF (cssca3, CSSCA3)
(
const int *const iscavr,
double *const visls0
)
{
int ind_thermal_scalar=0;
int i;
double result, coeff;
if (vars->nscaus > 0 ) {
/* prise en compte le scalaire thermique pour la position dans le tableau */
/* et pour le calcul de son coefficient de diffusion qui est egal à : */
/* conductivite thermique du fluide divisé par la chaleur massique : */
/* du fluide */
if (cs_gui_thermal_scalar()){
result = 0;
cs_gui_properties_value("specific_heat", &result);
if (!result) {
bft_error(__FILE__, __LINE__, 0,
_("Specific heat value is zero or not found in the xml file.\n"));
}
cs_gui_properties_value("thermal_conductivity", &visls0[0]);
visls0[0] = visls0[0]/result;
ind_thermal_scalar++ ;
}
/* Scalaires utilisateurs */
/* Dans l'interface, l'utilisateur donne le coefficient de diffusion, alors */
/* que dans Saturne on parle de la diffusivite, donc il faut multiplier */
/* ce coefficient par la masse volumique pour etre cohérent */
for (i=0 ; i < vars->nscaus-ind_thermal_scalar; i++) {
if (iscavr[i+ind_thermal_scalar] <= 0 ) {
result = 0;
cs_gui_properties_value("density", &result);
if (!result) {
bft_error(__FILE__, __LINE__, 0,
_("Density value is zero or not found in the xml file.\n"));
}
coeff = visls0[i+ind_thermal_scalar] / result ;
cs_gui_add_scalar_diffusion_coeff_value(i+1,
DIFFUSION_COEFFICIENT,
INITIAL,
&coeff);
visls0[i+ind_thermal_scalar] = coeff * result;
}
}
#if _XML_DEBUG_
bft_printf(_("==>CSSCA3\n"));
for (i=0 ; i < vars->nscaus-ind_thermal_scalar ; i++)
bft_printf(_("--visls0[%i] = %f\n"), i, visls0[i]);
#endif
}
}
/*----------------------------------------------------------------------------
* Turbulence initialization parameters.
*
* Fortran Interface:
*
* SUBROUTINE CSTINI (UREF, ALMAX)
* *****************
*
* INTEGER UREF <-- reference velocity
* INTEGER ALMAX <-- reference length
*----------------------------------------------------------------------------*/
void CS_PROCF (cstini, CSTINI) (double *const uref,
double *const almax)
{
int iphas = 0;
char* turb_ini_choice = NULL;
cs_gui_turbulence_initialization("reference_velocity", &uref[iphas]);
turb_ini_choice = cs_gui_turbulence_initialization_choice();
if (cs_gui_strcmp(turb_ini_choice, "reference_velocity_length"))
cs_gui_turbulence_initialization("reference_length", &almax[iphas]);
BFT_FREE(turb_ini_choice);
#if _XML_DEBUG_
bft_printf(_("==>CSTINI\n"));
bft_printf(_("--almax = %f\n"), almax[iphas]);
bft_printf(_("--uref = %f\n"), uref[iphas]);
#endif
}
/*----------------------------------------------------------------------------
* Traitement des entrees-sorties
*----------------------------------------------------------------------------*/
void CS_PROCF (csenso, CSENSO)
(
const int *const nvppmx,
int *const ncapt,
int *const nthist,
int *const ntlist,
int *const ichrvl,
int *const ichrbo,
int *const ichrsy,
char *const fmtchr,
int *const size_fmt,
char *const optchr,
int *const size_opt,
int *const ntchr,
int *const iecaux,
const int *const icp,
const int *const irom,
const int *const iviscl,
const int *const ivisct,
const int *const icour,
const int *const ifour,
const int *const ismago,
const int *const iprtot,
int *const ichrvr,
int *const ilisvr,
int *const ihisvr,
const int *const isca,
const int *const ipprtp,
const int *const ipppro,
const int *const ipproc,
const int *const ipptx,
const int *const ippty,
const int *const ipptz,
const int *const ippdt,
double *const xyzcap)
{
int iphas = 0;
int ind_thermal_scalar = 0;
int i, j;
int ipp;
char *model = NULL;
char *modelvalue = NULL;
const char *const _cs_properties_name[12] = {
"density",
"molecular_viscosity",
"turb_viscosity",
"courant_number",
"fourier_number",
"smagorinsky_constant",
"specific_heat",
"weight_matrix_X",
"weight_matrix_Y",
"weight_matrix_Z",
"local_time_step",
"total_pressure" };
int _cs_properties_ipp[12] ;
_cs_properties_ipp[0]=ipppro[ ipproc[ irom[iphas]-1 ]-1 ];
_cs_properties_ipp[1]=ipppro[ ipproc[ iviscl[iphas]-1 ]-1 ];
_cs_properties_ipp[2]=ipppro[ ipproc[ ivisct[iphas]-1 ]-1 ];
_cs_properties_ipp[3]=ipppro[ ipproc[ icour[iphas]-1 ]-1 ];
_cs_properties_ipp[4]=ipppro[ ipproc[ ifour[iphas]-1 ]-1 ];
if (ismago[iphas] != -1 )
_cs_properties_ipp[5]=ipppro[ ipproc[ ismago[iphas]-1 ]-1 ];
else
_cs_properties_ipp[5]=1;
if (icp[iphas]>0)
_cs_properties_ipp[6]=ipppro[ ipproc[ icp[iphas]-1 ]-1 ];
else
_cs_properties_ipp[6]=1;
_cs_properties_ipp[7]=*ipptx;
_cs_properties_ipp[8]=*ippty;
_cs_properties_ipp[9]=*ipptz;
_cs_properties_ipp[10]=*ippdt;
_cs_properties_ipp[11]=ipppro[ ipproc[ iprtot[iphas]-1 ]-1 ];
cs_gui_output_value("fuild_domain", ichrvl);
cs_gui_output_value("domain_boundary", ichrbo);
cs_gui_output_value("syrthes_boundary", ichrsy);
cs_gui_output_value("auxiliary_restart_file_writing", iecaux);
cs_gui_output_value("listing_printing_frequency", ntlist);
cs_gui_output_value("postprocessing_frequency", ntchr);
cs_gui_output_value("probe_recording_frequency", nthist);
cs_gui_output_choice("postprocessing_format", fmtchr, size_fmt);
cs_gui_output_choice("postprocessing_options", optchr, size_opt);
*ncapt = cs_gui_probes_number();
for (i=0; i < *ncapt; i++){
xyzcap[0 + i*3] = cs_gui_probe_coordinate(i+1, "probe_x");
xyzcap[1 + i*3] = cs_gui_probe_coordinate(i+1, "probe_y");
xyzcap[2 + i*3] = cs_gui_probe_coordinate(i+1, "probe_z");
}
/* Sorties des variables vitesses et turbulence */
for (i=0; i<vars->nvar - vars->nscaus - vars->nscapp; i++){
ipp = ipprtp[vars->rtp_nbr[i]];
cs_gui_thermophysical_post(vars->char2[i],
ipp,
ihisvr, ilisvr, ichrvr,
nvppmx);
}
/* scalaires utilisateurs */
if (vars->nscaus > 0 ) {
/* Scalaire thermique */
if (cs_gui_thermal_scalar()) {
ind_thermal_scalar++ ;
cs_gui_thermal_scalar_post("thermal_scalar", 1,
ihisvr, ilisvr, ichrvr,
ipprtp, isca, nvppmx);
}
for (i=0 ; i < vars->nscaus-ind_thermal_scalar; i++) {
cs_gui_additional_scalar_post(i+1+ind_thermal_scalar,
ihisvr, ilisvr, ichrvr,
ipprtp, isca, nvppmx);
}
}
/* Physiques particulieres */
if (cs_gui_get_activ_thermophysical_model(&model, &modelvalue)) {
/* Scalaire model */
if (vars->nscapp > 0){
for (i=vars->nscaus ; i < vars->nscaus+vars->nscapp; i++) {
cs_gui_model_scalar_post(model,
i + 1,
ihisvr, ilisvr, ichrvr,
ipprtp, isca, nvppmx);
}
}
/* Proprietes physiques */
if (vars->nsalpp > 0){
for (i=vars->nprop ; i < vars->nprop + vars->nsalpp; i++) {
cs_gui_model_property_post(model,
i + 1,
ihisvr, ilisvr, ichrvr,
ipppro, ipproc, nvppmx);
}
}
}
BFT_FREE(model);
BFT_FREE(modelvalue);
for (i=0 ; i<12 ; i++) {
cs_gui_properties_post(_cs_properties_name[i],
_cs_properties_ipp[i],
ichrvr,
ilisvr,
ihisvr,
nvppmx);
}
/* TODO: ici a voir ce qu'il se passe avec la diffusivité des scalaires */
#if _XML_DEBUG_
bft_printf(_("==>CSENSO\n"));
bft_printf(_("--iecaux = %i\n"), *iecaux);
bft_printf(_("--ichrvl = %i\n"), *ichrvl);
bft_printf(_("--ichrbo = %i\n"), *ichrbo);
bft_printf(_("--ichrsy = %i\n"), *ichrsy);
bft_printf(_("--fmtchr = %s\n"), "à vérifier en fortran");
bft_printf(_("--optchr = %s\n"), "à vérifier en fortran");
bft_printf(_("--ntlist = %i\n"), *ntlist);
bft_printf(_("--ntchr = %i\n"), *ntchr);
bft_printf(_("--nthist = %i\n"), *nthist);
bft_printf(_("--ncapt = %i\n"), *ncapt);
for (i = 0; i < *ncapt; i++) {
bft_printf(_("--xyzcap[%i][0] = %f\n"), i, xyzcap[0 +i*3]);
bft_printf(_("--xyzcap[%i][1] = %f\n"), i, xyzcap[1 +i*3]);
bft_printf(_("--xyzcap[%i][2] = %f\n"), i, xyzcap[2 +i*3]);
}
for (i=0; i < vars->nvar - vars->nscaus - vars->nscapp; i++){
ipp = ipprtp[vars->rtp_nbr[i]];
bft_printf(_("-->variable ipprtp[%i] = %s\n"), ipp, vars->char2[i]);
bft_printf(_("--ichrvr[%i] = %i \n"), ipp, ichrvr[ipp-1]);
bft_printf(_("--ilisvr[%i] = %i \n"), ipp, ilisvr[ipp-1]);
bft_printf(_("--ihisvr[0][%i]= %i \n"), ipp, ihisvr[0 + (ipp-1)]);
if (ihisvr[0 + (ipp-1)]>0)
for (j=0; j<ihisvr[0 + (ipp-1)]; j++)
bft_printf(_("--ihisvr[%i][%i]= %i \n"), j+1, ipp,
ihisvr[(j+1)*(*nvppmx) + (ipp-1)]);
}
for (i=0 ; i < vars->nscaus + vars->nscapp ; i++) {
ipp = ipprtp[isca[i] -1];
bft_printf(_("-->scalar ipprtp[%i]: %s\n"), ipp, vars->label[i]);
bft_printf(_("--ichrvr[%i] = %i \n"), ipp, ichrvr[ipp-1]);
bft_printf(_("--ilisvr[%i] = %i \n"), ipp, ilisvr[ipp-1]);
bft_printf(_("--ihisvr[0][%i]= %i \n"), ipp, ihisvr[0 + (ipp-1)]);
if (ihisvr[0 + (ipp-1)]>0)
for (j=0; j<ihisvr[0 + (ipp-1)]; j++)
bft_printf(_("--ihisvr[%i][%i]= %i \n"), j+1, ipp,
ihisvr[(j+1)*(*nvppmx) + (ipp-1)]);
}
for (i=0 ; i<12 ; i++) {
ipp = _cs_properties_ipp[i];
bft_printf(_("-->property ipprtp[%i]: %s\n"), ipp, _cs_properties_name[i]);
bft_printf(_("--ichrvr[%i] = %i \n"), ipp, ichrvr[ipp-1]);
bft_printf(_("--ilisvr[%i] = %i \n"), ipp, ilisvr[ipp-1]);
bft_printf(_("--ihisvr[0][%i]= %i \n"), ipp, ihisvr[0 + (ipp-1)]);
if (ihisvr[0 + (ipp-1)]>0)
for (j=0; j<ihisvr[0 + (ipp-1)]; j++)
bft_printf(_("--ihisvr[%i][%i]= %i \n"), j+1, ipp,
ihisvr[(j+1)*(*nvppmx) + (ipp-1)]);
}
#endif
}
/*----------------------------------------------------------------------------
* Copy variable name from Fortran to C
*----------------------------------------------------------------------------*/
void CS_PROCF(fcnmva, FCNMVA)
(
const char *const fstr, /* --> Fortran string */
int *const len, /* --> String Length */
int *const var_id /* --> Variable Id (1 to n) */
CS_ARGF_SUPP_CHAINE
)
{
int i, i1, i2, l;
char *cstr = NULL;
assert(*var_id > 0);
/* Resize array if necessary */
if (*var_id > _cs_gui_max_vars) {
if (_cs_gui_max_vars == 0)
_cs_gui_max_vars = 16;
while (_cs_gui_max_vars <= *var_id)
_cs_gui_max_vars *= 2;
BFT_REALLOC(_cs_gui_var_name, _cs_gui_max_vars, char *);
for (i = _cs_gui_last_var; i < _cs_gui_max_vars; i++)
_cs_gui_var_name[i] = NULL;
}
/* Compute string length (removing start or end blanks) */
for (i1 = 0;
i1 < *len && (fstr[i1] == ' ' || fstr[i1] == '\t');
i1++);
for (i2 = *len - 1;
i2 > i1 && (fstr[i2] == ' ' || fstr[i2] == '\t');
i2--);
l = i2 - i1 + 1;
/* Should be called once per variable only */
assert(_cs_gui_var_name[*var_id - 1] == NULL);
if (l > 0) {
/* Allocate and copy */
BFT_MALLOC(cstr, l + 1, char);
for (i = 0 ; i < l ; i++, i1++)
cstr[i] = fstr[i1];
cstr[l] = '\0';
_cs_gui_var_name[*var_id - 1] = cstr;
}
/* Update variable counter */
_cs_gui_last_var = *var_id;
}
/*----------------------------------------------------------------------------
* Copy variable name from C to Fortran
*----------------------------------------------------------------------------*/
void CS_PROCF(cfnmva, CFNMVA)
(
char *const fstr, /* --> Fortran string */
int *const len, /* --> String Length */
int *const var_id /* --> Variable Id (1 to n) */
CS_ARGF_SUPP_CHAINE
)
{
int i;
int l = 0;
char *cstr = NULL;
/* Check that variable name was set */
if (*var_id < 1 || *var_id > _cs_gui_last_var)
bft_error(__FILE__, __LINE__, 0,
_("Name of variable %d was never set.\n"), var_id);
/* Copy string */
cstr = _cs_gui_var_name[*var_id - 1];
if (cstr != NULL) {
/* Compute string length (removing start or end blanks) */
l = strlen(cstr);
if (l > *len)
l = *len;
for (i = 0; i < l; i++)
fstr[i] = cstr[i];
}
/* Pad with blanks if necessary */
for (i = l; i < *len; i++)
fstr[i] = ' ';
}
/*----------------------------------------------------------------------------
* Variables and scalars initialization
*----------------------------------------------------------------------------*/
void CS_PROCF(uiiniv, UIINIV)
(
const int *const nscapp,
const int *const ncelet,
const int *const ncel,
const int *const nfml,
const int *const nprfml,
const int *const isca,
const int *const ifmcel,
const int *const iprfml,
double *const rtp
)
{
int *cells_list = NULL;
int cells = 0;
int i, j, icel;
int ind_thermal_scalar = 0;
int zones = 0;
double initial_value = 0;
char *choice = NULL;
char *name = NULL;
char *description = NULL;
zones = cs_gui_initialization_zones_number();
#if _XML_DEBUG_
bft_printf(_("==>UIINIV\n"));
bft_printf(_("--initialization zones number: %i\n"), zones);
#endif
for (i=1; i < zones+1; i++) {
/* name and description (color or group) of the ith initialization zone */
name = cs_gui_initialization_zone_name(i);
description = cs_gui_initialization_zone_description(name);
/* list of cells building */
cs_gui_cells_list_building(description,
&cells,
&cells_list,
ncel,
nfml,
nprfml,
ifmcel,
iprfml);
/* Velocity variables */
for (j=1; j < 4; j++) {
cs_gui_variable_initial_value(vars->char2[j], name, &initial_value);
for (icel = 0; icel < cells; icel++) {
rtp[vars->rtp_nbr[j]*(*ncelet)+cells_list[icel]] = initial_value;
}
}
/* Turbulence variables */
choice = cs_gui_turbulence_initialization_choice();
if (cs_gui_strcmp(choice, "values")) {
for (j=4; j < vars->nvar - vars->nscaus - vars->nscapp; j++) {
cs_gui_variable_initial_value(vars->char2[j], name, &initial_value);
for (icel = 0; icel < cells; icel++) {
rtp[vars->rtp_nbr[j]*(*ncelet)+cells_list[icel]] = initial_value;
}
}
}
BFT_FREE(choice);
/* Thermal Scalar */
if (vars->nscaus >= 0) {
if (cs_gui_thermal_scalar()) {
ind_thermal_scalar = 1;
cs_gui_thermal_scalar_initial_value("thermal_scalar",
name,
&initial_value);
for (icel = 0; icel < cells; icel++) {
rtp[(isca[0]-1)*(*ncelet)+cells_list[icel]] = initial_value;
}
}
}
/* User Scalars */
for (j=0; j < vars->nscaus-ind_thermal_scalar; j++) {
cs_gui_scalar_initial_value("additional_scalars",
vars->label[j+ind_thermal_scalar],
name,
&initial_value);
for (icel = 0; icel < cells; icel++) {
rtp[(isca[j+ind_thermal_scalar]-1)*(*ncelet)+cells_list[icel]]
= initial_value;
}
}
BFT_FREE(cells_list);
#if _XML_DEBUG_
bft_printf(_("--zone name and description: %s, %s\n"), name, description);
bft_printf(_("--zone's element number: %i\n"), cells);
for (j=1; j < vars->nvar - vars->nscaus - vars->nscapp; j++){
cs_gui_variable_initial_value(vars->char2[j], name, &initial_value);
bft_printf(_("--initial value for %s: %f\n"),
vars->char2[j], initial_value);
}
ind_thermal_scalar = 0;
if (vars->nscaus >= 0) {
if (cs_gui_thermal_scalar()) {
ind_thermal_scalar = 1;
cs_gui_thermal_scalar_initial_value("thermal_scalar",
name,
&initial_value);
bft_printf(_("--initial value for %s: %f\n"),
"thermal_scalar", initial_value);
}
}
for (j=0; j < vars->nscaus-ind_thermal_scalar; j++) {
cs_gui_scalar_initial_value("additional_scalars",
vars->label[j+ind_thermal_scalar],
name,
&initial_value);
bft_printf(_("--initial value for %s: %f\n"),
vars->label[j+ind_thermal_scalar], initial_value);
}
#endif
} /* zones+1 */
BFT_FREE(name);
BFT_FREE(description);
}
void cs_gui_variable_initial_value(const char *const variable_name,
const char *const zone_name,
double *const initial_value)
{
char *path = NULL;
double result;
path = cs_xpath_short_path();
cs_xpath_add_element(&path, "variable");
cs_xpath_add_test_attribute(&path, "name", variable_name);
cs_xpath_add_element(&path, "initial_value");
cs_xpath_add_test_attribute(&path, "zone", zone_name);
cs_xpath_add_function_text(&path);
if (cs_gui_get_double(path, &result))
*initial_value = result;
else
*initial_value = 0.0;
BFT_FREE(path);
}
void cs_gui_reference_pressure(double *const p0)
{
char *path = NULL;
double value;
path = cs_xpath_init_path();
cs_xpath_add_elements(&path, 3,
"thermophysical_models",
"velocity_pressure",
"variable");
cs_xpath_add_test_attribute(&path,"name","pressure");
cs_xpath_add_element(&path, "reference_pressure");
cs_xpath_add_function_text(&path);
if (cs_gui_get_double(path, &value)) *p0 = value;
}
void cs_gui_thermal_scalar_initial_value(const char *const model_type,
const char *const zone_name,
double *const initial_value)
{
char *path = NULL;
char *scalar_name = NULL;
double result;
scalar_name = cs_gui_get_thermophysical_model(model_type);
path = cs_xpath_short_path();
cs_xpath_add_elements(&path, 2, model_type, "scalar");
cs_xpath_add_test_attribute(&path, "name", scalar_name);
cs_xpath_add_element(&path, "initial_value");
cs_xpath_add_test_attribute(&path, "zone", zone_name);
cs_xpath_add_function_text(&path);
if (cs_gui_get_double(path, &result))
*initial_value = result;
else
*initial_value = 0.0;
BFT_FREE(scalar_name);
BFT_FREE(path);
}
void cs_gui_scalar_initial_value(const char *const parent,
const char *const label,
const char *const zone_name,
double *const initial_value)
{
char *path = NULL;
char *scalar_name = NULL;
double result;
path = cs_xpath_short_path();
cs_xpath_add_elements(&path, 2, parent, "scalar");
cs_xpath_add_test_attribute(&path, "label", label);
cs_xpath_add_element(&path, "initial_value");
cs_xpath_add_test_attribute(&path, "zone", zone_name);
cs_xpath_add_function_text(&path);
if (cs_gui_get_double(path, &result))
*initial_value = result;
else
*initial_value = 0.0;
BFT_FREE(scalar_name);
BFT_FREE(path);
}
void cs_gui_cells_list_building(const char *const description,
int * cells,
int ** cells_list,
const int *const ncel,
const int *const nfml,
const int *const nprfml,
const int *const ifmcel,
const int *const iprfml)
{
int icel;
int icpt;
int n;
int iprop;
int ifml;
int icoul;
n = atoi(description);
*cells = 0;
icpt = 0;
for (icel=0; icel < *ncel; icel++) {
ifml = ifmcel[icel] - 1;
for (iprop=0 ; iprop < *nprfml ; iprop++) {
icoul = iprfml[iprop*(*nfml) + ifml];
if (icoul == n) icpt++;
}
}
if (!icpt) return;
*cells = icpt;
BFT_MALLOC((*cells_list), *cells, int);
icpt = 0;
for (icel=0; icel < *ncel; icel++) {
ifml = ifmcel[icel] - 1;
for (iprop=0 ; iprop < *nprfml ; iprop++) {
icoul = iprfml[iprop*(*nfml) + ifml];
if (icoul == n) {
(*cells_list)[icpt] = icel;
icpt++;
}
}
}
assert(icpt == *cells);
}
char *cs_gui_initialization_zone_name(const int ith_zone)
{
char *path = NULL;
char *name = NULL;
/* 1) get the name of the ith initialization zone */
path = cs_xpath_init_path();
cs_xpath_add_elements(&path, 2, "thermophysical_models", "initialization");
cs_xpath_add_element_num(&path, "zone", ith_zone);
cs_xpath_add_attribute(&path, "name");
name = cs_gui_get_attribute_value(path);
BFT_FREE(path);
return name;
}
char *cs_gui_initialization_zone_description(const char *const name)
{
char *path = NULL;
char *description = NULL;
/* 2) get the description (color and groups) of the ith initialization zone */
path = cs_xpath_init_path();
cs_xpath_add_elements(&path, 3, "thermophysical_models",
"initialization",
"zone");
cs_xpath_add_test_attribute(&path, "name", name);
cs_xpath_add_function_text(&path);
description = cs_gui_get_text_value(path);
BFT_FREE(path);
return description;
}
/*----------------------------------------------------------------------------
* Traitement des conditions aux limites
*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
* Traitement des conditions aux limites
*----------------------------------------------------------------------------*/
void CS_PROCF (uiclim, UICLIM)
(
const int *const nscapp,
const int *const nfabor,
const int *const nfml,
const int *const iindef,
const int *const ientre,
const int *const iparoi,
const int *const isymet,
const int *const isolib,
const int *const iturb,
const int *const ifmfbr,
const int *const iprfml,
int *const itypfb,
int *const icodcl,
double *const rcodcl,
const double *const surfbo
)
{
int iphas = 0;
int ifbr;
int i;
int n;
int nscalth = 0;
int numvar;
int therm_scalar_nb = 0;
int user_scalar_nb = 0;
char *choice = NULL;
char *nature = NULL;
char *label = NULL;
char *description = NULL;
int izone, ith_zone;
int zones = 0;
int *faces_list = NULL;
int faces = 0;
int ivar;
nscalth = cs_gui_thermal_scalar();
numvar = vars->nvar - vars->nscaus - vars->nscapp;
zones = cs_gui_boundary_zones_number();
/* Fisrt iteration only : memory allocation */
if (boundaries == NULL){
BFT_MALLOC(boundaries, 1, cs_boundary_t);
BFT_MALLOC(boundaries->label, zones, char* );
BFT_MALLOC(boundaries->nature, zones, char* );
BFT_MALLOC(boundaries->type_code, vars->nvar, int* );
BFT_MALLOC(boundaries->values, vars->nvar, cs_val_t* );
for (ivar = 0; ivar < vars->nvar; ivar++) {
BFT_MALLOC(boundaries->type_code[vars->rtp_nbr[ivar]], zones, int);
BFT_MALLOC(boundaries->values[vars->rtp_nbr[ivar]], zones, cs_val_t);
}
/* Initialization of boundary->type_code and boundary->values */
for (ivar = 0; ivar < vars->nvar; ivar++) {
for (izone = 0; izone < zones; izone++) {
boundaries->type_code[ivar][izone] = -1;
boundaries->values[ivar][izone].val1 = 0.;
boundaries->values[ivar][izone].val2 = 1.e30;
boundaries->values[ivar][izone].val3 = 0.;
}
}
/* Number of scalar (thermal and user) */
if (nscalth) therm_scalar_nb = 1;
user_scalar_nb = cs_gui_get_number_user_scalar();
for (izone = 0; izone < zones; izone++) {
/* nature, label and description (color or group)
of the ith initialization zone */
ith_zone = izone + 1;
nature = cs_gui_boundary_zone_nature(ith_zone);
label = cs_gui_boundary_zone_label(ith_zone);
BFT_MALLOC(boundaries->label[izone], strlen(label)+1, char);
strcpy(boundaries->label[izone], label);
BFT_MALLOC(boundaries->nature[izone], strlen(nature)+1, char);
strcpy(boundaries->nature[izone], nature);
/* description = cs_gui_boundary_zone_description(label); */
if (cs_gui_strcmp(nature, "inlet")) {
/* INLET: VELOCITY */
choice = cs_gui_boundary_choice("inlet",
label,
"velocity_pressure",
NULL);
if (cs_gui_strcmp(choice, "dirichlet")) {
for(ivar = 1; ivar < 4; ivar++)
cs_gui_boundary_dirichlet("inlet",
label,
vars->char2[ivar],
izone,
ivar);
} else if (cs_gui_strcmp(choice, "flow1")) {
/* list of faces building */
cs_gui_faces_list_building(nature,
label,
&faces,
&faces_list,
nfabor,
nfml,
ifmfbr,
iprfml);
cs_gui_boundary_flow(label, izone, faces, faces_list, surfbo);
BFT_FREE(faces_list);
}
BFT_FREE(choice);
/* INLET: TURBULENCE */
choice = cs_gui_boundary_choice("inlet",
label,
"turbulence",
NULL);
cs_gui_boundary_turbulence(choice, iturb, izone);
BFT_FREE(choice);
/* INLET: THERMAL AND USER SCALARS */
for (ivar = 0; ivar < vars->nscaus; ivar++) {
if (nscalth != 0 && ivar == 0) {
if (nscalth == -1)
cs_gui_boundary_value_scalar("inlet",
"temperature_celsius",
izone,
numvar,
nscalth,
ivar);
else if (nscalth == 1)
cs_gui_boundary_value_scalar("inlet",
"temperature_kelvin",
izone,
numvar,
nscalth,
ivar);
else if (nscalth == 2)
cs_gui_boundary_value_scalar("inlet",
"enthalpy",
izone,
numvar,
nscalth,
ivar);
} else {
/* selon le type et choice lu, on va lire les valeurs des scalaires */
cs_gui_boundary_value_scalar("inlet",
"users",
izone,
numvar+ivar,
nscalth,
ivar);
}
} /* for ivar */
} else if (cs_gui_strcmp(nature, "wall")) {
/* WALL: VELOCITY */
choice = cs_gui_boundary_choice("wall",
label,
"velocity_pressure",
NULL);
if (cs_gui_strcmp(choice, "on")) {
for (ivar = 1; ivar < 4; ivar++)
cs_gui_boundary_dirichlet("wall",
label,
vars->char2[ivar],
izone,
ivar);
}
BFT_FREE(choice);
/* WALL: THERMAL AND USER SCALARS */
for (ivar = 0; ivar < vars->nscaus; ivar++) {
if (nscalth != 0 && ivar == 0) {
if (nscalth == -1)
cs_gui_boundary_value_scalar("wall",
"temperature_celsius",
izone,
numvar,
nscalth,
ivar);
else if (nscalth == 1)
cs_gui_boundary_value_scalar("wall",
"temperature_kelvin",
izone,
numvar,
nscalth,
ivar);
else if (nscalth == 2)
cs_gui_boundary_value_scalar("wall",
"enthalpy",
izone,
numvar,
nscalth,
ivar);
} else {
/* selon le type et choice lu, on va lire les valeurs des scalaires */
cs_gui_boundary_value_scalar("wall",
"users",
izone,
numvar+ivar,
nscalth,
ivar);
}
} /* for ivar */
} else if (cs_gui_strcmp(nature, "outlet")) {
/* OUTLET: THERMAL AND USER SCALARS */
for (ivar = 0; ivar < vars->nscaus; ivar++) {
if (nscalth != 0 && ivar == 0) {
if (nscalth == -1)
cs_gui_boundary_value_scalar("outlet",
"temperature_celsius",
izone,
numvar,
nscalth,
ivar);
else if (nscalth == 1)
cs_gui_boundary_value_scalar("outlet",
"temperature_kelvin",
izone,
numvar,
nscalth,
ivar);
else if (nscalth == 2)
cs_gui_boundary_value_scalar("outlet",
"enthalpy",
izone,
numvar,
nscalth,
ivar);
} else {
/* selon le type et choice lu, on va lire les valeurs des scalaires */
cs_gui_boundary_value_scalar("outlet",
"users",
izone,
numvar+n,
nscalth,
ivar);
}
} /* for ivar */
} /* if (cs_gui_strcmp(nature, "outlet")) */
} /* for izones */
} /* if (boundaries == NULL)*/
/* A chaque iteration, boucle sur les faces de bord :
on remplit itypfb, rcodcl et icodcl a partir des tableaux
de la structures conditions.limites definie
dans la premiere partie de la fonction */
/* rdoccl[k][j][i] = rcodcl[ k * dim1 *dim2 + j *dim1 + i] */
for (izone=0 ; izone < zones ; izone++) {
nature = boundaries->nature[izone];
label = boundaries->label[izone];
/* description = cs_gui_boundary_zone_description(label); */
/* list of faces building */
cs_gui_faces_list_building(nature,
label,
&faces,
&faces_list,
nfabor,
nfml,
ifmfbr,
iprfml);
/* BFT_FREE(description); */
if (cs_gui_strcmp(nature, "inlet")) {
for (n = 0; n < faces; n++) {
ifbr = faces_list[n];
itypfb[iphas *(*nfabor) +ifbr] = *ientre;
for (ivar = 0; ivar < vars->nvar; ivar++) {
rcodcl[0 * (*nfabor * (vars->nvar)) + ivar * (*nfabor) + ifbr]
= boundaries->values[ivar][izone].val1 ;
}
}
} else if (cs_gui_strcmp(nature, "wall")) {
for (n = 0; n < faces; n++) {
ifbr = faces_list[n];
itypfb[iphas *(*nfabor) +ifbr] = *iparoi;
}
for (ivar = 0; ivar < vars->nvar; ivar++) {
switch (boundaries->type_code[ivar][izone]) {
case NEUMANN :
for (n = 0; n < faces; n++) {
ifbr = faces_list[n];
icodcl[ivar *(*nfabor) + ifbr ] = 3 ;
rcodcl[2 * (*nfabor * (vars->nvar)) + ivar * (*nfabor) + ifbr]
= boundaries->values[ivar][izone].val3 ;
}
break;
case DIRICHLET :
for (n = 0; n < faces; n++) {
ifbr = faces_list[n];
icodcl[ivar *(*nfabor) + ifbr ] = 5 ;
rcodcl[0 * (*nfabor * (vars->nvar)) + ivar * (*nfabor) + ifbr]
= boundaries->values[ivar][izone].val1 ;
}
break;
case COEF_ECHANGE :
for (n = 0; n < faces; n++) {
ifbr = faces_list[n];
icodcl[ivar *(*nfabor) + ifbr ] = 5 ;
rcodcl[0 * (*nfabor * (vars->nvar)) + ivar * (*nfabor) + ifbr]
= boundaries->values[ivar][izone].val1 ;
rcodcl[1 * (*nfabor * (vars->nvar)) + ivar * (*nfabor) + ifbr]
= boundaries->values[ivar][izone].val2 ;
}
break;
}
}
} else if (cs_gui_strcmp(nature, "outlet")) {
for (n = 0; n < faces; n++) {
ifbr = faces_list[n];
itypfb[iphas *(*nfabor) +ifbr] = *isolib;
}
for (ivar = numvar; ivar < vars->nvar; ivar++) {
switch (boundaries->type_code[ivar][izone]) {
case DIRICHLET :
for (n = 0; n < faces; n++) {
ifbr = faces_list[n];
icodcl[ivar *(*nfabor) + ifbr ] = 1 ;
rcodcl[0 * (*nfabor * (vars->nvar)) + ivar * (*nfabor) + ifbr]
= boundaries->values[ivar][izone].val1 ;
}
break;
}
}
} else if (cs_gui_strcmp(nature, "symmetry")) {
for (n = 0; n < faces; n++) {
ifbr = faces_list[n];
itypfb[iphas *(*nfabor) +ifbr] = *isymet;
}
} else if (cs_gui_strcmp(nature, "undefined")) {
for (n = 0; n < faces; n++) {
ifbr = faces_list[n];
itypfb[iphas *(*nfabor) +ifbr] = *iindef;
}
} else {
bft_error(__FILE__, __LINE__, 0,
_("boundary nature %s is unknown \n"), nature);
}
BFT_FREE(faces_list);
} /* for izone */
#if _XML_DEBUG_
bft_printf(_("==>UICLIM\n"));
bft_printf(_("--boundary zones number: %i\n"), zones);
for (izone=0 ; izone < zones ; izone++) {
nature = boundaries->nature[izone];
label = boundaries->label[izone];
cs_gui_faces_list_building(nature,
label,
&faces,
&faces_list,
nfabor,
nfml,
ifmfbr,
iprfml);
BFT_FREE(faces_list);
bft_printf(_("---zone %i label: %s\n"), izone, label);
bft_printf(_("---zone %i nature: %s\n"), izone, nature);
bft_printf(_("---zone %i number of faces: %i\n"), izone, faces);
n = cs_gui_boundary_zone_reference_number(nature, label);
bft_printf(_("----localization: "));
for (i=1 ; i < n+1 ; i++) {
bft_printf(_("%i "), cs_gui_boundary_zone_reference(nature, label, i));
}
bft_printf(_("\n"));
}
#endif
}
void CS_PROCF (uicliv, UICLIV)(const int *const nfabor,
const int *const nfml,
const int *const iindef,
const int *const ientre,
const int *const iparoi,
const int *const isymet,
const int *const isolib,
const int *const ifmfbr,
const int *const iprfml,
int *const itypfb)
{
int ifbr;
int izone, ith_zone, zones, ifac, inature;
char *label = NULL;
char *nature = NULL;
char *description = NULL;
int *faces_list = NULL;
int faces = 0, iphas = 0;
zones = cs_gui_boundary_zones_number();
for (izone=0 ; izone < zones ; izone++) {
ith_zone = izone + 1;
nature = boundaries->nature[izone];
label = boundaries->label[izone];
/* description = cs_gui_boundary_zone_description(label);*/
/* list of faces building */
cs_gui_faces_list_building(nature,
label,
&faces,
&faces_list,
nfabor,
nfml,
ifmfbr,
iprfml);
/* BFT_FREE(description); */
if (cs_gui_strcmp(nature, "inlet")) {
inature = *ientre;
} else if (cs_gui_strcmp(nature, "wall")) {
inature = *iparoi;
} else if (cs_gui_strcmp(nature, "outlet")) {
inature = *isolib;
} else if (cs_gui_strcmp(nature, "symmetry")) {
inature = *isymet;
} else if (cs_gui_strcmp(nature, "undefined")) {
inature = *iindef;
} else
bft_error(__FILE__, __LINE__, 0,
_("boundary nature %s is unknown \n"), nature);
for (ifac = 0; ifac < faces; ifac++) {
ifbr = faces_list[ifac];
if (itypfb[iphas *(*nfabor) +ifbr] != inature)
bft_error(__FILE__, __LINE__, 0,
_("The zone %s has not the same nature \n"
"between the GUI (nature: %s) and \n"
"the user subroutine USCLIM. \n"
"Please do not change this nature \n"
"(ITYPFB fortran array) in the user \n"
"subroutine USCLIM\n"), label, nature);
} /* for ifac */
BFT_FREE(faces_list);
} /* for izone */
}
int cs_gui_boundary_zone_reference(const char *const nature,
const char *const label,
const int ith_ref)
{
int ref = 0;
int res = 0;
char *path = NULL;
path = cs_xpath_init_path();
cs_xpath_add_elements(&path, 3, "boundary_conditions",
"boundary_definition",
nature);
cs_xpath_add_test_attribute(&path, "label", label);
cs_xpath_add_element_num(&path, "reference", ith_ref);
cs_xpath_add_function_text(&path);
if (cs_gui_get_int(path, &res)) ref = res;
BFT_FREE(path);
return ref;
}
char *cs_gui_boundary_choice(const char *const nature,
const char *const label,
const char *const var_sca,
const char *const sca_lbl) /* todelete ? */
{
char *path = NULL;
char *choice = NULL;
path = cs_xpath_init_path();
cs_xpath_add_elements(&path, 2, "boundary_conditions", nature);
cs_xpath_add_test_attribute(&path, "label", label);
if (cs_gui_strcmp(var_sca, "scalar")) {
cs_xpath_add_element(&path, "scalar");
cs_xpath_add_test_attribute(&path, "label", sca_lbl);
} else {
cs_xpath_add_element(&path, var_sca);
}
cs_xpath_add_attribute(&path, "choice");
choice = cs_gui_get_attribute_value(path);
BFT_FREE(path);
return choice;
}
void cs_gui_boundary_dirichlet(const char *const nature,
const char *const label,
const char *const var_name,
const int izone,
const int ivar)
{
char *path = NULL;
double result = 0.0;
path = cs_xpath_init_path();
cs_xpath_add_element(&path, "boundary_conditions");
cs_xpath_add_element(&path, nature);
cs_xpath_add_test_attribute(&path, "label", label);
cs_xpath_add_element(&path, "velocity_pressure");
if (cs_gui_strcmp(nature, "wall")) {
cs_xpath_add_test_attribute(&path, "choice", "on");
} else if (cs_gui_strcmp(nature, "inlet")) {
cs_xpath_add_test_attribute(&path, "choice", "dirichlet");
} else {
bft_error(__FILE__, __LINE__, 0,
_("Unknown conditions type in this context: %s.\nXpath: %s\n"),
nature, path);
}
cs_xpath_add_element(&path, "dirichlet");
cs_xpath_add_test_attribute(&path, "name", var_name);
cs_xpath_add_function_text(&path);
if (cs_gui_get_double(path, &result)) {
boundaries->type_code[vars->rtp_nbr[ivar]][izone] = cs_gui_boundary_code(DIRICHLET);
boundaries->values[vars->rtp_nbr[ivar]][izone].val1 = result;
}
BFT_FREE(path);
}
void cs_gui_boundary_flow(const char *const label,
const int izone,
const int faces,
int *const faces_list,
const double *const surfbo)
{
int ifac;
int ifbr;
char *path1 = NULL;
char *path2 = NULL;
double result;
double surface = 0.0;
double normu = 0.0;
double normv = 0.0;
double normw = 0.0;
path1 = cs_xpath_init_path();
cs_xpath_add_elements(&path1, 2, "boundary_conditions", "inlet");
cs_xpath_add_test_attribute(&path1, "label", label);
cs_xpath_add_element(&path1, "velocity_pressure");
BFT_MALLOC(path2, strlen(path1) + 1, char);
strcpy(path2, path1);
/* flow rate */
cs_xpath_add_element(&path1, "flow1");
cs_xpath_add_function_text(&path1);
if (cs_gui_get_double(path1, &result)){
for (ifac = 0; ifac < faces; ifac++){
ifbr = faces_list[ifac];
surface += sqrt (pow(surfbo[ifbr * 3 + 0],2) +
pow(surfbo[ifbr * 3 + 1],2) +
pow(surfbo[ifbr * 3 + 2],2));
normu += surfbo[ifbr * 3 + 0];
normv += surfbo[ifbr * 3 + 1];
normw += surfbo[ifbr * 3 + 2];
}
normu /= surface;
normv /= surface;
normw /= surface;
/* boundaries->type_code[vars->rtp_ptr[VELOCITY_U]][izone] = cs_gui_boundary_code(FLOW1);
boundaries->type_code[vars->rtp_ptr[VELOCITY_V]][izone] = cs_gui_boundary_code(FLOW1);
boundaries->type_code[vars->rtp_ptr[VELOCITY_W]][izone] = cs_gui_boundary_code(FLOW1); */
boundaries->values[vars->rtp_ptr[VELOCITY_U]][izone].val1 = normu*result/surface;
boundaries->values[vars->rtp_ptr[VELOCITY_V]][izone].val1 = normv*result/surface;
boundaries->values[vars->rtp_ptr[VELOCITY_W]][izone].val1 = normw*result/surface;
}
BFT_FREE(path1);
/* temperature */
cs_xpath_add_element(&path2, "temperature");
cs_xpath_add_function_text(&path2);
if (cs_gui_get_double(path2, &result)) {
boundaries->timpat[izone] = result;
}
BFT_FREE(path2);
}
void cs_gui_boundary_turbulence(const char *const choice,
const int *const iturb,
const int izone)
{
int iphas = 0;
int turb_int = 0;
char *path = NULL;
char *path_commun = NULL;
double result = 0;
double diameter = 0.;
double intensity = 0;
double cmu = 0.09;
double karman = 0.42;
double uref2;
double kent;
double epsent;
double reynolds;
double ro0;
double viscl0;
double xlambd, ustar2;
if (choice == NULL) return;
path = cs_xpath_init_path();
cs_xpath_add_element(&path, "boundary_conditions");
cs_xpath_add_element(&path, "inlet");
cs_xpath_add_test_attribute(&path, "label", boundaries->label[izone]);
cs_xpath_add_element(&path, "turbulence");
if (cs_gui_strcmp(choice, "hydraulic_diameter")){
cs_xpath_add_test_attribute(&path, "choice", "hydraulic_diameter");
turb_int = 0;
} else if(cs_gui_strcmp(choice, "turbulent_intensity")){
cs_xpath_add_test_attribute(&path, "choice", "turbulent_intensity");
turb_int = 1;
}
/* This common path is saved in order to read the turbulent intensity after */
BFT_MALLOC(path_commun, strlen(path)+1, char);
strcpy(path_commun, path);
/* read the hydraulic diameter */
cs_xpath_add_element(&path, "hydraulic_diameter");
cs_xpath_add_function_text(&path);
if (cs_gui_get_double(path, &result)) diameter = result;
/* read the turbulent intensity */
cs_xpath_add_element(&path_commun, "turbulent_intensity");
cs_xpath_add_function_text(&path_commun);
if (cs_gui_get_double(path_commun, &result)) intensity = result * 0.01;
BFT_FREE(path_commun);
BFT_FREE(path);
/* We have k=3/2 V**2 I**2 and epsilon= 10*(Cmu**0.75) * (k**1.5) / karman * Dh)*/
uref2 = pow(boundaries->values[vars->rtp_ptr[VELOCITY_U]][izone].val1, 2)
+ pow(boundaries->values[vars->rtp_ptr[VELOCITY_V]][izone].val1, 2)
+ pow(boundaries->values[vars->rtp_ptr[VELOCITY_W]][izone].val1, 2);
uref2 = CS_MAX(uref2, 1.e-12);
if (turb_int == 1){
kent = 1.5 * uref2 * pow(intensity,2);
epsent = 10. * pow(cmu,0.75) *(pow(kent,1.5) / (karman * diameter));
} else {
/* Re = Dh * V /nu et nu = mu /rho */
/* On récupère rho et nu propriétés du fluide pour le calcul du nombre de Reynolds */
cs_gui_properties_value("density", &ro0);
cs_gui_properties_value("molecular_viscosity", &viscl0);
reynolds = sqrt(uref2) * diameter * ro0 / viscl0;
if (reynolds <= 30000.0){
xlambd = 0.3164 * pow(reynolds,-0.25);
}else{
xlambd = 0.1840 * pow(reynolds,-0.20);
}
ustar2 = uref2 * xlambd / 8.0;
kent = ustar2 / sqrt(cmu);
epsent = pow(ustar2, 1.5) / (karman * diameter * 0.1);
}
if (iturb[iphas] == 20 || iturb[iphas] == 21){
/* boundaries->type_code[vars->rtp_ptr[TURB_K]][izone] = cs_gui_boundary_code(HYDRAULIC_DIAMETER);
boundaries->type_code[vars->rtp_ptr[TURB_EPS]][izone] = cs_gui_boundary_code(HYDRAULIC_DIAMETER); */
boundaries->values[vars->rtp_ptr[TURB_K]][izone].val1 = kent;
boundaries->values[vars->rtp_ptr[TURB_EPS]][izone].val1 = epsent;
} else if (iturb[iphas] == 30 || iturb[iphas] == 31){
/* boundaries->type_code[vars->rtp_ptr[R11]][izone] = cs_gui_boundary_code(HYDRAULIC_DIAMETER);
boundaries->type_code[vars->rtp_ptr[R22]][izone] = cs_gui_boundary_code(HYDRAULIC_DIAMETER);
boundaries->type_code[vars->rtp_ptr[R33]][izone] = cs_gui_boundary_code(HYDRAULIC_DIAMETER);
boundaries->type_code[vars->rtp_ptr[R12]][izone] = cs_gui_boundary_code(HYDRAULIC_DIAMETER);
boundaries->type_code[vars->rtp_ptr[R13]][izone] = cs_gui_boundary_code(HYDRAULIC_DIAMETER);
boundaries->type_code[vars->rtp_ptr[R23]][izone] = cs_gui_boundary_code(HYDRAULIC_DIAMETER);
boundaries->type_code[vars->rtp_ptr[TURB_EPS]][izone] = cs_gui_boundary_code(HYDRAULIC_DIAMETER); */
boundaries->values[vars->rtp_ptr[R11]][izone].val1 = kent * 2./3.;
boundaries->values[vars->rtp_ptr[R22]][izone].val1 = kent * 2./3.;
boundaries->values[vars->rtp_ptr[R33]][izone].val1 = kent * 2./3.;
boundaries->values[vars->rtp_ptr[R12]][izone].val1 = 0.;
boundaries->values[vars->rtp_ptr[R13]][izone].val1 = 0.;
boundaries->values[vars->rtp_ptr[R23]][izone].val1 = 0.;
boundaries->values[vars->rtp_ptr[TURB_EPS]][izone].val1 = epsent;
} else if (iturb[iphas] == 50){
/* boundaries->type_code[vars->rtp_ptr[TURB_K]][izone] = cs_gui_boundary_code(HYDRAULIC_DIAMETER);
boundaries->type_code[vars->rtp_ptr[TURB_EPS]][izone] = cs_gui_boundary_code(HYDRAULIC_DIAMETER);
boundaries->type_code[vars->rtp_ptr[TURB_PHI]][izone] = cs_gui_boundary_code(HYDRAULIC_DIAMETER);
boundaries->type_code[vars->rtp_ptr[TURB_FB]][izone] = cs_gui_boundary_code(HYDRAULIC_DIAMETER); */
boundaries->values[vars->rtp_ptr[TURB_K]][izone].val1 = kent;
boundaries->values[vars->rtp_ptr[TURB_EPS]][izone].val1 = epsent;
boundaries->values[vars->rtp_ptr[TURB_PHI]][izone].val1 = 2./3.;
boundaries->values[vars->rtp_ptr[TURB_FB]][izone].val1 = 0.;
} else if (iturb[iphas] == 60){
/* boundaries->type_code[vars->rtp_ptr[TURB_K]][izone] = cs_gui_boundary_code(HYDRAULIC_DIAMETER);
boundaries->type_code[vars->rtp_ptr[TURB_OMEGA]][izone] = cs_gui_boundary_code(HYDRAULIC_DIAMETER); */
boundaries->values[vars->rtp_ptr[TURB_K]][izone].val1 = kent;
boundaries->values[vars->rtp_ptr[TURB_OMEGA]][izone].val1 = epsent / (cmu * kent);
}
}
void cs_gui_boundary_value_scalar(const char *const nature,
const char *const thscal,
const int izone,
const int numvar, /* n° variable */
const int nscalth, /* different de 0 si scalaire thermique */
const int iscal) /* n° scalaire */
{
char *path = NULL;
char *path_commun = NULL;
char *path2 = NULL;
char *choice = NULL;
double result;
path = cs_xpath_init_path();
cs_xpath_add_elements(&path, 2, "boundary_conditions", nature);
cs_xpath_add_test_attribute(&path, "label", boundaries->label[izone]);
cs_xpath_add_element(&path, "scalar");
if (!cs_gui_strcmp(thscal, "users"))
cs_xpath_add_test_attribute(&path, "name", thscal);
else
cs_xpath_add_test_attribute(&path, "label", vars->label[iscal]);
BFT_MALLOC(path_commun, strlen(path)+1, char);
strcpy(path_commun, path);
BFT_MALLOC(path2, strlen(path)+1, char);
strcpy(path2, path);
cs_xpath_add_attribute(&path_commun, "choice");
choice = cs_gui_get_attribute_value(path_commun);
if (choice != NULL){
if(cs_gui_strcmp(choice, "dirichlet") || cs_gui_strcmp(choice, "exchange_coefficient")) {
cs_xpath_add_element(&path, "dirichlet");
cs_xpath_add_function_text(&path);
if (cs_gui_get_double(path, &result)) {
boundaries->type_code[vars->rtp_nbr[numvar]][izone] = cs_gui_boundary_code(DIRICHLET);
boundaries->values[vars->rtp_nbr[numvar]][izone].val1 = result;
}
} else if(cs_gui_strcmp(choice, "neumann")) {
cs_xpath_add_element(&path, "neumann");
cs_xpath_add_function_text(&path);
if (cs_gui_get_double(path, &result)) {
boundaries->type_code[vars->rtp_nbr[numvar]][izone] = cs_gui_boundary_code(NEUMANN);
boundaries->values[vars->rtp_nbr[numvar]][izone].val3 = result;
}
}
if(cs_gui_strcmp(choice, "exchange_coefficient")) {
cs_xpath_add_element(&path2, "exchange_coefficient");
cs_xpath_add_function_text(&path2);
if (cs_gui_get_double(path2, &result)) {
boundaries->type_code[vars->rtp_nbr[numvar]][izone] = cs_gui_boundary_code(COEF_ECHANGE);
boundaries->values[vars->rtp_nbr[numvar]][izone].val2 = result;
}
}
BFT_FREE(choice);
}
BFT_FREE(path);
BFT_FREE(path2);
BFT_FREE(path_commun);
}
/*-----------------------------------------------------------------------------
* Indirection entre la numérotation noyau et la numérotation XML des propriétés
* physiques de la physique particulière active
*----------------------------------------------------------------------------*/
void CS_PROCF (cscppp, CSCPPP)
(
int *const nclass,
int *const nsalpp,
int *const nsalto,
int *const itemp1,
int *const irom1,
int *const ym1,
int *const imel,
int *const itemp2,
int *const ix2,
int *const irom2,
int *const idiam2,
int *const igmdch,
int *const igmdv1,
int *const igmdv2,
int *const igmhet,
int *const ilumi
)
{
int i = 0;
char *name = NULL;
char *model = NULL;
char *modelvalue = NULL;
char *snumpp = NULL;
int nprop;
/* Récupération du model activé */
cs_gui_get_activ_thermophysical_model(&model, &modelvalue);
/* Allocation du tableau de redirection */
BFT_MALLOC(vars->XMLnumpp, *nsalpp, int);
/* Remplissage du tableau d'indirection en respectant la numérotation du noyau */
nprop = *nsalto - *nsalpp;
vars->nprop = nprop;
vars->nsalpp = *nsalpp;
/* ITEMP1 */
vars->XMLnumpp[*itemp1 - nprop - 1] = cs_gui_get_model_property_number(model, cs_coal_combustion_properties[ITEMP1]);
/* IROM1 */
vars->XMLnumpp[*irom1 - nprop - 1] = cs_gui_get_model_property_number(model, cs_coal_combustion_properties[IROM1]);
/* YM_CHX1M */
vars->XMLnumpp[ym1[0] - nprop - 1] = cs_gui_get_model_property_number(model, cs_coal_combustion_properties[YM_CHX1M]);
/* YM_CHX2M */
vars->XMLnumpp[ym1[1] - nprop - 1] = cs_gui_get_model_property_number(model, cs_coal_combustion_properties[YM_CHX2M]);
/* YM_CO */
vars->XMLnumpp[ym1[2] - nprop - 1] = cs_gui_get_model_property_number(model, cs_coal_combustion_properties[YM_CO]);
/* YM_O2 */
vars->XMLnumpp[ym1[3] - nprop - 1] = cs_gui_get_model_property_number(model, cs_coal_combustion_properties[YM_O2]);
/* YM_CO2 */
vars->XMLnumpp[ym1[4] - nprop - 1] = cs_gui_get_model_property_number(model, cs_coal_combustion_properties[YM_CO2]);
/* YM_H2O */
vars->XMLnumpp[ym1[5] - nprop - 1] = cs_gui_get_model_property_number(model, cs_coal_combustion_properties[YM_H2O]);
/* YM_N2 */
vars->XMLnumpp[ym1[6] - nprop - 1] = cs_gui_get_model_property_number(model, cs_coal_combustion_properties[YM_N2]);
/* IMEL */
vars->XMLnumpp[*imel - nprop - 1] = cs_gui_get_model_property_number(model, cs_coal_combustion_properties[IMEL]);
/* ITEMP2 boucle sur les classes */
BFT_MALLOC(name, strlen(cs_coal_combustion_properties[ITEMP2])+1 + 2, char);
BFT_MALLOC(snumpp, 1 + 2, char);
strcpy(name,cs_coal_combustion_properties[ITEMP2]);
for (i = 0; i < *nclass; i++) {
sprintf(snumpp,"%2.2i",i+1);
strcat(name, snumpp);
vars->XMLnumpp[itemp2[i] - nprop - 1] = cs_gui_get_model_property_number(model, name);
strcpy(name, cs_coal_combustion_properties[ITEMP2]);
}
/* IX2 boucle sur les classes */
BFT_REALLOC(name, strlen(cs_coal_combustion_properties[IX2])+1 + 2, char);
strcpy(name,cs_coal_combustion_properties[IX2]);
for (i = 0; i < *nclass; i++) {
sprintf(snumpp,"%2.2i",i+1);
strcat(name, snumpp);
vars->XMLnumpp[ix2[i] - nprop - 1] = cs_gui_get_model_property_number(model, name);
strcpy(name, cs_coal_combustion_properties[IX2]);
}
/* IROM2 boucle sur les classes */
BFT_REALLOC(name, strlen(cs_coal_combustion_properties[IROM2])+1 + 2, char);
strcpy(name,cs_coal_combustion_properties[IROM2]);
for (i = 0; i < *nclass; i++) {
sprintf(snumpp,"%2.2i",i+1);
strcat(name, snumpp);
vars->XMLnumpp[irom2[i] - nprop - 1] = cs_gui_get_model_property_number(model, name);
strcpy(name, cs_coal_combustion_properties[IROM2]);
}
/* IDIAM2 boucle sur les classes */
BFT_REALLOC(name, strlen(cs_coal_combustion_properties[IDIAM2])+1 + 2, char);
strcpy(name,cs_coal_combustion_properties[IDIAM2]);
for (i = 0; i < *nclass; i++) {
sprintf(snumpp,"%2.2i",i+1);
strcat(name, snumpp);
vars->XMLnumpp[idiam2[i] - nprop - 1] = cs_gui_get_model_property_number(model, name);
strcpy(name, cs_coal_combustion_properties[IDIAM2]);
}
/* IGMDCH boucle sur les classes */
BFT_REALLOC(name, strlen(cs_coal_combustion_properties[IGMDCH])+1 + 2, char);
strcpy(name,cs_coal_combustion_properties[IGMDCH]);
for (i = 0; i < *nclass; i++) {
sprintf(snumpp,"%2.2i",i+1);
strcat(name, snumpp);
vars->XMLnumpp[igmdch[i] - nprop - 1] = cs_gui_get_model_property_number(model, name);
strcpy(name, cs_coal_combustion_properties[IGMDCH]);
}
/* IGMDV1 boucle sur les classes */
BFT_REALLOC(name, strlen(cs_coal_combustion_properties[IGMDV1])+1 + 2, char);
strcpy(name,cs_coal_combustion_properties[IGMDV1]);
for (i = 0; i < *nclass; i++) {
sprintf(snumpp,"%2.2i",i+1);
strcat(name, snumpp);
vars->XMLnumpp[igmdv1[i] - nprop - 1] = cs_gui_get_model_property_number(model, name);
strcpy(name, cs_coal_combustion_properties[IGMDV1]);
}
/* IGMDV2 boucle sur les classes */
BFT_REALLOC(name, strlen(cs_coal_combustion_properties[IGMDV2])+1 + 2, char);
strcpy(name,cs_coal_combustion_properties[IGMDV2]);
for (i = 0; i < *nclass; i++) {
sprintf(snumpp,"%2.2i",i+1);
strcat(name, snumpp);
vars->XMLnumpp[igmdv2[i] - nprop - 1] = cs_gui_get_model_property_number(model, name);
strcpy(name, cs_coal_combustion_properties[IGMDV2]);
}
/* IGMHET boucle sur les classes */
BFT_REALLOC(name, strlen(cs_coal_combustion_properties[IGMHET])+1 + 2, char);
strcpy(name,cs_coal_combustion_properties[IGMHET]);
for (i = 0; i < *nclass; i++) {
sprintf(snumpp,"%2.2i",i+1);
strcat(name, snumpp);
vars->XMLnumpp[igmhet[i] - nprop - 1] = cs_gui_get_model_property_number(model, name);
strcpy(name, cs_coal_combustion_properties[IGMHET]);
}
/* ILUMI */
vars->XMLnumpp[*ilumi - nprop - 1] = cs_gui_get_model_property_number(model, cs_coal_combustion_properties[ILUMI]);
BFT_FREE(name);
BFT_FREE(snumpp);
BFT_FREE(model);
BFT_FREE(modelvalue);
#if _XML_DEBUG_
bft_printf(_("==>CSCPPP\n"));
for (i = 0; i < vars->nsalpp; i++)
bft_printf(_("--isca , iscaXML : %i, %i\n"), i ,vars->XMLnumpp[ i ]);
#endif
}
/*------------------------------------------------------------------------------------
* Indirection entre la numérotation noyau et la numérotation XML des scalaires model
*------------------------------------------------------------------------------------*/
void CS_PROCF (cscpsc, CSCPSC)
(
int *const ncharb,
int *const nclass,
int *const ihm,
int *const ih2,
int *const inp,
int *const ixch,
int *const ixck,
int *const if1m,
int *const if2m,
int *const if3m,
int *const if4p2m
)
{
int i = 0;
char * name = NULL;
char * model = NULL;
char * modelvalue = NULL;
char * snumsca = NULL;
cs_gui_get_activ_thermophysical_model(&model, &modelvalue);
BFT_MALLOC(vars->XMLnumsca, vars->nscapp, int);
/* Remplissage du tableau d'indirection en respectant la numérotation du noyau */
/* IHM */
vars->XMLnumsca[*ihm - vars->nscaus - 1] = cs_gui_get_model_scalar_number(model, cs_coal_combustion_scalar[IHM]);
/* Boucle sur les classes IH2, INP, IXCH, IXCK */
BFT_MALLOC(snumsca, 1 + 2, char);
/* IH2 */
BFT_MALLOC(name, strlen(cs_coal_combustion_scalar[IH2])+1 + 2, char);
strcpy(name,cs_coal_combustion_scalar[IH2]);
for (i = 0; i < *nclass; i++) {
sprintf(snumsca,"%2.2i",i+1);
strcat(name, snumsca);
vars->XMLnumsca[ ih2[i] - vars->nscaus - 1 ] = cs_gui_get_model_scalar_number(model, name);
strcpy(name,cs_coal_combustion_scalar[IH2]);
}
/* INP */
BFT_REALLOC(name, strlen(cs_coal_combustion_scalar[INP])+1 + 2, char);
strcpy(name,cs_coal_combustion_scalar[INP]);
for (i = 0; i < *nclass; i++) {
sprintf(snumsca,"%2.2i",i+1);
strcat(name, snumsca);
vars->XMLnumsca[ inp[i] - vars->nscaus - 1 ] = cs_gui_get_model_scalar_number(model, name);
strcpy(name,cs_coal_combustion_scalar[INP]);
}
/* IXCH */
BFT_REALLOC(name, strlen(cs_coal_combustion_scalar[IXCH])+1 + 2, char);
strcpy(name,cs_coal_combustion_scalar[IXCH]);
for (i = 0; i < *nclass; i++) {
sprintf(snumsca,"%2.2i",i+1);
strcat(name, snumsca);
vars->XMLnumsca[ ixch[i] - vars->nscaus - 1 ] = cs_gui_get_model_scalar_number(model, name);
strcpy(name,cs_coal_combustion_scalar[IXCH]);
}
/* IXCK */
BFT_REALLOC(name, strlen(cs_coal_combustion_scalar[IXCH])+1 + 2, char);
strcpy(name,cs_coal_combustion_scalar[IXCK]);
for (i = 0; i < *nclass; i++) {
sprintf(snumsca,"%2.2i",i+1);
strcat(name, snumsca);
vars->XMLnumsca[ ixck[i] - vars->nscaus - 1 ] = cs_gui_get_model_scalar_number(model, name);
strcpy(name,cs_coal_combustion_scalar[IXCK]);
}
/* Boucle sur les charbons IFM1 IFM2 */
BFT_REALLOC(name, strlen(cs_coal_combustion_scalar[IF1M])+1 + 2, char);
strcpy(name,cs_coal_combustion_scalar[IF1M]);
for (i = 0; i < *ncharb; i++) {
sprintf(snumsca,"%2.2i",i+1);
strcat(name, snumsca);
vars->XMLnumsca[ if1m[i] - vars->nscaus - 1 ] = cs_gui_get_model_scalar_number(model, name);
strcpy(name,cs_coal_combustion_scalar[IF1M]);
}
BFT_REALLOC(name, strlen(cs_coal_combustion_scalar[IF2M])+1 + 2, char);
strcpy(name,cs_coal_combustion_scalar[IF2M]);
for (i = 0; i < *ncharb; i++) {
sprintf(snumsca,"%2.2i",i+1);
strcat(name, snumsca);
vars->XMLnumsca[ if2m[i] - vars->nscaus - 1 ] = cs_gui_get_model_scalar_number(model, name);
strcpy(name,cs_coal_combustion_scalar[IF2M]);
}
/* IF3M */
vars->XMLnumsca[ *if3m - vars->nscaus - 1 ] = cs_gui_get_model_scalar_number(model, cs_coal_combustion_scalar[IF3M]);
/* IF4P2M */
vars->XMLnumsca[ *if4p2m - vars->nscaus - 1 ] = cs_gui_get_model_scalar_number(model, cs_coal_combustion_scalar[IF4P2M]);
BFT_FREE(name);
BFT_FREE(snumsca);
BFT_FREE(model);
BFT_FREE(modelvalue);
#if _XML_DEBUG_
bft_printf(_("==>CSCPPP\n"));
for (i=0; i<vars->nscapp; i++) {
bft_printf(_("--isca, iscaXML : %i, %i\n"),i ,vars->XMLnumsca[i]);
}
#endif
}
/*----------------------------------------------------------------------------
* Traitement des conditions aux limites pour le charbon
*----------------------------------------------------------------------------*/
void CS_PROCF (uicpcl, UICPCL)(const int *const nozppm,
const int *const ncharm,
const int *const ncharb,
const int *const nclpch,
const int *const nfabor,
const int *const nfml,
const int *const iindef,
const int *const ientre,
const int *const iparoi,
const int *const isymet,
const int *const isolib,
const int *const ifmfbr,
const int *const iprfml,
int *const itypfb,
int *const icodcl,
double *const rcodcl,
int *const ientat,
int *const iqimp,
double *const qimpat,
double *const timpat,
int *const ientcp,
double *const qimpcp,
double *const timpcp,
double *const distch,
int *const icalke,
double *const dh,
double *const xintur,
int *const izfppp,
const double *const surfbo
)
{
int iphas =0;
int ifbr;
int ivar;
int izone, icharb, isca, ith_zone, zones, ifac;
int i;
int k;
int n;
int nscalth = 0;
int numvar;
char *choice = NULL;
char *label = NULL;
char *nature = NULL;
char *description = NULL;
int *faces_list = NULL;
int faces = 0;
nscalth = 0;
numvar = vars->nvar - vars->nscaus - vars->nscapp;
zones = cs_gui_boundary_zones_number();
/* Fisrt iteration only : memory allocation */
if (boundaries == NULL){
BFT_MALLOC(boundaries, 1, cs_boundary_t);
BFT_MALLOC(boundaries->label, zones, char* );
BFT_MALLOC(boundaries->nature, zones, char* );
BFT_MALLOC(boundaries->type_code, vars->nvar, int* );
BFT_MALLOC(boundaries->values, vars->nvar, cs_val_t* );
BFT_MALLOC(boundaries->ientat, zones, int );
BFT_MALLOC(boundaries->iqimp, zones, int );
BFT_MALLOC(boundaries->qimpat, zones, double );
BFT_MALLOC(boundaries->timpat, zones, double );
BFT_MALLOC(boundaries->ientcp, zones, int );
BFT_MALLOC(boundaries->icalke, zones, int );
BFT_MALLOC(boundaries->dh, zones, double );
BFT_MALLOC(boundaries->xintur, zones, double );
BFT_MALLOC(boundaries->qimpcp, zones, double* );
BFT_MALLOC(boundaries->timpcp, zones, double* );
BFT_MALLOC(boundaries->distch, zones, cs_coal_ashes_ratio_t*);
for (izone = 0; izone < zones; izone++) {
BFT_MALLOC(boundaries->qimpcp[izone], *ncharb, double);
BFT_MALLOC(boundaries->timpcp[izone], *ncharb, double);
BFT_MALLOC(boundaries->distch[izone], *ncharb, cs_coal_ashes_ratio_t);
for (icharb = 0; icharb < *ncharb; icharb++) {
BFT_MALLOC((boundaries->distch[izone][icharb]).ratio,
nclpch[icharb],
double);
}
}
for (ivar = 0; ivar < vars->nvar; ivar++) {
n = vars->rtp_nbr[ivar];
BFT_MALLOC(boundaries->type_code[n], zones, int);
BFT_MALLOC(boundaries->values[n], zones, cs_val_t);
}
for (izone = 0; izone < zones; izone++) {
boundaries->iqimp[izone] = 0;
boundaries->ientat[izone] = 0;
boundaries->ientcp[izone] = 0;
boundaries->dh[izone] = 0;
boundaries->xintur[izone] = 0;
boundaries->icalke[izone] = 0;
boundaries->qimpat[izone] = 0;
boundaries->timpat[izone] = 0;
for (icharb = 0; icharb < *ncharb; icharb++) {
boundaries->qimpcp[izone][icharb] = 0;
boundaries->timpcp[izone][icharb] = 0;
for (k = 0; k < nclpch[icharb]; k++) {
(boundaries->distch[izone][icharb]).ratio[k] = 0;
}
}
}
/* Initialization of boundary->type_code and boundary->values */
for (ivar = 0; ivar < vars->nvar; ivar++) {
for (izone = 0; izone < zones; izone++) {
boundaries->type_code[ivar][izone] = -1;
boundaries->values[ivar][izone].val1 = 0.;
boundaries->values[ivar][izone].val2 = 1.e30;
boundaries->values[ivar][izone].val3 = 0.;
}
}
for (izone = 0; izone < zones; izone++) {
/* nature, label and description (color or group)
of the ith initialization zone */
ith_zone = izone + 1;
nature = cs_gui_boundary_zone_nature(ith_zone);
label = cs_gui_boundary_zone_label(ith_zone);
BFT_MALLOC(boundaries->label[izone], strlen(label)+1, char);
strcpy(boundaries->label[izone], label);
BFT_MALLOC(boundaries->nature[izone], strlen(nature)+1, char);
strcpy(boundaries->nature[izone], nature);
/* description = cs_gui_boundary_zone_description(label); */
if (cs_gui_strcmp(nature, "inlet")) {
/* list of faces building */
cs_gui_faces_list_building(nature,
label,
&faces,
&faces_list,
nfabor,
nfml,
ifmfbr,
iprfml);
/* INLET: VELOCITY */
choice = cs_gui_boundary_choice("inlet",
label,
"velocity_pressure",
NULL);
if (cs_gui_strcmp(choice, "coal_flow")) {
boundaries->ientcp[izone] = 1;
boundaries->iqimp[izone] = 1;
cs_gui_coal_boundary_coalflow(izone, ncharb, nclpch);
cs_gui_boundary_flow(label, izone, faces, faces_list, surfbo);
} else if (cs_gui_strcmp(choice, "flow1")) {
boundaries->ientat[izone] = 1;
boundaries->iqimp[izone] = 1;
cs_gui_boundary_flow(label, izone, faces, faces_list, surfbo);
}
BFT_FREE(faces_list);
BFT_FREE(choice);
/* INLET: TURBULENCE */
choice = cs_gui_boundary_choice("inlet",
label,
"turbulence",
NULL);
cs_gui_coal_boundary_turbulence(choice, izone);
BFT_FREE(choice);
/* INLET: USER SCALARS */
for (isca=0 ; isca < vars->nscaus ; isca++) {
/* selon le type et choice lu, on va lire les valeurs des scalaires */
cs_gui_boundary_value_scalar("inlet",
"users",
izone,
numvar+isca,
nscalth,
isca);
} /* for isca */
} else if (cs_gui_strcmp(nature, "wall")) {
/* WALL: VELOCITY */
choice = cs_gui_boundary_choice("wall",
label,
"velocity_pressure",
NULL);
if (cs_gui_strcmp(choice, "on")) {
for (ivar = 1; ivar < 4; ivar++)
cs_gui_boundary_dirichlet("wall",
label,
vars->char2[ivar],
izone,
ivar);
}
BFT_FREE(choice);
/* WALL: THERMAL AND USER SCALARS */
for (isca = 0; isca < vars->nscaus; isca++) {
/* selon le type et choice lu, on va lire les valeurs des scalaires */
cs_gui_boundary_value_scalar("wall",
"users",
izone,
numvar+isca,
nscalth,
isca);
} /* for isca */
} else if (cs_gui_strcmp(nature, "outlet")) {
/* OUTLET: THERMAL AND USER SCALARS */
for (isca=0; isca < vars->nscaus ; isca++) {
/* selon le type et choice lu, on va lire les valeurs des scalaires */
cs_gui_boundary_value_scalar("outlet",
"users",
izone,
numvar+isca,
nscalth,
isca);
} /* for isca */
} /* if (cs_gui_strcmp(nature, "outlet")) */
} /* for izones */
} /* if (boundaries == NULL)*/
/* A chaque iteration, boucle sur les faces de bord :
on remplit itypfb, rcodcl et icodcl a partir des tableaux
de la structures conditions.limites definie
dans la premiere partie de la fonction */
/* rdoccl[k][j][i] = rcodcl[ k * dim1 *dim2 + j *dim1 + i] */
/* Remettre a jour tous les tableaux dependant des zones (ICALCKE, IENTAT ...)
des zones car ils sont écrasés à chaque pas de temps dans PPPRCL !!! */
for (izone = 0; izone < zones; izone++) {
ith_zone = izone + 1;
nature = cs_gui_boundary_zone_nature(ith_zone);
if (cs_gui_strcmp(nature, "inlet")) {
iqimp[izone] = boundaries->iqimp[izone];
ientat[izone] = boundaries->ientat[izone];
ientcp[izone] = boundaries->ientcp[izone];
dh[izone] = boundaries->dh[izone];
xintur[izone] = boundaries->xintur[izone];
icalke[izone] = boundaries->icalke[izone];
qimpat[izone] = boundaries->qimpat[izone];
timpat[izone] = boundaries->timpat[izone];
for (icharb = 0; icharb < *ncharb; icharb++) {
qimpcp[icharb * (*nozppm) +izone] = boundaries->qimpcp[izone][icharb];
timpcp[icharb * (*nozppm) +izone] = boundaries->timpcp[izone][icharb];
for (k = 0; k < nclpch[icharb]; k++) {
distch[k * (*nozppm) * (*ncharm) +icharb * (*nozppm) +izone]
= (boundaries->distch[izone][icharb]).ratio[k];
}
}
} /* if (cs_gui_strcmp(nature, "inlet")) */
} /* for izone */
for (izone=0 ; izone < zones ; izone++) {
ith_zone = izone + 1;
nature = boundaries->nature[izone];
label = boundaries->label[izone];
/* description = cs_gui_boundary_zone_description(label); */
/* list of faces building */
cs_gui_faces_list_building(nature,
label,
&faces,
&faces_list,
nfabor,
nfml,
ifmfbr,
iprfml);
/* BFT_FREE(description); */
if (cs_gui_strcmp(nature, "inlet")) {
for (ifac = 0; ifac < faces; ifac++) {
ifbr = faces_list[ifac];
izfppp[ifbr] = ith_zone;
itypfb[iphas *(*nfabor) +ifbr] = *ientre;
for (ivar = 0; ivar < vars->nvar; ivar++) {
rcodcl[0 * (*nfabor * (vars->nvar)) + ivar * (*nfabor) + ifbr]
= boundaries->values[ivar][izone].val1 ;
}
}
} else if (cs_gui_strcmp(nature, "wall")) {
for (ifac = 0; ifac < faces; ifac++) {
ifbr = faces_list[ifac];
izfppp[ifbr] = ith_zone;
itypfb[iphas *(*nfabor) +ifbr] = *iparoi;
}
for (ivar = 0; ivar < vars->nvar; ivar++) {
switch (boundaries->type_code[ivar][izone]) {
case NEUMANN :
for (ifac = 0; ifac < faces; ifac++) {
ifbr = faces_list[ifac];
icodcl[ivar *(*nfabor) + ifbr ] = 3 ;
rcodcl[2 * (*nfabor * (vars->nvar)) + ivar * (*nfabor) + ifbr]
= boundaries->values[ivar][izone].val3 ;
}
break;
case DIRICHLET :
for (ifac = 0; ifac < faces; ifac++) {
ifbr = faces_list[ifac];
icodcl[ivar *(*nfabor) + ifbr ] = 5 ;
rcodcl[0 * (*nfabor * (vars->nvar)) + ivar * (*nfabor) + ifbr]
= boundaries->values[ivar][izone].val1 ;
}
break;
case COEF_ECHANGE :
for (ifac = 0; ifac < faces; ifac++) {
ifbr = faces_list[ifac];
icodcl[ivar *(*nfabor) + ifbr ] = 5 ;
rcodcl[0 * (*nfabor * (vars->nvar)) + ivar * (*nfabor) + ifbr]
= boundaries->values[ivar][izone].val1 ;
rcodcl[1 * (*nfabor * (vars->nvar)) + ivar * (*nfabor) + ifbr]
= boundaries->values[ivar][izone].val2 ;
}
break;
}
}
} else if (cs_gui_strcmp(nature, "outlet")) {
for (ifac = 0; ifac < faces; ifac++) {
ifbr = faces_list[ifac];
izfppp[ifbr] = ith_zone;
itypfb[iphas *(*nfabor) +ifbr] = *isolib;
}
for (ivar = numvar; ivar < vars->nvar; ivar++) {
switch (boundaries->type_code[ivar][izone]) {
case DIRICHLET :
for (ifac = 0; ifac < faces; ifac++) {
ifbr = faces_list[ifac];
icodcl[ivar *(*nfabor) + ifbr ] = 5 ;
rcodcl[0 * (*nfabor * (vars->nvar)) + ivar * (*nfabor) + ifbr]
= boundaries->values[ivar][izone].val1 ;
}
break;
}
}
} else if (cs_gui_strcmp(nature, "symmetry")) {
for (n = 0; n < faces; n++) {
ifbr = faces_list[n];
izfppp[ifbr] = ith_zone;
itypfb[iphas *(*nfabor) +ifbr] = *isymet;
}
} else if (cs_gui_strcmp(nature, "undefined")) {
for (n = 0; n < faces; n++) {
ifbr = faces_list[n];
izfppp[ifbr] = ith_zone;
itypfb[iphas *(*nfabor) +ifbr] = *iindef;
}
} else
bft_error(__FILE__, __LINE__, 0,
_("boundary nature %s is unknown \n"), nature);
BFT_FREE(faces_list);
} /* for izone */
#if _XML_DEBUG_
bft_printf(_("==>UICPCL\n"));
bft_printf(_("--boundary zones number: %i\n"), zones);
for (izone=0 ; izone < zones ; izone++) {
nature = boundaries->nature[izone];
label = boundaries->label[izone];
cs_gui_faces_list_building(nature,
label,
&faces,
&faces_list,
nfabor,
nfml,
ifmfbr,
iprfml);
BFT_FREE(faces_list);
bft_printf(_("---zone %i label: %s\n"), izone, label);
bft_printf(_("---zone %i nature: %s\n"), izone, nature);
bft_printf(_("---zone %i number of faces: %i\n"), izone, faces);
n = cs_gui_boundary_zone_reference_number(nature, label);
bft_printf(_("----localization: "));
for (i=1 ; i < n+1 ; i++) {
bft_printf(_("%i "), cs_gui_boundary_zone_reference(nature, label, i));
}
bft_printf(_("\n"));
bft_printf(_("---zone %i rate of flow: %i\n"), izone, boundaries->iqimp[izone]);
bft_printf(_("---zone %i air inlet: %i\n"), izone, boundaries->ientat[izone]);
bft_printf(_("---zone %i coal inlet: %i\n"), izone, boundaries->ientcp[izone]);
bft_printf(_("---zone %i turbulent choice: %i\n"), izone, boundaries->icalke[izone]);
bft_printf(_("---zone %i hydraulic diameter: %f\n"), izone, boundaries->dh[izone]);
bft_printf(_("---zone %i turbulent intensity: %f\n"), izone, boundaries->xintur[izone]);
bft_printf(_("---zone %i air rate of flow: %f\n"), izone, boundaries->qimpat[izone]);
bft_printf(_("---zone %i air temperature: %f\n"), izone, boundaries->timpat[izone]);
for (icharb = 0; icharb < *ncharb; icharb++) {
bft_printf(_("---zone %i coal %i rate of flow: %f\n"),
izone, icharb, boundaries->qimpcp[izone][icharb]);
bft_printf(_("---zone %i coal %i temperature: %f\n"),
izone, icharb, boundaries->timpcp[izone][icharb]);
for (k = 0; k < nclpch[icharb]; k++) {
bft_printf(_("---zone %i coal %i class %i ratio: %f\n"),
izone, icharb, k,
(boundaries->distch[izone][icharb]).ratio[k]);
}
}
}
#endif
}
/*----------------------------------------------------------------------------
*
*----------------------------------------------------------------------------*/
void CS_PROCF (uicpcv, UICPCV)(const int *const nfabor,
const int *const nfml,
const int *const iindef,
const int *const ientre,
const int *const iparoi,
const int *const isymet,
const int *const isolib,
const int *const ifmfbr,
const int *const iprfml,
int *const itypfb,
int *const izfppp)
{
int ifbr, ifac;
int izone, ith_zone, zones;
int inature;
char *label = NULL;
char *nature = NULL;
char *description = NULL;
int *faces_list = NULL;
int faces = 0, iphas = 0;
zones = cs_gui_boundary_zones_number();
for (izone=0 ; izone < zones ; izone++) {
ith_zone = izone + 1;
nature = boundaries->nature[izone];
label = boundaries->label[izone];
/* description = cs_gui_boundary_zone_description(label);*/
/* list of faces building */
cs_gui_faces_list_building(nature,
label,
&faces,
&faces_list,
nfabor,
nfml,
ifmfbr,
iprfml);
/* BFT_FREE(description);*/
if (cs_gui_strcmp(nature, "inlet")) {
inature = *ientre;
} else if (cs_gui_strcmp(nature, "wall")) {
inature = *iparoi;
} else if (cs_gui_strcmp(nature, "outlet")) {
inature = *isolib;
} else if (cs_gui_strcmp(nature, "symmetry")) {
inature = *isymet;
} else if (cs_gui_strcmp(nature, "undefined")) {
inature = *iindef;
} else
bft_error(__FILE__, __LINE__, 0,
_("boundary nature %s is unknown \n"), nature);
for (ifac = 0; ifac < faces; ifac++) {
ifbr = faces_list[ifac];
if (izfppp[ifbr] != ith_zone)
bft_error(__FILE__, __LINE__, 0,
_("The zone %s has not the same id number \n"
"between the GUI (number: %i) and \n"
"the user subroutine USCPCL (number: %i). \n"
"Please do not change this id number \n"
"(IZFPPP fortran array) in the user \n"
"subroutine USCPCL\n"), label, ith_zone, izfppp[ifbr]);
if (itypfb[iphas *(*nfabor) +ifbr] != inature)
bft_error(__FILE__, __LINE__, 0,
_("The zone %s has not the same nature \n"
"between the GUI (nature: %s) and \n"
"the user subroutine USCPCL. \n"
"Please do not change this nature \n"
"(ITYPFB fortran array) in the user \n"
"subroutine USCPCL\n"), label, nature);
} /* for ifac */
BFT_FREE(faces_list);
} /* for izone */
}
/*----------------------------------------------------------------------------
*
*----------------------------------------------------------------------------*/
void cs_gui_coal_boundary_coalflow(const int izone,
const int *const ncharb,
const int *const nclpch)
{
int icharb;
int iratio;
char *path1 = NULL;
char *path2 = NULL;
char *path3 = NULL;
char *path4 = NULL;
char *path5 = NULL;
char *coalname = NULL;
char *classname = NULL;
double value;
path1 = cs_xpath_init_path();
cs_xpath_add_elements(&path1, 2, "boundary_conditions", "inlet");
cs_xpath_add_test_attribute(&path1, "label", boundaries->label[izone]);
cs_xpath_add_elements(&path1, 2, "velocity_pressure", "coal_flow");
BFT_MALLOC(coalname, 4 + 2 + 1, char);
BFT_MALLOC(classname, 5 + 2 + 1, char);
for (icharb = 0; icharb < *ncharb; icharb++) {
BFT_MALLOC(path2, strlen(path1) + 1, char);
strcpy(path2, path1);
sprintf(coalname, "%.4s%2.2i", "coal", icharb+1);
cs_xpath_add_test_attribute(&path2, "name", coalname);
BFT_MALLOC(path3, strlen(path2) + 1, char);
strcpy(path3, path2);
BFT_MALLOC(path4, strlen(path2) + 1, char);
strcpy(path4, path2);
/* flow rate */
cs_xpath_add_element(&path3, "flow1");
cs_xpath_add_function_text(&path3);
if (cs_gui_get_double(path3, &value)) {
boundaries->qimpcp[izone][icharb] = value;
}
/* temperature */
cs_xpath_add_element(&path4, "temperature");
cs_xpath_add_function_text(&path4);
if (cs_gui_get_double(path4, &value)) {
boundaries->timpcp[izone][icharb] = value;
}
/* ratio */
for (iratio=0; iratio < nclpch[icharb]; iratio++) {
BFT_MALLOC(path5, strlen(path2) + 1, char);
strcpy(path5, path2);
cs_xpath_add_element(&path5, "ratio");
sprintf(classname, "%.5s%2.2i", "class", iratio+1);
cs_xpath_add_test_attribute(&path5, "name", classname);
cs_xpath_add_function_text(&path5);
if (cs_gui_get_double(path5, &value)) {
(boundaries->distch[izone][icharb]).ratio[iratio] = value;
}
BFT_FREE(path5);
}
BFT_FREE(path2);
BFT_FREE(path3);
BFT_FREE(path4);
}
BFT_FREE(path1);
BFT_FREE(coalname);
BFT_FREE(classname);
}
void cs_gui_coal_boundary_turbulence(const char *const choice,
const int izone)
{
char *path1 = NULL;
char *path2 = NULL;
double result;
if (cs_gui_strcmp(choice, "hydraulic_diameter")) {
boundaries->icalke[izone] = 1 ;
} else if(cs_gui_strcmp(choice, "turbulent_intensity")) {
boundaries->icalke[izone] = 2 ;
} else {
return;
}
path1 = cs_xpath_init_path();
cs_xpath_add_elements(&path1, 2, "boundary_conditions", "inlet");
cs_xpath_add_test_attribute(&path1, "label", boundaries->label[izone]);
cs_xpath_add_element(&path1, "turbulence");
BFT_MALLOC(path2, strlen(path1) + 1, char);
strcpy(path2, path1);
cs_xpath_add_element(&path1, "hydraulic_diameter");
cs_xpath_add_function_text(&path1);
if (cs_gui_get_double(path1, &result)) {
boundaries->dh[izone] = result;
}
if(cs_gui_strcmp(choice, "turbulent_intensity")) {
cs_xpath_add_element(&path2, "turbulent_intensity");
cs_xpath_add_function_text(&path2);
if (cs_gui_get_double(path2, &result)) {
boundaries->xintur[izone] = result * 0.01;
}
BFT_FREE(path2);
}
BFT_FREE(path1);
}
/*============================================================================
* Private functions
*============================================================================*/
/*-----------------------------------------------------------------------------
* Copy a variable name to private variable names array
*
* parameters:
* varname --> name or label of the variable/scalar/property
* ipp --> index from the fortran array associated to varname
*----------------------------------------------------------------------------*/
static void _cs_gui_copy_varname(const char *varname, int ipp)
{
size_t l;
if (ipp < 1 || ipp > _cs_gui_last_var)
bft_error(__FILE__, __LINE__, 0,
_("Variable index %d out of bounds (1 to %d)"),
ipp, _cs_gui_last_var);
l = strlen(varname);
if (_cs_gui_var_name[ipp-1] == NULL)
BFT_MALLOC(_cs_gui_var_name[ipp-1], l + 1, char);
else if (strlen(_cs_gui_var_name[ipp-1]) != l)
BFT_REALLOC(_cs_gui_var_name[ipp-1], l + 1, char);
strcpy(_cs_gui_var_name[ipp-1], varname);
}
/*----------------------------------------------------------------------------
* Turbulence model parameters.
*
* parameters:
* param --> name of the parameters
* keyword <-- turbulence model parameter
*----------------------------------------------------------------------------*/
void cs_gui_advanced_options_turbulence(const char *const param,
int *const keyword)
{
char *path = NULL;
int result;
path = cs_xpath_init_path();
cs_xpath_add_elements(&path, 3, "thermophysical_models", "turbulence", param);
if (cs_gui_strcmp("gravity_terms", param)) {
cs_xpath_add_attribute(&path, "status");
if (cs_gui_get_status(path, &result)) *keyword = result;
} else if (cs_gui_strcmp("scale_model", param)) {
cs_xpath_add_function_text(&path);
if (cs_gui_get_int(path, &result)) *keyword = result;
} else
bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s \n"), path);
BFT_FREE(path);
}
/*-----------------------------------------------------------------------------
* indique si le scalaire thermique est active
*----------------------------------------------------------------------------*/
int cs_gui_thermal_scalar(void)
{
char *model_name = NULL;
int test;
model_name = cs_gui_get_thermophysical_model("thermal_scalar");
if (cs_gui_strcmp(model_name, "off"))
test = 0;
else {
if (cs_gui_strcmp(model_name, cs_thermal_scalar_name[ENTHALPY]))
test = 2 ;
else if (cs_gui_strcmp(model_name, cs_thermal_scalar_name[TEMPERATURE_KELVIN]))
test = 1 ;
else if (cs_gui_strcmp(model_name, cs_thermal_scalar_name[TEMPERATURE_CELSIUS]))
test = -1 ;
else
bft_error(__FILE__, __LINE__, 0,
_("Invalid thermal model: %s\n"), model_name);
}
BFT_FREE(model_name);
return test;
}
/*============================================================================
* Fonctions liees a la balise thermophysical
*============================================================================*/
/*-----------------------------------------------------------------------------
* Retourne le nombre de zones d'initialisation
*----------------------------------------------------------------------------*/
int cs_gui_initialization_zones_number(void)
{
int zones = 0;
char *path = NULL;
path = cs_xpath_init_path();
cs_xpath_add_elements(&path, 3,"thermophysical_models", "initialization", "zone");
zones = cs_gui_get_nb_element(path);
BFT_FREE(path);
return zones;
}
/*-----------------------------------------------------------------------------
* Retourne le label des variables situees dans
* les sous-balises de THERMOPHYSICAL
*----------------------------------------------------------------------------*/
char *cs_gui_variable_label
(
const char *const variable
)
{
char *path = NULL;
char *label = NULL;
path = cs_xpath_short_path();
cs_xpath_add_element(&path, "variable");
cs_xpath_add_test_attribute(&path, "name", variable);
cs_xpath_add_attribute(&path, "label");
label = cs_gui_get_attribute_value(path);
BFT_FREE(path);
return label;
}
/*-----------------------------------------------------------------------------
* La fonction retourne 1 si la valeur numero i de la variable existe
* 0 sinon
* La valeur est stockee dans value
*----------------------------------------------------------------------------*/
void cs_gui_variable_value(const char *const variable_type,
const char *const value_type,
double *const value)
{
char *path = NULL;
double result = 0.0;
path = cs_xpath_short_path();
cs_xpath_add_element(&path, "variable");
cs_xpath_add_test_attribute(&path, "name", variable_type);
cs_xpath_add_element(&path, value_type);
cs_xpath_add_function_text(&path);
if (cs_gui_get_double(path, &result)) *value = result;
BFT_FREE(path);
}
/*-----------------------------------------------------------------------------
* La fonction retourne le numero de la sonde situe dans
* la balise "probe_recording"
*----------------------------------------------------------------------------*/
int cs_gui_variable_probe_name
(
const char *const variable,
int num_probe
)
{
char *path = NULL;
char *strvalue = NULL;
int intvalue;
path = cs_xpath_short_path();
cs_xpath_add_element(&path, "variable");
cs_xpath_add_test_attribute(&path, "name", variable);
cs_xpath_add_element_num(&path, "probe_recording", num_probe);
cs_xpath_add_attribute(&path, "name");
strvalue = cs_gui_get_attribute_value(path);
if (strvalue == NULL)
bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s \n"), path);
intvalue = atoi(strvalue);
BFT_FREE(strvalue);
BFT_FREE(path);
return intvalue;
}
/*-----------------------------------------------------------------------------
* Retourne la valeur de l'attribut status situe
* dans les sous-balises de variable
*----------------------------------------------------------------------------*/
void cs_gui_variable_status
(
const char *const variable,
const char *const value,
int *const keyword
)
{
char *path = NULL;
char *choice = NULL;
int result;
path = cs_xpath_short_path ();
cs_xpath_add_element(&path, "variable");
cs_xpath_add_test_attribute(&path, "name", variable);
cs_xpath_add_element(&path, value);
if (cs_gui_strcmp(value, "order_scheme")) {
cs_xpath_add_attribute(&path, "choice");
choice = cs_gui_get_attribute_value(path);
if (cs_gui_strcmp(choice, "centered"))
*keyword = 1;
else if (cs_gui_strcmp(choice, "solu"))
*keyword = 0;
BFT_FREE(choice);
} else {
cs_xpath_add_attribute(&path, "status");
if (cs_gui_get_status(path, &result)) {
*keyword = result;
if (cs_gui_strcmp(value, "slope_test")) {
if (result == 1) *keyword = 0;
if (result == 0) *keyword = 1;
}
}
}
BFT_FREE(path);
}
/*-----------------------------------------------------------------------------
* Retourne le nombre de sous-balises "probe recording" situees dans la balise
* <variable>
*----------------------------------------------------------------------------*/
int cs_gui_variable_number_probes
(
const char *const variable
)
{
char *path = NULL;
int nb_probes ;
path = cs_xpath_short_path();
cs_xpath_add_element(&path, "variable");
cs_xpath_add_test_attribute(&path, "name", variable);
cs_xpath_add_element(&path, "probe_recording");
nb_probes = cs_gui_get_nb_element(path);
BFT_FREE(path);
return nb_probes;
}
/*----------------------------------------------------------------------------
* Initialization choice of the turbulence variables parameters.
*
* parameters:
* param --> name of the parameters
* value <-- initialization choice
*----------------------------------------------------------------------------*/
void cs_gui_turbulence_initialization(const char *const param,
double *const value)
{
char *path = NULL;
double result;
path = cs_xpath_init_path();
cs_xpath_add_elements(&path, 4,
"thermophysical_models",
"turbulence",
"initialization",
param);
cs_xpath_add_function_text(&path);
if (cs_gui_get_double(path, &result)) *value = result;
BFT_FREE(path);
}
/*----------------------------------------------------------------------------
* Return the initialization choice of the turbulence variables.
*----------------------------------------------------------------------------*/
char *cs_gui_turbulence_initialization_choice(void)
{
char *path = NULL;
char *initialization_choice;
path = cs_xpath_init_path();
cs_xpath_add_elements(&path, 3,
"thermophysical_models",
"turbulence",
"initialization");
cs_xpath_add_attribute(&path, "choice");
initialization_choice = cs_gui_get_attribute_value(path);
BFT_FREE(path);
return initialization_choice;
}
/*============================================================================
* Fonctions liees aux scalaires
*============================================================================*/
/*-----------------------------------------------------------------------------
* Retourne le nombre de scalaires utilisateurs
*----------------------------------------------------------------------------*/
int cs_gui_get_number_user_scalar(void)
{
char *path = NULL;
int nb;
/* concatenation des chaines pour construire la requete */
path = cs_xpath_init_path();
cs_xpath_add_element(&path, cs_first_path_element[USER_SCALAR]);
cs_xpath_add_element(&path, cs_variable[SCALAR]);
/*Evaluation de la requete*/
nb = cs_gui_get_nb_element(path);
BFT_FREE(path);
return nb;
}
/*-----------------------------------------------------------------------------
* Retourne le nombre de scalaires model pour les physiques particulieres
*----------------------------------------------------------------------------*/
int cs_gui_get_number_model_scalar(const char* model)
{
char *path = NULL;
int nb;
/* Concatenation des chaines pour construire la requete */
path = cs_xpath_init_path();
cs_xpath_add_element(&path, cs_first_path_element[THERMOPHYSICAL_MODELS]);
cs_xpath_add_element(&path, model);
cs_xpath_add_element(&path, cs_variable[SCALAR]);
/* Evaluation de la requete */
nb = cs_gui_get_nb_element(path);
BFT_FREE(path);
return nb;
}
/*-----------------------------------------------------------------------------
* Retourne le nombre de proprietes model pour les physiques particulieres
*----------------------------------------------------------------------------*/
int cs_gui_get_number_model_properties(const char* model)
{
char *path = NULL;
int nb;
/* Concatenation des chaines pour construire la requete */
path = cs_xpath_init_path();
cs_xpath_add_element(&path, cs_first_path_element[THERMOPHYSICAL_MODELS]);
cs_xpath_add_element(&path, model);
cs_xpath_add_element(&path, cs_variable[PROPERTY]);
/* Evaluation de la requete */
nb = cs_gui_get_nb_element(path);
BFT_FREE(path);
return nb;
}
/*-----------------------------------------------------------------------------
* Donne le nom du scalaire dont le scalaire num_sca est la variance
*----------------------------------------------------------------------------*/
char *cs_gui_get_additional_scalar_variance(const int num_sca)
{
char *path = NULL;
char *scalar_variance = NULL;
/* Construction de la requete pour obtenir
le texte contenu dans la balise variance */
path = cs_xpath_init_path();
cs_xpath_add_element(&path,cs_first_path_element[USER_SCALAR]);
cs_xpath_add_element_num(&path,cs_variable[SCALAR],num_sca);
cs_xpath_add_element(&path, "variance");
cs_xpath_add_function_text(&path);
/* Evaluation de la requete */
scalar_variance = cs_gui_get_text_value(path);
BFT_FREE(path);
return scalar_variance ;
}
/*----------------------------------------------------------------------------
* Get the text value associated to a child markup from a scalar.
*
* parameters:
* label --> label of the scalar markup
* child --> name of the child markup
* value <-- value of text node contained in the child markup
*----------------------------------------------------------------------------*/
void cs_gui_scalar_value(const char *const label,
const char *const child,
double *const value)
{
char *path = NULL;
double result;
path = cs_xpath_short_path();
cs_xpath_add_element(&path, "scalar");
cs_xpath_add_test_attribute(&path, "label", label);
cs_xpath_add_element(&path, child);
cs_xpath_add_function_text(&path);
if (cs_gui_get_double(path, &result)) *value = result;
BFT_FREE(path);
}
/*-----------------------------------------------------------------------------
* Donne le coefficient de diffusion liees aux scalaire utilisateurs :
* La fonction retourne 1 si la valeur existe
* 0 sinon
* le resultat est stocke dans value
*----------------------------------------------------------------------------*/
void cs_gui_add_scalar_diffusion_coeff_value
(
const int scalar_num, /* Type de modele */
const cs_properties_t property, /* Valeur de la propriete */
const cs_values_t value_type, /* Type de valeur */
double *const value /* valeur de la variable */
)
{
char *path = NULL;
double result;
/* Construction de la requete */
path = cs_xpath_init_path();
cs_xpath_add_element(&path, cs_first_path_element[USER_SCALAR]);
cs_xpath_add_element_num(&path, cs_variable[SCALAR], scalar_num);
cs_xpath_add_element(&path, cs_variable[PROPERTY]);
cs_xpath_add_test_attribute(&path, "name", cs_properties_name[property]);
cs_xpath_add_element(&path, cs_values_name[value_type]);
cs_xpath_add_function_text(&path);
/* Evaluation de la requete */
if (cs_gui_get_double(path, &result))
*value = result;
BFT_FREE(path);
}
/*-----------------------------------------------------------------------------
* Nombre de sous-balise "probe_recording" pour les scalaires utilisateurs
*----------------------------------------------------------------------------*/
int cs_gui_additional_scalar_number_probes(const int scalar_num)
{
char *path = NULL;
int nb_probes ;
/* Construction de la requete */
path = cs_xpath_init_path();
cs_xpath_add_element(&path, cs_first_path_element[USER_SCALAR]);
cs_xpath_add_element_num(&path, cs_variable[SCALAR], scalar_num);
cs_xpath_add_element(&path, cs_values_name[PROBE_RECORDING]);
/* Evaluation de la requete */
nb_probes = cs_gui_get_nb_element(path);
BFT_FREE(path);
return nb_probes;
}
/*----------------------------------------------------------------------------
* Get the attribute value associated to a child markup from a scalar.
*
* parameters:
* label --> label of the scalar markup
* child --> name of the child markup
* value <-- value of attribute node contained in the
* child markup
*----------------------------------------------------------------------------*/
void cs_gui_scalar_attribute(const char *const label,
const char *const child,
int *const keyword)
{
char *path = NULL;
char *choice = NULL;
int result;
path = cs_xpath_short_path();
cs_xpath_add_element(&path, "scalar");
cs_xpath_add_test_attribute(&path, "label", label);
cs_xpath_add_element(&path, child);
if (cs_gui_strcmp(child, "order_scheme")) {
cs_xpath_add_attribute(&path, "choice");
choice = cs_gui_get_attribute_value(path);
if (cs_gui_strcmp(choice, "centered"))
*keyword = 1;
else if (cs_gui_strcmp(choice, "solu"))
*keyword = 0;
BFT_FREE(choice);
} else {
cs_xpath_add_attribute(&path, "status");
if (cs_gui_get_status(path, &result)) {
*keyword = result;
if (cs_gui_strcmp(child, "slope_test")) {
if (result == 1) *keyword = 0;
if (result == 0) *keyword = 1;
}
}
}
BFT_FREE(path);
}
/*-----------------------------------------------------------------------------
* Retourne le numero de la sonde situe dans la sous-balise "probe_recording"
* numero num_probe
*----------------------------------------------------------------------------*/
int cs_gui_additional_scalar_probe_name
(
const int scalar_num, /* numero du scalaire */
const int num_probe /* numero de la sonde */
)
{
char *path = NULL;
char *strvalue = NULL;
int value;
/* Construction de la requete */
path = cs_xpath_init_path();
cs_xpath_add_element(&path,cs_first_path_element[USER_SCALAR]);
cs_xpath_add_element_num(&path,cs_variable[SCALAR],scalar_num);
cs_xpath_add_element_num(&path, cs_values_name[PROBE_RECORDING],num_probe);
cs_xpath_add_attribute(&path, "name");
/* Evaluation de la requete */
strvalue = cs_gui_get_attribute_value(path);
if (strvalue == NULL)
bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
value = atoi(strvalue);
BFT_FREE(path);
BFT_FREE(strvalue);
return value;
}
/*-----------------------------------------------------------------------------
* Return the label attribute of scalars.
*
* parameters:
* markup --> parent markup of the scalar
* scalar_num <-- number of the searching scalar
*----------------------------------------------------------------------------*/
char *cs_gui_scalar_label(const char *const markup,
const int scalar_num)
{
char *path = NULL;
char *strvalue = NULL;
path = cs_xpath_short_path();
cs_xpath_add_element(&path, markup);
cs_xpath_add_element_num(&path, "scalar", scalar_num);
cs_xpath_add_attribute(&path, "label");
strvalue = cs_gui_get_attribute_value(path);
BFT_FREE(path);
return strvalue;
}
/*-----------------------------------------------------------------------------
* Donne les valeurs liees aux scalaire model : min, max ...
* La fonction retourne 1 si la valeur existe
* 0 sinon
* le resultat est stocke dans value
*----------------------------------------------------------------------------*/
void cs_gui_thermal_scalar_value
(
const char *const model_type, /* Type de modele */
const char *const value_type, /* Type de valeur */
double *const value /* valeur de la variable */
)
{
char *path = NULL;
char *scalar_name = NULL;
double result;
scalar_name = cs_gui_get_thermophysical_model(model_type);
path = cs_xpath_init_path();
cs_xpath_add_element(&path, cs_first_path_element[THERMOPHYSICAL_MODELS]);
cs_xpath_add_element(&path, model_type);
cs_xpath_add_element(&path, cs_variable[SCALAR]);
cs_xpath_add_test_attribute(&path, "name", scalar_name);
cs_xpath_add_element(&path, value_type);
cs_xpath_add_function_text(&path);
if (cs_gui_get_double(path, &result)) *value = result;
BFT_FREE(path);
BFT_FREE(scalar_name);
}
/*-----------------------------------------------------------------------------
* Donne les valeurs liees aux scalaire model : min, max ...
* La fonction retourne 1 si la valeur existe
* 0 sinon
* le resultat est stocke dans value
*----------------------------------------------------------------------------*/
void cs_gui_model_scalar_value
(
const char* const model , /* modele */
const int num_sca, /* numero du scalaire */
const cs_values_t value_type, /* Type de valeur */
double *const value /* valeur de la variable */
)
{
char *path = NULL;
double result;
/* Construction de la requete */
path = cs_xpath_init_path();
cs_xpath_add_element(&path, cs_first_path_element[THERMOPHYSICAL_MODELS]);
cs_xpath_add_element(&path, model);
cs_xpath_add_element_num(&path, cs_variable[SCALAR], num_sca);
cs_xpath_add_element(&path, cs_values_name[value_type]);
cs_xpath_add_function_text(&path);
/* Evaluation de la requete */
if (cs_gui_get_double(path,&result))
*value = result;
BFT_FREE(path);
}
/*-----------------------------------------------------------------------------
* Nombre de sous-balise "probe_recording" pour les scalaires thermique
*----------------------------------------------------------------------------*/
int cs_gui_thermal_scalar_number_probes
(
const char *const model_type /* Type de modele */
)
{
char *path = NULL;
char *scalar_name = NULL;
int nb_probes ;
scalar_name = cs_gui_get_thermophysical_model(model_type);
/* Construction de la requete */
path = cs_xpath_init_path();
cs_xpath_add_element(&path, cs_first_path_element[THERMOPHYSICAL_MODELS]);
cs_xpath_add_element(&path, model_type);
cs_xpath_add_element(&path, cs_variable[SCALAR]);
cs_xpath_add_test_attribute(&path, "name", scalar_name);
cs_xpath_add_element(&path, cs_values_name[PROBE_RECORDING]);
/* Evaluation de la requete */
nb_probes = cs_gui_get_nb_element(path);
BFT_FREE(path);
BFT_FREE(scalar_name);
return nb_probes;
}
/*-----------------------------------------------------------------------------
* Nombre de sous-balise "probe_recording" pour les scalaires model
*----------------------------------------------------------------------------*/
int cs_gui_model_scalar_number_probes
(
const char* const model, /* Type de modele */
const int num_sca /* numero du scalaire */
)
{
char *path = NULL;
int nb_probes ;
/* Construction de la requete */
path = cs_xpath_init_path();
cs_xpath_add_element(&path, cs_first_path_element[THERMOPHYSICAL_MODELS]);
cs_xpath_add_element(&path, model);
cs_xpath_add_element_num(&path, cs_variable[SCALAR], num_sca);
cs_xpath_add_element(&path, cs_values_name[PROBE_RECORDING]);
/* Evaluation de la requete */
nb_probes = cs_gui_get_nb_element(path);
BFT_FREE(path);
return nb_probes;
}
/*-----------------------------------------------------------------------------
* Nombre de sous-balise "probe_recording" pour les scalaires model
*----------------------------------------------------------------------------*/
int cs_gui_model_property_number_probes
(
const char* const model, /* Type de modele */
const int num_sca /* numero du scalaire */
)
{
char *path = NULL;
int nb_probes ;
/* Construction de la requete */
path = cs_xpath_init_path();
cs_xpath_add_element(&path, cs_first_path_element[THERMOPHYSICAL_MODELS]);
cs_xpath_add_element(&path, model);
cs_xpath_add_element_num(&path, cs_variable[PROPERTY], num_sca);
cs_xpath_add_element(&path, cs_values_name[PROBE_RECORDING]);
/* Evaluation de la requete */
nb_probes = cs_gui_get_nb_element(path);
BFT_FREE(path);
return nb_probes;
}
/*-----------------------------------------------------------------------------
* Retourne l'attribut status des sous-balises des scalaires model
*----------------------------------------------------------------------------*/
void cs_gui_thermal_scalar_output_status
(
const char *const model_type, /* Type de modele */
const char *const value_type, /* Type de valeur */
int *const keyword
)
{
char *path = NULL;
char *choice = NULL;
char *scalar_name = NULL;
int result;
scalar_name = cs_gui_get_thermophysical_model(model_type);
path = cs_xpath_init_path();
cs_xpath_add_element(&path, cs_first_path_element[THERMOPHYSICAL_MODELS]);
cs_xpath_add_element(&path, model_type);
cs_xpath_add_element(&path, cs_variable[SCALAR]);
cs_xpath_add_test_attribute(&path, "name", scalar_name);
cs_xpath_add_element(&path, value_type);
if (cs_gui_strcmp(value_type, "order_scheme")) {
cs_xpath_add_attribute(&path, "choice");
choice = cs_gui_get_attribute_value(path);
if (cs_gui_strcmp(choice, "centered"))
*keyword = 1;
else if (cs_gui_strcmp(choice, "solu"))
*keyword = 0;
BFT_FREE(choice);
} else {
cs_xpath_add_attribute(&path, "status");
if (cs_gui_get_status(path, &result)) {
*keyword = result;
if (cs_gui_strcmp(value_type, "slope_test")) {
if (result == 1) *keyword = 0;
if (result == 0) *keyword = 1;
}
}
}
BFT_FREE(path);
BFT_FREE(scalar_name);
}
/*-----------------------------------------------------------------------------
* Retourne l'attribut status des sous-balises des scalaires model
*----------------------------------------------------------------------------*/
void cs_gui_model_scalar_output_status
(
const char* const model, /* modele */
const int num_sca, /* numero du scalaire */
const cs_values_t value_type, /* Type de valeur */
int *const keyword
)
{
char *path = NULL;
char *choice = NULL;
int result;
path = cs_xpath_init_path();
cs_xpath_add_element(&path, cs_first_path_element[THERMOPHYSICAL_MODELS]);
cs_xpath_add_element(&path, model);
cs_xpath_add_element_num(&path, cs_variable[SCALAR], num_sca);
cs_xpath_add_element(&path, cs_values_name[value_type]);
if (value_type == ORDER_SCHEME) {
cs_xpath_add_attribute(&path, "choice");
choice = cs_gui_get_attribute_value(path);
if (cs_gui_strcmp(choice, "centered"))
*keyword = 1;
else if (cs_gui_strcmp(choice, "solu"))
*keyword = 0;
BFT_FREE(choice);
} else {
cs_xpath_add_attribute(&path, "status");
if (cs_gui_get_status(path, &result)) {
*keyword = result;
if (value_type == SLOPE_TEST) {
if (result == 1) *keyword = 0;
if (result == 0) *keyword = 1;
}
}
}
BFT_FREE(path);
}
/*-----------------------------------------------------------------------------
* Retourne l'attribut status des sous-balises des proprietes physiques model
*----------------------------------------------------------------------------*/
void cs_gui_model_property_output_status
(
const char* const model, /* modele */
const int num_pro, /* numero du scalaire */
const cs_values_t value_type, /* Type de valeur */
int *const keyword
)
{
char *path = NULL;
int result;
path = cs_xpath_init_path();
cs_xpath_add_element(&path, cs_first_path_element[THERMOPHYSICAL_MODELS]);
cs_xpath_add_element(&path, model);
cs_xpath_add_element_num(&path, cs_variable[PROPERTY], num_pro);
cs_xpath_add_element(&path, cs_values_name[value_type]);
cs_xpath_add_attribute(&path, "status");
if (cs_gui_get_status(path, &result))
*keyword = result;
else
*keyword = 1;
BFT_FREE(path);
}
/*-----------------------------------------------------------------------------
* Retourne le numero de la sonde situe dans la sous-balise "probe_recording"
* numero num_probe pour les scalaires thermiques
*----------------------------------------------------------------------------*/
int cs_gui_thermal_scalar_probe_name
(
const char *const model_type, /* Type de modele */
const int num_probe
)
{
char *path = NULL;
char *strvalue = NULL;
char *scalar_name = NULL;
int value;
scalar_name = cs_gui_get_thermophysical_model(model_type);
/* Construction de la requete */
path = cs_xpath_init_path();
cs_xpath_add_element(&path, cs_first_path_element[THERMOPHYSICAL_MODELS]);
cs_xpath_add_element(&path, model_type);
cs_xpath_add_element(&path, cs_variable[SCALAR]);
cs_xpath_add_test_attribute(&path, "name", scalar_name);
cs_xpath_add_element_num(&path, cs_values_name[PROBE_RECORDING], num_probe);
cs_xpath_add_attribute(&path, "name");
/* Evaluation de la requete */
strvalue = cs_gui_get_attribute_value(path);
if (strvalue == NULL)
bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
value = atoi(strvalue);
BFT_FREE(strvalue);
BFT_FREE(path);
BFT_FREE(scalar_name);
return value;
}
/*-----------------------------------------------------------------------------
* Retourne le numero de la sonde situe dans la sous-balise "probe_recording"
* numero num_probe pour les scalaires model
*----------------------------------------------------------------------------*/
int cs_gui_model_scalar_probe_name
(
const char * model, /* Type de modele */
const int num_sca,
const int num_probe
)
{
char *path = NULL;
char *strvalue = NULL;
int value;
/* Construction de la requete */
path = cs_xpath_init_path();
cs_xpath_add_element(&path, cs_first_path_element[THERMOPHYSICAL_MODELS]);
cs_xpath_add_element(&path, model);
cs_xpath_add_element_num(&path, cs_variable[SCALAR], num_sca);
cs_xpath_add_element_num(&path, cs_values_name[PROBE_RECORDING], num_probe);
cs_xpath_add_attribute(&path, "name");
/* Evaluation de la requete */
strvalue = cs_gui_get_attribute_value(path);
if (strvalue == NULL)
bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
value = atoi(strvalue);
BFT_FREE(path);
BFT_FREE(strvalue);
return value;
}
/*-----------------------------------------------------------------------------
* Retourne le numero de la sonde situe dans la sous-balise "probe_recording"
* numero num_probe pour les proprietes physiques model
*----------------------------------------------------------------------------*/
int cs_gui_model_property_probe_name
(
const char * model, /* Type de modele */
const int num_prop,
const int num_probe
)
{
char *path = NULL;
char *strvalue = NULL;
int value;
/* Construction de la requete */
path = cs_xpath_init_path();
cs_xpath_add_element(&path, cs_first_path_element[THERMOPHYSICAL_MODELS]);
cs_xpath_add_element(&path, model);
cs_xpath_add_element_num(&path, cs_variable[PROPERTY], num_prop);
cs_xpath_add_element_num(&path, cs_values_name[PROBE_RECORDING], num_probe);
cs_xpath_add_attribute(&path, "name");
/* Evaluation de la requete */
strvalue = cs_gui_get_attribute_value(path);
if (strvalue == NULL)
bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
value = atoi(strvalue);
BFT_FREE(path);
BFT_FREE(strvalue);
return value;
}
/*-----------------------------------------------------------------------------
* Retourne le label du scalaire thermique
*----------------------------------------------------------------------------*/
char *cs_gui_get_thermal_scalar_label
(
const char *const model_type /* Type de modele */
)
{
char *path = NULL;
char *label_name = NULL;
char *scalar_name = NULL;
scalar_name = cs_gui_get_thermophysical_model(model_type);
/* Construction de la requete */
path = cs_xpath_init_path();
cs_xpath_add_element(&path, cs_first_path_element[THERMOPHYSICAL_MODELS]);
cs_xpath_add_element(&path, model_type);
cs_xpath_add_element(&path, cs_variable[SCALAR]);
cs_xpath_add_test_attribute(&path, "name", scalar_name);
cs_xpath_add_attribute(&path, "label");
/* Evaluation de la requete */
label_name = cs_gui_get_attribute_value(path);
BFT_FREE(path);
BFT_FREE(scalar_name);
return label_name;
}
/*-----------------------------------------------------------------------------
* Retourne le label des propriétés model
*----------------------------------------------------------------------------*/
char *cs_gui_get_model_property_label
(
const char * const model, /* modele */
const int num_prop /* numero du scalaire */
)
{
char *path = NULL;
char *label_name = NULL;
path = cs_xpath_init_path();
cs_xpath_add_element(&path, cs_first_path_element[THERMOPHYSICAL_MODELS]);
cs_xpath_add_element(&path, model);
cs_xpath_add_element_num(&path, cs_variable[PROPERTY],num_prop);
cs_xpath_add_attribute(&path, "label");
/* Evaluation de la requete */
label_name = cs_gui_get_attribute_value(path);
BFT_FREE(path);
return label_name;
}
/*-----------------------------------------------------------------------------
* Modify integer numerical parameters.
*
* parameters:
* param --> label of the numerical parameter
* keyword <--> value of the numerical parameter
*----------------------------------------------------------------------------*/
void cs_gui_numerical_int_parameters(const char *const param,
int *const keyword)
{
char *path = NULL;
char *choice = NULL;
int result;
path = cs_xpath_init_path();
cs_xpath_add_element(&path, "numerical_parameters");
cs_xpath_add_element(&path, param);
if (cs_gui_strcmp(param, "gradient_reconstruction")){
cs_xpath_add_attribute(&path, "choice");
choice = cs_gui_get_attribute_value(path);
if (choice) *keyword = atoi(choice);
BFT_FREE(choice);
} else {
cs_xpath_add_attribute(&path, "status");
if (cs_gui_get_status(path, &result)) *keyword = result;
}
BFT_FREE(path);
}
/*-----------------------------------------------------------------------------
* Modify double numerical parameters.
*
* parameters:
* param --> label of the numerical parameter
* keyword <--> value of the numerical parameter
*----------------------------------------------------------------------------*/
void cs_gui_numerical_double_parameters(const char *const param,
double *const keyword)
{
char *path = NULL;
double result;
path = cs_xpath_init_path();
cs_xpath_add_element(&path, "numerical_parameters");
cs_xpath_add_element(&path, param);
cs_xpath_add_function_text(&path);
if (cs_gui_get_double(path, &result))
*keyword = result;
BFT_FREE(path);
}
/*-----------------------------------------------------------------------------
* Modify time parameters.
*
* parameters:
* param --> time parameter
* keyword <--> new value of the time parameter
*----------------------------------------------------------------------------*/
void
cs_gui_time_parameters(const char *const param,
double *const keyword)
{
char *path = NULL;
double result = 0.0;
int status = 0;
path = cs_xpath_init_path();
cs_xpath_add_elements(&path, 3, "analysis_control", "time_parameters", param);
if (cs_gui_strcmp(param,"zero_time_step") ||
cs_gui_strcmp(param,"thermal_time_step")) {
cs_xpath_add_attribute(&path, "status");
if(cs_gui_get_status(path, &status)) *keyword = status;
} else {
cs_xpath_add_function_text(&path);
if (cs_gui_get_double(path, &result)) *keyword = result;
}
BFT_FREE(path);
}
/*-----------------------------------------------------------------------------
* Modify restart parameters.
*
* parameters:
* param --> restart parameter
* keyword <--> new value of the restart parameter
*----------------------------------------------------------------------------*/
void cs_gui_restart_parameters_status(const char *const param,
int *const keyword)
{
int result;
char *path = NULL;
path = cs_xpath_init_path();
cs_xpath_add_elements(&path, 3, "calcul_management", "start_restart", param);
cs_xpath_add_attribute(&path, "status");
if(cs_gui_get_status(path, &result))
*keyword = result;
BFT_FREE(path);
}
/*-----------------------------------------------------------------------------
* Modify restart files format.
*
* parameters:
* param --> restart file name
* keyword <--> new value of the restart file format
*----------------------------------------------------------------------------*/
void cs_gui_restart_parameters_file_format (const char *const param,
int *const format)
{
char *path = NULL;
char *result = NULL;
path = cs_xpath_init_path();
cs_xpath_add_elements(&path, 3, "calcul_management", "start_restart", param);
cs_xpath_add_attribute(&path, "format");
result = cs_gui_get_attribute_value(path);
if (result != NULL) {
if (cs_gui_strcmp(result, "binary"))
*format = 0;
else if (cs_gui_strcmp(result, "ascii"))
*format = 1;
else
bft_error(__FILE__, __LINE__, 0,
_("Restart file format unknown: %s.\nXpath: %s\n"),
result, path);
}
BFT_FREE(result);
BFT_FREE(path);
}
/*-----------------------------------------------------------------------------
* Modify gravity parameters.
*
* parameters:
* param --> gravity parameter (GX, GY, GZ)
* keyword <--> new value of the gravity parameter
*----------------------------------------------------------------------------*/
void cs_gui_gravity_value(const char *const param,
double *const value)
{
char *path = NULL;
double result;
path = cs_xpath_init_path();
cs_xpath_add_elements(&path, 3, "physical_properties", "gravity", param);
cs_xpath_add_function_text(&path);
if (cs_gui_get_double(path, &result)) *value = result;
BFT_FREE(path);
}
/*-----------------------------------------------------------------------------
* Get initial value from property markup.
*
* parameters:
* property_name --> name of the property
* value <-- new initial value of the property
*----------------------------------------------------------------------------*/
void cs_gui_properties_value(const char *const property_name,
double *const value)
{
char *path = NULL;
double result;
path = cs_xpath_short_path();
cs_xpath_add_element(&path, "property");
cs_xpath_add_test_attribute(&path, "name", property_name);
cs_xpath_add_element(&path, "initial_value");
cs_xpath_add_function_text(&path);
if (cs_gui_get_double(path, &result)) *value = result;
BFT_FREE(path);
}
/*-----------------------------------------------------------------------------
* Nombre de sous-balise "probe_recording" pour les proprietes physiques
* Retourne le nombre de sondes pour la proprietes property_name
*----------------------------------------------------------------------------*/
int cs_gui_properties_number_probes(const char *const property_name)
{
char *path = NULL;
int nb_probe ;
path = cs_xpath_short_path();
cs_xpath_add_element(&path, "property");
cs_xpath_add_test_attribute(&path, "name", property_name);
cs_xpath_add_element(&path, "probe_recording");
nb_probe = cs_gui_get_nb_element(path);
BFT_FREE(path);
return nb_probe;
}
/*-----------------------------------------------------------------------------
* Retourne les status des sous-balises de proprietes physiques
*----------------------------------------------------------------------------*/
void cs_gui_properties_status(const char *const property_name,
const char *const value_type,
int *const keyword)
{
char *path = NULL;
int result;
path = cs_xpath_short_path();
cs_xpath_add_element(&path, "property");
cs_xpath_add_test_attribute(&path, "name", property_name);
cs_xpath_add_element(&path, value_type);
cs_xpath_add_attribute(&path, "status");
if (cs_gui_get_status(path, &result))
*keyword = result;
else
*keyword = 1;
BFT_FREE(path);
}
/*-----------------------------------------------------------------------------
* Retourne le numero de la sonde situe dans la sous-balise "probe_recording"
* numero num_probe pour les scalaires model
*----------------------------------------------------------------------------*/
int cs_gui_properties_probe_name(const char *const property_name,
const int num_probe)
{
char *path = NULL;
char *strvalue = NULL;
int value;
path = cs_xpath_short_path();
cs_xpath_add_element(&path, "property");
cs_xpath_add_test_attribute(&path, "name", property_name);
cs_xpath_add_element_num(&path, "probe_recording", num_probe);
cs_xpath_add_attribute(&path, "name");
strvalue = cs_gui_get_attribute_value(path);
if (strvalue == NULL)
bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
value = atoi(strvalue);
BFT_FREE(path);
BFT_FREE(strvalue);
return value;
}
/*-----------------------------------------------------------------------------
* Return the label attribute of a property markup.
*
* parameters:
* property_name --> name of the property
*----------------------------------------------------------------------------*/
char *cs_gui_properties_label(const char *const property_name)
{
char *path = NULL;
char *label = NULL;
path = cs_xpath_short_path();
cs_xpath_add_element(&path, "property");
cs_xpath_add_test_attribute(&path, "name", property_name);
cs_xpath_add_attribute(&path, "label");
label = cs_gui_get_attribute_value(path);
BFT_FREE(path);
return label;
}
/*----------------------------------------------------------------------------
* Get the value of the choice attribute from a property markup.
* Return 1 if the xpath request has succeeded, 0 otherwise.
*
* parameters:
* property_name --> name of the property
* choice <-- value of the attribute choice
*----------------------------------------------------------------------------*/
int cs_gui_properties_choice(const char *const property_name,
int * choice)
{
char *path = NULL;
char *buff = NULL;
int iok;
path = cs_xpath_short_path();
cs_xpath_add_element(&path, "property");
cs_xpath_add_test_attribute(&path, "name", property_name);
cs_xpath_add_attribute(&path, "choice");
buff = cs_gui_get_attribute_value(path);
if (buff == NULL)
iok = 0;
else {
iok = 1;
if (cs_gui_strcmp(buff, "variable"))
*choice = 1;
else if (cs_gui_strcmp(buff, "constant"))
*choice = 0;
else
bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
}
BFT_FREE(buff);
BFT_FREE(path);
return iok;
}
/*-----------------------------------------------------------------------------
* Retourne la valeur de l'attribut choice liee aux proprietes
* des scalaires utilisateurs
*----------------------------------------------------------------------------*/
int cs_gui_add_scalar_properties_choice(const int scalar_num,
const char *const property_name,
int *const choice)
{
char *path = NULL;
char *buff = NULL;
int ichoice;
/* Construction de la requete */
path = cs_xpath_init_path();
cs_xpath_add_element(&path, "additional_scalars");
cs_xpath_add_element_num(&path, "scalar", scalar_num);
cs_xpath_add_element(&path, "property");
cs_xpath_add_test_attribute(&path, "name", property_name);
cs_xpath_add_attribute(&path, "choice");
/* Evaluation de la requete */
buff = cs_gui_get_attribute_value(path);
BFT_FREE(path);
/* Tests sur le statut */
if (buff == NULL)
ichoice = 0;
else {
ichoice = 1;
if (cs_gui_strcmp(buff, "variable"))
*choice = 1;
else if (cs_gui_strcmp(buff, "constant"))
*choice = 0;
else
bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
}
BFT_FREE(buff);
return ichoice;
}
/*============================================================================
* Entrees-sorties
*============================================================================*/
/*----------------------------------------------------------------------------
* Get the output format and options for postprocessing.
*
* parameters:
* param --> name of the parameter
* keyword <-- output control parameter
* size_key --> keyword string size
*----------------------------------------------------------------------------*/
void cs_gui_output_choice(const char *const param,
char *const keyword,
const int *const size_key)
{
char *path = NULL;
char *choice = NULL;
path = cs_xpath_init_path();
cs_xpath_add_elements(&path, 3, "analysis_control", "output", param);
cs_xpath_add_attribute(&path, "choice");
choice = cs_gui_get_attribute_value(path);
if (choice != NULL) cs_gui_strcpy_c2f(keyword, choice, *size_key);
BFT_FREE(choice);
BFT_FREE(path);
}
/*----------------------------------------------------------------------------
* Get output control value parameters.
*
* parameters:
* param --> name of the parameter
* keyword <-- output control parameter
*----------------------------------------------------------------------------*/
void cs_gui_output_value(const char *const param,
int *const keyword)
{
char *path = NULL;
int result;
path = cs_xpath_init_path();
cs_xpath_add_elements(&path, 3, "analysis_control", "output", param);
if (cs_gui_strcmp(param, "auxiliary_restart_file_writing") ||
cs_gui_strcmp(param, "fluid_domain") ||
cs_gui_strcmp(param, "domain_boundary") ||
cs_gui_strcmp(param, "syrthes_boundary") ) {
cs_xpath_add_attribute(&path, "status");
if(cs_gui_get_status(path, &result)) *keyword = result;
} else {
cs_xpath_add_function_text(&path);
if (cs_gui_get_int(path, &result)) *keyword = result;
}
BFT_FREE(path);
}
/*-----------------------------------------------------------------------------
* Return the number of the <probe> markups.
*----------------------------------------------------------------------------*/
int cs_gui_probes_number(void)
{
char *path = NULL;
int number = 0;
path = cs_xpath_init_path();
cs_xpath_add_elements(&path, 3, "analysis_control", "output", "probe");
number = cs_gui_get_nb_element(path);
BFT_FREE(path);
return number ;
}
/*-----------------------------------------------------------------------------
* Return a single coordinate of a monitoring probe
*
* parameters
* num_probe --> number aka name of the monitoring probe
* probe_coord --> one coordinate of the monitoring probe
*----------------------------------------------------------------------------*/
double cs_gui_probe_coordinate(const int num_probe,
const char *const probe_coord)
{
char *path = NULL;
char *str_num_probe = NULL;
double result = 0.0;
assert(num_probe>0);
BFT_MALLOC(str_num_probe,
cs_gui_characters_number(num_probe)+1,
char);
sprintf(str_num_probe, "%i", num_probe);
path = cs_xpath_init_path();
cs_xpath_add_elements(&path, 3, "analysis_control", "output", "probe");
cs_xpath_add_test_attribute(&path, "name", str_num_probe);
cs_xpath_add_element(&path, probe_coord);
cs_xpath_add_function_text(&path);
if (!cs_gui_get_double(path, &result))
bft_error(__FILE__, __LINE__, 0,
_("Coordinate %s of the monitoring probe number %i "
"not found.\nXpath: %s\n"), probe_coord, num_probe, path);
BFT_FREE(str_num_probe);
BFT_FREE(path);
return result;
}
/*-----------------------------------------------------------------------------
* Prise en compte des options de post-traitement pour les varaibles
* (Vitesse, Pression...)
* le tableau "globale" est construit dans CSENSO
* globale[num_probe] = num_saturne_probe
* ou num_saturne_probe est le numero de la sonde dans le code
* num_probe et num_saturne_probe different lorsque des sondes
* sont desactivees
* dans le fichier XML
*----------------------------------------------------------------------------*/
void cs_gui_thermophysical_post(const char *const variable,
const int ipp,
int *const ihisvr,
int *const ilisvr,
int *const ichrvr,
const int *const nvppmx)
{
int nb_probes;
int iprob;
char *varname = NULL;
int num_probe;
if (ipp == 1) return;
cs_gui_variable_status(variable,
"postprocessing_recording",
&ichrvr[ipp-1]);
cs_gui_variable_status(variable,
"listing_printing",
&ilisvr[ipp-1]);
nb_probes = cs_gui_variable_number_probes(variable);
/* ihisvr[0][ipp - 1] = nb_probes; */
if (nb_probes > 0) ihisvr[0 + (ipp - 1)] = nb_probes;
for (iprob =0; iprob < nb_probes; iprob++) {
num_probe = cs_gui_variable_probe_name(variable, iprob+1);
ihisvr[(iprob+1)*(*nvppmx) + (ipp - 1)] = num_probe;
}
varname = cs_gui_variable_label(variable);
_cs_gui_copy_varname(varname, ipp);
BFT_FREE(varname);
}
/*-----------------------------------------------------------------------------
* Prise en compte des options de post-traitement pour
* les scalaires thermiques et model
* le tableau "globale" est construit dans CSENSO
* globale[num_probe] = num_saturne_probe
* ou num_saturne_probe est le numero de la sonde dans le code
* num_probe et num_saturne_probe different lorsque des sondes
* sont desactivees dans le fichier XML
*----------------------------------------------------------------------------*/
void cs_gui_thermal_scalar_post
(
const char *const model_type,
const int num_sca,
int *const ihisvr,
int *const ilisvr,
int *const ichrvr,
const int *const ipprtp,
const int *const isca,
const int *const nvppmx)
{
int ipp;
int nb_probes;
int iprob;
int num_probe;
ipp = ipprtp[isca[num_sca - 1] -1 ];
if (ipp == 1) return;
/* frequence des sorties ensight */
cs_gui_thermal_scalar_output_status(model_type,
"postprocessing_recording",
&ichrvr[ipp - 1]);
/* frequence des sorties listing */
cs_gui_thermal_scalar_output_status(model_type,
"listing_printing",
&ilisvr[ipp - 1]);
/* sondes actives */
nb_probes = cs_gui_thermal_scalar_number_probes(model_type);
/*ihisvr[0][ipp - 1] = nb_probes;*/
ihisvr[0 + (ipp - 1)] = nb_probes;
for (iprob =0; iprob < nb_probes; iprob++){
num_probe = cs_gui_thermal_scalar_probe_name(model_type, iprob+1);
ihisvr[(iprob+1)*(*nvppmx) + (ipp - 1)] = num_probe;
}
_cs_gui_copy_varname(vars->label[0], ipp);
}
/*-----------------------------------------------------------------------------
* Prise en compte des options de post-traitement pour
* les scalaires thermiques et model
* le tableau "globale" est construit dans CSENSO
* globale[num_probe] = num_saturne_probe
* ou num_saturne_probe est le numero de la sonde dans le code
* num_probe et num_saturne_probe different lorsque des sondes
* sont desactivees dans le fichier XML
*----------------------------------------------------------------------------*/
void cs_gui_model_scalar_post
(
const char *const model,
const int num_sca,
int *const ihisvr,
int *const ilisvr,
int *const ichrvr,
const int *const ipprtp,
const int *const isca,
const int *const nvppmx)
{
int ipp;
int nb_probes;
int iprob;
int num_probe;
ipp = ipprtp[isca[num_sca - 1] -1 ];
if (ipp == 1) return;
/* frequence des sorties ensight */
cs_gui_model_scalar_output_status(model, vars->XMLnumsca[num_sca - vars->nscaus - 1] + 1,
POST_RECORDING,
&ichrvr[ipp - 1]);
/* frequence des sorties listing */
cs_gui_model_scalar_output_status(model, vars->XMLnumsca[num_sca - vars->nscaus - 1] + 1,
LIST_PRINTING,
&ilisvr[ipp - 1]);
/* sondes actives */
nb_probes = cs_gui_model_scalar_number_probes(model, vars->XMLnumsca[num_sca - vars->nscaus - 1] + 1);
/*ihisvr[0][ipp - 1] = nb_probes;*/
ihisvr[0 + (ipp - 1)] = nb_probes;
for (iprob =0; iprob < nb_probes; iprob++) {
num_probe = cs_gui_model_scalar_probe_name(model, vars->XMLnumsca[num_sca - vars->nscaus - 1] + 1, iprob+1);
ihisvr[(iprob+1)*(*nvppmx) + (ipp - 1)] = num_probe;
}
_cs_gui_copy_varname(vars->label[vars->XMLnumsca[num_sca - vars->nscaus - 1] + vars->nscaus],
ipp);
}
/*-----------------------------------------------------------------------------
* Prise en compte des options de post-traitement pour
* les scalaires thermiques et model
* le tableau "globale" est construit dans CSENSO
* globale[num_probe] = num_saturne_probe
* ou num_saturne_probe est le numero de la sonde dans le code
* num_probe et num_saturne_probe different lorsque des sondes
* sont desactivees dans le fichier XML
*----------------------------------------------------------------------------*/
void cs_gui_model_property_post
(
const char *const model,
const int num_prop,
int *const ihisvr,
int *const ilisvr,
int *const ichrvr,
const int *const ipppro,
const int *const ipproc,
const int *const nvppmx)
{
int ipp;
int nb_probes;
int iprob;
int num_probe;
char *varname = NULL;
ipp = ipppro[ipproc[num_prop - 1] -1 ];
if (ipp == 1) return;
/* frequence des sorties ensight */
cs_gui_model_property_output_status(model,
vars->XMLnumpp[num_prop - vars->nprop - 1] + 1,
POST_RECORDING,
&ichrvr[ipp - 1]);
/* frequence des sorties listing */
cs_gui_model_property_output_status(model,
vars->XMLnumpp[num_prop - vars->nprop - 1] + 1,
LIST_PRINTING,
&ilisvr[ipp - 1]);
/* sondes actives */
nb_probes = cs_gui_model_property_number_probes(model,
vars->XMLnumpp[num_prop - vars->nprop - 1] + 1);
/*ihisvr[0][ipp - 1] = nb_probes;*/
ihisvr[0 + (ipp - 1)] = nb_probes;
for (iprob =0; iprob < nb_probes; iprob++){
num_probe = cs_gui_model_property_probe_name(model,
vars->XMLnumpp[num_prop - vars->nprop - 1] + 1,
iprob+1);
ihisvr[(iprob+1)*(*nvppmx) + (ipp - 1)] = num_probe;
}
/* prise en compte du label */
varname = cs_gui_get_model_property_label(model,
vars->XMLnumpp[num_prop - vars->nprop - 1] + 1);
_cs_gui_copy_varname(varname, ipp);
BFT_FREE(varname);
}
/*-----------------------------------------------------------------------------
* Prise en compte des options de post-traitement pour les scalaires
* utilisateurs, le tableau "globale" est construit dans CSENSO
* globale[num_probe] = num_saturne_probe
* ou num_saturne_probe est le numero de la sonde dans le code
* num_probe et num_saturne_probe different lorsque des sondes
* sont desactivees dans le fichier XML
*----------------------------------------------------------------------------*/
void cs_gui_additional_scalar_post
(
const int num_sca,
int *const ihisvr,
int *const ilisvr,
int *const ichrvr,
const int *const ipprtp,
const int *const isca,
const int *const nvppmx)
{
int ipp;
int nb_probes;
int iprob;
int num_probe;
int ind_thermal_scalar = 0;
int num_add_sca;
ipp = ipprtp[isca[num_sca - 1] -1 ];
if (ipp == 1) return;
if (cs_gui_thermal_scalar())
ind_thermal_scalar++;
num_add_sca = num_sca - ind_thermal_scalar;
/* frequence des sorties ensight */
cs_gui_scalar_attribute(vars->label[num_sca-1],
"postprocessing_recording",
&ichrvr[ipp - 1]);
/* frequence des sorties listing */
cs_gui_scalar_attribute(vars->label[num_sca-1],
"listing_printing",
&ilisvr[ipp - 1]);
/* sondes actives */
nb_probes = cs_gui_additional_scalar_number_probes(num_add_sca);
/*ihisvr[0][ipp - 1] = nb_probes;*/
ihisvr[0 + (ipp - 1)] = nb_probes;
for (iprob=0; iprob < nb_probes; iprob++){
num_probe = cs_gui_additional_scalar_probe_name(num_add_sca, iprob+1);
ihisvr[(iprob+1)*(*nvppmx) + (ipp - 1)] = num_probe;
}
if (ind_thermal_scalar == 0) num_add_sca--;
_cs_gui_copy_varname(vars->label[num_add_sca], ipp);
}
/*-----------------------------------------------------------------------------
* Prise en compte des options de post-traitement pour les proprietes physiques
* le tableau "globale" est construit dans CSENSO
* globale[num_probe] = num_saturne_probe
* ou num_saturne_probe est le numero de la sonde dans le code
* num_probe et num_saturne_probe different lorsque des sondes
* sont desactivees dans le fichier XML
*----------------------------------------------------------------------------*/
void cs_gui_properties_post
(
const char *const property_name,
const int ipp,
int *const ichrvr,
int *const ilisvr,
int *const ihisvr,
const int *const nvppmx)
{
int nb_probes;
int iprob;
char *varname = NULL;
int num_probe;
if (ipp == 1) return;
varname = cs_gui_properties_label(property_name);
if (varname == NULL) return;
_cs_gui_copy_varname(varname, ipp);
BFT_FREE(varname);
cs_gui_properties_status(property_name,
"postprocessing_recording",
&ichrvr[ipp - 1]);
cs_gui_properties_status(property_name,
"listing_printing",
&ilisvr[ipp - 1]);
nb_probes = cs_gui_properties_number_probes(property_name);
/*ihisvr[0][ipp - 1] = nb_probes;*/
ihisvr[0 + (ipp - 1)] = nb_probes;
for (iprob =0; iprob < nb_probes; iprob++){
num_probe = cs_gui_properties_probe_name(property_name,
iprob+1);
ihisvr[(iprob+1)*(*nvppmx) + (ipp - 1)] = num_probe;
}
}
/*=============================================================================
*
* Definition des conditions aux limites
*
*============================================================================*/
/*-----------------------------------------------------------------------------
* Return the fortran ICODCL code associated to the type of a boundary
* condition. Default returned value : -1
*----------------------------------------------------------------------------*/
int cs_gui_boundary_code(const cs_boundary_value_t bvalue)
{
int val = -1;
switch (bvalue) {
case DIRICHLET :
val = DIRICHLET;
break;
case NEUMANN :
val = NEUMANN;
break;
case COEF_ECHANGE :
val = COEF_ECHANGE;
break;
case FLOW1 :
val = FLOW1;
break;
case HYDRAULIC_DIAMETER :
val = HYDRAULIC_DIAMETER;
break;
default :
val = -1;
break;
}
return val;
}
/*-----------------------------------------------------------------------------
* sert a retourner T0, P0... pour la combustion
*----------------------------------------------------------------------------*/
int cs_gui_get_combustion_initial_value
(
const char* const model,
const int variable,
double * const value
)
{
char *path = NULL;
int iretour;
path = cs_xpath_init_path();
cs_xpath_add_element(&path, cs_first_path_element[THERMOPHYSICAL_MODELS]);
cs_xpath_add_element(&path, model);
cs_xpath_add_element(&path, cs_combustion_variables_name[variable]);
cs_xpath_add_function_text(&path);
iretour = 0;
if (cs_gui_get_double(path, value))
{
iretour = 1;
}
BFT_FREE(path);
return iretour ;
}
/*-----------------------------------------------------------------------------
* Retourne le numero du scalaire de nom name pour la physique particuliere model
*----------------------------------------------------------------------------*/
int cs_gui_get_model_scalar_number(
const char * const model,
const char * const name)
{
int i;
int nbsca = 0;
char * nametmp = NULL;
int numsca;
nbsca = cs_gui_get_number_model_scalar(model);
numsca = 0;
for (i = 0; i < nbsca; i++){
nametmp = cs_gui_get_model_scalar_name(model, i + 1);
if (cs_gui_strcmp(name, nametmp)) {
numsca = i;
BFT_FREE(nametmp);
break;
}
BFT_FREE(nametmp);
}
if (i == nbsca)
bft_error(__FILE__, __LINE__, 0, _("Invalid scalar name: %s.\n"), name);
return numsca;
}
/*-----------------------------------------------------------------------------
* Retourne le numero de la propriété de nom name pour la physique particuliere model
*----------------------------------------------------------------------------*/
int cs_gui_get_model_property_number
(
const char * const model,
const char * const name
)
{
int i;
int nbpp = 0;
char * nametmp = NULL;
int numpp;
nbpp = cs_gui_get_number_model_properties(model);
numpp = 0;
for (i = 0; i < nbpp; i++){
nametmp = cs_gui_get_model_property_name(model, i + 1);
if (cs_gui_strcmp(name, nametmp)) {
numpp = i;
BFT_FREE(nametmp);
break;
}
BFT_FREE(nametmp);
}
if (i == nbpp)
bft_error(__FILE__, __LINE__, 0, _("Invalid property name: %s.\n"), name);
return numpp;
}
/*-----------------------------------------------------------------------------
* Indique la valeur de l'attribut name pour un numero de scalaire et une
* physique particuliere donnee
*----------------------------------------------------------------------------*/
char* cs_gui_get_model_scalar_name
(
const char * const model,
const int scalar_num
)
{
char * path = NULL;
char * name_scalar = NULL;
path = cs_xpath_init_path();
cs_xpath_add_element(&path, cs_first_path_element[THERMOPHYSICAL_MODELS]);
cs_xpath_add_element(&path, model);
cs_xpath_add_element_num(&path, cs_variable[SCALAR], scalar_num);
cs_xpath_add_attribute(&path, "name");
name_scalar = cs_gui_get_attribute_value(path);
BFT_FREE(path);
return name_scalar;
}
/*-----------------------------------------------------------------------------
* Indique la valeur de l'attribut name pour un numero de proriété et une
* physique particuliere donnee
*----------------------------------------------------------------------------*/
char* cs_gui_get_model_property_name
(
const char * const model,
const int pp_num
)
{
char * path = NULL;
char * name_pp = NULL;
path = cs_xpath_init_path();
cs_xpath_add_element(&path, cs_first_path_element[THERMOPHYSICAL_MODELS]);
cs_xpath_add_element(&path, model);
cs_xpath_add_element_num(&path, cs_variable[PROPERTY], pp_num);
cs_xpath_add_attribute(&path, "name");
name_pp = cs_gui_get_attribute_value(path);
BFT_FREE(path);
return name_pp;
}
/*----------------------------------------------------------------------------
* Traitement des tableaux ISCSTH et ISCLAT lies au scalaire thermique
*----------------------------------------------------------------------------*/
void cs_gui_thermal_scalar_number
(
int *const iscalt,
int *const iscsth
)
{
int ind_thermal;
int index;
int iphas = 0;
ind_thermal = cs_gui_thermal_scalar();
/* On impose que le scalaire thermique
soit le premier des scalaires : index =1 */
if (ind_thermal){
index = 1;
iscalt[iphas] = index;
iscsth[index-1] = ind_thermal;
}
}
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _CS_HAVE_XML */
syntax highlighted by Code2HTML, v. 0.9.1