9.0
general documentation
Loading...
Searching...
No Matches
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-2025 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 "base/cs_defs.h"
41
42#include "base/cs_base.h"
43#include "base/cs_field.h"
45#include "mesh/cs_mesh.h"
47#include "base/cs_parameters.h"
48
49/*----------------------------------------------------------------------------*/
50
52
53/*=============================================================================
54 * Macro definitions
55 *============================================================================*/
56
57/*============================================================================
58 * Type definitions
59 *============================================================================*/
60
61/* Internal coupling structure definition */
62
63typedef struct {
64
65 /* Id */
66 int id;
67
68 /* Locator + tag for exchanging variables */
69 ple_locator_t *locator;
70 int *c_tag;
71
72 /* Selection criteria for coupled domains */
75
78
79 /* Associated zone ids */
80
83
84 cs_lnum_t n_local; /* Number of faces */
85 cs_lnum_t *faces_local; /* Coupling boundary faces, numbered 0..n-1 */
86
87 cs_lnum_t n_distant; /* Number of faces in faces_distant */
88 cs_lnum_t *faces_distant; /* Distant boundary faces associated with locator */
89
90 /* Face i is coupled in this entity if coupled_faces[i] = true */
92
93 /* Geometrical weights around coupling interface */
95
96 /* IJ vectors */
98
99 /* OF vectors */
101
103
104/*============================================================================
105 * Public function prototypes
106 *============================================================================*/
107
108/*----------------------------------------------------------------------------*/
114/*----------------------------------------------------------------------------*/
115
116int
118
119/*----------------------------------------------------------------------------*/
128/*----------------------------------------------------------------------------*/
129
130void
131cs_internal_coupling_add(const char criteria_cells[],
132 const char criteria_faces[]);
133
134/*----------------------------------------------------------------------------*/
141/*----------------------------------------------------------------------------*/
142
143void
144cs_internal_coupling_add_volume(const char criteria_cells[]);
145
146/*----------------------------------------------------------------------------*/
153/*----------------------------------------------------------------------------*/
154
155void
157
158/*----------------------------------------------------------------------------*/
166/*----------------------------------------------------------------------------*/
167
168void
170 const int zone_ids[]);
171
172/*----------------------------------------------------------------------------*/
188/*----------------------------------------------------------------------------*/
189
190void
192 const char *interior_name,
193 const char *exterior_name);
194
195/*----------------------------------------------------------------------------*/
201/*----------------------------------------------------------------------------*/
202
203void
204cs_internal_coupling_bcs(int bc_type[]);
205
206/*----------------------------------------------------------------------------*/
210/*----------------------------------------------------------------------------*/
211
212void
214
215/*----------------------------------------------------------------------------*/
223/*----------------------------------------------------------------------------*/
224
226cs_internal_coupling_by_id(int coupling_id);
227
228/*----------------------------------------------------------------------------*/
238/*----------------------------------------------------------------------------*/
239
240void
242 int stride,
243 cs_real_t distant[],
244 cs_real_t local[]);
245
246/*----------------------------------------------------------------------------*/
255/*----------------------------------------------------------------------------*/
256
257void
259 int stride,
260 const cs_real_t tab[],
261 cs_real_t local[]);
262
263/*----------------------------------------------------------------------------*/
272/*----------------------------------------------------------------------------*/
273
274void
276 int stride,
277 const cs_real_t tab[],
278 cs_real_t local[]);
279
280/*----------------------------------------------------------------------------
281 * Modify iterative COCG matrix to include internal coupling
282 *
283 * parameters:
284 * cpl <-- pointer to coupling entity
285 * cocg <-> cocg matrix modified
286 *----------------------------------------------------------------------------*/
287
288void
290 cs_real_33_t cocg[]);
291
292/*----------------------------------------------------------------------------*/
296/*----------------------------------------------------------------------------*/
297
298void
300
301/*----------------------------------------------------------------------------*/
305/*----------------------------------------------------------------------------*/
306
307void
309
310/*----------------------------------------------------------------------------*/
321/*----------------------------------------------------------------------------*/
322
323void
325(
326 const cs_internal_coupling_t *cpl,
327 const cs_real_t c_weight[],
328 cs_real_3_t *grad,
329 const cs_real_t pvar[],
330 cs_real_3_t rhs[]
331 );
332
333/*----------------------------------------------------------------------------*/
344/*----------------------------------------------------------------------------*/
345
346void
348(
349 const cs_internal_coupling_t *cpl,
350 const cs_real_t c_weight[],
351 cs_real_33_t *grad,
352 const cs_real_3_t pvar[],
353 cs_real_33_t rhs[]
354);
355
356/*----------------------------------------------------------------------------*/
367/*----------------------------------------------------------------------------*/
368
369void
371(
372 const cs_internal_coupling_t *cpl,
373 const cs_real_t c_weight[],
374 cs_real_63_t *grad,
375 const cs_real_6_t pvar[],
376 cs_real_63_t rhs[]
377);
378
379/*----------------------------------------------------------------------------*/
388/*----------------------------------------------------------------------------*/
389
390void
392 const cs_internal_coupling_t *cpl,
393 cs_real_3_t *r_grad,
394 cs_real_3_t grad[]);
395
396/*----------------------------------------------------------------------------*/
405/*----------------------------------------------------------------------------*/
406
407void
409 const cs_internal_coupling_t *cpl,
410 cs_real_33_t *r_grad,
411 cs_real_33_t grad[]);
412
413/*----------------------------------------------------------------------------*/
422/*----------------------------------------------------------------------------*/
423
424void
426 const cs_internal_coupling_t *cpl,
427 cs_real_63_t *r_grad,
428 cs_real_63_t grad[]);
429
430/*----------------------------------------------------------------------------*/
444/*----------------------------------------------------------------------------*/
445
446void
448 const cs_internal_coupling_t *cpl,
449 cs_halo_type_t halo_type,
450 int w_stride,
451 double clip_coeff,
452 const cs_real_t *var,
453 const cs_real_t *c_weight);
454
455/*----------------------------------------------------------------------------
456 * Addition to matrix-vector product in case of internal coupling.
457 *
458 * parameters:
459 * exclude_diag <-- extra diagonal flag
460 * f <-- associated field pointer
461 * x <-- vector x in m * x = y
462 * y <-> vector y in m * x = y
463 *----------------------------------------------------------------------------*/
464
465void
467 const cs_field_t *f,
468 const cs_real_t *x,
469 cs_real_t *y);
470
471/*----------------------------------------------------------------------------
472 * Add coupling term coordinates to matrix assembler.
473 *
474 * parameters:
475 * coupling_id
476 * r_g_id <-- global row ids (per cell)
477 * ma <-> matrix assembler
478 *----------------------------------------------------------------------------*/
479
480void
482 const cs_gnum_t *r_g_id,
484
485/*----------------------------------------------------------------------------
486 * Add coupling terms to matrix values assembly.
487 *
488 * parameters:
489 * f <-- associated field
490 * db_size <-- diagonal block size
491 * eb_size <-- extra-diagonal block size
492 * r_g_id <-- global row ids (per cell)
493 * mav <-> matrix values assembler
494 *----------------------------------------------------------------------------*/
495
496void
498 cs_lnum_t db_size,
499 cs_lnum_t eb_size,
500 const cs_gnum_t r_g_id[],
502
503/*----------------------------------------------------------------------------
504 * Return pointers to coupling components
505 *
506 * parameters:
507 * cpl <-- pointer to coupling entity
508 * n_local --> null or pointer to component n_local
509 * faces_local --> null or pointer to component faces_local
510 * n_distant --> null or pointer to component n_distant
511 * faces_distant --> null or pointer to component faces_distant
512 *----------------------------------------------------------------------------*/
513
514void
516 cs_lnum_t *n_local,
517 const cs_lnum_t *faces_local[],
518 cs_lnum_t *n_distant,
519 const cs_lnum_t *faces_distant[]);
520
521/*----------------------------------------------------------------------------
522 * Log information about a given internal coupling entity
523 *
524 * parameters:
525 * cpl <-- pointer to coupling entity
526 *----------------------------------------------------------------------------*/
527
528void
530
531/*----------------------------------------------------------------------------
532 * Print informations about all coupling entities
533 *
534 * parameters:
535 * cpl <-- pointer to coupling entity
536 *----------------------------------------------------------------------------*/
537
538void
540
541/*----------------------------------------------------------------------------
542 * Add preprocessing operations required by coupling volume using given
543 * criteria.
544 *
545 * The volume is separated from the rest of the domain with inserted
546 * boundaries.
547 *
548 * parameters:
549 * mesh <-> pointer to mesh structure to modify
550 *----------------------------------------------------------------------------*/
551
552void
554
555/*----------------------------------------------------------------------------
556 * Define face to face mappings for internal couplings.
557 *
558 * parameters:
559 * mesh <-> pointer to mesh structure to modify
560 *----------------------------------------------------------------------------*/
561
562void
564
565/*----------------------------------------------------------------------------
566 * Define coupling entity using given criteria.
567 *
568 * parameters:
569 * f_id <-- id of the field
570 *----------------------------------------------------------------------------*/
571
572void
574
575/*----------------------------------------------------------------------------*/
585/*----------------------------------------------------------------------------*/
586
587void
589(
590 const cs_internal_coupling_t *cpl,
591 const cs_real_t c_weight[],
592 const cs_real_t pvar[],
593 cs_real_3_t *grad
594);
595
596/*----------------------------------------------------------------------------*/
606/*----------------------------------------------------------------------------*/
607
608void
610(
611 const cs_internal_coupling_t *cpl,
612 const cs_real_t c_weight[],
613 const cs_real_3_t pvar[],
614 cs_real_33_t *grad
615);
616
617/*----------------------------------------------------------------------------*/
627/*----------------------------------------------------------------------------*/
628
629void
631(
632 const cs_internal_coupling_t *cpl,
633 const cs_real_t c_weight[],
634 const cs_real_6_t pvar[],
635 cs_real_63_t *grad
636);
637
638/*----------------------------------------------------------------------------*/
646/*----------------------------------------------------------------------------*/
647
648void
650 const cs_real_t *hbnd);
651
652/*----------------------------------------------------------------------------*/
662/*----------------------------------------------------------------------------*/
663
664void
665cs_ic_field_dist_data_by_face_id(const int field_id,
666 int stride,
667 const cs_real_t tab_distant[],
668 cs_real_t tab_local[]);
669
670/*----------------------------------------------------------------------------*/
671
673
674#if defined(__cplusplus)
675
676/*=============================================================================
677 * Public C++ functions
678 *============================================================================*/
679
680/*----------------------------------------------------------------------------*/
693/*----------------------------------------------------------------------------*/
694
695template <cs_lnum_t stride>
696void
697cs_internal_coupling_update_bc_coeff_strided(const cs_field_bc_coeffs_t *bc_coeffs_v,
698 const cs_internal_coupling_t *cpl,
699 cs_halo_type_t halo_type,
700 double clip_coeff,
701 cs_real_t *df_limiter,
702 const cs_real_t var[][stride],
703 const cs_real_t *c_weight);
704
705#endif // __cplusplus
706
707#endif /* __CS_INTERNAL_COUPLING_H__ */
cs_real_t cs_real_33_t[3][3]
3x3 matrix of floating-point values
Definition cs_defs.h:368
#define BEGIN_C_DECLS
Definition cs_defs.h:542
double cs_real_t
Floating-point value.
Definition cs_defs.h:342
cs_real_t cs_real_6_t[6]
vector of 6 floating-point values
Definition cs_defs.h:361
unsigned cs_gnum_t
global mesh entity number
Definition cs_defs.h:327
#define END_C_DECLS
Definition cs_defs.h:543
cs_real_t cs_real_63_t[6][3]
Definition cs_defs.h:376
int cs_lnum_t
local mesh entity id
Definition cs_defs.h:335
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition cs_defs.h:359
cs_halo_type_t
Definition cs_halo.h:56
void cs_internal_coupling_iterative_tensor_gradient(const cs_internal_coupling_t *cpl, const cs_real_t c_weight[], cs_real_63_t *grad, const cs_real_6_t pvar[], cs_real_63_t rhs[])
Add internal coupling rhs contribution for iterative tensor gradient calculation.
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 *grad)
Add contribution from coupled faces (internal coupling) to initialisation for iterative scalar gradie...
void cs_internal_coupling_preprocess(cs_mesh_t *mesh)
Definition cs_internal_coupling.cpp:2613
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 *grad)
Add contribution from coupled faces (internal coupling) to initialisation for iterative vector gradie...
void cs_internal_coupling_iterative_scalar_gradient(const cs_internal_coupling_t *cpl, const cs_real_t c_weight[], cs_real_3_t *grad, const cs_real_t pvar[], cs_real_3_t rhs[])
Add internal coupling rhs contribution for iterative gradient calculation.
void cs_internal_coupling_matrix_add_ids(int coupling_id, const cs_gnum_t *r_g_id, cs_matrix_assembler_t *ma)
Definition cs_internal_coupling.cpp:2267
void cs_internal_coupling_log(const cs_internal_coupling_t *cpl)
Definition cs_internal_coupling.cpp:2540
void cs_internal_coupling_reconstruct_scalar_gradient(const cs_internal_coupling_t *cpl, cs_real_3_t *r_grad, cs_real_3_t grad[])
Add internal coupling contribution for reconstruction of the gradient of a scalar.
void cs_internal_coupling_add_volume_zone(const cs_zone_t *z)
Define coupling volume using a cs_zone_t. Then, this volume will be separated from the rest of the do...
Definition cs_internal_coupling.cpp:959
void cs_internal_coupling_add_boundary_groups(cs_internal_coupling_t *cpl, const char *interior_name, const char *exterior_name)
Define internal coupling volume boundary group names.
Definition cs_internal_coupling.cpp:1022
void cs_internal_coupling_initialize(void)
Initialize internal coupling related structures.
Definition cs_internal_coupling.cpp:2523
void cs_internal_coupling_reconstruct_tensor_gradient(const cs_internal_coupling_t *cpl, cs_real_63_t *r_grad, cs_real_63_t grad[])
Add internal coupling contribution for reconstruction of the gradient of a symmetric tensor.
void cs_internal_coupling_exchange_var(const cs_internal_coupling_t *cpl, int stride, cs_real_t distant[], cs_real_t local[])
Exchange quantities from distant to local (update local using distant).
Definition cs_internal_coupling.cpp:1906
void cs_internal_coupling_finalize(void)
Destruction of all internal coupling related structures.
Definition cs_internal_coupling.cpp:1861
void cs_internal_coupling_iterative_vector_gradient(const cs_internal_coupling_t *cpl, const cs_real_t c_weight[], cs_real_33_t *grad, const cs_real_3_t pvar[], cs_real_33_t rhs[])
Add internal coupling rhs contribution for iterative vector gradient calculation.
void cs_internal_coupling_coupled_faces(const cs_internal_coupling_t *cpl, cs_lnum_t *n_local, const cs_lnum_t *faces_local[], cs_lnum_t *n_distant, const cs_lnum_t *faces_distant[])
Definition cs_internal_coupling.cpp:2021
void cs_internal_coupling_bcs(int bc_type[])
Impose wall BCs to internal coupled faces if not yet defined.
Definition cs_internal_coupling.cpp:1046
void cs_internal_coupling_matrix_add_values(const cs_field_t *f, cs_lnum_t db_size, cs_lnum_t eb_size, const cs_gnum_t r_g_id[], cs_matrix_assembler_values_t *mav)
Definition cs_internal_coupling.cpp:2340
void cs_internal_coupling_reconstruct_vector_gradient(const cs_internal_coupling_t *cpl, cs_real_33_t *r_grad, cs_real_33_t grad[])
Add internal coupling contribution for reconstruction of the gradient of a vector.
void cs_internal_coupling_add_volume_zones(int n_zones, const int zone_ids[])
Define coupling volume using given cs_zone_t. Then, this volume will be separated from the rest of th...
Definition cs_internal_coupling.cpp:977
void cs_internal_coupling_it_cocg_contribution(const cs_internal_coupling_t *cpl, cs_real_33_t cocg[])
Definition cs_internal_coupling.cpp:1826
int cs_internal_coupling_n_couplings(void)
Return number of defined internal couplings.
Definition cs_internal_coupling.cpp:883
void cs_ic_field_dist_data_by_face_id(const int field_id, int stride, const cs_real_t tab_distant[], cs_real_t tab_local[])
Get distant data using face id at all coupling faces for a given field id.
Definition cs_internal_coupling.cpp:2726
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[])
Exchange variable between groups using cell id.
Definition cs_internal_coupling.cpp:1932
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[])
Exchange variable between groups using face id.
Definition cs_internal_coupling.cpp:1981
cs_internal_coupling_t * cs_internal_coupling_by_id(int coupling_id)
Return the coupling associated with a given coupling_id.
Definition cs_internal_coupling.cpp:1883
void cs_internal_coupling_map(cs_mesh_t *mesh)
Definition cs_internal_coupling.cpp:2634
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 *grad)
Add contribution from coupled faces (internal coupling) to initialisation for iterative symmetric ten...
void cs_internal_coupling_update_bc_coeff_s(const cs_field_bc_coeffs_t *bc_coeffs, const cs_internal_coupling_t *cpl, cs_halo_type_t halo_type, int w_stride, double clip_coeff, const cs_real_t *var, const cs_real_t *c_weight)
Compute scalar boundary condition coefficients for internal coupling.
Definition cs_internal_coupling.cpp:2053
void cs_internal_coupling_add_volume(const char criteria_cells[])
Define coupling volume using given criteria. Then, this volume will be separated from the rest of the...
Definition cs_internal_coupling.cpp:928
void cs_internal_coupling_spmv_contribution(bool exclude_diag, const cs_field_t *f, const cs_real_t *x, cs_real_t *y)
void cs_ic_field_set_exchcoeff(const cs_field_t *f, const cs_real_t *hbnd)
Update internal coupling coefficients of the field of the given id using given boundary exchange coef...
Definition cs_internal_coupling.cpp:2680
void cs_internal_coupling_dump(void)
Definition cs_internal_coupling.cpp:2586
void cs_internal_coupling_add_entity(int f_id)
Definition cs_internal_coupling.cpp:2654
void cs_internal_coupling_setup(void)
Setup internal coupling related parameters.
Definition cs_internal_coupling.cpp:2470
void cs_internal_coupling_add(const char criteria_cells[], const char criteria_faces[])
Define coupling volume using given selection criteria.
Definition cs_internal_coupling.cpp:900
struct _cs_matrix_assembler_t cs_matrix_assembler_t
Definition cs_matrix_assembler.h:61
struct _cs_matrix_assembler_values_t cs_matrix_assembler_values_t
Definition cs_matrix_assembler.h:65
Definition mesh.f90:26
Field boundary condition descriptor (for variables)
Definition cs_field.h:121
Field descriptor.
Definition cs_field.h:158
Definition cs_internal_coupling.h:63
ple_locator_t * locator
Definition cs_internal_coupling.h:69
cs_lnum_t * faces_local
Definition cs_internal_coupling.h:85
cs_lnum_t * faces_distant
Definition cs_internal_coupling.h:88
int n_volume_zones
Definition cs_internal_coupling.h:81
bool * coupled_faces
Definition cs_internal_coupling.h:91
int * c_tag
Definition cs_internal_coupling.h:70
int id
Definition cs_internal_coupling.h:66
char * interior_faces_group_name
Definition cs_internal_coupling.h:76
cs_real_3_t * ci_cj_vect
Definition cs_internal_coupling.h:97
char * exterior_faces_group_name
Definition cs_internal_coupling.h:77
char * cells_criteria
Definition cs_internal_coupling.h:73
cs_real_3_t * offset_vect
Definition cs_internal_coupling.h:100
cs_lnum_t n_distant
Definition cs_internal_coupling.h:87
cs_lnum_t n_local
Definition cs_internal_coupling.h:84
char * faces_criteria
Definition cs_internal_coupling.h:74
cs_real_t * g_weight
Definition cs_internal_coupling.h:94
int * volume_zone_ids
Definition cs_internal_coupling.h:82
Definition cs_mesh.h:85
Definition cs_zone.h:55