Code_Saturne
CFD tool
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
cs_halo_perio.h
Go to the documentation of this file.
1 #ifndef __CS_HALO_PERIO_H__
2 #define __CS_HALO_PERIO_H__
3 
4 /*============================================================================
5  * Structure and function headers associated to periodicity
6  *============================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2012 EDF S.A.
12 
13  This program is free software; you can redistribute it and/or modify it under
14  the terms of the GNU General Public License as published by the Free Software
15  Foundation; either version 2 of the License, or (at your option) any later
16  version.
17 
18  This program is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21  details.
22 
23  You should have received a copy of the GNU General Public License along with
24  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25  Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 */
27 
28 /*----------------------------------------------------------------------------*/
29 
30 #include "cs_defs.h"
31 
32 /*----------------------------------------------------------------------------
33  * Local headers
34  *----------------------------------------------------------------------------*/
35 
36 #include "cs_base.h"
37 #include "cs_halo.h"
38 
39 /*----------------------------------------------------------------------------*/
40 
42 
43 /*============================================================================
44  * Type definitions
45  *============================================================================*/
46 
47 /*============================================================================
48  * Public function header for Fortran API
49  *============================================================================*/
50 
51 /*----------------------------------------------------------------------------
52  * Process dpdx, dpdy, dpdz buffers in case of rotation on velocity vector and
53  * Reynolds stress tensor.
54  *
55  * We retrieve the gradient given by perinu and perinr (phyvar) for the
56  * velocity and the reynolds stress tensor in a buffer on ghost cells. then
57  * we define dpdx, dpdy and dpdz gradient (1 -> n_cells_with_ghosts).
58  *
59  * We can't implicitly take into account rotation of a gradient of a non-scalar
60  * variable because we have to know the all three components in grad*c.
61  *
62  * Otherwise, we can implicitly treat values given by translation. There will
63  * be replace further in grad*c.
64  *
65  * We assume that is correct to treat periodicities implicitly for the other
66  * variables.
67  *
68  * Fortran Interface:
69  *
70  * subroutine persyn
71  * *****************
72  *
73  * integer ivar : -> : numero de la variable
74  * integer iu : <-- : position de la Vitesse(x,y,z)
75  * integer iv : <-- : dans RTP, RTPA
76  * integer iw : <-- : " "
77  * integer itytur : <-- : turbulence (Rij-epsilon ITYTUR = 3)
78  * integer ir11 : <-- : position des Tensions de Reynolds
79  * integer ir22 : <-- : en Rij dans RTP, RTPA
80  * integer ir33 : <-- : " "
81  * integer ir12 : <-- : " "
82  * integer ir13 : <-- : " "
83  * integer ir23 : <-- : " "
84  * double precision dpdx(ncelet) : <-> : gradient de IVAR
85  * double precision dpdy(ncelet) : <-> : " "
86  * double precision dpdz(ncelet) : <-> : " "
87  *----------------------------------------------------------------------------*/
88 
89 void
90 CS_PROCF (persyn, PERSYN)(const cs_int_t *ivar,
91  const cs_int_t *iu,
92  const cs_int_t *iv,
93  const cs_int_t *iw,
94  const cs_int_t *itytur,
95  const cs_int_t *ir11,
96  const cs_int_t *ir22,
97  const cs_int_t *ir33,
98  const cs_int_t *ir12,
99  const cs_int_t *ir13,
100  const cs_int_t *ir23,
101  cs_real_t dpdx[],
102  cs_real_t dpdy[],
103  cs_real_t dpdz[]);
104 
105 /*----------------------------------------------------------------------------
106  * Rotate vector values for periodic cells on extended halos.
107  *
108  * Fortran API:
109  *
110  * subroutine perrve
111  * *****************
112  *
113  * double precision var1(ncelet) : <-> : component 1 of vector
114  * double precision var2(ncelet) : <-> : component 2 of vector
115  * double precision var3(ncelet) : <-> : component 3 of vector
116  *----------------------------------------------------------------------------*/
117 
118 void
119 CS_PROCF (perrve, PERRVE) (cs_real_t var1[],
120  cs_real_t var2[],
121  cs_real_t var3[]);
122 
123 /*----------------------------------------------------------------------------
124  * Rotate tensor values for periodic cells on extended halos.
125  *
126  * Fortran API:
127  *
128  * subroutine perrte
129  * *****************
130  *
131  * double precision var11(ncelet) : <-> : component 11 of rank 2 tensor
132  * double precision var12(ncelet) : <-> : component 12 of rank 2 tensor
133  * double precision var13(ncelet) : <-> : component 13 of rank 2 tensor
134  * double precision var21(ncelet) : <-> : component 21 of rank 2 tensor
135  * double precision var22(ncelet) : <-> : component 22 of rank 2 tensor
136  * double precision var23(ncelet) : <-> : component 23 of rank 2 tensor
137  * double precision var31(ncelet) : <-> : component 31 of rank 2 tensor
138  * double precision var32(ncelet) : <-> : component 32 of rank 2 tensor
139  * double precision var33(ncelet) : <-> : component 33 of rank 2 tensor
140  *----------------------------------------------------------------------------*/
141 
142 void
143 CS_PROCF (perrte, PERRTE) (cs_real_t var11[],
144  cs_real_t var12[],
145  cs_real_t var13[],
146  cs_real_t var21[],
147  cs_real_t var22[],
148  cs_real_t var23[],
149  cs_real_t var31[],
150  cs_real_t var32[],
151  cs_real_t var33[]);
152 
153 /*----------------------------------------------------------------------------
154  * Periodicity management for INIMAS
155  *
156  * If INIMAS is called by NAVSTO :
157  * We assume that gradient on ghost cells given by a rotation is known
158  * and is equal to the velocity one for the previous time step.
159  * If INIMAS is called by DIVRIJ
160  * We assume that (more justifiable than in previous case) gradient on
161  * ghost cells given by rotation is equal to Rij gradient for the previous
162  * time step.
163  *
164  * Fortran Interface:
165  *
166  * SUBROUTINE PERMAS
167  * *****************
168  *
169  * INTEGER IMASPE : -> : suivant l'appel de INIMAS
170  * = 1 si appel de RESOLP ou NAVSTO
171  * = 2 si appel de DIVRIJ
172  * INTEGER IMASPE : -> : indicateur d'appel dans INIMAS
173  * = 1 si appel au debut
174  * = 2 si appel a la fin
175  * DOUBLE PRECISION ROM(NCELET) : -> : masse volumique aux cellules
176  * DOUBLE PRECISION DUDXYZ : -> : gradient de U aux cellules halo pour
177  * l'approche explicite en periodicite
178  * DOUBLE PRECISION DRDXYZ : -> : gradient de R aux cellules halo pour
179  * l'approche explicite en periodicite
180  * DOUBLE PRECISION WDUDXY : - : tableau de travail pour DUDXYZ
181  * DOUBLE PRECISION WDRDXY : - : tableau de travail pour DRDXYZ
182  *
183  * Size of DUDXYZ and WDUDXY = n_ghost_cells*3*3
184  * Size of DRDXYZ and WDRDXY = n_ghost_cells*6*3
185  *----------------------------------------------------------------------------*/
186 
187 void
188 CS_PROCF (permas, PERMAS)(const cs_int_t *imaspe,
189  const cs_int_t *iappel,
190  cs_real_t rom[],
191  cs_real_t *dudxyz,
192  cs_real_t *drdxyz,
193  cs_real_t *wdudxy,
194  cs_real_t *wdrdxy);
195 
196 /*----------------------------------------------------------------------------
197  * Process dpdx, dpdy, dpdz buffers in case of rotation on velocity vector and
198  * Reynolds stress tensor.
199  *
200  * We retrieve the gradient given by perinu and perinr (phyvar) for the
201  * velocity and the Reynolds stress tensor in a buffer on ghost cells. then
202  * we define dpdx, dpdy and dpdz gradient (1 -> n_cells_with_ghosts).
203  *
204  * We can't implicitly take into account rotation of a gradient of alnon-scalar
205  * variable because we have to know the all three components in gradrc.
206  *
207  * Otherwise, we can implicitly treat values given by translation. There will
208  * be replace further in GRADRC.
209  *
210  * We set idimtr to 1 and 2 respectively for the velocity vector and the
211  * Reynolds stress tensor.
212  *
213  * We assume that is correct to treat periodicities implicitly for the other
214  * variables in gradrc, for which we set idimtr to 0.
215  *
216  * Fortran Interface:
217  *
218  * subroutine pering
219  * *****************
220  *
221  * integer ivar : <-- : variable number
222  * integer idimtr : <-- : 0 if ivar does not match a vector
223  * : : or tensor or there is no periodicity
224  * : : of rotation
225  * : : 1 for velocity, 2 for Reynolds stress
226  * : : in case of periodicity of rotation
227  * integer irpvar : : -1 if ivar does not match a vector or
228  * : : or tensor or there is no periodicity
229  * : : of rotation; otherwise:
230  * : : 0 for iu, 1 for iv, 2 for iw
231  * : : 0 for ir11, 1 for ir22, 2 for ir33,
232  * : : 3 for ir12, 4 for ir13, 5 for ir23
233  * integer iguper : <-- : 0/1 indicates we have not computed
234  * : : gradients in dudxyz
235  * integer igrper : <-- : 0/1 indicates we have not computed
236  * : : gradients in drdxyz
237  * double precision dpdx(ncelet) : <-> : gradient of ivar
238  * double precision dpdy(ncelet) : <-> : " "
239  * double precision dpdz(ncelet) : <-> : " "
240  * double precision dudxyz : -> : gradient of u at ghost cells for
241  * explicit periodicity of rotation
242  * double precision drdxyz : -> : gradient of r at ghost cells for
243  * explicit periodicity of rotation
244  *
245  * size of dudxyz and wdudxy = n_ghost_cells*3*3
246  * size of drdxyz and wdrdxy = n_ghost_cells*6*3
247  *----------------------------------------------------------------------------*/
248 
249 void
250 CS_PROCF (pering, PERING)(const cs_int_t *idimtr,
251  const cs_int_t *irpvar,
252  const cs_int_t *iguper,
253  const cs_int_t *igrper,
254  cs_real_t dpdx[],
255  cs_real_t dpdy[],
256  cs_real_t dpdz[],
257  const cs_real_t *dudxyz,
258  const cs_real_t *drdxyz);
259 
260 /*----------------------------------------------------------------------------
261  * Exchange buffers for PERINU
262  *
263  * Fortran Interface:
264  *
265  * SUBROUTINE PEINU1
266  * *****************
267  *
268  * INTEGER ISOU : -> : component of the velocity vector
269  * DOUBLE PRECISION DUDXYZ : -> : gradient of the velocity vector
270  * for ghost cells and for an explicit
271  * treatment of the periodicity.
272  * DOUBLE PRECISION W1..3(NCELET) : - : working buffers
273  *
274  * Size of DUDXYZ and WDUDXY = n_ghost_cells*3*3
275  *----------------------------------------------------------------------------*/
276 
277 void
278 CS_PROCF (peinu1, PEINU1)(const cs_int_t *isou,
279  cs_real_t *dudxyz,
280  cs_real_t w1[],
281  cs_real_t w2[],
282  cs_real_t w3[]);
283 
284 /*----------------------------------------------------------------------------
285  * Apply rotation on DUDXYZ tensor.
286  *
287  * Fortran Interface:
288  *
289  * SUBROUTINE PEINU2 (VAR)
290  * *****************
291  *
292  * DOUBLE PRECISION DUDXYZ : <-> : gradient of the velocity vector
293  * for ghost cells and for an explicit
294  * treatment of the periodicity.
295  *
296  * Size of DUDXYZ and WDUDXY = n_ghost_cells*3*3
297  *----------------------------------------------------------------------------*/
298 
299 void
300 CS_PROCF (peinu2, PEINU2)(cs_real_t *dudxyz);
301 
302 /*----------------------------------------------------------------------------
303  * Exchange buffers for PERINR
304  *
305  * Fortran Interface
306  *
307  * SUBROUTINE PEINR1 (VAR)
308  * *****************
309  *
310  * INTEGER ISOU : -> : component of the Reynolds stress tensor
311  * DOUBLE PRECISION DRDXYZ : -> : gradient of the Reynolds stress tensor
312  * for ghost cells and for an explicit
313  * treatment of the periodicity.
314  * DOUBLE PRECISION GRADX(NCELET)
315  * GRADY(NCELET)
316  * GRADZ(NCELET) : - : x, y, z components of the gradient of
317  * the current component of the Reynolds
318  * stress tensor.
319  *
320  * Size of DRDXYZ and WDRDXY = n_ghost_cells*6*3
321  *----------------------------------------------------------------------------*/
322 
323 void
324 CS_PROCF (peinr1, PEINR1)(const cs_int_t *isou,
325  cs_real_t *drdxyz,
326  cs_real_t gradx[],
327  cs_real_t grady[],
328  cs_real_t gradz[]);
329 
330 /*----------------------------------------------------------------------------
331  * Apply rotation on the gradient of Reynolds stress tensor
332  *
333  * Fortran Interface:
334  *
335  * SUBROUTINE PEINR2 (VAR)
336  * *****************
337  *
338  * DOUBLE PRECISION DRDXYZ : -> : gradient of the Reynolds stress tensor
339  * for ghost cells and for an explicit
340  * treatment of the periodicity.
341  *
342  * Size of DRDXYZ and WDRDXY = n_ghost_cells*6*3
343  *----------------------------------------------------------------------------*/
344 
345 void
346 CS_PROCF (peinr2, PEINR2)(cs_real_t *drdxyz);
347 
348 /*=============================================================================
349  * Public function prototypes
350  *============================================================================*/
351 
352 /*----------------------------------------------------------------------------
353  * Apply transformation on coordinates.
354  *
355  * parameters:
356  * halo <-> halo associated with coordinates to synchronize
357  * sync_mode --> kind of halo treatment (standard or extended)
358  * coords --> coordinates on which transformation have to be done.
359  *----------------------------------------------------------------------------*/
360 
361 void
363  cs_halo_type_t sync_mode,
364  cs_real_t *coords);
365 
366 /*----------------------------------------------------------------------------
367  * Synchronize values for a real vector (interleaved) between periodic cells.
368  *
369  * parameters:
370  * halo <-> halo associated with variable to synchronize
371  * sync_mode --> type of halo treatment (standard or extended)
372  * var <-> vector to update
373  * incvar <-- specifies the increment for the elements of var
374  *----------------------------------------------------------------------------*/
375 
376 void
378  cs_halo_type_t sync_mode,
379  cs_real_t var[],
380  int incvar);
381 
382 /*----------------------------------------------------------------------------
383  * Synchronize values for a real vector between periodic cells.
384  *
385  * parameters:
386  * halo <-> halo associated with variable to synchronize
387  * sync_mode --> kind of halo treatment (standard or extended)
388  * var_x <-> component of the vector to update
389  * var_y <-> component of the vector to update
390  * var_z <-> component of the vector to update
391  *----------------------------------------------------------------------------*/
392 
393 void
395  cs_halo_type_t sync_mode,
396  cs_real_t var_x[],
397  cs_real_t var_y[],
398  cs_real_t var_z[]);
399 
400 /*----------------------------------------------------------------------------
401  * Synchronize values for a real tensor between periodic cells.
402  *
403  * parameters:
404  * halo <-> halo associated with variable to synchronize
405  * sync_mode --> kind of halo treatment (standard or extended)
406  * var11 <-> component of the tensor to update
407  * var12 <-> component of the tensor to update
408  * var13 <-> component of the tensor to update
409  * var21 <-> component of the tensor to update
410  * var22 <-> component of the tensor to update
411  * var23 <-> component of the tensor to update
412  * var31 <-> component of the tensor to update
413  * var32 <-> component of the tensor to update
414  * var33 <-> component of the tensor to update
415  *----------------------------------------------------------------------------*/
416 
417 void
419  cs_halo_type_t sync_mode,
420  cs_real_t var11[],
421  cs_real_t var12[],
422  cs_real_t var13[],
423  cs_real_t var21[],
424  cs_real_t var22[],
425  cs_real_t var23[],
426  cs_real_t var31[],
427  cs_real_t var32[],
428  cs_real_t var33[]);
429 
430 /*----------------------------------------------------------------------------
431  * Synchronize values for a real tensor (interleaved) between periodic cells.
432  *
433  * parameters:
434  * halo <-> halo associated with variable to synchronize
435  * sync_mode --> kind of halo treatment (standard or extended)
436  * var <-> tensor to update
437  *----------------------------------------------------------------------------*/
438 
439 void
441  cs_halo_type_t sync_mode,
442  cs_real_t var[]);
443 
444 /*----------------------------------------------------------------------------
445  * Synchronize values for a real diagonal tensor between periodic cells.
446  *
447  * We only know the diagonal of the tensor.
448  *
449  * parameters:
450  * halo <-> halo associated with variable to synchronize
451  * sync_mode --> kind of halo treatment (standard or extended)
452  * var11 <-> component of the tensor to update
453  * var22 <-> component of the tensor to update
454  * var33 <-> component of the tensor to update
455  *----------------------------------------------------------------------------*/
456 
457 void
459  cs_halo_type_t sync_mode,
460  cs_real_t var11[],
461  cs_real_t var22[],
462  cs_real_t var33[]);
463 
464 /*----------------------------------------------------------------------------
465  * Synchronize values for a real diagonal tensor (interleaved)
466  * between periodic cells.
467  *
468  * We only know the diagonal of the tensor.
469  *
470  * parameters:
471  * halo <-> halo associated with variable to synchronize
472  * sync_mode --> kind of halo treatment (standard or extended)
473  * var <-> diagonal tensor to update
474  *----------------------------------------------------------------------------*/
475 
476 void
478  cs_halo_type_t sync_mode,
479  cs_real_t var[]);
480 
481 /*----------------------------------------------------------------------------*/
482 
484 
485 #endif /* __CS_HALO_PERIO_H__ */
486 
void cs_halo_perio_sync_var_vect_ni(const cs_halo_t *halo, cs_halo_type_t sync_mode, cs_real_t var_x[], cs_real_t var_y[], cs_real_t var_z[])
Definition: cs_halo_perio.c:1420
void cs_halo_perio_sync_var_vect(const cs_halo_t *halo, cs_halo_type_t sync_mode, cs_real_t var[], int incvar)
Definition: cs_halo_perio.c:1349
void cs_halo_perio_sync_var_tens_ni(const cs_halo_t *halo, cs_halo_type_t sync_mode, cs_real_t var11[], cs_real_t var12[], cs_real_t var13[], cs_real_t var21[], cs_real_t var22[], cs_real_t var23[], cs_real_t var31[], cs_real_t var32[], cs_real_t var33[])
Definition: cs_halo_perio.c:1524
void permas(const cs_int_t *imaspe, const cs_int_t *iappel, cs_real_t rom[], cs_real_t *dudxyz, cs_real_t *drdxyz, cs_real_t *wdudxy, cs_real_t *wdrdxy)
Definition: cs_halo_perio.c:769
#define BEGIN_C_DECLS
Definition: cs_defs.h:365
Definition: cs_halo.h:75
int cs_int_t
Definition: cs_defs.h:263
void peinu2(cs_real_t *dudxyz)
Definition: cs_halo_perio.c:1068
void cs_halo_perio_sync_var_diag(const cs_halo_t *halo, cs_halo_type_t sync_mode, cs_real_t var[])
Definition: cs_halo_perio.c:1808
void pering(const cs_int_t *idimtr, const cs_int_t *irpvar, const cs_int_t *iguper, const cs_int_t *igrper, cs_real_t dpdx[], cs_real_t dpdy[], cs_real_t dpdz[], const cs_real_t *dudxyz, const cs_real_t *drdxyz)
Definition: cs_halo_perio.c:895
void peinr2(cs_real_t *drdxyz)
Definition: cs_halo_perio.c:1214
void perrve(cs_real_t var1[], cs_real_t var2[], cs_real_t var3[])
Definition: cs_halo_perio.c:678
BEGIN_C_DECLS void persyn(const cs_int_t *ivar, const cs_int_t *iu, const cs_int_t *iv, const cs_int_t *iw, const cs_int_t *itytur, const cs_int_t *ir11, const cs_int_t *ir22, const cs_int_t *ir33, const cs_int_t *ir12, const cs_int_t *ir13, const cs_int_t *ir23, cs_real_t dpdx[], cs_real_t dpdy[], cs_real_t dpdz[])
cs_halo_type_t
Definition: cs_halo.h:49
void peinr1(const cs_int_t *isou, cs_real_t *drdxyz, cs_real_t gradx[], cs_real_t grady[], cs_real_t gradz[])
Definition: cs_halo_perio.c:1185
void cs_halo_perio_sync_coords(const cs_halo_t *halo, cs_halo_type_t sync_mode, cs_real_t *coords)
Definition: cs_halo_perio.c:1283
void peinu1(const cs_int_t *isou, cs_real_t *dudxyz, cs_real_t w1[], cs_real_t w2[], cs_real_t w3[])
Definition: cs_halo_perio.c:1036
void perrte(cs_real_t var11[], cs_real_t var12[], cs_real_t var13[], cs_real_t var21[], cs_real_t var22[], cs_real_t var23[], cs_real_t var31[], cs_real_t var32[], cs_real_t var33[])
Definition: cs_halo_perio.c:712
void cs_halo_perio_sync_var_tens(const cs_halo_t *halo, cs_halo_type_t sync_mode, cs_real_t var[])
Definition: cs_halo_perio.c:1641
#define END_C_DECLS
Definition: cs_defs.h:366
double cs_real_t
Definition: cs_defs.h:264
#define CS_PROCF(x, y)
Definition: cs_defs.h:379
void cs_halo_perio_sync_var_diag_ni(const cs_halo_t *halo, cs_halo_type_t sync_mode, cs_real_t var11[], cs_real_t var22[], cs_real_t var33[])
Definition: cs_halo_perio.c:1713