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

« back to all changes in this revision

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