8.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-2023 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_defs.h"
41
42#include "cs_base.h"
43#include "cs_matrix_assembler.h"
44#include "cs_mesh.h"
45#include "cs_mesh_quantities.h"
46#include "cs_parameters.h"
47
48/*----------------------------------------------------------------------------*/
49
51
52/*=============================================================================
53 * Macro definitions
54 *============================================================================*/
55
56/*============================================================================
57 * Type definitions
58 *============================================================================*/
59
60/* Internal coupling structure definition */
61
62typedef struct {
63
64 /* Id */
65 int id;
66
67 /* Locator + tag for exchanging variables */
68 ple_locator_t *locator;
69 int *c_tag;
70
71 /* Selection criteria for coupled domains */
74
77
78 /* Associated zone ids */
79
82
83 cs_lnum_t n_local; /* Number of faces */
84 cs_lnum_t *faces_local; /* Coupling boundary faces, numbered 0..n-1 */
85
86 cs_lnum_t n_distant; /* Number of faces in faces_distant */
87 cs_lnum_t *faces_distant; /* Distant boundary faces associated with locator */
88
89 /* Face i is coupled in this entity if coupled_faces[i] = true */
91
92 /* Geometrical weights around coupling interface */
94
95 /* IJ vectors */
97
98 /* OF vectors */
100
102
103/*============================================================================
104 * Public function prototypes
105 *============================================================================*/
106
107/*----------------------------------------------------------------------------*/
113/*----------------------------------------------------------------------------*/
114
115int
117
118/*----------------------------------------------------------------------------*/
127/*----------------------------------------------------------------------------*/
128
129void
130cs_internal_coupling_add(const char criteria_cells[],
131 const char criteria_faces[]);
132
133/*----------------------------------------------------------------------------*/
140/*----------------------------------------------------------------------------*/
141
142void
143cs_internal_coupling_add_volume(const char criteria_cells[]);
144
145/*----------------------------------------------------------------------------*/
152/*----------------------------------------------------------------------------*/
153
154void
156
157/*----------------------------------------------------------------------------*/
165/*----------------------------------------------------------------------------*/
166
167void
169 const int zone_ids[]);
170
171/*----------------------------------------------------------------------------*/
187/*----------------------------------------------------------------------------*/
188
189void
191 const char *interior_name,
192 const char *exterior_name);
193
194/*----------------------------------------------------------------------------*/
200/*----------------------------------------------------------------------------*/
201
202void
203cs_internal_coupling_bcs(int bc_type[]);
204
205/*----------------------------------------------------------------------------*/
209/*----------------------------------------------------------------------------*/
210
211void
213
214/*----------------------------------------------------------------------------*/
222/*----------------------------------------------------------------------------*/
223
225cs_internal_coupling_by_id(int coupling_id);
226
227/*----------------------------------------------------------------------------*/
237/*----------------------------------------------------------------------------*/
238
239void
241 int stride,
242 cs_real_t distant[],
243 cs_real_t local[]);
244
245/*----------------------------------------------------------------------------*/
254/*----------------------------------------------------------------------------*/
255
256void
258 int stride,
259 const cs_real_t tab[],
260 cs_real_t local[]);
261
262/*----------------------------------------------------------------------------*/
271/*----------------------------------------------------------------------------*/
272
273void
275 int stride,
276 const cs_real_t tab[],
277 cs_real_t local[]);
278
279/*----------------------------------------------------------------------------
280 * Modify LSQ COCG matrix to include internal coupling
281 *
282 * parameters:
283 * cpl <-- pointer to coupling entity
284 * cocg <-> cocg matrix modified
285 *----------------------------------------------------------------------------*/
286
287void
289 cs_real_6_t cocg[]);
290
291/*----------------------------------------------------------------------------
292 * Modify LSQ COCG matrix to include internal coupling
293 * when diffusivity is a tensor
294 *
295 * parameters:
296 * cpl <-- pointer to coupling entity
297 * c_weight <-- weigthing coefficients
298 * cocg <-> cocg matrix modified
299 *----------------------------------------------------------------------------*/
300
301void
303 const cs_real_t *c_weight,
304 cs_real_6_t cocg[]);
305
306/*----------------------------------------------------------------------------
307 * Modify iterative COCG matrix to include internal coupling
308 *
309 * parameters:
310 * cpl <-- pointer to coupling entity
311 * cocg <-> cocg matrix modified
312 *----------------------------------------------------------------------------*/
313
314void
316 cs_real_33_t cocg[]);
317
318/*----------------------------------------------------------------------------*/
322/*----------------------------------------------------------------------------*/
323
324void
326
327/*----------------------------------------------------------------------------*/
331/*----------------------------------------------------------------------------*/
332
333void
335
336/*----------------------------------------------------------------------------*/
345/*----------------------------------------------------------------------------*/
346
347void
349 const cs_internal_coupling_t *cpl,
350 const cs_real_t c_weight[],
351 const int w_stride,
352 cs_real_4_t rhsv[]);
353
354/*----------------------------------------------------------------------------*/
364/*----------------------------------------------------------------------------*/
365
366void
368 const cs_internal_coupling_t *cpl,
369 const cs_real_t c_weight[],
370 const int w_stride,
371 const cs_real_3_t pvar[],
372 cs_real_33_t rhs[]);
373
374/*----------------------------------------------------------------------------*/
384/*----------------------------------------------------------------------------*/
385
386void
388 const cs_internal_coupling_t *cpl,
389 const cs_real_t c_weight[],
390 const int w_stride,
391 const cs_real_6_t pvar[],
392 cs_real_63_t rhs[]);
393
394/*----------------------------------------------------------------------------*/
405/*----------------------------------------------------------------------------*/
406
407void
409 const cs_internal_coupling_t *cpl,
410 const cs_real_t c_weight[],
411 cs_real_3_t *restrict grad,
412 const cs_real_t pvar[],
413 cs_real_3_t rhs[]);
414
415/*----------------------------------------------------------------------------*/
426/*----------------------------------------------------------------------------*/
427
428void
430 const cs_internal_coupling_t *cpl,
431 const cs_real_t c_weight[],
433 const cs_real_3_t pvar[],
434 cs_real_33_t rhs[]);
435
436/*----------------------------------------------------------------------------*/
447/*----------------------------------------------------------------------------*/
448
449void
451 const cs_internal_coupling_t *cpl,
452 const cs_real_t c_weight[],
454 const cs_real_6_t pvar[],
455 cs_real_63_t rhs[]);
456
457/*----------------------------------------------------------------------------*/
466/*----------------------------------------------------------------------------*/
467
468void
470 const cs_internal_coupling_t *cpl,
471 cs_real_3_t *restrict r_grad,
472 cs_real_3_t grad[]);
473
474/*----------------------------------------------------------------------------*/
483/*----------------------------------------------------------------------------*/
484
485void
487 const cs_internal_coupling_t *cpl,
488 cs_real_33_t *restrict r_grad,
489 cs_real_33_t grad[]);
490
491/*----------------------------------------------------------------------------*/
500/*----------------------------------------------------------------------------*/
501
502void
504 const cs_internal_coupling_t *cpl,
505 cs_real_63_t *restrict r_grad,
506 cs_real_63_t grad[]);
507
508/*----------------------------------------------------------------------------
509 * Addition to matrix-vector product in case of internal coupling.
510 *
511 * parameters:
512 * exclude_diag <-- extra diagonal flag
513 * f <-- associated field pointer
514 * x <-- vector x in m * x = y
515 * y <-> vector y in m * x = y
516 *----------------------------------------------------------------------------*/
517
518void
520 const cs_field_t *f,
521 const cs_real_t *restrict x,
523
524/*----------------------------------------------------------------------------
525 * Add coupling term coordinates to matrix assembler.
526 *
527 * parameters:
528 * coupling_id
529 * r_g_id <-- global row ids (per cell)
530 * ma <-> matrix assembler
531 *----------------------------------------------------------------------------*/
532
533void
535 const cs_gnum_t *r_g_id,
537
538/*----------------------------------------------------------------------------
539 * Add coupling terms to matrix values assembly.
540 *
541 * parameters:
542 * f <-- associated field
543 * db_size <-- diagonal block size
544 * eb_size <-- extra-diagonal block size
545 * r_g_id <-- global row ids (per cell)
546 * mav <-> matrix values assembler
547 *----------------------------------------------------------------------------*/
548
549void
551 cs_lnum_t db_size,
552 cs_lnum_t eb_size,
553 const cs_gnum_t r_g_id[],
555
556/*----------------------------------------------------------------------------
557 * Return pointers to coupling components
558 *
559 * parameters:
560 * cpl <-- pointer to coupling entity
561 * n_local --> NULL or pointer to component n_local
562 * faces_local --> NULL or pointer to component faces_local
563 * n_distant --> NULL or pointer to component n_distant
564 * faces_distant --> NULL or pointer to component faces_distant
565 *----------------------------------------------------------------------------*/
566
567void
569 cs_lnum_t *n_local,
570 const cs_lnum_t *faces_local[],
571 cs_lnum_t *n_distant,
572 const cs_lnum_t *faces_distant[]);
573
574/*----------------------------------------------------------------------------
575 * Log information about a given internal coupling entity
576 *
577 * parameters:
578 * cpl <-- pointer to coupling entity
579 *----------------------------------------------------------------------------*/
580
581void
583
584/*----------------------------------------------------------------------------
585 * Print informations about all coupling entities
586 *
587 * parameters:
588 * cpl <-- pointer to coupling entity
589 *----------------------------------------------------------------------------*/
590
591void
593
594/*----------------------------------------------------------------------------
595 * Add preprocessing operations required by coupling volume using given
596 * criteria.
597 *
598 * The volume is separated from the rest of the domain with inserted
599 * boundaries.
600 *
601 * parameters:
602 * mesh <-> pointer to mesh structure to modify
603 *----------------------------------------------------------------------------*/
604
605void
607
608/*----------------------------------------------------------------------------
609 * Define face to face mappings for internal couplings.
610 *
611 * parameters:
612 * mesh <-> pointer to mesh structure to modify
613 *----------------------------------------------------------------------------*/
614
615void
617
618/*----------------------------------------------------------------------------
619 * Define coupling entity using given criteria.
620 *
621 * parameters:
622 * f_id <-- id of the field
623 *----------------------------------------------------------------------------*/
624
625void
627
628/*----------------------------------------------------------------------------*/
638/*----------------------------------------------------------------------------*/
639
640void
642 const cs_internal_coupling_t *cpl,
643 const cs_real_t c_weight[],
644 const cs_real_t pvar[],
645 cs_real_3_t *restrict grad);
646
647/*----------------------------------------------------------------------------*/
657/*----------------------------------------------------------------------------*/
658
659void
661 const cs_internal_coupling_t *cpl,
662 const cs_real_t c_weight[],
663 const cs_real_3_t pvar[],
664 cs_real_33_t *restrict grad);
665
666
667/*----------------------------------------------------------------------------*/
677/*----------------------------------------------------------------------------*/
678
679void
681 const cs_internal_coupling_t *cpl,
682 const cs_real_t c_weight[],
683 const cs_real_6_t pvar[],
684 cs_real_63_t *restrict grad);
685
686/*----------------------------------------------------------------------------*/
694/*----------------------------------------------------------------------------*/
695
696void
697cs_ic_field_set_exchcoeff(const int field_id,
698 const cs_real_t *hbnd);
699
700/*----------------------------------------------------------------------------*/
710/*----------------------------------------------------------------------------*/
711
712void
713cs_ic_field_dist_data_by_face_id(const int field_id,
714 int stride,
715 const cs_real_t tab_distant[],
716 cs_real_t tab_local[]);
717
718/*----------------------------------------------------------------------------*/
719
721
722#endif /* __CS_INTERNAL_COUPLING_H__ */
#define restrict
Definition cs_defs.h:139
cs_real_t cs_real_33_t[3][3]
3x3 matrix of floating-point values
Definition cs_defs.h:341
#define BEGIN_C_DECLS
Definition cs_defs.h:509
double cs_real_t
Floating-point value.
Definition cs_defs.h:319
cs_real_t cs_real_6_t[6]
vector of 6 floating-point values
Definition cs_defs.h:334
cs_real_t cs_real_4_t[4]
vector of 4 floating-point values
Definition cs_defs.h:333
#define END_C_DECLS
Definition cs_defs.h:510
cs_real_t cs_real_63_t[6][3]
Definition cs_defs.h:349
int cs_lnum_t
local mesh entity id
Definition cs_defs.h:313
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition cs_defs.h:332
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:1823
void cs_internal_coupling_preprocess(cs_mesh_t *mesh)
Definition cs_internal_coupling.c:2971
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.
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.c:2622
void cs_internal_coupling_log(const cs_internal_coupling_t *cpl)
Definition cs_internal_coupling.c:2898
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.c:1075
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.c:1138
void cs_ic_field_set_exchcoeff(const int field_id, 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.c:3042
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.
void cs_internal_coupling_initialize(void)
Initialize internal coupling related structures.
Definition cs_internal_coupling.c:2881
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:1193
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.c:2378
void cs_internal_coupling_lsq_cocg_weighted(const cs_internal_coupling_t *cpl, const cs_real_t *c_weight, cs_real_6_t cocg[])
Definition cs_internal_coupling.c:2239
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:2067
void cs_internal_coupling_finalize(void)
Destruction of all internal coupling related structures.
Definition cs_internal_coupling.c:2333
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:1360
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.c:2493
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:1448
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:1945
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:1884
void cs_internal_coupling_bcs(int bc_type[])
Impose wall BCs to internal coupled faces if not yet defined.
Definition cs_internal_coupling.c:1162
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.c:2695
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.c:1093
void cs_internal_coupling_it_cocg_contribution(const cs_internal_coupling_t *cpl, cs_real_33_t cocg[])
Definition cs_internal_coupling.c:2298
int cs_internal_coupling_n_couplings(void)
Return number of defined internal couplings.
Definition cs_internal_coupling.c:999
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.c:3093
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.c:2404
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:1552
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.c:2453
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.c:2355
void cs_internal_coupling_map(cs_mesh_t *mesh)
Definition cs_internal_coupling.c:2992
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.c:1044
void cs_internal_coupling_dump(void)
Definition cs_internal_coupling.c:2944
void cs_internal_coupling_spmv_contribution(bool exclude_diag, const cs_field_t *f, const cs_real_t *restrict x, cs_real_t *restrict y)
Definition cs_internal_coupling.c:2520
void cs_internal_coupling_add_entity(int f_id)
Definition cs_internal_coupling.c:3012
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:1660
void cs_internal_coupling_setup(void)
Setup internal coupling related parameters.
Definition cs_internal_coupling.c:2825
void cs_internal_coupling_lsq_cocg_contribution(const cs_internal_coupling_t *cpl, cs_real_6_t cocg[])
Definition cs_internal_coupling.c:2199
void cs_internal_coupling_add(const char criteria_cells[], const char criteria_faces[])
Define coupling volume using given selection criteria.
Definition cs_internal_coupling.c:1016
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:1274
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 descriptor.
Definition cs_field.h:130
Definition cs_internal_coupling.h:62
ple_locator_t * locator
Definition cs_internal_coupling.h:68
cs_lnum_t * faces_local
Definition cs_internal_coupling.h:84
cs_lnum_t * faces_distant
Definition cs_internal_coupling.h:87
int n_volume_zones
Definition cs_internal_coupling.h:80
bool * coupled_faces
Definition cs_internal_coupling.h:90
int * c_tag
Definition cs_internal_coupling.h:69
int id
Definition cs_internal_coupling.h:65
char * interior_faces_group_name
Definition cs_internal_coupling.h:75
cs_real_3_t * ci_cj_vect
Definition cs_internal_coupling.h:96
char * exterior_faces_group_name
Definition cs_internal_coupling.h:76
char * cells_criteria
Definition cs_internal_coupling.h:72
cs_real_3_t * offset_vect
Definition cs_internal_coupling.h:99
cs_lnum_t n_distant
Definition cs_internal_coupling.h:86
cs_lnum_t n_local
Definition cs_internal_coupling.h:83
char * faces_criteria
Definition cs_internal_coupling.h:73
cs_real_t * g_weight
Definition cs_internal_coupling.h:93
int * volume_zone_ids
Definition cs_internal_coupling.h:81
Definition cs_mesh.h:85
Definition cs_zone.h:55