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

« back to all changes in this revision

Viewing changes to src/base/cs_gui_specific_physics.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: specific physics
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
 
 * BFT library headers
50
 
 *----------------------------------------------------------------------------*/
51
 
 
52
 
#include <bft_mem.h>
53
 
#include <bft_error.h>
54
 
#include <bft_printf.h>
55
 
 
56
 
/*----------------------------------------------------------------------------
57
 
 * FVM library headers
58
 
 *----------------------------------------------------------------------------*/
59
 
 
60
 
#include "fvm_selector.h"
61
 
 
62
 
/*----------------------------------------------------------------------------
63
 
 * MEI library headers
64
 
 *----------------------------------------------------------------------------*/
65
 
 
66
 
#ifdef HAVE_MEI
67
 
#include "mei_evaluate.h"
68
 
#endif
69
 
 
70
 
/*----------------------------------------------------------------------------
71
 
 * Local headers
72
 
 *----------------------------------------------------------------------------*/
73
 
 
74
 
#include "cs_base.h"
75
 
#include "cs_gui_util.h"
76
 
#include "cs_gui_variables.h"
77
 
#include "cs_mesh.h"
78
 
#include "cs_prototypes.h"
79
 
 
80
 
/*----------------------------------------------------------------------------
81
 
 * Header for the current file
82
 
 *----------------------------------------------------------------------------*/
83
 
 
84
 
#include "cs_gui_specific_physics.h"
85
 
 
86
 
/*----------------------------------------------------------------------------*/
87
 
 
88
 
BEGIN_C_DECLS
89
 
 
90
 
/*=============================================================================
91
 
 * Local Macro Definitions
92
 
 *============================================================================*/
93
 
 
94
 
/* debugging switch */
95
 
#define _XML_DEBUG_ 0
96
 
 
97
 
/*============================================================================
98
 
 * Private function definitions
99
 
 *============================================================================*/
100
 
 
101
 
/*-----------------------------------------------------------------------------
102
 
 * Return the activated specific physics scalar number
103
 
 *----------------------------------------------------------------------------*/
104
 
 
105
 
static int
106
 
_scalar_number(const char* model)
107
 
{
108
 
  char *path = NULL;
109
 
  int   nb;
110
 
 
111
 
  path = cs_xpath_init_path();
112
 
  cs_xpath_add_element(&path, "thermophysical_models");
113
 
  cs_xpath_add_element(&path, model);
114
 
  cs_xpath_add_element(&path, "scalar");
115
 
 
116
 
  nb = cs_gui_get_nb_element(path);
117
 
 
118
 
  BFT_FREE(path);
119
 
 
120
 
  return nb;
121
 
}
122
 
 
123
 
/*============================================================================
124
 
 * Public Fortran function definitions
125
 
 *============================================================================*/
126
 
 
127
 
/*-----------------------------------------------------------------------------
128
 
 * Predefined physics indicator.
129
 
 *
130
 
 * Fortran Interface:
131
 
 *
132
 
 * SUBROUTINE UIPPMO
133
 
 * *****************
134
 
 *
135
 
 * INTEGER          IPPMOD <--  specific physics indicator array
136
 
 * INTEGER          ICOD3P  --> diffusion flame in fast complete chemistry
137
 
 * INTEGER          ICODEQ  --> diffusion flame in fast chemistry towards balance
138
 
 * INTEGER          ICOEBU  --> Eddy Break Up premixing flame
139
 
 * INTEGER          ICOBML  --> Bray - Moss - Libby premixing flame
140
 
 * INTEGER          ICOLWC  --> Libby Williams premixing flame
141
 
 * INTEGER          ICP3PL  --> Coal combustion. Combustible moyen local
142
 
 * INTEGER          ICPL3C  --> Coal combustion coupled with lagrangien approach
143
 
 * INTEGER          ICFUEL  --> Fuel combustion
144
 
 * INTEGER          IELJOU  --> Joule effect
145
 
 * INTEGER          IELARC  --> electrical arc
146
 
 * INTEGER          IELION  --> ionique mobility
147
 
 * INTEGER          ICOMPF  --> compressible without shock
148
 
 * INTEGER          IATMOS  --> atmospheric flows
149
 
 * INTEGER          IAEROS  --> cooling tower
150
 
 * INTEGER          INDJON  --> INDJON=1: a JANAF enthalpy-temperature
151
 
 *                              tabulation is used. INDJON=1: users tabulation
152
 
 * INTEGER          IEQCO2  --> CO2 massic fraction transport
153
 
 *
154
 
 *----------------------------------------------------------------------------*/
155
 
 
156
 
void CS_PROCF (uippmo, UIPPMO)(int *const ippmod,
157
 
                               int *const icod3p,
158
 
                               int *const icodeq,
159
 
                               int *const icoebu,
160
 
                               int *const icobml,
161
 
                               int *const icolwc,
162
 
                               int *const icp3pl,
163
 
                               int *const icpl3c,
164
 
                               int *const icfuel,
165
 
                               int *const ieljou,
166
 
                               int *const ielarc,
167
 
                               int *const ielion,
168
 
                               int *const icompf,
169
 
                               int *const iatmos,
170
 
                               int *const iaeros,
171
 
                               int *const indjon,
172
 
                               int *const ieqco2)
173
 
{
174
 
    int isactiv = 0;
175
 
    int nscapp = 0;
176
 
 
177
 
    cs_var_t  *vars = cs_glob_var;
178
 
 
179
 
    ippmod[*icod3p - 1] = -1;
180
 
    ippmod[*icodeq - 1] = -1;
181
 
    ippmod[*icoebu - 1] = -1;
182
 
    ippmod[*icobml - 1] = -1;
183
 
    ippmod[*icolwc - 1] = -1;
184
 
    ippmod[*icp3pl - 1] = -1;
185
 
    ippmod[*icpl3c - 1] = -1;
186
 
    ippmod[*icfuel - 1] = -1;
187
 
    ippmod[*ieljou - 1] = -1;
188
 
    ippmod[*ielarc - 1] = -1;
189
 
    ippmod[*ielion - 1] = -1;
190
 
    ippmod[*icompf - 1] = -1;
191
 
    ippmod[*iatmos - 1] = -1;
192
 
    ippmod[*iaeros - 1] = -1;
193
 
 
194
 
    *indjon = 1;
195
 
    *ieqco2 = 0;
196
 
 
197
 
    /* Look for the active specific physics and give the value of the associated
198
 
       model attribute */
199
 
    isactiv = cs_gui_get_activ_thermophysical_model();
200
 
 
201
 
    if (isactiv)
202
 
    {
203
 
        if (cs_gui_strcmp(vars->model, "pulverized_coal"))
204
 
        {
205
 
            if (cs_gui_strcmp(vars->model_value, "coal_homo"))
206
 
                ippmod[*icp3pl - 1] = 0;
207
 
            else if (cs_gui_strcmp(vars->model_value, "coal_homo2"))
208
 
                ippmod[*icp3pl - 1] = 1;
209
 
            else
210
 
                bft_error(__FILE__, __LINE__, 0,
211
 
                          _("Invalid coal model: %s.\n"), vars->model_value);
212
 
        }
213
 
        else if  (cs_gui_strcmp(vars->model, "atmospheric_flows"))
214
 
        {
215
 
            if (cs_gui_strcmp(vars->model_value, "constant"))
216
 
                ippmod[*iatmos - 1] = 0;
217
 
            else if (cs_gui_strcmp(vars->model_value, "dry"))
218
 
                ippmod[*iatmos - 1] = 1;
219
 
            else if (cs_gui_strcmp(vars->model_value, "humid"))
220
 
                ippmod[*iatmos - 1] = 2;
221
 
            else
222
 
                bft_error(__FILE__, __LINE__, 0,
223
 
                          _("Invalid atmospheric flow model: %s.\n"),
224
 
                          vars->model_value);
225
 
        }
226
 
 
227
 
        /* If the model is active, one only takes the specific physics scalars */
228
 
        nscapp = _scalar_number(vars->model);
229
 
    }
230
 
 
231
 
    vars->nscapp = nscapp;
232
 
 
233
 
#if _XML_DEBUG_
234
 
    bft_printf("==>UIPPMO\n");
235
 
    if (isactiv)
236
 
    {
237
 
        bft_printf("--thermophysical model: %s\n", vars->model);
238
 
        bft_printf("--thermophysical value: %s\n", vars->model_value);
239
 
        bft_printf("--model scalars number: %i\n", vars->nscapp);
240
 
    }
241
 
#endif
242
 
 
243
 
}
244
 
 
245
 
/*----------------------------------------------------------------------------
246
 
 * Density under relaxation
247
 
 *
248
 
 * Fortran Interface:
249
 
 *
250
 
 * SUBROUTINE UICPI1 (SRROM)
251
 
 * *****************
252
 
 * DOUBLE PRECISION SRROM   <--   density relaxation
253
 
 *----------------------------------------------------------------------------*/
254
 
 
255
 
void CS_PROCF (uicpi1, UICPI1) (double *const srrom)
256
 
{
257
 
  cs_gui_numerical_double_parameters("density_relaxation", srrom);
258
 
 
259
 
#if _XML_DEBUG_
260
 
  bft_printf("==>UICPI1\n");
261
 
  bft_printf("--srrom  = %f\n", *srrom);
262
 
#endif
263
 
}
264
 
 
265
 
/*-----------------------------------------------------------------------------
266
 
 * Indirection between the solver numbering and the XML one
267
 
 * for physical properties of the activated specific physics
268
 
 *----------------------------------------------------------------------------*/
269
 
 
270
 
void CS_PROCF (uicppr, UICPPR) (const int *const nclass,
271
 
                                const int *const nsalpp,
272
 
                                const int *const nsalto,
273
 
                                const int *const ippmod,
274
 
                                const int *const icp3pl,
275
 
                                const int *const ipppro,
276
 
                                const int *const ipproc,
277
 
                                const int *const ihtco2,
278
 
                                const int *const itemp1,
279
 
                                const int *const irom1,
280
 
                                const int *const iym1,
281
 
                                const int *const immel,
282
 
                                const int *const itemp2,
283
 
                                const int *const ix2,
284
 
                                const int *const irom2,
285
 
                                const int *const idiam2,
286
 
                                const int *const igmdch,
287
 
                                const int *const igmdv1,
288
 
                                const int *const igmdv2,
289
 
                                const int *const igmhet,
290
 
                                const int *const ighco2,
291
 
                                const int *const igmsec)
292
 
{
293
 
  int i = 0;
294
 
  int n;
295
 
  char *name = NULL;
296
 
  char *snumpp = NULL;
297
 
 
298
 
  cs_var_t  *vars = cs_glob_var;
299
 
 
300
 
  n = vars->nprop;
301
 
  vars->nprop  += *nsalpp;
302
 
  vars->nsalpp  = *nsalpp;
303
 
 
304
 
  BFT_REALLOC(vars->properties_ipp,  vars->nprop, int);
305
 
  BFT_REALLOC(vars->propce,          vars->nprop, int);
306
 
  BFT_REALLOC(vars->properties_name, vars->nprop, char*);
307
 
 
308
 
 /* ITEMP1 */
309
 
  vars->properties_ipp[n] = ipppro[ ipproc[ *itemp1 -1 ]-1 ];
310
 
  vars->propce[n] = *itemp1;
311
 
  BFT_MALLOC(vars->properties_name[n], strlen("Temp_GAZ")+1, char);
312
 
  strcpy(vars->properties_name[n++], "Temp_GAZ");
313
 
 
314
 
 /* IROM1 */
315
 
  vars->properties_ipp[n] = ipppro[ ipproc[ *irom1 -1 ]-1 ];
316
 
  vars->propce[n] = *irom1;
317
 
  BFT_MALLOC(vars->properties_name[n], strlen("ROM_GAZ")+1, char);
318
 
  strcpy(vars->properties_name[n++], "ROM_GAZ");
319
 
 
320
 
 /*  YM_CHX1M */
321
 
  vars->properties_ipp[n] = ipppro[ ipproc[ iym1[0] -1 ]-1 ];
322
 
  vars->propce[n] = iym1[0];
323
 
  BFT_MALLOC(vars->properties_name[n], strlen("YM_CHx1m")+1, char);
324
 
  strcpy(vars->properties_name[n++], "YM_CHx1m");
325
 
 
326
 
 /*  YM_CHX2M */
327
 
  vars->properties_ipp[n] = ipppro[ ipproc[ iym1[1] -1 ]-1 ];
328
 
  vars->propce[n] = iym1[1];
329
 
  BFT_MALLOC(vars->properties_name[n], strlen("YM_CHx2m")+1, char);
330
 
  strcpy(vars->properties_name[n++], "YM_CHx2m");
331
 
 
332
 
 /*  YM_CO */
333
 
  vars->properties_ipp[n] = ipppro[ ipproc[ iym1[2] -1 ]-1 ];
334
 
  vars->propce[n] = iym1[2];
335
 
  BFT_MALLOC(vars->properties_name[n], strlen("YM_CO")+1, char);
336
 
  strcpy(vars->properties_name[n++], "YM_CO");
337
 
 
338
 
 /*  YM_O2 */
339
 
  vars->properties_ipp[n] = ipppro[ ipproc[ iym1[3] -1 ]-1 ];
340
 
  vars->propce[n] = iym1[3];
341
 
  BFT_MALLOC(vars->properties_name[n], strlen("YM_O2")+1, char);
342
 
  strcpy(vars->properties_name[n++], "YM_O2");
343
 
 
344
 
 /*  YM_CO2 */
345
 
  vars->properties_ipp[n] = ipppro[ ipproc[ iym1[4] -1 ]-1 ];
346
 
  vars->propce[n] = iym1[4];
347
 
  BFT_MALLOC(vars->properties_name[n], strlen("YM_CO2")+1, char);
348
 
  strcpy(vars->properties_name[n++], "YM_CO2");
349
 
 
350
 
 /*  YM_H2O */
351
 
  vars->properties_ipp[n] = ipppro[ ipproc[ iym1[5] -1 ]-1 ];
352
 
  vars->propce[n] = iym1[5];
353
 
  BFT_MALLOC(vars->properties_name[n], strlen("YM_H2O")+1, char);
354
 
  strcpy(vars->properties_name[n++], "YM_H2O");
355
 
 
356
 
 /*  YM_N2 */
357
 
  vars->properties_ipp[n] = ipppro[ ipproc[ iym1[6] -1 ]-1 ];
358
 
  vars->propce[n] = iym1[6];
359
 
  BFT_MALLOC(vars->properties_name[n], strlen("YM_N2")+1, char);
360
 
  strcpy(vars->properties_name[n++], "YM_N2");
361
 
 
362
 
 /* IMEL */
363
 
  vars->properties_ipp[n] = ipppro[ ipproc[ *immel -1 ]-1 ];
364
 
  vars->propce[n] = *immel;
365
 
  BFT_MALLOC(vars->properties_name[n], strlen("XM")+1, char);
366
 
  strcpy(vars->properties_name[n++], "XM");
367
 
 
368
 
  /* ITEMP2 loop on classes */
369
 
  BFT_MALLOC(name, strlen("Temp_CP")+1 + 2, char);
370
 
  BFT_MALLOC(snumpp, 1 + 2, char);
371
 
  strcpy(name, "Temp_CP");
372
 
  for (i = 0; i < *nclass; i++) {
373
 
    sprintf(snumpp, "%2.2i", i+1);
374
 
    strcat(name, snumpp);
375
 
 
376
 
    vars->properties_ipp[n] = ipppro[ ipproc[ itemp2[i] -1 ]-1 ];
377
 
    vars->propce[n] = itemp2[i];
378
 
    BFT_MALLOC(vars->properties_name[n], strlen(name)+1, char);
379
 
    strcpy(vars->properties_name[n++], name);
380
 
 
381
 
    strcpy(name, "Temp_CP");
382
 
  }
383
 
 
384
 
 /* IX2 loop on classes */
385
 
  BFT_REALLOC(name, strlen("Frm_CP")+1 + 2, char);
386
 
  strcpy(name, "Frm_CP");
387
 
  for (i = 0; i < *nclass; i++) {
388
 
    sprintf(snumpp, "%2.2i", i+1);
389
 
    strcat(name, snumpp);
390
 
 
391
 
    vars->properties_ipp[n] = ipppro[ ipproc[ ix2[i] -1 ]-1 ];
392
 
    vars->propce[n] = ix2[i];
393
 
    BFT_MALLOC(vars->properties_name[n], strlen(name)+1, char);
394
 
    strcpy(vars->properties_name[n++], name);
395
 
 
396
 
    strcpy(name, "Frm_CP");
397
 
  }
398
 
 
399
 
 /* IROM2 loop on classes */
400
 
  BFT_REALLOC(name, strlen("Rho_CP")+1 + 2, char);
401
 
  strcpy(name, "Rho_CP");
402
 
  for (i = 0; i < *nclass; i++) {
403
 
    sprintf(snumpp, "%2.2i", i+1);
404
 
    strcat(name, snumpp);
405
 
 
406
 
    vars->properties_ipp[n] = ipppro[ ipproc[ irom2[i] -1 ]-1 ];
407
 
    vars->propce[n] = irom2[i];
408
 
    BFT_MALLOC(vars->properties_name[n], strlen(name)+1, char);
409
 
    strcpy(vars->properties_name[n++], name);
410
 
 
411
 
    strcpy(name, "Rho_CP");
412
 
  }
413
 
 
414
 
 /* IDIAM2 loop on classes */
415
 
  BFT_REALLOC(name, strlen("Dia_CK")+1 + 2, char);
416
 
  strcpy(name, "Dia_CK");
417
 
  for (i = 0; i < *nclass; i++) {
418
 
    sprintf(snumpp, "%2.2i", i+1);
419
 
    strcat(name, snumpp);
420
 
 
421
 
    vars->properties_ipp[n] = ipppro[ ipproc[ idiam2[i] -1 ]-1 ];
422
 
    vars->propce[n] = idiam2[i];
423
 
    BFT_MALLOC(vars->properties_name[n], strlen(name)+1, char);
424
 
    strcpy(vars->properties_name[n++], name);
425
 
 
426
 
    strcpy(name, "Dia_CK");
427
 
  }
428
 
 
429
 
 /* IGMDCH loop on classes */
430
 
  BFT_REALLOC(name, strlen("Ga_DCH")+1 + 2, char);
431
 
  strcpy(name, "Ga_DCH");
432
 
  for (i = 0; i < *nclass; i++) {
433
 
    sprintf(snumpp, "%2.2i", i+1);
434
 
    strcat(name, snumpp);
435
 
 
436
 
    vars->properties_ipp[n] = ipppro[ ipproc[ igmdch[i] -1 ]-1 ];
437
 
    vars->propce[n] = igmdch[i];
438
 
    BFT_MALLOC(vars->properties_name[n], strlen(name)+1, char);
439
 
    strcpy(vars->properties_name[n++], name);
440
 
 
441
 
    strcpy(name, "Ga_DCH");
442
 
  }
443
 
 
444
 
 /* IGMDV1 loop on classes */
445
 
  BFT_REALLOC(name, strlen("Ga_DV1")+1 + 2, char);
446
 
  strcpy(name, "Ga_DV1");
447
 
  for (i = 0; i < *nclass; i++) {
448
 
    sprintf(snumpp, "%2.2i", i+1);
449
 
    strcat(name, snumpp);
450
 
 
451
 
    vars->properties_ipp[n] = ipppro[ ipproc[ igmdv1[i] -1 ]-1 ];
452
 
    vars->propce[n] = igmdv1[i];
453
 
    BFT_MALLOC(vars->properties_name[n], strlen(name)+1, char);
454
 
    strcpy(vars->properties_name[n++], name);
455
 
 
456
 
    strcpy(name, "Ga_DV1");
457
 
  }
458
 
 
459
 
 /* IGMDV2 loop on classes */
460
 
  BFT_REALLOC(name, strlen("Ga_DV2")+1 + 2, char);
461
 
  strcpy(name, "Ga_DV2");
462
 
  for (i = 0; i < *nclass; i++) {
463
 
    sprintf(snumpp, "%2.2i", i+1);
464
 
    strcat(name, snumpp);
465
 
 
466
 
    vars->properties_ipp[n] = ipppro[ ipproc[ igmdv2[i] -1 ]-1 ];
467
 
    vars->propce[n] = igmdv2[i];
468
 
    BFT_MALLOC(vars->properties_name[n], strlen(name)+1, char);
469
 
    strcpy(vars->properties_name[n++], name);
470
 
 
471
 
    strcpy(name, "Ga_DV2");
472
 
  }
473
 
 
474
 
 /* IGMHET loop on classes */
475
 
  BFT_REALLOC(name, strlen("Ga_HET_O2")+1 + 2, char);
476
 
  strcpy(name, "Ga_HET_O2");
477
 
  for (i = 0; i < *nclass; i++) {
478
 
    sprintf(snumpp, "%2.2i", i+1);
479
 
    strcat(name, snumpp);
480
 
 
481
 
    vars->properties_ipp[n] = ipppro[ ipproc[ igmhet[i] -1 ]-1 ];
482
 
    vars->propce[n] = igmhet[i];
483
 
    BFT_MALLOC(vars->properties_name[n], strlen(name)+1, char);
484
 
    strcpy(vars->properties_name[n++], name);
485
 
 
486
 
    strcpy(name, "Ga_HET_O2");
487
 
  }
488
 
 
489
 
    if (*ihtco2 == 1)
490
 
    {
491
 
        /* IGHCO2 loop on classes */
492
 
        BFT_REALLOC(name, strlen("Ga_HET_CO2")+1 + 2, char);
493
 
        strcpy(name, "Ga_HET_CO2");
494
 
        for (i = 0; i < *nclass; i++)
495
 
        {
496
 
            sprintf(snumpp, "%2.2i", i+1);
497
 
            strcat(name, snumpp);
498
 
 
499
 
            vars->properties_ipp[n] = ipppro[ ipproc[ ighco2[i] -1 ]-1 ];
500
 
            vars->propce[n] = ighco2[i];
501
 
            BFT_MALLOC(vars->properties_name[n], strlen(name)+1, char);
502
 
            strcpy(vars->properties_name[n++], name);
503
 
 
504
 
           strcpy(name, "Ga_HET_CO2");
505
 
        }
506
 
    }
507
 
 
508
 
    if (ippmod[*icp3pl -1] == 1)
509
 
    {
510
 
        /* IGMSEC loop on classes */
511
 
        BFT_REALLOC(name, strlen("Ga_SEC")+1 + 2, char);
512
 
        strcpy(name, "Ga_SEC");
513
 
        for (i = 0; i < *nclass; i++)
514
 
        {
515
 
            sprintf(snumpp, "%2.2i", i+1);
516
 
            strcat(name, snumpp);
517
 
 
518
 
            vars->properties_ipp[n] = ipppro[ ipproc[ igmsec[i] -1 ]-1 ];
519
 
            vars->propce[n] = igmsec[i];
520
 
            BFT_MALLOC(vars->properties_name[n], strlen(name)+1, char);
521
 
            strcpy(vars->properties_name[n++], name);
522
 
 
523
 
            strcpy(name, "Ga_SEC");
524
 
        }
525
 
    }
526
 
 
527
 
  BFT_FREE(name);
528
 
  BFT_FREE(snumpp);
529
 
 
530
 
  if (n != vars->nsalpp)
531
 
    bft_error(__FILE__, __LINE__, 0,
532
 
              _("number of properties is not correct: %i instead of: %i\n"),
533
 
                n, vars->nsalpp);
534
 
 
535
 
#if _XML_DEBUG_
536
 
  bft_printf("==>UICPPR\n");
537
 
  bft_printf("-->nombre de proprietes = %i\n", vars->nprop);
538
 
  for (i=0 ; i<vars->nprop ; i++)
539
 
    bft_printf("-->properties_ipp[%i]: %i propce[%i]: %i "
540
 
                 "properties_name[%i]: %s\n",
541
 
                 i, vars->properties_ipp[i],
542
 
                 i, vars->propce[i],
543
 
                 i, vars->properties_name[i]);
544
 
#endif
545
 
}
546
 
 
547
 
/*------------------------------------------------------------------------------
548
 
 * Indirection between the solver numbering and the XML one
549
 
 * for the model scalar
550
 
 *----------------------------------------------------------------------------*/
551
 
 
552
 
void CS_PROCF (uicpsc, UICPSC) (const int *const ncharb,
553
 
                                const int *const nclass,
554
 
                                const int *const noxyd,
555
 
                                const int *const ippmod,
556
 
                                const int *const icp3pl,
557
 
                                const int *const ieqco2,
558
 
                                const int *const ihtco2,
559
 
                                const int *const ihm,
560
 
                                const int *const inp,
561
 
                                const int *const ixch,
562
 
                                const int *const ixck,
563
 
                                const int *const ixwt,
564
 
                                const int *const ih2,
565
 
                                const int *const if1m,
566
 
                                const int *const if2m,
567
 
                                const int *const if3m,
568
 
                                const int *const if3mc2,
569
 
                                const int *const if4p2m,
570
 
                                const int *const if5m,
571
 
                                const int *const if6m,
572
 
                                const int *const if7m,
573
 
                                const int *const iyco2)
574
 
{
575
 
  int i;
576
 
  char *name = NULL;
577
 
  char *snumsca = NULL;
578
 
 
579
 
  cs_var_t  *vars = cs_glob_var;
580
 
 
581
 
  if (vars->nscaus > 0) {
582
 
    BFT_REALLOC(vars->label, vars->nscapp + vars->nscaus, char*);
583
 
  } else {
584
 
    BFT_MALLOC(vars->label, vars->nscapp, char*);
585
 
  }
586
 
 
587
 
  /* IHM */
588
 
  BFT_MALLOC(vars->label[*ihm -1], strlen("Enthalpy")+1, char);
589
 
  strcpy(vars->label[*ihm -1], "Enthalpy");
590
 
 
591
 
  /* Loop on classes IH2, INP, IXCH, IXCK */
592
 
  BFT_MALLOC(snumsca, 1 + 2, char);
593
 
 
594
 
  /* IH2 */
595
 
  BFT_MALLOC(name, strlen("ENT_CP")+1 + 2, char);
596
 
  strcpy(name, "ENT_CP");
597
 
  for (i = 0; i < *nclass; i++) {
598
 
    sprintf(snumsca,"%2.2i", i+1);
599
 
    strcat(name, snumsca);
600
 
 
601
 
    BFT_MALLOC(vars->label[ih2[i] -1], strlen(name)+1, char);
602
 
    strcpy(vars->label[ih2[i] -1], name);
603
 
 
604
 
    strcpy(name, "ENT_CP");
605
 
  }
606
 
 
607
 
  /* INP */
608
 
  BFT_REALLOC(name, strlen("NP_CP")+1 + 2, char);
609
 
  strcpy(name, "NP_CP");
610
 
  for (i = 0; i < *nclass; i++) {
611
 
    sprintf(snumsca,"%2.2i", i+1);
612
 
    strcat(name, snumsca);
613
 
 
614
 
    BFT_MALLOC(vars->label[inp[i] -1], strlen(name)+1, char);
615
 
    strcpy(vars->label[inp[i] -1], name);
616
 
 
617
 
    strcpy(name, "NP_CP");
618
 
  }
619
 
 
620
 
  /* IXCH */
621
 
  BFT_REALLOC(name, strlen("XCH_CP")+1 + 2, char);
622
 
  strcpy(name, "XCH_CP");
623
 
  for (i = 0; i < *nclass; i++) {
624
 
    sprintf(snumsca,"%2.2i", i+1);
625
 
    strcat(name, snumsca);
626
 
 
627
 
    BFT_MALLOC(vars->label[ixch[i] -1], strlen(name)+1, char);
628
 
    strcpy(vars->label[ixch[i] -1], name);
629
 
 
630
 
    strcpy(name, "XCH_CP");
631
 
  }
632
 
 
633
 
  /* IXCK */
634
 
  BFT_REALLOC(name, strlen("XCK_CP")+1 + 2, char);
635
 
  strcpy(name, "XCK_CP");
636
 
  for (i = 0; i < *nclass; i++) {
637
 
    sprintf(snumsca,"%2.2i", i+1);
638
 
    strcat(name, snumsca);
639
 
 
640
 
    BFT_MALLOC(vars->label[ixck[i] -1], strlen(name)+1, char);
641
 
    strcpy(vars->label[ixck[i] -1], name);
642
 
 
643
 
    strcpy(name, "XCK_CP");
644
 
  }
645
 
 
646
 
  /* Loop on coals IFM1 IFM2 */
647
 
 
648
 
  BFT_REALLOC(name, strlen("Fr_MV1")+1 + 2, char);
649
 
  strcpy(name, "Fr_MV1");
650
 
  for (i = 0; i < *ncharb; i++) {
651
 
    sprintf(snumsca,"%2.2i",i+1);
652
 
    strcat(name, snumsca);
653
 
 
654
 
    BFT_MALLOC(vars->label[if1m[i] -1], strlen(name)+1, char);
655
 
    strcpy(vars->label[if1m[i] -1], name);
656
 
 
657
 
    strcpy(name, "Fr_MV1");
658
 
  }
659
 
 
660
 
  BFT_REALLOC(name, strlen("Fr_MV2")+1 + 2, char);
661
 
  strcpy(name, "Fr_MV2");
662
 
  for (i = 0; i < *ncharb; i++) {
663
 
    sprintf(snumsca,"%2.2i",i+1);
664
 
    strcat(name, snumsca);
665
 
 
666
 
    BFT_MALLOC(vars->label[if2m[i] -1], strlen(name)+1, char);
667
 
    strcpy(vars->label[if2m[i] -1], name);
668
 
 
669
 
    strcpy(name, "Fr_MV2");
670
 
  }
671
 
 
672
 
    /* IF3M */
673
 
    BFT_MALLOC(vars->label[*if3m -1], strlen("Fr_HET_O2")+1, char);
674
 
    strcpy(vars->label[*if3m -1], "Fr_HET_O2");
675
 
 
676
 
    if (*ihtco2 == 1)
677
 
    {
678
 
        /* IF3MC2 */
679
 
        BFT_MALLOC(vars->label[*if3mc2 -1], strlen("Fr_HET_CO2")+1, char);
680
 
        strcpy(vars->label[*if3mc2 -1], "Fr_HET_CO2");
681
 
    }
682
 
 
683
 
    /* IF4P2M */
684
 
    BFT_MALLOC(vars->label[*if4p2m -1], strlen("Var_AIR")+1, char);
685
 
    strcpy(vars->label[*if4p2m -1], "Var_AIR");
686
 
 
687
 
    if (ippmod[*icp3pl -1] == 1)
688
 
    {
689
 
        /* IXWT */
690
 
        BFT_MALLOC(name, strlen("XWT_CP")+1 + 2, char);
691
 
        strcpy(name, "XWT_CP");
692
 
        for (i = 0; i < *nclass; i++)
693
 
        {
694
 
            sprintf(snumsca,"%2.2i", i+1);
695
 
            strcat(name, snumsca);
696
 
 
697
 
            BFT_MALLOC(vars->label[ixwt[i] -1], strlen(name)+1, char);
698
 
            strcpy(vars->label[ixwt[i] -1], name);
699
 
            strcpy(name, "XWT_CP");
700
 
        }
701
 
 
702
 
        /* IF5M */
703
 
        BFT_MALLOC(vars->label[*if5m -1], strlen("FR_H20")+1, char);
704
 
        strcpy(vars->label[*if5m -1], "FR_H20");
705
 
    }
706
 
 
707
 
 
708
 
    if (*noxyd >= 2)
709
 
    {
710
 
        /* IF6M */
711
 
        BFT_MALLOC(vars->label[*if6m -1], strlen("FR_OXYD2")+1, char);
712
 
        strcpy(vars->label[*if6m -1], "FR_OXYD2");
713
 
    }
714
 
 
715
 
    if (*noxyd == 3)
716
 
    {
717
 
        /* IF7M */
718
 
        BFT_MALLOC(vars->label[*if7m -1], strlen("FR_OXYD3")+1, char);
719
 
        strcpy(vars->label[*if7m -1], "FR_OXYD3");
720
 
    }
721
 
 
722
 
    if (*ieqco2 == 1)
723
 
    {
724
 
        /* IYCO2 */
725
 
        BFT_MALLOC(vars->label[*iyco2 -1], strlen("FR_CO2")+1, char);
726
 
        strcpy(vars->label[*iyco2 -1], "FR_CO2");
727
 
    }
728
 
 
729
 
  BFT_FREE(name);
730
 
  BFT_FREE(snumsca);
731
 
 
732
 
#if _XML_DEBUG_
733
 
  bft_printf("==>UICPSC\n");
734
 
  for (i=0; i< vars->nscaus+vars->nscapp; i++)
735
 
      bft_printf("--label of scalar[%i]: %s\n", i, vars->label[i]);
736
 
#endif
737
 
 
738
 
}
739
 
 
740
 
/*----------------------------------------------------------------------------
741
 
 * Atmospheric flows: read of meteorological file of data
742
 
 *
743
 
 * Fortran Interface:
744
 
 *
745
 
 * subroutine uiati1
746
 
 * *****************
747
 
 * integer         imeteo   <--   on/off index
748
 
 *----------------------------------------------------------------------------*/
749
 
 
750
 
void CS_PROCF (uiati1, UIATI1) (int *const imeteo)
751
 
{
752
 
    char *path   = NULL;
753
 
    int   status = 0;
754
 
 
755
 
    path = cs_xpath_init_path();
756
 
    cs_xpath_add_elements(&path, 3, "thermophysical_models",
757
 
                                    "atmospheric_flows",
758
 
                                    "read_meteo_data");
759
 
 
760
 
    cs_xpath_add_attribute(&path, "status");
761
 
    if (cs_gui_get_status(path, &status))
762
 
        *imeteo = status;
763
 
    BFT_FREE(path);
764
 
 
765
 
#if _XML_DEBUG_
766
 
    bft_printf("==>UIATI1\n");
767
 
    bft_printf("--imeteo  = %i\n", *imeteo);
768
 
#endif
769
 
}
770
 
 
771
 
/*----------------------------------------------------------------------------
772
 
 * Atmospheric flows: indirection between the solver numbering and the XML one
773
 
 * for physical properties.
774
 
 *
775
 
 * Fortran Interface:
776
 
 *
777
 
 * subroutine uiatpr
778
 
 * *****************
779
 
 * integer         nsalpp   -->
780
 
 * integer         nsalto   -->
781
 
 * integer         ippmod   -->   specific physics indicator array
782
 
 * integer         iatmos   -->   index for atmospheric flow
783
 
 * integer         ipppro   -->
784
 
 * integer         ipproc   -->
785
 
 * integer         itempc   -->   index for real temperature
786
 
 * integer         iliqwt   -->   index for liquid water
787
 
 *----------------------------------------------------------------------------*/
788
 
 
789
 
void CS_PROCF (uiatpr, UIATPR) (const int *const nsalpp,
790
 
                                const int *const nsalto,
791
 
                                const int *const ippmod,
792
 
                                const int *const iatmos,
793
 
                                const int *const ipppro,
794
 
                                const int *const ipproc,
795
 
                                const int *const itempc,
796
 
                                const int *const iliqwt)
797
 
{
798
 
    int n;
799
 
    cs_var_t *vars = cs_glob_var;
800
 
 
801
 
    n = vars->nprop;
802
 
    vars->nprop  += *nsalpp;
803
 
    vars->nsalpp  = *nsalpp;
804
 
 
805
 
    BFT_REALLOC(vars->properties_ipp,  vars->nprop, int);
806
 
    BFT_REALLOC(vars->propce,          vars->nprop, int);
807
 
    BFT_REALLOC(vars->properties_name, vars->nprop, char*);
808
 
 
809
 
    /* itempc */
810
 
    vars->properties_ipp[n] = ipppro[ ipproc[ *itempc -1 ]-1 ];
811
 
    vars->propce[n] = *itempc;
812
 
    BFT_MALLOC(vars->properties_name[n], strlen("real_temperature")+1, char);
813
 
    strcpy(vars->properties_name[n++], "real_temperature");
814
 
 
815
 
    if (ippmod[*iatmos -1] == 2)
816
 
    {
817
 
        /* iliqwt */
818
 
        vars->properties_ipp[n] = ipppro[ ipproc[ *iliqwt -1 ]-1 ];
819
 
        vars->propce[n] = *iliqwt;
820
 
        BFT_MALLOC(vars->properties_name[n], strlen("liquid_water")+1, char);
821
 
        strcpy(vars->properties_name[n++], "liquid_water");
822
 
    }
823
 
#if _XML_DEBUG_
824
 
    {
825
 
        int i;
826
 
        bft_printf("==>UIATPR\n");
827
 
        bft_printf("-->nombre de proprietes = %i\n", vars->nprop);
828
 
        for (i=0 ; i<vars->nprop ; i++)
829
 
            bft_printf("-->properties_ipp[%i]: %i propce[%i]: %i "
830
 
                       "properties_name[%i]: %s\n",
831
 
                       i, vars->properties_ipp[i],
832
 
                       i, vars->propce[i],
833
 
                       i, vars->properties_name[i]);
834
 
    }
835
 
#endif
836
 
}
837
 
 
838
 
/*----------------------------------------------------------------------------
839
 
 * Atmospheric flows: indirection between the solver numbering and the XML one
840
 
 * for models scalars.
841
 
 *
842
 
 * Fortran Interface:
843
 
 *
844
 
 * subroutine uiatsc
845
 
 * *****************
846
 
 * integer         ippmod   -->   specific physics indicator array
847
 
 * integer         iatmos   -->   index for atmospheric flow
848
 
 * integer         itempp   -->   index for potential temperature
849
 
 * integer         itempl   -->   index for liquid potential temperature
850
 
 * integer         itotwt   -->   index for total water content
851
 
 * integer         intdrp   -->   index for total number of droplets
852
 
 *----------------------------------------------------------------------------*/
853
 
 
854
 
void CS_PROCF (uiatsc, UIATSC) (const int *const ippmod,
855
 
                                const int *const iatmos,
856
 
                                const int *const itempp,
857
 
                                const int *const itempl,
858
 
                                const int *const itotwt,
859
 
                                const int *const intdrp)
860
 
{
861
 
    cs_var_t  *vars = cs_glob_var;
862
 
 
863
 
    if (vars->nscaus > 0)
864
 
    {
865
 
        BFT_REALLOC(vars->label, vars->nscapp + vars->nscaus, char*);
866
 
    }
867
 
    else
868
 
    {
869
 
        BFT_MALLOC(vars->label, vars->nscapp, char*);
870
 
    }
871
 
 
872
 
    if (ippmod[*iatmos -1] == 1)
873
 
    {
874
 
        /* itempp */
875
 
        BFT_MALLOC(vars->label[*itempp -1], strlen("potential_temperature")+1, char);
876
 
        strcpy(vars->label[*itempp -1], "potential_temperature");
877
 
    }
878
 
    else if (ippmod[*iatmos -1] == 2)
879
 
    {
880
 
        /* itempl */
881
 
        BFT_MALLOC(vars->label[*itempl -1], strlen("liquid_potential_temperature")+1, char);
882
 
        strcpy(vars->label[*itempl -1], "liquid_potential_temperature");
883
 
 
884
 
        /* itotwt */
885
 
        BFT_MALLOC(vars->label[*itotwt -1], strlen("total_water")+1, char);
886
 
        strcpy(vars->label[*itotwt -1], "total_water");
887
 
 
888
 
        /* intdrp */
889
 
        BFT_MALLOC(vars->label[*intdrp -1], strlen("number_of_droplets")+1, char);
890
 
        strcpy(vars->label[*intdrp -1], "number_of_droplets");
891
 
    }
892
 
#if _XML_DEBUG_
893
 
    {
894
 
        int i;
895
 
        bft_printf("==>UIATSC\n");
896
 
        for (i=0; i< vars->nscaus+vars->nscapp; i++)
897
 
            bft_printf("--label of scalar[%i]: %s\n", i, vars->label[i]);
898
 
    }
899
 
#endif
900
 
}
901
 
 
902
 
/*============================================================================
903
 
 * Public function definitions
904
 
 *============================================================================*/
905
 
 
906
 
/*-----------------------------------------------------------------------------
907
 
 * Return the name of a thermophysical model.
908
 
 *
909
 
 * parameter:
910
 
 *   model_thermo          -->  thermophysical model
911
 
 *----------------------------------------------------------------------------*/
912
 
 
913
 
char*
914
 
cs_gui_get_thermophysical_model(const char *const model_thermo)
915
 
{
916
 
  char *model = NULL;
917
 
  char *path = NULL;
918
 
 
919
 
  path = cs_xpath_init_path();
920
 
  cs_xpath_add_elements(&path, 2, "thermophysical_models", model_thermo);
921
 
  cs_xpath_add_attribute(&path, "model");
922
 
 
923
 
  model = cs_gui_get_attribute_value(path);
924
 
 
925
 
  BFT_FREE(path);
926
 
 
927
 
  return model;
928
 
}
929
 
 
930
 
/*-----------------------------------------------------------------------------
931
 
 * Return 1 if a specific physics model is activated. Store in the global
932
 
 * structure vars:
933
 
 *   vars->model         <= thermophysical model
934
 
 *   vars->model_value   <= related model name
935
 
 *----------------------------------------------------------------------------*/
936
 
 
937
 
int
938
 
cs_gui_get_activ_thermophysical_model(void)
939
 
{
940
 
    int i, isactiv = 0;
941
 
    char *value = NULL;
942
 
 
943
 
    cs_var_t  *vars = cs_glob_var;
944
 
 
945
 
    const char *name[] = { "pulverized_coal",
946
 
                           "gas_combustion",
947
 
                           "joule_effect",
948
 
                           "atmospheric_flows" };
949
 
    int name_nbr = sizeof(name) / sizeof(name[0]);
950
 
 
951
 
    if (vars->model != NULL && vars->model_value != NULL)
952
 
    {
953
 
        isactiv = 1;
954
 
        return isactiv;
955
 
    }
956
 
    else
957
 
    {
958
 
        vars->model = NULL;
959
 
        vars->model_value = NULL;
960
 
    }
961
 
 
962
 
    for (i = 0; i < name_nbr; i++)
963
 
    {
964
 
        value = cs_gui_get_thermophysical_model(name[i]);
965
 
 
966
 
        if (value && !cs_gui_strcmp(value, "off"))
967
 
        {
968
 
            BFT_MALLOC(vars->model, strlen(name[i])+1, char);
969
 
            strcpy(vars->model, name[i]);
970
 
 
971
 
            BFT_MALLOC(vars->model_value, strlen(value)+1, char);
972
 
            strcpy(vars->model_value, value);
973
 
 
974
 
            isactiv = 1;
975
 
            break;
976
 
        }
977
 
    }
978
 
 
979
 
    BFT_FREE(value);
980
 
 
981
 
    return isactiv;
982
 
}
983
 
 
984
 
/*----------------------------------------------------------------------------*/
985
 
 
986
 
END_C_DECLS