~ubuntu-branches/ubuntu/precise/code-saturne/precise

« back to all changes in this revision

Viewing changes to src/base/cs_gui.c

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2011-11-24 00:00:08 UTC
  • mfrom: (6.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20111124000008-2vo99e38267942q5
Tags: 2.1.0-3
Install a missing file

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*============================================================================
2
 
 *
3
 
 *     This file is part of the Code_Saturne Kernel, element of the
4
 
 *     Code_Saturne CFD tool.
5
 
 *
6
 
 *     Copyright (C) 1998-2009 EDF S.A., France
7
 
 *
8
 
 *     contact: saturne-support@edf.fr
9
 
 *
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.
14
 
 *
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.
19
 
 *
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
25
 
 *
26
 
 *============================================================================*/
27
 
 
28
 
/*============================================================================
29
 
 * Management of the GUI parameters file: main parameters
30
 
 *============================================================================*/
31
 
 
32
 
#if defined(HAVE_CONFIG_H)
33
 
#include "cs_config.h"
34
 
#endif
35
 
 
36
 
/*----------------------------------------------------------------------------
37
 
 * Standard C library headers
38
 
 *----------------------------------------------------------------------------*/
39
 
 
40
 
#include <stdio.h>
41
 
#include <stdlib.h>
42
 
#include <math.h>
43
 
#include <string.h>
44
 
#include <fcntl.h>
45
 
#include <unistd.h>
46
 
#include <assert.h>
47
 
 
48
 
/*----------------------------------------------------------------------------
49
 
 * libxml2 library headers
50
 
 *----------------------------------------------------------------------------*/
51
 
 
52
 
#if defined(HAVE_LIBXML2)
53
 
 
54
 
#include <libxml/tree.h>
55
 
#include <libxml/parser.h>
56
 
#include <libxml/xpath.h>
57
 
#include <libxml/xpathInternals.h>
58
 
 
59
 
#endif
60
 
 
61
 
/*----------------------------------------------------------------------------
62
 
 * BFT library headers
63
 
 *----------------------------------------------------------------------------*/
64
 
 
65
 
#include <bft_mem.h>
66
 
#include <bft_error.h>
67
 
#include <bft_printf.h>
68
 
 
69
 
/*----------------------------------------------------------------------------
70
 
 * FVM library headers
71
 
 *----------------------------------------------------------------------------*/
72
 
 
73
 
#include "fvm_selector.h"
74
 
 
75
 
/*----------------------------------------------------------------------------
76
 
 * MEI library headers
77
 
 *----------------------------------------------------------------------------*/
78
 
 
79
 
#ifdef HAVE_MEI
80
 
 
81
 
#include "mei_evaluate.h"
82
 
 
83
 
#endif
84
 
 
85
 
/*----------------------------------------------------------------------------
86
 
 * Local headers
87
 
 *----------------------------------------------------------------------------*/
88
 
 
89
 
#include "cs_base.h"
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"
95
 
#include "cs_mesh.h"
96
 
#include "cs_prototypes.h"
97
 
 
98
 
/*----------------------------------------------------------------------------
99
 
 * Header for the current file
100
 
 *----------------------------------------------------------------------------*/
101
 
 
102
 
#include "cs_gui.h"
103
 
 
104
 
/*----------------------------------------------------------------------------*/
105
 
 
106
 
BEGIN_C_DECLS
107
 
 
108
 
/*=============================================================================
109
 
 * Local Macro Definitions
110
 
 *============================================================================*/
111
 
 
112
 
/* debugging switch */
113
 
#define _XML_DEBUG_ 0
114
 
 
115
 
/*============================================================================
116
 
 * Local Structure Definitions
117
 
 *============================================================================*/
118
 
 
119
 
/*============================================================================
120
 
 * External global variables
121
 
 *============================================================================*/
122
 
 
123
 
/*----------------------------------------------------------------------------
124
 
 * Management of the XML document
125
 
 *----------------------------------------------------------------------------*/
126
 
 
127
 
#if defined(HAVE_LIBXML2)
128
 
extern xmlXPathContextPtr xpathCtx;   /* Pointer on the Context       */
129
 
extern xmlNodePtr node;               /* Pointer on the root node     */
130
 
#endif
131
 
 
132
 
/*============================================================================
133
 
 * Private global variables
134
 
 *============================================================================*/
135
 
 
136
 
/*============================================================================
137
 
 * Static global variables
138
 
 *============================================================================*/
139
 
 
140
 
/* Pointer on the main variable structure */
141
 
 
142
 
cs_var_t    *cs_glob_var = NULL;
143
 
cs_label_t  *cs_glob_label = NULL;
144
 
 
145
 
/*============================================================================
146
 
 * Private function definitions
147
 
 *============================================================================*/
148
 
 
149
 
/*-----------------------------------------------------------------------------
150
 
 * Copy a variable name to private variable names array
151
 
 *
152
 
 * parameters:
153
 
 *   varname        -->  name or label of the variable/scalar/property
154
 
 *   ipp            -->  index from the fortran array associated to varname
155
 
 *----------------------------------------------------------------------------*/
156
 
 
157
 
static void
158
 
_gui_copy_varname(const char *varname, int ipp)
159
 
{
160
 
  size_t l;
161
 
 
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);
166
 
 
167
 
  l = strlen(varname);
168
 
 
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);
171
 
 
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);
174
 
 
175
 
  strcpy(cs_glob_label->_cs_gui_var_name[ipp-1], varname);
176
 
}
177
 
 
178
 
/*----------------------------------------------------------------------------
179
 
 * Turbulence model parameters.
180
 
 *
181
 
 * parameters:
182
 
 *   param                -->  name of the parameters
183
 
 *   keyword             <--   turbulence model parameter
184
 
 *----------------------------------------------------------------------------*/
185
 
 
186
 
static void
187
 
cs_gui_advanced_options_turbulence(const char *const param,
188
 
                                         int  *const keyword)
189
 
{
190
 
  char *path = NULL;
191
 
  int  result;
192
 
 
193
 
  path = cs_xpath_init_path();
194
 
  cs_xpath_add_elements(&path, 3, "thermophysical_models", "turbulence", param);
195
 
 
196
 
  if (cs_gui_strcmp("gravity_terms", param)) {
197
 
 
198
 
    cs_xpath_add_attribute(&path, "status");
199
 
    if (cs_gui_get_status(path, &result)) *keyword = result;
200
 
 
201
 
  } else if (cs_gui_strcmp("scale_model", param)) {
202
 
 
203
 
    cs_xpath_add_function_text(&path);
204
 
    if (cs_gui_get_int(path, &result)) *keyword = result;
205
 
 
206
 
  } else
207
 
    bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
208
 
 
209
 
  BFT_FREE(path);
210
 
}
211
 
 
212
 
/*-----------------------------------------------------------------------------
213
 
 * Return the name of the related scalar if the scalar "num_sca" is a variance
214
 
 *
215
 
 * parameter:
216
 
 *   num_sca           -->  scalar number
217
 
 *----------------------------------------------------------------------------*/
218
 
 
219
 
static char *
220
 
cs_gui_scalar_variance(const int num_sca)
221
 
{
222
 
  char *path = NULL;
223
 
  char *variance = NULL;
224
 
 
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);
230
 
 
231
 
  variance = cs_gui_get_text_value(path);
232
 
 
233
 
  BFT_FREE(path);
234
 
 
235
 
  return variance;
236
 
}
237
 
 
238
 
/*-----------------------------------------------------------------------------
239
 
 * Return the user thermal scalar indicator.
240
 
 *----------------------------------------------------------------------------*/
241
 
 
242
 
static int
243
 
cs_gui_thermal_scalar(void)
244
 
{
245
 
  char *model_name = NULL;
246
 
  int   test = 0;
247
 
 
248
 
  model_name = cs_gui_get_thermophysical_model("thermal_scalar");
249
 
 
250
 
  if (cs_gui_strcmp(model_name, "off"))
251
 
    test = 0;
252
 
  else {
253
 
    if (cs_gui_strcmp(model_name, "enthalpy"))
254
 
      test =  2 ;
255
 
    else if (cs_gui_strcmp(model_name, "temperature_kelvin"))
256
 
      test =  1 ;
257
 
    else if (cs_gui_strcmp(model_name, "temperature_celsius"))
258
 
      test = -1 ;
259
 
    else
260
 
      bft_error(__FILE__, __LINE__, 0,
261
 
                _("Invalid thermal model: %s\n"), model_name);
262
 
    }
263
 
 
264
 
  BFT_FREE(model_name);
265
 
 
266
 
  return test;
267
 
}
268
 
 
269
 
/*----------------------------------------------------------------------------
270
 
 * Get thermal user scalar number if it is exist.
271
 
 *
272
 
 * parameters:
273
 
 *   iscalt               <--  thermal scalar number order
274
 
 *   iscsth               <--  nature of the thermal scalar (C, K, J/kg)
275
 
 *----------------------------------------------------------------------------*/
276
 
 
277
 
static void
278
 
cs_gui_thermal_scalar_number(int *const iscalt,
279
 
                             int *const iscsth)
280
 
{
281
 
  int ind_thermal;
282
 
  int i, index, size;
283
 
  int iphas = 0;
284
 
  char *path = NULL;
285
 
  char **name = NULL;
286
 
 
287
 
  ind_thermal = cs_gui_thermal_scalar();
288
 
 
289
 
  if (ind_thermal) {
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);
293
 
 
294
 
    index = -1;
295
 
    for (i=0; i < size; i++) {
296
 
      if (cs_gui_strcmp(name[i], "thermal")) index = i;
297
 
    }
298
 
    iscalt[iphas] = index+1;
299
 
    iscsth[index] = ind_thermal;
300
 
 
301
 
    BFT_FREE(path);
302
 
    for (i=0; i < size; i++) BFT_FREE(name[i]);
303
 
    BFT_FREE(name);
304
 
  }
305
 
}
306
 
 
307
 
/*-----------------------------------------------------------------------------
308
 
 * Return the name of the diffusion_coefficient property for a scalar
309
 
 *
310
 
 * parameters:
311
 
 *   scalar_index   --> index of the scalar
312
 
 *----------------------------------------------------------------------------*/
313
 
 
314
 
static char *
315
 
_scalar_diffusion_coefficient_name(const int idx)
316
 
{
317
 
    int ncar = 0;
318
 
    char *name = NULL;
319
 
    char *suf = NULL;
320
 
 
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");
326
 
    strcat(name, "_");
327
 
    strcat(name, suf);
328
 
    BFT_FREE(suf);
329
 
    return name;
330
 
}
331
 
 
332
 
/*-----------------------------------------------------------------------------
333
 
 * Return the value of choice for user scalar's property
334
 
 *
335
 
 * parameters:
336
 
 *   scalar_num     --> number of scalar
337
 
 *   choice         --> choice for property
338
 
 *----------------------------------------------------------------------------*/
339
 
 
340
 
static int
341
 
cs_gui_scalar_properties_choice(const int scalar_num, int *const choice)
342
 
{
343
 
  char *path = NULL;
344
 
  char *buff = NULL;
345
 
  int   ichoice;
346
 
 
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");
352
 
 
353
 
  buff = cs_gui_get_attribute_value(path);
354
 
 
355
 
  if (buff == NULL) {
356
 
    ichoice = 0;
357
 
 
358
 
  } else {
359
 
    ichoice = 1;
360
 
 
361
 
    if (cs_gui_strcmp(buff, "variable") || cs_gui_strcmp(buff, "user_law"))
362
 
      *choice = 1;
363
 
    else if (cs_gui_strcmp(buff, "constant"))
364
 
      *choice = 0;
365
 
    else
366
 
      bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
367
 
  }
368
 
 
369
 
  BFT_FREE(path);
370
 
  BFT_FREE(buff);
371
 
 
372
 
  return ichoice;
373
 
}
374
 
 
375
 
/*-----------------------------------------------------------------------------
376
 
 * Return value of diffusion coefficient for user scalars
377
 
 *        return 1 if value exists
378
 
 *        return 0 if not
379
 
 *
380
 
 * parameters:
381
 
 *   num_sca  --> number of scalar
382
 
 *   value   <--  value of diffusion coefficient
383
 
 *----------------------------------------------------------------------------*/
384
 
 
385
 
static void
386
 
cs_gui_scalar_diffusion_value(const int           num_sca,
387
 
                                    double *const value)
388
 
{
389
 
  char  *path = NULL;
390
 
  double result;
391
 
 
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);
398
 
 
399
 
  if (cs_gui_get_double(path, &result))
400
 
    *value = result;
401
 
 
402
 
  BFT_FREE(path);
403
 
}
404
 
 
405
 
/*-----------------------------------------------------------------------------
406
 
 * Get the status of steady management.
407
 
 *
408
 
 * parameter:
409
 
 *   keyword         <--  if 1 unsteady management else steady management
410
 
 *----------------------------------------------------------------------------*/
411
 
 
412
 
static void
413
 
cs_gui_get_steady_status(int *const keyword)
414
 
{
415
 
  char *path = NULL;
416
 
  int   result;
417
 
 
418
 
  path = cs_xpath_short_path();
419
 
  cs_xpath_add_element(&path, "steady_management");
420
 
  cs_xpath_add_attribute(&path, "status");
421
 
 
422
 
  if (cs_gui_get_status(path, &result))
423
 
    *keyword = result;
424
 
  else
425
 
    *keyword = 1;
426
 
 
427
 
  BFT_FREE(path);
428
 
}
429
 
 
430
 
/*-----------------------------------------------------------------------------
431
 
 * Return  parameters for steady management.
432
 
 *
433
 
 * parameter:
434
 
 *   param           -->  steady parameter
435
 
 *   keyword         <--  new value for the steady parameter
436
 
 *----------------------------------------------------------------------------*/
437
 
 
438
 
static void
439
 
cs_gui_steady_parameters(const char   *const param,
440
 
                               double *const keyword)
441
 
{
442
 
  char   *path   = NULL;
443
 
  double  result = 0.0;
444
 
  int     status = 0;
445
 
 
446
 
  path = cs_xpath_init_path();
447
 
  cs_xpath_add_elements(&path, 3, "analysis_control", "steady_management", param);
448
 
 
449
 
  if (cs_gui_strcmp(param,"zero_iteration")){
450
 
 
451
 
    cs_xpath_add_attribute(&path, "status");
452
 
    if(cs_gui_get_status(path, &status)) *keyword = status;
453
 
 
454
 
  } else {
455
 
 
456
 
    cs_xpath_add_function_text(&path);
457
 
    if (cs_gui_get_double(path, &result)) *keyword = result;
458
 
 
459
 
  }
460
 
  BFT_FREE(path);
461
 
}
462
 
 
463
 
/*-----------------------------------------------------------------------------
464
 
 * Modify time parameters.
465
 
 *
466
 
 * parameters:
467
 
 *   param              -->  time parameter
468
 
 *   keyword            <--  new value of the time parameter
469
 
 *----------------------------------------------------------------------------*/
470
 
 
471
 
static void
472
 
cs_gui_time_parameters(const char   *const param,
473
 
                             double *const keyword)
474
 
{
475
 
  char   *path   = NULL;
476
 
  double  result = 0.0;
477
 
  int     status = 0;
478
 
 
479
 
  path = cs_xpath_init_path();
480
 
  cs_xpath_add_elements(&path, 3, "analysis_control", "time_parameters", param);
481
 
 
482
 
  if (cs_gui_strcmp(param,"zero_time_step") ||
483
 
      cs_gui_strcmp(param,"thermal_time_step")) {
484
 
 
485
 
    cs_xpath_add_attribute(&path, "status");
486
 
    if(cs_gui_get_status(path, &status)) *keyword = status;
487
 
 
488
 
  } else {
489
 
 
490
 
    cs_xpath_add_function_text(&path);
491
 
    if (cs_gui_get_double(path, &result)) *keyword = result;
492
 
 
493
 
  }
494
 
  BFT_FREE(path);
495
 
}
496
 
 
497
 
/*-----------------------------------------------------------------------------
498
 
 * Modify restart parameters.
499
 
 *
500
 
 * parameters:
501
 
 *   param               -->  restart parameter
502
 
 *   keyword            <-->  new value of the restart parameter
503
 
 *----------------------------------------------------------------------------*/
504
 
 
505
 
static void
506
 
cs_gui_restart_parameters_status(const char *param, int *const keyword)
507
 
{
508
 
  int   result;
509
 
  char *path = NULL;
510
 
 
511
 
  path = cs_xpath_init_path();
512
 
  cs_xpath_add_elements(&path, 3, "calcul_management", "start_restart", param);
513
 
 
514
 
  if (cs_gui_strcmp(param, "restart_rescue")) {
515
 
    cs_xpath_add_function_text(&path);
516
 
    if (cs_gui_get_int(path, &result))
517
 
      *keyword = result;
518
 
 
519
 
  } else {
520
 
    cs_xpath_add_attribute(&path, "status");
521
 
 
522
 
    if (cs_gui_get_status(path, &result))
523
 
      *keyword = result;
524
 
  }
525
 
 
526
 
  BFT_FREE(path);
527
 
}
528
 
 
529
 
/*-----------------------------------------------------------------------------
530
 
 * Return value of numerical parameter markup
531
 
 *
532
 
 * parameters:
533
 
 *   variable_type  --> name of variable
534
 
 *   value_type     --> name of numerical parameter parkup
535
 
 *   value          <-- value of numerical parameter
536
 
 *----------------------------------------------------------------------------*/
537
 
 
538
 
static void
539
 
cs_gui_variable_value(const char   *const variable_type,
540
 
                      const char   *const value_type,
541
 
                            double *const value)
542
 
{
543
 
  char  *path = NULL;
544
 
  double result;
545
 
 
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);
551
 
 
552
 
  if (cs_gui_get_double(path, &result)) *value = result;
553
 
 
554
 
  BFT_FREE(path);
555
 
}
556
 
 
557
 
/*----------------------------------------------------------------------------
558
 
 * Get the attribute value from the xpath query.
559
 
 *
560
 
 * parameters:
561
 
 *   path          --> path for xpath query
562
 
 *   child         --> child markup
563
 
 *   keyword      <--  value of attribute node
564
 
 *----------------------------------------------------------------------------*/
565
 
 
566
 
static void
567
 
_attribute_value(      char *      path,
568
 
                 const char *const child,
569
 
                       int  *const keyword)
570
 
{
571
 
  char *choice = NULL;
572
 
  int   result;
573
 
 
574
 
  assert(path != NULL);
575
 
  assert(child != NULL);
576
 
 
577
 
  if (cs_gui_strcmp(child, "order_scheme")) {
578
 
 
579
 
    /* *keyword = 1; */
580
 
    cs_xpath_add_attribute(&path, "choice");
581
 
    choice = cs_gui_get_attribute_value(path);
582
 
 
583
 
    if (cs_gui_strcmp(choice, "centered"))
584
 
      *keyword = 1;
585
 
    else if (cs_gui_strcmp(choice, "solu"))
586
 
      *keyword = 0;
587
 
    BFT_FREE(choice);
588
 
 
589
 
  } else {
590
 
 
591
 
    cs_xpath_add_attribute(&path, "status");
592
 
 
593
 
    if (cs_gui_get_status(path, &result)) {
594
 
      *keyword = result;
595
 
 
596
 
      if (cs_gui_strcmp(child, "slope_test")) {
597
 
        if (result == 1) *keyword = 0;
598
 
        if (result == 0) *keyword = 1;
599
 
      }
600
 
    } else {
601
 
 
602
 
      if (cs_gui_strcmp(child, "postprocessing_recording") ||
603
 
          cs_gui_strcmp(child, "listing_printing")) *keyword = 1;
604
 
 
605
 
    }
606
 
  }
607
 
  BFT_FREE(path);
608
 
}
609
 
 
610
 
/*----------------------------------------------------------------------------
611
 
 * Get the attribute value associated to a child markup from a variable.
612
 
 *
613
 
 * parameters:
614
 
 *   name          -->  name of the variable markup
615
 
 *   child         -->  child markup
616
 
 *   keyword      <--   value of attribute node contained in the child markup
617
 
 *----------------------------------------------------------------------------*/
618
 
 
619
 
static void
620
 
cs_gui_variable_attribute(const char *const name,
621
 
                          const char *const child,
622
 
                                int  *const keyword)
623
 
{
624
 
  char *path = NULL;
625
 
 
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);
630
 
 
631
 
  _attribute_value(path, child, keyword);
632
 
}
633
 
 
634
 
/*----------------------------------------------------------------------------
635
 
 * Get the text value associated to a child markup from a scalar.
636
 
 *
637
 
 * parameters:
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
 
 *----------------------------------------------------------------------------*/
642
 
 
643
 
static void
644
 
cs_gui_scalar_value(const char   *const label,
645
 
                    const char   *const child,
646
 
                          double *const value)
647
 
{
648
 
  char   *path = NULL;
649
 
  double  result;
650
 
 
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);
656
 
 
657
 
  if (cs_gui_get_double(path, &result)) *value = result;
658
 
 
659
 
  BFT_FREE(path);
660
 
}
661
 
 
662
 
/*----------------------------------------------------------------------------
663
 
 * Get the attribute value associated to a child markup from a scalar.
664
 
 *
665
 
 * parameters:
666
 
 *   label         -->  name of the scalar markup
667
 
 *   child         -->  child markup
668
 
 *   keyword      <--   value of attribute node contained in the child markup
669
 
 *----------------------------------------------------------------------------*/
670
 
 
671
 
static void
672
 
cs_gui_scalar_attribute(const char *const label,
673
 
                        const char *const child,
674
 
                              int  *const keyword)
675
 
{
676
 
  char *path = NULL;
677
 
 
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);
682
 
 
683
 
  _attribute_value(path, child, keyword);
684
 
}
685
 
 
686
 
/*-----------------------------------------------------------------------------
687
 
 * Get values related the modelling scalar: min, max ...
688
 
 *
689
 
 * returns:
690
 
 *    1 if value exists
691
 
 *    0 otherwise
692
 
 *    the result is stored in "value"
693
 
 *----------------------------------------------------------------------------*/
694
 
 
695
 
 
696
 
static void
697
 
cs_gui_model_scalar_value(const   char *const model,
698
 
                          const   char *const name,
699
 
                          const   char *const keyword,
700
 
                                  double *const value)
701
 
{
702
 
  char   *path = NULL;
703
 
  double  result;
704
 
 
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);
712
 
 
713
 
  if (cs_gui_get_double(path,&result))
714
 
    *value = result;
715
 
 
716
 
  BFT_FREE(path);
717
 
}
718
 
 
719
 
/*----------------------------------------------------------------------------
720
 
 * Get the attribute value associated to a child markup from a scalar.
721
 
 *
722
 
 * parameters:
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
 
 *----------------------------------------------------------------------------*/
728
 
 
729
 
static void
730
 
cs_gui_model_scalar_output_status(const char *const model,
731
 
                                  const char *const name,
732
 
                                  const char *const child,
733
 
                                        int  *const keyword)
734
 
{
735
 
  char *path = NULL;
736
 
 
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);
743
 
 
744
 
  _attribute_value(path, child, keyword);
745
 
}
746
 
 
747
 
/*-----------------------------------------------------------------------------
748
 
 * Modify double numerical parameters.
749
 
 *
750
 
 * parameters:
751
 
 *   param               -->  label of the numerical parameter
752
 
 *   keyword            <-->  value of the numerical parameter
753
 
 *----------------------------------------------------------------------------*/
754
 
 
755
 
void
756
 
cs_gui_numerical_double_parameters(const char   *const param,
757
 
                                         double *const keyword)
758
 
{
759
 
  char  *path = NULL;
760
 
  double result;
761
 
 
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);
766
 
 
767
 
  if (cs_gui_get_double(path, &result))
768
 
    *keyword = result;
769
 
 
770
 
  BFT_FREE(path);
771
 
}
772
 
 
773
 
/*-----------------------------------------------------------------------------
774
 
 * Modify integer numerical parameters.
775
 
 *
776
 
 * parameters:
777
 
 *   param               -->  label of the numerical parameter
778
 
 *   keyword            <-->  value of the numerical parameter
779
 
 *----------------------------------------------------------------------------*/
780
 
 
781
 
static void
782
 
cs_gui_numerical_int_parameters(const char *const param,
783
 
                                      int  *const keyword)
784
 
{
785
 
  char *path = NULL;
786
 
  char *choice = NULL;
787
 
  int   result;
788
 
 
789
 
  path = cs_xpath_init_path();
790
 
  cs_xpath_add_element(&path, "numerical_parameters");
791
 
  cs_xpath_add_element(&path, param);
792
 
 
793
 
  if (cs_gui_strcmp(param, "gradient_reconstruction")){
794
 
 
795
 
    cs_xpath_add_attribute(&path, "choice");
796
 
    choice = cs_gui_get_attribute_value(path);
797
 
    if (choice) *keyword = atoi(choice);
798
 
    BFT_FREE(choice);
799
 
 
800
 
  } else {
801
 
 
802
 
    cs_xpath_add_attribute(&path, "status");
803
 
    if (cs_gui_get_status(path, &result)) *keyword = result;
804
 
 
805
 
  }
806
 
  BFT_FREE(path);
807
 
}
808
 
 
809
 
/*-----------------------------------------------------------------------------
810
 
 * Modify gravity parameters.
811
 
 *
812
 
 * parameters:
813
 
 *   param               -->  gravity parameter (GX, GY, GZ)
814
 
 *   keyword            <-->  new value of the gravity parameter
815
 
 *----------------------------------------------------------------------------*/
816
 
 
817
 
static void
818
 
cs_gui_gravity_value(const char   *const param,
819
 
                           double *const value)
820
 
{
821
 
  char   *path = NULL;
822
 
  double  result;
823
 
 
824
 
  path = cs_xpath_init_path();
825
 
  cs_xpath_add_elements(&path, 3, "physical_properties", "gravity", param);
826
 
  cs_xpath_add_function_text(&path);
827
 
 
828
 
  if (cs_gui_get_double(path, &result)) *value = result;
829
 
 
830
 
  BFT_FREE(path);
831
 
}
832
 
 
833
 
/*-----------------------------------------------------------------------------
834
 
 * Get initial value from property markup.
835
 
 *
836
 
 * parameters:
837
 
 *   property_name       -->  name of the property
838
 
 *   value              <--   new initial value of the property
839
 
 *----------------------------------------------------------------------------*/
840
 
 
841
 
static void
842
 
cs_gui_properties_value(const char   *const property_name,
843
 
                              double *const value)
844
 
{
845
 
  char   *path = NULL;
846
 
  double  result;
847
 
 
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);
853
 
 
854
 
  if (cs_gui_get_double(path, &result)) *value = result;
855
 
 
856
 
  BFT_FREE(path);
857
 
}
858
 
/*----------------------------------------------------------------------------
859
 
 * Return the value of the choice attribute from a property name.
860
 
 *
861
 
 * parameters:
862
 
 *   property_name        -->  name of the property
863
 
 *----------------------------------------------------------------------------*/
864
 
 
865
 
static char*
866
 
_properties_choice(const char *const property_name)
867
 
{
868
 
  char *path   = NULL;
869
 
  char *choice = NULL;
870
 
 
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);
876
 
  BFT_FREE(path);
877
 
  return choice;
878
 
}
879
 
 
880
 
/*----------------------------------------------------------------------------
881
 
 * Get the value of the choice attribute from a property markup.
882
 
 * Return 1 if the xpath request has succeeded, 0 otherwise.
883
 
 *
884
 
 * parameters:
885
 
 *   property_name        -->  name of the property
886
 
 *   choice              <--   value of the attribute choice
887
 
 *----------------------------------------------------------------------------*/
888
 
 
889
 
static int
890
 
cs_gui_properties_choice(const char *const property_name, int *choice)
891
 
{
892
 
  char *buff = NULL;
893
 
  int   iok = 0;
894
 
 
895
 
  buff = _properties_choice(property_name);
896
 
  if (buff)
897
 
  {
898
 
    iok = 1;
899
 
    if (cs_gui_strcmp(buff, "variable") || cs_gui_strcmp(buff, "user_law"))
900
 
      *choice = 1;
901
 
    else if (cs_gui_strcmp(buff, "constant"))
902
 
      *choice = 0;
903
 
  }
904
 
  else
905
 
    iok = 0;
906
 
  BFT_FREE(buff);
907
 
  return iok;
908
 
}
909
 
 
910
 
/*-----------------------------------------------------------------------------
911
 
 * Get reference value of pressure
912
 
 *
913
 
 * parameters:
914
 
 *   p0              <--   value of pressure
915
 
 *----------------------------------------------------------------------------*/
916
 
 
917
 
static void
918
 
cs_gui_reference_pressure(double *const p0)
919
 
{
920
 
  char *path = NULL;
921
 
  double value;
922
 
 
923
 
  path = cs_xpath_short_path();
924
 
  cs_xpath_add_element(&path, "reference_pressure");
925
 
  cs_xpath_add_function_text(&path);
926
 
 
927
 
  if (cs_gui_get_double(path, &value))
928
 
      *p0 = value;
929
 
  BFT_FREE(path);
930
 
}
931
 
 
932
 
/*-----------------------------------------------------------------------------
933
 
 * Get reference value of temperature
934
 
 *
935
 
 * parameters:
936
 
 *   model           -->   name of activated model
937
 
 *   t0              <--   value of temperature
938
 
 *----------------------------------------------------------------------------*/
939
 
 
940
 
static void
941
 
cs_gui_reference_temperature(char *const model, double *const t0)
942
 
{
943
 
  char *path = NULL;
944
 
  double value;
945
 
 
946
 
  path = cs_xpath_short_path();
947
 
  cs_xpath_add_elements(&path, 2, model,"reference_temperature");
948
 
  cs_xpath_add_function_text(&path);
949
 
 
950
 
  if (cs_gui_get_double(path, &value)) *t0 = value;
951
 
  BFT_FREE(path);
952
 
}
953
 
 
954
 
/*-----------------------------------------------------------------------------
955
 
 * Get reference value of mass molar molecular
956
 
 *
957
 
 * parameters:
958
 
 *   model           -->   name of activated model
959
 
 *   m0              <--   value of mass molar molecular
960
 
 *----------------------------------------------------------------------------*/
961
 
 
962
 
static void cs_gui_reference_mass_molar(char *const model, double *const m0)
963
 
{
964
 
  char *path = NULL;
965
 
  double value;
966
 
 
967
 
  path = cs_xpath_short_path();
968
 
  cs_xpath_add_elements(&path, 2, model,"reference_mass_molar");
969
 
  cs_xpath_add_function_text(&path);
970
 
 
971
 
  if (cs_gui_get_double(path, &value)) *m0 = value;
972
 
  BFT_FREE(path);
973
 
}
974
 
 
975
 
/*----------------------------------------------------------------------------
976
 
 * Turbulence model parameters.
977
 
 *
978
 
 * parameters:
979
 
 *   param                -->  name of the parameters
980
 
 *   keyword             <--   turbulence model parameter
981
 
 *----------------------------------------------------------------------------*/
982
 
 
983
 
static void _option_turbulence_double(const char *const param,
984
 
                                          double *const keyword)
985
 
{
986
 
  char *path = NULL;
987
 
  double  result;
988
 
 
989
 
  path = cs_xpath_init_path();
990
 
  cs_xpath_add_elements(&path, 3, "thermophysical_models", "turbulence", param);
991
 
 
992
 
  cs_xpath_add_function_text(&path);
993
 
  if (cs_gui_get_double(path, &result)) *keyword = result;
994
 
 
995
 
  BFT_FREE(path);
996
 
}
997
 
 
998
 
/*----------------------------------------------------------------------------
999
 
 * Initialization choice of the turbulence variables parameters.
1000
 
 *
1001
 
 * parameters:
1002
 
 *   param                -->  name of the parameters
1003
 
 *   value               <--   initialization choice
1004
 
 *----------------------------------------------------------------------------*/
1005
 
 
1006
 
static void cs_gui_turbulence_initialization(const char   *const param,
1007
 
                                                   double *const value)
1008
 
{
1009
 
  char   *path = NULL;
1010
 
  double  result;
1011
 
 
1012
 
  path = cs_xpath_init_path();
1013
 
  cs_xpath_add_elements(&path, 4,
1014
 
                        "thermophysical_models",
1015
 
                        "turbulence",
1016
 
                        "initialization",
1017
 
                        param);
1018
 
  cs_xpath_add_function_text(&path);
1019
 
 
1020
 
  if (cs_gui_get_double(path, &result)) *value = result;
1021
 
  BFT_FREE(path);
1022
 
}
1023
 
 
1024
 
/*----------------------------------------------------------------------------
1025
 
 * Return the initialization choice of the turbulence variables.
1026
 
 *----------------------------------------------------------------------------*/
1027
 
 
1028
 
static char *cs_gui_turbulence_initialization_choice(void)
1029
 
{
1030
 
  char *path = NULL;
1031
 
  char *initialization_choice;
1032
 
 
1033
 
  path = cs_xpath_init_path();
1034
 
  cs_xpath_add_elements(&path, 3,
1035
 
                        "thermophysical_models",
1036
 
                        "turbulence",
1037
 
                        "initialization");
1038
 
  cs_xpath_add_attribute(&path, "choice");
1039
 
 
1040
 
  initialization_choice = cs_gui_get_attribute_value(path);
1041
 
 
1042
 
  BFT_FREE(path);
1043
 
 
1044
 
  return initialization_choice;
1045
 
}
1046
 
 
1047
 
/*================================
1048
 
 * Input / Output
1049
 
 *===============================*/
1050
 
 
1051
 
/*----------------------------------------------------------------------------
1052
 
 * Get output control value parameters.
1053
 
 *
1054
 
 * parameters:
1055
 
 *   param                -->  name of the parameter
1056
 
 *   keyword             <--   output control parameter
1057
 
 *----------------------------------------------------------------------------*/
1058
 
 
1059
 
static void cs_gui_output_value(const char *const param,
1060
 
                                      int  *const keyword)
1061
 
{
1062
 
  char *path = NULL;
1063
 
  char *choice = NULL;
1064
 
  int   result;
1065
 
 
1066
 
  path = cs_xpath_init_path();
1067
 
  cs_xpath_add_elements(&path, 3, "analysis_control", "output", param);
1068
 
 
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") ) {
1073
 
 
1074
 
    cs_xpath_add_attribute(&path, "status");
1075
 
    if(cs_gui_get_status(path, &result)) *keyword = result;
1076
 
 
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);
1081
 
  } else {
1082
 
 
1083
 
    cs_xpath_add_function_text(&path);
1084
 
    if (cs_gui_get_int(path, &result)) *keyword = result;
1085
 
 
1086
 
  }
1087
 
 
1088
 
  BFT_FREE(choice);
1089
 
  BFT_FREE(path);
1090
 
}
1091
 
 
1092
 
/*----------------------------------------------------------------------------
1093
 
 * Return the output format and options for postprocessing.
1094
 
 *
1095
 
 * parameters:
1096
 
 *   param           -->  "postprocessing_format" or "postprocessing_options"
1097
 
 *----------------------------------------------------------------------------*/
1098
 
 
1099
 
static char *
1100
 
_output_choice(const char *const param)
1101
 
{
1102
 
  char *path = NULL;
1103
 
  char *choice = NULL;
1104
 
 
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);
1109
 
  BFT_FREE(path);
1110
 
  return choice;
1111
 
}
1112
 
 
1113
 
/*----------------------------------------------------------------------------
1114
 
 * Get the output format and options for postprocessing.
1115
 
 *
1116
 
 * parameters:
1117
 
 *   param                -->  name of the parameter
1118
 
 *   keyword             <--   output control parameter
1119
 
 *   size_key             -->  keyword string size
1120
 
 *----------------------------------------------------------------------------*/
1121
 
 
1122
 
static void cs_gui_output_choice(const char *const param,
1123
 
                                       char *const keyword,
1124
 
                                 const int  *const size_key)
1125
 
{
1126
 
  char *choice = NULL;
1127
 
  choice = _output_choice(param);
1128
 
  if (choice != NULL) cs_gui_strcpy_c2f(keyword, choice, *size_key);
1129
 
  BFT_FREE(choice);
1130
 
}
1131
 
 
1132
 
/*----------------------------------------------------------------------------
1133
 
 * Get postprocessing value parameters for surfacic variables
1134
 
 *
1135
 
 * parameters:
1136
 
 *   name                -->  name of the parameter
1137
 
 *   keyword             <--   output control parameter
1138
 
 *----------------------------------------------------------------------------*/
1139
 
 
1140
 
static void cs_gui_surfacic_variable_post(const char *const name,
1141
 
                                          const int  *const param,
1142
 
                                                int  *const ipstdv)
1143
 
{
1144
 
  char *path = NULL;
1145
 
  int   result;
1146
 
 
1147
 
  path = cs_xpath_short_path();
1148
 
  cs_xpath_add_element(&path, "property");
1149
 
 
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)) {
1154
 
    if (result == 0)
1155
 
      *ipstdv = *ipstdv / *param;
1156
 
  }
1157
 
  BFT_FREE(path);
1158
 
}
1159
 
 
1160
 
 
1161
 
/*==================================
1162
 
 * TREATMENTS FOR TIME AVERAGES
1163
 
 *=================================*/
1164
 
 
1165
 
/*----------------------------------------------------------------------------
1166
 
 * Return the number of variables and properties inside a given time average.
1167
 
 *
1168
 
 * parameters:
1169
 
 *   id           -->  time average number (imom)
1170
 
 *----------------------------------------------------------------------------*/
1171
 
 
1172
 
static int
1173
 
_get_time_average_n_variables(const int id)
1174
 
{
1175
 
  char *path = NULL;
1176
 
  int   number = 0;
1177
 
 
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);
1183
 
 
1184
 
  BFT_FREE(path);
1185
 
 
1186
 
  return number;
1187
 
 
1188
 
}
1189
 
 
1190
 
/*----------------------------------------------------------------------------
1191
 
 * Get value of a parameter for a given time avegare.
1192
 
 *
1193
 
 * parameters:
1194
 
 *   id              -->  time average number (imom)
1195
 
 *   param           -->  name of the parameter
1196
 
 *   data           <--   value of the parameter
1197
 
 *----------------------------------------------------------------------------*/
1198
 
 
1199
 
static void _get_time_average_data(const int         id,
1200
 
                                   const char *const param,
1201
 
                                         int  *const data)
1202
 
{
1203
 
  char *path = NULL;
1204
 
  int   result = 0;
1205
 
 
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);
1210
 
 
1211
 
  cs_xpath_add_function_text(&path);
1212
 
  if (cs_gui_get_int(path, &result))
1213
 
    *data = result;
1214
 
 
1215
 
  BFT_FREE(path);
1216
 
}
1217
 
 
1218
 
/*----------------------------------------------------------------------------
1219
 
 * Return the name of a variable or a property for a given time average.
1220
 
 *
1221
 
 * parameters:
1222
 
 *   id           -->  time average number (imom)
1223
 
 *   nb           -->  variable or property number
1224
 
 *----------------------------------------------------------------------------*/
1225
 
 
1226
 
static char *_get_time_average_variable_name(const int id, const int nb)
1227
 
{
1228
 
  char *path = NULL;
1229
 
  char *name = NULL;
1230
 
 
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");
1236
 
 
1237
 
  name = cs_gui_get_attribute_value(path);
1238
 
  BFT_FREE(path);
1239
 
 
1240
 
  return name;
1241
 
}
1242
 
 
1243
 
/*----------------------------------------------------------------------------
1244
 
 * Return the label of a time average.
1245
 
 *
1246
 
 * parameters:
1247
 
 *   id              -->  time average number (imom)
1248
 
 *----------------------------------------------------------------------------*/
1249
 
 
1250
 
static char *_get_time_average_label(const int id)
1251
 
{
1252
 
  char *path = NULL;
1253
 
  char *label = NULL;
1254
 
 
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");
1259
 
 
1260
 
  label = cs_gui_get_attribute_value(path);
1261
 
  BFT_FREE(path);
1262
 
 
1263
 
  return label;
1264
 
}
1265
 
 
1266
 
/*===================
1267
 
 * FOR PROBES
1268
 
 *==================*/
1269
 
 
1270
 
/*-----------------------------------------------------------------------------
1271
 
 * Return a single coordinate of a monitoring probe
1272
 
 *
1273
 
 * parameters
1274
 
 *   num_probe            -->  number aka name of the monitoring probe
1275
 
 *   probe_coord          -->  one coordinate of the monitoring probe
1276
 
 *----------------------------------------------------------------------------*/
1277
 
 
1278
 
static double cs_gui_probe_coordinate(const int         num_probe,
1279
 
                                      const char *const probe_coord)
1280
 
{
1281
 
  char  *path = NULL;
1282
 
  double result = 0.0;
1283
 
 
1284
 
  assert(num_probe>0);
1285
 
 
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);
1291
 
 
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);
1296
 
 
1297
 
  BFT_FREE(path);
1298
 
 
1299
 
  return result;
1300
 
}
1301
 
 
1302
 
/*-----------------------------------------------------------------------------
1303
 
 * Retourne le nombre de sous-balises "probe recording" situees dans la balise
1304
 
 * <variable>
1305
 
 *----------------------------------------------------------------------------*/
1306
 
 
1307
 
static int cs_gui_variable_number_probes (const char *const variable)
1308
 
{
1309
 
  char *path = NULL;
1310
 
  char *choice = NULL;
1311
 
  int   nb_probes ;
1312
 
 
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);
1319
 
 
1320
 
  if (choice) {
1321
 
    nb_probes = atoi(choice);
1322
 
  } else
1323
 
    nb_probes = -1;
1324
 
 
1325
 
  BFT_FREE(choice);
1326
 
  BFT_FREE(path);
1327
 
 
1328
 
  return nb_probes;
1329
 
}
1330
 
 
1331
 
/*-----------------------------------------------------------------------------
1332
 
 * Return probe number for balice "probe_recording" for variable
1333
 
 *
1334
 
 * parameters:
1335
 
 *   variable   -->  name of variable
1336
 
 *   num_probe  --> number of balise "probe_recording"
1337
 
 *----------------------------------------------------------------------------*/
1338
 
 
1339
 
static int cs_gui_variable_probe_name (const char *const variable,
1340
 
                                             int         num_probe)
1341
 
{
1342
 
  char *path = NULL;
1343
 
  char *strvalue = NULL;
1344
 
  int   intvalue;
1345
 
 
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");
1352
 
 
1353
 
  strvalue = cs_gui_get_attribute_value(path);
1354
 
 
1355
 
  if (strvalue == NULL)
1356
 
    bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
1357
 
 
1358
 
  intvalue = atoi(strvalue);
1359
 
 
1360
 
  BFT_FREE(strvalue);
1361
 
  BFT_FREE(path);
1362
 
 
1363
 
  return intvalue;
1364
 
}
1365
 
 
1366
 
/*-----------------------------------------------------------------------------
1367
 
 * Return label of variable
1368
 
 *
1369
 
 * parameters:
1370
 
 *   variable   --> name of variable
1371
 
 *----------------------------------------------------------------------------*/
1372
 
 
1373
 
static char *cs_gui_variable_label (const char *const variable)
1374
 
{
1375
 
  char *path = NULL;
1376
 
  char *label = NULL;
1377
 
 
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");
1382
 
 
1383
 
  label = cs_gui_get_attribute_value(path);
1384
 
 
1385
 
  BFT_FREE(path);
1386
 
 
1387
 
  return label;
1388
 
}
1389
 
 
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
 
 *----------------------------------------------------------------------------*/
1398
 
 
1399
 
static void cs_gui_thermophysical_post(const char *const variable,
1400
 
                                       const int         ipp,
1401
 
                                             int  *const ihisvr,
1402
 
                                             int  *const ilisvr,
1403
 
                                             int  *const ichrvr,
1404
 
                                       const int  *const nvppmx)
1405
 
{
1406
 
  int   nb_probes;
1407
 
  int   iprob;
1408
 
  char *varname = NULL;
1409
 
  int   num_probe;
1410
 
 
1411
 
  if (ipp == 1) return;
1412
 
 
1413
 
  cs_gui_variable_attribute(variable,
1414
 
                            "postprocessing_recording",
1415
 
                            &ichrvr[ipp-1]);
1416
 
 
1417
 
  cs_gui_variable_attribute(variable,
1418
 
                            "listing_printing",
1419
 
                            &ilisvr[ipp-1]);
1420
 
 
1421
 
  nb_probes = cs_gui_variable_number_probes(variable);
1422
 
 
1423
 
  ihisvr[0 + (ipp - 1)] = nb_probes;
1424
 
 
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;
1429
 
    }
1430
 
  }
1431
 
 
1432
 
  varname = cs_gui_variable_label(variable);
1433
 
  _gui_copy_varname(varname, ipp);
1434
 
 
1435
 
  BFT_FREE(varname);
1436
 
}
1437
 
 
1438
 
/*-----------------------------------------------------------------------------
1439
 
 * Number of sub-headers "probe_recording" for the user scalars
1440
 
 *----------------------------------------------------------------------------*/
1441
 
 
1442
 
static int cs_gui_scalar_number_probes(const int scalar_num)
1443
 
{
1444
 
  char *path = NULL;
1445
 
  char *choice = NULL;
1446
 
  int   nb_probes ;
1447
 
 
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);
1454
 
 
1455
 
  if (choice) {
1456
 
    nb_probes = atoi(choice);
1457
 
    BFT_FREE(choice);
1458
 
  } else
1459
 
    nb_probes = -1;
1460
 
 
1461
 
  BFT_FREE(path);
1462
 
 
1463
 
  return nb_probes;
1464
 
}
1465
 
 
1466
 
/*-----------------------------------------------------------------------------
1467
 
 * Return probe number for number of balise  "probe_recording"
1468
 
 *
1469
 
 * parameters:
1470
 
 *   scalar_num  --> number of scalar
1471
 
 *   num_probe   --> number of balise "probe_recording"
1472
 
 *----------------------------------------------------------------------------*/
1473
 
 
1474
 
static int cs_gui_scalar_probe_name(const int scalar_num,
1475
 
                                    const int num_probe)
1476
 
{
1477
 
  char *path = NULL;
1478
 
  char *strvalue = NULL;
1479
 
  int   value;
1480
 
 
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");
1487
 
 
1488
 
  strvalue = cs_gui_get_attribute_value(path);
1489
 
 
1490
 
  if (strvalue == NULL)
1491
 
    bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
1492
 
 
1493
 
  value = atoi(strvalue);
1494
 
 
1495
 
  BFT_FREE(path);
1496
 
  BFT_FREE(strvalue);
1497
 
 
1498
 
  return value;
1499
 
}
1500
 
 
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
 
 *----------------------------------------------------------------------------*/
1509
 
 
1510
 
static void cs_gui_scalar_post(const  int        num_sca,
1511
 
                                      int *const ihisvr,
1512
 
                                      int *const ilisvr,
1513
 
                                      int *const ichrvr,
1514
 
                               const  int *const ipprtp,
1515
 
                               const  int *const isca,
1516
 
                               const  int *const nvppmx)
1517
 
{
1518
 
  int ipp;
1519
 
  int nb_probes;
1520
 
  int iprob;
1521
 
  int num_probe;
1522
 
 
1523
 
  cs_var_t  *vars = cs_glob_var;
1524
 
 
1525
 
  ipp = ipprtp[isca[num_sca] -1 ];
1526
 
 
1527
 
  if (ipp == 1) return;
1528
 
 
1529
 
  /* EnSight outputs frequency */
1530
 
  cs_gui_scalar_attribute(vars->label[num_sca],
1531
 
                          "postprocessing_recording",
1532
 
                          &ichrvr[ipp - 1]);
1533
 
 
1534
 
  /* Listing output frequency */
1535
 
  cs_gui_scalar_attribute(vars->label[num_sca],
1536
 
                          "listing_printing",
1537
 
                          &ilisvr[ipp - 1]);
1538
 
 
1539
 
  /* Activated probes */
1540
 
  nb_probes = cs_gui_scalar_number_probes(num_sca+1);
1541
 
  ihisvr[0 + (ipp - 1)] = nb_probes;
1542
 
 
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;
1547
 
    }
1548
 
  }
1549
 
 
1550
 
  _gui_copy_varname(vars->label[num_sca], ipp);
1551
 
}
1552
 
 
1553
 
/*-----------------------------------------------------------------------------
1554
 
 * Return number of sub balises "probe_recording" for model scalars
1555
 
 *
1556
 
 * parameters:
1557
 
 *   model      -->  Type of model
1558
 
 *   name       -->  scalar name
1559
 
 *----------------------------------------------------------------------------*/
1560
 
 
1561
 
static int cs_gui_model_scalar_number_probes(const char* const model,
1562
 
                                             const char *const name)
1563
 
{
1564
 
  char *path = NULL;
1565
 
  char *choice = NULL;
1566
 
  int   nb_probes ;
1567
 
 
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);
1576
 
 
1577
 
  if (choice) {
1578
 
    nb_probes = atoi(choice);
1579
 
    BFT_FREE(choice);
1580
 
  } else
1581
 
    nb_probes = -1;
1582
 
 
1583
 
  BFT_FREE(path);
1584
 
 
1585
 
  return nb_probes;
1586
 
}
1587
 
 
1588
 
/*-----------------------------------------------------------------------------
1589
 
 * Return probe number for sub balise "probe_recording" for model scalar
1590
 
 *
1591
 
 * parameters:
1592
 
 *   model      --> type of model
1593
 
 *   name       --> scalar name
1594
 
 *   num_probe  --> number of balise "probe_recording"
1595
 
 *----------------------------------------------------------------------------*/
1596
 
 
1597
 
static int cs_gui_model_scalar_probe_name (const char *const model,
1598
 
                                           const char *const name,
1599
 
                                           const int         num_probe)
1600
 
{
1601
 
  char *path = NULL;
1602
 
  char *strvalue = NULL;
1603
 
  int   value;
1604
 
 
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");
1613
 
 
1614
 
  strvalue = cs_gui_get_attribute_value(path);
1615
 
 
1616
 
  if (strvalue == NULL)
1617
 
    bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
1618
 
 
1619
 
  value = atoi(strvalue);
1620
 
 
1621
 
  BFT_FREE(path);
1622
 
  BFT_FREE(strvalue);
1623
 
 
1624
 
  return value;
1625
 
}
1626
 
 
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
 
 *----------------------------------------------------------------------------*/
1635
 
 
1636
 
 
1637
 
static void cs_gui_model_scalar_post(const char  *const model,
1638
 
                                     const int          num_sca,
1639
 
                                           int   *const ihisvr,
1640
 
                                           int   *const ilisvr,
1641
 
                                           int   *const ichrvr,
1642
 
                                     const int   *const ipprtp,
1643
 
                                     const int   *const isca,
1644
 
                                     const int   *const nvppmx)
1645
 
{
1646
 
  int ipp;
1647
 
  int nb_probes;
1648
 
  int iprob;
1649
 
  int num_probe;
1650
 
 
1651
 
  cs_var_t  *vars = cs_glob_var;
1652
 
 
1653
 
  ipp = ipprtp[isca[num_sca] -1];
1654
 
 
1655
 
  if (ipp == 1) return;
1656
 
 
1657
 
  /* EnSight outputs frequency */
1658
 
  cs_gui_model_scalar_output_status(model, vars->label[num_sca],
1659
 
                                    "postprocessing_recording",
1660
 
                                    &ichrvr[ipp - 1]);
1661
 
 
1662
 
  /* Listing output frequency */
1663
 
  cs_gui_model_scalar_output_status(model, vars->label[num_sca],
1664
 
                                    "listing_printing",
1665
 
                                    &ilisvr[ipp - 1]);
1666
 
 
1667
 
  /* Activated probes */
1668
 
  nb_probes = cs_gui_model_scalar_number_probes(model, vars->label[num_sca]);
1669
 
 
1670
 
  ihisvr[0 + (ipp - 1)] = nb_probes;
1671
 
 
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;
1676
 
    }
1677
 
  }
1678
 
 
1679
 
  _gui_copy_varname(vars->label[num_sca], ipp);
1680
 
}
1681
 
 
1682
 
/*-----------------------------------------------------------------------------
1683
 
 * Return number of sub balises  "probe_recording" for propeety of model scalar
1684
 
 *
1685
 
 * parameters:
1686
 
 *   model    -->  Type of model
1687
 
 *   num_sca  -->  scalar number
1688
 
 *----------------------------------------------------------------------------*/
1689
 
 
1690
 
static int cs_gui_model_property_number_probes(const char *const model,
1691
 
                                               const char *const name)
1692
 
{
1693
 
  char *path = NULL;
1694
 
  char *choice = NULL;
1695
 
  int   nb_probes ;
1696
 
 
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);
1705
 
 
1706
 
  if (choice) {
1707
 
    nb_probes = atoi(choice);
1708
 
    BFT_FREE(choice);
1709
 
  } else
1710
 
    nb_probes = -1;
1711
 
 
1712
 
  BFT_FREE(path);
1713
 
 
1714
 
  return nb_probes;
1715
 
}
1716
 
 
1717
 
/*-----------------------------------------------------------------------------
1718
 
 * Return probe number for sub balise "probe_recording" for physical model's
1719
 
 * property
1720
 
 *
1721
 
 * parameters:
1722
 
 *   model      --> type of model
1723
 
 *   num_prop   --> number of property
1724
 
 *   num_probe  --> number of balise "probe_recording"
1725
 
 *----------------------------------------------------------------------------*/
1726
 
 
1727
 
static int cs_gui_model_property_probe_name(const char *const model,
1728
 
                                            const char *const name,
1729
 
                                            const int   num_probe)
1730
 
{
1731
 
  char *path = NULL;
1732
 
  char *strvalue = NULL;
1733
 
  int   value;
1734
 
 
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");
1743
 
 
1744
 
  strvalue = cs_gui_get_attribute_value(path);
1745
 
 
1746
 
  if (strvalue == NULL)
1747
 
    bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
1748
 
 
1749
 
  value = atoi(strvalue);
1750
 
 
1751
 
  BFT_FREE(path);
1752
 
  BFT_FREE(strvalue);
1753
 
 
1754
 
  return value;
1755
 
}
1756
 
 
1757
 
/*-----------------------------------------------------------------------------
1758
 
 * Return the label model's property
1759
 
 *
1760
 
 * parameters:
1761
 
 *   model             -->  modele
1762
 
 *   num_prop          <--  property's number
1763
 
 *----------------------------------------------------------------------------*/
1764
 
 
1765
 
static char *cs_gui_get_model_property_label(const char *const model,
1766
 
                                             const char *const name)
1767
 
{
1768
 
  char *path = NULL;
1769
 
  char *label_name = NULL;
1770
 
 
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");
1777
 
 
1778
 
  label_name = cs_gui_get_attribute_value(path);
1779
 
 
1780
 
  BFT_FREE(path);
1781
 
 
1782
 
  return label_name;
1783
 
}
1784
 
 
1785
 
/*-----------------------------------------------------------------------------
1786
 
 * Return status of the property for physical model
1787
 
 *
1788
 
 * parameters:
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
 
 *----------------------------------------------------------------------------*/
1794
 
 
1795
 
static void cs_gui_model_property_output_status (const char *const model,
1796
 
                                                 const char *const name,
1797
 
                                                 const char *const value_type,
1798
 
                                                       int  *const keyword)
1799
 
{
1800
 
  char *path = NULL;
1801
 
  int   result;
1802
 
 
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");
1810
 
 
1811
 
  if (cs_gui_get_status(path, &result))
1812
 
    *keyword = result;
1813
 
  else
1814
 
    *keyword = 1;
1815
 
  BFT_FREE(path);
1816
 
}
1817
 
 
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
 
 *----------------------------------------------------------------------------*/
1826
 
 
1827
 
 
1828
 
static void
1829
 
cs_gui_model_property_post (const char  *const model,
1830
 
                            const int          num_prop,
1831
 
                                  int   *const ihisvr,
1832
 
                                  int   *const ilisvr,
1833
 
                                  int   *const ichrvr,
1834
 
                            const int   *const nvppmx)
1835
 
{
1836
 
  int ipp;
1837
 
  int nb_probes;
1838
 
  int iprob;
1839
 
  int num_probe;
1840
 
  char *varname = NULL;
1841
 
 
1842
 
  cs_var_t  *vars = cs_glob_var;
1843
 
 
1844
 
  ipp = vars->properties_ipp[num_prop];
1845
 
 
1846
 
  if (ipp == 1) return;
1847
 
 
1848
 
  /* EnSight outputs frequency */
1849
 
  cs_gui_model_property_output_status(model,
1850
 
                                      vars->properties_name[num_prop],
1851
 
                                      "postprocessing_recording",
1852
 
                                      &ichrvr[ipp - 1]);
1853
 
 
1854
 
  /* Listing output frequency */
1855
 
  cs_gui_model_property_output_status(model,
1856
 
                                      vars->properties_name[num_prop],
1857
 
                                      "listing_printing",
1858
 
                                      &ilisvr[ipp - 1]);
1859
 
 
1860
 
 
1861
 
  /* Activated probes */
1862
 
  nb_probes = cs_gui_model_property_number_probes(model,
1863
 
                                                  vars->properties_name[num_prop]);
1864
 
 
1865
 
  ihisvr[0 + (ipp - 1)] = nb_probes;
1866
 
 
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],
1871
 
                                                   iprob+1);
1872
 
      ihisvr[(iprob+1)*(*nvppmx) + (ipp - 1)] = num_probe;
1873
 
    }
1874
 
  }
1875
 
 
1876
 
  /* Take into account labels */
1877
 
 
1878
 
  varname = cs_gui_get_model_property_label(model, vars->properties_name[num_prop]);
1879
 
  _gui_copy_varname(varname, ipp);
1880
 
 
1881
 
  BFT_FREE(varname);
1882
 
}
1883
 
 
1884
 
/*-----------------------------------------------------------------------------
1885
 
 * Return number of probes for property
1886
 
 *
1887
 
 * parameters:
1888
 
 *   property_name  --> name of property
1889
 
 *----------------------------------------------------------------------------*/
1890
 
 
1891
 
static int cs_gui_properties_number_probes(const char *const property_name)
1892
 
{
1893
 
  char *path = NULL;
1894
 
  char *choice = NULL;
1895
 
  int   nb_probes ;
1896
 
 
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);
1903
 
 
1904
 
  if (choice) {
1905
 
    nb_probes = atoi(choice);
1906
 
    BFT_FREE(choice);
1907
 
  } else
1908
 
    nb_probes = -1;
1909
 
 
1910
 
  BFT_FREE(path);
1911
 
 
1912
 
  return nb_probes;
1913
 
}
1914
 
 
1915
 
/*-----------------------------------------------------------------------------
1916
 
 * Return probe number for sub balise "probe_recording" for properties
1917
 
 *
1918
 
 * parameters:
1919
 
 *   property_name   --> name of property
1920
 
 *   num_probe       --> number of balise "probe_recording"
1921
 
 *----------------------------------------------------------------------------*/
1922
 
 
1923
 
static int cs_gui_properties_probe_name(const char *const property_name,
1924
 
                                        const int         num_probe)
1925
 
{
1926
 
  char *path = NULL;
1927
 
  char *strvalue = NULL;
1928
 
  int   value;
1929
 
 
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");
1936
 
 
1937
 
  strvalue = cs_gui_get_attribute_value(path);
1938
 
 
1939
 
  if (strvalue == NULL)
1940
 
    bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
1941
 
 
1942
 
  value = atoi(strvalue);
1943
 
 
1944
 
  BFT_FREE(path);
1945
 
  BFT_FREE(strvalue);
1946
 
 
1947
 
  return value;
1948
 
}
1949
 
 
1950
 
/*-----------------------------------------------------------------------------
1951
 
 * Return the label attribute of a property markup.
1952
 
 *
1953
 
 * parameters:
1954
 
 *   property_name        -->  name of the property
1955
 
 *----------------------------------------------------------------------------*/
1956
 
 
1957
 
static char *cs_gui_properties_label(const char *const property_name)
1958
 
{
1959
 
  char *path = NULL;
1960
 
  char *label = NULL;
1961
 
 
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");
1966
 
 
1967
 
  label = cs_gui_get_attribute_value(path);
1968
 
 
1969
 
  BFT_FREE(path);
1970
 
 
1971
 
  return label;
1972
 
}
1973
 
 
1974
 
/*-----------------------------------------------------------------------------
1975
 
 * Return status of thr property markup
1976
 
 *
1977
 
 * parameters:
1978
 
 *   property_name  --> name of property
1979
 
 *   value_type     --> type of balise (listing_printing, postprocessing ..)
1980
 
 *   keyword        <-- number of balise "probe_recording"
1981
 
 *----------------------------------------------------------------------------*/
1982
 
 
1983
 
static void cs_gui_properties_status(const char *const property_name,
1984
 
                                     const char *const value_type,
1985
 
                                     int        *const keyword)
1986
 
{
1987
 
  char *path = NULL;
1988
 
  int   result;
1989
 
 
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");
1995
 
 
1996
 
  if (cs_gui_get_status(path, &result))
1997
 
    *keyword = result;
1998
 
  else
1999
 
    *keyword = 1;
2000
 
 
2001
 
  BFT_FREE(path);
2002
 
}
2003
 
 
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
 
 *----------------------------------------------------------------------------*/
2012
 
 
2013
 
 
2014
 
static void cs_gui_properties_post(const char *const property_name,
2015
 
                                   const int         ipp,
2016
 
                                         int  *const ichrvr,
2017
 
                                         int  *const ilisvr,
2018
 
                                         int  *const ihisvr,
2019
 
                                   const int  *const nvppmx)
2020
 
{
2021
 
  int nb_probes;
2022
 
  int iprob;
2023
 
  char *varname = NULL;
2024
 
  int num_probe;
2025
 
 
2026
 
  if (ipp == 1) return;
2027
 
 
2028
 
  varname = cs_gui_properties_label(property_name);
2029
 
  if (varname == NULL) return;
2030
 
 
2031
 
  _gui_copy_varname(varname, ipp);
2032
 
  BFT_FREE(varname);
2033
 
 
2034
 
  cs_gui_properties_status(property_name,
2035
 
                           "postprocessing_recording",
2036
 
                           &ichrvr[ipp - 1]);
2037
 
 
2038
 
  cs_gui_properties_status(property_name,
2039
 
                           "listing_printing",
2040
 
                           &ilisvr[ipp - 1]);
2041
 
 
2042
 
  nb_probes = cs_gui_properties_number_probes(property_name);
2043
 
 
2044
 
  ihisvr[0 + (ipp - 1)] = nb_probes;
2045
 
 
2046
 
  if (nb_probes > 0) {
2047
 
    for (iprob =0; iprob < nb_probes; iprob++){
2048
 
      num_probe = cs_gui_properties_probe_name(property_name,
2049
 
                                               iprob+1);
2050
 
 
2051
 
      ihisvr[(iprob+1)*(*nvppmx) + (ipp - 1)] = num_probe;
2052
 
    }
2053
 
  }
2054
 
 
2055
 
}
2056
 
 
2057
 
/*-----------------------------------------------------------------------------
2058
 
 * Return number of probes for time average of property
2059
 
 *
2060
 
 * parameters:
2061
 
 *   property_name -->  label of property
2062
 
 *----------------------------------------------------------------------------*/
2063
 
 
2064
 
static int cs_gui_time_average_number_probes(const char *const property_name)
2065
 
{
2066
 
  char *path = NULL;
2067
 
  char *choice = NULL;
2068
 
  int   nb_probes ;
2069
 
 
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);
2076
 
 
2077
 
  if (choice) {
2078
 
    nb_probes = atoi(choice);
2079
 
    BFT_FREE(choice);
2080
 
  } else
2081
 
    nb_probes = -1;
2082
 
 
2083
 
  BFT_FREE(path);
2084
 
 
2085
 
  return nb_probes;
2086
 
}
2087
 
 
2088
 
/*-----------------------------------------------------------------------------
2089
 
 * Return probe number for sub balise "probe_recording" for time average of
2090
 
 * properties
2091
 
 *
2092
 
 * parameters:
2093
 
 *   property_name    --> label of property
2094
 
 *   num_probe        --> number of balise "probe_recording"
2095
 
 *----------------------------------------------------------------------------*/
2096
 
 
2097
 
static int cs_gui_time_average_probe_name(const char *const property_name,
2098
 
                                          const int         num_probe)
2099
 
{
2100
 
  char *path = NULL;
2101
 
  char *strvalue = NULL;
2102
 
  int   value;
2103
 
 
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");
2110
 
 
2111
 
  strvalue = cs_gui_get_attribute_value(path);
2112
 
 
2113
 
  if (strvalue == NULL)
2114
 
    bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
2115
 
 
2116
 
  value = atoi(strvalue);
2117
 
 
2118
 
  BFT_FREE(path);
2119
 
  BFT_FREE(strvalue);
2120
 
 
2121
 
  return value;
2122
 
}
2123
 
 
2124
 
/*-----------------------------------------------------------------------------
2125
 
 * Return status of time average markup
2126
 
 *
2127
 
 * parameters:
2128
 
 *   property_name  --> label of property
2129
 
 *   value_type     --> type of balise (listing_printing, postprocessing ..)
2130
 
 *   keyword        <-- number of balise "probe_recording"
2131
 
 *----------------------------------------------------------------------------*/
2132
 
 
2133
 
 
2134
 
static void cs_gui_time_average_status(const char *const property_name,
2135
 
                                       const char *const value_type,
2136
 
                                             int  *const keyword)
2137
 
{
2138
 
  char *path = NULL;
2139
 
  int   result;
2140
 
 
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");
2146
 
 
2147
 
  if (cs_gui_get_status(path, &result))
2148
 
    *keyword = result;
2149
 
  else
2150
 
    *keyword = 1;
2151
 
 
2152
 
  BFT_FREE(path);
2153
 
}
2154
 
 
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
 
 *----------------------------------------------------------------------------*/
2163
 
 
2164
 
static void cs_gui_time_average_post (const char *const property_name,
2165
 
                               const int         ipp,
2166
 
                                     int  *const ichrvr,
2167
 
                                     int  *const ilisvr,
2168
 
                                     int  *const ihisvr,
2169
 
                               const int  *const nvppmx)
2170
 
{
2171
 
  int nb_probes;
2172
 
  int iprob;
2173
 
  int num_probe;
2174
 
 
2175
 
  if (ipp == 1) return;
2176
 
 
2177
 
  cs_gui_time_average_status(property_name,
2178
 
                             "postprocessing_recording",
2179
 
                             &ichrvr[ipp - 1]);
2180
 
 
2181
 
  cs_gui_time_average_status(property_name,
2182
 
                             "listing_printing",
2183
 
                             &ilisvr[ipp - 1]);
2184
 
 
2185
 
  nb_probes = cs_gui_time_average_number_probes(property_name);
2186
 
 
2187
 
  ihisvr[0 + (ipp - 1)] = nb_probes;
2188
 
 
2189
 
  if (nb_probes > 0) {
2190
 
    for (iprob =0; iprob < nb_probes; iprob++){
2191
 
      num_probe = cs_gui_time_average_probe_name(property_name,
2192
 
                                                 iprob+1);
2193
 
 
2194
 
      ihisvr[(iprob+1)*(*nvppmx) + (ipp - 1)] = num_probe;
2195
 
    }
2196
 
  }
2197
 
  _gui_copy_varname(property_name, ipp);
2198
 
 
2199
 
}
2200
 
 
2201
 
/*-----------------------------------------------------------------------------
2202
 
 * Return the label or the name from a scalar.
2203
 
 *
2204
 
 * parameters:
2205
 
 *   kw                   -->  keyword: 'label' or 'name'
2206
 
 *   scalar_num          <--   number of the searching scalar
2207
 
 *----------------------------------------------------------------------------*/
2208
 
 
2209
 
static char *_scalar_name_label(const char *kw, const int scalar_num)
2210
 
{
2211
 
  char *path = NULL;
2212
 
  char *str  = NULL;
2213
 
 
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);
2218
 
 
2219
 
  str = cs_gui_get_attribute_value(path);
2220
 
 
2221
 
  BFT_FREE(path);
2222
 
 
2223
 
  return str;
2224
 
}
2225
 
 
2226
 
/*==========================
2227
 
 * FOR VOLUMICS ZONES
2228
 
 *==========================*/
2229
 
 
2230
 
/*-----------------------------------------------------------------------------
2231
 
 * Return the name of the volumic zone
2232
 
 *
2233
 
 * parameters:
2234
 
 *   ith_zone        -->  id of volumic zone
2235
 
 *----------------------------------------------------------------------------*/
2236
 
 
2237
 
static char *cs_gui_volumic_zone_label(const int ith_zone)
2238
 
{
2239
 
  char *path = NULL;
2240
 
  char *name = NULL;
2241
 
 
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");
2247
 
 
2248
 
  name = cs_gui_get_attribute_value(path);
2249
 
 
2250
 
  BFT_FREE(path);
2251
 
 
2252
 
  return name;
2253
 
}
2254
 
 
2255
 
/*-----------------------------------------------------------------------------
2256
 
 * Return the localisation for the volumic zone named label
2257
 
 *
2258
 
 * parameters:
2259
 
 *   label        -->  label of volumic zone
2260
 
 *----------------------------------------------------------------------------*/
2261
 
 
2262
 
static char *cs_gui_volumic_zone_localization(const char *const label)
2263
 
{
2264
 
  char *path = NULL;
2265
 
  char *description = NULL;
2266
 
 
2267
 
  path = cs_xpath_init_path();
2268
 
  cs_xpath_add_elements(&path, 3, "solution_domain",
2269
 
                                  "volumic_conditions",
2270
 
                                  "zone");
2271
 
  cs_xpath_add_test_attribute(&path, "label", label);
2272
 
  cs_xpath_add_function_text(&path);
2273
 
 
2274
 
  description = cs_gui_get_text_value(path);
2275
 
 
2276
 
  BFT_FREE(path);
2277
 
 
2278
 
  return description;
2279
 
}
2280
 
 
2281
 
/*-----------------------------------------------------------------------------
2282
 
 * Return the initial value of variable for the volumic zone named name
2283
 
 *
2284
 
 * parameters:
2285
 
 *   variable_name    -->  name of variable
2286
 
 *   zone_label       -->  label of volumic zone
2287
 
 *   initial_value    <--  initial value
2288
 
 *----------------------------------------------------------------------------*/
2289
 
 
2290
 
static void cs_gui_variable_initial_value(const char   *const variable_name,
2291
 
                                          const char   *const zone_label,
2292
 
                                                double *const initial_value)
2293
 
{
2294
 
  char *path = NULL;
2295
 
  double result;
2296
 
 
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);
2303
 
 
2304
 
  if (cs_gui_get_double(path, &result))
2305
 
    *initial_value = result;
2306
 
  else
2307
 
    *initial_value = 0.0;
2308
 
 
2309
 
  BFT_FREE(path);
2310
 
}
2311
 
 
2312
 
/*-----------------------------------------------------------------------------
2313
 
 * Return the initial value of scalar for the volumic zone named name
2314
 
 *
2315
 
 * parameters:
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
 
 *----------------------------------------------------------------------------*/
2321
 
 
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)
2326
 
{
2327
 
  char *path = NULL;
2328
 
  double result;
2329
 
 
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);
2336
 
 
2337
 
  if (cs_gui_get_double(path, &result))
2338
 
    *initial_value = result;
2339
 
  else
2340
 
    *initial_value = 0.0;
2341
 
 
2342
 
  BFT_FREE(path);
2343
 
}
2344
 
 
2345
 
/*----------------------------------------------------------------------------
2346
 
 * Return integer value for calculation of size of user arrays
2347
 
 *----------------------------------------------------------------------------*/
2348
 
 
2349
 
static int _user_array(const char *const keyword1,
2350
 
                       const char *const keyword2)
2351
 
{
2352
 
  char *path = NULL;
2353
 
  int value = 0;
2354
 
 
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);
2359
 
  BFT_FREE(path);
2360
 
  return value;
2361
 
}
2362
 
 
2363
 
/*----------------------------------------------------------------------------
2364
 
 * Get label of 1D profile file name
2365
 
 *
2366
 
 * parameters:
2367
 
 *   id           -->  number of order in list of 1D profile
2368
 
 *----------------------------------------------------------------------------*/
2369
 
 
2370
 
static char *_get_profile(const char *kw, const int id)
2371
 
{
2372
 
  char *path = NULL;
2373
 
  char *label = NULL;
2374
 
 
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);
2379
 
 
2380
 
  label = cs_gui_get_attribute_value(path);
2381
 
 
2382
 
  BFT_FREE(path);
2383
 
 
2384
 
  return label;
2385
 
}
2386
 
 
2387
 
/*----------------------------------------------------------------------------
2388
 
 * Get number of variables or properties or scalar for 1D profile
2389
 
 *
2390
 
 * parameters:
2391
 
 *   id           -->  number of 1D profile
2392
 
 *----------------------------------------------------------------------------*/
2393
 
 
2394
 
static int _get_profile_names_number(const int id)
2395
 
{
2396
 
  char *path = NULL;
2397
 
  int   number = 0;
2398
 
 
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);
2404
 
 
2405
 
  BFT_FREE(path);
2406
 
 
2407
 
  return number;
2408
 
}
2409
 
 
2410
 
/*----------------------------------------------------------------------------
2411
 
 * Return the name of variables or properties or scalar for 1D profile
2412
 
 *
2413
 
 * parameters:
2414
 
 *   id           -->  number of 1D profile
2415
 
 *   nm           -->  number of the variable name of the idst 1D profile
2416
 
 *----------------------------------------------------------------------------*/
2417
 
 
2418
 
static char *_get_profile_name(const int id, const int nm)
2419
 
{
2420
 
  char *path = NULL;
2421
 
  char *name = NULL;
2422
 
 
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");
2428
 
 
2429
 
  name = cs_gui_get_attribute_value(path);
2430
 
  if (name == NULL)
2431
 
    bft_error(__FILE__, __LINE__, 0,
2432
 
              _("Invalid xpath: %s\n name not found"), path);
2433
 
  BFT_FREE(path);
2434
 
 
2435
 
  return name;
2436
 
}
2437
 
 
2438
 
/*----------------------------------------------------------------------------
2439
 
 * Return the label of variables or properties or scalar for 1D profile
2440
 
 *
2441
 
 * parameters:
2442
 
 *   id           -->  number of 1D profile
2443
 
 *   nm           -->  number of the variable name of the idst 1D profile
2444
 
 *----------------------------------------------------------------------------*/
2445
 
 
2446
 
static char *_get_profile_label_name(const int id, const int nm)
2447
 
{
2448
 
  char *path = NULL;
2449
 
  char *name = NULL;
2450
 
  char *label = NULL;
2451
 
  int j, shift;
2452
 
 
2453
 
  cs_var_t  *vars = cs_glob_var;
2454
 
  name = _get_profile_name(id, nm);
2455
 
  shift = vars->nvar - vars->nscapp - vars->nscaus;
2456
 
 
2457
 
  for (j=0 ; j < shift ; j++) {
2458
 
    if (cs_gui_strcmp(name,  vars->name[j]))
2459
 
      label = cs_gui_variable_label(name);
2460
 
  }
2461
 
 
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]);
2466
 
    }
2467
 
  }
2468
 
 
2469
 
  for (j=0; j < vars->nprop; j++) {
2470
 
    if (cs_gui_strcmp(name, vars->properties_name[j])) {
2471
 
      if (label != NULL)
2472
 
        BFT_FREE(label);
2473
 
      label = cs_gui_properties_label(vars->properties_name[j]);
2474
 
    }
2475
 
  }
2476
 
 
2477
 
  if (label == NULL)
2478
 
    bft_error(__FILE__, __LINE__, 0,
2479
 
              _("Invalid markup name: %s\n label not found"), name);
2480
 
 
2481
 
  BFT_FREE(path);
2482
 
  BFT_FREE(name);
2483
 
 
2484
 
  return label;
2485
 
}
2486
 
 
2487
 
/*----------------------------------------------------------------------------
2488
 
 * Get coordinates or output frequency for 1D profile
2489
 
 *
2490
 
 * parameters:
2491
 
 *   id           -->  number of 1D profile
2492
 
 *    x          <--   name of the coordinate (x1, y1, z1, x2, y2, z2)
2493
 
 *                     or the output frequency
2494
 
 *----------------------------------------------------------------------------*/
2495
 
 
2496
 
static double _get_profile_coordinate(const int id, const char *const x)
2497
 
{
2498
 
  char *path = NULL;
2499
 
  double coordinate = 0.0;
2500
 
 
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);
2506
 
 
2507
 
  if (!cs_gui_get_double(path, &coordinate))
2508
 
    bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
2509
 
 
2510
 
  BFT_FREE(path);
2511
 
 
2512
 
  return coordinate;
2513
 
}
2514
 
 
2515
 
/*============================================================================
2516
 
 * Public Fortran function definitions
2517
 
 *============================================================================*/
2518
 
 
2519
 
/*----------------------------------------------------------------------------
2520
 
 * Initialise the global 'vars' structure.
2521
 
 *
2522
 
 * Fortran Interface:
2523
 
 *
2524
 
 * subroutine uiinit
2525
 
 * *****************
2526
 
 *----------------------------------------------------------------------------*/
2527
 
 
2528
 
void CS_PROCF (uiinit, UIINIT) (void)
2529
 
{
2530
 
    assert(cs_glob_var == NULL);
2531
 
 
2532
 
    BFT_MALLOC(cs_glob_var, 1, cs_var_t);
2533
 
 
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;
2550
 
 
2551
 
    BFT_MALLOC(cs_glob_label, 1, cs_label_t);
2552
 
 
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;
2556
 
}
2557
 
 
2558
 
/*----------------------------------------------------------------------------
2559
 
 * Turbulence model.
2560
 
 *
2561
 
 * Fortran Interface:
2562
 
 *
2563
 
 * SUBROUTINE CSTURB (ITURB, IDEUCH, IGRAKE, IGRAKI, XLOMLG)
2564
 
 * *****************
2565
 
 *
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
 
 *----------------------------------------------------------------------------*/
2572
 
 
2573
 
 
2574
 
void CS_PROCF (csturb, CSTURB) (int    *const iturb,
2575
 
                                int    *const ideuch,
2576
 
                                int    *const igrake,
2577
 
                                int    *const igrari,
2578
 
                                double *const xlomlg)
2579
 
{
2580
 
  char *model = NULL;
2581
 
  int iphas = 0;
2582
 
 
2583
 
  model = cs_gui_get_thermophysical_model("turbulence");
2584
 
  if (model == NULL) return;
2585
 
 
2586
 
  if (cs_gui_strcmp(model, "off"))
2587
 
     iturb[iphas] = 0;
2588
 
  else if (cs_gui_strcmp(model, "mixing_length")){
2589
 
     iturb[iphas] = 10;
2590
 
     _option_turbulence_double("mixing_length_scale", &xlomlg[iphas]);
2591
 
   }
2592
 
  else if (cs_gui_strcmp(model, "k-epsilon")){
2593
 
     iturb[iphas] = 20;
2594
 
     cs_gui_advanced_options_turbulence("scale_model", &ideuch[iphas]);
2595
 
     cs_gui_advanced_options_turbulence("gravity_terms", &igrake[iphas]);
2596
 
   }
2597
 
  else if (cs_gui_strcmp(model, "k-epsilon-PL")){
2598
 
     iturb[iphas] = 21;
2599
 
     cs_gui_advanced_options_turbulence("scale_model", &ideuch[iphas]);
2600
 
     cs_gui_advanced_options_turbulence("gravity_terms", &igrake[iphas]);
2601
 
   }
2602
 
  else if (cs_gui_strcmp(model, "Rij-epsilon")){
2603
 
     iturb[iphas] = 30;
2604
 
     cs_gui_advanced_options_turbulence("scale_model", &ideuch[iphas]);
2605
 
     cs_gui_advanced_options_turbulence("gravity_terms", &igrari[iphas]);
2606
 
   }
2607
 
  else if (cs_gui_strcmp(model, "Rij-SSG")){
2608
 
     iturb[iphas] = 31;
2609
 
     cs_gui_advanced_options_turbulence("scale_model", &ideuch[iphas]);
2610
 
     cs_gui_advanced_options_turbulence("gravity_terms", &igrari[iphas]);
2611
 
   }
2612
 
  else if (cs_gui_strcmp(model, "LES_Smagorinsky")){
2613
 
     iturb[iphas] = 40;
2614
 
   }
2615
 
  else if (cs_gui_strcmp(model, "LES_dynamique")){
2616
 
     iturb[iphas] = 41;
2617
 
   }
2618
 
  else if (cs_gui_strcmp(model, "LES_WALE")){
2619
 
     iturb[iphas] = 42;
2620
 
   }
2621
 
  else if (cs_gui_strcmp(model, "v2f-phi")){
2622
 
     iturb[iphas] = 50;
2623
 
     cs_gui_advanced_options_turbulence("scale_model", &ideuch[iphas]);
2624
 
     cs_gui_advanced_options_turbulence("gravity_terms", &igrake[iphas]);
2625
 
   }
2626
 
  else if (cs_gui_strcmp(model, "k-omega-SST")){
2627
 
     iturb[iphas] = 60;
2628
 
     cs_gui_advanced_options_turbulence("scale_model", &ideuch[iphas]);
2629
 
     cs_gui_advanced_options_turbulence("gravity_terms", &igrake[iphas]);
2630
 
   }
2631
 
  else
2632
 
     bft_error(__FILE__, __LINE__, 0,
2633
 
               _("Invalid turbulence model: %s.\n"), model);
2634
 
 
2635
 
#if _XML_DEBUG_
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]);
2643
 
#endif
2644
 
 
2645
 
  BFT_FREE(model);
2646
 
}
2647
 
 
2648
 
/*----------------------------------------------------------------------------
2649
 
 * Specific heat variable or constant indicator.
2650
 
 *
2651
 
 * Fortran Interface:
2652
 
 *
2653
 
 * SUBROUTINE CSCPVA (ICP)
2654
 
 * *****************
2655
 
 *
2656
 
 * INTEGER          ICP     <--   specific heat variable or constant indicator
2657
 
 *----------------------------------------------------------------------------*/
2658
 
 
2659
 
void CS_PROCF (cscpva, CSCPVA) (int *const icp)
2660
 
{
2661
 
  int choice;
2662
 
  int iphas = 0;
2663
 
 
2664
 
  if (cs_gui_properties_choice("specific_heat", &choice)) icp[iphas] = choice;
2665
 
 
2666
 
#if _XML_DEBUG_
2667
 
  bft_printf("==>CSCPVA\n");
2668
 
  bft_printf("--icp = %i\n", icp[iphas]);
2669
 
#endif
2670
 
}
2671
 
 
2672
 
/*----------------------------------------------------------------------------
2673
 
 * User scalars number.
2674
 
 *
2675
 
 * Fortran Interface:
2676
 
 *
2677
 
 * SUBROUTINE CSNSCA (NSCAUS)
2678
 
 * *****************
2679
 
 *
2680
 
 * INTEGER          NSCAUS     <--   user scalars number
2681
 
 *----------------------------------------------------------------------------*/
2682
 
 
2683
 
void CS_PROCF (csnsca, CSNSCA) (int *const nscaus)
2684
 
{
2685
 
  int   i     = 0;
2686
 
  char *label = NULL;
2687
 
 
2688
 
  cs_var_t *vars = cs_glob_var;
2689
 
 
2690
 
  *nscaus = cs_gui_get_tag_number("/additional_scalars/scalar", 1);
2691
 
 
2692
 
  cs_glob_var->nscaus = *nscaus;
2693
 
 
2694
 
  BFT_MALLOC(vars->label, *nscaus, char*);
2695
 
 
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);
2700
 
    BFT_FREE(label);
2701
 
  }
2702
 
 
2703
 
#if _XML_DEBUG_
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]);
2708
 
#endif
2709
 
}
2710
 
 
2711
 
/*----------------------------------------------------------------------------
2712
 
 * User scalars which are variance.
2713
 
 *
2714
 
 * Fortran Interface:
2715
 
 *
2716
 
 * SUBROUTINE CSISCA (ISCAVR)
2717
 
 * *****************
2718
 
 *
2719
 
 * INTEGER          ISCAVR     <--   user scalars variance array
2720
 
 *----------------------------------------------------------------------------*/
2721
 
 
2722
 
void CS_PROCF (csisca, CSISCA) (int *const iscavr)
2723
 
{
2724
 
  int i;
2725
 
  int j;
2726
 
  char *variance = NULL;
2727
 
 
2728
 
  cs_var_t  *vars = cs_glob_var;
2729
 
 
2730
 
  if (vars->nscaus > 0) {
2731
 
 
2732
 
    for (i=0; i < vars->nscaus; i++) {
2733
 
      variance = cs_gui_scalar_variance(i+1);
2734
 
 
2735
 
      if (variance != NULL) {
2736
 
 
2737
 
        for (j=0 ; j < vars->nscaus ; j++) {
2738
 
 
2739
 
          if (cs_gui_strcmp(variance, vars->label[j])) {
2740
 
 
2741
 
            if ( i == j )
2742
 
              bft_error(__FILE__, __LINE__, 0,
2743
 
                 _("Scalar: %i and its variance: %i are the same.\n"),
2744
 
                 i, j);
2745
 
            iscavr[i] = j + 1;
2746
 
          }
2747
 
        }
2748
 
        BFT_FREE(variance);
2749
 
      }
2750
 
    }
2751
 
 
2752
 
#if _XML_DEBUG_
2753
 
    bft_printf("==>CSISCA\n");
2754
 
    for (i = 0 ; i < vars->nscaus ; i++)
2755
 
      bft_printf("--iscavr[%i] = %i \n", i, iscavr[i]);
2756
 
#endif
2757
 
  }
2758
 
  return;
2759
 
}
2760
 
 
2761
 
/*----------------------------------------------------------------------------
2762
 
 * Constant or variable indicator for the user scalar laminar viscosity.
2763
 
 *
2764
 
 * Fortran Interface:
2765
 
 *
2766
 
 * SUBROUTINE CSIVIS (ISCAVR, IVISLS, ISCALT, ISCSTH)
2767
 
 * *****************
2768
 
 *
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
 
 *----------------------------------------------------------------------------*/
2774
 
 
2775
 
void CS_PROCF (csivis, CSIVIS) (int *const iscavr,
2776
 
                                int *const ivisls,
2777
 
                                int *const iscalt,
2778
 
                                int *const iscsth)
2779
 
{
2780
 
  int iphas = 0;
2781
 
  int i;
2782
 
  int choice1, choice2;
2783
 
  int test1, test2;
2784
 
 
2785
 
  cs_var_t  *vars = cs_glob_var;
2786
 
 
2787
 
  if (vars->nscaus > 0) {
2788
 
 
2789
 
    if (cs_gui_thermal_scalar()) {
2790
 
      test1 = cs_gui_properties_choice("thermal_conductivity", &choice1);
2791
 
      test2 = cs_gui_properties_choice("specific_heat", &choice2);
2792
 
 
2793
 
      if (test1 && test2) {
2794
 
        cs_gui_thermal_scalar_number(iscalt, iscsth);
2795
 
 
2796
 
        if (choice1 || choice2)
2797
 
          ivisls[iscalt[iphas]-1] = 1;
2798
 
        else
2799
 
          ivisls[iscalt[iphas]-1] = 0;
2800
 
      }
2801
 
    }
2802
 
 
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;
2807
 
      }
2808
 
    }
2809
 
 
2810
 
#if _XML_DEBUG_
2811
 
    bft_printf("==>CSIVIS\n");
2812
 
    for (i=0 ; i < vars->nscaus ; i++)
2813
 
      bft_printf("--ivisls[%i] = %i\n", i, ivisls[i]);
2814
 
#endif
2815
 
    }
2816
 
}
2817
 
 
2818
 
/*----------------------------------------------------------------------------
2819
 
 * Time passing parameter.
2820
 
 *
2821
 
 * Fortran Interface:
2822
 
 *
2823
 
 * SUBROUTINE CSIDTV (IDTVAR)
2824
 
 * *****************
2825
 
 *
2826
 
 * INTEGER          IDTVAR  <--   fixed or variable time step
2827
 
 *----------------------------------------------------------------------------*/
2828
 
 
2829
 
void CS_PROCF (csidtv, CSIDTV) (int *const idtvar)
2830
 
{
2831
 
  double param;
2832
 
  int steady = 0;
2833
 
 
2834
 
  cs_gui_get_steady_status(&steady);
2835
 
  if (steady){
2836
 
    *idtvar = -1;
2837
 
  }
2838
 
  else{
2839
 
    param = (double) *idtvar;
2840
 
    cs_gui_time_parameters("time_passing", &param);
2841
 
    *idtvar = (int) param;
2842
 
  }
2843
 
 
2844
 
#if _XML_DEBUG_
2845
 
  bft_printf("==>CSIDTV\n");
2846
 
  bft_printf("--idtvar = %i\n", *idtvar);
2847
 
#endif
2848
 
}
2849
 
 
2850
 
/*----------------------------------------------------------------------------
2851
 
 * Hydrostatic pressure parameter.
2852
 
 *
2853
 
 * Fortran Interface:
2854
 
 *
2855
 
 * SUBROUTINE CSIPHY (IPHYDR)
2856
 
 * *****************
2857
 
 *
2858
 
 * INTEGER          IPHYDR  <--   hydrostatic pressure
2859
 
 *----------------------------------------------------------------------------*/
2860
 
 
2861
 
void CS_PROCF (csiphy, CSIPHY) (int *const iphydr)
2862
 
{
2863
 
  char *path = NULL;
2864
 
  int   result;
2865
 
 
2866
 
  path = cs_xpath_short_path();
2867
 
  cs_xpath_add_element(&path, "hydrostatic_pressure");
2868
 
  cs_xpath_add_attribute(&path, "status");
2869
 
 
2870
 
  if (cs_gui_get_status(path, &result)) *iphydr = result;
2871
 
 
2872
 
  BFT_FREE(path);
2873
 
 
2874
 
#if _XML_DEBUG_
2875
 
  bft_printf("==>CSIPHY\n");
2876
 
  bft_printf("--iphydr = %i\n", *iphydr);
2877
 
#endif
2878
 
}
2879
 
 
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).
2886
 
 *
2887
 
 * Fortran Interface:
2888
 
 *
2889
 
 * SUBROUTINE CSVNUM
2890
 
 * *****************
2891
 
 *
2892
 
 * INTEGER          IPHYDR  <--   hydrostatic pressure
2893
 
 *----------------------------------------------------------------------------*/
2894
 
 
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)
2918
 
{
2919
 
  int iphas = 0;
2920
 
  int n = 0;
2921
 
  int i, j, k;
2922
 
  char *name = NULL;
2923
 
 
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*);
2928
 
 
2929
 
  /* Warning!!  for scalars: vars->nscaus is already fill in CSNSCA */
2930
 
  /*                         vars->nscapp is already fill in UIPPMO */
2931
 
 
2932
 
  cs_glob_var->nvar   = *nvar;
2933
 
 
2934
 
  /* 1) pressure and velocity variables */
2935
 
 
2936
 
  k = n;
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");
2940
 
 
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");
2944
 
 
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");
2948
 
 
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");
2952
 
 
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");
2956
 
  }
2957
 
 
2958
 
  /* 2) turbulence variables */
2959
 
 
2960
 
  k = n;
2961
 
 
2962
 
  if (iturb[iphas] == 20 || iturb[iphas] == 21) {
2963
 
 
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");
2967
 
 
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");
2971
 
 
2972
 
  } else if (iturb[iphas] == 30 || iturb[iphas] == 31) {
2973
 
 
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");
2977
 
 
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");
2981
 
 
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");
2985
 
 
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");
2989
 
 
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");
2993
 
 
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");
2997
 
 
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");
3001
 
 
3002
 
  } else if (iturb[iphas] == 50) {
3003
 
 
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");
3007
 
 
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");
3011
 
 
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");
3015
 
 
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");
3019
 
 
3020
 
  } else if (iturb[iphas] == 60) {
3021
 
 
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");
3025
 
 
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");
3029
 
  }
3030
 
 
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");
3034
 
  }
3035
 
 
3036
 
  /* 3) ALE variables */
3037
 
 
3038
 
  if (*iale) {
3039
 
    k = n;
3040
 
 
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");
3044
 
 
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");
3048
 
 
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");
3052
 
 
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");
3056
 
    }
3057
 
  }
3058
 
 
3059
 
  /* 4) update vars->type for variables */
3060
 
 
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");
3065
 
  }
3066
 
 
3067
 
  /* 5) user scalars */
3068
 
 
3069
 
  for (i=0; i < cs_glob_var->nscaus; i++) {
3070
 
    cs_glob_var->rtp[n++] = isca[i] -1;
3071
 
 
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);
3075
 
    BFT_FREE(name);
3076
 
 
3077
 
    BFT_MALLOC(cs_glob_var->type[k+i], strlen("scalar")+1, char);
3078
 
    strcpy(cs_glob_var->type[k+i], "scalar");
3079
 
 
3080
 
    BFT_MALLOC(cs_glob_var->head[k+i], strlen("additional_scalar")+1, char);
3081
 
    strcpy(cs_glob_var->head[k+i], "additional_scalar");
3082
 
  }
3083
 
 
3084
 
  /* 6) model scalars */
3085
 
 
3086
 
  k = cs_glob_var->nvar -cs_glob_var->nscaus - cs_glob_var->nscapp;
3087
 
  for (i=0; i < cs_glob_var->nscapp; i++) {
3088
 
    j = iscapp[i] -1;
3089
 
    cs_glob_var->rtp[n++] = isca[j] -1;
3090
 
 
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]);
3093
 
 
3094
 
    BFT_MALLOC(cs_glob_var->type[k+j], strlen("scalar")+1, char);
3095
 
    strcpy(cs_glob_var->type[k+j], "scalar");
3096
 
 
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);
3099
 
  }
3100
 
 
3101
 
  /* 7) check for errors */
3102
 
 
3103
 
  if (n != *nvar)
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"),
3107
 
                *nvar, n);
3108
 
 
3109
 
#if _XML_DEBUG_
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]); */
3116
 
#endif
3117
 
 
3118
 
}
3119
 
 
3120
 
/*----------------------------------------------------------------------------
3121
 
 * Restart parameters.
3122
 
 *
3123
 
 * Fortran Interface:
3124
 
 *
3125
 
 * SUBROUTINE CSISUI (ISUITE, ILEAUX, ICCVFG)
3126
 
 * *****************
3127
 
 *
3128
 
 * INTEGER          ISUITE  <--   restart
3129
 
 * INTEGER          NTSUIT  <--   checkpoint frequency
3130
 
 * INTEGER          ILEAUX  <--   restart with auxiliary
3131
 
 * INTEGER          ICCFVG  <--   restart with frozen field
3132
 
 *----------------------------------------------------------------------------*/
3133
 
 
3134
 
void CS_PROCF (csisui, CSISUI) (int *const isuite,
3135
 
                                int *const ntsuit,
3136
 
                                int *const ileaux,
3137
 
                                int *const iccvfg)
3138
 
{
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);
3143
 
 
3144
 
#if _XML_DEBUG_
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);
3150
 
#endif
3151
 
}
3152
 
 
3153
 
/*----------------------------------------------------------------------------
3154
 
 * Time passing parameters.
3155
 
 *
3156
 
 * Fortran Interface:
3157
 
 *
3158
 
 * SUBROUTINE CSTIME (INPDT0, IPTLTO, NTMABS, DTREF,
3159
 
 * *****************  DTMIN,  DTMAX,  COUMAX, FOUMAX, VARRDT)
3160
 
 *
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
 
 *----------------------------------------------------------------------------*/
3173
 
 
3174
 
void CS_PROCF (cstime, CSTIME) (int    *const inpdt0,
3175
 
                                int    *const iptlro,
3176
 
                                int    *const ntmabs,
3177
 
                                int    *const idtvar,
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)
3185
 
{
3186
 
  double value;
3187
 
  /* Default values for time step factor */
3188
 
  double cdtmin = 0.1, cdtmax = 1000.;
3189
 
 
3190
 
  if (*idtvar == -1){
3191
 
    cs_gui_steady_parameters("relaxation_coefficient", relxst);
3192
 
 
3193
 
    value =(double) *inpdt0;
3194
 
    cs_gui_steady_parameters("zero_iteration", &value);
3195
 
    *inpdt0 = (int) value;
3196
 
 
3197
 
    value =(double) *ntmabs;
3198
 
    cs_gui_steady_parameters("iterations", &value);
3199
 
    *ntmabs = (int) value;
3200
 
  }
3201
 
  else{
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);
3208
 
 
3209
 
    *dtmin = cdtmin*(*dtref);
3210
 
    *dtmax = cdtmax*(*dtref);
3211
 
 
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);
3215
 
 
3216
 
    value =(double) *ntmabs;
3217
 
    cs_gui_time_parameters("iterations", &value);
3218
 
    *ntmabs = (int) value;
3219
 
 
3220
 
    value =(double) *inpdt0;
3221
 
    cs_gui_time_parameters("zero_time_step", &value);
3222
 
    *inpdt0 = (int) value;
3223
 
 
3224
 
    value =(double) *iptlro;
3225
 
    cs_gui_time_parameters("thermal_time_step", &value);
3226
 
    *iptlro = (int) value;
3227
 
  }
3228
 
 
3229
 
#if _XML_DEBUG_
3230
 
  bft_printf("==>CSTIME\n");
3231
 
  bft_printf("--idtvar = %i\n", *idtvar);
3232
 
  if (*idtvar == -1){
3233
 
    bft_printf("--inpdt0 = %i\n", *inpdt0);
3234
 
    bft_printf("--relxst = %i\n", *relxst);
3235
 
  }
3236
 
  else{
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);
3246
 
  }
3247
 
#endif
3248
 
}
3249
 
 
3250
 
/*----------------------------------------------------------------------------
3251
 
 * Check if a users thermal scalar is defined.
3252
 
 *
3253
 
 * Fortran Interface:
3254
 
 *
3255
 
 * SUBROUTINE CSSCA1 (ISCALT, ISCSTH)
3256
 
 * *****************
3257
 
 *
3258
 
 * INTEGER          ISCALT  <--   number of the user thermal scalar if any
3259
 
 * INTEGER          ISCSTH  <--   type of the user thermal scalar
3260
 
 *----------------------------------------------------------------------------*/
3261
 
 
3262
 
void CS_PROCF (cssca1, CSSCA1) (int *const iscalt,
3263
 
                                int *const iscsth)
3264
 
{
3265
 
    cs_gui_thermal_scalar_number(iscalt, iscsth);
3266
 
 
3267
 
#if _XML_DEBUG_
3268
 
    {
3269
 
        int i;
3270
 
        int iphas = 0;
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]);
3276
 
    }
3277
 
#endif
3278
 
}
3279
 
 
3280
 
/*----------------------------------------------------------------------------
3281
 
 * Treatment of local numerical aspects:
3282
 
 *     BLENCV, ISCHCV, ISSTPC, IRCFLU, CDTVAR, NITMAX, EPSILO
3283
 
 *----------------------------------------------------------------------------*/
3284
 
 
3285
 
void CS_PROCF (uinum1, UINUM1) (const    int *const isca,
3286
 
                                const    int *const iscapp,
3287
 
                                      double *const blencv,
3288
 
                                         int *const ischcv,
3289
 
                                         int *const isstpc,
3290
 
                                         int *const ircflu,
3291
 
                                      double *const cdtvar,
3292
 
                                         int *const nitmax,
3293
 
                                      double *const epsilo)
3294
 
{
3295
 
  int i, j, jj, k;
3296
 
  double tmp;
3297
 
 
3298
 
  cs_var_t  *vars = cs_glob_var;
3299
 
 
3300
 
  k = vars->nvar - vars->nscaus - vars->nscapp;
3301
 
 
3302
 
  /* 1) variables from velocity_pressure and turbulence */
3303
 
  /* 1-a) for pressure */
3304
 
     j = vars->rtp[0];
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;
3309
 
 
3310
 
  /* 1-b) for the other variables */
3311
 
  for (i=1; i < k; i++) {
3312
 
     j = vars->rtp[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]);
3321
 
  }
3322
 
 
3323
 
  /* 2) user scalars */
3324
 
 
3325
 
  if (vars->nscaus > 0 ) {
3326
 
    for (i=0 ; i < vars->nscaus; i++) {
3327
 
      j = isca[i]-1;
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]);
3337
 
    }
3338
 
  }
3339
 
 
3340
 
  /* 3) model scalars */
3341
 
 
3342
 
  if (vars->nscapp > 0 ) {
3343
 
    for (i=0 ; i < vars->nscapp ; i++) {
3344
 
      j = iscapp[i] -1;
3345
 
      jj = isca[j]-1;
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]);
3355
 
    }
3356
 
  }
3357
 
 
3358
 
#if _XML_DEBUG_
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]]);
3369
 
  }
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]);
3379
 
  }
3380
 
#endif
3381
 
}
3382
 
 
3383
 
/*----------------------------------------------------------------------------
3384
 
 * Global numerical parameters.
3385
 
 *
3386
 
 * Fortran Interface:
3387
 
 *
3388
 
 * SUBROUTINE CSNUM2 (IVISSE, RELAXP, IPUCOU, EXTRAG, IMRGRA, IMGRPR)
3389
 
 * *****************
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
 
 *----------------------------------------------------------------------------*/
3397
 
 
3398
 
void CS_PROCF (csnum2, CSNUM2)(   int *const ivisse,
3399
 
                               double *const relaxp,
3400
 
                                  int *const ipucou,
3401
 
                               double *const extrag,
3402
 
                                  int *const imrgra,
3403
 
                                  int *const imgrpr)
3404
 
{
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);
3411
 
 
3412
 
#if _XML_DEBUG_
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);
3420
 
#endif
3421
 
}
3422
 
 
3423
 
/*----------------------------------------------------------------------------
3424
 
 * Treatment of gravity and fluid physical properties
3425
 
 * Initialize reference pressure and temperature if present
3426
 
 *----------------------------------------------------------------------------*/
3427
 
 
3428
 
void CS_PROCF (csphys, CSPHYS)
3429
 
(
3430
 
 const    int *const nmodpp,
3431
 
          int *const irovar,
3432
 
          int *const ivivar,
3433
 
          int *const icorio,
3434
 
       double *const gx,
3435
 
       double *const gy,
3436
 
       double *const gz,
3437
 
       double *const omegax,
3438
 
       double *const omegay,
3439
 
       double *const omegaz,
3440
 
       double *const ro0,
3441
 
       double *const viscl0,
3442
 
       double *const cp0,
3443
 
       double *const t0,
3444
 
       double *const p0
3445
 
)
3446
 
{
3447
 
  int iphas = 0;
3448
 
  int choice;
3449
 
 
3450
 
  cs_var_t  *vars = cs_glob_var;
3451
 
 
3452
 
  cs_gui_gravity_value("gravity_x", gx);
3453
 
  cs_gui_gravity_value("gravity_y", gy);
3454
 
  cs_gui_gravity_value("gravity_z", gz);
3455
 
 
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]);
3459
 
 
3460
 
  cs_gui_reference_pressure(p0);
3461
 
 
3462
 
  /* Variable rho and viscl */
3463
 
  if (*nmodpp == 0) {
3464
 
    if (cs_gui_properties_choice("density", &choice))
3465
 
      irovar[iphas] = choice;
3466
 
 
3467
 
    if (cs_gui_properties_choice("molecular_viscosity", &choice))
3468
 
      ivivar[iphas] = choice;
3469
 
  }
3470
 
 
3471
 
  /* T0 if necessary */
3472
 
 
3473
 
  if (vars->model != NULL)
3474
 
    cs_gui_reference_temperature(vars->model, t0);
3475
 
 
3476
 
#if _XML_DEBUG_
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);
3486
 
#endif
3487
 
}
3488
 
 
3489
 
/*----------------------------------------------------------------------------
3490
 
 * User scalar min and max values for clipping.
3491
 
 *
3492
 
 * Fortran Interface:
3493
 
 *
3494
 
 * SUBROUTINE CSSCA2 (ISCAVR, SCAMIN, SCAMAX)
3495
 
 * *****************
3496
 
 *
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
 
 *----------------------------------------------------------------------------*/
3501
 
 
3502
 
void CS_PROCF (cssca2, CSSCA2) (const    int *const iscavr,
3503
 
                                      double *const scamin,
3504
 
                                      double *const scamax)
3505
 
{
3506
 
  /* Specific physics: the min max of the model scalar are not given */
3507
 
 
3508
 
  int i;
3509
 
  cs_var_t  *vars = cs_glob_var;
3510
 
 
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]);
3516
 
      }
3517
 
    }
3518
 
 
3519
 
#if _XML_DEBUG_
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]);
3524
 
    }
3525
 
#endif
3526
 
  }
3527
 
}
3528
 
 
3529
 
 
3530
 
/*----------------------------------------------------------------------------
3531
 
 * Read reference dynamic and user scalar viscosity
3532
 
 *----------------------------------------------------------------------------*/
3533
 
 
3534
 
 
3535
 
void CS_PROCF (cssca3, CSSCA3) (const    int *const iscalt,
3536
 
                                const    int *const iscavr,
3537
 
                                      double *const visls0,
3538
 
                                      double *const t0,
3539
 
                                      double *const p0)
3540
 
{
3541
 
  int i, iphas = 0;
3542
 
  double result, coeff, density;
3543
 
 
3544
 
  cs_var_t  *vars = cs_glob_var;
3545
 
 
3546
 
  if (vars->nscaus > 0) {
3547
 
 
3548
 
    if (cs_gui_thermal_scalar()) {
3549
 
      result = 0;
3550
 
      cs_gui_properties_value("specific_heat", &result);
3551
 
      if (result <= 0)
3552
 
        bft_error(__FILE__, __LINE__, 0,
3553
 
                  _("Specific heat value is zero or not found in the xml file.\n"));
3554
 
 
3555
 
      i = iscalt[iphas]-1;
3556
 
      cs_gui_properties_value("thermal_conductivity", &visls0[i]);
3557
 
      visls0[i] = visls0[i]/result;
3558
 
    }
3559
 
 
3560
 
    /* User scalar
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 */
3564
 
 
3565
 
    for (i=0 ; i < vars->nscaus; i++) {
3566
 
      if (iscavr[i] <= 0 && i != iscalt[iphas]-1) {
3567
 
 
3568
 
        if (cs_gui_strcmp(vars->model, "pulverized_coal")) {
3569
 
          /* Air molar mass */
3570
 
          result = 0.028966;
3571
 
          cs_gui_reference_mass_molar(vars->model, &result);
3572
 
          if (result <= 0)
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));
3576
 
        }
3577
 
        else
3578
 
          cs_gui_properties_value("density", &density);
3579
 
 
3580
 
        if (density <= 0)
3581
 
          bft_error(__FILE__, __LINE__, 0,
3582
 
                    _("Density value is zero or not found in the xml file.\n"));
3583
 
 
3584
 
        coeff = visls0[i] / density ;
3585
 
        cs_gui_scalar_diffusion_value(i+1, &coeff);
3586
 
        visls0[i] = coeff * density;
3587
 
      }
3588
 
    }
3589
 
#if _XML_DEBUG_
3590
 
    bft_printf("==>CSSCA3\n");
3591
 
    for (i=0 ; i < vars->nscaus; i++)
3592
 
      bft_printf("--visls0[%i] = %f\n", i, visls0[i]);
3593
 
#endif
3594
 
  }
3595
 
}
3596
 
 
3597
 
/*----------------------------------------------------------------------------
3598
 
 * Turbulence initialization parameters.
3599
 
 *
3600
 
 * Fortran Interface:
3601
 
 *
3602
 
 * SUBROUTINE CSTINI (UREF, ALMAX)
3603
 
 * *****************
3604
 
 *
3605
 
 * INTEGER          UREF   <--   reference velocity
3606
 
 * INTEGER          ALMAX  <--   reference length
3607
 
 *----------------------------------------------------------------------------*/
3608
 
 
3609
 
void CS_PROCF (cstini, CSTINI) (double *const uref,
3610
 
                                double *const almax)
3611
 
{
3612
 
  int iphas = 0;
3613
 
  char* turb_ini_choice = NULL;
3614
 
 
3615
 
  cs_gui_turbulence_initialization("reference_velocity", &uref[iphas]);
3616
 
 
3617
 
  turb_ini_choice = cs_gui_turbulence_initialization_choice();
3618
 
 
3619
 
  if (cs_gui_strcmp(turb_ini_choice, "reference_velocity_length"))
3620
 
    cs_gui_turbulence_initialization("reference_length", &almax[iphas]);
3621
 
 
3622
 
  BFT_FREE(turb_ini_choice);
3623
 
 
3624
 
#if _XML_DEBUG_
3625
 
  bft_printf("==>CSTINI\n");
3626
 
  bft_printf("--almax = %f\n", almax[iphas]);
3627
 
  bft_printf("--uref  = %f\n", uref[iphas]);
3628
 
#endif
3629
 
}
3630
 
 
3631
 
/*----------------------------------------------------------------------------
3632
 
 * Properties array used in the calculation
3633
 
 *----------------------------------------------------------------------------*/
3634
 
 
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)
3658
 
{
3659
 
  int iphas = 0;
3660
 
  int itype = 0;
3661
 
  int n;
3662
 
  int i = 0;
3663
 
  int nbp = 6;
3664
 
  char *name = NULL;
3665
 
 
3666
 
  /* Compute the new size of vars->properties_name,
3667
 
     vars->properties_ipp and vars->propce */
3668
 
 
3669
 
  if (ismago[iphas] != -1 ) nbp++;
3670
 
 
3671
 
  if (icp[iphas]>0) nbp++;
3672
 
 
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++;
3676
 
  }
3677
 
 
3678
 
  if (*iale) {
3679
 
    cs_gui_get_ale_viscosity_type(&itype);
3680
 
    if (itype == 1) {
3681
 
      nbp = nbp + 3;
3682
 
    } else {
3683
 
      nbp++;
3684
 
    }
3685
 
  }
3686
 
 
3687
 
  n = cs_glob_var->nprop;
3688
 
 
3689
 
  if (*iappel == 0) {
3690
 
 
3691
 
    cs_glob_var->nprop += nbp;
3692
 
 
3693
 
    /* Fisrt step : before the third call of VARPOS in INIUSI */
3694
 
 
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*);
3698
 
 
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");
3703
 
 
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");
3708
 
 
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");
3713
 
 
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");
3718
 
 
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");
3723
 
 
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");
3729
 
    }
3730
 
 
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");
3736
 
    }
3737
 
 
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");
3742
 
 
3743
 
    if (*iale) {
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");
3748
 
 
3749
 
      if (itype == 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");
3754
 
 
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");
3759
 
      }
3760
 
 
3761
 
    }
3762
 
 
3763
 
    /* scalar diffusivity */
3764
 
 
3765
 
    if (cs_glob_var->nscaus > 0) {
3766
 
 
3767
 
      /* search lenght of first character of scalar property's suffixe : '_' */
3768
 
      for (i=0; i < cs_glob_var->nscaus; i++) {
3769
 
 
3770
 
        if (iscavr[i] <= 0 && ivisls[i] > 0) {
3771
 
 
3772
 
          cs_glob_var->properties_ipp[n] = ipppro[ ipproc[ ivisls[i]-1 ]-1 ];
3773
 
          cs_glob_var->propce[n] = ivisls[iphas];
3774
 
 
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");
3778
 
          } else {
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);
3782
 
            BFT_FREE(name);
3783
 
          }
3784
 
        }
3785
 
      }
3786
 
    }
3787
 
 
3788
 
  } else {
3789
 
 
3790
 
    /* Second step : before the fourth call of VARPOS in INIUSI */
3791
 
 
3792
 
    if (*idtvar == 1 || *idtvar == 2)
3793
 
        cs_glob_var->nprop += 1;
3794
 
    if (*ipucou == 1)
3795
 
        cs_glob_var->nprop += 3;
3796
 
    cs_glob_var->nprop += cs_glob_var->ntimaver;
3797
 
 
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*);
3801
 
 
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");
3807
 
    }
3808
 
 
3809
 
    if (*ipucou == 1) {
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");
3814
 
 
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");
3819
 
 
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");
3824
 
    }
3825
 
 
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);
3832
 
      BFT_FREE(name);
3833
 
    }
3834
 
  }
3835
 
 
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);
3840
 
 
3841
 
#if _XML_DEBUG_
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]);
3850
 
  }
3851
 
#endif
3852
 
}
3853
 
 
3854
 
/*----------------------------------------------------------------------------
3855
 
 * Temporal averaging treatment
3856
 
 *----------------------------------------------------------------------------*/
3857
 
 
3858
 
void CS_PROCF (uimoyt, UIMOYT) (const int *const ndgmox,
3859
 
                                      int *const ntdmom,
3860
 
                                      int *const imoold,
3861
 
                                      int *const idfmom)
3862
 
{
3863
 
  int imom = 0;
3864
 
  int isuite = 0;
3865
 
  int i, j, n;
3866
 
  char *name = NULL;
3867
 
 
3868
 
  cs_glob_var->ntimaver
3869
 
    = cs_gui_get_tag_number("/analysis_control/time_averages/time_average", 1);
3870
 
 
3871
 
  /* for each average */
3872
 
  for (i=0; i < cs_glob_var->ntimaver; i++) {
3873
 
 
3874
 
    imom = i + 1;
3875
 
 
3876
 
    _get_time_average_data(imom, "time_step_start", &ntdmom[i]);
3877
 
 
3878
 
    /* test on isuite */
3879
 
    cs_gui_restart_parameters_status("restart", &isuite);
3880
 
 
3881
 
    if (isuite != 0) {
3882
 
      _get_time_average_data(imom, "restart_from_time_average", &imoold[i]);
3883
 
      if (imoold[i] == imom) imoold[i] = -2;
3884
 
    }
3885
 
 
3886
 
    for (n=0; n < _get_time_average_n_variables(imom); n++) {
3887
 
 
3888
 
      name = _get_time_average_variable_name(imom, n + 1);
3889
 
 
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;
3893
 
        }
3894
 
      }
3895
 
 
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]);
3899
 
      }
3900
 
 
3901
 
      BFT_FREE(name);
3902
 
    }
3903
 
  }
3904
 
#if _XML_DEBUG_
3905
 
  bft_printf("==>UIMOYT\n");
3906
 
  for (i=0; i < cs_glob_var->ntimaver; i++) {
3907
 
    bft_printf("-->ntdmom =  %i\n", ntdmom[i]);
3908
 
  }
3909
 
#endif
3910
 
}
3911
 
 
3912
 
/*----------------------------------------------------------------------------
3913
 
 * Input/output treatment
3914
 
 *----------------------------------------------------------------------------*/
3915
 
 
3916
 
void CS_PROCF (csenso, CSENSO)
3917
 
(
3918
 
 const    int *const nvppmx,
3919
 
          int *const ncapt,
3920
 
          int *const nthist,
3921
 
          int *const ntlist,
3922
 
          int *const ichrvl,
3923
 
          int *const ichrbo,
3924
 
          int *const ichrsy,
3925
 
          int *const ichrmd,
3926
 
         char *const fmtchr,
3927
 
          int *const size_fmt,
3928
 
         char *const optchr,
3929
 
          int *const size_opt,
3930
 
          int *const ntchr,
3931
 
          int *const iecaux,
3932
 
          int *const ipstdv,
3933
 
          int *const ipstyp,
3934
 
          int *const ipstcl,
3935
 
          int *const ipstft,
3936
 
          int *const ipstfo,
3937
 
          int *const ichrvr,
3938
 
          int *const ilisvr,
3939
 
          int *const ihisvr,
3940
 
 const    int *const isca,
3941
 
 const    int *const iscapp,
3942
 
 const    int *const ipprtp,
3943
 
       double *const xyzcap)
3944
 
{
3945
 
  int i, j;
3946
 
  int ipp;
3947
 
 
3948
 
  cs_var_t  *vars = cs_glob_var;
3949
 
 
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);
3960
 
 
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);
3966
 
 
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");
3972
 
  }
3973
 
 
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],
3978
 
                                ipp,
3979
 
                                ihisvr, ilisvr, ichrvr,
3980
 
                                nvppmx);
3981
 
  }
3982
 
 
3983
 
  /* User scalar */
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);
3988
 
    }
3989
 
  }
3990
 
 
3991
 
  /* Specific physics scalars */
3992
 
  if (vars->nscapp > 0) {
3993
 
    for (i=0 ; i < vars->nscapp; i++) {
3994
 
      j = iscapp[i]-1 ;
3995
 
      cs_gui_model_scalar_post(vars->model, j,
3996
 
                               ihisvr, ilisvr, ichrvr,
3997
 
                               ipprtp, isca, nvppmx);
3998
 
    }
3999
 
  }
4000
 
 
4001
 
  /* Physical properties */
4002
 
 
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);
4007
 
    }
4008
 
  }
4009
 
 
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],
4014
 
                               ichrvr,
4015
 
                               ilisvr,
4016
 
                               ihisvr,
4017
 
                               nvppmx);
4018
 
    }
4019
 
    else
4020
 
      cs_gui_properties_post(vars->properties_name[i],
4021
 
                             vars->properties_ipp[i],
4022
 
                             ichrvr,
4023
 
                             ilisvr,
4024
 
                             ihisvr,
4025
 
                             nvppmx);
4026
 
  }
4027
 
 
4028
 
#if _XML_DEBUG_
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]);
4044
 
  }
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)]);
4055
 
  }
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)]);
4066
 
  }
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)]);
4077
 
  }
4078
 
#endif
4079
 
}
4080
 
 
4081
 
/*----------------------------------------------------------------------------
4082
 
 * Users arrays
4083
 
 *
4084
 
 * Fortran Interface:
4085
 
 *
4086
 
 * SUBROUTINE UIUSAR (ICOFTU)
4087
 
 * *****************
4088
 
 *
4089
 
 * INTEGER          ICOFTU   -->  Dimension coef for user arrays
4090
 
 *----------------------------------------------------------------------------*/
4091
 
 
4092
 
void CS_PROCF (uiusar, UIUSAR) (int *const icoftu)
4093
 
{
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");
4098
 
 
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");
4103
 
 
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");
4108
 
 
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");
4113
 
 
4114
 
 
4115
 
#if _XML_DEBUG_
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]);
4125
 
#endif
4126
 
}
4127
 
 
4128
 
 
4129
 
/*----------------------------------------------------------------------------
4130
 
 * Copy variable name from Fortran to C
4131
 
 *----------------------------------------------------------------------------*/
4132
 
 
4133
 
void CS_PROCF(fcnmva, FCNMVA)
4134
 
(
4135
 
 const char          *const fstr,    /* --> Fortran string */
4136
 
 int                 *const len,     /* --> String Length  */
4137
 
 int                 *const var_id   /* --> Variable Id (1 to n) */
4138
 
 CS_ARGF_SUPP_CHAINE
4139
 
)
4140
 
{
4141
 
  int i, i1, i2, l;
4142
 
  char *cstr = NULL;
4143
 
 
4144
 
  assert(*var_id > 0);
4145
 
 
4146
 
  /* Resize array if necessary */
4147
 
 
4148
 
  if (*var_id > cs_glob_label->_cs_gui_max_vars) {
4149
 
 
4150
 
    if (cs_glob_label->_cs_gui_max_vars == 0)
4151
 
      cs_glob_label->_cs_gui_max_vars = 16;
4152
 
 
4153
 
    while (cs_glob_label->_cs_gui_max_vars <= *var_id)
4154
 
      cs_glob_label->_cs_gui_max_vars *= 2;
4155
 
 
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;
4159
 
  }
4160
 
 
4161
 
  /* Compute string length (removing start or end blanks) */
4162
 
 
4163
 
  for (i1 = 0;
4164
 
       i1 < *len && (fstr[i1] == ' ' || fstr[i1] == '\t');
4165
 
       i1++);
4166
 
 
4167
 
  for (i2 = *len - 1;
4168
 
       i2 > i1 && (fstr[i2] == ' ' || fstr[i2] == '\t');
4169
 
       i2--);
4170
 
 
4171
 
  l = i2 - i1 + 1;
4172
 
 
4173
 
  /* Should be called once per variable only */
4174
 
  assert(cs_glob_label->_cs_gui_var_name[*var_id - 1] == NULL);
4175
 
 
4176
 
  if (l > 0) {
4177
 
 
4178
 
    /* Allocate and copy */
4179
 
    BFT_MALLOC(cstr, l + 1, char);
4180
 
 
4181
 
  for (i = 0 ; i < l ; i++, i1++)
4182
 
    cstr[i] = fstr[i1];
4183
 
 
4184
 
  cstr[l] = '\0';
4185
 
 
4186
 
    cs_glob_label->_cs_gui_var_name[*var_id - 1] = cstr;
4187
 
 
4188
 
  }
4189
 
 
4190
 
  /* Update variable counter */
4191
 
  cs_glob_label->_cs_gui_last_var = *var_id;
4192
 
 
4193
 
}
4194
 
 
4195
 
/*----------------------------------------------------------------------------
4196
 
 * Copy variable name from C to Fortran
4197
 
 *----------------------------------------------------------------------------*/
4198
 
 
4199
 
void CS_PROCF(cfnmva, CFNMVA)
4200
 
(
4201
 
 char          *const fstr,    /* --> Fortran string */
4202
 
 int           *const len,     /* --> String Length  */
4203
 
 int           *const var_id   /* --> Variable Id (1 to n) */
4204
 
 CS_ARGF_SUPP_CHAINE
4205
 
)
4206
 
{
4207
 
  int i;
4208
 
  int l = 0;
4209
 
  char *cstr = NULL;
4210
 
 
4211
 
  /* Check that variable name was set */
4212
 
 
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);
4216
 
 
4217
 
  /* Copy string */
4218
 
 
4219
 
  cstr = cs_glob_label->_cs_gui_var_name[*var_id - 1];
4220
 
 
4221
 
  if (cstr != NULL) {
4222
 
 
4223
 
  /* Compute string length (removing start or end blanks) */
4224
 
 
4225
 
  l = strlen(cstr);
4226
 
  if (l > *len)
4227
 
    l = *len;
4228
 
 
4229
 
    for (i = 0; i < l; i++)
4230
 
      fstr[i] = cstr[i];
4231
 
 
4232
 
  }
4233
 
 
4234
 
  /* Pad with blanks if necessary */
4235
 
 
4236
 
  for (i = l; i < *len; i++)
4237
 
    fstr[i] = ' ';
4238
 
}
4239
 
 
4240
 
/*----------------------------------------------------------------------------
4241
 
 * Clean memory for fortran name of variables
4242
 
 *----------------------------------------------------------------------------*/
4243
 
 
4244
 
void CS_PROCF(nvamem, NVAMEM) (void)
4245
 
{
4246
 
    int i;
4247
 
#if _XML_DEBUG_
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]);
4252
 
#endif
4253
 
 
4254
 
    for (i = 0; i < cs_glob_label->_cs_gui_max_vars; i++)
4255
 
        BFT_FREE(cs_glob_label->_cs_gui_var_name[i]);
4256
 
 
4257
 
    BFT_FREE(cs_glob_label->_cs_gui_var_name);
4258
 
 
4259
 
    cs_glob_label->_cs_gui_max_vars = 0;
4260
 
    cs_glob_label->_cs_gui_last_var = 0;
4261
 
}
4262
 
 
4263
 
/*-----------------------------------------------------------------------------
4264
 
 * Return the list of cells describing a given zone.
4265
 
 *
4266
 
 * parameters:
4267
 
 *   label     -->  volume label
4268
 
 *   ncelet    -->  number of cells with halo
4269
 
 *   faces     <--  number of selected cells
4270
 
 *----------------------------------------------------------------------------*/
4271
 
 
4272
 
static int*
4273
 
cs_gui_get_cells_list(const char *label,
4274
 
                      const int   ncelet,
4275
 
                            int  *cells )
4276
 
{
4277
 
    int  c_id         = 0;
4278
 
    int  *cells_list  = NULL;
4279
 
    char *description = NULL;
4280
 
 
4281
 
    description = cs_gui_volumic_zone_localization(label);
4282
 
 
4283
 
    /* build list of cells */
4284
 
    BFT_MALLOC(cells_list, ncelet, int);
4285
 
 
4286
 
    c_id = fvm_selector_get_list(cs_glob_mesh->select_cells,
4287
 
                                 description,
4288
 
                                 cells,
4289
 
                                 cells_list);
4290
 
 
4291
 
    if (fvm_selector_n_missing(cs_glob_mesh->select_cells, c_id) > 0)
4292
 
    {
4293
 
        const char *missing
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"
4297
 
                     "criteria:\n"
4298
 
                     "\"%s\"\n"
4299
 
                     " does not correspond to any cell.\n"),
4300
 
                   missing, description);
4301
 
    }
4302
 
    BFT_FREE(description);
4303
 
    return cells_list;
4304
 
}
4305
 
 
4306
 
/*----------------------------------------------------------------------------
4307
 
 * Variables and user scalars initialization.
4308
 
 *
4309
 
 * Fortran Interface:
4310
 
 *
4311
 
 * subroutine uiiniv (ncelet, isuite, isca, iscold, rtp)
4312
 
 * *****************
4313
 
 *
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
 
 *----------------------------------------------------------------------------*/
4320
 
 
4321
 
void CS_PROCF(uiiniv, UIINIV)(const int    *ncelet,
4322
 
                              const int    *isuite,
4323
 
                              const int    *isca,
4324
 
                              const int    *iscold,
4325
 
                                    double  rtp[])
4326
 
{
4327
 
  /* Coal combustion: the initialization of the model scalar are not given */
4328
 
 
4329
 
  int i, j, icel, iel;
4330
 
  int zones = 0;
4331
 
  int cells = 0;
4332
 
  int *cells_list = NULL;
4333
 
  double initial_value = 0;
4334
 
  char *choice = NULL;
4335
 
  char *path = NULL;
4336
 
  char *status = NULL;
4337
 
  char *label = NULL;
4338
 
 
4339
 
  cs_var_t  *vars = cs_glob_var;
4340
 
 
4341
 
  /* number of volumic zone */
4342
 
 
4343
 
  zones
4344
 
    = cs_gui_get_tag_number("/solution_domain/volumic_conditions/zone", 1);
4345
 
 
4346
 
#if _XML_DEBUG_
4347
 
  bft_printf("==>UIINIV\n");
4348
 
#endif
4349
 
 
4350
 
  for (i=1; i < zones+1; i++) {
4351
 
 
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);
4357
 
    BFT_FREE(path);
4358
 
 
4359
 
    if (cs_gui_strcmp(status, "on"))  {
4360
 
 
4361
 
      label = cs_gui_volumic_zone_label(i);
4362
 
      cells_list = cs_gui_get_cells_list(label, *ncelet, &cells);
4363
 
 
4364
 
      if (*isuite == 0) {
4365
 
 
4366
 
        /* Velocity variables initialization */
4367
 
        for (j=1; j < 4; j++) {
4368
 
 
4369
 
          cs_gui_variable_initial_value(vars->name[j], label, &initial_value);
4370
 
 
4371
 
          for (icel = 0; icel < cells; icel++) {
4372
 
            iel = cells_list[icel]-1;
4373
 
            rtp[vars->rtp[j]*(*ncelet) + iel] = initial_value;
4374
 
          }
4375
 
        }
4376
 
 
4377
 
        /* Turbulence variables initialization */
4378
 
        choice = cs_gui_turbulence_initialization_choice();
4379
 
 
4380
 
        if (cs_gui_strcmp(choice, "values")) {
4381
 
          for (j=4; j < vars->nvar - vars->nscaus - vars->nscapp; j++) {
4382
 
 
4383
 
            cs_gui_variable_initial_value(vars->name[j], label, &initial_value);
4384
 
 
4385
 
            for (icel = 0; icel < cells; icel++) {
4386
 
              iel = cells_list[icel]-1;
4387
 
              rtp[vars->rtp[j]*(*ncelet) + iel] = initial_value;
4388
 
            }
4389
 
          }
4390
 
        }
4391
 
 
4392
 
        BFT_FREE(choice);
4393
 
      }
4394
 
 
4395
 
      /* User Scalars initialization */
4396
 
      for (j=0; j < vars->nscaus; j++) {
4397
 
 
4398
 
        cs_gui_scalar_initial_value("additional_scalars",
4399
 
                                    vars->label[j],
4400
 
                                    label,
4401
 
                                    &initial_value);
4402
 
 
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;
4407
 
          }
4408
 
        }
4409
 
      }
4410
 
 
4411
 
      BFT_FREE(cells_list);
4412
 
 
4413
 
#if _XML_DEBUG_
4414
 
      bft_printf("--zone label: %s\n", label);
4415
 
      bft_printf("--zone's element number: %i\n", cells);
4416
 
 
4417
 
      if (*isuite == 0) {
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);
4422
 
        }
4423
 
      }
4424
 
 
4425
 
      for (j=0; j < vars->nscaus; j++) {
4426
 
        cs_gui_scalar_initial_value("additional_scalars",
4427
 
                                    vars->label[j],
4428
 
                                    label,
4429
 
                                    &initial_value);
4430
 
        if (*isuite == 0 || (*isuite !=0 && iscold[j] == 0)) {
4431
 
          bft_printf("--initial value for %s: %f\n", vars->label[j], initial_value);
4432
 
        }
4433
 
      }
4434
 
#endif
4435
 
      BFT_FREE(cells_list);
4436
 
      BFT_FREE(label);
4437
 
    }
4438
 
    BFT_FREE(status);
4439
 
  } /* zones+1 */
4440
 
}
4441
 
 
4442
 
/*-----------------------------------------------------------------------------
4443
 
 * Change the head losses matrix from the local frame to the global frame.
4444
 
 *
4445
 
 * parameters:
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
 
 *----------------------------------------------------------------------------*/
4450
 
 
4451
 
static void
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)
4461
 
{
4462
 
    int     i, j, k;
4463
 
    double  tensorP[3][3], tensorA[3][3], tensorB[3][3], tensorC[3][3], tensorD[3][3];
4464
 
 
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;
4474
 
 
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;
4484
 
 
4485
 
    for (i = 0; i < 3; i++)
4486
 
    {
4487
 
        for (j = 0; j < 3; j++)
4488
 
        {
4489
 
            tensorB[i][j] = 0.;
4490
 
            for (k = 0; k < 3; k++)
4491
 
                tensorB[i][j] += tensorP[i][k] * tensorA[k][j];
4492
 
        }
4493
 
    }
4494
 
 
4495
 
    /* Inversion of a 3x3 matrix */
4496
 
 
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;
4506
 
 
4507
 
    for (i = 0; i < 3; i++)
4508
 
    {
4509
 
        for (j = 0; j < 3; j++)
4510
 
        {
4511
 
            tensorD[i][j] = 0.;
4512
 
            for (k = 0; k < 3; k++)
4513
 
                tensorD[i][j] += tensorB[i][k] * tensorC[k][j];
4514
 
        }
4515
 
    }
4516
 
 
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];
4526
 
}
4527
 
 
4528
 
/*-----------------------------------------------------------------------------
4529
 
 * Return value of coefficient associated to the head losses definition.
4530
 
 *
4531
 
 * parameters:
4532
 
 *   label     -->  label of the volume zone
4533
 
 *   c         -->  name of the coefficient
4534
 
 *----------------------------------------------------------------------------*/
4535
 
 
4536
 
static double
4537
 
_c_heads_losses(const char* label, const char* c)
4538
 
{
4539
 
    char* path;
4540
 
    double result = 0.0;
4541
 
    double value  = 0.0;
4542
 
 
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))
4549
 
        value = result;
4550
 
    else
4551
 
        value= 0.0;
4552
 
    BFT_FREE(path);
4553
 
    return value;
4554
 
}
4555
 
 
4556
 
/*----------------------------------------------------------------------------
4557
 
 * Head losses definition
4558
 
 *
4559
 
 * Fortran Interface:
4560
 
 *
4561
 
 * subroutine uikpdc
4562
 
 * *****************
4563
 
 *
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
 
 *----------------------------------------------------------------------------*/
4572
 
 
4573
 
void CS_PROCF(uikpdc, UIKPDC)(const int*   iappel,
4574
 
                              const int*   iphas,
4575
 
                              const int*   ncelet,
4576
 
                                    int    ncepdp[],
4577
 
                                    int    icepdc[],
4578
 
                                    double ckupdc[],
4579
 
                              const double rtpa[] )
4580
 
{
4581
 
  int i, j, iel, ielpdc, ikpdc;
4582
 
  int zones = 0;
4583
 
  int cells = 0;
4584
 
  int *cells_list = NULL;
4585
 
  double vit;
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;
4589
 
  char *label = NULL;
4590
 
  char *status = NULL;
4591
 
  char *path = NULL;
4592
 
 
4593
 
  assert(*iphas == 1);
4594
 
 
4595
 
  cs_var_t  *vars = cs_glob_var;
4596
 
 
4597
 
  /* number of volumic zone */
4598
 
 
4599
 
  zones
4600
 
    = cs_gui_get_tag_number("/solution_domain/volumic_conditions/zone", 1);
4601
 
 
4602
 
 
4603
 
    if (*iappel == 1 || *iappel == 2)
4604
 
    {
4605
 
        ielpdc = 0;
4606
 
 
4607
 
        for (i=1; i < zones+1; i++)
4608
 
        {
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);
4614
 
            BFT_FREE(path);
4615
 
 
4616
 
            if (cs_gui_strcmp(status, "on"))
4617
 
            {
4618
 
                label = cs_gui_volumic_zone_label(i);
4619
 
                cells_list = cs_gui_get_cells_list(label, *ncelet, &cells);
4620
 
 
4621
 
                for (j=0; j < cells; j++)
4622
 
                {
4623
 
                    if (*iappel == 2)
4624
 
                        icepdc[ielpdc] = cells_list[j];
4625
 
                    ielpdc++;
4626
 
                }
4627
 
                BFT_FREE(cells_list);
4628
 
                BFT_FREE(label);
4629
 
            }
4630
 
            BFT_FREE(status);
4631
 
        } /* zones+1 */
4632
 
        if (*iappel == 1)
4633
 
            ncepdp[*iphas-1] = ielpdc;
4634
 
    }
4635
 
 
4636
 
    if (*iappel == 3)
4637
 
    {
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;
4641
 
 
4642
 
        ielpdc = 0;
4643
 
 
4644
 
        for (i=1; i < zones+1; i++)
4645
 
        {
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);
4651
 
            BFT_FREE(path);
4652
 
 
4653
 
            if (cs_gui_strcmp(status, "on"))
4654
 
            {
4655
 
                label = cs_gui_volumic_zone_label(i);
4656
 
                cells_list = cs_gui_get_cells_list(label, *ncelet, &cells);
4657
 
 
4658
 
                k11 = _c_heads_losses(label, "kxx");
4659
 
                k22 = _c_heads_losses(label, "kyy");
4660
 
                k33 = _c_heads_losses(label, "kzz");
4661
 
 
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");
4671
 
 
4672
 
                if (a12 == 0.0 && a13 == 0.0 && a23 == 0.0)
4673
 
                {
4674
 
                    c11 = k11;
4675
 
                    c22 = k22;
4676
 
                    c33 = k33;
4677
 
                    c12 = 0.0;
4678
 
                    c13 = 0.0;
4679
 
                    c23 = 0.0;
4680
 
                }
4681
 
                else
4682
 
                {
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);
4686
 
                }
4687
 
 
4688
 
                for (j = 0; j < cells; j++)
4689
 
                {
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] ;
4694
 
                    vit = sqrt(vit);
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;
4701
 
                    ielpdc++;
4702
 
                }
4703
 
                BFT_FREE(cells_list);
4704
 
                BFT_FREE(label);
4705
 
            }
4706
 
            BFT_FREE(status);
4707
 
        } /* zones+1 */
4708
 
    }
4709
 
#if _XML_DEBUG_
4710
 
    bft_printf("==>uikpdc\n");
4711
 
    if (*iappel == 1)
4712
 
        bft_printf("--%i number of head losses cells: %i\n", *iappel, ncepdp[*iphas-1]);
4713
 
    if (*iappel == 3)
4714
 
        bft_printf("--%i number of head losses cells: %i\n", *iappel, ielpdc);
4715
 
#endif
4716
 
}
4717
 
 
4718
 
/*----------------------------------------------------------------------------
4719
 
 * User law for material properties
4720
 
 *
4721
 
 * Fortran Interface:
4722
 
 *
4723
 
 * SUBROUTINE UIPHYV
4724
 
 * *****************
4725
 
 *
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
 
 *----------------------------------------------------------------------------*/
4744
 
 
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[],
4761
 
                                    cs_real_t        propce[])
4762
 
{
4763
 
#if defined(HAVE_MEI)
4764
 
 
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;
4776
 
 
4777
 
    cs_int_t iphas = 0;
4778
 
    char *path = NULL;
4779
 
    int i, j, iel;
4780
 
    double tmp;
4781
 
 
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 */
4786
 
 
4787
 
    /* law for density */
4788
 
 
4789
 
    if (irovar[iphas] == 1 && cs_gui_strcmp(_properties_choice("density"), "user_law"))
4790
 
    {
4791
 
        /* search the formula for the law */
4792
 
 
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);
4798
 
 
4799
 
        law_rho = cs_gui_get_text_value(path);
4800
 
        BFT_FREE(path);
4801
 
 
4802
 
        /* return an empty interpreter */
4803
 
 
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);
4807
 
 
4808
 
       /* try to build the interpreter */
4809
 
 
4810
 
        if (mei_tree_builder(ev_rho))
4811
 
            bft_error(__FILE__, __LINE__, 0,
4812
 
                      _("Error: can not interprete expression: %s\n"), ev_rho->string);
4813
 
 
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");
4817
 
 
4818
 
        /* for each cell, update the value of the table of symbols for each scalar
4819
 
           (including the thermal scalar), and evaluate the interpreter */
4820
 
 
4821
 
        for (iel = 0; iel < *ncel; iel++)
4822
 
        {
4823
 
            for (i = 0; i < *nscaus; i++)
4824
 
                mei_tree_insert(ev_rho,
4825
 
                                vars->label[i],
4826
 
                                rtp[(isca[i] -1) * (*ncelet) + iel]);
4827
 
 
4828
 
            tmp = mei_evaluate(ev_rho);
4829
 
            propce[ipcrom * (*ncelet) + iel] = mei_tree_lookup(ev_rho, "rho");
4830
 
        }
4831
 
 
4832
 
        mei_tree_destroy(ev_rho);
4833
 
    }
4834
 
 
4835
 
    /* law for molecular viscosity */
4836
 
 
4837
 
    if (ivivar[iphas] == 1 && cs_gui_strcmp(_properties_choice("molecular_viscosity"), "user_law"))
4838
 
    {
4839
 
        /* search the formula for the law */
4840
 
 
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);
4846
 
 
4847
 
        law_mu = cs_gui_get_text_value(path);
4848
 
        BFT_FREE(path);
4849
 
 
4850
 
        /* return an empty interpreter */
4851
 
 
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);
4855
 
 
4856
 
       /* try to build the interpreter */
4857
 
 
4858
 
        if (mei_tree_builder(ev_mu))
4859
 
            bft_error(__FILE__, __LINE__, 0,
4860
 
                      _("Error: can not interprete expression: %s\n"), ev_mu->string);
4861
 
 
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");
4865
 
 
4866
 
        /* for each cell, update the value of the table of symbols for each scalar
4867
 
           (including the thermal scalar), and evaluate the interpreter */
4868
 
 
4869
 
        for (iel = 0; iel < *ncel; iel++)
4870
 
        {
4871
 
            for (i = 0; i < *nscaus; i++)
4872
 
                mei_tree_insert(ev_mu,
4873
 
                                vars->label[i],
4874
 
                                rtp[(isca[i] -1) * (*ncelet) + iel]);
4875
 
 
4876
 
            tmp = mei_evaluate(ev_mu);
4877
 
            propce[ipcvis * (*ncelet) + iel] = mei_tree_lookup(ev_mu, "mu");
4878
 
        }
4879
 
 
4880
 
        mei_tree_destroy(ev_mu);
4881
 
    }
4882
 
 
4883
 
    /* law for specific heat */
4884
 
 
4885
 
    if (icp[iphas] > 0 && cs_gui_strcmp(_properties_choice("specific_heat"), "user_law"))
4886
 
    {
4887
 
        /* search the formula for the law */
4888
 
 
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);
4894
 
 
4895
 
        law_cp = cs_gui_get_text_value(path);
4896
 
        BFT_FREE(path);
4897
 
 
4898
 
        /* return an empty interpreter */
4899
 
 
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);
4903
 
 
4904
 
       /* try to build the interpreter */
4905
 
 
4906
 
        if (mei_tree_builder(ev_cp))
4907
 
            bft_error(__FILE__, __LINE__, 0,
4908
 
                      _("Error: can not interprete expression: %s\n"), ev_cp->string);
4909
 
 
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");
4913
 
 
4914
 
        /* for each cell, update the value of the table of symbols for each scalar
4915
 
           (including the thermal scalar), and evaluate the interpreter */
4916
 
 
4917
 
        for (iel = 0; iel < *ncel; iel++)
4918
 
        {
4919
 
            for (i = 0; i < *nscaus; i++)
4920
 
                mei_tree_insert(ev_cp,
4921
 
                                vars->label[i],
4922
 
                                rtp[(isca[i] -1) * (*ncelet) + iel]);
4923
 
 
4924
 
            tmp = mei_evaluate(ev_cp);
4925
 
            propce[ipccp * (*ncelet) + iel] = mei_tree_lookup(ev_cp, "cp");
4926
 
        }
4927
 
 
4928
 
        mei_tree_destroy(ev_cp);
4929
 
    }
4930
 
 
4931
 
    /* law for thermal conductivity */
4932
 
 
4933
 
    if (ivisls[iscalt[iphas] -1] > 0 && cs_gui_strcmp(_properties_choice("thermal_conductivity"), "user_law"))
4934
 
    {
4935
 
        /* search the formula for the law */
4936
 
 
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);
4942
 
 
4943
 
        law_la = cs_gui_get_text_value(path);
4944
 
        BFT_FREE(path);
4945
 
 
4946
 
        /* return an empty interpreter */
4947
 
 
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);
4951
 
 
4952
 
       /* try to build the interpreter */
4953
 
 
4954
 
        if (mei_tree_builder(ev_la))
4955
 
            bft_error(__FILE__, __LINE__, 0,
4956
 
                      _("Error: can not interprete expression: %s\n"), ev_la->string);
4957
 
 
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");
4961
 
 
4962
 
        /* for each cell, update the value of the table of symbols for each scalar
4963
 
           (including the thermal scalar), and evaluate the interpreter */
4964
 
 
4965
 
        if (icp[iphas] > 0)
4966
 
        {
4967
 
            for (iel = 0; iel < *ncel; iel++)
4968
 
            {
4969
 
                for (i = 0; i < *nscaus; i++)
4970
 
                    mei_tree_insert(ev_la,
4971
 
                                    vars->label[i],
4972
 
                                    rtp[(isca[i] -1) * (*ncelet) + iel]);
4973
 
 
4974
 
                tmp = mei_evaluate(ev_la);
4975
 
                propce[ipcvsl * (*ncelet) + iel] =
4976
 
                    mei_tree_lookup(ev_la, "lambda") / propce[ipccp * (*ncelet) + iel];
4977
 
            }
4978
 
        }
4979
 
        else
4980
 
        {
4981
 
            for (iel = 0; iel < *ncel; iel++)
4982
 
            {
4983
 
                for (i = 0; i < *nscaus; i++)
4984
 
                    mei_tree_insert(ev_la,
4985
 
                                    vars->label[i],
4986
 
                                    rtp[(isca[i] -1) * (*ncelet) + iel]);
4987
 
 
4988
 
                tmp = mei_evaluate(ev_la);
4989
 
                propce[ipcvsl * (*ncelet) + iel] =
4990
 
                    mei_tree_lookup(ev_la, "lambda") / cp0[iphas];
4991
 
            }
4992
 
        }
4993
 
        mei_tree_destroy(ev_la);
4994
 
    }
4995
 
 
4996
 
    /* law for scalar diffusivity */
4997
 
 
4998
 
    for (j = 0; j < *nscaus; j++)
4999
 
    {
5000
 
        char *name = _scalar_diffusion_coefficient_name(j);
5001
 
 
5002
 
        if (j != iscalt[iphas] -1 && iscavr[j] <= 0 && ivisls[j] > 0 &&
5003
 
            cs_gui_strcmp(_properties_choice(name), "user_law"))
5004
 
        {
5005
 
            ipcvsl = ipproc[ ivisls[j] -1 ] -1;
5006
 
 
5007
 
            /* search the formula for the law */
5008
 
 
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);
5015
 
 
5016
 
            law_Ds = cs_gui_get_text_value(path);
5017
 
            BFT_FREE(path);
5018
 
 
5019
 
            /* return an empty interpreter */
5020
 
 
5021
 
            ev_Ds = mei_tree_new(law_Ds);
5022
 
            BFT_FREE(law_Ds);
5023
 
            for (i = 0; i < *nscaus; i++)
5024
 
                mei_tree_insert(ev_Ds, vars->label[i], 0.0);
5025
 
 
5026
 
           /* try to build the interpreter */
5027
 
 
5028
 
            if (mei_tree_builder(ev_Ds))
5029
 
                bft_error(__FILE__, __LINE__, 0,
5030
 
                          _("Error: can not interprete expression: %s\n"), ev_Ds->string);
5031
 
 
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");
5035
 
 
5036
 
            /* for each cell, update the value of the table of symbols for each scalar
5037
 
               (including the thermal scalar), and evaluate the interpreter */
5038
 
 
5039
 
            if (irovar[iphas] == 1)
5040
 
            {
5041
 
                for (iel = 0; iel < *ncel; iel++)
5042
 
                {
5043
 
                    for (i = 0; i < *nscaus; i++)
5044
 
                        mei_tree_insert(ev_Ds,
5045
 
                                        vars->label[i],
5046
 
                                        rtp[(isca[i] -1) * (*ncelet) + iel]);
5047
 
 
5048
 
                    tmp = mei_evaluate(ev_Ds);
5049
 
                    propce[ipcvsl * (*ncelet) + iel] =
5050
 
                        mei_tree_lookup(ev_Ds, "diffusivity") * propce[ipcrom * (*ncelet) + iel];
5051
 
                }
5052
 
            }
5053
 
            else
5054
 
            {
5055
 
                for (iel = 0; iel < *ncel; iel++)
5056
 
                {
5057
 
                    for (i = 0; i < *nscaus; i++)
5058
 
                        mei_tree_insert(ev_Ds,
5059
 
                                        vars->label[i],
5060
 
                                        rtp[(isca[i] -1) * (*ncelet) + iel]);
5061
 
 
5062
 
                    tmp = mei_evaluate(ev_Ds);
5063
 
                    propce[ipcvsl * (*ncelet) + iel] =
5064
 
                        mei_tree_lookup(ev_Ds, "diffusivity") * ro0[iphas];
5065
 
                }
5066
 
            }
5067
 
            mei_tree_destroy(ev_Ds);
5068
 
        }
5069
 
        BFT_FREE(name);
5070
 
    }
5071
 
 
5072
 
#if _XML_DEBUG_
5073
 
    bft_printf("==>UIPHYV\n");
5074
 
    if (irovar[iphas] == 1)
5075
 
        bft_printf("--law for density: %s\n", law_rho);
5076
 
 
5077
 
    if (ivivar[iphas] == 1)
5078
 
        bft_printf("--law for viscosity: %s\n", law_mu);
5079
 
 
5080
 
    if (icp[iphas] > 0)
5081
 
        bft_printf("--law for specific heat: %s\n", law_cp);
5082
 
 
5083
 
    if (ivisls[iscalt[iphas] -1] > 0)
5084
 
        bft_printf("--law for thermal conductivity: %s\n", law_la);
5085
 
 
5086
 
    for (j = 0; j < *nscaus; j++)
5087
 
    {
5088
 
        if (j != iscalt[iphas] -1 && iscavr[j] <= 0 && ivisls[j] > 0)
5089
 
        {
5090
 
            ipcvsl = ipproc[ ivisls[j] -1 ] -1;
5091
 
 
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);
5098
 
 
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);
5102
 
            BFT_FREE(path);
5103
 
            BFT_FREE(law_Ds);
5104
 
        }
5105
 
    }
5106
 
#endif
5107
 
 
5108
 
    BFT_FREE(law_rho);
5109
 
    BFT_FREE(law_mu);
5110
 
    BFT_FREE(law_cp);
5111
 
    BFT_FREE(law_la);
5112
 
 
5113
 
#endif
5114
 
}
5115
 
 
5116
 
/*----------------------------------------------------------------------------
5117
 
 * 1D profile postprocessing
5118
 
 *
5119
 
 * Fortran Interface:
5120
 
 *
5121
 
 * SUBROUTINE UIPROF
5122
 
 * *****************
5123
 
 *
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
 
 *----------------------------------------------------------------------------*/
5133
 
 
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)
5142
 
{
5143
 
  FILE *file = NULL;
5144
 
  char *filename = NULL;
5145
 
  char *title = NULL;
5146
 
  char *name = NULL;
5147
 
 
5148
 
  int fic_nbr = 0;
5149
 
  int i, ii, iii, j;
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];
5154
 
  double a, aa;
5155
 
  double *array;
5156
 
 
5157
 
  cs_var_t  *vars = cs_glob_var;
5158
 
 
5159
 
  /* get the number of 1D profile file to write*/
5160
 
 
5161
 
  fic_nbr = cs_gui_get_tag_number("/analysis_control/profiles/profile", 1);
5162
 
 
5163
 
  if (!fic_nbr) return;
5164
 
 
5165
 
  for (i = 0 ; i < fic_nbr ; i++) {
5166
 
 
5167
 
    /* for each profile, check the output frequency */
5168
 
 
5169
 
    output_frequency = _get_profile_coordinate(i, "output_frequency");
5170
 
 
5171
 
    if ((output_frequency == -1 && *ntmabs == *ntcabs) ||
5172
 
        (output_frequency > 0 && (*ntcabs % output_frequency) == 0)) {
5173
 
 
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");
5180
 
 
5181
 
      nvar_prop = _get_profile_names_number(i);
5182
 
      nvar_prop4 = nvar_prop + 4;
5183
 
      BFT_MALLOC(array, nvar_prop4, double);
5184
 
 
5185
 
      /* Only the first processor rank opens the file */
5186
 
 
5187
 
      if (cs_glob_rank_id <= 0) {
5188
 
 
5189
 
        filename = _get_profile("label", i);
5190
 
        title    = _get_profile("title", i);
5191
 
 
5192
 
        if (output_frequency > 0) {
5193
 
 
5194
 
          char buf1[5];
5195
 
          const char buffer[5] = "%.4i";
5196
 
 
5197
 
          /* Extension creation : format stored in 'buffer' */
5198
 
 
5199
 
          sprintf(buf1, buffer, *ntcabs);
5200
 
 
5201
 
          BFT_REALLOC(filename, strlen(filename) + 1 + 4 + 1, char);
5202
 
 
5203
 
          strcat(filename, "_");
5204
 
          strcat(filename, buf1);
5205
 
 
5206
 
        }
5207
 
 
5208
 
        BFT_REALLOC(filename, strlen(filename) + 4 + 1, char);
5209
 
        strcat(filename, ".dat");
5210
 
        file = fopen(filename, "w");
5211
 
 
5212
 
        if (file ==  NULL) {
5213
 
          cs_base_warn(__FILE__, __LINE__);
5214
 
          bft_printf( _("Unable to open the file: %s\n"), filename);
5215
 
          break;
5216
 
        }
5217
 
 
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",
5222
 
                x1, y1, z1);
5223
 
        fprintf(file, "# End point:   x = %12.5e y = %12.5e z = %12.5e\n#\n",
5224
 
                x2, y2, z2);
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);
5230
 
          BFT_FREE(buffer);
5231
 
        }
5232
 
        fprintf(file, "\n");
5233
 
        BFT_FREE(filename);
5234
 
        BFT_FREE(title);
5235
 
      }
5236
 
 
5237
 
      npoint = 200;
5238
 
      iel1   = -999;
5239
 
      irang1 = -999;
5240
 
 
5241
 
      a = 1. / (double) (npoint-1);
5242
 
 
5243
 
      for (ii = 0; ii < npoint; ii++) {
5244
 
 
5245
 
        aa = ii*a;
5246
 
        xyz[0] = aa * (x2 - x1) + x1;
5247
 
        xyz[1] = aa * (y2 - y1) + y1;
5248
 
        xyz[2] = aa * (z2 - z1) + z1;
5249
 
 
5250
 
        CS_PROCF(findpt, FINDPT)(ncelet,  ncel,    xyzcen,
5251
 
                                 &xyz[0], &xyz[1], &xyz[2],
5252
 
                                 &iel,    &irangv);
5253
 
 
5254
 
        if ((iel != iel1) || (irangv != irang1)) {
5255
 
          iel1 = iel;
5256
 
          irang1 = irangv;
5257
 
 
5258
 
          if (cs_glob_rank_id == irangv) {
5259
 
 
5260
 
            iel--;
5261
 
            xx = xyzcen[3 * iel + 0];
5262
 
            yy = xyzcen[3 * iel + 1];
5263
 
            zz = xyzcen[3 * iel + 2];
5264
 
            array[1] = xx;
5265
 
            array[2] = yy;
5266
 
            array[3] = zz;
5267
 
            xx = xx - x1;
5268
 
            yy = yy - y1;
5269
 
            zz = zz - z1;
5270
 
            array[0] = sqrt(xx*xx + yy*yy + zz*zz);
5271
 
 
5272
 
            for (iii=0; iii < nvar_prop; iii++) {
5273
 
 
5274
 
              name = _get_profile_name(i, iii);
5275
 
 
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];
5279
 
              }
5280
 
 
5281
 
              for (j=0; j < vars->nprop; j++) {
5282
 
                if (cs_gui_strcmp(name, vars->properties_name[j]))
5283
 
                  array[iii+4]
5284
 
                  = propce[(vars->propce[j]-1) * (*ncelet) + iel];
5285
 
              }
5286
 
 
5287
 
              BFT_FREE(name);
5288
 
            }
5289
 
 
5290
 
          } else {
5291
 
 
5292
 
            for (iii=0; iii < nvar_prop4; iii++)
5293
 
              array[iii] = 0.0;
5294
 
          }
5295
 
 
5296
 
          /* Send to other processors if parallel */
5297
 
#if defined(HAVE_MPI)
5298
 
          if (cs_glob_rank_id >= 0) {
5299
 
            MPI_Bcast(array,
5300
 
                      nvar_prop4,
5301
 
                      CS_MPI_REAL,
5302
 
                      irangv,
5303
 
                      cs_glob_mpi_comm);
5304
 
          }
5305
 
#endif
5306
 
 
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");
5311
 
          }
5312
 
        }
5313
 
      }
5314
 
 
5315
 
      if (cs_glob_rank_id <= 0) fclose(file);
5316
 
 
5317
 
      BFT_FREE(array);
5318
 
    }
5319
 
  }
5320
 
}
5321
 
 
5322
 
/*----------------------------------------------------------------------------
5323
 
 * Free memory: clean global private variables and libxml2 variables
5324
 
 *
5325
 
 * Fortran Interface:
5326
 
 *
5327
 
 * SUBROUTINE MEMUI1
5328
 
 * *****************
5329
 
 *
5330
 
 * INTEGER          NCHARB  --> number of coal
5331
 
 *----------------------------------------------------------------------------*/
5332
 
 
5333
 
void CS_PROCF (memui1, MEMUI1) (const int *const ncharb)
5334
 
{
5335
 
    int i;
5336
 
 
5337
 
    cs_gui_boundary_conditions_free_memory(ncharb);
5338
 
 
5339
 
    /* clean memory for global private structure vars */
5340
 
 
5341
 
    for (i=0; i < cs_glob_var->nvar; i++)
5342
 
    {
5343
 
        BFT_FREE(cs_glob_var->type[i]);
5344
 
        BFT_FREE(cs_glob_var->head[i]);
5345
 
        BFT_FREE(cs_glob_var->name[i]);
5346
 
    }
5347
 
 
5348
 
    for (i=0; i < cs_glob_var->nscaus + cs_glob_var->nscapp; i++)
5349
 
        BFT_FREE(cs_glob_var->label[i]);
5350
 
 
5351
 
    for (i=0; i < cs_glob_var->nprop; i++)
5352
 
        BFT_FREE(cs_glob_var->properties_name[i]);
5353
 
 
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);
5365
 
 
5366
 
 
5367
 
    for (i = 0; i < cs_glob_label->_cs_gui_max_vars; i++)
5368
 
        BFT_FREE(cs_glob_label->_cs_gui_var_name[i]);
5369
 
 
5370
 
    BFT_FREE(cs_glob_label->_cs_gui_var_name);
5371
 
    BFT_FREE(cs_glob_label);
5372
 
 
5373
 
    /* clean memory for xml document */
5374
 
 
5375
 
#if defined(HAVE_LIBXML2)
5376
 
    if (xpathCtx != NULL) xmlXPathFreeContext(xpathCtx);
5377
 
    if (node != NULL) xmlFreeNode(node);
5378
 
#endif
5379
 
 
5380
 
    /* Shutdown libxml */
5381
 
 
5382
 
#if defined(HAVE_LIBXML2)
5383
 
    xmlCleanupParser();
5384
 
    xmlMemoryDump();
5385
 
#endif
5386
 
}
5387
 
 
5388
 
/*----------------------------------------------------------------------------*/
5389
 
 
5390
 
END_C_DECLS