2
This file is part of Code_Saturne, a general-purpose CFD tool.
4
Copyright (C) 1998-2011 EDF S.A.
6
This program is free software; you can redistribute it and/or modify it under
7
the terms of the GNU General Public License as published by the Free Software
8
Foundation; either version 2 of the License, or (at your option) any later
11
This program is distributed in the hope that it will be useful, but WITHOUT
12
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16
You should have received a copy of the GNU General Public License along with
17
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
18
Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
/*----------------------------------------------------------------------------*/
23
/*----------------------------------------------------------------------------
24
* Standard C library headers
25
*----------------------------------------------------------------------------*/
29
/*----------------------------------------------------------------------------
31
*----------------------------------------------------------------------------*/
33
#include "utilitaires.h"
35
#include "communication.h"
37
/*----------------------------------------------------------------------------
38
* Header for the current file
39
*----------------------------------------------------------------------------*/
41
#include "runmilieu.h"
43
/*----------------------------------------------------------------------------*/
49
/*============================================================================
51
*============================================================================*/
67
/*============================================================================
68
* Public function definitions
69
*============================================================================*/
71
/*----------------------------------------------------------------------------
72
* "runmilieu" function
73
*----------------------------------------------------------------------------*/
76
runmilieu(void *icompo)
85
double dt_ast, dt_sat;
89
/* Input data for the coupled calculation are defined in SALOME by
90
the study case's XML file */
92
/* Initialize communication */
93
if ((ierr = inicom(icompo)) >= 0) {
94
printf(" Initializing communication\n");
97
/* Send parameters to codes */
98
if ((ierr = send_param(icompo)) >= 0) {
99
printf(" Send calculation parameters to codes\n");
102
/* Compute array sizes and initialize */
104
/* Receive geometric data (nb_for and nb_dyn) */
106
ierr = recv_geom(icompo);
108
printf("----------------------------------\n");
109
printf(" Geometric parameters\n");
110
printf(" number of coupled faces: %i\n", nb_for);
111
printf(" number of coupled nodes: %i\n", nb_dyn);
112
printf(" reference length (m): %4.2le\n", lref );
113
printf("----------------------------------\n");
121
/* Prediction coefficients */
129
/* Send geometric data to Code_Aster (remove in the future)*/
131
ierr = send_geom(icompo);
134
/* Initialize time step */
139
/* Initialize coupling iteration */
146
printf("----------------------------------------------------\n");
148
printf("*********************************\n");
149
printf("* iteration %i *\n", i);
150
printf("*********************************\n");
154
/* Info on time scheme */
156
printf("Explicit time-stepping scheme\n");
159
printf("Implicit time-stepping scheme\n");
160
printf(" number of sub-iterations: %i\n", nbssit);
163
/* Manage time steps */
165
/* Receive time steps from Code_Aster and Code_Saturne */
166
ierr = recv_pdt(icompo,&(dt_ast), &(dt_sat), i);
168
printf("----------------------------------\n");
169
printf("reference time step: %4.21e \n", dtref );
170
printf("Code_Saturne time step: %4.2le \n", dt_sat);
171
printf("Code_Aster time step: %4.2le \n", dt_ast);
173
/* choose the smallest time step: dt = dt_ast; */
182
/* Send the selected time step */
183
if (ierr >= 0) ierr = send_pdt(icompo, dt, i);
185
printf("selected time step: %4.2le \n", dt);
186
printf("----------------------------------\n");
194
printf("*********************************\n");
195
printf("* sub - iteration %i *\n", j);
196
printf("*********************************\n");
199
/* increment coupling iteration */
202
printf("ntcast = %i\n", ntcast);
204
/* printf("***************************************\n"); */
205
/* printf("* predict displacements *\n"); */
206
/* printf("***************************************\n"); */
208
/* Predict displacements */
214
/* seperate prediction for explicit/implicit cases */
219
c2 = (alpha + beta) * dt ;
221
pred(xastp, xast, xvast, xvasa, c1, c2, c3, nb_dyn);
229
pred(xastp, xast, xastp, xast, c1, c2, c3, nb_dyn);
232
printf("--------------------------------------------\n");
233
printf("Displacement prediction coefficients\n");
234
printf(" C1: %4.2le\n", c1);
235
printf(" C2: %4.2le\n", c2);
236
printf(" C3: %4.2le\n", c3);
237
printf("--------------------------------------------\n");
240
/* send predicted displacements */
241
if (ierr >= 0) ierr = send_dyn(icompo);
243
/* explicit case: no need for a convergence test */
245
/* implicit case: needs a convergence test */
247
/* printf("***************************************\n"); */
248
/* printf("* end of displacements prediction *\n"); */
249
/* printf("***************************************\n"); */
251
/* printf("*********************************\n"); */
252
/* printf("* forces prediction *\n"); */
253
/* printf("*********************************\n"); */
256
ierr = recv_for(icompo);
258
/* No difference between explicit and implicit cases for forces */
263
pred(fopas, foras, foaas, foaas, c1, c2, c3, nb_for);
264
printf("--------------------------------------\n");
265
printf("Forces prediction coefficients\n");
266
printf(" C1: %4.2le\n",c1);
267
printf(" C2: %4.2le\n",c2);
268
printf(" C3: %4.2le\n",c3);
269
printf("--------------------------------------\n");
272
/* send des forces */
273
if (ierr >= 0) ierr = send_for(icompo);
275
/* printf("*********************************\n"); */
276
/* printf("* end of forces prediction *\n"); */
277
/* printf("*********************************\n"); */
281
/* explicit case: no need fo a convergence test */
283
/* handle convergence even when no test is done */
285
if (ierr >= 0) ierr = send_icv1(icompo,icv);
286
if (ierr >= 0) ierr = recv_icv(icompo,&(icv));
288
if (ierr >= 0) ierr = send_icv2(icompo,icv);
290
/* receive displacements effectively calculated by Code_Aster */
291
if (ierr >= 0) ierr = recv_dyn(icompo);
293
/* record previous values */
299
/* implicit case: requires a convergence test */
302
if (ierr >= 0) ierr = conv(&(icv));
303
if (ierr >= 0) ierr = send_icv1(icompo,icv);
304
if (ierr >= 0) ierr = recv_icv(icompo,&(icv));
305
if (ierr >= 0) ierr = send_icv2(icompo,icv);
307
if((j>=nbssit) || (icv == 1)) {
308
/* receive displacements effectivemey computed by Code_Aster */
309
/* Receive displacements */
310
if (ierr >= 0) ierr = recv_dyn(icompo);
312
/* then send to Code_Saturne ? the question remains open... */
313
/* if necessary, function to send these displs. should be
314
created in middle and matching receive in Code_Saturne */
315
/* if (ierr >= 0) ierr = send2_dyn(); */
317
/* receive displacements effectiveley calculated by Code_Aster */
318
if (ierr >= 0) ierr = recv_dyn(icompo);
325
} /* end of sub-iterations loop */
327
/* iterations test */
331
/* end of iterations test */
338
} /* en of iterations loop */
340
ierr = calfin(icompo);
343
/*----------------------------------------------------------------------------*/