8.3
general documentation
cs_boundary_conditions_set_coeffs.h
Go to the documentation of this file.
1#ifndef __CS_BOUNDARY_CONDITIONS_SET_COEFFS_H__
2#define __CS_BOUNDARY_CONDITIONS_SET_COEFFS_H__
3
4/*============================================================================
5 * Boundary condition management.
6 *============================================================================*/
7
8/*
9 This file is part of code_saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2024 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 * Local headers
32 *----------------------------------------------------------------------------*/
33
34#include "cs_defs.h"
35
36#include "bft_error.h"
37#include "cs_field.h"
38#include "cs_math.h"
39
40/*----------------------------------------------------------------------------*/
41
43
44/*=============================================================================
45 * Public function prototypes
46 *============================================================================*/
47
48/*----------------------------------------------------------------------------*/
54/*----------------------------------------------------------------------------*/
55
56/*----------------------------------------------------------------------------*/
57/*
58 * \brief Translation of the boundary conditions given by the user
59 * in a form that fits to the solver.
60 *
61 * The values at a boundary face \f$ \fib \f$ stored in the face center
62 * \f$ \centf \f$ of the variable \f$ P \f$ and its diffusive flux \f$ Q \f$
63 * are written as:
64 * \f[
65 * P_{\face} = A_P^g + B_P^g P_{\centi}
66 * \f]
67 * and
68 * \f[
69 * Q_{\face} = A_P^f + B_P^f P_{\centi}
70 * \f]
71 * where \f$ P_\centi \f$ is the value of the variable \f$ P \f$ at the
72 * neighboring cell.
73 *
74 * \warning
75 * - If we consider an increment of a variable, the boundary conditions
76 * read:
77 * \f[
78 * \delta P_{\face} = B_P^g \delta P_{\centi}
79 * \f]
80 * and
81 * \f[
82 * \delta Q_{\face} = -B_P^f \delta P_{\centi}
83 * \f]
84 *
85 * - For a vector field such as the velocity \f$ \vect{u} \f$ the boundary
86 * conditions may read:
87 * \f[
88 * \vect{u}_{\face} = \vect{A}_u^g + \tens{B}_u^g \vect{u}_{\centi}
89 * \f]
90 * and
91 * \f[
92 * \vect{Q}_{\face} = \vect{A}_u^f + \tens{B}_u^f \vect{u}_{\centi}
93 * \f]
94 * where \f$ \tens{B}_u^g \f$ and \f$ \tens{B}_u^f \f$ are 3x3 tensor matrix
95 * which coupled velocity components next to a boundary.
96 *
97 * Please refer to the
98 * <a href="../../theory.pdf#boundary"><b>boundary conditions</b></a> section
99 * of the theory guide for more informations, as well as the
100 * <a href="../../theory.pdf#condli"><b>condli</b></a> section.
101 *
102 * \param[in] nvar total number of variables
103 * \param[in] iterns iteration number on Navier-Stokes equations
104 * \param[in] isvhb id of field whose exchange coeffient should be
105 * saved at the walls, or -1.
106 * \param[in] itrale ALE iteration number
107 * \param[in] italim for ALE
108 * \param[in] itrfin for ALE
109 * \param[in] ineefl for ALE
110 * \param[in] itrfup for ALE
111 * \param[in,out] isostd indicator for standard outlet
112 * and reference face index
113 * \param[in] dt time step (per cell)
114 * \param[out] visvdr dynamic viscosity after V. Driest damping in
115 * boundary cells
116 * \param[out] hbord exchange coefficient at boundary
117 * \param[out] theipb value of thermal scalar at \f$ \centip \f$
118 * of boundary cells
119 * \param[in] nftcdt Global indicator of condensation source terms
120 * (ie. sum on the processors of nfbpcd) cells
121 * associated to the face with condensation
122 * phenomenon
123 */
124/*----------------------------------------------------------------------------*/
125
126void
128 int iterns,
129 int isvhb,
130 int itrale,
131 int italim,
132 int itrfin,
133 int ineefl,
134 int itrfup,
135 int isostd[],
136 cs_real_t visvdr[],
137 cs_real_t hbord[],
138 cs_real_t theipb[],
139 int nftcdt);
140
141/*----------------------------------------------------------------------------*/
145/*----------------------------------------------------------------------------*/
146
147void
149
150/*----------------------------------------------------------------------------*/
159/*----------------------------------------------------------------------------*/
160
161inline static void
163 cs_field_bc_coeffs_t *bc_coeffs,
165 cs_real_t hint)
166{
167 cs_real_t *a = bc_coeffs->a;
168 cs_real_t *b = bc_coeffs->b;
169 cs_real_t *af = bc_coeffs->af;
170 cs_real_t *bf = bc_coeffs->bf;
171
172 /* Gradient BCs */
173 a[f_id] = -qimp/cs_math_fmax(hint, 1.e-300);
174 b[f_id] = 1.;
175
176 /* Flux BCs */
177 af[f_id] = qimp;
178 bf[f_id] = 0.;
179}
180
181/*----------------------------------------------------------------------------*/
188/*----------------------------------------------------------------------------*/
189
190inline static void
192 cs_field_bc_coeffs_t *bc_coeffs)
193{
194 cs_real_t *a = bc_coeffs->a;
195 cs_real_t *b = bc_coeffs->b;
196 cs_real_t *af = bc_coeffs->af;
197 cs_real_t *bf = bc_coeffs->bf;
198
199 /* Gradient BCs */
200 a[f_id] = 0.;
201 b[f_id] = 1.;
202
203 /* Flux BCs */
204 af[f_id] = 0.;
205 bf[f_id] = 0.;
206}
207
208/*----------------------------------------------------------------------------*/
217/*----------------------------------------------------------------------------*/
218
219inline static void
221 cs_field_bc_coeffs_t *bc_coeffs,
222 const cs_real_t qimpv[3],
223 cs_real_t hint)
224{
225 cs_real_3_t *a = (cs_real_3_t *)bc_coeffs->a;
226 cs_real_33_t *b = (cs_real_33_t *)bc_coeffs->b;
227 cs_real_3_t *af = (cs_real_3_t *)bc_coeffs->af;
228 cs_real_33_t *bf = (cs_real_33_t *)bc_coeffs->bf;
229
230 /* Gradient BCs */
231
232 for (size_t i = 0; i < 3; i++) {
233 a[f_id][i] = -qimpv[i] / fmax(hint, 1.e-300);
234 }
235
236 b[f_id][0][0] = 1., b[f_id][0][1] = 0., b[f_id][0][2] = 0.;
237 b[f_id][1][0] = 0., b[f_id][1][1] = 1., b[f_id][1][2] = 0.;
238 b[f_id][2][0] = 0., b[f_id][2][1] = 0., b[f_id][2][2] = 1.;
239
240 /* Flux BCs */
241
242 for (size_t i = 0; i < 3; i++) {
243 af[f_id][i] = qimpv[i];
244
245 for (size_t j = 0; j < 3; j++)
246 bf[f_id][i][j] = 0.;
247 }
248}
249
250/*----------------------------------------------------------------------------*/
259/*----------------------------------------------------------------------------*/
260
261inline static void
263 cs_field_bc_coeffs_t *bc_coeffs,
264 const cs_real_t qimpv[3],
265 const cs_real_t hint[6])
266{
267 cs_real_3_t *a = (cs_real_3_t *)bc_coeffs->a;
268 cs_real_33_t *b = (cs_real_33_t *)bc_coeffs->b;
269 cs_real_3_t *af = (cs_real_3_t *)bc_coeffs->af;
270 cs_real_33_t *bf = (cs_real_33_t *)bc_coeffs->bf;
271
272 cs_real_t m[6] = {0., 0., 0., 0., 0., 0.};
273 m[0] = hint[1]*hint[2] - hint[4]*hint[4];
274 m[1] = hint[0]*hint[2] - hint[5]*hint[5];
275 m[2] = hint[0]*hint[1] - hint[3]*hint[3];
276 m[3] = hint[4]*hint[5] - hint[3]*hint[2];
277 m[4] = hint[3]*hint[5] - hint[0]*hint[4];
278 m[5] = hint[3]*hint[4] - hint[1]*hint[5];
279
280 cs_real_t invdet = 1./(hint[0]*m[0] + hint[3]*m[3] + hint[5]*m[5]);
281
282 cs_real_t invh[6] = {0., 0., 0., 0., 0., 0.};
283 invh[0] = m[0] * invdet;
284 invh[1] = m[1] * invdet;
285 invh[2] = m[2] * invdet;
286 invh[3] = m[3] * invdet;
287 invh[4] = m[4] * invdet;
288 invh[5] = m[5] * invdet;
289
290 /* Gradient BCs */
291 cs_math_sym_33_3_product(invh, qimpv, a[f_id]);
292 for (int isou = 0; isou < 3; isou++)
293 a[f_id][isou] = -a[f_id][isou];
294
295 b[f_id][0][0] = 1.0, b[f_id][0][1] = 0.0, b[f_id][0][2] = 0.0;
296 b[f_id][1][0] = 0.0, b[f_id][1][1] = 1.0, b[f_id][1][2] = 0.0;
297 b[f_id][2][0] = 0.0, b[f_id][2][1] = 0.0, b[f_id][2][2] = 1.0;
298
299 for (int isou = 0; isou < 3; isou++) {
300
301 /* Flux BCs */
302 af[f_id][isou] = qimpv[isou];
303 for (int jsou = 0; jsou < 3; jsou++)
304 bf[f_id][isou][jsou] = 0.0;
305 }
306}
307
308/*----------------------------------------------------------------------------*/
316/*----------------------------------------------------------------------------*/
317
318inline static void
320 cs_real_t af[6],
321 cs_real_t b[6][6],
322 cs_real_t bf[6][6],
323 const cs_real_t qimpts[6],
324 cs_real_t hint)
325{
326 for (int isou = 0; isou < 6; isou++) {
327
328 /* Gradient BC */
329 a[isou] = -qimpts[isou]/cs_math_fmax(hint, 1.e-300);
330 for (int jsou = 0; jsou < 6; jsou++) {
331 if (jsou == isou)
332 b[isou][jsou] = 1.0;
333 else
334 b[isou][jsou] = 0.0;
335 }
336
337 /* Flux BCs */
338 af[isou] = qimpts[isou];
339 for (int jsou = 0; jsou < 6; jsou++)
340 bf[isou][jsou] = 0.0;
341 }
342}
343
344/*----------------------------------------------------------------------------*/
355/*----------------------------------------------------------------------------*/
356
357inline static void
359 cs_field_bc_coeffs_t *bc_coeffs,
360 cs_real_t pimp,
361 cs_real_t hint,
362 cs_real_t hext)
363{
364 cs_real_t *a = bc_coeffs->a;
365 cs_real_t *b = bc_coeffs->b;
366 cs_real_t *af = bc_coeffs->af;
367 cs_real_t *bf = bc_coeffs->bf;
368
369 //if (fabs(hext) > cs_math_infinite_r*0.5) {
370 if (hext < 0.) {
371
372 /* Gradient BCs */
373 a[f_id] = pimp;
374 b[f_id] = 0.;
375
376 /* Flux BCs */
377 af[f_id] = -hint*pimp;
378 bf[f_id] = hint;
379
380 }
381 else {
382
383 /* Gradient BCs */
384 a[f_id] = hext*pimp/(hint + hext);
385 b[f_id] = hint /(hint + hext);
386
387 /* Flux BCs */
388 cs_real_t heq = hint*hext/(hint + hext);
389 af[f_id] = -heq*pimp;
390 bf[f_id] = heq;
391
392 }
393}
394
395/*----------------------------------------------------------------------------*/
406/*----------------------------------------------------------------------------*/
407
408inline static void
410 cs_field_bc_coeffs_t *bc_coeffs,
411 const cs_real_t pimpv[3],
412 cs_real_t hint,
413 const cs_real_t hextv[3])
414{
415
416 cs_real_3_t *a = (cs_real_3_t *)bc_coeffs->a;
417 cs_real_33_t *b = (cs_real_33_t *)bc_coeffs->b;
418 cs_real_3_t *af = (cs_real_3_t *)bc_coeffs->af;
419 cs_real_33_t *bf = (cs_real_33_t *)bc_coeffs->bf;
420
421 for (int isou = 0; isou < 3; isou++) {
422 if (fabs(hextv[isou]) > 0.5*cs_math_infinite_r) {
423
424 /* Gradient BCs */
425 a[f_id][isou] = pimpv[isou];
426 for (int jsou = 0; jsou < 3; jsou++)
427 b[f_id][isou][jsou] = 0.;
428
429 /* Flux BCs */
430 af[f_id][isou] = -hint*pimpv[isou];
431
432 bf[f_id][0][0] = hint, bf[f_id][0][1] = 0., bf[f_id][0][2] = 0.;
433 bf[f_id][1][0] = 0., bf[f_id][1][1] = hint, bf[f_id][1][2] = 0.;
434 bf[f_id][2][0] = 0., bf[f_id][2][1] = 0., bf[f_id][2][2] = hint;
435
436 }
437 else {
438
439 const cs_real_t val = hint/(hint + hextv[isou]);
440 const cs_real_t heq = hextv[isou]*val;
441
442 /* Gradient BCs */
443 a[f_id][isou] = hextv[isou]*pimpv[isou]/(hint + hextv[isou]);
444
445 b[f_id][0][0] = val, b[f_id][0][1] = 0., b[f_id][0][2] = 0.;
446 b[f_id][1][0] = 0., b[f_id][1][1] = val, b[f_id][1][2] = 0.;
447 b[f_id][2][0] = 0., b[f_id][2][1] = 0., b[f_id][2][2] = val;
448
449 /* Flux BCs */
450 af[f_id][isou] = -heq*pimpv[isou];
451
452 bf[f_id][0][0] = heq, bf[f_id][0][1] = 0., bf[f_id][0][2] = 0.;
453 bf[f_id][1][0] = 0., bf[f_id][1][1] = heq, bf[f_id][1][2] = 0.;
454 bf[f_id][2][0] = 0., bf[f_id][2][1] = 0., bf[f_id][2][2] = heq;
455
456 }
457 }
458}
459
460/*----------------------------------------------------------------------------*/
461/*
462 * \brief Set convective oulet BC for a scalar for a given face.
463 *
464 * \param[in] f_id face id
465 * \param[out] bc_coeffs boundary conditions structure
466 * \param[in] pimp flux value to impose
467 * \param[in] cfl local Courant number used to convect
468 * \param[in] hint internal exchange coefficient
469 */
470/*----------------------------------------------------------------------------*/
471
472void
474 (cs_lnum_t f_id,
475 cs_field_bc_coeffs_t *bc_coeffs,
476 cs_real_t pimp,
477 cs_real_t cfl,
478 cs_real_t hint);
479
480/*----------------------------------------------------------------------------*/
492/*----------------------------------------------------------------------------*/
493
494inline static void
496(cs_lnum_t f_id,
497 cs_field_bc_coeffs_t *bc_coeffs,
498 const cs_real_t pimpv[3],
499 const cs_real_t hintt[6],
500 const cs_real_t hextv[3])
501{
502
503 cs_real_3_t *a = (cs_real_3_t *)bc_coeffs->a;
504 cs_real_33_t *b = (cs_real_33_t *)bc_coeffs->b;
505 cs_real_3_t *af = (cs_real_3_t *)bc_coeffs->af;
506 cs_real_33_t *bf = (cs_real_33_t *)bc_coeffs->bf;
507
508 /* Gradient BCs */
509 for (int isou = 0; isou < 3; isou++) {
510 if (fabs(hextv[isou]) > 0.5*cs_math_infinite_r) {
511 a[f_id][isou] = pimpv[isou];
512 for (int jsou = 0; jsou < 3; jsou++)
513 b[f_id][isou][jsou] = 0.;
514 }
515 else {
516 /* FIXME: at least log error message */
517 bft_error(__FILE__, __LINE__, 0,
518 _(" %s: hextv not set for component %d."),
519 __func__, isou);
520 }
521 }
522
523 /* Flux BCs */
524 cs_math_sym_33_3_product(hintt, pimpv, af[f_id]);
525 for (int isou = 0; isou < 3; isou++)
526 af[f_id][isou] = -af[f_id][isou];
527
528 bf[f_id][0][0] = hintt[0];
529 bf[f_id][1][1] = hintt[1];
530 bf[f_id][2][2] = hintt[2];
531 bf[f_id][0][1] = hintt[3];
532 bf[f_id][1][0] = hintt[3];
533 bf[f_id][1][2] = hintt[4];
534 bf[f_id][2][1] = hintt[4];
535 bf[f_id][0][2] = hintt[5];
536 bf[f_id][2][0] = hintt[5];
537}
538
539/*----------------------------------------------------------------------------*/
549/*----------------------------------------------------------------------------*/
550
551inline static void
553 cs_real_t af[6],
554 cs_real_t b[6][6],
555 cs_real_t bf[6][6],
556 const cs_real_t pimpts[6],
557 cs_real_t hint,
558 const cs_real_t hextts[6])
559{
560 for (int isou = 0; isou < 6; isou++) {
561
562 if (fabs(hextts[isou]) > 0.5*cs_math_infinite_r) {
563 /* Gradient BCs */
564 a[isou] = pimpts[isou];
565 for (int jsou = 0; jsou < 6; jsou++)
566 b[isou][jsou] = 0.;
567
568 /* Flux BCs */
569 af[isou] = -hint * pimpts[isou];
570 for (int jsou = 0; jsou < 6; jsou++) {
571 if (jsou == isou)
572 bf[isou][jsou] = hint;
573 else
574 bf[isou][jsou] = 0.;
575 }
576 }
577
578 else {
579
580 const cs_real_t heq = hint * hextts[isou] / (hint + hextts[isou]);
581
582 /* Gradient BCs */
583 a[isou] = hextts[isou] * pimpts[isou] / (hint + hextts[isou]);
584 for (int jsou = 0; jsou < 6; jsou++) {
585 if (jsou == isou)
586 b[isou][jsou] = hint / (hint + hextts[isou]);
587 else
588 b[isou][jsou] = 0.;
589 }
590
591 /* Flux BCs */
592 af[isou] = -heq * pimpts[isou];
593 for (int jsou = 0; jsou < 6; jsou++) {
594 if (jsou == isou)
595 bf[isou][jsou] = heq;
596 else
597 bf[isou][jsou] = 0.;
598 }
599 }
600 }
601}
602
603/*----------------------------------------------------------------------------*/
614/*----------------------------------------------------------------------------*/
615
616inline static void
618 (cs_lnum_t f_id,
619 cs_field_bc_coeffs_t *bc_coeffs,
620 const cs_real_t pimpv[3],
621 const cs_real_t qimpv[3],
622 cs_real_t hint,
623 const cs_nreal_t normal[3])
624{
625 cs_real_3_t *a = (cs_real_3_t *)bc_coeffs->a;
626 cs_real_33_t *b = (cs_real_33_t *)bc_coeffs->b;
627 cs_real_3_t *af = (cs_real_3_t *)bc_coeffs->af;
628 cs_real_33_t *bf = (cs_real_33_t *)bc_coeffs->bf;
629
630 for (int isou = 0; isou < 3; isou++) {
631
632 /* Gradient BCs */
633 a[f_id][isou] = - qimpv[isou]/cs_math_fmax(hint, 1.e-300);
634 /* "[1 -n(x)n] Qimp / hint" is divided into two */
635 for (int jsou = 0; jsou < 3; jsou++) {
636
637 a[f_id][isou] = a[f_id][isou] + normal[isou]*normal[jsou]
638 * (pimpv[jsou] + qimpv[jsou] / cs_math_fmax(hint, 1.e-300));
639
640 if (jsou == isou)
641 b[f_id][isou][jsou] = 1.0 - normal[isou] * normal[jsou];
642 else
643 b[f_id][isou][jsou] = - normal[isou] * normal[jsou];
644 }
645
646 /* Flux BCs */
647 af[f_id][isou] = qimpv[isou];
648 /* "[1 -n(x)n] Qimp" is divided into two */
649 for (int jsou = 0; jsou < 3; jsou++){
650
651 af[f_id][isou] = af[f_id][isou] - normal[isou]*normal[jsou]
652 * (hint * pimpv[jsou] + qimpv[jsou]);
653
654 bf[f_id][isou][jsou] = hint * normal[isou] * normal[jsou];
655 }
656 }
657}
658
659/*----------------------------------------------------------------------------*/
671/*----------------------------------------------------------------------------*/
672
673void
675 (cs_lnum_t f_id,
676 cs_field_bc_coeffs_t *bc_coeffs,
677 const cs_real_t pimpv[3],
678 const cs_real_t qimpv[3],
679 const cs_real_t hint[6],
680 const cs_nreal_t normal[3]);
681
682/*----------------------------------------------------------------------------*/
694/*----------------------------------------------------------------------------*/
695
696inline static void
698 (cs_lnum_t f_id,
699 cs_field_bc_coeffs_t *bc_coeffs,
700 const cs_real_t pimpv[3],
701 const cs_real_t qimpv[3],
702 cs_real_t hint,
703 const cs_nreal_t normal[3])
704{
705 cs_real_3_t *a = (cs_real_3_t *)bc_coeffs->a;
706 cs_real_33_t *b = (cs_real_33_t *)bc_coeffs->b;
707 cs_real_3_t *af = (cs_real_3_t *)bc_coeffs->af;
708 cs_real_33_t *bf = (cs_real_33_t *)bc_coeffs->bf;
709
710 for (int isou = 0; isou < 3; isou++) {
711
712 /* Gradient BC*/
713 /* "[1 -n(x)n] Pimp" is divided into two */
714 a[f_id][isou] = pimpv[isou];
715 for (int jsou = 0; jsou < 3; jsou++) {
716
717 a[f_id][isou] = a[f_id][isou] - normal[isou]*normal[jsou]
718 * (pimpv[jsou] + qimpv[jsou] / cs_math_fmax(hint, 1.e-300));
719
720 b[f_id][isou][jsou] = normal[isou] * normal[jsou];
721 }
722
723 /* Flux BC */
724 /* "[1 -n(x)n] Pimp" is divided into two */
725 af[f_id][isou] = -hint*pimpv[isou];
726 for (int jsou = 0; jsou < 3; jsou++) {
727
728 af[f_id][isou] = af[f_id][isou] + normal[isou]*normal[jsou]
729 * (qimpv[jsou] + pimpv[jsou] * hint);
730
731 if (jsou == isou)
732 bf[f_id][isou][jsou] = hint * (1.0 - normal[isou] * normal[jsou]);
733 else
734 bf[f_id][isou][jsou] = - hint * normal[isou] * normal[jsou];
735 }
736 }
737}
738
739/*----------------------------------------------------------------------------*/
752/*----------------------------------------------------------------------------*/
753
754void
756 (cs_lnum_t f_id,
757 cs_field_bc_coeffs_t *bc_coeffs,
758 const cs_real_t pimpv[3],
759 const cs_real_t qimpv[3],
760 const cs_real_t hint[6],
761 const cs_nreal_t normal[3]);
762
763/*----------------------------------------------------------------------------*/
773/*----------------------------------------------------------------------------*/
774
775inline static void
777 (cs_lnum_t f_id,
778 cs_field_bc_coeffs_t *bc_coeffs,
779 const cs_real_t pimpv[3],
780 const cs_real_t cflv[3],
781 cs_real_t hint)
782{
783 cs_real_3_t *a = (cs_real_3_t *)bc_coeffs->a;
784 cs_real_33_t *b = (cs_real_33_t *)bc_coeffs->b;
785 cs_real_3_t *af = (cs_real_3_t *)bc_coeffs->af;
786 cs_real_33_t *bf = (cs_real_33_t *)bc_coeffs->bf;
787
788 for (int isou = 0; isou < 3; isou++) {
789
790 /* Gradient BCs */
791 for (int jsou = 0; jsou < 3; jsou ++) {
792 if (jsou == isou)
793 b[f_id][isou][jsou] = cflv[isou] / (1.0 + cflv[isou]);
794 else
795 b[f_id][isou][jsou] = 0.0;
796 }
797 a[f_id][isou] = pimpv[isou] * (1.0 - b[f_id][isou][isou]);
798
799 /* Flux BCs */
800 af[f_id][isou] = -hint * a[f_id][isou];
801 for (int jsou = 0; jsou < 3; jsou++) {
802 if (jsou == isou)
803 bf[f_id][isou][jsou] = hint * (1.0 - b[f_id][isou][jsou]);
804 else
805 bf[f_id][isou][jsou] = 0.0;
806 }
807 }
808}
809
810/*----------------------------------------------------------------------------*/
820/*----------------------------------------------------------------------------*/
821
822inline static void
824 cs_real_t af[6],
825 cs_real_t b[6][6],
826 cs_real_t bf[6][6],
827 const cs_real_t pimpts[6],
828 const cs_real_t cflts[6],
829 cs_real_t hint)
830{
831 for (int isou = 0; isou < 6; isou++) {
832
833 /* Gradient BCs */
834 for (int jsou = 0; jsou < 6; jsou++) {
835 if (jsou == isou)
836 b[isou][jsou] = cflts[isou] / (1.0 + cflts[isou]);
837 else
838 b[isou][jsou] = 0.0;
839 }
840 a[isou] = (1.0 - b[isou][isou]) * pimpts[isou];
841
842 /* Flux BCs */
843 af[isou] = -hint*a[isou];
844 for (int jsou = 0; jsou < 6; jsou++) {
845 if (jsou == isou)
846 bf[isou][jsou] = hint * (1.0 - b[isou][jsou]);
847 else
848 bf[isou][jsou] = 0.0;
849 }
850 }
851}
852
853/*----------------------------------------------------------------------------*/
863/*----------------------------------------------------------------------------*/
864
865inline static void
867(cs_lnum_t f_id,
868 cs_field_bc_coeffs_t *bc_coeffs,
869 const cs_real_t pimpv[3],
870 const cs_real_t cflv[3],
871 const cs_real_t hintt[6])
872{
873
874 cs_real_3_t *a = (cs_real_3_t *)bc_coeffs->a;
875 cs_real_33_t *b = (cs_real_33_t *)bc_coeffs->b;
876 cs_real_3_t *af = (cs_real_3_t *)bc_coeffs->af;
877 cs_real_33_t *bf = (cs_real_33_t *)bc_coeffs->bf;
878
879 for(int isou = 0; isou < 3; isou++) {
880
881 /* Gradient BCs */
882 for (int jsou = 0; jsou < 3; jsou++) {
883 if (jsou == isou)
884 b[f_id][isou][jsou] = cflv[isou]/(1.0+cflv[isou]);
885 else
886 b[f_id][isou][jsou] = 0.0;
887 }
888 a[f_id][isou] = (1.0-b[f_id][isou][isou])*pimpv[isou];
889
890 }
891
892 /* Flux BCs */
893 cs_math_sym_33_3_product(hintt, a[f_id], af[f_id]);
894 for (int isou = 0; isou < 3; isou++)
895 af[f_id][isou] = -af[f_id][isou];
896
897 bf[f_id][0][0] = hintt[0]*(1.0 - b[f_id][0][0]);
898 bf[f_id][1][1] = hintt[1]*(1.0 - b[f_id][1][1]);
899 bf[f_id][2][2] = hintt[2]*(1.0 - b[f_id][2][2]);
900 bf[f_id][0][1] = hintt[3]*(1.0 - b[f_id][0][0]);
901 bf[f_id][1][0] = hintt[3]*(1.0 - b[f_id][0][0]);
902 bf[f_id][1][2] = hintt[4]*(1.0 - b[f_id][1][1]);
903 bf[f_id][2][1] = hintt[4]*(1.0 - b[f_id][1][1]);
904 bf[f_id][0][2] = hintt[5]*(1.0 - b[f_id][2][2]);
905 bf[f_id][2][0] = hintt[5]*(1.0 - b[f_id][2][2]);
906}
907
908/*----------------------------------------------------------------------------*/
918/*----------------------------------------------------------------------------*/
919
920inline static void
922 (cs_lnum_t f_id,
923 cs_field_bc_coeffs_t *bc_coeffs,
924 cs_real_t pinf,
925 cs_real_t ratio,
926 cs_real_t hint)
927{
928 cs_real_t *a = bc_coeffs->a;
929 cs_real_t *b = bc_coeffs->b;
930 cs_real_t *af = bc_coeffs->af;
931 cs_real_t *bf = bc_coeffs->bf;
932
933 /* Gradient BCs */
934 b[f_id] = ratio;
935 a[f_id] = pinf;
936
937 /* Flux BCs */
938 af[f_id] = -hint * a[f_id];
939 bf[f_id] = hint * (1. - b[f_id]);
940}
941
942/*----------------------------------------------------------------------------*/
951/*----------------------------------------------------------------------------*/
952
953inline static void
955 (cs_lnum_t f_id,
956 cs_field_bc_coeffs_t *bc_coeffs,
957 cs_real_t dimp,
958 cs_real_t hint)
959
960{
961 cs_real_t *af = bc_coeffs->af;
962 cs_real_t *bf = bc_coeffs->bf;
963
964 /* Gradient BCs */
966 bc_coeffs,
967 dimp,
968 hint);
969
970 /* Flux BCs */
971 af[f_id] = 0.;
972 bf[f_id] = 0.;
973}
974
975/*----------------------------------------------------------------------------*/
986/*----------------------------------------------------------------------------*/
987
988inline static void
990 (cs_lnum_t f_id,
991 cs_field_bc_coeffs_t *bc_coeffs,
992 cs_real_t pinf,
993 cs_real_t ratio,
994 cs_real_t dimp)
995{
996 cs_real_t *a = bc_coeffs->a;
997 cs_real_t *b = bc_coeffs->b;
998 cs_real_t *af = bc_coeffs->af;
999 cs_real_t *bf = bc_coeffs->bf;
1000
1001 /* Gradient BCs */
1002 b[f_id] = ratio;
1003 a[f_id] = pinf;
1004
1005 /* Flux BCs */
1006 af[f_id] = dimp;
1007 bf[f_id] = 0.;
1008}
1009
1010/*----------------------------------------------------------------------------*/
1019/*----------------------------------------------------------------------------*/
1020
1021inline static void
1023 cs_field_bc_coeffs_t *bc_coeffs,
1024 cs_real_t hext,
1025 cs_real_t dimp)
1026{
1027 cs_real_t *a = bc_coeffs->a;
1028 cs_real_t *b = bc_coeffs->b;
1029 cs_real_t *af = bc_coeffs->af;
1030 cs_real_t *bf = bc_coeffs->bf;
1031
1032 /* Gradients BCs */
1033 a[f_id] = 0.;
1034 b[f_id] = 1.;
1035
1036 /* Flux BCs */
1037 af[f_id] = dimp;
1038 bf[f_id] = hext;
1039}
1040
1041/*----------------------------------------------------------------------------*/
1051/*----------------------------------------------------------------------------*/
1052
1053inline static void
1055 (cs_lnum_t f_id,
1056 cs_field_bc_coeffs_t *bc_coeffs,
1057 cs_real_t pimp,
1058 cs_real_t dimp)
1059{
1060 cs_real_t *a = bc_coeffs->a;
1061 cs_real_t *b = bc_coeffs->b;
1062 cs_real_t *af = bc_coeffs->af;
1063 cs_real_t *bf = bc_coeffs->bf;
1064
1065 /* Gradients BC */
1066 a[f_id] = pimp;
1067 b[f_id] = 0.;
1068
1069 /* Flux BCs */
1070 af[f_id] = dimp;
1071 bf[f_id] = 0.;
1072}
1073
1074/*----------------------------------------------------------------------------*/
1084/*----------------------------------------------------------------------------*/
1085
1086inline static void
1088 (cs_lnum_t f_id,
1089 cs_field_bc_coeffs_t *bc_coeffs,
1090 const cs_real_t pimpv[3],
1091 const cs_real_t qimpv[3])
1092{
1093 cs_real_3_t *a = (cs_real_3_t *)bc_coeffs->a;
1094 cs_real_33_t *b = (cs_real_33_t *)bc_coeffs->b;
1095 cs_real_3_t *af = (cs_real_3_t *)bc_coeffs->af;
1096 cs_real_33_t *bf = (cs_real_33_t *)bc_coeffs->bf;
1097
1098 for (int isou = 0; isou < 3; isou++) {
1099
1100 /* Gradient BCs */
1101 a[f_id][isou] = pimpv[isou];
1102 for (int jsou = 0; jsou < 3; jsou++)
1103 b[f_id][isou][jsou] = 0.0;
1104
1105 /* Flux BCs */
1106 af[f_id][isou] = qimpv[isou];
1107 for (int jsou = 0; jsou < 3; jsou++)
1108 bf[f_id][isou][jsou] = 0.0;
1109 }
1110}
1111
1112/*----------------------------------------------------------------------------*/
1122/*----------------------------------------------------------------------------*/
1123
1124inline static void
1126 (cs_real_t a[6],
1127 cs_real_t af[6],
1128 cs_real_t b[6][6],
1129 cs_real_t bf[6][6],
1130 const cs_real_t pimpts[6],
1131 const cs_real_t qimpts[6])
1132{
1133 for (int isou = 0; isou < 6; isou++) {
1134
1135 /* BS test on hextv ? if (abs(hextv[isou]) > cs_math_infinite_r * 0.5) */
1136
1137 /* Gradient BCs */
1138 a[isou] = pimpts[isou];
1139 for (int jsou = 0; jsou < 6; jsou++)
1140 b[isou][jsou] = 0.0;
1141
1142 /* Flux BCs */
1143 af[isou] = qimpts[isou];
1144 for (int jsou = 0; jsou < 6; jsou++)
1145 bf[isou][jsou] = 0.0;
1146 }
1147}
1148
1149/*----------------------------------------------------------------------------*/
1150
1152
1153#endif /* __CS_BOUNDARY_CONDITIONS_SET_COEFFS_H__ */
void bft_error(const char *const file_name, const int line_num, const int sys_error_code, const char *const format,...)
Calls the error handler (set by bft_error_handler_set() or default).
Definition: bft_error.cpp:193
void cs_boundary_conditions_set_generalized_sym_vector_aniso(cs_lnum_t f_id, cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t pimpv[3], const cs_real_t qimpv[3], const cs_real_t hint[6], const cs_nreal_t normal[3])
Set generalized BC for an anisotropic symmetric vector for a given face.
Definition: cs_boundary_conditions_set_coeffs.cpp:3906
static void cs_boundary_conditions_set_dirichlet_vector(cs_lnum_t f_id, cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t pimpv[3], cs_real_t hint, const cs_real_t hextv[3])
Set Dirichlet BC for a vector for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:409
static void cs_boundary_conditions_set_neumann_scalar_hmg(cs_lnum_t f_id, cs_field_bc_coeffs_t *bc_coeffs)
Set homogeneous Neumann BC for a scalar for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:191
static void cs_boundary_conditions_set_affine_function_conv_neumann_diff_scalar(cs_lnum_t f_id, cs_field_bc_coeffs_t *bc_coeffs, cs_real_t pinf, cs_real_t ratio, cs_real_t dimp)
Set Neumann BC for the convection operator, imposed flux for diffusion.
Definition: cs_boundary_conditions_set_coeffs.h:990
static void cs_boundary_conditions_set_dirichlet_conv_neumann_diff_scalar(cs_lnum_t f_id, cs_field_bc_coeffs_t *bc_coeffs, cs_real_t pimp, cs_real_t dimp)
Imposed value for the convection operator, imposed flux for diffusion, for a scalar.
Definition: cs_boundary_conditions_set_coeffs.h:1055
static void cs_boundary_conditions_set_dirichlet_scalar(cs_lnum_t f_id, cs_field_bc_coeffs_t *bc_coeffs, cs_real_t pimp, cs_real_t hint, cs_real_t hext)
Set Dirichlet BC for a scalar for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:358
static void cs_boundary_conditions_set_dirichlet_conv_neumann_diff_vector(cs_lnum_t f_id, cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t pimpv[3], const cs_real_t qimpv[3])
Imposed value for the convection operator, imposed flux for diffusion, for a vector.
Definition: cs_boundary_conditions_set_coeffs.h:1088
static void cs_boundary_conditions_set_convective_outlet_tensor(cs_real_t a[6], cs_real_t af[6], cs_real_t b[6][6], cs_real_t bf[6][6], const cs_real_t pimpts[6], const cs_real_t cflts[6], cs_real_t hint)
Set convective outlet BC for a tensor for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:823
void cs_boundary_conditions_set_convective_outlet_scalar(cs_lnum_t f_id, cs_field_bc_coeffs_t *bc_coeffs, cs_real_t pimp, cs_real_t cfl, cs_real_t hint)
Set convective oulet boundary condition for a scalar.
Definition: cs_boundary_conditions_set_coeffs.cpp:3870
static void cs_boundary_conditions_set_neumann_vector(cs_lnum_t f_id, cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t qimpv[3], cs_real_t hint)
Set Neumann BC for a scalar for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:220
void cs_boundary_conditions_set_coeffs_init(void)
Initialization of boundary condition arrays.
Definition: cs_boundary_conditions_set_coeffs.cpp:3714
static void cs_boundary_conditions_set_neumann_vector_aniso(cs_lnum_t f_id, cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t qimpv[3], const cs_real_t hint[6])
Set neumann BC for an anisotropic vector for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:262
static void cs_boundary_conditions_set_dirichlet_conv_neumann_diff_tensor(cs_real_t a[6], cs_real_t af[6], cs_real_t b[6][6], cs_real_t bf[6][6], const cs_real_t pimpts[6], const cs_real_t qimpts[6])
Imposed value for the convection operator, imposed flux for diffusion, for a tensor.
Definition: cs_boundary_conditions_set_coeffs.h:1126
static void cs_boundary_conditions_set_affine_function_scalar(cs_lnum_t f_id, cs_field_bc_coeffs_t *bc_coeffs, cs_real_t pinf, cs_real_t ratio, cs_real_t hint)
Set BC for an affine scalar function for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:922
static void cs_boundary_conditions_set_convective_outlet_vector_aniso(cs_lnum_t f_id, cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t pimpv[3], const cs_real_t cflv[3], const cs_real_t hintt[6])
Set convective outlet BC for an anisotropic vector for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:867
void cs_boundary_conditions_set_coeffs(int nvar, int iterns, int isvhb, int itrale, int italim, int itrfin, int ineefl, int itrfup, int isostd[], cs_real_t visvdr[], cs_real_t hbord[], cs_real_t theipb[], int nftcdt)
Translation of the boundary conditions given by the user in a form that fits to the solver.
Definition: cs_boundary_conditions_set_coeffs.cpp:853
static void cs_boundary_conditions_set_dirichlet_vector_aniso(cs_lnum_t f_id, cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t pimpv[3], const cs_real_t hintt[6], const cs_real_t hextv[3])
Set Dirichlet BC for a vector for a given face with left anisotropic diffusion.
Definition: cs_boundary_conditions_set_coeffs.h:496
static void cs_boundary_conditions_set_generalized_dirichlet_vector(cs_lnum_t f_id, cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t pimpv[3], const cs_real_t qimpv[3], cs_real_t hint, const cs_nreal_t normal[3])
Set generalized Dirichlet BC for a vector for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:698
static void cs_boundary_conditions_set_generalized_sym_vector(cs_lnum_t f_id, cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t pimpv[3], const cs_real_t qimpv[3], cs_real_t hint, const cs_nreal_t normal[3])
Set generalized BC for a symmetric vector for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:618
static void cs_boundary_conditions_set_convective_outlet_vector(cs_lnum_t f_id, cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t pimpv[3], const cs_real_t cflv[3], cs_real_t hint)
Set convective outlet BC for a vector for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:777
static void cs_boundary_conditions_set_neumann_conv_h_neumann_diff_scalar(cs_lnum_t f_id, cs_field_bc_coeffs_t *bc_coeffs, cs_real_t dimp, cs_real_t hint)
Set Neumann BC for the convection operator, zero flux for diffusion.
Definition: cs_boundary_conditions_set_coeffs.h:955
static void cs_boundary_conditions_set_total_flux(cs_lnum_t f_id, cs_field_bc_coeffs_t *bc_coeffs, cs_real_t hext, cs_real_t dimp)
Set total flux as a Robin condition.
Definition: cs_boundary_conditions_set_coeffs.h:1022
static void cs_boundary_conditions_set_dirichlet_tensor(cs_real_t a[6], cs_real_t af[6], cs_real_t b[6][6], cs_real_t bf[6][6], const cs_real_t pimpts[6], cs_real_t hint, const cs_real_t hextts[6])
Set Dirichlet BC for a tensor for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:552
static void cs_boundary_conditions_set_neumann_tensor(cs_real_t a[6], cs_real_t af[6], cs_real_t b[6][6], cs_real_t bf[6][6], const cs_real_t qimpts[6], cs_real_t hint)
Set Neumann boundary conditions for a tensor for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:319
static void cs_boundary_conditions_set_neumann_scalar(cs_lnum_t f_id, cs_field_bc_coeffs_t *bc_coeffs, cs_real_t qimp, cs_real_t hint)
Set Neumann BC for a scalar for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:162
void cs_boundary_conditions_set_generalized_dirichlet_vector_aniso(cs_lnum_t f_id, cs_field_bc_coeffs_t *bc_coeffs, const cs_real_t pimpv[3], const cs_real_t qimpv[3], const cs_real_t hint[6], const cs_nreal_t normal[3])
Set generalized Dirichlet BC for an anisotropic vector for a given face.
Definition: cs_boundary_conditions_set_coeffs.cpp:3989
#define BEGIN_C_DECLS
Definition: cs_defs.h:542
double cs_real_t
Floating-point value.
Definition: cs_defs.h:342
#define _(String)
Definition: cs_defs.h:67
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:359
#define END_C_DECLS
Definition: cs_defs.h:543
cs_real_t cs_real_33_t[3][3]
3x3 matrix of floating-point values
Definition: cs_defs.h:368
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:335
double cs_nreal_t
Definition: cs_defs.h:346
const cs_real_t cs_math_infinite_r
static CS_F_HOST_DEVICE void cs_math_sym_33_3_product(const cs_real_t m[6], const cs_real_t v[3], cs_real_t *restrict mv)
Compute the product of a symmetric matrix of 3x3 real values by a vector of 3 real values....
Definition: cs_math.h:983
static CS_F_HOST_DEVICE cs_real_t cs_math_fmax(cs_real_t x, cs_real_t y)
Compute the max value of two real values.
Definition: cs_math.h:503
integer, save nvar
number of solved variables (must be lower than nvarmx)
Definition: dimens.f90:42
real(c_double), dimension(:), pointer, save qimp
Definition: coincl.f90:158
real(c_double), pointer, save fmax
Definition: coincl.f90:185
Field boundary condition descriptor (for variables)
Definition: cs_field.h:104
cs_real_t * af
Definition: cs_field.h:115
cs_real_t * b
Definition: cs_field.h:114
cs_real_t * a
Definition: cs_field.h:113
cs_real_t * bf
Definition: cs_field.h:116