1
/*============================================================================
3
* This file is part of the Code_Saturne Kernel, element of the
4
* Code_Saturne CFD tool.
6
* Copyright (C) 1998-2009 EDF S.A., France
8
* contact: saturne-support@edf.fr
10
* The Code_Saturne Kernel is free software; you can redistribute it
11
* and/or modify it under the terms of the GNU General Public License
12
* as published by the Free Software Foundation; either version 2 of
13
* the License, or (at your option) any later version.
15
* The Code_Saturne Kernel is distributed in the hope that it will be
16
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
17
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with the Code_Saturne Kernel; if not, write to the
22
* Free Software Foundation, Inc.,
23
* 51 Franklin St, Fifth Floor,
24
* Boston, MA 02110-1301 USA
26
*============================================================================*/
28
/*============================================================================
29
* Management of the GUI parameters file: mobile mesh
30
*============================================================================*/
32
#if defined(HAVE_CONFIG_H)
33
#include "cs_config.h"
36
/*----------------------------------------------------------------------------
37
* Standard C library headers
38
*----------------------------------------------------------------------------*/
48
/*----------------------------------------------------------------------------
50
*----------------------------------------------------------------------------*/
53
#include <bft_error.h>
54
#include <bft_printf.h>
56
/*----------------------------------------------------------------------------
58
*----------------------------------------------------------------------------*/
60
#include "fvm_selector.h"
62
/*----------------------------------------------------------------------------
64
*----------------------------------------------------------------------------*/
67
#include "mei_evaluate.h"
70
/*----------------------------------------------------------------------------
72
*----------------------------------------------------------------------------*/
75
#include "cs_gui_util.h"
76
#include "cs_gui_variables.h"
77
#include "cs_gui_boundary_conditions.h"
79
#include "cs_prototypes.h"
81
/*----------------------------------------------------------------------------
82
* Header for the current file
83
*----------------------------------------------------------------------------*/
85
#include "cs_gui_mobile_mesh.h"
87
/*----------------------------------------------------------------------------*/
91
/*=============================================================================
92
* Local Macro Definitions
93
*============================================================================*/
95
/* debugging switch */
98
/*============================================================================
100
*============================================================================*/
102
/*----------------------------------------------------------------------------
103
* ALE property choice possible value
104
*----------------------------------------------------------------------------*/
106
enum ale_property_choice
108
ale_property_choice_user_function,
109
ale_property_choice_user_subroutine
112
/*-----------------------------------------------------------------------------
113
* Possible values for boundary nature
114
*----------------------------------------------------------------------------*/
116
enum ale_boundary_nature
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
126
/*============================================================================
127
* Private function definitions
128
*============================================================================*/
130
/*-----------------------------------------------------------------------------
131
* Return value for iale method
134
* param --> iale parameter
135
* keyword <-- value of the iale parameter
136
*----------------------------------------------------------------------------*/
139
cs_gui_iale_parameter(const char *const param,
140
double *const keyword)
146
path = cs_xpath_init_path();
147
cs_xpath_add_elements(&path, 3, "thermophysical_models", "ale_method", param);
149
if (cs_gui_strcmp(param,"mesh_viscosity")) {
151
cs_xpath_add_attribute(&path, "type");
152
type = cs_gui_get_attribute_value(path);
153
if(cs_gui_strcmp(type, "isotrop"))
155
else if (cs_gui_strcmp(type, "orthotrop"))
158
bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
162
cs_xpath_add_function_text(&path);
163
if (cs_gui_get_double(path, &result)) *keyword = result;
170
/*-----------------------------------------------------------------------------
171
* Return the status of ALE method
174
* keyword <-- status of ale balise
175
*----------------------------------------------------------------------------*/
178
cs_gui_get_ale_status(int *const keyword)
183
path = cs_xpath_init_path();
184
cs_xpath_add_elements(&path, 2, "thermophysical_models", "ale_method");
185
cs_xpath_add_attribute(&path, "status");
187
if(cs_gui_get_status(path, &result))
196
/*-----------------------------------------------------------------------------
197
* Return the viscosity's type of ALE method
200
* type <-- type of viscosity's type
201
*----------------------------------------------------------------------------*/
204
cs_gui_get_ale_viscosity_type(int * type)
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");
213
buff = cs_gui_get_attribute_value(path);
215
if (cs_gui_strcmp(buff, "orthotrop"))
217
else if (cs_gui_strcmp(buff, "isotrop"))
220
bft_error(__FILE__, __LINE__, 0, _("Invalid xpath: %s\n"), path);
227
/*============================================================================
228
* Public function definitions
229
*============================================================================*/
231
/*-----------------------------------------------------------------------------
232
* Initialize mei tree and check for symbols existence
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
*----------------------------------------------------------------------------*/
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,
259
/* return an empty interpreter */
260
mei_tree_t *tree = mei_tree_new(formula);
262
/* Insert variables into mei_tree */
263
for (i = 0; i < variable_nbr; ++i)
267
/* Read value from variables_value if it is not null 0 otherwise */
269
value = variables_value[i];
270
mei_tree_insert(tree, variables[i], value);
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);
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);
283
/* Check for symbols */
284
for (i = 0; i < symbol_nbr; ++i)
286
const char* symbol = symbols[i];
288
if (mei_tree_find_symbol(tree, symbol))
290
bft_error(__FILE__, __LINE__, 0,
291
_("Error: can not find the required symbol: %s\n"), symbol);
297
#endif /* HAVE_MEI */
299
/*----------------------------------------------------------------------------
300
* Get the ale property choice
301
*----------------------------------------------------------------------------*/
303
static enum ale_property_choice
304
get_ale_property_choice(void)
308
enum ale_property_choice choice = ale_property_choice_user_function;
309
char *path = cs_xpath_init_path();
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");
315
choice_str = cs_gui_get_attribute_value(path);
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;
322
bft_error(__FILE__, __LINE__, 0,
323
_("Unknow ale property choice %s.\n"), choice);
324
BFT_FREE(choice_str);
329
/*-----------------------------------------------------------------------------
330
* Return the ale boundary nature
331
*----------------------------------------------------------------------------*/
334
get_ale_formula(void)
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);
343
aleFormula = cs_gui_get_text_value(path);
348
/*-----------------------------------------------------------------------------
349
* Return the ale mesh viscosity
350
*----------------------------------------------------------------------------*/
353
get_ale_mesh_viscosity(void)
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");
362
viscosityType = cs_gui_get_attribute_value(path);
364
return viscosityType;
367
/*-----------------------------------------------------------------------------
368
* Get the ale boundary formula
371
* label --> boundary label
372
* choice --> nature: "fixed_velocity" or "fixed_displacement"
373
*----------------------------------------------------------------------------*/
376
get_ale_boundary_formula(const char *const label,
377
const char *const choice)
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);
389
formula = cs_gui_get_text_value(path);
395
/*-----------------------------------------------------------------------------
396
* Get uialcl data for fixed displacement
399
* label --> boundary label
400
* begin --> begin index for nodfbr
401
* end --> end index for nodfbr
402
* nnod --> number of node
406
* dtref --> time step
407
* ttcabs --> current time
408
* ntcabs --> current iteration number
409
*----------------------------------------------------------------------------*/
412
uialcl_fixed_displacement(const char *const label,
415
const int *const nnod,
416
const int *const nodfbr,
418
double *const depale,
426
double X_mesh, Y_mesh, Z_mesh;
428
const char* variables[3] = {"mesh_x", "mesh_y", "mesh_z"};
429
unsigned int variable_nbr = 3;
432
char* formula = get_ale_boundary_formula(label, "fixed_displacement");
435
bft_error(__FILE__, __LINE__, 0,
436
_("Boundary nature formula is null for %s.\n"), label);
439
ev = cs_gui_init_mei_tree(formula, variables, variable_nbr,
440
0, 0, 0, dtref, ttcabs, ntcabs);
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");
450
mei_tree_destroy(ev);
451
#endif /* HAVE_MEI */
453
/* Set depale and impale */
454
for (ii = begin; ii < end; ++ii)
456
int inod = nodfbr[ii-1] - 1;
457
if (impale[inod] == 0)
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 */
469
/*-----------------------------------------------------------------------------
470
* Get uialcl data for fixed velocity
473
* label --> boundary label
477
* nfabor --> Number of boundary faces
480
* dtref --> time step
481
* ttcabs --> current time
482
* ntcabs --> current iteration number
483
*----------------------------------------------------------------------------*/
486
uialcl_fixed_velocity(const char* label,
492
double *const rcodcl,
499
const char* variables[3] = { "mesh_u", "mesh_v", "mesh_w" };
502
char* formula = get_ale_boundary_formula(label, "fixed_velocity");
505
bft_error(__FILE__, __LINE__, 0,
506
_("Boundary nature formula is null for %s.\n"), label);
509
ev = cs_gui_init_mei_tree(formula, variables, 3, 0, 0, 0,
510
dtref, ttcabs, ntcabs);
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");
520
mei_tree_destroy(ev);
521
#endif /* HAVE_MEI */
524
/*-----------------------------------------------------------------------------
525
* Return the ale boundary nature
528
* label --> label of boundary zone
529
*----------------------------------------------------------------------------*/
531
static enum ale_boundary_nature
532
get_ale_boundary_nature(const char *const label)
534
char *ale_boundary_nature;
536
enum ale_boundary_nature nature = ale_boundary_nature_fixed_wall;
538
char *path = cs_xpath_init_path();
539
cs_xpath_add_elements(&path, 2, "boundary_conditions", "wall");
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);
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;
560
BFT_FREE(ale_boundary_nature);
565
/*-----------------------------------------------------------------------------
566
* Get boundary attribute like nature or label
569
* ith_zone --> boundary index
570
* nodeName --> xml attribute name. for example, "nature" or "label"
571
*----------------------------------------------------------------------------*/
574
get_boundary_attribute(unsigned int ith_zone,
575
const char *nodeName)
578
char *path = cs_xpath_init_path();
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);
584
result = cs_gui_get_attribute_value(path);
591
/*-----------------------------------------------------------------------------
592
* Init xpath for internal coupling with:
594
* boundary_conditions/wall[label=label]/
595
* ale[choice=internal_coupling]/node_name, node_sub_name/text()
598
* label --> boundary label
599
* node_name --> xml node name ("initial_displacement")
600
* node_sub_name --> xml child node of node_name ("X")
601
*----------------------------------------------------------------------------*/
604
init_internal_coupling_xpath(const char* label,
605
const char* node_name,
606
const char* node_sub_name)
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);
623
/*-----------------------------------------------------------------------------
624
* Get internal coupling double
627
* label --> boundary label
628
* node_name --> xml node name ("initial_displacement")
629
* node_sub_name --> xml child node of node_name ("X")
630
*----------------------------------------------------------------------------*/
633
get_internal_coupling_double(const char* label,
634
const char* node_name,
635
const char* node_sub_name)
638
char *path = init_internal_coupling_xpath(label, node_name, node_sub_name);
640
if (!cs_gui_get_double(path, &value))
642
bft_error(__FILE__, __LINE__, 0,
643
_("cannot get value for %s %s %s"),
644
label, node_name, node_sub_name);
652
/*-----------------------------------------------------------------------------
653
* Get internal coupling string
656
* label --> boundary label
657
* node_name --> xml node name ("initial_displacement")
658
* node_sub_name --> xml child node of node_name ("formula")
659
*----------------------------------------------------------------------------*/
662
get_internal_coupling_string(const char* label,
663
const char* node_name,
664
const char* node_sub_name)
666
char *path = init_internal_coupling_xpath(label, node_name, node_sub_name);
667
char* str = cs_gui_get_text_value(path);
675
/*-----------------------------------------------------------------------------
676
* Retreive internal coupling x, y and z XML values
679
* label --> boundary label
680
* node_name --> xml node name ("initial_displacement")
681
* xyz <-- result matrix
682
*----------------------------------------------------------------------------*/
685
get_internal_coupling_xyz_values(const char *label,
686
const char *node_name,
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");
695
/*-----------------------------------------------------------------------------
696
* Retreive internal coupling advanced windows double value
699
* node_name --> xml node name ("displacement_prediction_alpha")
700
*----------------------------------------------------------------------------*/
703
get_uistr1_advanced_double(const char *const keyword,
707
char *path = cs_xpath_init_path();
709
cs_xpath_add_elements(&path, 3, "thermophysical_models", "ale_method", keyword);
710
cs_xpath_add_function_text(&path);
712
if (cs_gui_get_double(path, &result))
717
/*-----------------------------------------------------------------------------
718
* Retreive internal coupling advanced windows checkbox value
721
* node_name --> xml node name ("monitor_point_synchronisation")
722
*----------------------------------------------------------------------------*/
725
get_uistr1_advanced_checkbox(const char *const keyword, int *const value)
728
char *path = cs_xpath_init_path();
730
cs_xpath_add_elements(&path, 3, "thermophysical_models", "ale_method", keyword);
731
cs_xpath_add_attribute(&path, "status");
733
if (cs_gui_get_status(path, &result))
738
/*-----------------------------------------------------------------------------
739
* Retreive data the internal coupling matrices
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
*----------------------------------------------------------------------------*/
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,
769
/* Get the formula */
773
char *matrix = get_internal_coupling_string(label, node_name, "formula");
776
bft_error(__FILE__, __LINE__, 0,
777
_("Formula is null for %s %s"), label, node_name);
780
tree = cs_gui_init_mei_tree(matrix, symbols, symbol_nbr,
781
variables, variables_value, variable_nbr,
782
dtref, ttcabs, ntcabs);
785
/* Read matrix values */
786
for (i = 0; i < symbol_nbr; ++i)
788
const char *symbol = symbols[i];
789
output_matrix[i] = mei_tree_lookup(tree, symbol);
792
mei_tree_destroy(tree);
793
#endif /* HAVE_MEI */
796
/*-----------------------------------------------------------------------------
797
* Retreive data for internal coupling for a specific boundary
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
*----------------------------------------------------------------------------*/
812
get_uistr2_data(const char *label,
813
double *const xmstru,
814
double *const xcstru,
815
double *const xkstru,
816
double *const forstr,
822
const char *m_symbols[] = {"m11", "m12", "m13",
824
"m31", "m32", "m33"};
825
const char *c_symbols[] = {"c11", "c12", "c13",
827
"c31", "c32", "c33"};
828
const char *k_symbols[] = {"k11", "k12", "k13",
830
"k31", "k32", "k33"};
832
unsigned int symbol_nbr = sizeof(m_symbols) / sizeof(m_symbols[0]);
834
const char *force_symbols[] = {"fx", "fy", "fz"};
835
unsigned int force_symbol_nbr = sizeof(force_symbols) / sizeof(force_symbols[0]);
837
const unsigned int variable_nbr = 3;
838
const char *variables[3] = {"fluid_fx", "fluid_fy", "fluid_fz"};
839
double variable_values[3];
841
/* Get mass matrix, damping matrix and stiffness matrix */
843
get_internal_coupling_matrix(label, "mass_matrix", m_symbols,
845
&xmstru[istruc * symbol_nbr],
846
dtref, ttcabs, ntcabs);
848
get_internal_coupling_matrix(label, "damping_matrix", c_symbols,
850
&xcstru[istruc * symbol_nbr],
851
dtref, ttcabs, ntcabs);
853
get_internal_coupling_matrix(label, "stiffness_matrix", k_symbols,
855
&xkstru[istruc * symbol_nbr],
856
dtref, ttcabs, ntcabs);
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];
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);
871
/*-----------------------------------------------------------------------------
872
* Return the post synchronization status
874
* <thermophysical_models>
875
* <ale_method status="on">
876
* <external_coupling_post_synchronization ***status="off"*** />
878
*----------------------------------------------------------------------------*/
881
get_coupling_post_synchronization_status(void)
886
char *path = cs_xpath_init_path();
888
cs_xpath_add_elements(&path, 3, "thermophysical_models",
890
"external_coupling_post_synchronization");
891
cs_xpath_add_attribute(&path, "status");
893
statusStr = cs_gui_get_attribute_value(path);
894
status = cs_gui_strcmp(statusStr, "on");
903
/*-----------------------------------------------------------------------------
904
* Return the external coupling DDL value
906
* <boundary_conditions>
907
* <wall label=label_argument">
908
* <ale choice="external_coupling">
909
* <node_name_argument choice="off"/>
911
* label --> The wall label.
912
* node_name --> Node name: DDLX, DDLY or DDLZ.
913
*----------------------------------------------------------------------------*/
916
get_external_coupling_ddl(const char *const label,
917
const char *const node_name)
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");
930
choice = cs_gui_get_attribute_value(path);
931
isOn = cs_gui_strcmp(choice, "on");
939
/*============================================================================
940
* Public Fortran function definitions
941
*============================================================================*/
943
/*----------------------------------------------------------------------------
946
* ncel --> number of cells whithout halo
950
* xyzcen --> cell's gravity center
951
* dtref --> time step
952
* ttcabs --> current time
953
* ntcabs --> current iteration number
954
*----------------------------------------------------------------------------*/
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,
962
double *const ttcabs,
963
const int *const ntcabs)
965
#if defined(HAVE_MEI)
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;
971
/* Check if user function is selection */
972
if (get_ale_property_choice() == ale_property_choice_user_function)
976
char *aleFormula = get_ale_formula();
977
char *viscosityType = get_ale_mesh_viscosity();
978
unsigned int isOrthotrop = cs_gui_strcmp(viscosityType, "orthotrop");
984
bft_error(__FILE__, __LINE__, 0,
985
_("Formula is null for ale.\n"));
988
ev = cs_gui_init_mei_tree(aleFormula, variables,
989
variable_nbr, symbols, 0, 3,
990
*dtref, *ttcabs, *ntcabs);
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++)
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]);
1003
/* Set viscmx, viscmy and viscmz */
1004
viscmx[iel] = mei_tree_lookup(ev, "mesh_vi1");
1007
viscmy[iel] = mei_tree_lookup(ev, "mesh_vi2");
1008
viscmz[iel] = mei_tree_lookup(ev, "mesh_vi3");
1011
mei_tree_destroy(ev);
1012
BFT_FREE(aleFormula);
1013
BFT_FREE(viscosityType);
1015
#endif /* HAVE_MEI */
1018
/*----------------------------------------------------------------------------
1019
* ALE related keywords
1021
* Fortran Interface:
1026
* INTEGER IALE <-- iale method activation
1027
* INTEGER NALINF <-- number of sub iteration of initialization
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
1035
*----------------------------------------------------------------------------*/
1037
void CS_PROCF (uialin, UIALIN) (int *const iale,
1040
double *const epalim,
1045
cs_gui_get_ale_status(iale);
1048
value =(double) *nalinf;
1049
cs_gui_iale_parameter("fluid_initialization_sub_iterations", &value);
1050
*nalinf = (int) value;
1052
value =(double) *nalimx;
1053
cs_gui_iale_parameter("max_iterations_implicitation", &value);
1054
*nalimx = (int) value;
1056
cs_gui_iale_parameter("implicitation_precision", epalim);
1058
value =(double) *iortvm;
1059
cs_gui_iale_parameter("mesh_viscosity", &value);
1060
*iortvm = (int) value;
1064
bft_printf("==>UIALIN\n");
1065
bft_printf("--iale = %i\n", *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);
1075
/*-----------------------------------------------------------------------------
1079
* nfabor --> Number of boundary faces
1080
* nozppm --> Max number of boundary conditions zone
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
*----------------------------------------------------------------------------*/
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,
1101
const int *const ipnfbr,
1102
const int *const nnod,
1103
const int *const nodfbr,
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)
1118
int zones = cs_gui_boundary_zones_number();
1120
/* At each time-step, loop on boundary faces: */
1121
for (izone=0 ; izone < zones ; izone++)
1123
int* faces_list = cs_gui_get_faces_list(izone,
1124
boundaries->label[izone],
1129
/* get the ale choice */
1130
const char* label = boundaries->label[izone];
1131
enum ale_boundary_nature nature = get_ale_boundary_nature(label);
1133
if (nature == ale_boundary_nature_fixed_wall)
1135
for (ifac = 0; ifac < faces; ifac++)
1137
int ifbr = faces_list[ifac]-1;
1138
ialtyb[ifbr] = *ibfixe;
1141
else if (nature == ale_boundary_nature_sliding_wall)
1143
for (ifac = 0; ifac < faces; ifac++)
1145
int ifbr = faces_list[ifac]-1;
1146
ialtyb[ifbr] = *igliss;
1149
else if (nature == ale_boundary_nature_fixed_displacement)
1151
for (ifac = 0; ifac < faces; ifac++)
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);
1159
else if (nature == ale_boundary_nature_fixed_velocity)
1161
for (ifac = 0; ifac < faces; ifac++)
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;
1170
BFT_FREE(faces_list);
1174
/*-----------------------------------------------------------------------------
1175
* Retreive data for internal coupling. Called once at initialization
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
*----------------------------------------------------------------------------*/
1189
void CS_PROCF (uistr1, UISTR1) (const int *const nfabor,
1204
int *faces_list = NULL;
1205
unsigned int istruct = 0;
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);
1213
zones = cs_gui_boundary_zones_number();
1215
/* At each time-step, loop on boundary faces */
1216
for (izone=0 ; izone < zones ; izone++)
1218
char *nature = get_boundary_attribute(izone + 1, "nature");
1219
char *label = get_boundary_attribute(izone + 1, "label");
1221
/* Keep only internal coupling */
1222
if (get_ale_boundary_nature(label) == ale_boundary_nature_internal_coupling)
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]);
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++)
1236
ifbr = faces_list[ifac]-1;
1237
idfstr[ifbr] = istruct + 1;
1240
BFT_FREE(faces_list);
1247
/*-----------------------------------------------------------------------------
1248
* Retreive data for internal coupling. Called at each step
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
*----------------------------------------------------------------------------*/
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,
1269
unsigned int istru = 0;
1271
int zones = cs_gui_boundary_zones_number();
1273
/* At each time-step, loop on boundary faces */
1274
for (izone=0 ; izone < zones ; izone++)
1276
const char *label = boundaries->label[izone];
1278
/* Keep only internal coupling */
1279
if (get_ale_boundary_nature(label) == ale_boundary_nature_internal_coupling)
1282
/* Read internal coupling data for boundaries */
1283
for (int ii=0; ii<3; ii++)
1290
get_uistr2_data(label,
1304
/*-----------------------------------------------------------------------------
1305
* Retreive data for external coupling
1308
* nfabor <-- Number of boundary faces
1309
* idfstr <-- Structure definition
1310
* asddlf <-- Block of the DDL forces
1312
*----------------------------------------------------------------------------*/
1315
CS_PROCF (uiaste, UIASTE) (const int *const nfabor,
1317
double *const asddlf,
1326
int zones = cs_gui_boundary_zones_number();
1328
/* Get the coupling post synchronization status */
1329
*isyncp = get_coupling_post_synchronization_status() ? 1 : 0;
1331
/* At each time-step, loop on boundary faces */
1332
for (izone=0 ; izone < zones ; izone++)
1334
const char *label = boundaries->label[izone];
1336
/* Keep only internal coupling */
1337
if (get_ale_boundary_nature(label) == ale_boundary_nature_external_coupling)
1339
int* faces_list = cs_gui_get_faces_list(izone, label, *nfabor, 0, &faces);
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;
1346
/* Set idfstr with negativ value starting from -1 */
1347
for (ifac = 0; ifac < faces; ifac++)
1349
ifbr = faces_list[ifac]-1;
1350
idfstr[ifbr] = -istruct - 1;
1353
BFT_FREE(faces_list);
1358
/*----------------------------------------------------------------------------*/