1
/*============================================================================
3
* This file is part of the Code_Saturne Kernel, element of the
4
* Code_Saturne CFD tool.
6
* Copyright (C) 1998-2009 EDF S.A., France
8
* contact: saturne-support@edf.fr
10
* The Code_Saturne Kernel is free software; you can redistribute it
11
* and/or modify it under the terms of the GNU General Public License
12
* as published by the Free Software Foundation; either version 2 of
13
* the License, or (at your option) any later version.
15
* The Code_Saturne Kernel is distributed in the hope that it will be
16
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
17
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with the Code_Saturne Kernel; if not, write to the
22
* Free Software Foundation, Inc.,
23
* 51 Franklin St, Fifth Floor,
24
* Boston, MA 02110-1301 USA
26
*============================================================================*/
28
/*============================================================================
29
* Management of the GUI parameters file: main parameters
30
*============================================================================*/
32
#if defined(HAVE_CONFIG_H)
33
#include "cs_config.h"
36
/*----------------------------------------------------------------------------
37
* Standard C library headers
38
*----------------------------------------------------------------------------*/
48
/*----------------------------------------------------------------------------
49
* libxml2 library headers
50
*----------------------------------------------------------------------------*/
52
#if defined(HAVE_LIBXML2)
54
#include <libxml/tree.h>
55
#include <libxml/parser.h>
56
#include <libxml/xpath.h>
57
#include <libxml/xpathInternals.h>
61
/*----------------------------------------------------------------------------
63
*----------------------------------------------------------------------------*/
66
#include <bft_error.h>
67
#include <bft_printf.h>
69
/*----------------------------------------------------------------------------
71
*----------------------------------------------------------------------------*/
73
#include "fvm_selector.h"
75
/*----------------------------------------------------------------------------
77
*----------------------------------------------------------------------------*/
81
#include "mei_evaluate.h"
85
/*----------------------------------------------------------------------------
87
*----------------------------------------------------------------------------*/
90
#include "cs_gui_util.h"
91
#include "cs_gui_variables.h"
92
#include "cs_gui_boundary_conditions.h"
93
#include "cs_gui_specific_physics.h"
94
#include "cs_gui_mobile_mesh.h"
96
#include "cs_prototypes.h"
98
/*----------------------------------------------------------------------------
99
* Header for the current file
100
*----------------------------------------------------------------------------*/
104
/*----------------------------------------------------------------------------*/
108
/*=============================================================================
109
* Local Macro Definitions
110
*============================================================================*/
112
/* debugging switch */
113
#define _XML_DEBUG_ 0
115
/*============================================================================
116
* Local Structure Definitions
117
*============================================================================*/
119
/*============================================================================
120
* External global variables
121
*============================================================================*/
123
/*----------------------------------------------------------------------------
124
* Management of the XML document
125
*----------------------------------------------------------------------------*/
127
#if defined(HAVE_LIBXML2)
128
extern xmlXPathContextPtr xpathCtx; /* Pointer on the Context */
129
extern xmlNodePtr node; /* Pointer on the root node */
132
/*============================================================================
133
* Private global variables
134
*============================================================================*/
136
/*============================================================================
137
* Static global variables
138
*============================================================================*/
140
/* Pointer on the main variable structure */
142
cs_var_t *cs_glob_var = NULL;
143
cs_label_t *cs_glob_label = NULL;
145
/*============================================================================
146
* Private function definitions
147
*============================================================================*/
149
/*-----------------------------------------------------------------------------
150
* Copy a variable name to private variable names array
153
* varname --> name or label of the variable/scalar/property
154
* ipp --> index from the fortran array associated to varname
155
*----------------------------------------------------------------------------*/
158
_gui_copy_varname(const char *varname, int ipp)
162
if (ipp < 1 || ipp > cs_glob_label->_cs_gui_last_var)
163
bft_error(__FILE__, __LINE__, 0,
164
_("Variable index %d out of bounds (1 to %d)"),
165
ipp, cs_glob_label->_cs_gui_last_var);
169
if (cs_glob_label->_cs_gui_var_name[ipp-1] == NULL)
170
BFT_MALLOC(cs_glob_label->_cs_gui_var_name[ipp-1], l + 1, char);
172
else if (strlen(cs_glob_label->_cs_gui_var_name[ipp-1]) != l)
173
BFT_REALLOC(cs_glob_label->_cs_gui_var_name[ipp-1], l + 1, char);
175
strcpy(cs_glob_label->_cs_gui_var_name[ipp-1], varname);
178
/*----------------------------------------------------------------------------
179
* Turbulence model parameters.
182
* param --> name of the parameters
183
* keyword <-- turbulence model parameter
184
*----------------------------------------------------------------------------*/
187
cs_gui_advanced_options_turbulence(const char *const param,
193
path = cs_xpath_init_path();
194
cs_xpath_add_elements(&path, 3, "thermophysical_models", "turbulence", param);
196
if (cs_gui_strcmp("gravity_terms", param)) {
198
cs_xpath_add_attribute(&path, "status");
199
if (cs_gui_get_status(path, &result)) *keyword = result;
201
} else if (cs_gui_strcmp("scale_model", param)) {
203
cs_xpath_add_function_text(&path);
204
if (cs_gui_get_int(path, &result)) *keyword = result;
207
bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
212
/*-----------------------------------------------------------------------------
213
* Return the name of the related scalar if the scalar "num_sca" is a variance
216
* num_sca --> scalar number
217
*----------------------------------------------------------------------------*/
220
cs_gui_scalar_variance(const int num_sca)
223
char *variance = NULL;
225
path = cs_xpath_init_path();
226
cs_xpath_add_element(&path, "additional_scalars");
227
cs_xpath_add_element_num(&path, "scalar", num_sca);
228
cs_xpath_add_element(&path, "variance");
229
cs_xpath_add_function_text(&path);
231
variance = cs_gui_get_text_value(path);
238
/*-----------------------------------------------------------------------------
239
* Return the user thermal scalar indicator.
240
*----------------------------------------------------------------------------*/
243
cs_gui_thermal_scalar(void)
245
char *model_name = NULL;
248
model_name = cs_gui_get_thermophysical_model("thermal_scalar");
250
if (cs_gui_strcmp(model_name, "off"))
253
if (cs_gui_strcmp(model_name, "enthalpy"))
255
else if (cs_gui_strcmp(model_name, "temperature_kelvin"))
257
else if (cs_gui_strcmp(model_name, "temperature_celsius"))
260
bft_error(__FILE__, __LINE__, 0,
261
_("Invalid thermal model: %s\n"), model_name);
264
BFT_FREE(model_name);
269
/*----------------------------------------------------------------------------
270
* Get thermal user scalar number if it is exist.
273
* iscalt <-- thermal scalar number order
274
* iscsth <-- nature of the thermal scalar (C, K, J/kg)
275
*----------------------------------------------------------------------------*/
278
cs_gui_thermal_scalar_number(int *const iscalt,
287
ind_thermal = cs_gui_thermal_scalar();
290
path = cs_xpath_init_path();
291
cs_xpath_add_elements(&path, 2, "additional_scalars", "/@type");
292
name = cs_gui_get_attribute_values(path, &size);
295
for (i=0; i < size; i++) {
296
if (cs_gui_strcmp(name[i], "thermal")) index = i;
298
iscalt[iphas] = index+1;
299
iscsth[index] = ind_thermal;
302
for (i=0; i < size; i++) BFT_FREE(name[i]);
307
/*-----------------------------------------------------------------------------
308
* Return the name of the diffusion_coefficient property for a scalar
311
* scalar_index --> index of the scalar
312
*----------------------------------------------------------------------------*/
315
_scalar_diffusion_coefficient_name(const int idx)
321
ncar = cs_gui_characters_number(idx+1);
322
BFT_MALLOC(name, strlen("diffusion_coefficient") +2 +ncar, char);
323
BFT_MALLOC(suf, 1 + ncar, char);
324
sprintf(suf, "%i", idx+1);
325
strcpy(name, "diffusion_coefficient");
332
/*-----------------------------------------------------------------------------
333
* Return the value of choice for user scalar's property
336
* scalar_num --> number of scalar
337
* choice --> choice for property
338
*----------------------------------------------------------------------------*/
341
cs_gui_scalar_properties_choice(const int scalar_num, int *const choice)
347
path = cs_xpath_init_path();
348
cs_xpath_add_element(&path, "additional_scalars");
349
cs_xpath_add_element_num(&path, "scalar", scalar_num);
350
cs_xpath_add_element(&path, "property");
351
cs_xpath_add_attribute(&path, "choice");
353
buff = cs_gui_get_attribute_value(path);
361
if (cs_gui_strcmp(buff, "variable") || cs_gui_strcmp(buff, "user_law"))
363
else if (cs_gui_strcmp(buff, "constant"))
366
bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
375
/*-----------------------------------------------------------------------------
376
* Return value of diffusion coefficient for user scalars
377
* return 1 if value exists
381
* num_sca --> number of scalar
382
* value <-- value of diffusion coefficient
383
*----------------------------------------------------------------------------*/
386
cs_gui_scalar_diffusion_value(const int num_sca,
392
path = cs_xpath_init_path();
393
cs_xpath_add_element(&path, "additional_scalars");
394
cs_xpath_add_element_num(&path, "scalar", num_sca);
395
cs_xpath_add_element(&path, "property");
396
cs_xpath_add_element(&path, "initial_value");
397
cs_xpath_add_function_text(&path);
399
if (cs_gui_get_double(path, &result))
405
/*-----------------------------------------------------------------------------
406
* Get the status of steady management.
409
* keyword <-- if 1 unsteady management else steady management
410
*----------------------------------------------------------------------------*/
413
cs_gui_get_steady_status(int *const keyword)
418
path = cs_xpath_short_path();
419
cs_xpath_add_element(&path, "steady_management");
420
cs_xpath_add_attribute(&path, "status");
422
if (cs_gui_get_status(path, &result))
430
/*-----------------------------------------------------------------------------
431
* Return parameters for steady management.
434
* param --> steady parameter
435
* keyword <-- new value for the steady parameter
436
*----------------------------------------------------------------------------*/
439
cs_gui_steady_parameters(const char *const param,
440
double *const keyword)
446
path = cs_xpath_init_path();
447
cs_xpath_add_elements(&path, 3, "analysis_control", "steady_management", param);
449
if (cs_gui_strcmp(param,"zero_iteration")){
451
cs_xpath_add_attribute(&path, "status");
452
if(cs_gui_get_status(path, &status)) *keyword = status;
456
cs_xpath_add_function_text(&path);
457
if (cs_gui_get_double(path, &result)) *keyword = result;
463
/*-----------------------------------------------------------------------------
464
* Modify time parameters.
467
* param --> time parameter
468
* keyword <-- new value of the time parameter
469
*----------------------------------------------------------------------------*/
472
cs_gui_time_parameters(const char *const param,
473
double *const keyword)
479
path = cs_xpath_init_path();
480
cs_xpath_add_elements(&path, 3, "analysis_control", "time_parameters", param);
482
if (cs_gui_strcmp(param,"zero_time_step") ||
483
cs_gui_strcmp(param,"thermal_time_step")) {
485
cs_xpath_add_attribute(&path, "status");
486
if(cs_gui_get_status(path, &status)) *keyword = status;
490
cs_xpath_add_function_text(&path);
491
if (cs_gui_get_double(path, &result)) *keyword = result;
497
/*-----------------------------------------------------------------------------
498
* Modify restart parameters.
501
* param --> restart parameter
502
* keyword <--> new value of the restart parameter
503
*----------------------------------------------------------------------------*/
506
cs_gui_restart_parameters_status(const char *param, int *const keyword)
511
path = cs_xpath_init_path();
512
cs_xpath_add_elements(&path, 3, "calcul_management", "start_restart", param);
514
if (cs_gui_strcmp(param, "restart_rescue")) {
515
cs_xpath_add_function_text(&path);
516
if (cs_gui_get_int(path, &result))
520
cs_xpath_add_attribute(&path, "status");
522
if (cs_gui_get_status(path, &result))
529
/*-----------------------------------------------------------------------------
530
* Return value of numerical parameter markup
533
* variable_type --> name of variable
534
* value_type --> name of numerical parameter parkup
535
* value <-- value of numerical parameter
536
*----------------------------------------------------------------------------*/
539
cs_gui_variable_value(const char *const variable_type,
540
const char *const value_type,
546
path = cs_xpath_short_path();
547
cs_xpath_add_element(&path, "variable");
548
cs_xpath_add_test_attribute(&path, "name", variable_type);
549
cs_xpath_add_element(&path, value_type);
550
cs_xpath_add_function_text(&path);
552
if (cs_gui_get_double(path, &result)) *value = result;
557
/*----------------------------------------------------------------------------
558
* Get the attribute value from the xpath query.
561
* path --> path for xpath query
562
* child --> child markup
563
* keyword <-- value of attribute node
564
*----------------------------------------------------------------------------*/
567
_attribute_value( char * path,
568
const char *const child,
574
assert(path != NULL);
575
assert(child != NULL);
577
if (cs_gui_strcmp(child, "order_scheme")) {
580
cs_xpath_add_attribute(&path, "choice");
581
choice = cs_gui_get_attribute_value(path);
583
if (cs_gui_strcmp(choice, "centered"))
585
else if (cs_gui_strcmp(choice, "solu"))
591
cs_xpath_add_attribute(&path, "status");
593
if (cs_gui_get_status(path, &result)) {
596
if (cs_gui_strcmp(child, "slope_test")) {
597
if (result == 1) *keyword = 0;
598
if (result == 0) *keyword = 1;
602
if (cs_gui_strcmp(child, "postprocessing_recording") ||
603
cs_gui_strcmp(child, "listing_printing")) *keyword = 1;
610
/*----------------------------------------------------------------------------
611
* Get the attribute value associated to a child markup from a variable.
614
* name --> name of the variable markup
615
* child --> child markup
616
* keyword <-- value of attribute node contained in the child markup
617
*----------------------------------------------------------------------------*/
620
cs_gui_variable_attribute(const char *const name,
621
const char *const child,
626
path = cs_xpath_short_path();
627
cs_xpath_add_element(&path, "variable");
628
cs_xpath_add_test_attribute(&path, "name", name);
629
cs_xpath_add_element(&path, child);
631
_attribute_value(path, child, keyword);
634
/*----------------------------------------------------------------------------
635
* Get the text value associated to a child markup from a scalar.
638
* label --> label of the scalar markup
639
* child --> name of the child markup
640
* value <-- value of text node contained in the child markup
641
*----------------------------------------------------------------------------*/
644
cs_gui_scalar_value(const char *const label,
645
const char *const child,
651
path = cs_xpath_short_path();
652
cs_xpath_add_element(&path, "scalar");
653
cs_xpath_add_test_attribute(&path, "label", label);
654
cs_xpath_add_element(&path, child);
655
cs_xpath_add_function_text(&path);
657
if (cs_gui_get_double(path, &result)) *value = result;
662
/*----------------------------------------------------------------------------
663
* Get the attribute value associated to a child markup from a scalar.
666
* label --> name of the scalar markup
667
* child --> child markup
668
* keyword <-- value of attribute node contained in the child markup
669
*----------------------------------------------------------------------------*/
672
cs_gui_scalar_attribute(const char *const label,
673
const char *const child,
678
path = cs_xpath_short_path();
679
cs_xpath_add_element(&path, "scalar");
680
cs_xpath_add_test_attribute(&path, "label", label);
681
cs_xpath_add_element(&path, child);
683
_attribute_value(path, child, keyword);
686
/*-----------------------------------------------------------------------------
687
* Get values related the modelling scalar: min, max ...
692
* the result is stored in "value"
693
*----------------------------------------------------------------------------*/
697
cs_gui_model_scalar_value(const char *const model,
698
const char *const name,
699
const char *const keyword,
705
path = cs_xpath_init_path();
706
cs_xpath_add_element(&path, "thermophysical_models");
707
cs_xpath_add_element(&path, model);
708
cs_xpath_add_element(&path, "scalar");
709
cs_xpath_add_test_attribute(&path, "name", name);
710
cs_xpath_add_element(&path, keyword);
711
cs_xpath_add_function_text(&path);
713
if (cs_gui_get_double(path,&result))
719
/*----------------------------------------------------------------------------
720
* Get the attribute value associated to a child markup from a scalar.
723
* model --> model markup
724
* name --> name of the scalar markup
725
* child --> child markup
726
* keyword <-- value of attribute node contained in the child markup
727
*----------------------------------------------------------------------------*/
730
cs_gui_model_scalar_output_status(const char *const model,
731
const char *const name,
732
const char *const child,
737
path = cs_xpath_init_path();
738
cs_xpath_add_element(&path, "thermophysical_models");
739
cs_xpath_add_element(&path, model);
740
cs_xpath_add_element(&path, "scalar");
741
cs_xpath_add_test_attribute(&path, "name", name);
742
cs_xpath_add_element(&path, child);
744
_attribute_value(path, child, keyword);
747
/*-----------------------------------------------------------------------------
748
* Modify double numerical parameters.
751
* param --> label of the numerical parameter
752
* keyword <--> value of the numerical parameter
753
*----------------------------------------------------------------------------*/
756
cs_gui_numerical_double_parameters(const char *const param,
757
double *const keyword)
762
path = cs_xpath_init_path();
763
cs_xpath_add_element(&path, "numerical_parameters");
764
cs_xpath_add_element(&path, param);
765
cs_xpath_add_function_text(&path);
767
if (cs_gui_get_double(path, &result))
773
/*-----------------------------------------------------------------------------
774
* Modify integer numerical parameters.
777
* param --> label of the numerical parameter
778
* keyword <--> value of the numerical parameter
779
*----------------------------------------------------------------------------*/
782
cs_gui_numerical_int_parameters(const char *const param,
789
path = cs_xpath_init_path();
790
cs_xpath_add_element(&path, "numerical_parameters");
791
cs_xpath_add_element(&path, param);
793
if (cs_gui_strcmp(param, "gradient_reconstruction")){
795
cs_xpath_add_attribute(&path, "choice");
796
choice = cs_gui_get_attribute_value(path);
797
if (choice) *keyword = atoi(choice);
802
cs_xpath_add_attribute(&path, "status");
803
if (cs_gui_get_status(path, &result)) *keyword = result;
809
/*-----------------------------------------------------------------------------
810
* Modify gravity parameters.
813
* param --> gravity parameter (GX, GY, GZ)
814
* keyword <--> new value of the gravity parameter
815
*----------------------------------------------------------------------------*/
818
cs_gui_gravity_value(const char *const param,
824
path = cs_xpath_init_path();
825
cs_xpath_add_elements(&path, 3, "physical_properties", "gravity", param);
826
cs_xpath_add_function_text(&path);
828
if (cs_gui_get_double(path, &result)) *value = result;
833
/*-----------------------------------------------------------------------------
834
* Get initial value from property markup.
837
* property_name --> name of the property
838
* value <-- new initial value of the property
839
*----------------------------------------------------------------------------*/
842
cs_gui_properties_value(const char *const property_name,
848
path = cs_xpath_short_path();
849
cs_xpath_add_element(&path, "property");
850
cs_xpath_add_test_attribute(&path, "name", property_name);
851
cs_xpath_add_element(&path, "initial_value");
852
cs_xpath_add_function_text(&path);
854
if (cs_gui_get_double(path, &result)) *value = result;
858
/*----------------------------------------------------------------------------
859
* Return the value of the choice attribute from a property name.
862
* property_name --> name of the property
863
*----------------------------------------------------------------------------*/
866
_properties_choice(const char *const property_name)
871
path = cs_xpath_short_path();
872
cs_xpath_add_element(&path, "property");
873
cs_xpath_add_test_attribute(&path, "name", property_name);
874
cs_xpath_add_attribute(&path, "choice");
875
choice = cs_gui_get_attribute_value(path);
880
/*----------------------------------------------------------------------------
881
* Get the value of the choice attribute from a property markup.
882
* Return 1 if the xpath request has succeeded, 0 otherwise.
885
* property_name --> name of the property
886
* choice <-- value of the attribute choice
887
*----------------------------------------------------------------------------*/
890
cs_gui_properties_choice(const char *const property_name, int *choice)
895
buff = _properties_choice(property_name);
899
if (cs_gui_strcmp(buff, "variable") || cs_gui_strcmp(buff, "user_law"))
901
else if (cs_gui_strcmp(buff, "constant"))
910
/*-----------------------------------------------------------------------------
911
* Get reference value of pressure
914
* p0 <-- value of pressure
915
*----------------------------------------------------------------------------*/
918
cs_gui_reference_pressure(double *const p0)
923
path = cs_xpath_short_path();
924
cs_xpath_add_element(&path, "reference_pressure");
925
cs_xpath_add_function_text(&path);
927
if (cs_gui_get_double(path, &value))
932
/*-----------------------------------------------------------------------------
933
* Get reference value of temperature
936
* model --> name of activated model
937
* t0 <-- value of temperature
938
*----------------------------------------------------------------------------*/
941
cs_gui_reference_temperature(char *const model, double *const t0)
946
path = cs_xpath_short_path();
947
cs_xpath_add_elements(&path, 2, model,"reference_temperature");
948
cs_xpath_add_function_text(&path);
950
if (cs_gui_get_double(path, &value)) *t0 = value;
954
/*-----------------------------------------------------------------------------
955
* Get reference value of mass molar molecular
958
* model --> name of activated model
959
* m0 <-- value of mass molar molecular
960
*----------------------------------------------------------------------------*/
962
static void cs_gui_reference_mass_molar(char *const model, double *const m0)
967
path = cs_xpath_short_path();
968
cs_xpath_add_elements(&path, 2, model,"reference_mass_molar");
969
cs_xpath_add_function_text(&path);
971
if (cs_gui_get_double(path, &value)) *m0 = value;
975
/*----------------------------------------------------------------------------
976
* Turbulence model parameters.
979
* param --> name of the parameters
980
* keyword <-- turbulence model parameter
981
*----------------------------------------------------------------------------*/
983
static void _option_turbulence_double(const char *const param,
984
double *const keyword)
989
path = cs_xpath_init_path();
990
cs_xpath_add_elements(&path, 3, "thermophysical_models", "turbulence", param);
992
cs_xpath_add_function_text(&path);
993
if (cs_gui_get_double(path, &result)) *keyword = result;
998
/*----------------------------------------------------------------------------
999
* Initialization choice of the turbulence variables parameters.
1002
* param --> name of the parameters
1003
* value <-- initialization choice
1004
*----------------------------------------------------------------------------*/
1006
static void cs_gui_turbulence_initialization(const char *const param,
1007
double *const value)
1012
path = cs_xpath_init_path();
1013
cs_xpath_add_elements(&path, 4,
1014
"thermophysical_models",
1018
cs_xpath_add_function_text(&path);
1020
if (cs_gui_get_double(path, &result)) *value = result;
1024
/*----------------------------------------------------------------------------
1025
* Return the initialization choice of the turbulence variables.
1026
*----------------------------------------------------------------------------*/
1028
static char *cs_gui_turbulence_initialization_choice(void)
1031
char *initialization_choice;
1033
path = cs_xpath_init_path();
1034
cs_xpath_add_elements(&path, 3,
1035
"thermophysical_models",
1038
cs_xpath_add_attribute(&path, "choice");
1040
initialization_choice = cs_gui_get_attribute_value(path);
1044
return initialization_choice;
1047
/*================================
1049
*===============================*/
1051
/*----------------------------------------------------------------------------
1052
* Get output control value parameters.
1055
* param --> name of the parameter
1056
* keyword <-- output control parameter
1057
*----------------------------------------------------------------------------*/
1059
static void cs_gui_output_value(const char *const param,
1063
char *choice = NULL;
1066
path = cs_xpath_init_path();
1067
cs_xpath_add_elements(&path, 3, "analysis_control", "output", param);
1069
if (cs_gui_strcmp(param, "auxiliary_restart_file_writing") ||
1070
cs_gui_strcmp(param, "fluid_domain") ||
1071
cs_gui_strcmp(param, "domain_boundary") ||
1072
cs_gui_strcmp(param, "syrthes_boundary") ) {
1074
cs_xpath_add_attribute(&path, "status");
1075
if(cs_gui_get_status(path, &result)) *keyword = result;
1077
}else if (cs_gui_strcmp(param, "postprocessing_mesh_options")){
1078
cs_xpath_add_attribute(&path, "choice");
1079
choice = cs_gui_get_attribute_value(path);
1080
if (choice) *keyword = atoi(choice);
1083
cs_xpath_add_function_text(&path);
1084
if (cs_gui_get_int(path, &result)) *keyword = result;
1092
/*----------------------------------------------------------------------------
1093
* Return the output format and options for postprocessing.
1096
* param --> "postprocessing_format" or "postprocessing_options"
1097
*----------------------------------------------------------------------------*/
1100
_output_choice(const char *const param)
1103
char *choice = NULL;
1105
path = cs_xpath_init_path();
1106
cs_xpath_add_elements(&path, 3, "analysis_control", "output", param);
1107
cs_xpath_add_attribute(&path, "choice");
1108
choice = cs_gui_get_attribute_value(path);
1113
/*----------------------------------------------------------------------------
1114
* Get the output format and options for postprocessing.
1117
* param --> name of the parameter
1118
* keyword <-- output control parameter
1119
* size_key --> keyword string size
1120
*----------------------------------------------------------------------------*/
1122
static void cs_gui_output_choice(const char *const param,
1123
char *const keyword,
1124
const int *const size_key)
1126
char *choice = NULL;
1127
choice = _output_choice(param);
1128
if (choice != NULL) cs_gui_strcpy_c2f(keyword, choice, *size_key);
1132
/*----------------------------------------------------------------------------
1133
* Get postprocessing value parameters for surfacic variables
1136
* name --> name of the parameter
1137
* keyword <-- output control parameter
1138
*----------------------------------------------------------------------------*/
1140
static void cs_gui_surfacic_variable_post(const char *const name,
1141
const int *const param,
1147
path = cs_xpath_short_path();
1148
cs_xpath_add_element(&path, "property");
1150
cs_xpath_add_test_attribute(&path, "name", name);
1151
cs_xpath_add_element(&path, "postprocessing_recording");
1152
cs_xpath_add_attribute(&path, "status");
1153
if (cs_gui_get_status(path, &result)) {
1155
*ipstdv = *ipstdv / *param;
1161
/*==================================
1162
* TREATMENTS FOR TIME AVERAGES
1163
*=================================*/
1165
/*----------------------------------------------------------------------------
1166
* Return the number of variables and properties inside a given time average.
1169
* id --> time average number (imom)
1170
*----------------------------------------------------------------------------*/
1173
_get_time_average_n_variables(const int id)
1178
path = cs_xpath_init_path();
1179
cs_xpath_add_elements(&path, 2, "analysis_control", "time_averages");
1180
cs_xpath_add_element_num(&path, "time_average", id);
1181
cs_xpath_add_element(&path, "var_prop");
1182
number = cs_gui_get_nb_element(path);
1190
/*----------------------------------------------------------------------------
1191
* Get value of a parameter for a given time avegare.
1194
* id --> time average number (imom)
1195
* param --> name of the parameter
1196
* data <-- value of the parameter
1197
*----------------------------------------------------------------------------*/
1199
static void _get_time_average_data(const int id,
1200
const char *const param,
1206
path = cs_xpath_init_path();
1207
cs_xpath_add_elements(&path, 2, "analysis_control", "time_averages");
1208
cs_xpath_add_element_num(&path, "time_average", id);
1209
cs_xpath_add_element(&path, param);
1211
cs_xpath_add_function_text(&path);
1212
if (cs_gui_get_int(path, &result))
1218
/*----------------------------------------------------------------------------
1219
* Return the name of a variable or a property for a given time average.
1222
* id --> time average number (imom)
1223
* nb --> variable or property number
1224
*----------------------------------------------------------------------------*/
1226
static char *_get_time_average_variable_name(const int id, const int nb)
1231
path = cs_xpath_init_path();
1232
cs_xpath_add_elements(&path, 2, "analysis_control", "time_averages");
1233
cs_xpath_add_element_num(&path, "time_average", id);
1234
cs_xpath_add_element_num(&path, "var_prop", nb);
1235
cs_xpath_add_attribute(&path, "name");
1237
name = cs_gui_get_attribute_value(path);
1243
/*----------------------------------------------------------------------------
1244
* Return the label of a time average.
1247
* id --> time average number (imom)
1248
*----------------------------------------------------------------------------*/
1250
static char *_get_time_average_label(const int id)
1255
path = cs_xpath_init_path();
1256
cs_xpath_add_elements(&path, 2, "analysis_control", "time_averages");
1257
cs_xpath_add_element_num(&path, "time_average", id);
1258
cs_xpath_add_attribute(&path,"label");
1260
label = cs_gui_get_attribute_value(path);
1266
/*===================
1268
*==================*/
1270
/*-----------------------------------------------------------------------------
1271
* Return a single coordinate of a monitoring probe
1274
* num_probe --> number aka name of the monitoring probe
1275
* probe_coord --> one coordinate of the monitoring probe
1276
*----------------------------------------------------------------------------*/
1278
static double cs_gui_probe_coordinate(const int num_probe,
1279
const char *const probe_coord)
1282
double result = 0.0;
1284
assert(num_probe>0);
1286
path = cs_xpath_init_path();
1287
cs_xpath_add_elements(&path, 2, "analysis_control", "output");
1288
cs_xpath_add_element_num(&path, "probe", num_probe);
1289
cs_xpath_add_element(&path, probe_coord);
1290
cs_xpath_add_function_text(&path);
1292
if (!cs_gui_get_double(path, &result))
1293
bft_error(__FILE__, __LINE__, 0,
1294
_("Coordinate %s of the monitoring probe number %i "
1295
"not found.\nXpath: %s\n"), probe_coord, num_probe, path);
1302
/*-----------------------------------------------------------------------------
1303
* Retourne le nombre de sous-balises "probe recording" situees dans la balise
1305
*----------------------------------------------------------------------------*/
1307
static int cs_gui_variable_number_probes (const char *const variable)
1310
char *choice = NULL;
1313
path = cs_xpath_short_path();
1314
cs_xpath_add_element(&path, "variable");
1315
cs_xpath_add_test_attribute(&path, "name", variable);
1316
cs_xpath_add_element(&path, "probes");
1317
cs_xpath_add_attribute(&path, "choice");
1318
choice = cs_gui_get_attribute_value(path);
1321
nb_probes = atoi(choice);
1331
/*-----------------------------------------------------------------------------
1332
* Return probe number for balice "probe_recording" for variable
1335
* variable --> name of variable
1336
* num_probe --> number of balise "probe_recording"
1337
*----------------------------------------------------------------------------*/
1339
static int cs_gui_variable_probe_name (const char *const variable,
1343
char *strvalue = NULL;
1346
path = cs_xpath_short_path();
1347
cs_xpath_add_element(&path, "variable");
1348
cs_xpath_add_test_attribute(&path, "name", variable);
1349
cs_xpath_add_element(&path, "probes");
1350
cs_xpath_add_element_num(&path, "probe_recording", num_probe);
1351
cs_xpath_add_attribute(&path, "name");
1353
strvalue = cs_gui_get_attribute_value(path);
1355
if (strvalue == NULL)
1356
bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
1358
intvalue = atoi(strvalue);
1366
/*-----------------------------------------------------------------------------
1367
* Return label of variable
1370
* variable --> name of variable
1371
*----------------------------------------------------------------------------*/
1373
static char *cs_gui_variable_label (const char *const variable)
1378
path = cs_xpath_short_path();
1379
cs_xpath_add_element(&path, "variable");
1380
cs_xpath_add_test_attribute(&path, "name", variable);
1381
cs_xpath_add_attribute(&path, "label");
1383
label = cs_gui_get_attribute_value(path);
1390
/*-----------------------------------------------------------------------------
1391
* Post-processing options for variables (velocity, pressure, ...)
1392
* the "globale" array is built in CSENSO
1393
* globale[num_probe] = num_saturne_probe
1394
* where num_saturne_probe is the probe number in the code
1395
* num_probe and num_saturne_probe are different when some probes
1396
* are de-activated in the XML file
1397
*----------------------------------------------------------------------------*/
1399
static void cs_gui_thermophysical_post(const char *const variable,
1404
const int *const nvppmx)
1408
char *varname = NULL;
1411
if (ipp == 1) return;
1413
cs_gui_variable_attribute(variable,
1414
"postprocessing_recording",
1417
cs_gui_variable_attribute(variable,
1421
nb_probes = cs_gui_variable_number_probes(variable);
1423
ihisvr[0 + (ipp - 1)] = nb_probes;
1425
if (nb_probes > 0) {
1426
for (iprob =0; iprob < nb_probes; iprob++) {
1427
num_probe = cs_gui_variable_probe_name(variable, iprob+1);
1428
ihisvr[(iprob+1)*(*nvppmx) + (ipp - 1)] = num_probe;
1432
varname = cs_gui_variable_label(variable);
1433
_gui_copy_varname(varname, ipp);
1438
/*-----------------------------------------------------------------------------
1439
* Number of sub-headers "probe_recording" for the user scalars
1440
*----------------------------------------------------------------------------*/
1442
static int cs_gui_scalar_number_probes(const int scalar_num)
1445
char *choice = NULL;
1448
path = cs_xpath_init_path();
1449
cs_xpath_add_element(&path, "additional_scalars");
1450
cs_xpath_add_element_num(&path, "scalar", scalar_num);
1451
cs_xpath_add_element(&path, "probes");
1452
cs_xpath_add_attribute(&path, "choice");
1453
choice = cs_gui_get_attribute_value(path);
1456
nb_probes = atoi(choice);
1466
/*-----------------------------------------------------------------------------
1467
* Return probe number for number of balise "probe_recording"
1470
* scalar_num --> number of scalar
1471
* num_probe --> number of balise "probe_recording"
1472
*----------------------------------------------------------------------------*/
1474
static int cs_gui_scalar_probe_name(const int scalar_num,
1475
const int num_probe)
1478
char *strvalue = NULL;
1481
path = cs_xpath_init_path();
1482
cs_xpath_add_element(&path, "additional_scalars");
1483
cs_xpath_add_element_num(&path, "scalar", scalar_num);
1484
cs_xpath_add_element(&path, "probes");
1485
cs_xpath_add_element_num(&path, "probe_recording", num_probe);
1486
cs_xpath_add_attribute(&path, "name");
1488
strvalue = cs_gui_get_attribute_value(path);
1490
if (strvalue == NULL)
1491
bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
1493
value = atoi(strvalue);
1501
/*-----------------------------------------------------------------------------
1502
* Post-processing options for scalars
1503
* the "globale" array is built in CSENSO
1504
* globale[num_probe] = num_saturne_probe
1505
* where num_saturne_probe is the probe number in the code
1506
* num_probe and num_saturne_probe are different when some probes
1507
* are de-activated in the XML file
1508
*----------------------------------------------------------------------------*/
1510
static void cs_gui_scalar_post(const int num_sca,
1514
const int *const ipprtp,
1515
const int *const isca,
1516
const int *const nvppmx)
1523
cs_var_t *vars = cs_glob_var;
1525
ipp = ipprtp[isca[num_sca] -1 ];
1527
if (ipp == 1) return;
1529
/* EnSight outputs frequency */
1530
cs_gui_scalar_attribute(vars->label[num_sca],
1531
"postprocessing_recording",
1534
/* Listing output frequency */
1535
cs_gui_scalar_attribute(vars->label[num_sca],
1539
/* Activated probes */
1540
nb_probes = cs_gui_scalar_number_probes(num_sca+1);
1541
ihisvr[0 + (ipp - 1)] = nb_probes;
1543
if (nb_probes > 0) {
1544
for (iprob=0; iprob < nb_probes; iprob++){
1545
num_probe = cs_gui_scalar_probe_name(num_sca+1, iprob+1);
1546
ihisvr[(iprob+1)*(*nvppmx) + (ipp - 1)] = num_probe;
1550
_gui_copy_varname(vars->label[num_sca], ipp);
1553
/*-----------------------------------------------------------------------------
1554
* Return number of sub balises "probe_recording" for model scalars
1557
* model --> Type of model
1558
* name --> scalar name
1559
*----------------------------------------------------------------------------*/
1561
static int cs_gui_model_scalar_number_probes(const char* const model,
1562
const char *const name)
1565
char *choice = NULL;
1568
path = cs_xpath_init_path();
1569
cs_xpath_add_element(&path, "thermophysical_models");
1570
cs_xpath_add_element(&path, model);
1571
cs_xpath_add_element(&path, "scalar");
1572
cs_xpath_add_test_attribute(&path, "name", name);
1573
cs_xpath_add_element(&path, "probes");
1574
cs_xpath_add_attribute(&path, "choice");
1575
choice = cs_gui_get_attribute_value(path);
1578
nb_probes = atoi(choice);
1588
/*-----------------------------------------------------------------------------
1589
* Return probe number for sub balise "probe_recording" for model scalar
1592
* model --> type of model
1593
* name --> scalar name
1594
* num_probe --> number of balise "probe_recording"
1595
*----------------------------------------------------------------------------*/
1597
static int cs_gui_model_scalar_probe_name (const char *const model,
1598
const char *const name,
1599
const int num_probe)
1602
char *strvalue = NULL;
1605
path = cs_xpath_init_path();
1606
cs_xpath_add_element(&path, "thermophysical_models");
1607
cs_xpath_add_element(&path, model);
1608
cs_xpath_add_element(&path, "scalar");
1609
cs_xpath_add_test_attribute(&path, "name", name);
1610
cs_xpath_add_element(&path, "probes");
1611
cs_xpath_add_element_num(&path, "probe_recording", num_probe);
1612
cs_xpath_add_attribute(&path, "name");
1614
strvalue = cs_gui_get_attribute_value(path);
1616
if (strvalue == NULL)
1617
bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
1619
value = atoi(strvalue);
1627
/*-----------------------------------------------------------------------------
1628
* Post-processing options for thermal and modelling scalars
1629
* the "globale" array is built in CSENSO
1630
* globale[num_probe] = num_saturne_probe
1631
* where num_saturne_probe is the probe number in the code
1632
* num_probe and num_saturne_probe are different when some probes
1633
* are de-activated in the XML file
1634
*----------------------------------------------------------------------------*/
1637
static void cs_gui_model_scalar_post(const char *const model,
1642
const int *const ipprtp,
1643
const int *const isca,
1644
const int *const nvppmx)
1651
cs_var_t *vars = cs_glob_var;
1653
ipp = ipprtp[isca[num_sca] -1];
1655
if (ipp == 1) return;
1657
/* EnSight outputs frequency */
1658
cs_gui_model_scalar_output_status(model, vars->label[num_sca],
1659
"postprocessing_recording",
1662
/* Listing output frequency */
1663
cs_gui_model_scalar_output_status(model, vars->label[num_sca],
1667
/* Activated probes */
1668
nb_probes = cs_gui_model_scalar_number_probes(model, vars->label[num_sca]);
1670
ihisvr[0 + (ipp - 1)] = nb_probes;
1672
if (nb_probes > 0) {
1673
for (iprob =0; iprob < nb_probes; iprob++) {
1674
num_probe = cs_gui_model_scalar_probe_name(model, vars->label[num_sca], iprob+1);
1675
ihisvr[(iprob+1)*(*nvppmx) + (ipp - 1)] = num_probe;
1679
_gui_copy_varname(vars->label[num_sca], ipp);
1682
/*-----------------------------------------------------------------------------
1683
* Return number of sub balises "probe_recording" for propeety of model scalar
1686
* model --> Type of model
1687
* num_sca --> scalar number
1688
*----------------------------------------------------------------------------*/
1690
static int cs_gui_model_property_number_probes(const char *const model,
1691
const char *const name)
1694
char *choice = NULL;
1697
path = cs_xpath_init_path();
1698
cs_xpath_add_element(&path, "thermophysical_models");
1699
cs_xpath_add_element(&path, model);
1700
cs_xpath_add_element(&path, "property");
1701
cs_xpath_add_test_attribute(&path, "name", name);
1702
cs_xpath_add_element(&path, "probes");
1703
cs_xpath_add_attribute(&path, "choice");
1704
choice = cs_gui_get_attribute_value(path);
1707
nb_probes = atoi(choice);
1717
/*-----------------------------------------------------------------------------
1718
* Return probe number for sub balise "probe_recording" for physical model's
1722
* model --> type of model
1723
* num_prop --> number of property
1724
* num_probe --> number of balise "probe_recording"
1725
*----------------------------------------------------------------------------*/
1727
static int cs_gui_model_property_probe_name(const char *const model,
1728
const char *const name,
1729
const int num_probe)
1732
char *strvalue = NULL;
1735
path = cs_xpath_init_path();
1736
cs_xpath_add_element(&path, "thermophysical_models");
1737
cs_xpath_add_element(&path, model);
1738
cs_xpath_add_element(&path, "property");
1739
cs_xpath_add_test_attribute(&path, "name", name);
1740
cs_xpath_add_element(&path, "probes");
1741
cs_xpath_add_element_num(&path, "probe_recording", num_probe);
1742
cs_xpath_add_attribute(&path, "name");
1744
strvalue = cs_gui_get_attribute_value(path);
1746
if (strvalue == NULL)
1747
bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
1749
value = atoi(strvalue);
1757
/*-----------------------------------------------------------------------------
1758
* Return the label model's property
1762
* num_prop <-- property's number
1763
*----------------------------------------------------------------------------*/
1765
static char *cs_gui_get_model_property_label(const char *const model,
1766
const char *const name)
1769
char *label_name = NULL;
1771
path = cs_xpath_init_path();
1772
cs_xpath_add_element(&path, "thermophysical_models");
1773
cs_xpath_add_element(&path, model);
1774
cs_xpath_add_element(&path, "property");
1775
cs_xpath_add_test_attribute(&path, "name", name);
1776
cs_xpath_add_attribute(&path, "label");
1778
label_name = cs_gui_get_attribute_value(path);
1785
/*-----------------------------------------------------------------------------
1786
* Return status of the property for physical model
1789
* model --> type of model
1790
* num_pro --> property name
1791
* value_type --> type of value (listing_printing, postprocessing ..)
1792
* keyword <-- value for the Fortran array
1793
*----------------------------------------------------------------------------*/
1795
static void cs_gui_model_property_output_status (const char *const model,
1796
const char *const name,
1797
const char *const value_type,
1803
path = cs_xpath_init_path();
1804
cs_xpath_add_element(&path, "thermophysical_models");
1805
cs_xpath_add_element(&path, model);
1806
cs_xpath_add_element(&path, "property");
1807
cs_xpath_add_test_attribute(&path, "name", name);
1808
cs_xpath_add_element(&path, value_type);
1809
cs_xpath_add_attribute(&path, "status");
1811
if (cs_gui_get_status(path, &result))
1818
/*-----------------------------------------------------------------------------
1819
* Post-processing options for properties
1820
* the "globale" array is built in CSENSO
1821
* globale[num_probe] = num_saturne_probe
1822
* where num_saturne_probe is the probe number in the code
1823
* num_probe and num_saturne_probe are different when some probes
1824
* are de-activated in the XML file
1825
*----------------------------------------------------------------------------*/
1829
cs_gui_model_property_post (const char *const model,
1834
const int *const nvppmx)
1840
char *varname = NULL;
1842
cs_var_t *vars = cs_glob_var;
1844
ipp = vars->properties_ipp[num_prop];
1846
if (ipp == 1) return;
1848
/* EnSight outputs frequency */
1849
cs_gui_model_property_output_status(model,
1850
vars->properties_name[num_prop],
1851
"postprocessing_recording",
1854
/* Listing output frequency */
1855
cs_gui_model_property_output_status(model,
1856
vars->properties_name[num_prop],
1861
/* Activated probes */
1862
nb_probes = cs_gui_model_property_number_probes(model,
1863
vars->properties_name[num_prop]);
1865
ihisvr[0 + (ipp - 1)] = nb_probes;
1867
if (nb_probes > 0) {
1868
for (iprob=0; iprob<nb_probes; iprob++){
1869
num_probe = cs_gui_model_property_probe_name(model,
1870
vars->properties_name[num_prop],
1872
ihisvr[(iprob+1)*(*nvppmx) + (ipp - 1)] = num_probe;
1876
/* Take into account labels */
1878
varname = cs_gui_get_model_property_label(model, vars->properties_name[num_prop]);
1879
_gui_copy_varname(varname, ipp);
1884
/*-----------------------------------------------------------------------------
1885
* Return number of probes for property
1888
* property_name --> name of property
1889
*----------------------------------------------------------------------------*/
1891
static int cs_gui_properties_number_probes(const char *const property_name)
1894
char *choice = NULL;
1897
path = cs_xpath_short_path();
1898
cs_xpath_add_element(&path, "property");
1899
cs_xpath_add_test_attribute(&path, "name", property_name);
1900
cs_xpath_add_element(&path, "probes");
1901
cs_xpath_add_attribute(&path, "choice");
1902
choice = cs_gui_get_attribute_value(path);
1905
nb_probes = atoi(choice);
1915
/*-----------------------------------------------------------------------------
1916
* Return probe number for sub balise "probe_recording" for properties
1919
* property_name --> name of property
1920
* num_probe --> number of balise "probe_recording"
1921
*----------------------------------------------------------------------------*/
1923
static int cs_gui_properties_probe_name(const char *const property_name,
1924
const int num_probe)
1927
char *strvalue = NULL;
1930
path = cs_xpath_short_path();
1931
cs_xpath_add_element(&path, "property");
1932
cs_xpath_add_test_attribute(&path, "name", property_name);
1933
cs_xpath_add_element(&path, "probes");
1934
cs_xpath_add_element_num(&path, "probe_recording", num_probe);
1935
cs_xpath_add_attribute(&path, "name");
1937
strvalue = cs_gui_get_attribute_value(path);
1939
if (strvalue == NULL)
1940
bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
1942
value = atoi(strvalue);
1950
/*-----------------------------------------------------------------------------
1951
* Return the label attribute of a property markup.
1954
* property_name --> name of the property
1955
*----------------------------------------------------------------------------*/
1957
static char *cs_gui_properties_label(const char *const property_name)
1962
path = cs_xpath_short_path();
1963
cs_xpath_add_element(&path, "property");
1964
cs_xpath_add_test_attribute(&path, "name", property_name);
1965
cs_xpath_add_attribute(&path, "label");
1967
label = cs_gui_get_attribute_value(path);
1974
/*-----------------------------------------------------------------------------
1975
* Return status of thr property markup
1978
* property_name --> name of property
1979
* value_type --> type of balise (listing_printing, postprocessing ..)
1980
* keyword <-- number of balise "probe_recording"
1981
*----------------------------------------------------------------------------*/
1983
static void cs_gui_properties_status(const char *const property_name,
1984
const char *const value_type,
1990
path = cs_xpath_short_path();
1991
cs_xpath_add_element(&path, "property");
1992
cs_xpath_add_test_attribute(&path, "name", property_name);
1993
cs_xpath_add_element(&path, value_type);
1994
cs_xpath_add_attribute(&path, "status");
1996
if (cs_gui_get_status(path, &result))
2004
/*-----------------------------------------------------------------------------
2005
* Post-processing options for physical properties
2006
* the "globale" array is built in CSENSO
2007
* globale[num_probe] = num_saturne_probe
2008
* where num_saturne_probe is the probe number in the code
2009
* num_probe and num_saturne_probe are different when some probes
2010
* are de-activated in the XML file
2011
*----------------------------------------------------------------------------*/
2014
static void cs_gui_properties_post(const char *const property_name,
2019
const int *const nvppmx)
2023
char *varname = NULL;
2026
if (ipp == 1) return;
2028
varname = cs_gui_properties_label(property_name);
2029
if (varname == NULL) return;
2031
_gui_copy_varname(varname, ipp);
2034
cs_gui_properties_status(property_name,
2035
"postprocessing_recording",
2038
cs_gui_properties_status(property_name,
2042
nb_probes = cs_gui_properties_number_probes(property_name);
2044
ihisvr[0 + (ipp - 1)] = nb_probes;
2046
if (nb_probes > 0) {
2047
for (iprob =0; iprob < nb_probes; iprob++){
2048
num_probe = cs_gui_properties_probe_name(property_name,
2051
ihisvr[(iprob+1)*(*nvppmx) + (ipp - 1)] = num_probe;
2057
/*-----------------------------------------------------------------------------
2058
* Return number of probes for time average of property
2061
* property_name --> label of property
2062
*----------------------------------------------------------------------------*/
2064
static int cs_gui_time_average_number_probes(const char *const property_name)
2067
char *choice = NULL;
2070
path = cs_xpath_short_path();
2071
cs_xpath_add_element(&path, "time_average");
2072
cs_xpath_add_test_attribute(&path, "label", property_name);
2073
cs_xpath_add_element(&path, "probes");
2074
cs_xpath_add_attribute(&path, "choice");
2075
choice = cs_gui_get_attribute_value(path);
2078
nb_probes = atoi(choice);
2088
/*-----------------------------------------------------------------------------
2089
* Return probe number for sub balise "probe_recording" for time average of
2093
* property_name --> label of property
2094
* num_probe --> number of balise "probe_recording"
2095
*----------------------------------------------------------------------------*/
2097
static int cs_gui_time_average_probe_name(const char *const property_name,
2098
const int num_probe)
2101
char *strvalue = NULL;
2104
path = cs_xpath_short_path();
2105
cs_xpath_add_element(&path, "time_average");
2106
cs_xpath_add_test_attribute(&path, "label", property_name);
2107
cs_xpath_add_element(&path, "probes");
2108
cs_xpath_add_element_num(&path, "probe_recording", num_probe);
2109
cs_xpath_add_attribute(&path, "name");
2111
strvalue = cs_gui_get_attribute_value(path);
2113
if (strvalue == NULL)
2114
bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
2116
value = atoi(strvalue);
2124
/*-----------------------------------------------------------------------------
2125
* Return status of time average markup
2128
* property_name --> label of property
2129
* value_type --> type of balise (listing_printing, postprocessing ..)
2130
* keyword <-- number of balise "probe_recording"
2131
*----------------------------------------------------------------------------*/
2134
static void cs_gui_time_average_status(const char *const property_name,
2135
const char *const value_type,
2141
path = cs_xpath_short_path();
2142
cs_xpath_add_element(&path, "time_average");
2143
cs_xpath_add_test_attribute(&path, "label", property_name);
2144
cs_xpath_add_element(&path, value_type);
2145
cs_xpath_add_attribute(&path, "status");
2147
if (cs_gui_get_status(path, &result))
2155
/*-----------------------------------------------------------------------------
2156
* Post-processing options for temporal averaging
2157
* the "globale" array is built in CSENSO
2158
* globale[num_probe] = num_saturne_probe
2159
* where num_saturne_probe is the probe number in the code
2160
* num_probe and num_saturne_probe are different when some probes
2161
* are de-activated in the XML file
2162
*----------------------------------------------------------------------------*/
2164
static void cs_gui_time_average_post (const char *const property_name,
2169
const int *const nvppmx)
2175
if (ipp == 1) return;
2177
cs_gui_time_average_status(property_name,
2178
"postprocessing_recording",
2181
cs_gui_time_average_status(property_name,
2185
nb_probes = cs_gui_time_average_number_probes(property_name);
2187
ihisvr[0 + (ipp - 1)] = nb_probes;
2189
if (nb_probes > 0) {
2190
for (iprob =0; iprob < nb_probes; iprob++){
2191
num_probe = cs_gui_time_average_probe_name(property_name,
2194
ihisvr[(iprob+1)*(*nvppmx) + (ipp - 1)] = num_probe;
2197
_gui_copy_varname(property_name, ipp);
2201
/*-----------------------------------------------------------------------------
2202
* Return the label or the name from a scalar.
2205
* kw --> keyword: 'label' or 'name'
2206
* scalar_num <-- number of the searching scalar
2207
*----------------------------------------------------------------------------*/
2209
static char *_scalar_name_label(const char *kw, const int scalar_num)
2214
path = cs_xpath_short_path();
2215
cs_xpath_add_element(&path, "additional_scalars");
2216
cs_xpath_add_element_num(&path, "scalar", scalar_num);
2217
cs_xpath_add_attribute(&path, kw);
2219
str = cs_gui_get_attribute_value(path);
2226
/*==========================
2227
* FOR VOLUMICS ZONES
2228
*==========================*/
2230
/*-----------------------------------------------------------------------------
2231
* Return the name of the volumic zone
2234
* ith_zone --> id of volumic zone
2235
*----------------------------------------------------------------------------*/
2237
static char *cs_gui_volumic_zone_label(const int ith_zone)
2242
/* 1) get the name of the ith initialization zone */
2243
path = cs_xpath_init_path();
2244
cs_xpath_add_elements(&path, 2, "solution_domain", "volumic_conditions");
2245
cs_xpath_add_element_num(&path, "zone", ith_zone);
2246
cs_xpath_add_attribute(&path, "label");
2248
name = cs_gui_get_attribute_value(path);
2255
/*-----------------------------------------------------------------------------
2256
* Return the localisation for the volumic zone named label
2259
* label --> label of volumic zone
2260
*----------------------------------------------------------------------------*/
2262
static char *cs_gui_volumic_zone_localization(const char *const label)
2265
char *description = NULL;
2267
path = cs_xpath_init_path();
2268
cs_xpath_add_elements(&path, 3, "solution_domain",
2269
"volumic_conditions",
2271
cs_xpath_add_test_attribute(&path, "label", label);
2272
cs_xpath_add_function_text(&path);
2274
description = cs_gui_get_text_value(path);
2281
/*-----------------------------------------------------------------------------
2282
* Return the initial value of variable for the volumic zone named name
2285
* variable_name --> name of variable
2286
* zone_label --> label of volumic zone
2287
* initial_value <-- initial value
2288
*----------------------------------------------------------------------------*/
2290
static void cs_gui_variable_initial_value(const char *const variable_name,
2291
const char *const zone_label,
2292
double *const initial_value)
2297
path = cs_xpath_short_path();
2298
cs_xpath_add_element(&path, "variable");
2299
cs_xpath_add_test_attribute(&path, "name", variable_name);
2300
cs_xpath_add_element(&path, "initial_value");
2301
cs_xpath_add_test_attribute(&path, "label", zone_label);
2302
cs_xpath_add_function_text(&path);
2304
if (cs_gui_get_double(path, &result))
2305
*initial_value = result;
2307
*initial_value = 0.0;
2312
/*-----------------------------------------------------------------------------
2313
* Return the initial value of scalar for the volumic zone named name
2316
* parent --> name of balise parent for the scalar
2317
* label --> label of scalar
2318
* zone_label --> label of volumic zone
2319
* initial_value <-- initial value
2320
*----------------------------------------------------------------------------*/
2322
static void cs_gui_scalar_initial_value(const char *const parent,
2323
const char *const label,
2324
const char *const zone_label,
2325
double *const initial_value)
2330
path = cs_xpath_short_path();
2331
cs_xpath_add_elements(&path, 2, parent, "scalar");
2332
cs_xpath_add_test_attribute(&path, "label", label);
2333
cs_xpath_add_element(&path, "initial_value");
2334
cs_xpath_add_test_attribute(&path, "label", zone_label);
2335
cs_xpath_add_function_text(&path);
2337
if (cs_gui_get_double(path, &result))
2338
*initial_value = result;
2340
*initial_value = 0.0;
2345
/*----------------------------------------------------------------------------
2346
* Return integer value for calculation of size of user arrays
2347
*----------------------------------------------------------------------------*/
2349
static int _user_array(const char *const keyword1,
2350
const char *const keyword2)
2355
path = cs_xpath_short_path();
2356
cs_xpath_add_elements(&path, 2, keyword1, keyword2);
2357
cs_xpath_add_function_text(&path);
2358
cs_gui_get_int(path, &value);
2363
/*----------------------------------------------------------------------------
2364
* Get label of 1D profile file name
2367
* id --> number of order in list of 1D profile
2368
*----------------------------------------------------------------------------*/
2370
static char *_get_profile(const char *kw, const int id)
2375
path = cs_xpath_init_path();
2376
cs_xpath_add_elements(&path, 2, "analysis_control", "profiles");
2377
cs_xpath_add_element_num(&path, "profile", id+1);
2378
cs_xpath_add_attribute(&path, kw);
2380
label = cs_gui_get_attribute_value(path);
2387
/*----------------------------------------------------------------------------
2388
* Get number of variables or properties or scalar for 1D profile
2391
* id --> number of 1D profile
2392
*----------------------------------------------------------------------------*/
2394
static int _get_profile_names_number(const int id)
2399
path = cs_xpath_init_path();
2400
cs_xpath_add_elements(&path, 2, "analysis_control", "profiles");
2401
cs_xpath_add_element_num(&path, "profile", id+1);
2402
cs_xpath_add_element(&path, "var_prop");
2403
number = cs_gui_get_nb_element(path);
2410
/*----------------------------------------------------------------------------
2411
* Return the name of variables or properties or scalar for 1D profile
2414
* id --> number of 1D profile
2415
* nm --> number of the variable name of the idst 1D profile
2416
*----------------------------------------------------------------------------*/
2418
static char *_get_profile_name(const int id, const int nm)
2423
path = cs_xpath_init_path();
2424
cs_xpath_add_elements(&path, 2, "analysis_control", "profiles");
2425
cs_xpath_add_element_num(&path, "profile", id+1);
2426
cs_xpath_add_element_num(&path, "var_prop", nm+1);
2427
cs_xpath_add_attribute(&path, "name");
2429
name = cs_gui_get_attribute_value(path);
2431
bft_error(__FILE__, __LINE__, 0,
2432
_("Invalid xpath: %s\n name not found"), path);
2438
/*----------------------------------------------------------------------------
2439
* Return the label of variables or properties or scalar for 1D profile
2442
* id --> number of 1D profile
2443
* nm --> number of the variable name of the idst 1D profile
2444
*----------------------------------------------------------------------------*/
2446
static char *_get_profile_label_name(const int id, const int nm)
2453
cs_var_t *vars = cs_glob_var;
2454
name = _get_profile_name(id, nm);
2455
shift = vars->nvar - vars->nscapp - vars->nscaus;
2457
for (j=0 ; j < shift ; j++) {
2458
if (cs_gui_strcmp(name, vars->name[j]))
2459
label = cs_gui_variable_label(name);
2462
for (j=0 ; j < vars->nscaus + vars->nscapp; j++) {
2463
if (cs_gui_strcmp(name, vars->name[j+shift])) {
2464
BFT_MALLOC(label, strlen(vars->label[j])+1, char);
2465
strcpy(label, vars->label[j]);
2469
for (j=0; j < vars->nprop; j++) {
2470
if (cs_gui_strcmp(name, vars->properties_name[j])) {
2473
label = cs_gui_properties_label(vars->properties_name[j]);
2478
bft_error(__FILE__, __LINE__, 0,
2479
_("Invalid markup name: %s\n label not found"), name);
2487
/*----------------------------------------------------------------------------
2488
* Get coordinates or output frequency for 1D profile
2491
* id --> number of 1D profile
2492
* x <-- name of the coordinate (x1, y1, z1, x2, y2, z2)
2493
* or the output frequency
2494
*----------------------------------------------------------------------------*/
2496
static double _get_profile_coordinate(const int id, const char *const x)
2499
double coordinate = 0.0;
2501
path = cs_xpath_init_path();
2502
cs_xpath_add_elements(&path, 2, "analysis_control", "profiles");
2503
cs_xpath_add_element_num(&path, "profile", id+1);
2504
cs_xpath_add_element(&path, x);
2505
cs_xpath_add_function_text(&path);
2507
if (!cs_gui_get_double(path, &coordinate))
2508
bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
2515
/*============================================================================
2516
* Public Fortran function definitions
2517
*============================================================================*/
2519
/*----------------------------------------------------------------------------
2520
* Initialise the global 'vars' structure.
2522
* Fortran Interface:
2526
*----------------------------------------------------------------------------*/
2528
void CS_PROCF (uiinit, UIINIT) (void)
2530
assert(cs_glob_var == NULL);
2532
BFT_MALLOC(cs_glob_var, 1, cs_var_t);
2534
cs_glob_var->model = NULL;
2535
cs_glob_var->model_value = NULL;
2536
cs_glob_var->head = NULL;
2537
cs_glob_var->type = NULL;
2538
cs_glob_var->name = NULL;
2539
cs_glob_var->label = NULL;
2540
cs_glob_var->rtp = NULL;
2541
cs_glob_var->nvar = 0;
2542
cs_glob_var->nscaus = 0;
2543
cs_glob_var->nscapp = 0;
2544
cs_glob_var->nprop = 0;
2545
cs_glob_var->nsalpp = 0;
2546
cs_glob_var->ntimaver = 0;
2547
cs_glob_var->properties_name = NULL;
2548
cs_glob_var->properties_ipp = NULL;
2549
cs_glob_var->propce = NULL;
2551
BFT_MALLOC(cs_glob_label, 1, cs_label_t);
2553
cs_glob_label->_cs_gui_max_vars = 0;
2554
cs_glob_label->_cs_gui_last_var = 0;
2555
cs_glob_label->_cs_gui_var_name = NULL;
2558
/*----------------------------------------------------------------------------
2561
* Fortran Interface:
2563
* SUBROUTINE CSTURB (ITURB, IDEUCH, IGRAKE, IGRAKI, XLOMLG)
2566
* INTEGER ITURB <-- turbulence model
2567
* INTEGER IDEUCH <-- wall law treatment
2568
* INTEGER IGRAKE <-- k-eps gravity effects
2569
* INTEGER IGRAKI <-- Rij-eps gravity effects
2570
* DOUBLE PRECISION XLOMLG <-- mixing_length_scale
2571
*----------------------------------------------------------------------------*/
2574
void CS_PROCF (csturb, CSTURB) (int *const iturb,
2578
double *const xlomlg)
2583
model = cs_gui_get_thermophysical_model("turbulence");
2584
if (model == NULL) return;
2586
if (cs_gui_strcmp(model, "off"))
2588
else if (cs_gui_strcmp(model, "mixing_length")){
2590
_option_turbulence_double("mixing_length_scale", &xlomlg[iphas]);
2592
else if (cs_gui_strcmp(model, "k-epsilon")){
2594
cs_gui_advanced_options_turbulence("scale_model", &ideuch[iphas]);
2595
cs_gui_advanced_options_turbulence("gravity_terms", &igrake[iphas]);
2597
else if (cs_gui_strcmp(model, "k-epsilon-PL")){
2599
cs_gui_advanced_options_turbulence("scale_model", &ideuch[iphas]);
2600
cs_gui_advanced_options_turbulence("gravity_terms", &igrake[iphas]);
2602
else if (cs_gui_strcmp(model, "Rij-epsilon")){
2604
cs_gui_advanced_options_turbulence("scale_model", &ideuch[iphas]);
2605
cs_gui_advanced_options_turbulence("gravity_terms", &igrari[iphas]);
2607
else if (cs_gui_strcmp(model, "Rij-SSG")){
2609
cs_gui_advanced_options_turbulence("scale_model", &ideuch[iphas]);
2610
cs_gui_advanced_options_turbulence("gravity_terms", &igrari[iphas]);
2612
else if (cs_gui_strcmp(model, "LES_Smagorinsky")){
2615
else if (cs_gui_strcmp(model, "LES_dynamique")){
2618
else if (cs_gui_strcmp(model, "LES_WALE")){
2621
else if (cs_gui_strcmp(model, "v2f-phi")){
2623
cs_gui_advanced_options_turbulence("scale_model", &ideuch[iphas]);
2624
cs_gui_advanced_options_turbulence("gravity_terms", &igrake[iphas]);
2626
else if (cs_gui_strcmp(model, "k-omega-SST")){
2628
cs_gui_advanced_options_turbulence("scale_model", &ideuch[iphas]);
2629
cs_gui_advanced_options_turbulence("gravity_terms", &igrake[iphas]);
2632
bft_error(__FILE__, __LINE__, 0,
2633
_("Invalid turbulence model: %s.\n"), model);
2636
bft_printf("==>CSTURB\n");
2637
bft_printf("--model: %s\n", model);
2638
bft_printf("--iturb = %i\n", iturb[iphas]);
2639
bft_printf("--igrake = %i\n", igrake[iphas]);
2640
bft_printf("--igrari = %i\n", igrari[iphas]);
2641
bft_printf("--ideuch = %i\n", ideuch[iphas]);
2642
bft_printf("--xlomlg = %f\n", xlomlg[iphas]);
2648
/*----------------------------------------------------------------------------
2649
* Specific heat variable or constant indicator.
2651
* Fortran Interface:
2653
* SUBROUTINE CSCPVA (ICP)
2656
* INTEGER ICP <-- specific heat variable or constant indicator
2657
*----------------------------------------------------------------------------*/
2659
void CS_PROCF (cscpva, CSCPVA) (int *const icp)
2664
if (cs_gui_properties_choice("specific_heat", &choice)) icp[iphas] = choice;
2667
bft_printf("==>CSCPVA\n");
2668
bft_printf("--icp = %i\n", icp[iphas]);
2672
/*----------------------------------------------------------------------------
2673
* User scalars number.
2675
* Fortran Interface:
2677
* SUBROUTINE CSNSCA (NSCAUS)
2680
* INTEGER NSCAUS <-- user scalars number
2681
*----------------------------------------------------------------------------*/
2683
void CS_PROCF (csnsca, CSNSCA) (int *const nscaus)
2688
cs_var_t *vars = cs_glob_var;
2690
*nscaus = cs_gui_get_tag_number("/additional_scalars/scalar", 1);
2692
cs_glob_var->nscaus = *nscaus;
2694
BFT_MALLOC(vars->label, *nscaus, char*);
2696
for (i=0; i < vars->nscaus; i++) {
2697
label = _scalar_name_label("label", i+1);
2698
BFT_MALLOC(cs_glob_var->label[i], strlen(label)+1, char);
2699
strcpy(cs_glob_var->label[i], label);
2704
bft_printf("==>CSNSCA\n");
2705
bft_printf("--user scalars number: %i\n", vars->nscaus);
2706
for (i=0; i<*nscaus; i++)
2707
bft_printf("--label of scalar[%i]: %s\n", i, vars->label[i]);
2711
/*----------------------------------------------------------------------------
2712
* User scalars which are variance.
2714
* Fortran Interface:
2716
* SUBROUTINE CSISCA (ISCAVR)
2719
* INTEGER ISCAVR <-- user scalars variance array
2720
*----------------------------------------------------------------------------*/
2722
void CS_PROCF (csisca, CSISCA) (int *const iscavr)
2726
char *variance = NULL;
2728
cs_var_t *vars = cs_glob_var;
2730
if (vars->nscaus > 0) {
2732
for (i=0; i < vars->nscaus; i++) {
2733
variance = cs_gui_scalar_variance(i+1);
2735
if (variance != NULL) {
2737
for (j=0 ; j < vars->nscaus ; j++) {
2739
if (cs_gui_strcmp(variance, vars->label[j])) {
2742
bft_error(__FILE__, __LINE__, 0,
2743
_("Scalar: %i and its variance: %i are the same.\n"),
2753
bft_printf("==>CSISCA\n");
2754
for (i = 0 ; i < vars->nscaus ; i++)
2755
bft_printf("--iscavr[%i] = %i \n", i, iscavr[i]);
2761
/*----------------------------------------------------------------------------
2762
* Constant or variable indicator for the user scalar laminar viscosity.
2764
* Fortran Interface:
2766
* SUBROUTINE CSIVIS (ISCAVR, IVISLS, ISCALT, ISCSTH)
2769
* INTEGER ISCAVR <--> number of the related variance if any
2770
* INTEGER IVISLS <-- indicator for the user scalar viscosity
2771
* INTEGER ISCALT <--> number of the user thermal scalar if any
2772
* INTEGER ISCSTH <--> type of the user thermal scalar
2773
*----------------------------------------------------------------------------*/
2775
void CS_PROCF (csivis, CSIVIS) (int *const iscavr,
2782
int choice1, choice2;
2785
cs_var_t *vars = cs_glob_var;
2787
if (vars->nscaus > 0) {
2789
if (cs_gui_thermal_scalar()) {
2790
test1 = cs_gui_properties_choice("thermal_conductivity", &choice1);
2791
test2 = cs_gui_properties_choice("specific_heat", &choice2);
2793
if (test1 && test2) {
2794
cs_gui_thermal_scalar_number(iscalt, iscsth);
2796
if (choice1 || choice2)
2797
ivisls[iscalt[iphas]-1] = 1;
2799
ivisls[iscalt[iphas]-1] = 0;
2803
for (i=0 ; i < vars->nscaus; i++) {
2804
if (iscavr[i] <= 0 ) {
2805
if (cs_gui_scalar_properties_choice(i+1, &choice1))
2806
if (iscalt[iphas] != i+1) ivisls[i] = choice1;
2811
bft_printf("==>CSIVIS\n");
2812
for (i=0 ; i < vars->nscaus ; i++)
2813
bft_printf("--ivisls[%i] = %i\n", i, ivisls[i]);
2818
/*----------------------------------------------------------------------------
2819
* Time passing parameter.
2821
* Fortran Interface:
2823
* SUBROUTINE CSIDTV (IDTVAR)
2826
* INTEGER IDTVAR <-- fixed or variable time step
2827
*----------------------------------------------------------------------------*/
2829
void CS_PROCF (csidtv, CSIDTV) (int *const idtvar)
2834
cs_gui_get_steady_status(&steady);
2839
param = (double) *idtvar;
2840
cs_gui_time_parameters("time_passing", ¶m);
2841
*idtvar = (int) param;
2845
bft_printf("==>CSIDTV\n");
2846
bft_printf("--idtvar = %i\n", *idtvar);
2850
/*----------------------------------------------------------------------------
2851
* Hydrostatic pressure parameter.
2853
* Fortran Interface:
2855
* SUBROUTINE CSIPHY (IPHYDR)
2858
* INTEGER IPHYDR <-- hydrostatic pressure
2859
*----------------------------------------------------------------------------*/
2861
void CS_PROCF (csiphy, CSIPHY) (int *const iphydr)
2866
path = cs_xpath_short_path();
2867
cs_xpath_add_element(&path, "hydrostatic_pressure");
2868
cs_xpath_add_attribute(&path, "status");
2870
if (cs_gui_get_status(path, &result)) *iphydr = result;
2875
bft_printf("==>CSIPHY\n");
2876
bft_printf("--iphydr = %i\n", *iphydr);
2880
/*----------------------------------------------------------------------------
2881
* Constructs an indirection between an internal index vars->rtp and
2882
* the fortran array RTP.
2883
* This function is called after the third call to VARPOS routine.
2884
* Warning: in vars->rtp, variables are stored first and then
2885
* scalars (not like VARPOS because of ALE variables).
2887
* Fortran Interface:
2892
* INTEGER IPHYDR <-- hydrostatic pressure
2893
*----------------------------------------------------------------------------*/
2895
void CS_PROCF (csvnum, CSVNUM) (const int *const nvar,
2896
const int *const iu,
2897
const int *const iv,
2898
const int *const iw,
2899
const int *const ipr,
2900
const int *const iturb,
2901
const int *const ik,
2902
const int *const iep,
2903
const int *const ir11,
2904
const int *const ir22,
2905
const int *const ir33,
2906
const int *const ir12,
2907
const int *const ir13,
2908
const int *const ir23,
2909
const int *const iomg,
2910
const int *const iphi,
2911
const int *const ifb,
2912
const int *const iale,
2913
const int *const iuma,
2914
const int *const ivma,
2915
const int *const iwma,
2916
const int *const isca,
2917
const int *const iscapp)
2924
BFT_MALLOC(cs_glob_var->rtp, *nvar, int);
2925
BFT_MALLOC(cs_glob_var->head, *nvar, char*);
2926
BFT_MALLOC(cs_glob_var->type, *nvar, char*);
2927
BFT_MALLOC(cs_glob_var->name, *nvar, char*);
2929
/* Warning!! for scalars: vars->nscaus is already fill in CSNSCA */
2930
/* vars->nscapp is already fill in UIPPMO */
2932
cs_glob_var->nvar = *nvar;
2934
/* 1) pressure and velocity variables */
2937
cs_glob_var->rtp[n] = ipr[iphas] -1;
2938
BFT_MALLOC(cs_glob_var->name[n], strlen("pressure")+1, char);
2939
strcpy(cs_glob_var->name[n++], "pressure");
2941
cs_glob_var->rtp[n] = iu[iphas] -1;
2942
BFT_MALLOC(cs_glob_var->name[n], strlen("velocity_U")+1, char);
2943
strcpy(cs_glob_var->name[n++], "velocity_U");
2945
cs_glob_var->rtp[n] = iv[iphas] -1;
2946
BFT_MALLOC(cs_glob_var->name[n], strlen("velocity_V")+1, char);
2947
strcpy(cs_glob_var->name[n++], "velocity_V");
2949
cs_glob_var->rtp[n] = iw[iphas] -1;
2950
BFT_MALLOC(cs_glob_var->name[n], strlen("velocity_W")+1, char);
2951
strcpy(cs_glob_var->name[n++], "velocity_W");
2953
for (i=k; i < n; i++) {
2954
BFT_MALLOC(cs_glob_var->head[i], strlen("velocity_pressure")+1, char);
2955
strcpy(cs_glob_var->head[i], "velocity_pressure");
2958
/* 2) turbulence variables */
2962
if (iturb[iphas] == 20 || iturb[iphas] == 21) {
2964
cs_glob_var->rtp[n] = ik[iphas] -1;
2965
BFT_MALLOC(cs_glob_var->name[n], strlen("turb_k")+1, char);
2966
strcpy(cs_glob_var->name[n++], "turb_k");
2968
cs_glob_var->rtp[n] = iep[iphas] -1;
2969
BFT_MALLOC(cs_glob_var->name[n], strlen("turb_eps")+1, char);
2970
strcpy(cs_glob_var->name[n++], "turb_eps");
2972
} else if (iturb[iphas] == 30 || iturb[iphas] == 31) {
2974
cs_glob_var->rtp[n] = ir11[iphas] -1;
2975
BFT_MALLOC(cs_glob_var->name[n], strlen("component_R11")+1, char);
2976
strcpy(cs_glob_var->name[n++], "component_R11");
2978
cs_glob_var->rtp[n] = ir22[iphas] -1;
2979
BFT_MALLOC(cs_glob_var->name[n], strlen("component_R22")+1, char);
2980
strcpy(cs_glob_var->name[n++], "component_R22");
2982
cs_glob_var->rtp[n] = ir33[iphas] -1;
2983
BFT_MALLOC(cs_glob_var->name[n], strlen("component_R33")+1, char);
2984
strcpy(cs_glob_var->name[n++], "component_R33");
2986
cs_glob_var->rtp[n] = ir12[iphas] -1;
2987
BFT_MALLOC(cs_glob_var->name[n], strlen("component_R12")+1, char);
2988
strcpy(cs_glob_var->name[n++], "component_R12");
2990
cs_glob_var->rtp[n] = ir13[iphas] -1;
2991
BFT_MALLOC(cs_glob_var->name[n], strlen("component_R13")+1, char);
2992
strcpy(cs_glob_var->name[n++], "component_R13");
2994
cs_glob_var->rtp[n] = ir23[iphas] -1;
2995
BFT_MALLOC(cs_glob_var->name[n], strlen("component_R23")+1, char);
2996
strcpy(cs_glob_var->name[n++], "component_R23");
2998
cs_glob_var->rtp[n] = iep[iphas] -1;
2999
BFT_MALLOC(cs_glob_var->name[n], strlen("turb_eps")+1, char);
3000
strcpy(cs_glob_var->name[n++], "turb_eps");
3002
} else if (iturb[iphas] == 50) {
3004
cs_glob_var->rtp[n] = ik[iphas] -1;
3005
BFT_MALLOC(cs_glob_var->name[n], strlen("turb_k")+1, char);
3006
strcpy(cs_glob_var->name[n++], "turb_k");
3008
cs_glob_var->rtp[n] = iep[iphas] -1;
3009
BFT_MALLOC(cs_glob_var->name[n], strlen("turb_eps")+1, char);
3010
strcpy(cs_glob_var->name[n++], "turb_eps");
3012
cs_glob_var->rtp[n] = iphi[iphas] -1;
3013
BFT_MALLOC(cs_glob_var->name[n], strlen("turb_phi")+1, char);
3014
strcpy(cs_glob_var->name[n++], "turb_phi");
3016
cs_glob_var->rtp[n] = ifb[iphas] -1;
3017
BFT_MALLOC(cs_glob_var->name[n], strlen("turb_fb")+1, char);
3018
strcpy(cs_glob_var->name[n++], "turb_fb");
3020
} else if (iturb[iphas] == 60) {
3022
cs_glob_var->rtp[n] = ik[iphas] -1;
3023
BFT_MALLOC(cs_glob_var->name[n], strlen("turb_k")+1, char);
3024
strcpy(cs_glob_var->name[n++], "turb_k");
3026
cs_glob_var->rtp[n] = iomg[iphas] -1;
3027
BFT_MALLOC(cs_glob_var->name[n], strlen("turb_omega")+1, char);
3028
strcpy(cs_glob_var->name[n++], "turb_omega");
3031
for (i=k; i < n; i++) {
3032
BFT_MALLOC(cs_glob_var->head[i], strlen("turbulence")+1, char);
3033
strcpy(cs_glob_var->head[i], "turbulence");
3036
/* 3) ALE variables */
3041
cs_glob_var->rtp[n] = *iuma -1;
3042
BFT_MALLOC(cs_glob_var->name[n], strlen("mesh_velocity_U")+1, char);
3043
strcpy(cs_glob_var->name[n++], "mesh_velocity_U");
3045
cs_glob_var->rtp[n] = *ivma -1;
3046
BFT_MALLOC(cs_glob_var->name[n], strlen("mesh_velocity_V")+1, char);
3047
strcpy(cs_glob_var->name[n++], "mesh_velocity_V");
3049
cs_glob_var->rtp[n] = *iwma -1;
3050
BFT_MALLOC(cs_glob_var->name[n], strlen("mesh_velocity_W")+1, char);
3051
strcpy(cs_glob_var->name[n++], "mesh_velocity_W");
3053
for (i=k; i < n; i++) {
3054
BFT_MALLOC(cs_glob_var->head[i], strlen("ale_method")+1, char);
3055
strcpy(cs_glob_var->head[i], "ale_method");
3059
/* 4) update vars->type for variables */
3061
k = cs_glob_var->nvar -cs_glob_var->nscapp -cs_glob_var->nscaus;
3062
for (i=0; i < k; i++) {
3063
BFT_MALLOC(cs_glob_var->type[i], strlen("variable")+1, char);
3064
strcpy(cs_glob_var->type[i], "variable");
3067
/* 5) user scalars */
3069
for (i=0; i < cs_glob_var->nscaus; i++) {
3070
cs_glob_var->rtp[n++] = isca[i] -1;
3072
name = _scalar_name_label("name", i+1);
3073
BFT_MALLOC(cs_glob_var->name[k+i], strlen(name) +1, char);
3074
strcpy(cs_glob_var->name[k+i], name);
3077
BFT_MALLOC(cs_glob_var->type[k+i], strlen("scalar")+1, char);
3078
strcpy(cs_glob_var->type[k+i], "scalar");
3080
BFT_MALLOC(cs_glob_var->head[k+i], strlen("additional_scalar")+1, char);
3081
strcpy(cs_glob_var->head[k+i], "additional_scalar");
3084
/* 6) model scalars */
3086
k = cs_glob_var->nvar -cs_glob_var->nscaus - cs_glob_var->nscapp;
3087
for (i=0; i < cs_glob_var->nscapp; i++) {
3089
cs_glob_var->rtp[n++] = isca[j] -1;
3091
BFT_MALLOC(cs_glob_var->name[k+j], strlen(cs_glob_var->label[j]) +1, char);
3092
strcpy(cs_glob_var->name[k+j], cs_glob_var->label[j]);
3094
BFT_MALLOC(cs_glob_var->type[k+j], strlen("scalar")+1, char);
3095
strcpy(cs_glob_var->type[k+j], "scalar");
3097
BFT_MALLOC(cs_glob_var->head[k+j], strlen(cs_glob_var->model)+1, char);
3098
strcpy(cs_glob_var->head[k+j], cs_glob_var->model);
3101
/* 7) check for errors */
3104
bft_error(__FILE__, __LINE__, 0,
3105
_("The kernel variables number %i and the "
3106
"calculated one by the GUI %i are not the same.\n"),
3110
bft_printf("==>CSVNUM\n");
3111
bft_printf("--variables and scalars name: %i\n", cs_glob_var->nvar);
3112
for (i=0; i < cs_glob_var->nvar; i++)
3113
bft_printf("---name: %s\n", cs_glob_var->name[i]);
3114
/* for (i=0; i < vars->nscapp+vars->nscaus; i++)
3115
bft_printf("--scalars: %s\n", vars->label[i]); */
3120
/*----------------------------------------------------------------------------
3121
* Restart parameters.
3123
* Fortran Interface:
3125
* SUBROUTINE CSISUI (ISUITE, ILEAUX, ICCVFG)
3128
* INTEGER ISUITE <-- restart
3129
* INTEGER NTSUIT <-- checkpoint frequency
3130
* INTEGER ILEAUX <-- restart with auxiliary
3131
* INTEGER ICCFVG <-- restart with frozen field
3132
*----------------------------------------------------------------------------*/
3134
void CS_PROCF (csisui, CSISUI) (int *const isuite,
3139
cs_gui_restart_parameters_status("restart", isuite);
3140
cs_gui_restart_parameters_status("restart_rescue", ntsuit);
3141
cs_gui_restart_parameters_status("restart_with_auxiliary", ileaux);
3142
cs_gui_restart_parameters_status("frozen_field", iccvfg);
3145
bft_printf("==>CSISUI\n");
3146
bft_printf("--isuite = %i\n", *isuite);
3147
bft_printf("--ntsuit = %i\n", *ntsuit);
3148
bft_printf("--ileaux = %i\n", *ileaux);
3149
bft_printf("--iccvfg = %i\n", *iccvfg);
3153
/*----------------------------------------------------------------------------
3154
* Time passing parameters.
3156
* Fortran Interface:
3158
* SUBROUTINE CSTIME (INPDT0, IPTLTO, NTMABS, DTREF,
3159
* ***************** DTMIN, DTMAX, COUMAX, FOUMAX, VARRDT)
3161
* INTEGER INPDT0 <-- zero time step
3162
* INTEGER IPTLTO <-- thermal time step control
3163
* INTEGER NTMABS <-- iterations numbers
3164
* INTEGER IDTVAR <-- time steps'options
3165
* DOUBLE PRECISION DTREF <-- time step
3166
* DOUBLE PRECISION DTMIN <-- minimal time step
3167
* DOUBLE PRECISION DTMAX <-- maximal time step
3168
* DOUBLE PRECISION COUMAX <-- maximal courant number
3169
* DOUBLE PRECISION FOUMAX <-- maximal fournier number
3170
* DOUBLE PRECISION VARRDT <-- max time step variation between 2 iterations
3171
* DOUBLE PRECISION RELXST <-- relaxation coefficient id idtvar = -1
3172
*----------------------------------------------------------------------------*/
3174
void CS_PROCF (cstime, CSTIME) (int *const inpdt0,
3178
double *const dtref,
3179
double *const dtmin,
3180
double *const dtmax,
3181
double *const coumax,
3182
double *const foumax,
3183
double *const varrdt,
3184
double *const relxst)
3187
/* Default values for time step factor */
3188
double cdtmin = 0.1, cdtmax = 1000.;
3191
cs_gui_steady_parameters("relaxation_coefficient", relxst);
3193
value =(double) *inpdt0;
3194
cs_gui_steady_parameters("zero_iteration", &value);
3195
*inpdt0 = (int) value;
3197
value =(double) *ntmabs;
3198
cs_gui_steady_parameters("iterations", &value);
3199
*ntmabs = (int) value;
3202
cs_gui_time_parameters("time_step_ref", dtref);
3203
cs_gui_time_parameters("time_step_min_factor", &cdtmin);
3204
cs_gui_time_parameters("time_step_max_factor", &cdtmax);
3205
cs_gui_time_parameters("max_courant_num", coumax);
3206
cs_gui_time_parameters("max_fourier_num", foumax);
3207
cs_gui_time_parameters("time_step_var", varrdt);
3209
*dtmin = cdtmin*(*dtref);
3210
*dtmax = cdtmax*(*dtref);
3212
/* We keep these two lines in case we read an old XML file... */
3213
cs_gui_time_parameters("time_step_min", dtmin);
3214
cs_gui_time_parameters("time_step_max", dtmax);
3216
value =(double) *ntmabs;
3217
cs_gui_time_parameters("iterations", &value);
3218
*ntmabs = (int) value;
3220
value =(double) *inpdt0;
3221
cs_gui_time_parameters("zero_time_step", &value);
3222
*inpdt0 = (int) value;
3224
value =(double) *iptlro;
3225
cs_gui_time_parameters("thermal_time_step", &value);
3226
*iptlro = (int) value;
3230
bft_printf("==>CSTIME\n");
3231
bft_printf("--idtvar = %i\n", *idtvar);
3233
bft_printf("--inpdt0 = %i\n", *inpdt0);
3234
bft_printf("--relxst = %i\n", *relxst);
3237
bft_printf("--inpdt0 = %i\n", *inpdt0);
3238
bft_printf("--iptlro = %i\n", *iptlro);
3239
bft_printf("--ntmabs = %i\n", *ntmabs);
3240
bft_printf("--dtref = %f\n", *dtref);
3241
bft_printf("--dtmin = %f\n", *dtmin);
3242
bft_printf("--dtmax = %f\n", *dtmax);
3243
bft_printf("--coumax = %f\n", *coumax);
3244
bft_printf("--foumax = %f\n", *foumax);
3245
bft_printf("--varrdt = %f\n", *varrdt);
3250
/*----------------------------------------------------------------------------
3251
* Check if a users thermal scalar is defined.
3253
* Fortran Interface:
3255
* SUBROUTINE CSSCA1 (ISCALT, ISCSTH)
3258
* INTEGER ISCALT <-- number of the user thermal scalar if any
3259
* INTEGER ISCSTH <-- type of the user thermal scalar
3260
*----------------------------------------------------------------------------*/
3262
void CS_PROCF (cssca1, CSSCA1) (int *const iscalt,
3265
cs_gui_thermal_scalar_number(iscalt, iscsth);
3271
cs_var_t *vars = cs_glob_var;
3272
bft_printf("==>CSSCA1\n");
3273
bft_printf("--iscalt[0]=%i \n", iscalt[iphas]);
3274
for (i = 0 ; i < vars->nscaus ; i++)
3275
bft_printf("--iscsth[%i]=%i \n", i, iscsth[i]);
3280
/*----------------------------------------------------------------------------
3281
* Treatment of local numerical aspects:
3282
* BLENCV, ISCHCV, ISSTPC, IRCFLU, CDTVAR, NITMAX, EPSILO
3283
*----------------------------------------------------------------------------*/
3285
void CS_PROCF (uinum1, UINUM1) (const int *const isca,
3286
const int *const iscapp,
3287
double *const blencv,
3291
double *const cdtvar,
3293
double *const epsilo)
3298
cs_var_t *vars = cs_glob_var;
3300
k = vars->nvar - vars->nscaus - vars->nscapp;
3302
/* 1) variables from velocity_pressure and turbulence */
3303
/* 1-a) for pressure */
3305
cs_gui_variable_value(vars->name[0], "solveur_precision", &epsilo[j]);
3306
tmp = (double) nitmax[j];
3307
cs_gui_variable_value(vars->name[0], "max_iter_number", &tmp);
3308
nitmax[j] = (int) tmp;
3310
/* 1-b) for the other variables */
3311
for (i=1; i < k; i++) {
3313
cs_gui_variable_value(vars->name[i], "blending_factor", &blencv[j]);
3314
cs_gui_variable_value(vars->name[i], "solveur_precision", &epsilo[j]);
3315
tmp = (double) nitmax[j];
3316
cs_gui_variable_value(vars->name[i], "max_iter_number", &tmp);
3317
nitmax[j] = (int) tmp;
3318
cs_gui_variable_attribute(vars->name[i], "order_scheme", &ischcv[j]);
3319
cs_gui_variable_attribute(vars->name[i], "slope_test", &isstpc[j]);
3320
cs_gui_variable_attribute(vars->name[i], "flux_reconstruction", &ircflu[j]);
3323
/* 2) user scalars */
3325
if (vars->nscaus > 0 ) {
3326
for (i=0 ; i < vars->nscaus; i++) {
3328
cs_gui_scalar_value(vars->label[i], "blending_factor", &blencv[j]);
3329
cs_gui_scalar_value(vars->label[i], "solveur_precision", &epsilo[j]);
3330
cs_gui_scalar_value(vars->label[i], "time_step_factor", &cdtvar[j]);
3331
tmp = (double) nitmax[j];
3332
cs_gui_scalar_value(vars->label[i], "max_iter_number", &tmp);
3333
nitmax[j] = (int) tmp;
3334
cs_gui_scalar_attribute(vars->label[i], "order_scheme", &ischcv[j]);
3335
cs_gui_scalar_attribute(vars->label[i], "slope_test", &isstpc[j]);
3336
cs_gui_scalar_attribute(vars->label[i], "flux_reconstruction", &ircflu[j]);
3340
/* 3) model scalars */
3342
if (vars->nscapp > 0 ) {
3343
for (i=0 ; i < vars->nscapp ; i++) {
3346
cs_gui_model_scalar_value(vars->model, vars->label[j], "blending_factor", &blencv[jj]);
3347
cs_gui_model_scalar_value(vars->model, vars->label[j], "solveur_precision", &epsilo[jj]);
3348
cs_gui_model_scalar_value(vars->model, vars->label[j], "time_step_factor", &cdtvar[jj]);
3349
tmp = (double) nitmax[jj];
3350
cs_gui_model_scalar_value(vars->model, vars->label[j], "max_iter_number", &tmp);
3351
nitmax[jj] = (int) tmp;
3352
cs_gui_model_scalar_output_status(vars->model, vars->label[j], "order_scheme", &ischcv[jj]);
3353
cs_gui_model_scalar_output_status(vars->model, vars->label[j], "slope_test", &isstpc[jj]);
3354
cs_gui_model_scalar_output_status(vars->model, vars->label[j], "flux_reconstruction", &ircflu[jj]);
3359
bft_printf("==>UINUM1\n");
3360
for (i=0; i < vars->nvar; i++) {
3361
bft_printf("-->variable[%i] = %s\n", i, vars->name[i]);
3362
bft_printf("--blencv = %f\n", blencv[vars->rtp[i]]);
3363
bft_printf("--epsilo = %g\n", epsilo[vars->rtp[i]]);
3364
bft_printf("--cdtvar = %g\n", cdtvar[vars->rtp[i]]);
3365
bft_printf("--nitmax = %i\n", nitmax[vars->rtp[i]]);
3366
bft_printf("--ischcv = %i\n", ischcv[vars->rtp[i]]);
3367
bft_printf("--isstpc = %i\n", isstpc[vars->rtp[i]]);
3368
bft_printf("--ircflu = %i\n", ircflu[vars->rtp[i]]);
3370
for (i=0 ; i < vars->nscaus + vars->nscapp ; i++) {
3371
bft_printf("-->scalar[%i]: %s\n", isca[i]-1, vars->label[i]);
3372
bft_printf("--blencv = %f\n", blencv[isca[i]-1]);
3373
bft_printf("--epsilo = %g\n", epsilo[isca[i]-1]);
3374
bft_printf("--cdtvar = %g\n", cdtvar[isca[i]-1]);
3375
bft_printf("--nitmax = %i\n", nitmax[isca[i]-1]);
3376
bft_printf("--ischcv = %i\n", ischcv[isca[i]-1]);
3377
bft_printf("--isstpc = %i\n", isstpc[isca[i]-1]);
3378
bft_printf("--ircflu = %i\n", ircflu[isca[i]-1]);
3383
/*----------------------------------------------------------------------------
3384
* Global numerical parameters.
3386
* Fortran Interface:
3388
* SUBROUTINE CSNUM2 (IVISSE, RELAXP, IPUCOU, EXTRAG, IMRGRA, IMGRPR)
3390
* INTEGER IVISSE <-- gradient transposed
3391
* DOUBLE PRECISION RELAXP <-- pressure relaxation
3392
* INTEGER IPUCOU <-- velocity pressure coupling
3393
* DOUBLE PRECISION EXTRAG <-- wall pressure extrapolation
3394
* INTEGER IMRGRA <-- gradient reconstruction
3395
* INTEGER IMGRPR <-- multigrid algorithm for pressure
3396
*----------------------------------------------------------------------------*/
3398
void CS_PROCF (csnum2, CSNUM2)( int *const ivisse,
3399
double *const relaxp,
3401
double *const extrag,
3405
cs_gui_numerical_int_parameters("gradient_transposed", ivisse);
3406
cs_gui_numerical_int_parameters("velocity_pressure_coupling", ipucou);
3407
cs_gui_numerical_int_parameters("gradient_reconstruction", imrgra);
3408
cs_gui_numerical_int_parameters("multigrid", imgrpr);
3409
cs_gui_numerical_double_parameters("wall_pressure_extrapolation", extrag);
3410
cs_gui_numerical_double_parameters("pressure_relaxation", relaxp);
3413
bft_printf("==>CSNUM2\n");
3414
bft_printf("--ivisse = %i\n", *ivisse);
3415
bft_printf("--ipucou = %i\n", *ipucou);
3416
bft_printf("--imrgra = %i\n", *imrgra);
3417
bft_printf("--extrag = %f\n", *extrag);
3418
bft_printf("--relaxp = %f\n", *relaxp);
3419
bft_printf("--imgrpr = %i\n", *imgrpr);
3423
/*----------------------------------------------------------------------------
3424
* Treatment of gravity and fluid physical properties
3425
* Initialize reference pressure and temperature if present
3426
*----------------------------------------------------------------------------*/
3428
void CS_PROCF (csphys, CSPHYS)
3430
const int *const nmodpp,
3437
double *const omegax,
3438
double *const omegay,
3439
double *const omegaz,
3441
double *const viscl0,
3450
cs_var_t *vars = cs_glob_var;
3452
cs_gui_gravity_value("gravity_x", gx);
3453
cs_gui_gravity_value("gravity_y", gy);
3454
cs_gui_gravity_value("gravity_z", gz);
3456
cs_gui_properties_value("density", &ro0[iphas]);
3457
cs_gui_properties_value("molecular_viscosity", &viscl0[iphas]);
3458
cs_gui_properties_value("specific_heat", &cp0[iphas]);
3460
cs_gui_reference_pressure(p0);
3462
/* Variable rho and viscl */
3464
if (cs_gui_properties_choice("density", &choice))
3465
irovar[iphas] = choice;
3467
if (cs_gui_properties_choice("molecular_viscosity", &choice))
3468
ivivar[iphas] = choice;
3471
/* T0 if necessary */
3473
if (vars->model != NULL)
3474
cs_gui_reference_temperature(vars->model, t0);
3477
bft_printf("==>CSPHYS\n");
3478
bft_printf("--gx = %f \n",*gx);
3479
bft_printf("--gy = %f \n",*gy);
3480
bft_printf("--gz = %f \n",*gz);
3481
bft_printf("--rho = %g , variable %i\n", ro0[iphas], irovar[iphas]);
3482
bft_printf("--mu = %g , variable %i \n", viscl0[iphas], ivivar[iphas]);
3483
bft_printf("--Cp = %g \n", cp0[0]);
3484
bft_printf("--T0 = %f \n", *t0);
3485
bft_printf("--P0 = %f \n", *p0);
3489
/*----------------------------------------------------------------------------
3490
* User scalar min and max values for clipping.
3492
* Fortran Interface:
3494
* SUBROUTINE CSSCA2 (ISCAVR, SCAMIN, SCAMAX)
3497
* INTEGER ISCAVR --> number of the related variance if any
3498
* DOUBLE PRECISION SCAMIN <-- user scalar min array
3499
* DOUBLE PRECISION SCAMAX <-- user scalar max array
3500
*----------------------------------------------------------------------------*/
3502
void CS_PROCF (cssca2, CSSCA2) (const int *const iscavr,
3503
double *const scamin,
3504
double *const scamax)
3506
/* Specific physics: the min max of the model scalar are not given */
3509
cs_var_t *vars = cs_glob_var;
3511
if (vars->nscaus > 0 ) {
3512
for (i=0 ; i < vars->nscaus; i++) {
3513
if (iscavr[i] <= 0 ) {
3514
cs_gui_scalar_value(vars->label[i], "min_value", &scamin[i]);
3515
cs_gui_scalar_value(vars->label[i], "max_value", &scamax[i]);
3520
bft_printf("==>CSSCA2\n");
3521
for (i=0 ; i < vars->nscaus ; i++) {
3522
bft_printf("--scamin[%i] = %f\n", i, scamin[i]);
3523
bft_printf("--scamax[%i] = %f\n", i, scamax[i]);
3530
/*----------------------------------------------------------------------------
3531
* Read reference dynamic and user scalar viscosity
3532
*----------------------------------------------------------------------------*/
3535
void CS_PROCF (cssca3, CSSCA3) (const int *const iscalt,
3536
const int *const iscavr,
3537
double *const visls0,
3542
double result, coeff, density;
3544
cs_var_t *vars = cs_glob_var;
3546
if (vars->nscaus > 0) {
3548
if (cs_gui_thermal_scalar()) {
3550
cs_gui_properties_value("specific_heat", &result);
3552
bft_error(__FILE__, __LINE__, 0,
3553
_("Specific heat value is zero or not found in the xml file.\n"));
3555
i = iscalt[iphas]-1;
3556
cs_gui_properties_value("thermal_conductivity", &visls0[i]);
3557
visls0[i] = visls0[i]/result;
3561
In the interface, the user gives the diffusion coefficient, whereas in
3562
the solver, one sets the diffusivity, thus one need to multiply
3563
this coefficient by the density to remain coherent */
3565
for (i=0 ; i < vars->nscaus; i++) {
3566
if (iscavr[i] <= 0 && i != iscalt[iphas]-1) {
3568
if (cs_gui_strcmp(vars->model, "pulverized_coal")) {
3569
/* Air molar mass */
3571
cs_gui_reference_mass_molar(vars->model, &result);
3573
bft_error(__FILE__, __LINE__, 0,
3574
_("mass molar value is zero or not found in the xml file.\n"));
3575
density = *p0 * result / (8.31434 *(*t0));
3578
cs_gui_properties_value("density", &density);
3581
bft_error(__FILE__, __LINE__, 0,
3582
_("Density value is zero or not found in the xml file.\n"));
3584
coeff = visls0[i] / density ;
3585
cs_gui_scalar_diffusion_value(i+1, &coeff);
3586
visls0[i] = coeff * density;
3590
bft_printf("==>CSSCA3\n");
3591
for (i=0 ; i < vars->nscaus; i++)
3592
bft_printf("--visls0[%i] = %f\n", i, visls0[i]);
3597
/*----------------------------------------------------------------------------
3598
* Turbulence initialization parameters.
3600
* Fortran Interface:
3602
* SUBROUTINE CSTINI (UREF, ALMAX)
3605
* INTEGER UREF <-- reference velocity
3606
* INTEGER ALMAX <-- reference length
3607
*----------------------------------------------------------------------------*/
3609
void CS_PROCF (cstini, CSTINI) (double *const uref,
3610
double *const almax)
3613
char* turb_ini_choice = NULL;
3615
cs_gui_turbulence_initialization("reference_velocity", &uref[iphas]);
3617
turb_ini_choice = cs_gui_turbulence_initialization_choice();
3619
if (cs_gui_strcmp(turb_ini_choice, "reference_velocity_length"))
3620
cs_gui_turbulence_initialization("reference_length", &almax[iphas]);
3622
BFT_FREE(turb_ini_choice);
3625
bft_printf("==>CSTINI\n");
3626
bft_printf("--almax = %f\n", almax[iphas]);
3627
bft_printf("--uref = %f\n", uref[iphas]);
3631
/*----------------------------------------------------------------------------
3632
* Properties array used in the calculation
3633
*----------------------------------------------------------------------------*/
3635
void CS_PROCF (uiprop, UIPROP) (const int *const irom,
3636
const int *const iviscl,
3637
const int *const ivisct,
3638
const int *const ivisls,
3639
const int *const icour,
3640
const int *const ifour,
3641
const int *const ismago,
3642
const int *const iale,
3643
const int *const icp,
3644
const int *const iscalt,
3645
const int *const iscavr,
3646
const int *const iprtot,
3647
const int *const ipppro,
3648
const int *const ipproc,
3649
const int *const icmome,
3650
const int *const ipptx,
3651
const int *const ippty,
3652
const int *const ipptz,
3653
const int *const ippdt,
3654
const int *const ivisma,
3655
const int *const idtvar,
3656
const int *const ipucou,
3657
const int *const iappel)
3666
/* Compute the new size of vars->properties_name,
3667
vars->properties_ipp and vars->propce */
3669
if (ismago[iphas] != -1 ) nbp++;
3671
if (icp[iphas]>0) nbp++;
3673
if (cs_glob_var->nscaus > 0) {
3674
for (i=0; i < cs_glob_var->nscaus; i++)
3675
if (ivisls[i] > 0 && iscavr[i] <= 0) nbp++;
3679
cs_gui_get_ale_viscosity_type(&itype);
3687
n = cs_glob_var->nprop;
3691
cs_glob_var->nprop += nbp;
3693
/* Fisrt step : before the third call of VARPOS in INIUSI */
3695
BFT_REALLOC(cs_glob_var->properties_ipp, cs_glob_var->nprop, int);
3696
BFT_REALLOC(cs_glob_var->propce, cs_glob_var->nprop, int);
3697
BFT_REALLOC(cs_glob_var->properties_name, cs_glob_var->nprop, char*);
3699
cs_glob_var->properties_ipp[n] = ipppro[ ipproc[ irom[iphas]-1 ]-1 ];
3700
cs_glob_var->propce[n] = irom[iphas];
3701
BFT_MALLOC(cs_glob_var->properties_name[n], strlen("density")+1, char);
3702
strcpy(cs_glob_var->properties_name[n++], "density");
3704
cs_glob_var->properties_ipp[n] = ipppro[ ipproc[ iviscl[iphas]-1 ]-1 ];
3705
cs_glob_var->propce[n] = iviscl[iphas];
3706
BFT_MALLOC(cs_glob_var->properties_name[n], strlen("molecular_viscosity")+1, char);
3707
strcpy(cs_glob_var->properties_name[n++], "molecular_viscosity");
3709
cs_glob_var->properties_ipp[n] = ipppro[ ipproc[ ivisct[iphas]-1 ]-1 ];
3710
cs_glob_var->propce[n] = ivisct[iphas];
3711
BFT_MALLOC(cs_glob_var->properties_name[n], strlen("turb_viscosity")+1, char);
3712
strcpy(cs_glob_var->properties_name[n++], "turb_viscosity");
3714
cs_glob_var->properties_ipp[n] = ipppro[ ipproc[ icour[iphas]-1 ]-1 ];
3715
cs_glob_var->propce[n] = icour[iphas];
3716
BFT_MALLOC(cs_glob_var->properties_name[n], strlen("courant_number")+1, char);
3717
strcpy(cs_glob_var->properties_name[n++], "courant_number");
3719
cs_glob_var->properties_ipp[n] = ipppro[ ipproc[ ifour[iphas]-1 ]-1 ];
3720
cs_glob_var->propce[n] = ifour[iphas];
3721
BFT_MALLOC(cs_glob_var->properties_name[n], strlen("fourier_number")+1, char);
3722
strcpy(cs_glob_var->properties_name[n++], "fourier_number");
3724
if (ismago[iphas] != -1 ) {
3725
cs_glob_var->properties_ipp[n] = ipppro[ ipproc[ ismago[iphas]-1 ]-1 ];
3726
cs_glob_var->propce[n] = ismago[iphas];
3727
BFT_MALLOC(cs_glob_var->properties_name[n], strlen("smagorinsky_constant")+1, char);
3728
strcpy(cs_glob_var->properties_name[n++], "smagorinsky_constant");
3731
if (icp[iphas] > 0) {
3732
cs_glob_var->properties_ipp[n] = ipppro[ ipproc[ icp[iphas]-1 ]-1 ];
3733
cs_glob_var->propce[n] = icp[iphas];
3734
BFT_MALLOC(cs_glob_var->properties_name[n], strlen("specific_heat")+1, char);
3735
strcpy(cs_glob_var->properties_name[n++], "specific_heat");
3738
cs_glob_var->properties_ipp[n] = ipppro[ ipproc[ iprtot[iphas]-1 ]-1 ];
3739
cs_glob_var->propce[n] = iprtot[iphas];
3740
BFT_MALLOC(cs_glob_var->properties_name[n], strlen("total_pressure")+1, char);
3741
strcpy(cs_glob_var->properties_name[n++], "total_pressure");
3744
cs_glob_var->properties_ipp[n] = ipppro[ ipproc[ ivisma[0]-1 ]-1 ];
3745
cs_glob_var->propce[n] = ivisma[0];
3746
BFT_MALLOC(cs_glob_var->properties_name[n], strlen("mesh_viscosity_1")+1, char);
3747
strcpy(cs_glob_var->properties_name[n++], "mesh_viscosity_1");
3750
cs_glob_var->properties_ipp[n] = ipppro[ ipproc[ ivisma[1]-1 ]-1 ];
3751
cs_glob_var->propce[n] = ivisma[1];
3752
BFT_MALLOC(cs_glob_var->properties_name[n], strlen("mesh_viscosity_2")+1, char);
3753
strcpy(cs_glob_var->properties_name[n++], "mesh_viscosity_2");
3755
cs_glob_var->properties_ipp[n] = ipppro[ ipproc[ ivisma[2]-1 ]-1 ];
3756
cs_glob_var->propce[n] = ivisma[2];
3757
BFT_MALLOC(cs_glob_var->properties_name[n], strlen("mesh_viscosity_3")+1, char);
3758
strcpy(cs_glob_var->properties_name[n++], "mesh_viscosity_3");
3763
/* scalar diffusivity */
3765
if (cs_glob_var->nscaus > 0) {
3767
/* search lenght of first character of scalar property's suffixe : '_' */
3768
for (i=0; i < cs_glob_var->nscaus; i++) {
3770
if (iscavr[i] <= 0 && ivisls[i] > 0) {
3772
cs_glob_var->properties_ipp[n] = ipppro[ ipproc[ ivisls[i]-1 ]-1 ];
3773
cs_glob_var->propce[n] = ivisls[iphas];
3775
if (iscalt[iphas] == i+1) {
3776
BFT_MALLOC(cs_glob_var->properties_name[n], strlen("thermal_conductivity")+1, char);
3777
strcpy(cs_glob_var->properties_name[n++], "thermal_conductivity");
3779
name = _scalar_diffusion_coefficient_name(i);
3780
BFT_MALLOC(cs_glob_var->properties_name[n], strlen(name)+1, char);
3781
strcpy(cs_glob_var->properties_name[n++], name);
3790
/* Second step : before the fourth call of VARPOS in INIUSI */
3792
if (*idtvar == 1 || *idtvar == 2)
3793
cs_glob_var->nprop += 1;
3795
cs_glob_var->nprop += 3;
3796
cs_glob_var->nprop += cs_glob_var->ntimaver;
3798
BFT_REALLOC(cs_glob_var->properties_ipp, cs_glob_var->nprop, int);
3799
BFT_REALLOC(cs_glob_var->propce, cs_glob_var->nprop, int);
3800
BFT_REALLOC(cs_glob_var->properties_name, cs_glob_var->nprop, char*);
3802
if (*idtvar == 1 || *idtvar == 2) {
3803
cs_glob_var->properties_ipp[n] = *ippdt;
3804
cs_glob_var->propce[n] = -1;
3805
BFT_MALLOC(cs_glob_var->properties_name[n], strlen("local_time_step")+1, char);
3806
strcpy(cs_glob_var->properties_name[n++], "local_time_step");
3810
cs_glob_var->properties_ipp[n] = *ipptx;
3811
cs_glob_var->propce[n] = -1;
3812
BFT_MALLOC(cs_glob_var->properties_name[n], strlen("weight_matrix_X")+1, char);
3813
strcpy(cs_glob_var->properties_name[n++], "weight_matrix_X");
3815
cs_glob_var->properties_ipp[n] = *ippty;
3816
cs_glob_var->propce[n] = -1;
3817
BFT_MALLOC(cs_glob_var->properties_name[n], strlen("weight_matrix_Y")+1, char);
3818
strcpy(cs_glob_var->properties_name[n++], "weight_matrix_Y");
3820
cs_glob_var->properties_ipp[n] = *ipptz;
3821
cs_glob_var->propce[n] = -1;
3822
BFT_MALLOC(cs_glob_var->properties_name[n], strlen("weight_matrix_Z")+1, char);
3823
strcpy(cs_glob_var->properties_name[n++], "weight_matrix_Z");
3826
for (i=0; i < cs_glob_var->ntimaver; i++) {
3827
cs_glob_var->properties_ipp[n] = ipppro[ ipproc[ icmome[i]-1 ]-1 ];
3828
cs_glob_var->propce[n] = icmome[i];
3829
name = _get_time_average_label(i+1);
3830
BFT_MALLOC(cs_glob_var->properties_name[n], strlen(name)+1, char);
3831
strcpy(cs_glob_var->properties_name[n++], name);
3836
if (n != cs_glob_var->nprop)
3837
bft_error(__FILE__, __LINE__, 0,
3838
_("number of properties is not correct: %i instead of: %i\n"),
3839
n, cs_glob_var->nprop);
3842
bft_printf("==>UIPROP %i\n",*iappel);
3843
bft_printf("-->nombre de proprietes = %i\n", cs_glob_var->nprop);
3844
for (i=0; i < cs_glob_var->nprop; i++) {
3845
bft_printf("-->properties_ipp[%i]: %i propce[%i]: %i "
3846
"properties_name[%i]: %s\n",
3847
i, cs_glob_var->properties_ipp[i],
3848
i, cs_glob_var->propce[i],
3849
i, cs_glob_var->properties_name[i]);
3854
/*----------------------------------------------------------------------------
3855
* Temporal averaging treatment
3856
*----------------------------------------------------------------------------*/
3858
void CS_PROCF (uimoyt, UIMOYT) (const int *const ndgmox,
3868
cs_glob_var->ntimaver
3869
= cs_gui_get_tag_number("/analysis_control/time_averages/time_average", 1);
3871
/* for each average */
3872
for (i=0; i < cs_glob_var->ntimaver; i++) {
3876
_get_time_average_data(imom, "time_step_start", &ntdmom[i]);
3878
/* test on isuite */
3879
cs_gui_restart_parameters_status("restart", &isuite);
3882
_get_time_average_data(imom, "restart_from_time_average", &imoold[i]);
3883
if (imoold[i] == imom) imoold[i] = -2;
3886
for (n=0; n < _get_time_average_n_variables(imom); n++) {
3888
name = _get_time_average_variable_name(imom, n + 1);
3890
for (j=0; j < cs_glob_var->nvar; j++) {
3891
if (cs_gui_strcmp(name, cs_glob_var->name[j])) {
3892
idfmom[(imom-1)*(*ndgmox) + n] = cs_glob_var->rtp[j] +1;
3896
for (j=0 ; j < cs_glob_var->nprop; j++) {
3897
if (cs_gui_strcmp(name, cs_glob_var->properties_name[j]))
3898
idfmom[(imom-1)*(*ndgmox) + n] = -(cs_glob_var->propce[j]);
3905
bft_printf("==>UIMOYT\n");
3906
for (i=0; i < cs_glob_var->ntimaver; i++) {
3907
bft_printf("-->ntdmom = %i\n", ntdmom[i]);
3912
/*----------------------------------------------------------------------------
3913
* Input/output treatment
3914
*----------------------------------------------------------------------------*/
3916
void CS_PROCF (csenso, CSENSO)
3918
const int *const nvppmx,
3927
int *const size_fmt,
3929
int *const size_opt,
3940
const int *const isca,
3941
const int *const iscapp,
3942
const int *const ipprtp,
3943
double *const xyzcap)
3948
cs_var_t *vars = cs_glob_var;
3950
cs_gui_output_value("fluid_domain", ichrvl);
3951
cs_gui_output_value("domain_boundary", ichrbo);
3952
cs_gui_output_value("syrthes_boundary", ichrsy);
3953
cs_gui_output_value("auxiliary_restart_file_writing", iecaux);
3954
cs_gui_output_value("listing_printing_frequency", ntlist);
3955
cs_gui_output_value("postprocessing_frequency", ntchr);
3956
cs_gui_output_value("probe_recording_frequency", nthist);
3957
cs_gui_output_value("postprocessing_mesh_options", ichrmd);
3958
cs_gui_output_choice("postprocessing_format", fmtchr, size_fmt);
3959
cs_gui_output_choice("postprocessing_options", optchr, size_opt);
3961
/* Surfacic variables output */
3962
cs_gui_surfacic_variable_post("yplus", ipstyp, ipstdv);
3963
cs_gui_surfacic_variable_post("effort", ipstfo, ipstdv);
3964
cs_gui_surfacic_variable_post("all_variables",ipstcl, ipstdv);
3965
cs_gui_surfacic_variable_post("input_thermal_flux",ipstft, ipstdv);
3967
*ncapt = cs_gui_get_tag_number("/analysis_control/output/probe", 1);
3968
for (i=0; i < *ncapt; i++) {
3969
xyzcap[0 + i*3] = cs_gui_probe_coordinate(i+1, "probe_x");
3970
xyzcap[1 + i*3] = cs_gui_probe_coordinate(i+1, "probe_y");
3971
xyzcap[2 + i*3] = cs_gui_probe_coordinate(i+1, "probe_z");
3974
/* Velocity and turbulence output */
3975
for (i=0; i<vars->nvar - vars->nscaus - vars->nscapp; i++) {
3976
ipp = ipprtp[vars->rtp[i]];
3977
cs_gui_thermophysical_post(vars->name[i],
3979
ihisvr, ilisvr, ichrvr,
3984
if (vars->nscaus > 0 ) {
3985
for (i=0 ; i < vars->nscaus; i++) {
3986
cs_gui_scalar_post(i, ihisvr, ilisvr, ichrvr,
3987
ipprtp, isca, nvppmx);
3991
/* Specific physics scalars */
3992
if (vars->nscapp > 0) {
3993
for (i=0 ; i < vars->nscapp; i++) {
3995
cs_gui_model_scalar_post(vars->model, j,
3996
ihisvr, ilisvr, ichrvr,
3997
ipprtp, isca, nvppmx);
4001
/* Physical properties */
4003
if (vars->nsalpp > 0) {
4004
for (i=0 ; i < vars->nsalpp; i++) {
4005
cs_gui_model_property_post(vars->model, i,
4006
ihisvr, ilisvr, ichrvr, nvppmx);
4010
for (i=vars->nsalpp ; i < vars->nprop ; i++) {
4011
if (vars->ntimaver != 0 && i >= vars->nprop - vars->ntimaver) {
4012
cs_gui_time_average_post(vars->properties_name[i],
4013
vars->properties_ipp[i],
4020
cs_gui_properties_post(vars->properties_name[i],
4021
vars->properties_ipp[i],
4029
bft_printf("==>CSENSO\n");
4030
bft_printf("--iecaux = %i\n", *iecaux);
4031
bft_printf("--ichrvl = %i\n", *ichrvl);
4032
bft_printf("--ichrbo = %i\n", *ichrbo);
4033
bft_printf("--ichrsy = %i\n", *ichrsy);
4034
bft_printf("--fmtchr = %s\n", "need to be checked in Fortran");
4035
bft_printf("--optchr = %s\n", "need to be checked in Fortran");
4036
bft_printf("--ntlist = %i\n", *ntlist);
4037
bft_printf("--ntchr = %i\n", *ntchr);
4038
bft_printf("--nthist = %i\n", *nthist);
4039
bft_printf("--ncapt = %i\n", *ncapt);
4040
for (i = 0; i < *ncapt; i++) {
4041
bft_printf("--xyzcap[%i][0] = %f\n", i, xyzcap[0 +i*3]);
4042
bft_printf("--xyzcap[%i][1] = %f\n", i, xyzcap[1 +i*3]);
4043
bft_printf("--xyzcap[%i][2] = %f\n", i, xyzcap[2 +i*3]);
4045
for (i=0; i < vars->nvar - vars->nscaus - vars->nscapp; i++){
4046
ipp = ipprtp[vars->rtp[i]];
4047
bft_printf("-->variable ipprtp[%i] = %s\n", ipp, vars->name[i]);
4048
bft_printf("--ichrvr[%i] = %i \n", ipp, ichrvr[ipp-1]);
4049
bft_printf("--ilisvr[%i] = %i \n", ipp, ilisvr[ipp-1]);
4050
bft_printf("--ihisvr[0][%i]= %i \n", ipp, ihisvr[0 + (ipp-1)]);
4051
if (ihisvr[0 + (ipp-1)]>0)
4052
for (j=0; j<ihisvr[0 + (ipp-1)]; j++)
4053
bft_printf("--ihisvr[%i][%i]= %i \n", j+1, ipp,
4054
ihisvr[(j+1)*(*nvppmx) + (ipp-1)]);
4056
for (i=0 ; i < vars->nscaus + vars->nscapp ; i++) {
4057
ipp = ipprtp[isca[i] -1];
4058
bft_printf("-->scalar ipprtp[%i]: %s\n", ipp, vars->label[i]);
4059
bft_printf("--ichrvr[%i] = %i \n", ipp, ichrvr[ipp-1]);
4060
bft_printf("--ilisvr[%i] = %i \n", ipp, ilisvr[ipp-1]);
4061
bft_printf("--ihisvr[0][%i]= %i \n", ipp, ihisvr[0 + (ipp-1)]);
4062
if (ihisvr[0 + (ipp-1)]>0)
4063
for (j=0; j<ihisvr[0 + (ipp-1)]; j++)
4064
bft_printf("--ihisvr[%i][%i]= %i \n", j+1, ipp,
4065
ihisvr[(j+1)*(*nvppmx) + (ipp-1)]);
4067
for (i=0 ; i<vars->nprop ; i++) {
4068
ipp = vars->properties_ipp[i];
4069
bft_printf("-->properties_name[%i]: %s\n", i, vars->properties_name[i]);
4070
bft_printf("--ichrvr[%i] = %i \n", ipp, ichrvr[ipp-1]);
4071
bft_printf("--ilisvr[%i] = %i \n", ipp, ilisvr[ipp-1]);
4072
bft_printf("--ihisvr[0][%i]= %i \n", ipp, ihisvr[0 + (ipp-1)]);
4073
if (ihisvr[0 + (ipp-1)]>0)
4074
for (j=0; j<ihisvr[0 + (ipp-1)]; j++)
4075
bft_printf("--ihisvr[%i][%i]= %i \n", j+1, ipp,
4076
ihisvr[(j+1)*(*nvppmx) + (ipp-1)]);
4081
/*----------------------------------------------------------------------------
4084
* Fortran Interface:
4086
* SUBROUTINE UIUSAR (ICOFTU)
4089
* INTEGER ICOFTU --> Dimension coef for user arrays
4090
*----------------------------------------------------------------------------*/
4092
void CS_PROCF (uiusar, UIUSAR) (int *const icoftu)
4094
icoftu[0] = _user_array("integer_user_array", "ncelet");
4095
icoftu[1] = _user_array("integer_user_array", "nfac");
4096
icoftu[2] = _user_array("integer_user_array", "nfabor");
4097
icoftu[3] = _user_array("integer_user_array", "dimless");
4099
icoftu[4] = _user_array("real_user_array", "ncelet");
4100
icoftu[5] = _user_array("real_user_array", "nfac");
4101
icoftu[6] = _user_array("real_user_array", "nfabor");
4102
icoftu[7] = _user_array("real_user_array", "dimless");
4104
icoftu[8] = _user_array("integer_work_array", "ncelet");
4105
icoftu[9] = _user_array("integer_work_array", "nfac");
4106
icoftu[10] = _user_array("integer_work_array", "nfabor");
4107
icoftu[11] = _user_array("integer_work_array", "dimless");
4109
icoftu[12] = _user_array("real_work_array", "ncelet");
4110
icoftu[13] = _user_array("real_work_array", "nfac");
4111
icoftu[14] = _user_array("real_work_array", "nfabor");
4112
icoftu[15] = _user_array("real_work_array", "dimless");
4116
bft_printf("==>UIUSAR\n");
4117
bft_printf("--icoftu = %i %i %i %i\n",
4118
icoftu[0],icoftu[1],icoftu[2],icoftu[3]);
4119
bft_printf(" %i %i %i %i\n",
4120
icoftu[4],icoftu[5],icoftu[6],icoftu[7]);
4121
bft_printf("--icoftu = %i %i %i %i\n",
4122
icoftu[8],icoftu[9],icoftu[10],icoftu[11]);
4123
bft_printf(" %i %i %i %i\n",
4124
icoftu[12],icoftu[13],icoftu[14],icoftu[15]);
4129
/*----------------------------------------------------------------------------
4130
* Copy variable name from Fortran to C
4131
*----------------------------------------------------------------------------*/
4133
void CS_PROCF(fcnmva, FCNMVA)
4135
const char *const fstr, /* --> Fortran string */
4136
int *const len, /* --> String Length */
4137
int *const var_id /* --> Variable Id (1 to n) */
4144
assert(*var_id > 0);
4146
/* Resize array if necessary */
4148
if (*var_id > cs_glob_label->_cs_gui_max_vars) {
4150
if (cs_glob_label->_cs_gui_max_vars == 0)
4151
cs_glob_label->_cs_gui_max_vars = 16;
4153
while (cs_glob_label->_cs_gui_max_vars <= *var_id)
4154
cs_glob_label->_cs_gui_max_vars *= 2;
4156
BFT_REALLOC(cs_glob_label->_cs_gui_var_name, cs_glob_label->_cs_gui_max_vars, char *);
4157
for (i = cs_glob_label->_cs_gui_last_var; i < cs_glob_label->_cs_gui_max_vars; i++)
4158
cs_glob_label->_cs_gui_var_name[i] = NULL;
4161
/* Compute string length (removing start or end blanks) */
4164
i1 < *len && (fstr[i1] == ' ' || fstr[i1] == '\t');
4168
i2 > i1 && (fstr[i2] == ' ' || fstr[i2] == '\t');
4173
/* Should be called once per variable only */
4174
assert(cs_glob_label->_cs_gui_var_name[*var_id - 1] == NULL);
4178
/* Allocate and copy */
4179
BFT_MALLOC(cstr, l + 1, char);
4181
for (i = 0 ; i < l ; i++, i1++)
4186
cs_glob_label->_cs_gui_var_name[*var_id - 1] = cstr;
4190
/* Update variable counter */
4191
cs_glob_label->_cs_gui_last_var = *var_id;
4195
/*----------------------------------------------------------------------------
4196
* Copy variable name from C to Fortran
4197
*----------------------------------------------------------------------------*/
4199
void CS_PROCF(cfnmva, CFNMVA)
4201
char *const fstr, /* --> Fortran string */
4202
int *const len, /* --> String Length */
4203
int *const var_id /* --> Variable Id (1 to n) */
4211
/* Check that variable name was set */
4213
if (*var_id < 1 || *var_id > cs_glob_label->_cs_gui_last_var)
4214
bft_error(__FILE__, __LINE__, 0,
4215
_("Name of variable %i was never set.\n"), *var_id);
4219
cstr = cs_glob_label->_cs_gui_var_name[*var_id - 1];
4223
/* Compute string length (removing start or end blanks) */
4229
for (i = 0; i < l; i++)
4234
/* Pad with blanks if necessary */
4236
for (i = l; i < *len; i++)
4240
/*----------------------------------------------------------------------------
4241
* Clean memory for fortran name of variables
4242
*----------------------------------------------------------------------------*/
4244
void CS_PROCF(nvamem, NVAMEM) (void)
4248
bft_printf("==>NVAMEM\n");
4249
for (i = 0; i < cs_glob_label->_cs_gui_max_vars; i++)
4250
if (cs_glob_label->_cs_gui_var_name[i])
4251
bft_printf("-->label[%i] = %s\n", i, cs_glob_label->_cs_gui_var_name[i]);
4254
for (i = 0; i < cs_glob_label->_cs_gui_max_vars; i++)
4255
BFT_FREE(cs_glob_label->_cs_gui_var_name[i]);
4257
BFT_FREE(cs_glob_label->_cs_gui_var_name);
4259
cs_glob_label->_cs_gui_max_vars = 0;
4260
cs_glob_label->_cs_gui_last_var = 0;
4263
/*-----------------------------------------------------------------------------
4264
* Return the list of cells describing a given zone.
4267
* label --> volume label
4268
* ncelet --> number of cells with halo
4269
* faces <-- number of selected cells
4270
*----------------------------------------------------------------------------*/
4273
cs_gui_get_cells_list(const char *label,
4278
int *cells_list = NULL;
4279
char *description = NULL;
4281
description = cs_gui_volumic_zone_localization(label);
4283
/* build list of cells */
4284
BFT_MALLOC(cells_list, ncelet, int);
4286
c_id = fvm_selector_get_list(cs_glob_mesh->select_cells,
4291
if (fvm_selector_n_missing(cs_glob_mesh->select_cells, c_id) > 0)
4294
= fvm_selector_get_missing(cs_glob_mesh->select_cells, c_id, 0);
4295
cs_base_warn(__FILE__, __LINE__);
4296
bft_printf(_("The group or attribute \"%s\" in the selection\n"
4299
" does not correspond to any cell.\n"),
4300
missing, description);
4302
BFT_FREE(description);
4306
/*----------------------------------------------------------------------------
4307
* Variables and user scalars initialization.
4309
* Fortran Interface:
4311
* subroutine uiiniv (ncelet, isuite, isca, iscold, rtp)
4314
* integer ncelet --> number of cells with halo
4315
* integer isuite --> restart indicator
4316
* integer isca --> indirection array for scalar number
4317
* integer iscold --> scalar number for restart
4318
* double precision rtp <-- variables and scalars array
4319
*----------------------------------------------------------------------------*/
4321
void CS_PROCF(uiiniv, UIINIV)(const int *ncelet,
4327
/* Coal combustion: the initialization of the model scalar are not given */
4329
int i, j, icel, iel;
4332
int *cells_list = NULL;
4333
double initial_value = 0;
4334
char *choice = NULL;
4336
char *status = NULL;
4339
cs_var_t *vars = cs_glob_var;
4341
/* number of volumic zone */
4344
= cs_gui_get_tag_number("/solution_domain/volumic_conditions/zone", 1);
4347
bft_printf("==>UIINIV\n");
4350
for (i=1; i < zones+1; i++) {
4352
path = cs_xpath_init_path();
4353
cs_xpath_add_elements(&path, 2, "solution_domain", "volumic_conditions");
4354
cs_xpath_add_element_num(&path, "zone", i);
4355
cs_xpath_add_attribute(&path, "initialization");
4356
status = cs_gui_get_attribute_value(path);
4359
if (cs_gui_strcmp(status, "on")) {
4361
label = cs_gui_volumic_zone_label(i);
4362
cells_list = cs_gui_get_cells_list(label, *ncelet, &cells);
4366
/* Velocity variables initialization */
4367
for (j=1; j < 4; j++) {
4369
cs_gui_variable_initial_value(vars->name[j], label, &initial_value);
4371
for (icel = 0; icel < cells; icel++) {
4372
iel = cells_list[icel]-1;
4373
rtp[vars->rtp[j]*(*ncelet) + iel] = initial_value;
4377
/* Turbulence variables initialization */
4378
choice = cs_gui_turbulence_initialization_choice();
4380
if (cs_gui_strcmp(choice, "values")) {
4381
for (j=4; j < vars->nvar - vars->nscaus - vars->nscapp; j++) {
4383
cs_gui_variable_initial_value(vars->name[j], label, &initial_value);
4385
for (icel = 0; icel < cells; icel++) {
4386
iel = cells_list[icel]-1;
4387
rtp[vars->rtp[j]*(*ncelet) + iel] = initial_value;
4395
/* User Scalars initialization */
4396
for (j=0; j < vars->nscaus; j++) {
4398
cs_gui_scalar_initial_value("additional_scalars",
4403
if (*isuite == 0 || (*isuite !=0 && iscold[j] == 0)) {
4404
for (icel = 0; icel < cells; icel++) {
4405
iel = cells_list[icel]-1;
4406
rtp[(isca[j]-1)*(*ncelet) + iel] = initial_value;
4411
BFT_FREE(cells_list);
4414
bft_printf("--zone label: %s\n", label);
4415
bft_printf("--zone's element number: %i\n", cells);
4418
for (j=1; j < vars->nvar - vars->nscaus - vars->nscapp; j++) {
4419
cs_gui_variable_initial_value(vars->name[j], label, &initial_value);
4420
bft_printf("--initial value for %s: %f\n",
4421
vars->name[j], initial_value);
4425
for (j=0; j < vars->nscaus; j++) {
4426
cs_gui_scalar_initial_value("additional_scalars",
4430
if (*isuite == 0 || (*isuite !=0 && iscold[j] == 0)) {
4431
bft_printf("--initial value for %s: %f\n", vars->label[j], initial_value);
4435
BFT_FREE(cells_list);
4442
/*-----------------------------------------------------------------------------
4443
* Change the head losses matrix from the local frame to the global frame.
4446
* a_ij --> change matrix from the local frame to the global frame
4447
* in_ij --> head losses matrix in the local frame
4448
* out_ij --> head losses matrix in the global frame
4449
*----------------------------------------------------------------------------*/
4452
_matrix_base_conversion(double a11, double a12, double a13,
4453
double a21, double a22, double a23,
4454
double a31, double a32, double a33,
4455
double in11, double in12, double in13,
4456
double in21, double in22, double in23,
4457
double in31, double in32, double in33,
4458
double *out11, double *out12, double *out13,
4459
double *out21, double *out22, double *out23,
4460
double *out31, double *out32, double *out33)
4463
double tensorP[3][3], tensorA[3][3], tensorB[3][3], tensorC[3][3], tensorD[3][3];
4465
tensorA[0][0] = in11;
4466
tensorA[0][1] = in12;
4467
tensorA[0][2] = in13;
4468
tensorA[1][0] = in21;
4469
tensorA[1][1] = in22;
4470
tensorA[1][2] = in23;
4471
tensorA[2][0] = in31;
4472
tensorA[2][1] = in32;
4473
tensorA[2][2] = in33;
4475
tensorP[0][0] = a11;
4476
tensorP[0][1] = a12;
4477
tensorP[0][2] = a13;
4478
tensorP[1][0] = a21;
4479
tensorP[1][1] = a22;
4480
tensorP[1][2] = a23;
4481
tensorP[2][0] = a31;
4482
tensorP[2][1] = a32;
4483
tensorP[2][2] = a33;
4485
for (i = 0; i < 3; i++)
4487
for (j = 0; j < 3; j++)
4490
for (k = 0; k < 3; k++)
4491
tensorB[i][j] += tensorP[i][k] * tensorA[k][j];
4495
/* Inversion of a 3x3 matrix */
4497
tensorC[0][0] = a11;
4498
tensorC[0][1] = a21;
4499
tensorC[0][2] = a31;
4500
tensorC[1][0] = a12;
4501
tensorC[1][1] = a22;
4502
tensorC[1][2] = a32;
4503
tensorC[2][0] = a13;
4504
tensorC[2][1] = a23;
4505
tensorC[2][2] = a33;
4507
for (i = 0; i < 3; i++)
4509
for (j = 0; j < 3; j++)
4512
for (k = 0; k < 3; k++)
4513
tensorD[i][j] += tensorB[i][k] * tensorC[k][j];
4517
*out11 = tensorD[0][0];
4518
*out22 = tensorD[1][1];
4519
*out33 = tensorD[2][2];
4520
*out12 = tensorD[0][1];
4521
*out13 = tensorD[0][2];
4522
*out21 = tensorD[1][0];
4523
*out23 = tensorD[1][2];
4524
*out31 = tensorD[2][0];
4525
*out32 = tensorD[2][1];
4528
/*-----------------------------------------------------------------------------
4529
* Return value of coefficient associated to the head losses definition.
4532
* label --> label of the volume zone
4533
* c --> name of the coefficient
4534
*----------------------------------------------------------------------------*/
4537
_c_heads_losses(const char* label, const char* c)
4540
double result = 0.0;
4543
path = cs_xpath_init_path();
4544
cs_xpath_add_elements(&path, 3, "thermophysical_models", "heads_losses", "head_loss");
4545
cs_xpath_add_test_attribute(&path, "label", label);
4546
cs_xpath_add_element(&path, c);
4547
cs_xpath_add_function_text(&path);
4548
if (cs_gui_get_double(path, &result))
4556
/*----------------------------------------------------------------------------
4557
* Head losses definition
4559
* Fortran Interface:
4564
* integer iappel --> number of calls during a time step
4565
* integer iphas --> number of phase (only 1 allowed)
4566
* integer ncelet --> number of cells with halo
4567
* integer ncepdp <-- number of cells with head losses
4568
* integer icepdc <-- ncepdp cells number with head losses
4569
* double precision ckupdc <-- head losses matrix
4570
* double precision rtpa --> variables array at previous time step
4571
*----------------------------------------------------------------------------*/
4573
void CS_PROCF(uikpdc, UIKPDC)(const int* iappel,
4579
const double rtpa[] )
4581
int i, j, iel, ielpdc, ikpdc;
4584
int *cells_list = NULL;
4586
double a11, a12, a13, a21, a22, a23, a31, a32, a33;
4587
double c11, c12, c13, c21, c22, c23, c31, c32, c33;
4588
double k11, k22, k33;
4590
char *status = NULL;
4593
assert(*iphas == 1);
4595
cs_var_t *vars = cs_glob_var;
4597
/* number of volumic zone */
4600
= cs_gui_get_tag_number("/solution_domain/volumic_conditions/zone", 1);
4603
if (*iappel == 1 || *iappel == 2)
4607
for (i=1; i < zones+1; i++)
4609
path = cs_xpath_init_path();
4610
cs_xpath_add_elements(&path, 2, "solution_domain", "volumic_conditions");
4611
cs_xpath_add_element_num(&path, "zone", i);
4612
cs_xpath_add_attribute(&path, "head_losses");
4613
status = cs_gui_get_attribute_value(path);
4616
if (cs_gui_strcmp(status, "on"))
4618
label = cs_gui_volumic_zone_label(i);
4619
cells_list = cs_gui_get_cells_list(label, *ncelet, &cells);
4621
for (j=0; j < cells; j++)
4624
icepdc[ielpdc] = cells_list[j];
4627
BFT_FREE(cells_list);
4633
ncepdp[*iphas-1] = ielpdc;
4638
for (ikpdc = 0; ikpdc < 6; ikpdc++)
4639
for (ielpdc = 0; ielpdc < ncepdp[*iphas-1]; ielpdc++)
4640
ckupdc[ikpdc * ncepdp[*iphas-1] + ielpdc] = 0.0;
4644
for (i=1; i < zones+1; i++)
4646
path = cs_xpath_init_path();
4647
cs_xpath_add_elements(&path, 2, "solution_domain", "volumic_conditions");
4648
cs_xpath_add_element_num(&path, "zone", i);
4649
cs_xpath_add_attribute(&path, "head_losses");
4650
status = cs_gui_get_attribute_value(path);
4653
if (cs_gui_strcmp(status, "on"))
4655
label = cs_gui_volumic_zone_label(i);
4656
cells_list = cs_gui_get_cells_list(label, *ncelet, &cells);
4658
k11 = _c_heads_losses(label, "kxx");
4659
k22 = _c_heads_losses(label, "kyy");
4660
k33 = _c_heads_losses(label, "kzz");
4662
a11 = _c_heads_losses(label, "a11");
4663
a12 = _c_heads_losses(label, "a12");
4664
a13 = _c_heads_losses(label, "a13");
4665
a21 = _c_heads_losses(label, "a21");
4666
a22 = _c_heads_losses(label, "a22");
4667
a23 = _c_heads_losses(label, "a23");
4668
a31 = _c_heads_losses(label, "a31");
4669
a32 = _c_heads_losses(label, "a32");
4670
a33 = _c_heads_losses(label, "a33");
4672
if (a12 == 0.0 && a13 == 0.0 && a23 == 0.0)
4683
_matrix_base_conversion(a11, a12, a13, a21, a22, a23, a31, a32, a33,
4684
k11, 0.0, 0.0, 0.0, k22, 0.0, 0.0, 0.0, k33,
4685
&c11, &c12, &c13, &c21, &c22, &c23, &c31, &c32, &c33);
4688
for (j = 0; j < cells; j++)
4690
iel = cells_list[j];
4691
vit = rtpa[vars->rtp[1]*(*ncelet) + iel-1] * rtpa[vars->rtp[1]*(*ncelet) + iel-1] \
4692
+ rtpa[vars->rtp[2]*(*ncelet) + iel-1] * rtpa[vars->rtp[2]*(*ncelet) + iel-1] \
4693
+ rtpa[vars->rtp[3]*(*ncelet) + iel-1] * rtpa[vars->rtp[3]*(*ncelet) + iel-1] ;
4695
ckupdc[0 * ncepdp[*iphas-1] + ielpdc] = 0.5 * c11 * vit;
4696
ckupdc[1 * ncepdp[*iphas-1] + ielpdc] = 0.5 * c22 * vit;
4697
ckupdc[2 * ncepdp[*iphas-1] + ielpdc] = 0.5 * c33 * vit;
4698
ckupdc[3 * ncepdp[*iphas-1] + ielpdc] = 0.5 * c12 * vit;
4699
ckupdc[4 * ncepdp[*iphas-1] + ielpdc] = 0.5 * c13 * vit;
4700
ckupdc[5 * ncepdp[*iphas-1] + ielpdc] = 0.5 * c23 * vit;
4703
BFT_FREE(cells_list);
4710
bft_printf("==>uikpdc\n");
4712
bft_printf("--%i number of head losses cells: %i\n", *iappel, ncepdp[*iphas-1]);
4714
bft_printf("--%i number of head losses cells: %i\n", *iappel, ielpdc);
4718
/*----------------------------------------------------------------------------
4719
* User law for material properties
4721
* Fortran Interface:
4726
* INTEGER NCEL --> number of cells whithout halo
4727
* INTEGER NCELET --> number of cells whith halo
4728
* INTEGER NSCAUS --> number of user scalar including thermal scalar
4729
* INTEGER IROM --> pointer for density rho
4730
* INTEGER IVISCL --> pointer for mulecular viscosity mu
4731
* INTEGER ICP --> pointer for specific heat Cp
4732
* INTEGER IVISLS --> pointer for Lambda/Cp
4733
* INTEGER IROVAR --> =1 if rho variable, =0 if rho constant
4734
* INTEGER IVIVAR --> =1 if mu variable, =0 if mu constant
4735
* INTEGER ISCA --> indirection array for scalar number
4736
* INTEGER ISCALT --> pointer for the thermal scalar in ISCA
4737
* INTEGER ISCAVR --> scalars that are variance
4738
* INTEGER IPPROC --> indirection array for cell properties
4739
* DOUBLE PRECISION RO0 --> value of density if IROVAR=0
4740
* DOUBLE PRECISION CP0 --> value of specific heat if ICP=0
4741
* DOUBLE PRECISION RTP --> variables and scalars array
4742
* DOUBLE PRECISION PROPCE <-- cell properties array
4743
*----------------------------------------------------------------------------*/
4745
void CS_PROCF(uiphyv, UIPHYV)(const cs_int_t *const ncel,
4746
const cs_int_t *const ncelet,
4747
const cs_int_t *const nscaus,
4748
const cs_int_t irom[],
4749
const cs_int_t iviscl[],
4750
const cs_int_t icp[],
4751
const cs_int_t ivisls[],
4752
const cs_int_t irovar[],
4753
const cs_int_t ivivar[],
4754
const cs_int_t isca[],
4755
const cs_int_t iscalt[],
4756
const cs_int_t iscavr[],
4757
const cs_int_t ipproc[],
4758
const cs_real_t ro0[],
4759
const cs_real_t cp0[],
4760
const cs_real_t rtp[],
4763
#if defined(HAVE_MEI)
4765
cs_var_t *vars = cs_glob_var;
4766
mei_tree_t *ev_rho = NULL;
4767
mei_tree_t *ev_mu = NULL;
4768
mei_tree_t *ev_cp = NULL;
4769
mei_tree_t *ev_la = NULL;
4770
mei_tree_t *ev_Ds = NULL;
4771
char *law_rho = NULL;
4772
char *law_mu = NULL;
4773
char *law_cp = NULL;
4774
char *law_la = NULL;
4775
char *law_Ds = NULL;
4782
int ipcrom = ipproc[ irom [iphas] -1 ] -1;
4783
int ipcvis = ipproc[ iviscl[iphas] -1 ] -1;
4784
int ipccp = ipproc[ icp [iphas] -1 ] -1;
4785
int ipcvsl = ipproc[ ivisls[iscalt[iphas] -1 ] -1 ] -1; /* Lambda/Cp from the current thermal scalar */
4787
/* law for density */
4789
if (irovar[iphas] == 1 && cs_gui_strcmp(_properties_choice("density"), "user_law"))
4791
/* search the formula for the law */
4793
path = cs_xpath_short_path();
4794
cs_xpath_add_element(&path, "property");
4795
cs_xpath_add_test_attribute(&path, "name", "density");
4796
cs_xpath_add_element(&path, "formula");
4797
cs_xpath_add_function_text(&path);
4799
law_rho = cs_gui_get_text_value(path);
4802
/* return an empty interpreter */
4804
ev_rho = mei_tree_new(law_rho);
4805
for (i = 0; i < *nscaus; i++)
4806
mei_tree_insert(ev_rho, vars->label[i], 0.0);
4808
/* try to build the interpreter */
4810
if (mei_tree_builder(ev_rho))
4811
bft_error(__FILE__, __LINE__, 0,
4812
_("Error: can not interprete expression: %s\n"), ev_rho->string);
4814
if (mei_tree_find_symbol(ev_rho, "rho"))
4815
bft_error(__FILE__, __LINE__, 0,
4816
_("Error: can not find the required symbol: %s\n"), "rho");
4818
/* for each cell, update the value of the table of symbols for each scalar
4819
(including the thermal scalar), and evaluate the interpreter */
4821
for (iel = 0; iel < *ncel; iel++)
4823
for (i = 0; i < *nscaus; i++)
4824
mei_tree_insert(ev_rho,
4826
rtp[(isca[i] -1) * (*ncelet) + iel]);
4828
tmp = mei_evaluate(ev_rho);
4829
propce[ipcrom * (*ncelet) + iel] = mei_tree_lookup(ev_rho, "rho");
4832
mei_tree_destroy(ev_rho);
4835
/* law for molecular viscosity */
4837
if (ivivar[iphas] == 1 && cs_gui_strcmp(_properties_choice("molecular_viscosity"), "user_law"))
4839
/* search the formula for the law */
4841
path = cs_xpath_short_path();
4842
cs_xpath_add_element(&path, "property");
4843
cs_xpath_add_test_attribute(&path, "name", "molecular_viscosity");
4844
cs_xpath_add_element(&path, "formula");
4845
cs_xpath_add_function_text(&path);
4847
law_mu = cs_gui_get_text_value(path);
4850
/* return an empty interpreter */
4852
ev_mu = mei_tree_new(law_mu);
4853
for (i = 0; i < *nscaus; i++)
4854
mei_tree_insert(ev_mu, vars->label[i], 0.0);
4856
/* try to build the interpreter */
4858
if (mei_tree_builder(ev_mu))
4859
bft_error(__FILE__, __LINE__, 0,
4860
_("Error: can not interprete expression: %s\n"), ev_mu->string);
4862
if (mei_tree_find_symbol(ev_mu, "mu"))
4863
bft_error(__FILE__, __LINE__, 0,
4864
_("Error: can not find the required symbol: %s\n"), "mu");
4866
/* for each cell, update the value of the table of symbols for each scalar
4867
(including the thermal scalar), and evaluate the interpreter */
4869
for (iel = 0; iel < *ncel; iel++)
4871
for (i = 0; i < *nscaus; i++)
4872
mei_tree_insert(ev_mu,
4874
rtp[(isca[i] -1) * (*ncelet) + iel]);
4876
tmp = mei_evaluate(ev_mu);
4877
propce[ipcvis * (*ncelet) + iel] = mei_tree_lookup(ev_mu, "mu");
4880
mei_tree_destroy(ev_mu);
4883
/* law for specific heat */
4885
if (icp[iphas] > 0 && cs_gui_strcmp(_properties_choice("specific_heat"), "user_law"))
4887
/* search the formula for the law */
4889
path = cs_xpath_short_path();
4890
cs_xpath_add_element(&path, "property");
4891
cs_xpath_add_test_attribute(&path, "name", "specific_heat");
4892
cs_xpath_add_element(&path, "formula");
4893
cs_xpath_add_function_text(&path);
4895
law_cp = cs_gui_get_text_value(path);
4898
/* return an empty interpreter */
4900
ev_cp = mei_tree_new(law_cp);
4901
for (i = 0; i < *nscaus; i++)
4902
mei_tree_insert(ev_cp, vars->label[i], 0.0);
4904
/* try to build the interpreter */
4906
if (mei_tree_builder(ev_cp))
4907
bft_error(__FILE__, __LINE__, 0,
4908
_("Error: can not interprete expression: %s\n"), ev_cp->string);
4910
if (mei_tree_find_symbol(ev_cp, "cp"))
4911
bft_error(__FILE__, __LINE__, 0,
4912
_("Error: can not find the required symbol: %s\n"), "cp");
4914
/* for each cell, update the value of the table of symbols for each scalar
4915
(including the thermal scalar), and evaluate the interpreter */
4917
for (iel = 0; iel < *ncel; iel++)
4919
for (i = 0; i < *nscaus; i++)
4920
mei_tree_insert(ev_cp,
4922
rtp[(isca[i] -1) * (*ncelet) + iel]);
4924
tmp = mei_evaluate(ev_cp);
4925
propce[ipccp * (*ncelet) + iel] = mei_tree_lookup(ev_cp, "cp");
4928
mei_tree_destroy(ev_cp);
4931
/* law for thermal conductivity */
4933
if (ivisls[iscalt[iphas] -1] > 0 && cs_gui_strcmp(_properties_choice("thermal_conductivity"), "user_law"))
4935
/* search the formula for the law */
4937
path = cs_xpath_short_path();
4938
cs_xpath_add_element(&path, "property");
4939
cs_xpath_add_test_attribute(&path, "name", "thermal_conductivity");
4940
cs_xpath_add_element(&path, "formula");
4941
cs_xpath_add_function_text(&path);
4943
law_la = cs_gui_get_text_value(path);
4946
/* return an empty interpreter */
4948
ev_la = mei_tree_new(law_la);
4949
for (i = 0; i < *nscaus; i++)
4950
mei_tree_insert(ev_la, vars->label[i], 0.0);
4952
/* try to build the interpreter */
4954
if (mei_tree_builder(ev_la))
4955
bft_error(__FILE__, __LINE__, 0,
4956
_("Error: can not interprete expression: %s\n"), ev_la->string);
4958
if (mei_tree_find_symbol(ev_la, "lambda"))
4959
bft_error(__FILE__, __LINE__, 0,
4960
_("Error: can not find the required symbol: %s\n"), "lambda");
4962
/* for each cell, update the value of the table of symbols for each scalar
4963
(including the thermal scalar), and evaluate the interpreter */
4967
for (iel = 0; iel < *ncel; iel++)
4969
for (i = 0; i < *nscaus; i++)
4970
mei_tree_insert(ev_la,
4972
rtp[(isca[i] -1) * (*ncelet) + iel]);
4974
tmp = mei_evaluate(ev_la);
4975
propce[ipcvsl * (*ncelet) + iel] =
4976
mei_tree_lookup(ev_la, "lambda") / propce[ipccp * (*ncelet) + iel];
4981
for (iel = 0; iel < *ncel; iel++)
4983
for (i = 0; i < *nscaus; i++)
4984
mei_tree_insert(ev_la,
4986
rtp[(isca[i] -1) * (*ncelet) + iel]);
4988
tmp = mei_evaluate(ev_la);
4989
propce[ipcvsl * (*ncelet) + iel] =
4990
mei_tree_lookup(ev_la, "lambda") / cp0[iphas];
4993
mei_tree_destroy(ev_la);
4996
/* law for scalar diffusivity */
4998
for (j = 0; j < *nscaus; j++)
5000
char *name = _scalar_diffusion_coefficient_name(j);
5002
if (j != iscalt[iphas] -1 && iscavr[j] <= 0 && ivisls[j] > 0 &&
5003
cs_gui_strcmp(_properties_choice(name), "user_law"))
5005
ipcvsl = ipproc[ ivisls[j] -1 ] -1;
5007
/* search the formula for the law */
5009
path = cs_xpath_init_path();
5010
cs_xpath_add_element(&path, "additional_scalars");
5011
cs_xpath_add_element_num(&path, "scalar", j+1);
5012
cs_xpath_add_element(&path, "property");
5013
cs_xpath_add_element(&path, "formula");
5014
cs_xpath_add_function_text(&path);
5016
law_Ds = cs_gui_get_text_value(path);
5019
/* return an empty interpreter */
5021
ev_Ds = mei_tree_new(law_Ds);
5023
for (i = 0; i < *nscaus; i++)
5024
mei_tree_insert(ev_Ds, vars->label[i], 0.0);
5026
/* try to build the interpreter */
5028
if (mei_tree_builder(ev_Ds))
5029
bft_error(__FILE__, __LINE__, 0,
5030
_("Error: can not interprete expression: %s\n"), ev_Ds->string);
5032
if (mei_tree_find_symbol(ev_Ds, "diffusivity"))
5033
bft_error(__FILE__, __LINE__, 0,
5034
_("Error: can not find the required symbol: %s\n"), "diffusivity");
5036
/* for each cell, update the value of the table of symbols for each scalar
5037
(including the thermal scalar), and evaluate the interpreter */
5039
if (irovar[iphas] == 1)
5041
for (iel = 0; iel < *ncel; iel++)
5043
for (i = 0; i < *nscaus; i++)
5044
mei_tree_insert(ev_Ds,
5046
rtp[(isca[i] -1) * (*ncelet) + iel]);
5048
tmp = mei_evaluate(ev_Ds);
5049
propce[ipcvsl * (*ncelet) + iel] =
5050
mei_tree_lookup(ev_Ds, "diffusivity") * propce[ipcrom * (*ncelet) + iel];
5055
for (iel = 0; iel < *ncel; iel++)
5057
for (i = 0; i < *nscaus; i++)
5058
mei_tree_insert(ev_Ds,
5060
rtp[(isca[i] -1) * (*ncelet) + iel]);
5062
tmp = mei_evaluate(ev_Ds);
5063
propce[ipcvsl * (*ncelet) + iel] =
5064
mei_tree_lookup(ev_Ds, "diffusivity") * ro0[iphas];
5067
mei_tree_destroy(ev_Ds);
5073
bft_printf("==>UIPHYV\n");
5074
if (irovar[iphas] == 1)
5075
bft_printf("--law for density: %s\n", law_rho);
5077
if (ivivar[iphas] == 1)
5078
bft_printf("--law for viscosity: %s\n", law_mu);
5081
bft_printf("--law for specific heat: %s\n", law_cp);
5083
if (ivisls[iscalt[iphas] -1] > 0)
5084
bft_printf("--law for thermal conductivity: %s\n", law_la);
5086
for (j = 0; j < *nscaus; j++)
5088
if (j != iscalt[iphas] -1 && iscavr[j] <= 0 && ivisls[j] > 0)
5090
ipcvsl = ipproc[ ivisls[j] -1 ] -1;
5092
path = cs_xpath_init_path();
5093
cs_xpath_add_element(&path, "additional_scalars");
5094
cs_xpath_add_element_num(&path, "scalar", j+1);
5095
cs_xpath_add_element(&path, "property");
5096
cs_xpath_add_element(&path, "formula");
5097
cs_xpath_add_function_text(&path);
5099
law_Ds = cs_gui_get_text_value(path);
5100
bft_printf("--law for the coefficient of diffusity of the scalar %s: %s\n",
5101
vars->label[j], law_Ds);
5116
/*----------------------------------------------------------------------------
5117
* 1D profile postprocessing
5119
* Fortran Interface:
5124
* INTEGER NCELET --> number of cells with halo
5125
* INTEGER NCEL --> number of cells without halo
5126
* INTEGER NTMABS --> max iterations numbers
5127
* INTEGER NTCABS --> current iteration number
5128
* DOUBLE PRECISION TTCABS --> current physical time
5129
* DOUBLE PRECISION XYZCEN --> cell's gravity center
5130
* DOUBLE PRECISION RTP --> variables and scalars array
5131
* DOUBLE PRECISION PROPCE --> property array
5132
*----------------------------------------------------------------------------*/
5134
void CS_PROCF (uiprof, UIPROF) (const int *const ncelet,
5135
const int *const ncel,
5136
const int *const ntmabs,
5137
const int *const ntcabs,
5138
const double *const ttcabs,
5139
const double *const xyzcen,
5140
const double *const rtp,
5141
const double *const propce)
5144
char *filename = NULL;
5150
int npoint, iel1, irang1, iel, irangv;
5151
int nvar_prop, nvar_prop4, output_frequency;
5152
double x1, x2, y1, y2, z1, z2;
5153
double xx, yy, zz, xyz[3];
5157
cs_var_t *vars = cs_glob_var;
5159
/* get the number of 1D profile file to write*/
5161
fic_nbr = cs_gui_get_tag_number("/analysis_control/profiles/profile", 1);
5163
if (!fic_nbr) return;
5165
for (i = 0 ; i < fic_nbr ; i++) {
5167
/* for each profile, check the output frequency */
5169
output_frequency = _get_profile_coordinate(i, "output_frequency");
5171
if ((output_frequency == -1 && *ntmabs == *ntcabs) ||
5172
(output_frequency > 0 && (*ntcabs % output_frequency) == 0)) {
5174
x1 = _get_profile_coordinate(i, "x1");
5175
y1 = _get_profile_coordinate(i, "y1");
5176
z1 = _get_profile_coordinate(i, "z1");
5177
x2 = _get_profile_coordinate(i, "x2");
5178
y2 = _get_profile_coordinate(i, "y2");
5179
z2 = _get_profile_coordinate(i, "z2");
5181
nvar_prop = _get_profile_names_number(i);
5182
nvar_prop4 = nvar_prop + 4;
5183
BFT_MALLOC(array, nvar_prop4, double);
5185
/* Only the first processor rank opens the file */
5187
if (cs_glob_rank_id <= 0) {
5189
filename = _get_profile("label", i);
5190
title = _get_profile("title", i);
5192
if (output_frequency > 0) {
5195
const char buffer[5] = "%.4i";
5197
/* Extension creation : format stored in 'buffer' */
5199
sprintf(buf1, buffer, *ntcabs);
5201
BFT_REALLOC(filename, strlen(filename) + 1 + 4 + 1, char);
5203
strcat(filename, "_");
5204
strcat(filename, buf1);
5208
BFT_REALLOC(filename, strlen(filename) + 4 + 1, char);
5209
strcat(filename, ".dat");
5210
file = fopen(filename, "w");
5213
cs_base_warn(__FILE__, __LINE__);
5214
bft_printf( _("Unable to open the file: %s\n"), filename);
5218
fprintf(file, "# Code_Saturne 1D result's profile\n#\n");
5219
fprintf(file, "# Iteration output: %i\n", *ntcabs);
5220
fprintf(file, "# Time output: %12.5e\n#\n", *ttcabs);
5221
fprintf(file, "# Start point: x = %12.5e y = %12.5e z = %12.5e\n",
5223
fprintf(file, "# End point: x = %12.5e y = %12.5e z = %12.5e\n#\n",
5225
fprintf(file, "#TITLE: %s\n", title);
5226
fprintf(file, "#COLUMN_TITLES: Distance | X | Y | Z");
5227
for (ii = 0 ; ii < nvar_prop ; ii++) {
5228
char *buffer = _get_profile_label_name(i, ii);
5229
fprintf(file, " | %s", buffer);
5232
fprintf(file, "\n");
5241
a = 1. / (double) (npoint-1);
5243
for (ii = 0; ii < npoint; ii++) {
5246
xyz[0] = aa * (x2 - x1) + x1;
5247
xyz[1] = aa * (y2 - y1) + y1;
5248
xyz[2] = aa * (z2 - z1) + z1;
5250
CS_PROCF(findpt, FINDPT)(ncelet, ncel, xyzcen,
5251
&xyz[0], &xyz[1], &xyz[2],
5254
if ((iel != iel1) || (irangv != irang1)) {
5258
if (cs_glob_rank_id == irangv) {
5261
xx = xyzcen[3 * iel + 0];
5262
yy = xyzcen[3 * iel + 1];
5263
zz = xyzcen[3 * iel + 2];
5270
array[0] = sqrt(xx*xx + yy*yy + zz*zz);
5272
for (iii=0; iii < nvar_prop; iii++) {
5274
name = _get_profile_name(i, iii);
5276
for (j=0; j < vars->nvar; j++) {
5277
if (cs_gui_strcmp(name, vars->name[j]))
5278
array[iii+4] = rtp[vars->rtp[j] * (*ncelet) + iel];
5281
for (j=0; j < vars->nprop; j++) {
5282
if (cs_gui_strcmp(name, vars->properties_name[j]))
5284
= propce[(vars->propce[j]-1) * (*ncelet) + iel];
5292
for (iii=0; iii < nvar_prop4; iii++)
5296
/* Send to other processors if parallel */
5297
#if defined(HAVE_MPI)
5298
if (cs_glob_rank_id >= 0) {
5307
if (cs_glob_rank_id <= 0) {
5308
for (iii=0; iii < nvar_prop4; iii++)
5309
fprintf(file, "%12.5e ", array[iii]);
5310
fprintf(file, "\n");
5315
if (cs_glob_rank_id <= 0) fclose(file);
5322
/*----------------------------------------------------------------------------
5323
* Free memory: clean global private variables and libxml2 variables
5325
* Fortran Interface:
5330
* INTEGER NCHARB --> number of coal
5331
*----------------------------------------------------------------------------*/
5333
void CS_PROCF (memui1, MEMUI1) (const int *const ncharb)
5337
cs_gui_boundary_conditions_free_memory(ncharb);
5339
/* clean memory for global private structure vars */
5341
for (i=0; i < cs_glob_var->nvar; i++)
5343
BFT_FREE(cs_glob_var->type[i]);
5344
BFT_FREE(cs_glob_var->head[i]);
5345
BFT_FREE(cs_glob_var->name[i]);
5348
for (i=0; i < cs_glob_var->nscaus + cs_glob_var->nscapp; i++)
5349
BFT_FREE(cs_glob_var->label[i]);
5351
for (i=0; i < cs_glob_var->nprop; i++)
5352
BFT_FREE(cs_glob_var->properties_name[i]);
5354
BFT_FREE(cs_glob_var->label);
5355
BFT_FREE(cs_glob_var->model);
5356
BFT_FREE(cs_glob_var->model_value);
5357
BFT_FREE(cs_glob_var->rtp);
5358
BFT_FREE(cs_glob_var->name);
5359
BFT_FREE(cs_glob_var->type);
5360
BFT_FREE(cs_glob_var->head);
5361
BFT_FREE(cs_glob_var->properties_name);
5362
BFT_FREE(cs_glob_var->properties_ipp);
5363
BFT_FREE(cs_glob_var->propce);
5364
BFT_FREE(cs_glob_var);
5367
for (i = 0; i < cs_glob_label->_cs_gui_max_vars; i++)
5368
BFT_FREE(cs_glob_label->_cs_gui_var_name[i]);
5370
BFT_FREE(cs_glob_label->_cs_gui_var_name);
5371
BFT_FREE(cs_glob_label);
5373
/* clean memory for xml document */
5375
#if defined(HAVE_LIBXML2)
5376
if (xpathCtx != NULL) xmlXPathFreeContext(xpathCtx);
5377
if (node != NULL) xmlFreeNode(node);
5380
/* Shutdown libxml */
5382
#if defined(HAVE_LIBXML2)
5388
/*----------------------------------------------------------------------------*/