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

« back to all changes in this revision

Viewing changes to src/base/cs_gui_mobile_mesh.c

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2011-11-01 17:43:32 UTC
  • mto: (6.1.7 sid)
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: package-import@ubuntu.com-20111101174332-tl4vk45no0x3emc3
Tags: upstream-2.1.0
ImportĀ upstreamĀ versionĀ 2.1.0

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: mobile mesh
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_gui_boundary_conditions.h"
78
 
#include "cs_mesh.h"
79
 
#include "cs_prototypes.h"
80
 
 
81
 
/*----------------------------------------------------------------------------
82
 
 * Header for the current file
83
 
 *----------------------------------------------------------------------------*/
84
 
 
85
 
#include "cs_gui_mobile_mesh.h"
86
 
 
87
 
/*----------------------------------------------------------------------------*/
88
 
 
89
 
BEGIN_C_DECLS
90
 
 
91
 
/*=============================================================================
92
 
 * Local Macro Definitions
93
 
 *============================================================================*/
94
 
 
95
 
/* debugging switch */
96
 
#define _XML_DEBUG_ 0
97
 
 
98
 
/*============================================================================
99
 
 * Static variables
100
 
 *============================================================================*/
101
 
 
102
 
/*----------------------------------------------------------------------------
103
 
 *  ALE property choice possible value
104
 
 *----------------------------------------------------------------------------*/
105
 
 
106
 
enum ale_property_choice
107
 
{
108
 
  ale_property_choice_user_function,
109
 
  ale_property_choice_user_subroutine
110
 
};
111
 
 
112
 
/*-----------------------------------------------------------------------------
113
 
 * Possible values for boundary nature
114
 
 *----------------------------------------------------------------------------*/
115
 
 
116
 
enum ale_boundary_nature
117
 
{
118
 
    ale_boundary_nature_fixed_wall,
119
 
    ale_boundary_nature_sliding_wall,
120
 
    ale_boundary_nature_internal_coupling,
121
 
    ale_boundary_nature_external_coupling,
122
 
    ale_boundary_nature_fixed_velocity,
123
 
    ale_boundary_nature_fixed_displacement
124
 
};
125
 
 
126
 
/*============================================================================
127
 
 * Private function definitions
128
 
 *============================================================================*/
129
 
 
130
 
/*-----------------------------------------------------------------------------
131
 
 * Return value for iale method
132
 
 *
133
 
 * parameters:
134
 
 *   param               -->  iale parameter
135
 
 *   keyword             <--  value of the iale parameter
136
 
 *----------------------------------------------------------------------------*/
137
 
 
138
 
static void
139
 
cs_gui_iale_parameter(const char   *const param,
140
 
                            double *const keyword)
141
 
{
142
 
  char   *path   = NULL;
143
 
  char   *type = NULL;
144
 
  double  result = 0.0;
145
 
 
146
 
  path = cs_xpath_init_path();
147
 
  cs_xpath_add_elements(&path, 3, "thermophysical_models", "ale_method", param);
148
 
 
149
 
  if (cs_gui_strcmp(param,"mesh_viscosity")) {
150
 
 
151
 
    cs_xpath_add_attribute(&path, "type");
152
 
    type = cs_gui_get_attribute_value(path);
153
 
    if(cs_gui_strcmp(type, "isotrop"))
154
 
      *keyword = 0;
155
 
    else if (cs_gui_strcmp(type, "orthotrop"))
156
 
      *keyword = 1;
157
 
    else
158
 
      bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
159
 
 
160
 
  } else {
161
 
 
162
 
    cs_xpath_add_function_text(&path);
163
 
    if (cs_gui_get_double(path, &result)) *keyword = result;
164
 
 
165
 
  }
166
 
  BFT_FREE(type);
167
 
  BFT_FREE(path);
168
 
}
169
 
 
170
 
/*-----------------------------------------------------------------------------
171
 
 * Return the status of ALE method
172
 
 *
173
 
 * parameters:
174
 
 *   keyword        <--  status of ale balise
175
 
 *----------------------------------------------------------------------------*/
176
 
 
177
 
static void
178
 
cs_gui_get_ale_status(int  *const keyword)
179
 
{
180
 
  char *path = NULL;
181
 
  int   result;
182
 
 
183
 
  path = cs_xpath_init_path();
184
 
  cs_xpath_add_elements(&path, 2, "thermophysical_models", "ale_method");
185
 
  cs_xpath_add_attribute(&path, "status");
186
 
 
187
 
  if(cs_gui_get_status(path, &result))
188
 
    *keyword = result;
189
 
  else
190
 
    *keyword = 0;
191
 
 
192
 
 
193
 
  BFT_FREE(path);
194
 
}
195
 
 
196
 
/*-----------------------------------------------------------------------------
197
 
 * Return the viscosity's type of ALE method
198
 
 *
199
 
 * parameters:
200
 
 *   type        <--  type of viscosity's type
201
 
 *----------------------------------------------------------------------------*/
202
 
 
203
 
void
204
 
cs_gui_get_ale_viscosity_type(int  * type)
205
 
{
206
 
  char *path = NULL;
207
 
  char *buff = NULL;
208
 
 
209
 
  path = cs_xpath_init_path();
210
 
  cs_xpath_add_elements(&path, 3, "thermophysical_models", "ale_method", "mesh_viscosity");
211
 
  cs_xpath_add_attribute(&path, "type");
212
 
 
213
 
  buff = cs_gui_get_attribute_value(path);
214
 
 
215
 
  if (cs_gui_strcmp(buff, "orthotrop"))
216
 
    *type = 1;
217
 
  else if (cs_gui_strcmp(buff, "isotrop"))
218
 
    *type = 0;
219
 
  else
220
 
    bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
221
 
 
222
 
  BFT_FREE(path);
223
 
  BFT_FREE(buff);
224
 
}
225
 
 
226
 
 
227
 
/*============================================================================
228
 
 * Public function definitions
229
 
 *============================================================================*/
230
 
 
231
 
/*-----------------------------------------------------------------------------
232
 
 * Initialize mei tree and check for symbols existence
233
 
 *
234
 
 * parameters:
235
 
 *   formula        -->  mei formula
236
 
 *   symbols        -->  array of symbol to check
237
 
 *   symbol_nbr     -->  number of symbol in symbols
238
 
 *   variables      -->  variables required in the formula
239
 
 *   variable_nbr   -->  number of variable in variables
240
 
 *   dtref          -->   time step
241
 
 *   ttcabs         --> current time
242
 
 *   ntcabs         --> current iteration number
243
 
 *----------------------------------------------------------------------------*/
244
 
 
245
 
#ifdef HAVE_MEI
246
 
static mei_tree_t *
247
 
cs_gui_init_mei_tree(char         *formula,
248
 
                     const char   **symbols,
249
 
                     unsigned int symbol_nbr,
250
 
                     const char   **variables,
251
 
                     const double *variables_value,
252
 
                     unsigned int variable_nbr,
253
 
                     const double dtref,
254
 
                     const double ttcabs,
255
 
                     const int    ntcabs)
256
 
{
257
 
    unsigned int i = 0;
258
 
 
259
 
    /* return an empty interpreter */
260
 
    mei_tree_t *tree = mei_tree_new(formula);
261
 
 
262
 
    /* Insert variables into mei_tree */
263
 
    for (i = 0; i < variable_nbr; ++i)
264
 
    {
265
 
        double value = 0;
266
 
 
267
 
        /* Read value from variables_value if it is not null 0 otherwise */
268
 
        if (variables_value)
269
 
            value = variables_value[i];
270
 
        mei_tree_insert(tree, variables[i], value);
271
 
    }
272
 
 
273
 
    /* Add commun variables: dt, t, nbIter */
274
 
    mei_tree_insert(tree, "dt",   dtref);
275
 
    mei_tree_insert(tree, "t",    ttcabs);
276
 
    mei_tree_insert(tree, "iter", ntcabs);
277
 
 
278
 
    /* try to build the interpreter */
279
 
    if (mei_tree_builder(tree))
280
 
        bft_error(__FILE__, __LINE__, 0,
281
 
                      _("Error: can not interprete expression: %s\n"), tree->string);
282
 
 
283
 
    /* Check for symbols */
284
 
    for (i = 0; i < symbol_nbr; ++i)
285
 
    {
286
 
        const char* symbol = symbols[i];
287
 
 
288
 
        if (mei_tree_find_symbol(tree, symbol))
289
 
        {
290
 
            bft_error(__FILE__, __LINE__, 0,
291
 
                      _("Error: can not find the required symbol: %s\n"), symbol);
292
 
        }
293
 
    }
294
 
 
295
 
    return tree;
296
 
}
297
 
#endif /* HAVE_MEI */
298
 
 
299
 
/*----------------------------------------------------------------------------
300
 
 *  Get the ale property choice
301
 
 *----------------------------------------------------------------------------*/
302
 
 
303
 
static enum ale_property_choice
304
 
get_ale_property_choice(void)
305
 
{
306
 
    char *choice_str;
307
 
 
308
 
    enum ale_property_choice choice = ale_property_choice_user_function;
309
 
    char *path = cs_xpath_init_path();
310
 
 
311
 
    cs_xpath_add_elements(&path, 3, "thermophysical_models", "ale_method", "property");
312
 
    cs_xpath_add_test_attribute(&path, "label", "mesh_vi1");
313
 
    cs_xpath_add_attribute(&path, "choice");
314
 
 
315
 
    choice_str = cs_gui_get_attribute_value(path);
316
 
 
317
 
    if (cs_gui_strcmp(choice_str , "user_function"))
318
 
        choice = ale_property_choice_user_function;
319
 
    else if (cs_gui_strcmp(choice_str , "user_subroutine"))
320
 
        choice = ale_property_choice_user_subroutine;
321
 
    else
322
 
        bft_error(__FILE__, __LINE__, 0,
323
 
            _("Unknow ale property choice %s.\n"), choice);
324
 
    BFT_FREE(choice_str);
325
 
    BFT_FREE(path);
326
 
    return choice;
327
 
}
328
 
 
329
 
/*-----------------------------------------------------------------------------
330
 
 * Return the ale boundary nature
331
 
 *----------------------------------------------------------------------------*/
332
 
 
333
 
static char *
334
 
get_ale_formula(void)
335
 
{
336
 
    char *aleFormula;
337
 
 
338
 
    char *path = cs_xpath_short_path();
339
 
    cs_xpath_add_element(&path, "ale_method");
340
 
    cs_xpath_add_element(&path, "formula");
341
 
    cs_xpath_add_function_text(&path);
342
 
 
343
 
    aleFormula =  cs_gui_get_text_value(path);
344
 
    BFT_FREE(path);
345
 
    return aleFormula;
346
 
}
347
 
 
348
 
/*-----------------------------------------------------------------------------
349
 
 * Return the ale mesh viscosity
350
 
 *----------------------------------------------------------------------------*/
351
 
 
352
 
static char *
353
 
get_ale_mesh_viscosity(void)
354
 
{
355
 
    char *viscosityType;
356
 
 
357
 
    char *path = cs_xpath_short_path();
358
 
    cs_xpath_add_element(&path, "ale_method");
359
 
    cs_xpath_add_element(&path, "mesh_viscosity");
360
 
    cs_xpath_add_attribute(&path, "type");
361
 
 
362
 
    viscosityType = cs_gui_get_attribute_value(path);
363
 
    BFT_FREE(path);
364
 
    return viscosityType;
365
 
}
366
 
 
367
 
/*-----------------------------------------------------------------------------
368
 
 * Get the ale boundary formula
369
 
 *
370
 
 * parameters:
371
 
 *   label        --> boundary label
372
 
 *   choice       --> nature: "fixed_velocity" or "fixed_displacement"
373
 
 *----------------------------------------------------------------------------*/
374
 
 
375
 
static char*
376
 
get_ale_boundary_formula(const char *const label,
377
 
                                     const char *const choice)
378
 
{
379
 
    char* formula;
380
 
 
381
 
    char *path = cs_xpath_init_path();
382
 
    cs_xpath_add_elements(&path, 2, "boundary_conditions",  "wall");
383
 
    cs_xpath_add_test_attribute(&path, "label", label);
384
 
    cs_xpath_add_element(&path, "ale");
385
 
    cs_xpath_add_test_attribute(&path, "choice", choice);
386
 
    cs_xpath_add_element(&path, "formula");
387
 
    cs_xpath_add_function_text(&path);
388
 
 
389
 
    formula = cs_gui_get_text_value(path);
390
 
    BFT_FREE(path);
391
 
 
392
 
    return formula;
393
 
}
394
 
 
395
 
/*-----------------------------------------------------------------------------
396
 
 * Get uialcl data for fixed displacement
397
 
 *
398
 
 * parameters:
399
 
 *   label        --> boundary label
400
 
 *   begin        --> begin index for nodfbr
401
 
 *   end          --> end index for nodfbr
402
 
 *   nnod         --> number of node
403
 
 *   nodfbr       --> NODFBR
404
 
 *   impale       <-- IMPALE
405
 
 *   depale       <-- DEPALE
406
 
 *   dtref        --> time step
407
 
 *   ttcabs       --> current time
408
 
 *   ntcabs       --> current iteration number
409
 
 *----------------------------------------------------------------------------*/
410
 
 
411
 
static void
412
 
uialcl_fixed_displacement(const char *const label,
413
 
                          const int         begin,
414
 
                          const int         end,
415
 
                          const int  *const nnod,
416
 
                          const int  *const nodfbr,
417
 
                          int        *const impale,
418
 
                          double     *const depale,
419
 
                          const double      dtref,
420
 
                          const double      ttcabs,
421
 
                          const int         ntcabs)
422
 
{
423
 
    int ii = 0;
424
 
#ifdef HAVE_MEI
425
 
    mei_tree_t *ev;
426
 
    double X_mesh, Y_mesh, Z_mesh;
427
 
 
428
 
    const char*  variables[3] = {"mesh_x", "mesh_y", "mesh_z"};
429
 
    unsigned int variable_nbr = 3;
430
 
 
431
 
    /* Get formula */
432
 
    char* formula = get_ale_boundary_formula(label, "fixed_displacement");
433
 
 
434
 
    if (!formula)
435
 
        bft_error(__FILE__, __LINE__, 0,
436
 
            _("Boundary nature formula is null for %s.\n"), label);
437
 
 
438
 
    /* Init mei */
439
 
    ev = cs_gui_init_mei_tree(formula, variables, variable_nbr,
440
 
                              0, 0, 0, dtref, ttcabs, ntcabs);
441
 
 
442
 
    mei_evaluate(ev);
443
 
 
444
 
    /* Get mei results */
445
 
    X_mesh = mei_tree_lookup(ev, "mesh_x");
446
 
    Y_mesh = mei_tree_lookup(ev, "mesh_y");
447
 
    Z_mesh = mei_tree_lookup(ev, "mesh_z");
448
 
 
449
 
    BFT_FREE(formula);
450
 
    mei_tree_destroy(ev);
451
 
#endif /* HAVE_MEI */
452
 
 
453
 
    /* Set depale and impale */
454
 
    for (ii = begin; ii < end; ++ii)
455
 
    {
456
 
        int inod = nodfbr[ii-1] - 1;
457
 
        if (impale[inod] == 0)
458
 
        {
459
 
#ifdef HAVE_MEI
460
 
            depale[inod + 0 * (*nnod)] = X_mesh;
461
 
            depale[inod + 1 * (*nnod)] = Y_mesh;
462
 
            depale[inod + 2 * (*nnod)] = Z_mesh;
463
 
#endif /* HAVE_MEI */
464
 
            impale[inod] = 1;
465
 
        }
466
 
    }
467
 
}
468
 
 
469
 
/*-----------------------------------------------------------------------------
470
 
 * Get uialcl data for fixed velocity
471
 
 *
472
 
 * parameters:
473
 
 *   label        --> boundary label
474
 
 *   iuma         --> IUMA
475
 
 *   ivma         --> IVMA
476
 
 *   iwma         --> IWMA
477
 
 *   nfabor       --> Number of boundary faces
478
 
 *   ifbr         --> ifbr
479
 
 *   rcodcl       <-- RCODCL
480
 
 *   dtref        --> time step
481
 
 *   ttcabs       --> current time
482
 
 *   ntcabs       --> current iteration number
483
 
 *----------------------------------------------------------------------------*/
484
 
 
485
 
static void
486
 
uialcl_fixed_velocity(const char*   label,
487
 
                      const int     iuma,
488
 
                      const int     ivma,
489
 
                      const int     iwma,
490
 
                      const int     nfabor,
491
 
                      const int     ifbr,
492
 
                      double *const rcodcl,
493
 
                      const double  dtref,
494
 
                      const double  ttcabs,
495
 
                      const int     ntcabs)
496
 
{
497
 
#ifdef HAVE_MEI
498
 
    mei_tree_t *ev;
499
 
    const char*  variables[3] = { "mesh_u", "mesh_v", "mesh_w" };
500
 
 
501
 
    /* Get formula */
502
 
    char* formula = get_ale_boundary_formula(label, "fixed_velocity");
503
 
 
504
 
    if (!formula)
505
 
        bft_error(__FILE__, __LINE__, 0,
506
 
            _("Boundary nature formula is null for %s.\n"), label);
507
 
 
508
 
    /* Init MEI */
509
 
    ev = cs_gui_init_mei_tree(formula, variables, 3, 0, 0, 0,
510
 
                              dtref, ttcabs, ntcabs);
511
 
 
512
 
    mei_evaluate(ev);
513
 
 
514
 
    /* Fill  rcodcl */
515
 
    rcodcl[ (iuma-1) * nfabor + ifbr ] = mei_tree_lookup(ev, "mesh_u");
516
 
    rcodcl[ (ivma-1) * nfabor + ifbr ] = mei_tree_lookup(ev, "mesh_v");
517
 
    rcodcl[ (iwma-1) * nfabor + ifbr ] = mei_tree_lookup(ev, "mesh_w");
518
 
 
519
 
    BFT_FREE(formula);
520
 
    mei_tree_destroy(ev);
521
 
#endif /* HAVE_MEI */
522
 
}
523
 
 
524
 
/*-----------------------------------------------------------------------------
525
 
 * Return the ale boundary nature
526
 
 *
527
 
 * parameters:
528
 
 *   label  -->  label of boundary zone
529
 
 *----------------------------------------------------------------------------*/
530
 
 
531
 
static enum ale_boundary_nature
532
 
get_ale_boundary_nature(const char *const label)
533
 
{
534
 
  char *ale_boundary_nature;
535
 
 
536
 
  enum ale_boundary_nature nature = ale_boundary_nature_fixed_wall;
537
 
 
538
 
  char *path = cs_xpath_init_path();
539
 
  cs_xpath_add_elements(&path, 2, "boundary_conditions",  "wall");
540
 
 
541
 
  cs_xpath_add_test_attribute(&path, "label", label);
542
 
  cs_xpath_add_element(&path, "ale");
543
 
  cs_xpath_add_attribute(&path, "choice");
544
 
  ale_boundary_nature = cs_gui_get_attribute_value(path);
545
 
 
546
 
  if (cs_gui_strcmp(ale_boundary_nature, "fixed_boundary"))
547
 
    nature = ale_boundary_nature_fixed_wall;
548
 
  if (cs_gui_strcmp(ale_boundary_nature, "sliding_boundary"))
549
 
    nature = ale_boundary_nature_sliding_wall;
550
 
  else if (cs_gui_strcmp(ale_boundary_nature, "internal_coupling"))
551
 
    nature = ale_boundary_nature_internal_coupling;
552
 
  else if (cs_gui_strcmp(ale_boundary_nature, "external_coupling"))
553
 
    nature = ale_boundary_nature_external_coupling;
554
 
  else if (cs_gui_strcmp(ale_boundary_nature, "fixed_velocity"))
555
 
    nature = ale_boundary_nature_fixed_velocity;
556
 
  else if (cs_gui_strcmp(ale_boundary_nature, "fixed_displacement"))
557
 
    nature = ale_boundary_nature_fixed_displacement;
558
 
 
559
 
  BFT_FREE(path);
560
 
  BFT_FREE(ale_boundary_nature);
561
 
 
562
 
  return nature;
563
 
}
564
 
 
565
 
/*-----------------------------------------------------------------------------
566
 
 * Get boundary attribute like nature or label
567
 
 *
568
 
 * parameters:
569
 
 *   ith_zone  --> boundary index
570
 
 *   nodeName  --> xml attribute name. for example, "nature" or "label"
571
 
 *----------------------------------------------------------------------------*/
572
 
 
573
 
static char*
574
 
get_boundary_attribute(unsigned int ith_zone,
575
 
                       const char   *nodeName)
576
 
{
577
 
    char *result;
578
 
    char *path = cs_xpath_init_path();
579
 
 
580
 
    cs_xpath_add_element(&path, "boundary_conditions");
581
 
    cs_xpath_add_element_num(&path, "boundary", ith_zone);
582
 
    cs_xpath_add_attribute(&path, nodeName);
583
 
 
584
 
    result = cs_gui_get_attribute_value(path);
585
 
 
586
 
    BFT_FREE(path);
587
 
    return result;
588
 
}
589
 
 
590
 
 
591
 
/*-----------------------------------------------------------------------------
592
 
 * Init xpath for internal coupling with:
593
 
 *
594
 
 * boundary_conditions/wall[label=label]/
595
 
 * ale[choice=internal_coupling]/node_name, node_sub_name/text()
596
 
 *
597
 
 * parameters:
598
 
 *   label            --> boundary label
599
 
 *   node_name        --> xml node name ("initial_displacement")
600
 
 *   node_sub_name    --> xml child node of node_name ("X")
601
 
 *----------------------------------------------------------------------------*/
602
 
 
603
 
static char*
604
 
init_internal_coupling_xpath(const char* label,
605
 
                             const char* node_name,
606
 
                             const char* node_sub_name)
607
 
{
608
 
  char *path = NULL;
609
 
 
610
 
  path = cs_xpath_init_path();
611
 
  cs_xpath_add_elements(&path, 2, "boundary_conditions",  "wall");
612
 
  cs_xpath_add_test_attribute(&path, "label", label);
613
 
  cs_xpath_add_element(&path, "ale");
614
 
  cs_xpath_add_test_attribute(&path, "choice", "internal_coupling");
615
 
  cs_xpath_add_element(&path, node_name);
616
 
  cs_xpath_add_element(&path, node_sub_name);
617
 
  cs_xpath_add_function_text(&path);
618
 
 
619
 
  return path;
620
 
}
621
 
 
622
 
 
623
 
/*-----------------------------------------------------------------------------
624
 
 * Get internal coupling double
625
 
 *
626
 
 * parameters:
627
 
 *   label            --> boundary label
628
 
 *   node_name        --> xml node name ("initial_displacement")
629
 
 *   node_sub_name    --> xml child node of node_name ("X")
630
 
 *----------------------------------------------------------------------------*/
631
 
 
632
 
static double
633
 
get_internal_coupling_double(const char* label,
634
 
                             const char* node_name,
635
 
                             const char* node_sub_name)
636
 
{
637
 
  double value = 0;
638
 
  char *path = init_internal_coupling_xpath(label, node_name, node_sub_name);
639
 
 
640
 
  if (!cs_gui_get_double(path, &value))
641
 
  {
642
 
    bft_error(__FILE__, __LINE__, 0,
643
 
              _("cannot get value for %s %s %s"),
644
 
                 label, node_name, node_sub_name);
645
 
  }
646
 
  BFT_FREE(path);
647
 
 
648
 
  return value;
649
 
}
650
 
 
651
 
 
652
 
/*-----------------------------------------------------------------------------
653
 
 * Get internal coupling string
654
 
 *
655
 
 * parameters:
656
 
 *   label            --> boundary label
657
 
 *   node_name        --> xml node name ("initial_displacement")
658
 
 *   node_sub_name    --> xml child node of node_name ("formula")
659
 
 *----------------------------------------------------------------------------*/
660
 
 
661
 
static char*
662
 
get_internal_coupling_string(const char* label,
663
 
                             const char* node_name,
664
 
                             const char* node_sub_name)
665
 
{
666
 
  char *path = init_internal_coupling_xpath(label, node_name, node_sub_name);
667
 
  char* str  = cs_gui_get_text_value(path);
668
 
 
669
 
  BFT_FREE(path);
670
 
 
671
 
  return str;
672
 
}
673
 
 
674
 
 
675
 
/*-----------------------------------------------------------------------------
676
 
 * Retreive internal coupling x, y and z XML values
677
 
 *
678
 
 * parameters:
679
 
 *   label      --> boundary label
680
 
 *   node_name  --> xml node name ("initial_displacement")
681
 
 *   xyz        <-- result matrix
682
 
 *----------------------------------------------------------------------------*/
683
 
 
684
 
static void
685
 
get_internal_coupling_xyz_values(const char *label,
686
 
                                 const char *node_name,
687
 
                                 double      xyz[3])
688
 
{
689
 
    xyz[0] = get_internal_coupling_double(label, node_name, "X");
690
 
    xyz[1] = get_internal_coupling_double(label, node_name, "Y");
691
 
    xyz[2] = get_internal_coupling_double(label, node_name, "Z");
692
 
}
693
 
 
694
 
 
695
 
/*-----------------------------------------------------------------------------
696
 
 * Retreive internal coupling advanced windows double value
697
 
 *
698
 
 * parameters:
699
 
 *   node_name  --> xml node name ("displacement_prediction_alpha")
700
 
 *----------------------------------------------------------------------------*/
701
 
 
702
 
static void
703
 
get_uistr1_advanced_double(const char *const keyword,
704
 
                               double *const value)
705
 
{
706
 
    double result = 0;
707
 
    char   *path = cs_xpath_init_path();
708
 
 
709
 
    cs_xpath_add_elements(&path, 3, "thermophysical_models", "ale_method", keyword);
710
 
    cs_xpath_add_function_text(&path);
711
 
 
712
 
    if (cs_gui_get_double(path, &result))
713
 
        *value = result;
714
 
    BFT_FREE(path);
715
 
}
716
 
 
717
 
/*-----------------------------------------------------------------------------
718
 
 * Retreive internal coupling advanced windows checkbox value
719
 
 *
720
 
 * parameters:
721
 
 *   node_name  --> xml node name ("monitor_point_synchronisation")
722
 
 *----------------------------------------------------------------------------*/
723
 
 
724
 
static void
725
 
get_uistr1_advanced_checkbox(const char *const keyword, int *const value)
726
 
{
727
 
    int result = 0;
728
 
    char *path = cs_xpath_init_path();
729
 
 
730
 
    cs_xpath_add_elements(&path, 3, "thermophysical_models", "ale_method", keyword);
731
 
    cs_xpath_add_attribute(&path, "status");
732
 
 
733
 
    if (cs_gui_get_status(path, &result))
734
 
        *value = result;
735
 
    BFT_FREE(path);
736
 
}
737
 
 
738
 
/*-----------------------------------------------------------------------------
739
 
 * Retreive data the internal coupling matrices
740
 
 *
741
 
 * parameters:
742
 
 *   label            --> boundary label
743
 
 *   node_name        --> xml matrix node name
744
 
 *   symbols          --> see cs_gui_init_mei_tree
745
 
 *   symbol_nbr       --> see cs_gui_init_mei_tree
746
 
 *   variables        --> see cs_gui_init_mei_tree
747
 
 *   variables_value  --> see cs_gui_init_mei_tree
748
 
 *   variable_nbr     --> see cs_gui_init_mei_tree
749
 
 *   output_matrix,   <-- result matrix
750
 
 *   dtref            --> time step
751
 
 *   ttcabs           --> current time
752
 
 *   ntcabs           --> current iteration number
753
 
 *----------------------------------------------------------------------------*/
754
 
 
755
 
static void
756
 
get_internal_coupling_matrix(const char    *label,
757
 
                             const char    *node_name,
758
 
                             const char    *symbols[],
759
 
                             unsigned int  symbol_nbr,
760
 
                             const char    **variables,
761
 
                             const double  *variables_value,
762
 
                             unsigned int  variable_nbr,
763
 
                             double        *output_matrix,
764
 
                             const double  dtref,
765
 
                             const double  ttcabs,
766
 
                             const int     ntcabs)
767
 
{
768
 
#ifdef HAVE_MEI
769
 
    /* Get the formula */
770
 
    mei_tree_t *tree;
771
 
 
772
 
    unsigned int i = 0;
773
 
    char *matrix = get_internal_coupling_string(label, node_name, "formula");
774
 
 
775
 
    if (!matrix)
776
 
        bft_error(__FILE__, __LINE__, 0,
777
 
                  _("Formula is null for %s %s"), label, node_name);
778
 
 
779
 
    /* Initialize mei */
780
 
    tree = cs_gui_init_mei_tree(matrix, symbols, symbol_nbr,
781
 
                                variables, variables_value, variable_nbr,
782
 
                                dtref, ttcabs, ntcabs);
783
 
    mei_evaluate(tree);
784
 
 
785
 
    /* Read matrix values */
786
 
    for (i = 0; i < symbol_nbr; ++i)
787
 
    {
788
 
        const char *symbol = symbols[i];
789
 
        output_matrix[i] = mei_tree_lookup(tree, symbol);
790
 
    }
791
 
    BFT_FREE(matrix);
792
 
    mei_tree_destroy(tree);
793
 
#endif /* HAVE_MEI */
794
 
}
795
 
 
796
 
/*-----------------------------------------------------------------------------
797
 
 * Retreive data for internal coupling for a specific boundary
798
 
 *
799
 
 * parameters:
800
 
 *   label    --> boundary label
801
 
 *   xmstru   <-- Mass matrix
802
 
 *   xcstr    <-- Damping matrix
803
 
 *   xkstru   <-- Stiffness matrix
804
 
 *   forstr   <-- Fluid force matrix
805
 
 *   istruc   --> internal coupling boundary index
806
 
 *   dtref    --> time step
807
 
 *   ttcabs   --> current time
808
 
 *   ntcabs   --> current iteration number
809
 
 *----------------------------------------------------------------------------*/
810
 
 
811
 
static void
812
 
get_uistr2_data(const char    *label,
813
 
                double *const xmstru,
814
 
                double *const xcstru,
815
 
                double *const xkstru,
816
 
                double *const forstr,
817
 
                unsigned int  istruc,
818
 
                const double  dtref,
819
 
                const double  ttcabs,
820
 
                const int     ntcabs)
821
 
{
822
 
    const char  *m_symbols[] = {"m11", "m12", "m13",
823
 
                                "m21", "m22", "m23",
824
 
                                "m31", "m32", "m33"};
825
 
    const char  *c_symbols[] = {"c11", "c12", "c13",
826
 
                                "c21", "c22", "c23",
827
 
                                "c31", "c32", "c33"};
828
 
    const char  *k_symbols[] = {"k11", "k12", "k13",
829
 
                                "k21", "k22", "k23",
830
 
                                "k31", "k32", "k33"};
831
 
 
832
 
    unsigned int symbol_nbr = sizeof(m_symbols) / sizeof(m_symbols[0]);
833
 
 
834
 
    const char   *force_symbols[] = {"fx", "fy", "fz"};
835
 
    unsigned int force_symbol_nbr = sizeof(force_symbols) / sizeof(force_symbols[0]);
836
 
 
837
 
    const unsigned int  variable_nbr = 3;
838
 
    const char *variables[3] = {"fluid_fx", "fluid_fy", "fluid_fz"};
839
 
    double variable_values[3];
840
 
 
841
 
    /* Get mass matrix, damping matrix and stiffness matrix */
842
 
 
843
 
    get_internal_coupling_matrix(label, "mass_matrix", m_symbols,
844
 
                                 symbol_nbr, 0, 0, 0,
845
 
                                 &xmstru[istruc * symbol_nbr],
846
 
                                 dtref, ttcabs, ntcabs);
847
 
 
848
 
    get_internal_coupling_matrix(label, "damping_matrix", c_symbols,
849
 
                                 symbol_nbr, 0, 0, 0,
850
 
                                 &xcstru[istruc * symbol_nbr],
851
 
                                 dtref, ttcabs, ntcabs);
852
 
 
853
 
    get_internal_coupling_matrix(label, "stiffness_matrix", k_symbols,
854
 
                                 symbol_nbr, 0, 0, 0,
855
 
                                 &xkstru[istruc * symbol_nbr],
856
 
                                 dtref, ttcabs, ntcabs);
857
 
 
858
 
    /* Set variable for fluid force matrix */
859
 
    variable_values[0] = forstr[istruc * force_symbol_nbr + 0];
860
 
    variable_values[1] = forstr[istruc * force_symbol_nbr + 1];
861
 
    variable_values[2] = forstr[istruc * force_symbol_nbr + 2];
862
 
 
863
 
    /* Get fluid force matrix */
864
 
    get_internal_coupling_matrix(label, "fluid_force_matrix",
865
 
                                 force_symbols, force_symbol_nbr,
866
 
                                 variables, variable_values, variable_nbr,
867
 
                                 &forstr[istruc * force_symbol_nbr],
868
 
                                 dtref, ttcabs, ntcabs);
869
 
}
870
 
 
871
 
/*-----------------------------------------------------------------------------
872
 
 * Return the post synchronization status
873
 
 *
874
 
 *  <thermophysical_models>
875
 
 *      <ale_method status="on">
876
 
 *          <external_coupling_post_synchronization ***status="off"*** />
877
 
 *
878
 
 *----------------------------------------------------------------------------*/
879
 
 
880
 
static int
881
 
get_coupling_post_synchronization_status(void)
882
 
{
883
 
    char *statusStr;
884
 
    int  status;
885
 
 
886
 
    char *path = cs_xpath_init_path();
887
 
 
888
 
    cs_xpath_add_elements(&path, 3, "thermophysical_models",
889
 
                          "ale_method",
890
 
                          "external_coupling_post_synchronization");
891
 
    cs_xpath_add_attribute(&path, "status");
892
 
 
893
 
    statusStr = cs_gui_get_attribute_value(path);
894
 
    status    = cs_gui_strcmp(statusStr, "on");
895
 
 
896
 
    BFT_FREE(statusStr);
897
 
    BFT_FREE(path);
898
 
 
899
 
    return status;
900
 
}
901
 
 
902
 
 
903
 
/*-----------------------------------------------------------------------------
904
 
 * Return the external coupling DDL value
905
 
 *
906
 
 *  <boundary_conditions>
907
 
 *      <wall label=label_argument">
908
 
 *          <ale choice="external_coupling">
909
 
 *              <node_name_argument choice="off"/>
910
 
 *
911
 
 *   label     -->  The wall label.
912
 
 *   node_name -->  Node name: DDLX, DDLY or DDLZ.
913
 
*----------------------------------------------------------------------------*/
914
 
 
915
 
static int
916
 
get_external_coupling_ddl(const char *const label,
917
 
                          const char *const node_name)
918
 
{
919
 
    char* choice;
920
 
    int isOn;
921
 
 
922
 
    char *path = cs_xpath_init_path();
923
 
    cs_xpath_add_elements(&path, 2, "boundary_conditions", "wall");
924
 
    cs_xpath_add_test_attribute(&path, "label", label);
925
 
    cs_xpath_add_element(&path, "ale");
926
 
    cs_xpath_add_test_attribute(&path, "choice", "external_coupling");
927
 
    cs_xpath_add_element(&path, node_name);
928
 
    cs_xpath_add_attribute(&path, "choice");
929
 
 
930
 
    choice = cs_gui_get_attribute_value(path);
931
 
    isOn = cs_gui_strcmp(choice, "on");
932
 
 
933
 
    BFT_FREE(choice);
934
 
    BFT_FREE(path);
935
 
 
936
 
    return isOn;
937
 
}
938
 
 
939
 
/*============================================================================
940
 
 * Public Fortran function definitions
941
 
 *============================================================================*/
942
 
 
943
 
/*----------------------------------------------------------------------------
944
 
 *  uivima
945
 
 *
946
 
 * ncel     -->  number of cells whithout halo
947
 
 * viscmx   <--  VISCMX
948
 
 * viscmy   <--  VISCMY
949
 
 * viscmz   <--  VISCMZ
950
 
 * xyzcen   -->  cell's gravity center
951
 
 * dtref    -->  time step
952
 
 * ttcabs   --> current time
953
 
 * ntcabs   --> current iteration number
954
 
 *----------------------------------------------------------------------------*/
955
 
 
956
 
void CS_PROCF (uivima, UIVIMA) (const cs_int_t *const ncel,
957
 
                                double         *const viscmx,
958
 
                                double         *const viscmy,
959
 
                                double         *const viscmz,
960
 
                                const double   *const xyzcen,
961
 
                                double         *const dtref,
962
 
                                double         *const ttcabs,
963
 
                                const int      *const ntcabs)
964
 
{
965
 
#if defined(HAVE_MEI)
966
 
    int          iel            = 0;
967
 
    const char*  symbols[3]     = { "x", "y", "z" };
968
 
    const char*  variables[3]   = { "mesh_vi1", "mesh_vi2", "mesh_vi3" };
969
 
    unsigned int variable_nbr   = 1;
970
 
 
971
 
    /* Check if user function is selection */
972
 
    if (get_ale_property_choice() == ale_property_choice_user_function)
973
 
    {
974
 
        /* Get formula */
975
 
        mei_tree_t *ev;
976
 
        char *aleFormula    = get_ale_formula();
977
 
        char *viscosityType = get_ale_mesh_viscosity();
978
 
        unsigned int isOrthotrop = cs_gui_strcmp(viscosityType, "orthotrop");
979
 
 
980
 
        if (isOrthotrop)
981
 
            variable_nbr = 3;
982
 
 
983
 
        if (!aleFormula)
984
 
            bft_error(__FILE__, __LINE__, 0,
985
 
                    _("Formula is null for ale.\n"));
986
 
 
987
 
        /* Init mei */
988
 
        ev = cs_gui_init_mei_tree(aleFormula, variables,
989
 
                                  variable_nbr, symbols, 0, 3,
990
 
                                  *dtref, *ttcabs, *ntcabs);
991
 
 
992
 
        /* for each cell, update the value of the table of symbols for each scalar
993
 
            (including the thermal scalar), and evaluate the interpreter */
994
 
        for (iel = 0; iel < *ncel; iel++)
995
 
        {
996
 
            /* insert symbols */
997
 
            mei_tree_insert(ev, "x", xyzcen[3 * iel + 0]);
998
 
            mei_tree_insert(ev, "y", xyzcen[3 * iel + 1]);
999
 
            mei_tree_insert(ev, "z", xyzcen[3 * iel + 2]);
1000
 
 
1001
 
            mei_evaluate(ev);
1002
 
 
1003
 
            /* Set viscmx, viscmy and viscmz */
1004
 
            viscmx[iel] = mei_tree_lookup(ev, "mesh_vi1");
1005
 
            if (isOrthotrop)
1006
 
            {
1007
 
                viscmy[iel] = mei_tree_lookup(ev, "mesh_vi2");
1008
 
                viscmz[iel] = mei_tree_lookup(ev, "mesh_vi3");
1009
 
            }
1010
 
        }
1011
 
        mei_tree_destroy(ev);
1012
 
        BFT_FREE(aleFormula);
1013
 
        BFT_FREE(viscosityType);
1014
 
    }
1015
 
#endif /* HAVE_MEI */
1016
 
}
1017
 
 
1018
 
/*----------------------------------------------------------------------------
1019
 
 * ALE related keywords
1020
 
 *
1021
 
 * Fortran Interface:
1022
 
 *
1023
 
 * SUBROUTINE UIALIN
1024
 
 * *****************
1025
 
 *
1026
 
 * INTEGER          IALE    <--  iale method activation
1027
 
 * INTEGER          NALINF  <--  number of sub iteration of initialization
1028
 
 *                               of fluid
1029
 
 * INTEGER          NALIMX  <--  max number of iterations of implicitation of
1030
 
 *                               the displacement of the structures
1031
 
 * DOUBLE           EPALIM  <--  realtive precision of implicitation of
1032
 
 *                               the displacement of the structures
1033
 
 * INTEGER          IORTVM  <--  type of viscosity of mesh
1034
 
 *
1035
 
 *----------------------------------------------------------------------------*/
1036
 
 
1037
 
void CS_PROCF (uialin, UIALIN) (int    *const iale,
1038
 
                                int    *const nalinf,
1039
 
                                int    *const nalimx,
1040
 
                                double *const epalim,
1041
 
                                int    *const iortvm)
1042
 
{
1043
 
  double value;
1044
 
 
1045
 
  cs_gui_get_ale_status(iale);
1046
 
 
1047
 
  if (*iale) {
1048
 
    value =(double) *nalinf;
1049
 
    cs_gui_iale_parameter("fluid_initialization_sub_iterations", &value);
1050
 
    *nalinf = (int) value;
1051
 
 
1052
 
    value =(double) *nalimx;
1053
 
    cs_gui_iale_parameter("max_iterations_implicitation", &value);
1054
 
    *nalimx = (int) value;
1055
 
 
1056
 
    cs_gui_iale_parameter("implicitation_precision", epalim);
1057
 
 
1058
 
    value =(double) *iortvm;
1059
 
    cs_gui_iale_parameter("mesh_viscosity", &value);
1060
 
    *iortvm = (int) value;
1061
 
  }
1062
 
 
1063
 
#if _XML_DEBUG_
1064
 
  bft_printf("==>UIALIN\n");
1065
 
  bft_printf("--iale = %i\n", *iale);
1066
 
  if (*iale) {
1067
 
    bft_printf("--nalinf = %i\n", *nalinf);
1068
 
    bft_printf("--nalimx = %i\n", *nalimx);
1069
 
    bft_printf("--epalim = %g\n", *epalim);
1070
 
    bft_printf("--iortvm = %i\n", *iortvm);
1071
 
  }
1072
 
#endif
1073
 
}
1074
 
 
1075
 
/*-----------------------------------------------------------------------------
1076
 
 *  uialcl
1077
 
 *
1078
 
 * parameters:
1079
 
 *   nfabor       --> Number of boundary faces
1080
 
 *   nozppm       --> Max number of boundary conditions zone
1081
 
 *   ialtyb       --> ialtyb
1082
 
 *   ipnfbr       --> First node position for each boundary in nodfbr
1083
 
 *   nodfbr       --> uialcl_fixed_displacement
1084
 
 *   impale       --> uialcl_fixed_displacement
1085
 
 *   depale       --> See uialcl_fixed_displacement
1086
 
 *   dtref        --> time step
1087
 
 *   ttcabs       --> current time
1088
 
 *   ntcabs       --> current iteration number
1089
 
 *   iuma         --> See uialcl_fixed_velocity
1090
 
 *   ivma         --> See uialcl_fixed_velocity
1091
 
 *   iwma         --> See uialcl_fixed_velocity
1092
 
 *   rcodcl       --> See uialcl_fixed_velocity
1093
 
 *----------------------------------------------------------------------------*/
1094
 
 
1095
 
void CS_PROCF (uialcl, UIALCL) (const int *const    nfabor,
1096
 
                                const int *const    nozppm,
1097
 
                                const int *const    ibfixe,
1098
 
                                const int *const    igliss,
1099
 
                                const int *const    ivimpo,
1100
 
                                int       *const    ialtyb,
1101
 
                                const int *const    ipnfbr,
1102
 
                                const int *const    nnod,
1103
 
                                const int *const    nodfbr,
1104
 
                                int       *const    impale,
1105
 
                                double    *const    depale,
1106
 
                                double    *const    dtref,
1107
 
                                double    *const    ttcabs,
1108
 
                                const int *const    ntcabs,
1109
 
                                const int *const    iuma,
1110
 
                                const int *const    ivma,
1111
 
                                const int *const    iwma,
1112
 
                                double    *const    rcodcl)
1113
 
{
1114
 
    int  izone        = 0;
1115
 
    int  ifac         = 0;
1116
 
    int  faces        = 0;
1117
 
 
1118
 
    int zones = cs_gui_boundary_zones_number();
1119
 
 
1120
 
    /* At each time-step, loop on boundary faces: */
1121
 
    for (izone=0 ; izone < zones ; izone++)
1122
 
    {
1123
 
        int* faces_list = cs_gui_get_faces_list(izone,
1124
 
                                                boundaries->label[izone],
1125
 
                                                *nfabor,
1126
 
                                                *nozppm,
1127
 
                                                &faces);
1128
 
 
1129
 
        /* get the ale choice */
1130
 
        const char* label = boundaries->label[izone];
1131
 
        enum ale_boundary_nature nature = get_ale_boundary_nature(label);
1132
 
 
1133
 
        if (nature ==  ale_boundary_nature_fixed_wall)
1134
 
        {
1135
 
            for (ifac = 0; ifac < faces; ifac++)
1136
 
            {
1137
 
                int ifbr = faces_list[ifac]-1;
1138
 
                ialtyb[ifbr]  = *ibfixe;
1139
 
            }
1140
 
        }
1141
 
        else if (nature ==  ale_boundary_nature_sliding_wall)
1142
 
        {
1143
 
            for (ifac = 0; ifac < faces; ifac++)
1144
 
            {
1145
 
                int ifbr = faces_list[ifac]-1;
1146
 
                ialtyb[ifbr]  = *igliss;
1147
 
            }
1148
 
        }
1149
 
        else if (nature == ale_boundary_nature_fixed_displacement)
1150
 
        {
1151
 
            for (ifac = 0; ifac < faces; ifac++)
1152
 
            {
1153
 
                int ifbr = faces_list[ifac]-1;
1154
 
                uialcl_fixed_displacement(label, ipnfbr[ifbr], ipnfbr[ifbr+1],
1155
 
                                          nnod, nodfbr, impale, depale,
1156
 
                                          *dtref, *ttcabs, *ntcabs);
1157
 
            }
1158
 
        }
1159
 
        else if (nature == ale_boundary_nature_fixed_velocity)
1160
 
        {
1161
 
            for (ifac = 0; ifac < faces; ifac++)
1162
 
            {
1163
 
                int ifbr = faces_list[ifac]-1;
1164
 
                uialcl_fixed_velocity(label, *iuma, *ivma, *iwma,
1165
 
                                      *nfabor, ifbr, rcodcl,
1166
 
                                      *dtref, *ttcabs, *ntcabs);
1167
 
                ialtyb[ifbr]  = *ivimpo;
1168
 
            }
1169
 
        }
1170
 
        BFT_FREE(faces_list);
1171
 
    }
1172
 
}
1173
 
 
1174
 
/*-----------------------------------------------------------------------------
1175
 
 * Retreive data for internal coupling. Called once at initialization
1176
 
 *
1177
 
 * parameters:
1178
 
 *   nfabor   --> Number of boundary faces
1179
 
 *   idfstr   --> Structure definition
1180
 
 *   aexxst   <--  Displacement prediction alpha
1181
 
 *   bexxst   <-- Displacement prediction beta
1182
 
 *   cfopre   <-- Stress prediction alpha
1183
 
 *   ihistr   <-- Monitor point synchronisation
1184
 
 *   xstr0    <-- Values of the initial displacement
1185
 
 *   xstreq   <-- Values of the equilibrium displacement
1186
 
 *   vstr0    <-- Values of the initial velocity
1187
 
 *----------------------------------------------------------------------------*/
1188
 
 
1189
 
void CS_PROCF (uistr1, UISTR1) (const int *const nfabor,
1190
 
                                int       *const idfstr,
1191
 
                                double           *aexxst,
1192
 
                                double           *bexxst,
1193
 
                                double           *cfopre,
1194
 
                                int              *ihistr,
1195
 
                                double           *xstr0,
1196
 
                                double           *xstreq,
1197
 
                                double           *vstr0)
1198
 
{
1199
 
    int  zones;
1200
 
    int  izone        = 0;
1201
 
    int  ifac         = 0;
1202
 
    int  faces        = 0;
1203
 
    int  ifbr         = 0;
1204
 
    int  *faces_list  = NULL;
1205
 
    unsigned int    istruct = 0;
1206
 
 
1207
 
    /* Get advanced data */
1208
 
    get_uistr1_advanced_double("displacement_prediction_alpha", aexxst);
1209
 
    get_uistr1_advanced_double("displacement_prediction_beta", bexxst);
1210
 
    get_uistr1_advanced_double("stress_prediction_alpha", cfopre);
1211
 
    get_uistr1_advanced_checkbox("monitor_point_synchronisation", ihistr);
1212
 
 
1213
 
    zones = cs_gui_boundary_zones_number();
1214
 
 
1215
 
    /* At each time-step, loop on boundary faces */
1216
 
    for (izone=0 ; izone < zones ; izone++)
1217
 
    {
1218
 
        char *nature = get_boundary_attribute(izone + 1, "nature");
1219
 
        char *label  = get_boundary_attribute(izone + 1, "label");
1220
 
 
1221
 
        /* Keep only internal coupling */
1222
 
        if (get_ale_boundary_nature(label) == ale_boundary_nature_internal_coupling)
1223
 
        {
1224
 
            /* Read initial_displacement, equilibrium_displacement and initial_velocity */
1225
 
            get_internal_coupling_xyz_values(label, "initial_displacement",
1226
 
                                             &xstr0[3 * istruct]);
1227
 
            get_internal_coupling_xyz_values(label, "equilibrium_displacement",
1228
 
                                             &xstreq[3 * istruct]);
1229
 
            get_internal_coupling_xyz_values(label, "initial_velocity",
1230
 
                                             &vstr0[3 * istruct]);
1231
 
 
1232
 
            faces_list = cs_gui_get_faces_list(izone, label, *nfabor, 0, &faces);
1233
 
            /* Set idfstr to positiv index starting at 1 */
1234
 
            for (ifac = 0; ifac < faces; ifac++)
1235
 
            {
1236
 
                ifbr = faces_list[ifac]-1;
1237
 
                idfstr[ifbr] = istruct + 1;
1238
 
            }
1239
 
            ++istruct;
1240
 
            BFT_FREE(faces_list);
1241
 
        }
1242
 
        BFT_FREE(nature);
1243
 
        BFT_FREE(label);
1244
 
    }
1245
 
}
1246
 
 
1247
 
/*-----------------------------------------------------------------------------
1248
 
 * Retreive data for internal coupling. Called at each step
1249
 
 *
1250
 
 * parameters:
1251
 
 *   xmstru       <-- Mass matrix
1252
 
 *   xcstr        <-- Damping matrix
1253
 
 *   xkstru       <-- Stiffness matrix
1254
 
 *   forstr       <-- Fluid force matrix
1255
 
 *   dtref        -->   time step
1256
 
 *   ttcabs       --> current time
1257
 
 *   ntcabs       --> current iteration number
1258
 
 *----------------------------------------------------------------------------*/
1259
 
 
1260
 
void CS_PROCF (uistr2, UISTR2) (double *const  xmstru,
1261
 
                                double *const  xcstru,
1262
 
                                double *const  xkstru,
1263
 
                                double *const  forstr,
1264
 
                                double *const  dtref,
1265
 
                                double *const  ttcabs,
1266
 
                                int    *const  ntcabs)
1267
 
{
1268
 
    int          izone   = 0;
1269
 
    unsigned int istru   = 0;
1270
 
 
1271
 
    int zones   = cs_gui_boundary_zones_number();
1272
 
 
1273
 
    /* At each time-step, loop on boundary faces */
1274
 
    for (izone=0 ; izone < zones ; izone++)
1275
 
    {
1276
 
        const char *label = boundaries->label[izone];
1277
 
 
1278
 
        /* Keep only internal coupling */
1279
 
        if (get_ale_boundary_nature(label) == ale_boundary_nature_internal_coupling)
1280
 
        {
1281
 
#if 0
1282
 
            /* Read internal coupling data for boundaries */
1283
 
            for (int ii=0; ii<3; ii++)
1284
 
            {
1285
 
                xmstru = 0.;
1286
 
                xkstru = 0.;
1287
 
                xcstru = 0.;
1288
 
            }
1289
 
#endif
1290
 
            get_uistr2_data(label,
1291
 
                            xmstru,
1292
 
                            xcstru,
1293
 
                            xkstru,
1294
 
                            forstr,
1295
 
                            istru,
1296
 
                            *dtref,
1297
 
                            *ttcabs,
1298
 
                            *ntcabs);
1299
 
            ++istru;
1300
 
        }
1301
 
    }
1302
 
}
1303
 
 
1304
 
/*-----------------------------------------------------------------------------
1305
 
 * Retreive data for external coupling
1306
 
 *
1307
 
 * parameters:
1308
 
 *   nfabor    <-- Number of boundary faces
1309
 
 *   idfstr    <-- Structure definition
1310
 
 *   asddlf    <-- Block of the DDL forces
1311
 
 *   isyncp    <---
1312
 
 *----------------------------------------------------------------------------*/
1313
 
 
1314
 
void
1315
 
CS_PROCF (uiaste, UIASTE) (const int *const nfabor,
1316
 
                           int       *const idfstr,
1317
 
                           double    *const asddlf,
1318
 
                           int       *const isyncp)
1319
 
{
1320
 
    int faces   = 0;
1321
 
    int izone   = 0;
1322
 
    int istruct = 0;
1323
 
    int ifbr    = 0;
1324
 
    int ifac    = 0;
1325
 
 
1326
 
    int zones = cs_gui_boundary_zones_number();
1327
 
 
1328
 
    /* Get the coupling post synchronization status */
1329
 
    *isyncp = get_coupling_post_synchronization_status() ? 1 : 0;
1330
 
 
1331
 
    /* At each time-step, loop on boundary faces */
1332
 
    for (izone=0 ; izone < zones ; izone++)
1333
 
    {
1334
 
        const char *label  = boundaries->label[izone];
1335
 
 
1336
 
        /* Keep only internal coupling */
1337
 
        if (get_ale_boundary_nature(label) == ale_boundary_nature_external_coupling)
1338
 
        {
1339
 
            int* faces_list = cs_gui_get_faces_list(izone, label, *nfabor, 0, &faces);
1340
 
 
1341
 
            /* Get DDLX, DDLY and DDLZ values */
1342
 
            asddlf[istruct * 3 + 0] = get_external_coupling_ddl(label, "DDLX") ? 0 : 1;
1343
 
            asddlf[istruct * 3 + 1] = get_external_coupling_ddl(label, "DDLY") ? 0 : 1;
1344
 
            asddlf[istruct * 3 + 2] = get_external_coupling_ddl(label, "DDLZ") ? 0 : 1;
1345
 
 
1346
 
            /* Set idfstr with negativ value starting from -1 */
1347
 
            for (ifac = 0; ifac < faces; ifac++)
1348
 
            {
1349
 
                ifbr = faces_list[ifac]-1;
1350
 
                idfstr[ifbr] = -istruct - 1;
1351
 
            }
1352
 
            ++istruct;
1353
 
            BFT_FREE(faces_list);
1354
 
        }
1355
 
    }
1356
 
}
1357
 
 
1358
 
/*----------------------------------------------------------------------------*/
1359
 
 
1360
 
END_C_DECLS