programmer's documentation
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
cs_internal_coupling.h
Go to the documentation of this file.
1 #ifndef __CS_INTERNAL_COUPLING_H__
2 #define __CS_INTERNAL_COUPLING_H__
3 
4 /*============================================================================
5  * Internal coupling: coupling for one instance of Code_Saturne
6  *============================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2018 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 /*----------------------------------------------------------------------------
31  * PLE library headers
32  *----------------------------------------------------------------------------*/
33 
34 #include <ple_locator.h>
35 
36 /*----------------------------------------------------------------------------
37  * Local headers
38  *----------------------------------------------------------------------------*/
39 
40 #include "cs_base.h"
41 #include "cs_mesh.h"
42 #include "cs_parameters.h"
43 
44 /*----------------------------------------------------------------------------*/
45 
47 
48 /*=============================================================================
49  * Macro definitions
50  *============================================================================*/
51 
52 /*============================================================================
53  * Type definitions
54  *============================================================================*/
55 
56 
57 /* Internal coupling structure definition */
58 
59 typedef struct {
60 
61  /* Locator + tag for exchanging variables */
62  ple_locator_t *locator;
63  int *c_tag;
64 
65  /* Selection criterias for coupled domains */
68 
69  cs_lnum_t n_local; /* Number of faces */
70  cs_lnum_t *faces_local; /* Coupling boundary faces, numbered 0..n-1 */
71 
72  cs_lnum_t n_distant; /* Number of faces in faces_distant */
73  cs_lnum_t *faces_distant; /* Distant boundary faces associated with locator */
74 
75  /* face i is coupled in this entity if coupled_faces[i] = true */
77 
78  /* Geometrical weights around coupling interface */
80 
81  /* IJ vectors */
83 
84  /* OF vectors */
86 
87  /* Gradient reconstruction */
90 
91  /* User information */
92  char *namesca;
93 
95 
96 /*============================================================================
97  * Public function prototypes
98  *============================================================================*/
99 
100 /*----------------------------------------------------------------------------*/
106 /*----------------------------------------------------------------------------*/
107 
108 void
109 cs_internal_coupling_bcs(int bc_type[]);
110 
111 /*----------------------------------------------------------------------------
112  * Destruction of all internal coupling related structures.
113  *----------------------------------------------------------------------------*/
114 
115 void
117 
118 /*----------------------------------------------------------------------------
119  * Return the coupling associated with a given coupling_id.
120  *
121  * parameters:
122  * coupling_id <-> id associated with a coupling entity
123  *----------------------------------------------------------------------------*/
124 
126 cs_internal_coupling_by_id(int coupling_id);
127 
128 /*----------------------------------------------------------------------------
129  * Exchange quantities from distant to local (update local using distant)
130  *
131  * parameters:
132  * cpl <-- pointer to coupling entity
133  * stride <-- Stride (e.g. 1 for double, 3 for interleaved coordinates)
134  * distant <-- Distant values, size coupling->n_distant
135  * local --> Local values, size coupling->n_local
136  *----------------------------------------------------------------------------*/
137 
138 void
140  int stride,
141  cs_real_t distant[],
142  cs_real_t local[]);
143 
144 /*----------------------------------------------------------------------------
145  * Exchange variable between groups using cell id
146  *
147  * parameters:
148  * cpl <-- pointer to coupling entity
149  * stride <-- number of values (non interlaced) by entity
150  * tab <-- variable exchanged
151  * local --> local data
152  *----------------------------------------------------------------------------*/
153 
154 void
156  int stride,
157  const cs_real_t tab[],
158  cs_real_t local[]);
159 
160 /*----------------------------------------------------------------------------
161  * Exchange variable between groups using face id
162  *
163  * parameters:
164  * cpl <-- pointer to coupling entity
165  * stride <-- number of values (non interlaced) by entity
166  * tab <-- variable exchanged
167  * local --> local data
168  *----------------------------------------------------------------------------*/
169 
170 void
172  int stride,
173  const cs_real_t tab[],
174  cs_real_t local[]);
175 
176 /*----------------------------------------------------------------------------
177  * Modify LSQ COCG matrix to include internal coupling
178  *
179  * parameters:
180  * cpl <-- pointer to coupling entity
181  * cocg <-> cocg matrix modified
182  *----------------------------------------------------------------------------*/
183 
184 void
186  cs_real_33_t cocg[]);
187 
188 /*----------------------------------------------------------------------------
189  * Modify LSQ COCG matrix to include internal coupling
190  * when diffusivity is a tensor
191  *
192  * parameters:
193  * cpl <-- pointer to coupling entity
194  * c_weight <-- weigthing coefficients
195  * cocg <-> cocg matrix modified
196  *----------------------------------------------------------------------------*/
197 
198 void
200  const cs_real_t *c_weight,
201  cs_real_33_t cocg[]);
202 
203 /*----------------------------------------------------------------------------
204  * Modify iterative COCG matrix to include internal coupling
205  *
206  * parameters:
207  * cpl <-- pointer to coupling entity
208  * cocg <-> cocg matrix modified
209  *----------------------------------------------------------------------------*/
210 
211 void
213  cs_real_33_t cocg[]);
214 
215 /*----------------------------------------------------------------------------
216  * Initialize internal coupling related structures.
217  *
218  *----------------------------------------------------------------------------*/
219 
220 void
222 
223 /*----------------------------------------------------------------------------*/
232 /*----------------------------------------------------------------------------*/
233 
234 void
236  const cs_internal_coupling_t *cpl,
237  const cs_real_t c_weight[],
238  const int w_stride,
239  cs_real_4_t rhsv[]);
240 
241 /*----------------------------------------------------------------------------*/
251 /*----------------------------------------------------------------------------*/
252 
253 void
255  const cs_internal_coupling_t *cpl,
256  const cs_real_t c_weight[],
257  const int w_stride,
258  const cs_real_3_t pvar[],
259  cs_real_33_t rhs[]);
260 
261 /*----------------------------------------------------------------------------*/
271 /*----------------------------------------------------------------------------*/
272 
273 void
275  const cs_internal_coupling_t *cpl,
276  const cs_real_t c_weight[],
277  const int w_stride,
278  const cs_real_6_t pvar[],
279  cs_real_63_t rhs[]);
280 
281 /*----------------------------------------------------------------------------*/
292 /*----------------------------------------------------------------------------*/
293 
294 void
296  const cs_internal_coupling_t *cpl,
297  const cs_real_t c_weight[],
298  cs_real_3_t *restrict grad,
299  const cs_real_t pvar[],
300  cs_real_3_t rhs[]);
301 
302 /*----------------------------------------------------------------------------*/
313 /*----------------------------------------------------------------------------*/
314 
315 void
317  const cs_internal_coupling_t *cpl,
318  const cs_real_t c_weight[],
319  cs_real_33_t *restrict grad,
320  const cs_real_3_t pvar[],
321  cs_real_33_t rhs[]);
322 
323 /*----------------------------------------------------------------------------*/
334 /*----------------------------------------------------------------------------*/
335 
336 void
338  const cs_internal_coupling_t *cpl,
339  const cs_real_t c_weight[],
340  cs_real_63_t *restrict grad,
341  const cs_real_6_t pvar[],
342  cs_real_63_t rhs[]);
343 
344 /*----------------------------------------------------------------------------*/
353 /*----------------------------------------------------------------------------*/
354 
355 void
357  const cs_internal_coupling_t *cpl,
358  cs_real_3_t *restrict r_grad,
359  cs_real_3_t grad[]);
360 
361 /*----------------------------------------------------------------------------*/
370 /*----------------------------------------------------------------------------*/
371 
372 void
374  const cs_internal_coupling_t *cpl,
375  cs_real_33_t *restrict r_grad,
376  cs_real_33_t grad[]);
377 
378 /*----------------------------------------------------------------------------*/
387 /*----------------------------------------------------------------------------*/
388 
389 void
391  const cs_internal_coupling_t *cpl,
392  cs_real_63_t *restrict r_grad,
393  cs_real_63_t grad[]);
394 
395 /*----------------------------------------------------------------------------
396  * Modify matrix-vector product in case of internal coupling
397  *
398  * parameters:
399  * exclude_diag <-- extra diagonal flag
400  * matrix <-- matrix m in m * x = y
401  * x <-- vector x in m * x = y
402  * y <-> vector y in m * x = y
403  *----------------------------------------------------------------------------*/
404 
405 void
407  void *input,
408  const cs_real_t *restrict x,
409  cs_real_t *restrict y);
410 
411 /*----------------------------------------------------------------------------
412  * Add contribution from coupled faces (internal coupling) to polynomial
413  * preconditionning.
414  *
415  * This function is common to most solvers
416  *
417  * parameters:
418  * input <-- input
419  * ad <-> diagonal part of linear equation matrix
420  *----------------------------------------------------------------------------*/
421 
422 void
424  cs_real_t *ad);
425 
426 /*----------------------------------------------------------------------------
427  * Return pointers to coupling components
428  *
429  * parameters:
430  * cpl <-- pointer to coupling entity
431  * n_local --> NULL or pointer to component n_local
432  * faces_local --> NULL or pointer to component faces_local
433  * n_distant --> NULL or pointer to component n_distant
434  * faces_distant --> NULL or pointer to component faces_distant
435  *----------------------------------------------------------------------------*/
436 
437 void
439  cs_lnum_t *n_local,
440  cs_lnum_t *faces_local[],
441  cs_lnum_t *n_distant,
442  cs_lnum_t *faces_distant[]);
443 
444 /*----------------------------------------------------------------------------
445  * Log information about a given internal coupling entity
446  *
447  * parameters:
448  * cpl <-- pointer to coupling entity
449  *----------------------------------------------------------------------------*/
450 
451 void
453 
454 /*----------------------------------------------------------------------------
455  * Print informations about all coupling entities
456  *
457  * parameters:
458  * cpl <-- pointer to coupling entity
459  *----------------------------------------------------------------------------*/
460 
461 void
463 
464 /*----------------------------------------------------------------------------
465  * Update components hint_* and hext_* using hbord
466  * in the coupling entity associated with given field_id
467  *
468  * parameters:
469  * field_id <-- id of the field
470  * hbord <-- array used to update hint_* and hext_*
471  *----------------------------------------------------------------------------*/
472 
473 void
474 cs_ic_set_exchcoeff(const int field_id,
475  const cs_real_t *hbord);
476 
477 /*----------------------------------------------------------------------------
478  * Define coupling volume using given criterias. Then, this volume will be
479  * seperated from the rest of the domain with thin walls.
480  *
481  * parameters:
482  * mesh <-> pointer to mesh structure to modify
483  * criteria_cells <-- string criteria for the first group of cells
484  *----------------------------------------------------------------------------*/
485 
486 void
488  const char criteria_cells[]);
489 
490 /*----------------------------------------------------------------------------
491  * Define coupling volume using given criterias. Then, this volume has been
492  * seperated from the rest of the domain with a thin wall.
493  *
494  * parameters:
495  * mesh <-> pointer to mesh structure to modify
496  *----------------------------------------------------------------------------*/
497 
498 void
500 
501 /*----------------------------------------------------------------------------
502  * Define coupling volume using given criteria.
503  *
504  * Then, this volume must be seperated from the rest of the domain with a wall.
505  *
506  * parameters:
507  * mesh <-> pointer to mesh structure to modify
508  * criteria_cells <-- selection criteria for the first group of cells
509  * criteria_faces <-- selection criteria for faces to be joined
510  *----------------------------------------------------------------------------*/
511 
512 void
514  const char criteria_cells[],
515  const char criteria_faces[]);
516 
517 /*----------------------------------------------------------------------------
518  * Define coupling entity using given criterias
519  *
520  * parameters:
521  * f_id <-- id of the field
522  *----------------------------------------------------------------------------*/
523 
524 void
526 
527 /*----------------------------------------------------------------------------*/
537 /*----------------------------------------------------------------------------*/
538 
539 void
541  const cs_internal_coupling_t *cpl,
542  const cs_real_t c_weight[],
543  const cs_real_t pvar[],
544  cs_real_3_t *restrict grad);
545 
546 /*----------------------------------------------------------------------------*/
556 /*----------------------------------------------------------------------------*/
557 
558 void
560  const cs_internal_coupling_t *cpl,
561  const cs_real_t c_weight[],
562  const cs_real_3_t pvar[],
563  cs_real_33_t *restrict grad);
564 
565 
566 /*----------------------------------------------------------------------------*/
576 /*----------------------------------------------------------------------------*/
577 
578 void
580  const cs_internal_coupling_t *cpl,
581  const cs_real_t c_weight[],
582  const cs_real_6_t pvar[],
583  cs_real_63_t *restrict grad);
584 
585 
586 /*----------------------------------------------------------------------------*/
587 
589 
590 #endif /* __CS_INTERNAL_COUPLING_H__ */
cs_real_3_t * offset_vect
Definition: cs_internal_coupling.h:85
void cs_internal_coupling_iterative_tensor_gradient(const cs_internal_coupling_t *cpl, const cs_real_t c_weight[], cs_real_63_t *restrict grad, const cs_real_6_t pvar[], cs_real_63_t rhs[])
Add internal coupling rhs contribution for iterative tensor gradient calculation. ...
Definition: cs_internal_coupling.c:1322
ple_locator_t * locator
Definition: cs_internal_coupling.h:62
#define restrict
Definition: cs_defs.h:122
void cs_internal_coupling_exchange_by_face_id(const cs_internal_coupling_t *cpl, int stride, const cs_real_t tab[], cs_real_t local[])
Definition: cs_internal_coupling.c:2031
cs_real_t cs_real_6_t[6]
vector of 6 floating-point values
Definition: cs_defs.h:311
void cs_matrix_preconditionning_add_coupling_contribution(void *input, cs_real_t *ad)
Definition: cs_internal_coupling.c:2644
Definition: cs_internal_coupling.h:59
void cs_internal_coupling_lsq_cocg_weighted(const cs_internal_coupling_t *cpl, const cs_real_t *c_weight, cs_real_33_t cocg[])
Definition: cs_internal_coupling.c:1914
#define BEGIN_C_DECLS
Definition: cs_defs.h:453
void cs_internal_coupling_coupled_faces(const cs_internal_coupling_t *cpl, cs_lnum_t *n_local, cs_lnum_t *faces_local[], cs_lnum_t *n_distant, cs_lnum_t *faces_distant[])
Definition: cs_internal_coupling.c:2146
void cs_internal_coupling_it_cocg_contribution(const cs_internal_coupling_t *cpl, cs_real_33_t cocg[])
Definition: cs_internal_coupling.c:1973
cs_real_33_t * cocg_it
Definition: cs_internal_coupling.h:89
void cs_internal_coupling_add(cs_mesh_t *mesh, const char criteria_cells[], const char criteria_faces[])
Definition: cs_internal_coupling.c:2526
cs_real_3_t * ci_cj_vect
Definition: cs_internal_coupling.h:82
void cs_internal_coupling_iterative_scalar_gradient(const cs_internal_coupling_t *cpl, const cs_real_t c_weight[], cs_real_3_t *restrict grad, const cs_real_t pvar[], cs_real_3_t rhs[])
Add internal coupling rhs contribution for iterative gradient calculation.
Definition: cs_internal_coupling.c:1108
void cs_internal_coupling_finalize(void)
Definition: cs_internal_coupling.c:2009
void cs_internal_coupling_bcs(int bc_type[])
Impose wall BCs to internal coupled faces if not yet defined.
Definition: cs_internal_coupling.c:827
void cs_internal_coupling_initialize_tensor_gradient(const cs_internal_coupling_t *cpl, const cs_real_t c_weight[], const cs_real_6_t pvar[], cs_real_63_t *restrict grad)
Add contribution from coupled faces (internal coupling) to initialisation for iterative symmetric ten...
Definition: cs_internal_coupling.c:1022
void cs_internal_coupling_reconstruct_vector_gradient(const cs_internal_coupling_t *cpl, cs_real_33_t *restrict r_grad, cs_real_33_t grad[])
Add internal coupling contribution for reconstruction of the gradient of a vector.
Definition: cs_internal_coupling.c:1491
cs_real_t cs_real_4_t[4]
vector of 4 floating-point values
Definition: cs_defs.h:310
double cs_real_t
Floating-point value.
Definition: cs_defs.h:297
void cs_internal_coupling_add_entity(int f_id)
Definition: cs_internal_coupling.c:2554
cs_lnum_t n_local
Definition: cs_internal_coupling.h:69
void cs_internal_coupling_add_volumes_finalize(cs_mesh_t *mesh)
Definition: cs_internal_coupling.c:2504
void cs_internal_coupling_log(const cs_internal_coupling_t *cpl)
Definition: cs_internal_coupling.c:2418
void cs_internal_coupling_initialize_vector_gradient(const cs_internal_coupling_t *cpl, const cs_real_t c_weight[], const cs_real_3_t pvar[], cs_real_33_t *restrict grad)
Add contribution from coupled faces (internal coupling) to initialisation for iterative vector gradie...
Definition: cs_internal_coupling.c:938
Definition: cs_mesh.h:63
void cs_internal_coupling_spmv_contribution(bool exclude_diag, void *input, const cs_real_t *restrict x, cs_real_t *restrict y)
Definition: cs_internal_coupling.c:2191
void cs_internal_coupling_exchange_by_cell_id(const cs_internal_coupling_t *cpl, int stride, const cs_real_t tab[], cs_real_t local[])
Definition: cs_internal_coupling.c:2072
bool * coupled_faces
Definition: cs_internal_coupling.h:76
void cs_internal_coupling_lsq_tensor_gradient(const cs_internal_coupling_t *cpl, const cs_real_t c_weight[], const int w_stride, const cs_real_6_t pvar[], cs_real_63_t rhs[])
Add internal coupling rhs contribution for LSQ gradient calculation.
cs_lnum_t * faces_local
Definition: cs_internal_coupling.h:70
cs_lnum_t * faces_distant
Definition: cs_internal_coupling.h:73
cs_real_t * g_weight
Definition: cs_internal_coupling.h:79
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:309
void cs_internal_coupling_lsq_vector_gradient(const cs_internal_coupling_t *cpl, const cs_real_t c_weight[], const int w_stride, const cs_real_3_t pvar[], cs_real_33_t rhs[])
Add internal coupling rhs contribution for LSQ gradient calculation.
Definition: cs_internal_coupling.c:1741
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:293
void cs_internal_coupling_initialize_scalar_gradient(const cs_internal_coupling_t *cpl, const cs_real_t c_weight[], const cs_real_t pvar[], cs_real_3_t *restrict grad)
Add contribution from coupled faces (internal coupling) to initialisation for iterative scalar gradie...
Definition: cs_internal_coupling.c:857
char * cells_criteria
Definition: cs_internal_coupling.h:66
#define END_C_DECLS
Definition: cs_defs.h:454
void cs_internal_coupling_dump(void)
Definition: cs_internal_coupling.c:2445
void cs_internal_coupling_lsq_scalar_gradient(const cs_internal_coupling_t *cpl, const cs_real_t c_weight[], const int w_stride, cs_real_4_t rhsv[])
Add internal coupling rhs contribution for LSQ gradient calculation.
Definition: cs_internal_coupling.c:1619
void cs_internal_coupling_initialize(void)
Definition: cs_internal_coupling.c:2303
void cs_internal_coupling_exchange_var(const cs_internal_coupling_t *cpl, int stride, cs_real_t distant[], cs_real_t local[])
Definition: cs_internal_coupling.c:2120
cs_real_t cs_real_33_t[3][3]
3x3 matrix of floating-point values
Definition: cs_defs.h:315
void cs_internal_coupling_reconstruct_tensor_gradient(const cs_internal_coupling_t *cpl, cs_real_63_t *restrict r_grad, cs_real_63_t grad[])
Add internal coupling contribution for reconstruction of the gradient of a symmetric tensor...
Definition: cs_internal_coupling.c:1555
void cs_ic_set_exchcoeff(const int field_id, const cs_real_t *hbord)
Definition: cs_internal_coupling.c:2583
cs_real_t cs_real_63_t[6][3]
Definition: cs_defs.h:321
cs_real_33_t * cocgb_s_lsq
Definition: cs_internal_coupling.h:88
int * c_tag
Definition: cs_internal_coupling.h:63
void cs_internal_coupling_lsq_cocg_contribution(const cs_internal_coupling_t *cpl, cs_real_33_t cocg[])
Definition: cs_internal_coupling.c:1870
void cs_internal_coupling_iterative_vector_gradient(const cs_internal_coupling_t *cpl, const cs_real_t c_weight[], cs_real_33_t *restrict grad, const cs_real_3_t pvar[], cs_real_33_t rhs[])
Add internal coupling rhs contribution for iterative vector gradient calculation. ...
Definition: cs_internal_coupling.c:1214
void cs_internal_coupling_add_volume(cs_mesh_t *mesh, const char criteria_cells[])
Definition: cs_internal_coupling.c:2470
char * faces_criteria
Definition: cs_internal_coupling.h:67
cs_internal_coupling_t * cs_internal_coupling_by_id(int coupling_id)
Definition: cs_internal_coupling.c:2170
cs_lnum_t n_distant
Definition: cs_internal_coupling.h:72
char * namesca
Definition: cs_internal_coupling.h:92
void cs_internal_coupling_reconstruct_scalar_gradient(const cs_internal_coupling_t *cpl, cs_real_3_t *restrict r_grad, cs_real_3_t grad[])
Add internal coupling contribution for reconstruction of the gradient of a scalar.
Definition: cs_internal_coupling.c:1428