programmer's documentation
cs_convection_diffusion.h
Go to the documentation of this file.
1 #ifndef __CS_CONVECTION_DIFFUSION_H__
2 #define __CS_CONVECTION_DIFFUSION_H__
3 
4 /*============================================================================
5  * Convection-diffusion operators.
6  *============================================================================*/
7 
8 /*
9  This file is part of Code_Saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2015 EDF S.A.
12 
13  This program is free software; you can redistribute it and/or modify it under
14  the terms of the GNU General Public License as published by the Free Software
15  Foundation; either version 2 of the License, or (at your option) any later
16  version.
17 
18  This program is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20  FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21  details.
22 
23  You should have received a copy of the GNU General Public License along with
24  this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25  Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 */
27 
28 /*----------------------------------------------------------------------------*/
29 
30 #include "cs_defs.h"
31 
32 /*----------------------------------------------------------------------------
33  * Local headers
34  *----------------------------------------------------------------------------*/
35 
36 #include "cs_base.h"
37 #include "cs_halo.h"
38 
39 /*----------------------------------------------------------------------------*/
40 
42 
43 /*=============================================================================
44  * Local Macro definitions
45  *============================================================================*/
46 
47 /*============================================================================
48  * Type definition
49  *============================================================================*/
50 
51 /*============================================================================
52  * Global variables
53  *============================================================================*/
54 
55 /*============================================================================
56  * Private function definitions
57  *============================================================================*/
58 
59 /*----------------------------------------------------------------------------*/
76 /*----------------------------------------------------------------------------*/
77 
78 inline static void
80  const cs_real_t pj,
81  const cs_real_t distf,
82  const cs_real_t srfan,
83  const cs_real_3_t i_face_normal,
84  const cs_real_3_t gradi,
85  const cs_real_3_t gradj,
86  const cs_real_3_t grdpai,
87  const cs_real_3_t grdpaj,
88  const cs_real_t i_massflux,
89  double *testij,
90  double *tesqck)
91 {
92  double testi, testj;
93  double dcc, ddi, ddj;
94 
95  /* Slope test
96  ----------*/
97 
98  testi = grdpai[0]*i_face_normal[0]
99  + grdpai[1]*i_face_normal[1]
100  + grdpai[2]*i_face_normal[2];
101  testj = grdpaj[0]*i_face_normal[0]
102  + grdpaj[1]*i_face_normal[1]
103  + grdpaj[2]*i_face_normal[2];
104  *testij = grdpai[0]*grdpaj[0]
105  + grdpai[1]*grdpaj[1]
106  + grdpai[2]*grdpaj[2];
107 
108  if (i_massflux>0.) {
109  dcc = gradi[0]*i_face_normal[0]
110  + gradi[1]*i_face_normal[1]
111  + gradi[2]*i_face_normal[2];
112  ddi = testi;
113  ddj = (pj-pi)/distf *srfan;
114  } else {
115  dcc = gradj[0]*i_face_normal[0]
116  + gradj[1]*i_face_normal[1]
117  + gradj[2]*i_face_normal[2];
118  ddi = (pj-pi)/distf *srfan;
119  ddj = testj;
120  }
121  *tesqck = pow(dcc, 2.) - pow(ddi-ddj, 2.);
122 }
123 
124 /*----------------------------------------------------------------------------*/
143 /*----------------------------------------------------------------------------*/
144 
145 inline static void
146 cs_i_compute_quantities(const int ircflp,
147  const double pnd,
148  const cs_real_3_t cell_ceni,
149  const cs_real_3_t cell_cenj,
150  const cs_real_3_t i_face_cog,
151  const cs_real_3_t dijpf,
152  const cs_real_3_t gradi,
153  const cs_real_3_t gradj,
154  const cs_real_t pi,
155  const cs_real_t pj,
156  cs_real_t *recoi,
157  cs_real_t *recoj,
158  cs_real_t *pip,
159  cs_real_t *pjp)
160 {
161  cs_real_t diipfx, diipfy, diipfz, djjpfx, djjpfy, djjpfz;
162  cs_real_t dpxf, dpyf, dpzf;
163 
164  /* Recompute II' and JJ' at this level */
165 
166  diipfx = i_face_cog[0] - (cell_ceni[0] + (1.-pnd) * dijpf[0]);
167  diipfy = i_face_cog[1] - (cell_ceni[1] + (1.-pnd) * dijpf[1]);
168  diipfz = i_face_cog[2] - (cell_ceni[2] + (1.-pnd) * dijpf[2]);
169 
170  djjpfx = i_face_cog[0] - cell_cenj[0] + pnd * dijpf[0];
171  djjpfy = i_face_cog[1] - cell_cenj[1] + pnd * dijpf[1];
172  djjpfz = i_face_cog[2] - cell_cenj[2] + pnd * dijpf[2];
173 
174  dpxf = 0.5*(gradi[0] + gradj[0]);
175  dpyf = 0.5*(gradi[1] + gradj[1]);
176  dpzf = 0.5*(gradi[2] + gradj[2]);
177 
178  /* reconstruction only if IRCFLP = 1 */
179  *recoi = ircflp*(dpxf*diipfx+dpyf*diipfy+dpzf*diipfz);
180  *recoj = ircflp*(dpxf*djjpfx+dpyf*djjpfy+dpzf*djjpfz);
181  *pip = pi + *recoi;
182  *pjp = pj + *recoj;
183 }
184 
185 /*----------------------------------------------------------------------------*/
201 /*----------------------------------------------------------------------------*/
202 
203 inline static void
204 cs_i_relax_c_val(const double relaxp,
205  const cs_real_t pia,
206  const cs_real_t pja,
207  const cs_real_t recoi,
208  const cs_real_t recoj,
209  const cs_real_t pi,
210  const cs_real_t pj,
211  cs_real_t *pir,
212  cs_real_t *pjr,
213  cs_real_t *pipr,
214  cs_real_t *pjpr)
215 {
216  *pir = pi/relaxp - (1.-relaxp)/relaxp * pia;
217  *pjr = pj/relaxp - (1.-relaxp)/relaxp * pja;
218 
219  *pipr = *pir + recoi;
220  *pjpr = *pjr + recoj;
221 }
222 
223 /*----------------------------------------------------------------------------*/
237 /*----------------------------------------------------------------------------*/
238 
239 inline static void
241  const cs_real_t pj,
242  const cs_real_t pip,
243  const cs_real_t pjp,
244  cs_real_t *pir,
245  cs_real_t *pjr,
246  cs_real_t *pipr,
247  cs_real_t *pjpr)
248 {
249  *pir = pi;
250  *pjr = pj;
251 
252  *pipr = pip;
253  *pjpr = pjp;
254 }
255 
256 /*----------------------------------------------------------------------------*/
269 /*----------------------------------------------------------------------------*/
270 
271 inline static void
273  const cs_real_t pj,
274  const cs_real_t pir,
275  const cs_real_t pjr,
276  cs_real_t *pifri,
277  cs_real_t *pifrj,
278  cs_real_t *pjfri,
279  cs_real_t *pjfrj)
280 {
281  *pifri = pir;
282  *pifrj = pi;
283  *pjfri = pj;
284  *pjfrj = pjr;
285 }
286 
287 /*----------------------------------------------------------------------------*/
301 /*----------------------------------------------------------------------------*/
302 
303 inline static void
304 cs_centered_f_val(const double pnd,
305  const cs_real_t pip,
306  const cs_real_t pjp,
307  const cs_real_t pipr,
308  const cs_real_t pjpr,
309  cs_real_t *pifri,
310  cs_real_t *pifrj,
311  cs_real_t *pjfri,
312  cs_real_t *pjfrj)
313 {
314  *pifri = pnd*pipr + (1.-pnd)*pjp;
315  *pjfri = *pifri;
316  *pifrj = pnd*pip + (1.-pnd)*pjpr;
317  *pjfrj = *pifrj;
318 }
319 
320 /*----------------------------------------------------------------------------*/
338 /*----------------------------------------------------------------------------*/
339 
340 inline static void
341 cs_solu_f_val(const cs_real_3_t cell_ceni,
342  const cs_real_3_t cell_cenj,
343  const cs_real_3_t i_face_cog,
344  const cs_real_3_t gradi,
345  const cs_real_3_t gradj,
346  const cs_real_t pi,
347  const cs_real_t pj,
348  const cs_real_t pir,
349  const cs_real_t pjr,
350  cs_real_t *pifri,
351  cs_real_t *pifrj,
352  cs_real_t *pjfri,
353  cs_real_t *pjfrj)
354 {
355  cs_real_t difx, dify, difz, djfx, djfy, djfz;
356 
357  difx = i_face_cog[0] - cell_ceni[0];
358  dify = i_face_cog[1] - cell_ceni[1];
359  difz = i_face_cog[2] - cell_ceni[2];
360  djfx = i_face_cog[0] - cell_cenj[0];
361  djfy = i_face_cog[1] - cell_cenj[1];
362  djfz = i_face_cog[2] - cell_cenj[2];
363 
364  /* leave reconstruction of PIF and PJF even if IRCFLP=0
365  otherwise, it is the same as using upwind */
366  *pifri = pir + difx*gradi[0]+dify*gradi[1]+difz*gradi[2];
367  *pifrj = pi + difx*gradi[0]+dify*gradi[1]+difz*gradi[2];
368  *pjfrj = pjr + djfx*gradj[0]+djfy*gradj[1]+djfz*gradj[2];
369  *pjfri = pj + djfx*gradj[0]+djfy*gradj[1]+djfz*gradj[2];
370 }
371 
372 /*----------------------------------------------------------------------------*/
388 /*----------------------------------------------------------------------------*/
389 
390 inline static void
391 cs_blend_f_val(const double blencp,
392  const cs_real_t pi,
393  const cs_real_t pj,
394  const cs_real_t pir,
395  const cs_real_t pjr,
396  cs_real_t *pifri,
397  cs_real_t *pifrj,
398  cs_real_t *pjfri,
399  cs_real_t *pjfrj)
400 {
401  *pifri = blencp*(*pifri)+(1.-blencp)*pir;
402  *pifrj = blencp*(*pifrj)+(1.-blencp)*pi;
403  *pjfri = blencp*(*pjfri)+(1.-blencp)*pj;
404  *pjfrj = blencp*(*pjfrj)+(1.-blencp)*pjr;
405 }
406 
407 /*----------------------------------------------------------------------------*/
422 /*----------------------------------------------------------------------------*/
423 
424 inline static void
425 cs_i_conv_flux(const int iconvp,
426  const cs_real_t pi,
427  const cs_real_t pj,
428  const cs_real_t pifri,
429  const cs_real_t pifrj,
430  const cs_real_t pjfri,
431  const cs_real_t pjfrj,
432  const cs_real_t i_massflux,
433  cs_real_2_t fluxij)
434 {
435  cs_real_t flui, fluj;
436 
437  flui = 0.5*(i_massflux + fabs(i_massflux));
438  fluj = 0.5*(i_massflux - fabs(i_massflux));
439 
440  fluxij[0] += iconvp*(flui*pifri + fluj*pjfri - i_massflux*pi);
441  fluxij[1] += iconvp*(flui*pifrj + fluj*pjfrj - i_massflux*pj);
442 }
443 
444 /*----------------------------------------------------------------------------*/
460 /*----------------------------------------------------------------------------*/
461 
462 inline static void
463 cs_i_conv_flux_cons(const int iconvp,
464  const cs_real_t pifri,
465  const cs_real_t pifrj,
466  const cs_real_t pjfri,
467  const cs_real_t pjfrj,
468  const cs_real_t i_massflux,
469  const cs_real_t xcppi,
470  const cs_real_t xcppj,
471  cs_real_2_t fluxij)
472 {
473  cs_real_t flui, fluj;
474 
475  flui = 0.5*(i_massflux +fabs(i_massflux));
476  fluj = 0.5*(i_massflux -fabs(i_massflux));
477 
478  fluxij[0] += iconvp*xcppi*(flui*pifri + fluj*pjfri);
479  fluxij[1] += iconvp*xcppj*(flui*pifrj + fluj*pjfrj);
480 }
481 
482 /*----------------------------------------------------------------------------*/
494 /*----------------------------------------------------------------------------*/
495 
496 inline static void
497 cs_i_diff_flux(const int idiffp,
498  const cs_real_t pip,
499  const cs_real_t pjp,
500  const cs_real_t pipr,
501  const cs_real_t pjpr,
502  const cs_real_t i_visc,
503  cs_real_2_t fluxij)
504 {
505  fluxij[0] += idiffp*i_visc*(pipr -pjp);
506  fluxij[1] += idiffp*i_visc*(pip -pjpr);
507 }
508 
509 /*----------------------------------------------------------------------------*/
536 /*----------------------------------------------------------------------------*/
537 
538 inline static void
539 cs_i_cd_steady_upwind(const int ircflp,
540  const cs_real_t relaxp,
541  const cs_real_t weight,
542  const cs_real_3_t cell_ceni,
543  const cs_real_3_t cell_cenj,
544  const cs_real_3_t i_face_cog,
545  const cs_real_3_t dijpf,
546  const cs_real_3_t gradi,
547  const cs_real_3_t gradj,
548  const cs_real_t pi,
549  const cs_real_t pj,
550  const cs_real_t pia,
551  const cs_real_t pja,
552  cs_real_t *pifri,
553  cs_real_t *pifrj,
554  cs_real_t *pjfri,
555  cs_real_t *pjfrj,
556  cs_real_t *pip,
557  cs_real_t *pjp,
558  cs_real_t *pipr,
559  cs_real_t *pjpr)
560 {
561  cs_real_t pir, pjr;
562  cs_real_t recoi, recoj;
563 
565  weight,
566  cell_ceni,
567  cell_cenj,
568  i_face_cog,
569  dijpf,
570  gradi,
571  gradj,
572  pi,
573  pj,
574  &recoi,
575  &recoj,
576  pip,
577  pjp);
578 
579  cs_i_relax_c_val(relaxp,
580  pia,
581  pja,
582  recoi,
583  recoj,
584  pi,
585  pj,
586  &pir,
587  &pjr,
588  pipr,
589  pjpr);
590 
591  cs_upwind_f_val(pi,
592  pj,
593  pir,
594  pjr,
595  pifri,
596  pifrj,
597  pjfri,
598  pjfrj);
599 }
600 
601 /*----------------------------------------------------------------------------*/
625 /*----------------------------------------------------------------------------*/
626 
627 inline static void
628 cs_i_cd_unsteady_upwind(const int ircflp,
629  const cs_real_t weight,
630  const cs_real_3_t cell_ceni,
631  const cs_real_3_t cell_cenj,
632  const cs_real_3_t i_face_cog,
633  const cs_real_3_t dijpf,
634  const cs_real_3_t gradi,
635  const cs_real_3_t gradj,
636  const cs_real_t pi,
637  const cs_real_t pj,
638  cs_real_t *pifri,
639  cs_real_t *pifrj,
640  cs_real_t *pjfri,
641  cs_real_t *pjfrj,
642  cs_real_t *pip,
643  cs_real_t *pjp,
644  cs_real_t *pipr,
645  cs_real_t *pjpr)
646 {
647  cs_real_t pir, pjr;
648  cs_real_t recoi, recoj;
649 
651  weight,
652  cell_ceni,
653  cell_cenj,
654  i_face_cog,
655  dijpf,
656  gradi,
657  gradj,
658  pi,
659  pj,
660  &recoi,
661  &recoj,
662  pip,
663  pjp);
664 
666  pj,
667  *pip,
668  *pjp,
669  &pir,
670  &pjr,
671  pipr,
672  pjpr);
673 
674  cs_upwind_f_val(pi,
675  pj,
676  pir,
677  pjr,
678  pifri,
679  pifrj,
680  pjfri,
681  pjfrj);
682 }
683 
684 /*----------------------------------------------------------------------------*/
714 /*----------------------------------------------------------------------------*/
715 
716 inline static void
717 cs_i_cd_steady(const int ircflp,
718  const int ischcp,
719  const double relaxp,
720  const double blencp,
721  const cs_real_t weight,
722  const cs_real_3_t cell_ceni,
723  const cs_real_3_t cell_cenj,
724  const cs_real_3_t i_face_cog,
725  const cs_real_3_t dijpf,
726  const cs_real_3_t gradi,
727  const cs_real_3_t gradj,
728  const cs_real_t pi,
729  const cs_real_t pj,
730  const cs_real_t pia,
731  const cs_real_t pja,
732  cs_real_t *pifri,
733  cs_real_t *pifrj,
734  cs_real_t *pjfri,
735  cs_real_t *pjfrj,
736  cs_real_t *pip,
737  cs_real_t *pjp,
738  cs_real_t *pipr,
739  cs_real_t *pjpr)
740 {
741  cs_real_t pir, pjr;
742  cs_real_t recoi, recoj;
743 
745  weight,
746  cell_ceni,
747  cell_cenj,
748  i_face_cog,
749  dijpf,
750  gradi,
751  gradj,
752  pi,
753  pj,
754  &recoi,
755  &recoj,
756  pip,
757  pjp);
758 
759  cs_i_relax_c_val(relaxp,
760  pia,
761  pja,
762  recoi,
763  recoj,
764  pi,
765  pj,
766  &pir,
767  &pjr,
768  pipr,
769  pjpr);
770 
771  if (ischcp == 1) {
772 
773  /* Centered
774  --------*/
775 
776  cs_centered_f_val(weight,
777  *pip,
778  *pjp,
779  *pipr,
780  *pjpr,
781  pifri,
782  pifrj,
783  pjfri,
784  pjfrj);
785 
786  } else {
787 
788  /* Second order
789  ------------*/
790 
791  cs_solu_f_val(cell_ceni,
792  cell_cenj,
793  i_face_cog,
794  gradi,
795  gradj,
796  pi,
797  pj,
798  pir,
799  pjr,
800  pifri,
801  pifrj,
802  pjfri,
803  pjfrj);
804 
805  }
806 
807  /* Blending
808  --------*/
809 
810  cs_blend_f_val(blencp,
811  pi,
812  pj,
813  pir,
814  pjr,
815  pifri,
816  pifrj,
817  pjfri,
818  pjfrj);
819 }
820 
821 /*----------------------------------------------------------------------------*/
848 /*----------------------------------------------------------------------------*/
849 
850 inline static void
851 cs_i_cd_unsteady(const int ircflp,
852  const int ischcp,
853  const double blencp,
854  const cs_real_t weight,
855  const cs_real_3_t cell_ceni,
856  const cs_real_3_t cell_cenj,
857  const cs_real_3_t i_face_cog,
858  const cs_real_3_t dijpf,
859  const cs_real_3_t gradi,
860  const cs_real_3_t gradj,
861  const cs_real_t pi,
862  const cs_real_t pj,
863  cs_real_t *pifri,
864  cs_real_t *pifrj,
865  cs_real_t *pjfri,
866  cs_real_t *pjfrj,
867  cs_real_t *pip,
868  cs_real_t *pjp,
869  cs_real_t *pipr,
870  cs_real_t *pjpr)
871 {
872  cs_real_t pir, pjr;
873  cs_real_t recoi, recoj;
874 
876  weight,
877  cell_ceni,
878  cell_cenj,
879  i_face_cog,
880  dijpf,
881  gradi,
882  gradj,
883  pi,
884  pj,
885  &recoi,
886  &recoj,
887  pip,
888  pjp);
889 
891  pj,
892  *pip,
893  *pjp,
894  &pir,
895  &pjr,
896  pipr,
897  pjpr);
898 
899  if (ischcp == 1) {
900 
901  /* Centered
902  --------*/
903 
904  cs_centered_f_val(weight,
905  *pip,
906  *pjp,
907  *pipr,
908  *pjpr,
909  pifri,
910  pifrj,
911  pjfri,
912  pjfrj);
913 
914  } else {
915 
916  /* Second order
917  ------------*/
918 
919  cs_solu_f_val(cell_ceni,
920  cell_cenj,
921  i_face_cog,
922  gradi,
923  gradj,
924  pi,
925  pj,
926  pir,
927  pjr,
928  pifri,
929  pifrj,
930  pjfri,
931  pjfrj);
932 
933  }
934 
935  /* Blending
936  --------*/
937 
938  cs_blend_f_val(blencp,
939  pi,
940  pj,
941  pir,
942  pjr,
943  pifri,
944  pifrj,
945  pjfri,
946  pjfrj);
947 }
948 
949 /*----------------------------------------------------------------------------*/
986 /*----------------------------------------------------------------------------*/
987 
988 inline static void
989 cs_i_cd_steady_slope_test(bool *upwind_switch,
990  const int ircflp,
991  const int ischcp,
992  const double relaxp,
993  const double blencp,
994  const cs_real_t weight,
995  const cs_real_t i_dist,
996  const cs_real_t i_face_surf,
997  const cs_real_3_t cell_ceni,
998  const cs_real_3_t cell_cenj,
999  const cs_real_3_t i_face_normal,
1000  const cs_real_3_t i_face_cog,
1001  const cs_real_3_t dijpf,
1002  const cs_real_t i_massflux,
1003  const cs_real_3_t gradi,
1004  const cs_real_3_t gradj,
1005  const cs_real_3_t grdpai,
1006  const cs_real_3_t grdpaj,
1007  const cs_real_t pi,
1008  const cs_real_t pj,
1009  const cs_real_t pia,
1010  const cs_real_t pja,
1011  cs_real_t *pifri,
1012  cs_real_t *pifrj,
1013  cs_real_t *pjfri,
1014  cs_real_t *pjfrj,
1015  cs_real_t *pip,
1016  cs_real_t *pjp,
1017  cs_real_t *pipr,
1018  cs_real_t *pjpr)
1019 {
1020  cs_real_t pir, pjr;
1021  cs_real_t recoi, recoj;
1022  cs_real_t distf, srfan, testij, tesqck;
1023 
1024  distf = i_dist;
1025  srfan = i_face_surf;
1026 
1027  *upwind_switch = false;
1028 
1029  cs_i_compute_quantities(ircflp,
1030  weight,
1031  cell_ceni,
1032  cell_cenj,
1033  i_face_cog,
1034  dijpf,
1035  gradi,
1036  gradj,
1037  pi,
1038  pj,
1039  &recoi,
1040  &recoj,
1041  pip,
1042  pjp);
1043 
1044  cs_i_relax_c_val(relaxp,
1045  pia,
1046  pja,
1047  recoi,
1048  recoj,
1049  pi,
1050  pj,
1051  &pir,
1052  &pjr,
1053  pipr,
1054  pjpr);
1055 
1056  cs_slope_test(pi,
1057  pj,
1058  distf,
1059  srfan,
1060  i_face_normal,
1061  gradi,
1062  gradj,
1063  grdpai,
1064  grdpaj,
1065  i_massflux,
1066  &testij,
1067  &tesqck);
1068 
1069  if (tesqck<=0. || testij<=0.) {
1070 
1071  /* Upwind
1072  --------*/
1073 
1074  cs_upwind_f_val(pi,
1075  pj,
1076  pir,
1077  pjr,
1078  pifri,
1079  pifrj,
1080  pjfri,
1081  pjfrj);
1082 
1083  *upwind_switch = true;
1084 
1085  } else {
1086 
1087  if (ischcp==1) {
1088 
1089  /* Centered
1090  --------*/
1091 
1092  cs_centered_f_val(weight,
1093  *pip,
1094  *pjp,
1095  *pipr,
1096  *pjpr,
1097  pifri,
1098  pifrj,
1099  pjfri,
1100  pjfrj);
1101 
1102  } else {
1103 
1104  /* Second order
1105  ------------*/
1106 
1107  cs_solu_f_val(cell_ceni,
1108  cell_cenj,
1109  i_face_cog,
1110  gradi,
1111  gradj,
1112  pi,
1113  pj,
1114  pir,
1115  pjr,
1116  pifri,
1117  pifrj,
1118  pjfri,
1119  pjfrj);
1120 
1121  }
1122  }
1123 
1124  /* Blending
1125  --------*/
1126 
1127  cs_blend_f_val(blencp,
1128  pi,
1129  pj,
1130  pir,
1131  pjr,
1132  pifri,
1133  pifrj,
1134  pjfri,
1135  pjfrj);
1136 }
1137 
1138 /*----------------------------------------------------------------------------*/
1172 /*----------------------------------------------------------------------------*/
1173 
1174 inline static void
1175 cs_i_cd_unsteady_slope_test(bool *upwind_switch,
1176  const int ircflp,
1177  const int ischcp,
1178  const double blencp,
1179  const cs_real_t weight,
1180  const cs_real_t i_dist,
1181  const cs_real_t i_face_surf,
1182  const cs_real_3_t cell_ceni,
1183  const cs_real_3_t cell_cenj,
1184  const cs_real_3_t i_face_normal,
1185  const cs_real_3_t i_face_cog,
1186  const cs_real_3_t dijpf,
1187  const cs_real_t i_massflux,
1188  const cs_real_3_t gradi,
1189  const cs_real_3_t gradj,
1190  const cs_real_3_t grdpai,
1191  const cs_real_3_t grdpaj,
1192  const cs_real_t pi,
1193  const cs_real_t pj,
1194  cs_real_t *pifri,
1195  cs_real_t *pifrj,
1196  cs_real_t *pjfri,
1197  cs_real_t *pjfrj,
1198  cs_real_t *pip,
1199  cs_real_t *pjp,
1200  cs_real_t *pipr,
1201  cs_real_t *pjpr)
1202 {
1203  cs_real_t pir, pjr;
1204  cs_real_t recoi, recoj;
1205  cs_real_t distf, srfan, testij, tesqck;
1206 
1207  distf = i_dist;
1208  srfan = i_face_surf;
1209 
1210  *upwind_switch = false;
1211 
1212  cs_i_compute_quantities(ircflp,
1213  weight,
1214  cell_ceni,
1215  cell_cenj,
1216  i_face_cog,
1217  dijpf,
1218  gradi,
1219  gradj,
1220  pi,
1221  pj,
1222  &recoi,
1223  &recoj,
1224  pip,
1225  pjp);
1226 
1228  pj,
1229  *pip,
1230  *pjp,
1231  &pir,
1232  &pjr,
1233  pipr,
1234  pjpr);
1235 
1236  cs_slope_test(pi,
1237  pj,
1238  distf,
1239  srfan,
1240  i_face_normal,
1241  gradi,
1242  gradj,
1243  grdpai,
1244  grdpaj,
1245  i_massflux,
1246  &testij,
1247  &tesqck);
1248 
1249  if (tesqck<=0. || testij<=0.) {
1250 
1251  /* Upwind
1252  --------*/
1253 
1254  cs_upwind_f_val(pi,
1255  pj,
1256  pir,
1257  pjr,
1258  pifri,
1259  pifrj,
1260  pjfri,
1261  pjfrj);
1262 
1263  *upwind_switch = true;
1264 
1265  } else {
1266 
1267  if (ischcp==1) {
1268 
1269  /* Centered
1270  --------*/
1271 
1272  cs_centered_f_val(weight,
1273  *pip,
1274  *pjp,
1275  *pipr,
1276  *pjpr,
1277  pifri,
1278  pifrj,
1279  pjfri,
1280  pjfrj);
1281 
1282  } else {
1283 
1284  /* Second order
1285  ------------*/
1286 
1287  cs_solu_f_val(cell_ceni,
1288  cell_cenj,
1289  i_face_cog,
1290  gradi,
1291  gradj,
1292  pi,
1293  pj,
1294  pir,
1295  pjr,
1296  pifri,
1297  pifrj,
1298  pjfri,
1299  pjfrj);
1300 
1301  }
1302  }
1303 
1304  /* Blending
1305  --------*/
1306 
1307  cs_blend_f_val(blencp,
1308  pi,
1309  pj,
1310  pir,
1311  pjr,
1312  pifri,
1313  pifrj,
1314  pjfri,
1315  pjfrj);
1316 }
1317 
1318 /*----------------------------------------------------------------------------*/
1327 /*----------------------------------------------------------------------------*/
1328 
1329 inline static void
1331  const cs_real_3_t gradi,
1332  const int ircflp,
1333  cs_real_t *recoi)
1334 {
1335  *recoi = ircflp * ( gradi[0]*diipb[0]
1336  + gradi[1]*diipb[1]
1337  + gradi[2]*diipb[2]);
1338 }
1339 
1340 /*----------------------------------------------------------------------------*/
1351 /*----------------------------------------------------------------------------*/
1352 
1353 inline static void
1354 cs_b_relax_c_val(const double relaxp,
1355  const cs_real_t pi,
1356  const cs_real_t pia,
1357  const cs_real_t recoi,
1358  cs_real_t *pir,
1359  cs_real_t *pipr)
1360 {
1361  *pir = pi/relaxp - (1.-relaxp)/relaxp*pia;
1362  *pipr = *pir + recoi;
1363 }
1364 
1365 /*----------------------------------------------------------------------------*/
1374 /*----------------------------------------------------------------------------*/
1375 
1376 inline static void
1378  const cs_real_t recoi,
1379  cs_real_t *pir,
1380  cs_real_t *pipr)
1381 {
1382  *pir = pi;
1383  *pipr = pi + recoi;
1384 }
1385 
1386 /*----------------------------------------------------------------------------*/
1409 /*----------------------------------------------------------------------------*/
1410 
1411 inline static void
1412 cs_b_imposed_conv_flux(const int iconvp,
1413  const int inc,
1414  const int ifaccp,
1415  const cs_int_t bc_type,
1416  const int icvfli,
1417  const cs_real_t pi,
1418  const cs_real_t pir,
1419  const cs_real_t pipr,
1420  const cs_real_t coefap,
1421  const cs_real_t coefbp,
1422  const cs_real_t coface,
1423  const cs_real_t cofbce,
1424  const cs_real_t b_massflux,
1425  cs_real_t *flux)
1426 {
1427  cs_real_t flui, fluj, pfac;
1428 
1429  /* Computed convective flux */
1430 
1431  if (icvfli == 0) {
1432 
1433  /* Remove decentering for coupled faces */
1434  if (ifaccp==1 && bc_type==CS_COUPLED) {
1435  flui = 0.0;
1436  fluj = b_massflux;
1437  } else {
1438  flui = 0.5*(b_massflux +fabs(b_massflux));
1439  fluj = 0.5*(b_massflux -fabs(b_massflux));
1440  }
1441 
1442  pfac = inc*coefap + coefbp*pipr;
1443  *flux += iconvp*(flui*pir + fluj*pfac - b_massflux*pi);
1444 
1445  /* Imposed convective flux */
1446 
1447  } else {
1448 
1449  pfac = inc*coface + cofbce*pipr;
1450  *flux += iconvp*(-b_massflux*pi + pfac);
1451 
1452  }
1453 }
1454 
1455 /*----------------------------------------------------------------------------*/
1478 /*----------------------------------------------------------------------------*/
1479 
1480 inline static void
1482  const int inc,
1483  const int ifaccp,
1484  const cs_int_t bc_type,
1485  const int icvfli,
1486  const cs_real_t pir,
1487  const cs_real_t pipr,
1488  const cs_real_t coefap,
1489  const cs_real_t coefbp,
1490  const cs_real_t coface,
1491  const cs_real_t cofbce,
1492  const cs_real_t xcpp,
1493  const cs_real_t b_massflux,
1494  cs_real_t *flux)
1495 {
1496  cs_real_t flui, fluj, pfac;
1497 
1498  /* Computed convective flux */
1499 
1500  if (icvfli == 0) {
1501 
1502  /* Remove decentering for coupled faces */
1503  if (ifaccp==1 && bc_type==CS_COUPLED) {
1504  flui = 0.0;
1505  fluj = b_massflux;
1506  } else {
1507  flui = 0.5*(b_massflux +fabs(b_massflux));
1508  fluj = 0.5*(b_massflux -fabs(b_massflux));
1509  }
1510 
1511  pfac = inc*coefap + coefbp*pipr;
1512  *flux += iconvp*xcpp*(flui*pir + fluj*pfac);
1513 
1514  /* Imposed convective flux */
1515 
1516  } else {
1517 
1518  pfac = inc*coface + cofbce*pipr;
1519  *flux += iconvp*pfac;
1520 
1521  }
1522 }
1523 
1524 /*----------------------------------------------------------------------------*/
1543 /*----------------------------------------------------------------------------*/
1544 
1545 inline static void
1546 cs_b_upwind_flux(const int iconvp,
1547  const int inc,
1548  const int ifaccp,
1549  const int bc_type,
1550  const cs_real_t pi,
1551  const cs_real_t pir,
1552  const cs_real_t pipr,
1553  const cs_real_t coefap,
1554  const cs_real_t coefbp,
1555  const cs_real_t b_massflux,
1556  cs_real_t *flux)
1557 {
1558  cs_real_t flui, fluj, pfac;
1559 
1560  /* Remove decentering for coupled faces */
1561  if (ifaccp==1 && bc_type==CS_COUPLED) {
1562  flui = 0.0;
1563  fluj = b_massflux;
1564  } else {
1565  flui = 0.5*(b_massflux +fabs(b_massflux));
1566  fluj = 0.5*(b_massflux -fabs(b_massflux));
1567  }
1568 
1569  pfac = inc*coefap + coefbp*pipr;
1570  *flux += iconvp*(flui*pir + fluj*pfac - b_massflux*pi);
1571 }
1572 
1573 /*----------------------------------------------------------------------------*/
1595 /*----------------------------------------------------------------------------*/
1596 
1597 inline static void
1598 cs_b_upwind_flux_cons(const int iconvp,
1599  const int inc,
1600  const int ifaccp,
1601  const cs_int_t bc_type,
1602  const cs_real_t pir,
1603  const cs_real_t pipr,
1604  const cs_real_t coefap,
1605  const cs_real_t coefbp,
1606  const cs_real_t b_massflux,
1607  const cs_real_t xcpp,
1608  cs_real_t *flux)
1609 {
1610  cs_real_t flui, fluj, pfac;
1611 
1612  /* Remove decentering for coupled faces */
1613  if (ifaccp==1 && bc_type==CS_COUPLED) {
1614  flui = 0.0;
1615  fluj = b_massflux;
1616  } else {
1617  flui = 0.5*(b_massflux +fabs(b_massflux));
1618  fluj = 0.5*(b_massflux -fabs(b_massflux));
1619  }
1620 
1621  pfac = inc*coefap + coefbp*pipr;
1622  *flux += iconvp*xcpp*(flui*pir + fluj*pfac);
1623 }
1624 
1625 /*----------------------------------------------------------------------------*/
1637 /*----------------------------------------------------------------------------*/
1638 
1639 inline static void
1640 cs_b_diff_flux(const int idiffp,
1641  const int inc,
1642  const cs_real_t pipr,
1643  const cs_real_t cofafp,
1644  const cs_real_t cofbfp,
1645  const cs_real_t b_visc,
1646  cs_real_t *flux)
1647 {
1648  cs_real_t pfacd = inc*cofafp + cofbfp*pipr;
1649  *flux += idiffp*b_visc*pfacd;
1650 }
1651 
1652 /*----------------------------------------------------------------------------*/
1666 /*----------------------------------------------------------------------------*/
1667 
1668 inline static void
1669 cs_b_cd_steady(const int ircflp,
1670  const double relaxp,
1671  const cs_real_3_t diipb,
1672  const cs_real_3_t gradi,
1673  const cs_real_t pi,
1674  const cs_real_t pia,
1675  cs_real_t *pir,
1676  cs_real_t *pipr)
1677 {
1678  cs_real_t recoi;
1679 
1681  gradi,
1682  ircflp,
1683  &recoi);
1684 
1685  cs_b_relax_c_val(relaxp,
1686  pi,
1687  pia,
1688  recoi,
1689  pir,
1690  pipr);
1691 }
1692 
1693 /*----------------------------------------------------------------------------*/
1705 /*----------------------------------------------------------------------------*/
1706 
1707 inline static void
1708 cs_b_cd_unsteady(const int ircflp,
1709  const cs_real_3_t diipb,
1710  const cs_real_3_t gradi,
1711  const cs_real_t pi,
1712  cs_real_t *pir,
1713  cs_real_t *pipr)
1714 {
1715  cs_real_t recoi;
1716 
1718  gradi,
1719  ircflp,
1720  &recoi);
1721 
1723  recoi,
1724  pir,
1725  pipr);
1726 }
1727 
1728 /*----------------------------------------------------------------------------*/
1744 /*----------------------------------------------------------------------------*/
1745 
1746 inline static void
1747 cs_slope_test_gradient(const int f_id,
1748  const int inc,
1749  const cs_halo_type_t halo_type,
1750  cs_real_3_t *grad,
1751  cs_real_3_t *grdpa,
1752  cs_real_t *pvar,
1753  const cs_real_t *coefap,
1754  const cs_real_t *coefbp,
1755  const cs_real_t *i_massflux)
1756 {
1757  const cs_mesh_t *m = cs_glob_mesh;
1758  const cs_halo_t *halo = m->halo;
1760 
1761  const cs_lnum_t n_cells = m->n_cells;
1762 
1763  const cs_lnum_2_t *restrict i_face_cells
1764  = (const cs_lnum_2_t *restrict)m->i_face_cells;
1765  const cs_lnum_t *restrict b_face_cells
1766  = (const cs_lnum_t *restrict)m->b_face_cells;
1767  const cs_real_t *restrict cell_vol = fvq->cell_vol;
1768  const cs_real_3_t *restrict cell_cen
1769  = (const cs_real_3_t *restrict)fvq->cell_cen;
1770  const cs_real_3_t *restrict i_face_normal
1771  = (const cs_real_3_t *restrict)fvq->i_face_normal;
1772  const cs_real_3_t *restrict b_face_normal
1773  = (const cs_real_3_t *restrict)fvq->b_face_normal;
1774  const cs_real_3_t *restrict i_face_cog
1775  = (const cs_real_3_t *restrict)fvq->i_face_cog;
1776  const cs_real_3_t *restrict diipb
1777  = (const cs_real_3_t *restrict)fvq->diipb;
1778 
1779  const int n_i_groups = m->i_face_numbering->n_groups;
1780  const int n_i_threads = m->i_face_numbering->n_threads;
1781  const int n_b_groups = m->b_face_numbering->n_groups;
1782  const int n_b_threads = m->b_face_numbering->n_threads;
1783  const cs_lnum_t *restrict i_group_index = m->i_face_numbering->group_index;
1784  const cs_lnum_t *restrict b_group_index = m->b_face_numbering->group_index;
1785 
1786  cs_lnum_t cell_id, face_id, ii, jj;
1787  int g_id, t_id;
1788 
1789  cs_real_t difx,dify,difz,djfx,djfy,djfz;
1790  cs_real_t diipbx, diipby, diipbz;
1791  cs_real_t pfac, pfac1, pfac2, pfac3, unsvol;
1792  cs_real_t pif,pjf;
1793 
1794  for (g_id = 0; g_id < n_i_groups; g_id++) {
1795 # pragma omp parallel for private(face_id, ii, jj, difx, dify, difz, \
1796  djfx, djfy, djfz, pif, pjf, pfac, \
1797  pfac1, pfac2, pfac3)
1798  for (t_id = 0; t_id < n_i_threads; t_id++) {
1799  for (face_id = i_group_index[(t_id*n_i_groups + g_id)*2];
1800  face_id < i_group_index[(t_id*n_i_groups + g_id)*2 + 1];
1801  face_id++) {
1802 
1803  ii = i_face_cells[face_id][0];
1804  jj = i_face_cells[face_id][1];
1805 
1806  difx = i_face_cog[face_id][0] - cell_cen[ii][0];
1807  dify = i_face_cog[face_id][1] - cell_cen[ii][1];
1808  difz = i_face_cog[face_id][2] - cell_cen[ii][2];
1809  djfx = i_face_cog[face_id][0] - cell_cen[jj][0];
1810  djfy = i_face_cog[face_id][1] - cell_cen[jj][1];
1811  djfz = i_face_cog[face_id][2] - cell_cen[jj][2];
1812 
1813  pif = pvar[ii]
1814  + difx*grad[ii][0]+dify*grad[ii][1]+difz*grad[ii][2];
1815  pjf = pvar[jj]
1816  + djfx*grad[jj][0]+djfy*grad[jj][1]+djfz*grad[jj][2];
1817 
1818  pfac = pjf;
1819  if (i_massflux[face_id] > 0.) pfac = pif;
1820 
1821  pfac1 = pfac*i_face_normal[face_id][0];
1822  pfac2 = pfac*i_face_normal[face_id][1];
1823  pfac3 = pfac*i_face_normal[face_id][2];
1824 
1825  grdpa[ii][0] = grdpa[ii][0] + pfac1;
1826  grdpa[ii][1] = grdpa[ii][1] + pfac2;
1827  grdpa[ii][2] = grdpa[ii][2] + pfac3;
1828 
1829  grdpa[jj][0] = grdpa[jj][0] - pfac1;
1830  grdpa[jj][1] = grdpa[jj][1] - pfac2;
1831  grdpa[jj][2] = grdpa[jj][2] - pfac3;
1832 
1833  }
1834  }
1835  }
1836 
1837  for (g_id = 0; g_id < n_b_groups; g_id++) {
1838 # pragma omp parallel for private(face_id, ii, diipbx, diipby, diipbz, pfac) \
1839  if(m->n_b_faces > CS_THR_MIN)
1840  for (t_id = 0; t_id < n_b_threads; t_id++) {
1841  for (face_id = b_group_index[(t_id*n_b_groups + g_id)*2];
1842  face_id < b_group_index[(t_id*n_b_groups + g_id)*2 + 1];
1843  face_id++) {
1844 
1845  ii = b_face_cells[face_id];
1846 
1847  diipbx = diipb[face_id][0];
1848  diipby = diipb[face_id][1];
1849  diipbz = diipb[face_id][2];
1850  pfac = inc*coefap[face_id]
1851  + coefbp[face_id] * (pvar[ii] + diipbx*grad[ii][0]
1852  + diipby*grad[ii][1]
1853  + diipbz*grad[ii][2]);
1854  grdpa[ii][0] = grdpa[ii][0] + pfac*b_face_normal[face_id][0];
1855  grdpa[ii][1] = grdpa[ii][1] + pfac*b_face_normal[face_id][1];
1856  grdpa[ii][2] = grdpa[ii][2] + pfac*b_face_normal[face_id][2];
1857 
1858  }
1859  }
1860  }
1861 
1862 # pragma omp parallel for private(unsvol)
1863  for (cell_id = 0; cell_id < n_cells; cell_id++) {
1864 
1865  unsvol = 1./cell_vol[cell_id];
1866 
1867  grdpa[cell_id][0] = grdpa[cell_id][0]*unsvol;
1868  grdpa[cell_id][1] = grdpa[cell_id][1]*unsvol;
1869  grdpa[cell_id][2] = grdpa[cell_id][2]*unsvol;
1870 
1871  }
1872 
1873  /* Synchronization for parallelism or periodicity */
1874 
1875  if (halo != NULL) {
1876  cs_halo_sync_var_strided(halo, halo_type, (cs_real_t *)grdpa, 3);
1877  if (cs_glob_mesh->n_init_perio > 0)
1878  cs_halo_perio_sync_var_vect(halo, halo_type, (cs_real_t *)grdpa, 3);
1879 
1880  /* Gradient periodicity of rotation for Reynolds stress components */
1881  if (cs_glob_mesh->have_rotation_perio > 0 && f_id != -1)
1882  cs_gradient_perio_process_rij(&f_id, grdpa);
1883  }
1884 
1885 }
1886 
1887 /*============================================================================
1888  * Public function prototypes for Fortran API
1889  *============================================================================*/
1890 
1891 /*----------------------------------------------------------------------------
1892  * Wrapper to cs_convection_diffusion_scalar
1893  *----------------------------------------------------------------------------*/
1894 
1895 void CS_PROCF (bilsc2, BILSC2)
1896 (
1897  const cs_int_t *const idtvar,
1898  const cs_int_t *const f_id,
1899  const cs_var_cal_opt_t *const var_cal_opt,
1900  const cs_int_t *const icvflb,
1901  const cs_int_t *const inc,
1902  const cs_int_t *const iccocg,
1903  const cs_int_t *const ifaccp,
1904  cs_real_t pvar[],
1905  const cs_real_t pvara[],
1906  const cs_int_t bc_type[],
1907  const cs_int_t icvfli[],
1908  const cs_real_t coefap[],
1909  const cs_real_t coefbp[],
1910  const cs_real_t cofafp[],
1911  const cs_real_t cofbfp[],
1912  const cs_real_t i_massflux[],
1913  const cs_real_t b_massflux[],
1914  const cs_real_t i_visc[],
1915  const cs_real_t b_visc[],
1916  cs_real_t rhs[]
1917 );
1918 
1919 /*----------------------------------------------------------------------------
1920  * Wrapper to cs_convection_diffusion_vector
1921  *----------------------------------------------------------------------------*/
1922 
1923 void CS_PROCF (bilsc4, BILSC4)
1924 (
1925  const cs_int_t *const idtvar,
1926  const cs_int_t *const f_id,
1927  const cs_var_cal_opt_t *const var_cal_opt,
1928  const cs_int_t *const icvflb,
1929  const cs_int_t *const inc,
1930  const cs_int_t *const ifaccp,
1931  const cs_int_t *const ivisep,
1932  cs_real_3_t pvar[],
1933  const cs_real_3_t pvara[],
1934  const cs_int_t bc_type[],
1935  const cs_int_t icvfli[],
1936  const cs_real_3_t coefav[],
1937  const cs_real_33_t coefbv[],
1938  const cs_real_3_t cofafv[],
1939  const cs_real_33_t cofbfv[],
1940  const cs_real_t i_massflux[],
1941  const cs_real_t b_massflux[],
1942  const cs_real_t i_visc[],
1943  const cs_real_t b_visc[],
1944  const cs_real_t secvif[],
1945  cs_real_3_t rhs[]
1946 );
1947 
1948 /*----------------------------------------------------------------------------
1949  * Wrapper to cs_convection_diffusion_thermal
1950  *----------------------------------------------------------------------------*/
1951 
1952 void CS_PROCF (bilsct, BILSCT)
1953 (
1954  const cs_int_t *const idtvar,
1955  const cs_int_t *const f_id,
1956  const cs_var_cal_opt_t *const var_cal_opt,
1957  const cs_int_t *const inc,
1958  const cs_int_t *const iccocg,
1959  const cs_int_t *const ifaccp,
1960  cs_real_t pvar[],
1961  const cs_real_t pvara[],
1962  const cs_int_t bc_type[],
1963  const cs_real_t coefap[],
1964  const cs_real_t coefbp[],
1965  const cs_real_t cofafp[],
1966  const cs_real_t cofbfp[],
1967  const cs_real_t i_massflux[],
1968  const cs_real_t b_massflux[],
1969  const cs_real_t i_visc[],
1970  const cs_real_t b_visc[],
1971  const cs_real_t xcpp[],
1972  cs_real_t rhs[]
1973 );
1974 
1975 /*----------------------------------------------------------------------------
1976  * Wrapper to cs_anisotropic_diffusion_scalar
1977  *----------------------------------------------------------------------------*/
1978 
1979 void CS_PROCF (diften, DIFTEN)
1980 (
1981  const cs_int_t *const idtvar,
1982  const cs_int_t *const f_id,
1983  const cs_var_cal_opt_t *const var_cal_opt,
1984  const cs_int_t *const inc,
1985  const cs_int_t *const iccocg,
1986  cs_real_t pvar[],
1987  const cs_real_t pvara[],
1988  const cs_real_t coefap[],
1989  const cs_real_t coefbp[],
1990  const cs_real_t cofafp[],
1991  const cs_real_t cofbfp[],
1992  const cs_real_t i_visc[],
1993  const cs_real_t b_visc[],
1994  cs_real_6_t viscel[],
1995  const cs_real_2_t weighf[],
1996  const cs_real_t weighb[],
1997  cs_real_t rhs[]
1998 );
1999 
2000 /*----------------------------------------------------------------------------
2001  * Wrapper to cs_anisotropic_diffusion_vector
2002  *----------------------------------------------------------------------------*/
2003 
2004 void CS_PROCF (diftnv, DIFTNV)
2005 (
2006  const cs_int_t *const idtvar,
2007  const cs_int_t *const f_id,
2008  const cs_var_cal_opt_t *const var_cal_opt,
2009  const cs_int_t *const inc,
2010  const cs_int_t *const ifaccp,
2011  const cs_int_t *const ivisep,
2012  cs_real_3_t pvar[],
2013  const cs_real_3_t pvara[],
2014  const cs_int_t bc_type[],
2015  const cs_real_3_t coefav[],
2016  const cs_real_33_t coefbv[],
2017  const cs_real_3_t cofafv[],
2018  const cs_real_33_t cofbfv[],
2019  const cs_real_33_t i_visc[],
2020  const cs_real_t b_visc[],
2021  const cs_real_t secvif[],
2022  cs_real_3_t rhs[]
2023 );
2024 
2025 /*----------------------------------------------------------------------------
2026  * Wrapper to cs_face_diffusion_potential
2027  *----------------------------------------------------------------------------*/
2028 
2029 void CS_PROCF (itrmas, ITRMAS)
2030 (
2031  const cs_int_t *const f_id,
2032  const cs_int_t *const init,
2033  const cs_int_t *const inc,
2034  const cs_int_t *const imrgra,
2035  const cs_int_t *const iccocg,
2036  const cs_int_t *const nswrgp,
2037  const cs_int_t *const imligp,
2038  const cs_int_t *const iphydp,
2039  const cs_int_t *const iwarnp,
2040  const cs_real_t *const epsrgp,
2041  const cs_real_t *const climgp,
2042  const cs_real_t *const extrap,
2043  cs_real_3_t frcxt[],
2044  cs_real_t pvar[],
2045  const cs_real_t coefap[],
2046  const cs_real_t coefbp[],
2047  const cs_real_t cofafp[],
2048  const cs_real_t cofbfp[],
2049  const cs_real_t i_visc[],
2050  const cs_real_t b_visc[],
2051  const cs_real_t viselx[],
2052  const cs_real_t visely[],
2053  const cs_real_t viselz[],
2054  cs_real_t i_massflux[],
2055  cs_real_t b_massflux[]
2056 );
2057 
2058 /*----------------------------------------------------------------------------
2059  * Wrapper to cs_face_anisotropic_diffusion_potential
2060  *----------------------------------------------------------------------------*/
2061 
2062 void CS_PROCF (itrmav, ITRMAV)
2063 (
2064  const cs_int_t *const init,
2065  const cs_int_t *const inc,
2066  const cs_int_t *const imrgra,
2067  const cs_int_t *const iccocg,
2068  const cs_int_t *const nswrgp,
2069  const cs_int_t *const imligp,
2070  const cs_int_t *const ircflp,
2071  const cs_int_t *const iphydp,
2072  const cs_int_t *const iwarnp,
2073  const cs_real_t *const epsrgp,
2074  const cs_real_t *const climgp,
2075  const cs_real_t *const extrap,
2076  cs_real_3_t frcxt[],
2077  cs_real_t pvar[],
2078  const cs_real_t coefap[],
2079  const cs_real_t coefbp[],
2080  const cs_real_t cofafp[],
2081  const cs_real_t cofbfp[],
2082  const cs_real_t i_visc[],
2083  const cs_real_t b_visc[],
2084  cs_real_6_t viscel[],
2085  const cs_real_2_t weighf[],
2086  const cs_real_t weighb[],
2087  cs_real_t i_massflux[],
2088  cs_real_t b_massflux[]
2089 );
2090 
2091 /*----------------------------------------------------------------------------
2092  * Wrapper to cs_diffusion_potential
2093  *----------------------------------------------------------------------------*/
2094 
2095 void CS_PROCF (itrgrp, ITRGRP)
2096 (
2097  const cs_int_t *const f_id,
2098  const cs_int_t *const init,
2099  const cs_int_t *const inc,
2100  const cs_int_t *const imrgra,
2101  const cs_int_t *const iccocg,
2102  const cs_int_t *const nswrgp,
2103  const cs_int_t *const imligp,
2104  const cs_int_t *const iphydp,
2105  const cs_int_t *const iwarnp,
2106  const cs_real_t *const epsrgp,
2107  const cs_real_t *const climgp,
2108  const cs_real_t *const extrap,
2109  cs_real_3_t frcxt[],
2110  cs_real_t pvar[],
2111  const cs_real_t coefap[],
2112  const cs_real_t coefbp[],
2113  const cs_real_t cofafp[],
2114  const cs_real_t cofbfp[],
2115  const cs_real_t i_visc[],
2116  const cs_real_t b_visc[],
2117  const cs_real_t viselx[],
2118  const cs_real_t visely[],
2119  const cs_real_t viselz[],
2120  cs_real_t diverg[]
2121 );
2122 
2123 /*----------------------------------------------------------------------------
2124  * Wrapper to cs_anisotropic_diffusion_potential
2125  *----------------------------------------------------------------------------*/
2126 
2127 void CS_PROCF (itrgrv, ITRGRV)
2128 (
2129  const cs_int_t *const init,
2130  const cs_int_t *const inc,
2131  const cs_int_t *const imrgra,
2132  const cs_int_t *const iccocg,
2133  const cs_int_t *const nswrgp,
2134  const cs_int_t *const imligp,
2135  const cs_int_t *const ircflp,
2136  const cs_int_t *const iphydp,
2137  const cs_int_t *const iwarnp,
2138  const cs_real_t *const epsrgp,
2139  const cs_real_t *const climgp,
2140  const cs_real_t *const extrap,
2141  cs_real_3_t frcxt[],
2142  cs_real_t pvar[],
2143  const cs_real_t coefap[],
2144  const cs_real_t coefbp[],
2145  const cs_real_t cofafp[],
2146  const cs_real_t cofbfp[],
2147  const cs_real_t i_visc[],
2148  const cs_real_t b_visc[],
2149  cs_real_6_t viscel[],
2150  const cs_real_2_t weighf[],
2151  const cs_real_t weighb[],
2152  cs_real_t diverg[]
2153 );
2154 
2155 /*=============================================================================
2156  * Public function prototypes
2157  *============================================================================*/
2158 
2159 /*----------------------------------------------------------------------------*/
2214 /*----------------------------------------------------------------------------*/
2215 
2216 void
2218  int f_id,
2219  const cs_var_cal_opt_t var_cal_opt,
2220  int icvflb,
2221  int inc,
2222  int iccocg,
2223  int ifaccp,
2224  cs_real_t *restrict pvar,
2225  const cs_real_t *restrict pvara,
2226  const cs_int_t bc_type[],
2227  const cs_int_t icvfli[],
2228  const cs_real_t coefap[],
2229  const cs_real_t coefbp[],
2230  const cs_real_t cofafp[],
2231  const cs_real_t cofbfp[],
2232  const cs_real_t i_massflux[],
2233  const cs_real_t b_massflux[],
2234  const cs_real_t i_visc[],
2235  const cs_real_t b_visc[],
2236  cs_real_t *restrict rhs);
2237 
2238 /*----------------------------------------------------------------------------*/
2300 /*----------------------------------------------------------------------------*/
2301 
2302 void
2304  int f_id,
2305  const cs_var_cal_opt_t var_cal_opt,
2306  int icvflb,
2307  int inc,
2308  int ifaccp,
2309  int ivisep,
2310  cs_real_3_t *restrict pvar,
2311  const cs_real_3_t *restrict pvara,
2312  const cs_int_t bc_type[],
2313  const cs_int_t icvfli[],
2314  const cs_real_3_t coefav[],
2315  const cs_real_33_t coefbv[],
2316  const cs_real_3_t cofafv[],
2317  const cs_real_33_t cofbfv[],
2318  const cs_real_t i_massflux[],
2319  const cs_real_t b_massflux[],
2320  const cs_real_t i_visc[],
2321  const cs_real_t b_visc[],
2322  const cs_real_t secvif[],
2323  cs_real_3_t *restrict rhs);
2324 
2325 /*----------------------------------------------------------------------------*/
2374 /*----------------------------------------------------------------------------*/
2375 
2376 void
2378  int f_id,
2379  const cs_var_cal_opt_t var_cal_opt,
2380  int inc,
2381  int iccocg,
2382  int ifaccp,
2383  cs_real_t *restrict pvar,
2384  const cs_real_t *restrict pvara,
2385  const cs_int_t bc_type[],
2386  const cs_real_t coefap[],
2387  const cs_real_t coefbp[],
2388  const cs_real_t cofafp[],
2389  const cs_real_t cofbfp[],
2390  const cs_real_t i_massflux[],
2391  const cs_real_t b_massflux[],
2392  const cs_real_t i_visc[],
2393  const cs_real_t b_visc[],
2394  const cs_real_t xcpp[],
2395  cs_real_t *restrict rhs);
2396 
2397 /*----------------------------------------------------------------------------*/
2445 /*----------------------------------------------------------------------------*/
2446 
2447 void
2449  int f_id,
2450  const cs_var_cal_opt_t var_cal_opt,
2451  int inc,
2452  int iccocg,
2453  cs_real_t *restrict pvar,
2454  const cs_real_t *restrict pvara,
2455  const cs_real_t coefap[],
2456  const cs_real_t coefbp[],
2457  const cs_real_t cofafp[],
2458  const cs_real_t cofbfp[],
2459  const cs_real_t i_visc[],
2460  const cs_real_t b_visc[],
2461  cs_real_6_t *restrict viscel,
2462  const cs_real_2_t weighf[],
2463  const cs_real_t weighb[],
2464  cs_real_t *restrict rhs);
2465 
2466 /*-----------------------------------------------------------------------------*/
2513 /*----------------------------------------------------------------------------*/
2514 
2515 void
2517  int f_id,
2518  const cs_var_cal_opt_t var_cal_opt,
2519  int inc,
2520  int ifaccp,
2521  int ivisep,
2522  cs_real_3_t *restrict pvar,
2523  const cs_real_3_t *restrict pvara,
2524  const cs_int_t bc_type[],
2525  const cs_real_3_t coefav[],
2526  const cs_real_33_t coefbv[],
2527  const cs_real_3_t cofafv[],
2528  const cs_real_33_t cofbfv[],
2529  const cs_real_33_t i_visc[],
2530  const cs_real_t b_visc[],
2531  const cs_real_t secvif[],
2532  cs_real_3_t *restrict rhs);
2533 
2534 /*----------------------------------------------------------------------------*/
2593 /*----------------------------------------------------------------------------*/
2594 
2595 void
2596 cs_face_diffusion_potential(const int f_id,
2597  const cs_mesh_t *m,
2598  cs_mesh_quantities_t *fvq,
2599  int init,
2600  int inc,
2601  int imrgra,
2602  int iccocg,
2603  int nswrgp,
2604  int imligp,
2605  int iphydp,
2606  int iwarnp,
2607  double epsrgp,
2608  double climgp,
2609  double extrap,
2610  cs_real_3_t *restrict frcxt,
2611  cs_real_t *restrict pvar,
2612  const cs_real_t coefap[],
2613  const cs_real_t coefbp[],
2614  const cs_real_t cofafp[],
2615  const cs_real_t cofbfp[],
2616  const cs_real_t i_visc[],
2617  const cs_real_t b_visc[],
2618  const cs_real_t viselx[],
2619  const cs_real_t visely[],
2620  const cs_real_t viselz[],
2621  cs_real_t *restrict i_massflux,
2622  cs_real_t *restrict b_massflux);
2623 
2624 /*----------------------------------------------------------------------------*/
2691 /*----------------------------------------------------------------------------*/
2692 
2693 void
2695  cs_mesh_quantities_t *fvq,
2696  int init,
2697  int inc,
2698  int imrgra,
2699  int iccocg,
2700  int nswrgp,
2701  int imligp,
2702  int ircflp,
2703  int iphydp,
2704  int iwarnp,
2705  double epsrgp,
2706  double climgp,
2707  double extrap,
2708  cs_real_3_t *restrict frcxt,
2709  cs_real_t *restrict pvar,
2710  const cs_real_t coefap[],
2711  const cs_real_t coefbp[],
2712  const cs_real_t cofafp[],
2713  const cs_real_t cofbfp[],
2714  const cs_real_t i_visc[],
2715  const cs_real_t b_visc[],
2716  cs_real_6_t *restrict viscel,
2717  const cs_real_2_t weighf[],
2718  const cs_real_t weighb[],
2719  cs_real_t *restrict i_massflux,
2720  cs_real_t *restrict b_massflux);
2721 
2722 /*----------------------------------------------------------------------------*/
2780 /*----------------------------------------------------------------------------*/
2781 
2782 void
2783 cs_diffusion_potential(const int f_id,
2784  const cs_mesh_t *m,
2785  cs_mesh_quantities_t *fvq,
2786  int init,
2787  int inc,
2788  int imrgra,
2789  int iccocg,
2790  int nswrgp,
2791  int imligp,
2792  int iphydp,
2793  int iwarnp,
2794  double epsrgp,
2795  double climgp,
2796  double extrap,
2797  cs_real_3_t *restrict frcxt,
2798  cs_real_t *restrict pvar,
2799  const cs_real_t coefap[],
2800  const cs_real_t coefbp[],
2801  const cs_real_t cofafp[],
2802  const cs_real_t cofbfp[],
2803  const cs_real_t i_visc[],
2804  const cs_real_t b_visc[],
2805  const cs_real_t viselx[],
2806  const cs_real_t visely[],
2807  const cs_real_t viselz[],
2808  cs_real_t *restrict diverg);
2809 
2810 /*----------------------------------------------------------------------------*/
2878 /*----------------------------------------------------------------------------*/
2879 
2880 void
2882  cs_mesh_quantities_t *fvq,
2883  int init,
2884  int inc,
2885  int imrgra,
2886  int iccocg,
2887  int nswrgp,
2888  int imligp,
2889  int ircflp,
2890  int iphydp,
2891  int iwarnp,
2892  double epsrgp,
2893  double climgp,
2894  double extrap,
2895  cs_real_3_t *restrict frcxt,
2896  cs_real_t *restrict pvar,
2897  const cs_real_t coefap[],
2898  const cs_real_t coefbp[],
2899  const cs_real_t cofafp[],
2900  const cs_real_t cofbfp[],
2901  const cs_real_t i_visc[],
2902  const cs_real_t b_visc[],
2903  cs_real_6_t *restrict viscel,
2904  const cs_real_2_t weighf[],
2905  const cs_real_t weighb[],
2906  cs_real_t *restrict diverg);
2907 
2908 /*----------------------------------------------------------------------------*/
2909 
2911 
2912 #endif /* __CS_CONVECTION_DIFFUSION_H__ */
static void cs_b_cd_steady(const int ircflp, const double relaxp, const cs_real_3_t diipb, const cs_real_3_t gradi, const cs_real_t pi, const cs_real_t pia, cs_real_t *pir, cs_real_t *pipr)
Handle preparation of boundary face values for the flux computation in case of a steady algorithm...
Definition: cs_convection_diffusion.h:1669
void cs_gradient_perio_process_rij(const cs_int_t *f_id, cs_real_3_t grad[])
Process grad buffers in case of rotation on Reynolds stress tensor.
Definition: cs_gradient_perio.c:588
double precision, dimension(:,:), pointer diipb
Definition: mesh.f90:216
#define restrict
Definition: cs_defs.h:122
static void cs_i_diff_flux(const int idiffp, const cs_real_t pip, const cs_real_t pjp, const cs_real_t pipr, const cs_real_t pjpr, const cs_real_t i_visc, cs_real_2_t fluxij)
Add diffusive fluxes to fluxes at face ij.
Definition: cs_convection_diffusion.h:497
void itrmav(const cs_int_t *const init, const cs_int_t *const inc, const cs_int_t *const imrgra, const cs_int_t *const iccocg, const cs_int_t *const nswrgp, const cs_int_t *const imligp, const cs_int_t *const ircflp, const cs_int_t *const iphydp, const cs_int_t *const iwarnp, const cs_real_t *const epsrgp, const cs_real_t *const climgp, const cs_real_t *const extrap, cs_real_3_t frcxt[], cs_real_t pvar[], const cs_real_t coefap[], const cs_real_t coefbp[], const cs_real_t cofafp[], const cs_real_t cofbfp[], const cs_real_t i_visc[], const cs_real_t b_visc[], cs_real_6_t viscel[], const cs_real_2_t weighf[], const cs_real_t weighb[], cs_real_t i_massflux[], cs_real_t b_massflux[])
Definition: cs_convection_diffusion.c:464
static void cs_slope_test_gradient(const int f_id, const int inc, const cs_halo_type_t halo_type, cs_real_3_t *grad, cs_real_3_t *grdpa, cs_real_t *pvar, const cs_real_t *coefap, const cs_real_t *coefbp, const cs_real_t *i_massflux)
Compute the upwind gradient used in the slope tests.
Definition: cs_convection_diffusion.h:1747
void cs_halo_sync_var_strided(const cs_halo_t *halo, cs_halo_type_t sync_mode, cs_real_t var[], int stride)
Definition: cs_halo.c:1288
cs_real_t cs_real_2_t[2]
vector of 2 floating-point values
Definition: cs_defs.h:306
cs_real_t cs_real_6_t[6]
vector of 6 floating-point values
Definition: cs_defs.h:309
void cs_anisotropic_diffusion_vector(int idtvar, int f_id, const cs_var_cal_opt_t var_cal_opt, int inc, int ifaccp, int ivisep, cs_real_3_t *restrict pvar, const cs_real_3_t *restrict pvara, const cs_int_t bc_type[], const cs_real_3_t coefav[], const cs_real_33_t coefbv[], const cs_real_3_t cofafv[], const cs_real_33_t cofbfv[], const cs_real_33_t i_visc[], const cs_real_t b_visc[], const cs_real_t secvif[], cs_real_3_t *restrict rhs)
Add the explicit part of the diffusion terms with a symmetric tensorial diffusivity for a transport e...
Definition: cs_convection_diffusion.c:5072
static void cs_i_conv_flux(const int iconvp, const cs_real_t pi, const cs_real_t pj, const cs_real_t pifri, const cs_real_t pifrj, const cs_real_t pjfri, const cs_real_t pjfrj, const cs_real_t i_massflux, cs_real_2_t fluxij)
Add convective fluxes (substracting the mass accumulation from them) to fluxes at face ij...
Definition: cs_convection_diffusion.h:425
void cs_anisotropic_diffusion_scalar(int idtvar, int f_id, const cs_var_cal_opt_t var_cal_opt, int inc, int iccocg, cs_real_t *restrict pvar, const cs_real_t *restrict pvara, const cs_real_t coefap[], const cs_real_t coefbp[], const cs_real_t cofafp[], const cs_real_t cofbfp[], const cs_real_t i_visc[], const cs_real_t b_visc[], cs_real_6_t *restrict viscel, const cs_real_2_t weighf[], const cs_real_t weighb[], cs_real_t *restrict rhs)
Add the explicit part of the diffusion terms with a symmetric tensor diffusivity for a transport equa...
Definition: cs_convection_diffusion.c:4501
integer, dimension(:), allocatable icvfli
Definition: cfpoin.f90:48
static void cs_b_upwind_flux(const int iconvp, const int inc, const int ifaccp, const int bc_type, const cs_real_t pi, const cs_real_t pir, const cs_real_t pipr, const cs_real_t coefap, const cs_real_t coefbp, const cs_real_t b_massflux, cs_real_t *flux)
Add convective flux (substracting the mass accumulation from it) to flux at boundary face...
Definition: cs_convection_diffusion.h:1546
static void cs_b_cd_unsteady(const int ircflp, const cs_real_3_t diipb, const cs_real_3_t gradi, const cs_real_t pi, cs_real_t *pir, cs_real_t *pipr)
Handle preparation of boundary face values for the flux computation in case of an unsteady algorithm...
Definition: cs_convection_diffusion.h:1708
double precision pi
value with 16 digits
Definition: cstnum.f90:48
#define BEGIN_C_DECLS
Definition: cs_defs.h:419
int cs_int_t
Fortran-compatible integer.
Definition: cs_defs.h:295
static void cs_b_no_relax_c_val(const cs_real_t pi, const cs_real_t recoi, cs_real_t *pir, cs_real_t *pipr)
Copy values at bounadry cell i for consistency with relaxation case.
Definition: cs_convection_diffusion.h:1377
cs_mesh_t * cs_glob_mesh
static void cs_i_relax_c_val(const double relaxp, const cs_real_t pia, const cs_real_t pja, const cs_real_t recoi, const cs_real_t recoj, const cs_real_t pi, const cs_real_t pj, cs_real_t *pir, cs_real_t *pjr, cs_real_t *pipr, cs_real_t *pjpr)
Compute relaxed values at cell i and j.
Definition: cs_convection_diffusion.h:204
static void cs_b_upwind_flux_cons(const int iconvp, const int inc, const int ifaccp, const cs_int_t bc_type, const cs_real_t pir, const cs_real_t pipr, const cs_real_t coefap, const cs_real_t coefbp, const cs_real_t b_massflux, const cs_real_t xcpp, cs_real_t *flux)
Add convective flux (conservative formulation) to flux at boundary face. The convective flux is a pur...
Definition: cs_convection_diffusion.h:1598
void diftnv(const cs_int_t *const idtvar, const cs_int_t *const f_id, const cs_var_cal_opt_t *const var_cal_opt, const cs_int_t *const inc, const cs_int_t *const ifaccp, const cs_int_t *const ivisep, cs_real_3_t pvar[], const cs_real_3_t pvara[], const cs_int_t bc_type[], const cs_real_3_t coefav[], const cs_real_33_t coefbv[], const cs_real_3_t cofafv[], const cs_real_33_t cofbfv[], const cs_real_33_t i_visc[], const cs_real_t b_visc[], const cs_real_t secvif[], cs_real_3_t rhs[])
Definition: cs_convection_diffusion.c:355
Definition: cs_halo.h:70
integer(c_int), pointer, save idtvar
option for a variable time step
Definition: optcal.f90:437
void cs_anisotropic_diffusion_potential(const cs_mesh_t *m, cs_mesh_quantities_t *fvq, int init, int inc, int imrgra, int iccocg, int nswrgp, int imligp, int ircflp, int iphydp, int iwarnp, double epsrgp, double climgp, double extrap, cs_real_3_t *restrict frcxt, cs_real_t *restrict pvar, const cs_real_t coefap[], const cs_real_t coefbp[], const cs_real_t cofafp[], const cs_real_t cofbfp[], const cs_real_t i_visc[], const cs_real_t b_visc[], cs_real_6_t *restrict viscel, const cs_real_2_t weighf[], const cs_real_t weighb[], cs_real_t *restrict diverg)
Add the explicit part of the divergence of the mass flux due to the pressure gradient (routine analog...
Definition: cs_convection_diffusion.c:6763
void cs_convection_diffusion_vector(int idtvar, int f_id, const cs_var_cal_opt_t var_cal_opt, int icvflb, int inc, int ifaccp, int ivisep, cs_real_3_t *restrict pvar, const cs_real_3_t *restrict pvara, const cs_int_t bc_type[], const cs_int_t icvfli[], const cs_real_3_t coefav[], const cs_real_33_t coefbv[], const cs_real_3_t cofafv[], const cs_real_33_t cofbfv[], const cs_real_t i_massflux[], const cs_real_t b_massflux[], const cs_real_t i_visc[], const cs_real_t b_visc[], const cs_real_t secvif[], cs_real_3_t *restrict rhs)
Add the explicit part of the convection/diffusion terms of a transport equation of a vector field ...
Definition: cs_convection_diffusion.c:1709
void bilsc2(const cs_int_t *const idtvar, const cs_int_t *const f_id, const cs_var_cal_opt_t *const var_cal_opt, const cs_int_t *const icvflb, const cs_int_t *const inc, const cs_int_t *const iccocg, const cs_int_t *const ifaccp, cs_real_t pvar[], const cs_real_t pvara[], const cs_int_t bc_type[], const cs_int_t icvfli[], const cs_real_t coefap[], const cs_real_t coefbp[], const cs_real_t cofafp[], const cs_real_t cofbfp[], const cs_real_t i_massflux[], const cs_real_t b_massflux[], const cs_real_t i_visc[], const cs_real_t b_visc[], cs_real_t rhs[])
Definition: cs_convection_diffusion.c:161
Definition: cs_mesh.h:62
static void cs_blend_f_val(const double blencp, const cs_real_t pi, const cs_real_t pj, const cs_real_t pir, const cs_real_t pjr, cs_real_t *pifri, cs_real_t *pifrj, cs_real_t *pjfri, cs_real_t *pjfrj)
Blend face values for a centered or SOLU scheme with face values for an upwind scheme.
Definition: cs_convection_diffusion.h:391
static void cs_i_cd_unsteady_slope_test(bool *upwind_switch, const int ircflp, const int ischcp, const double blencp, const cs_real_t weight, const cs_real_t i_dist, const cs_real_t i_face_surf, const cs_real_3_t cell_ceni, const cs_real_3_t cell_cenj, const cs_real_3_t i_face_normal, const cs_real_3_t i_face_cog, const cs_real_3_t dijpf, const cs_real_t i_massflux, const cs_real_3_t gradi, const cs_real_3_t gradj, const cs_real_3_t grdpai, const cs_real_3_t grdpaj, const cs_real_t pi, const cs_real_t pj, cs_real_t *pifri, cs_real_t *pifrj, cs_real_t *pjfri, cs_real_t *pjfrj, cs_real_t *pip, cs_real_t *pjp, cs_real_t *pipr, cs_real_t *pjpr)
Handle preparation of internal face values for the fluxes computation in case of a unsteady algorithm...
Definition: cs_convection_diffusion.h:1175
cs_lnum_t n_cells
Definition: cs_mesh.h:72
int n_init_perio
Definition: cs_mesh.h:111
cs_lnum_t * group_index
Definition: cs_numbering.h:93
static void cs_b_relax_c_val(const double relaxp, const cs_real_t pi, const cs_real_t pia, const cs_real_t recoi, cs_real_t *pir, cs_real_t *pipr)
Compute relaxed values at boundary cell i.
Definition: cs_convection_diffusion.h:1354
cs_real_t * cell_cen
Definition: cs_mesh_quantities.h:53
static void cs_b_imposed_conv_flux_cons(const int iconvp, const int inc, const int ifaccp, const cs_int_t bc_type, const int icvfli, const cs_real_t pir, const cs_real_t pipr, const cs_real_t coefap, const cs_real_t coefbp, const cs_real_t coface, const cs_real_t cofbce, const cs_real_t xcpp, const cs_real_t b_massflux, cs_real_t *flux)
Add convective flux (conservative formulation) to flux at boundary face. The convective flux can be e...
Definition: cs_convection_diffusion.h:1481
void diften(const cs_int_t *const idtvar, const cs_int_t *const f_id, const cs_var_cal_opt_t *const var_cal_opt, const cs_int_t *const inc, const cs_int_t *const iccocg, cs_real_t pvar[], const cs_real_t pvara[], const cs_real_t coefap[], const cs_real_t coefbp[], const cs_real_t cofafp[], const cs_real_t cofbfp[], const cs_real_t i_visc[], const cs_real_t b_visc[], cs_real_6_t viscel[], const cs_real_2_t weighf[], const cs_real_t weighb[], cs_real_t rhs[])
Definition: cs_convection_diffusion.c:311
static void cs_i_cd_steady_slope_test(bool *upwind_switch, const int ircflp, const int ischcp, const double relaxp, const double blencp, const cs_real_t weight, const cs_real_t i_dist, const cs_real_t i_face_surf, const cs_real_3_t cell_ceni, const cs_real_3_t cell_cenj, const cs_real_3_t i_face_normal, const cs_real_3_t i_face_cog, const cs_real_3_t dijpf, const cs_real_t i_massflux, const cs_real_3_t gradi, const cs_real_3_t gradj, const cs_real_3_t grdpai, const cs_real_3_t grdpaj, const cs_real_t pi, const cs_real_t pj, const cs_real_t pia, const cs_real_t pja, cs_real_t *pifri, cs_real_t *pifrj, cs_real_t *pjfri, cs_real_t *pjfrj, cs_real_t *pip, cs_real_t *pjp, cs_real_t *pipr, cs_real_t *pjpr)
Handle preparation of internal face values for the fluxes computation in case of a steady algorithm a...
Definition: cs_convection_diffusion.h:989
cs_mesh_quantities_t * cs_glob_mesh_quantities
Definition: cs_parameters.h:124
cs_real_t * i_face_normal
Definition: cs_mesh_quantities.h:57
Definition: cs_mesh_quantities.h:51
cs_halo_type_t
Definition: cs_halo.h:49
static void cs_upwind_f_val(const cs_real_t pi, const cs_real_t pj, const cs_real_t pir, const cs_real_t pjr, cs_real_t *pifri, cs_real_t *pifrj, cs_real_t *pjfri, cs_real_t *pjfrj)
Prepare value at face ij by using an upwind scheme.
Definition: cs_convection_diffusion.h:272
void itrgrv(const cs_int_t *const init, const cs_int_t *const inc, const cs_int_t *const imrgra, const cs_int_t *const iccocg, const cs_int_t *const nswrgp, const cs_int_t *const imligp, const cs_int_t *const ircflp, const cs_int_t *const iphydp, const cs_int_t *const iwarnp, const cs_real_t *const epsrgp, const cs_real_t *const climgp, const cs_real_t *const extrap, cs_real_3_t frcxt[], cs_real_t pvar[], const cs_real_t coefap[], const cs_real_t coefbp[], const cs_real_t cofafp[], const cs_real_t cofbfp[], const cs_real_t i_visc[], const cs_real_t b_visc[], cs_real_6_t viscel[], const cs_real_2_t weighf[], const cs_real_t weighb[], cs_real_t diverg[])
Definition: cs_convection_diffusion.c:592
static void cs_slope_test(const cs_real_t pi, const cs_real_t pj, const cs_real_t distf, const cs_real_t srfan, const cs_real_3_t i_face_normal, const cs_real_3_t gradi, const cs_real_3_t gradj, const cs_real_3_t grdpai, const cs_real_3_t grdpaj, const cs_real_t i_massflux, double *testij, double *tesqck)
Compute slope test criteria at internal face between cell i and j.
Definition: cs_convection_diffusion.h:79
int cs_lnum_2_t[2]
vector of 2 local mesh-entity ids
Definition: cs_defs.h:301
static void cs_i_cd_unsteady_upwind(const int ircflp, const cs_real_t weight, const cs_real_3_t cell_ceni, const cs_real_3_t cell_cenj, const cs_real_3_t i_face_cog, const cs_real_3_t dijpf, const cs_real_3_t gradi, const cs_real_3_t gradj, const cs_real_t pi, const cs_real_t pj, cs_real_t *pifri, cs_real_t *pifrj, cs_real_t *pjfri, cs_real_t *pjfrj, cs_real_t *pip, cs_real_t *pjp, cs_real_t *pipr, cs_real_t *pjpr)
Handle preparation of internal face values for the fluxes computation in case of an unsteady algorith...
Definition: cs_convection_diffusion.h:628
void cs_face_diffusion_potential(const int f_id, const cs_mesh_t *m, cs_mesh_quantities_t *fvq, int init, int inc, int imrgra, int iccocg, int nswrgp, int imligp, int iphydp, int iwarnp, double epsrgp, double climgp, double extrap, cs_real_3_t *restrict frcxt, cs_real_t *restrict pvar, const cs_real_t coefap[], const cs_real_t coefbp[], const cs_real_t cofafp[], const cs_real_t cofbfp[], const cs_real_t i_visc[], const cs_real_t b_visc[], const cs_real_t viselx[], const cs_real_t visely[], const cs_real_t viselz[], cs_real_t *restrict i_massflux, cs_real_t *restrict b_massflux)
Update the face mass flux with the face pressure (or pressure increment, or pressure double increment...
Definition: cs_convection_diffusion.c:5617
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:307
void cs_diffusion_potential(const int f_id, const cs_mesh_t *m, cs_mesh_quantities_t *fvq, int init, int inc, int imrgra, int iccocg, int nswrgp, int imligp, int iphydp, int iwarnp, double epsrgp, double climgp, double extrap, cs_real_3_t *restrict frcxt, cs_real_t *restrict pvar, const cs_real_t coefap[], const cs_real_t coefbp[], const cs_real_t cofafp[], const cs_real_t cofbfp[], const cs_real_t i_visc[], const cs_real_t b_visc[], const cs_real_t viselx[], const cs_real_t visely[], const cs_real_t viselz[], cs_real_t *restrict diverg)
Update the cell mass flux divergence with the face pressure (or pressure increment, or pressure double increment) gradient.
Definition: cs_convection_diffusion.c:6365
int n_groups
Definition: cs_numbering.h:85
Definition: cs_parameters.h:52
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:292
static void cs_b_compute_quantities(const cs_real_3_t diipb, const cs_real_3_t gradi, const int ircflp, cs_real_t *recoi)
Reconstruct values in I' at boundary cell i.
Definition: cs_convection_diffusion.h:1330
void itrmas(const cs_int_t *const f_id, const cs_int_t *const init, const cs_int_t *const inc, const cs_int_t *const imrgra, const cs_int_t *const iccocg, const cs_int_t *const nswrgp, const cs_int_t *const imligp, const cs_int_t *const iphydp, const cs_int_t *const iwarnp, const cs_real_t *const epsrgp, const cs_real_t *const climgp, const cs_real_t *const extrap, cs_real_3_t frcxt[], cs_real_t pvar[], const cs_real_t coefap[], const cs_real_t coefbp[], const cs_real_t cofafp[], const cs_real_t cofbfp[], const cs_real_t i_visc[], const cs_real_t b_visc[], const cs_real_t viselx[], const cs_real_t visely[], const cs_real_t viselz[], cs_real_t i_massflux[], cs_real_t b_massflux[])
Definition: cs_convection_diffusion.c:399
static void cs_b_imposed_conv_flux(const int iconvp, const int inc, const int ifaccp, const cs_int_t bc_type, const int icvfli, const cs_real_t pi, const cs_real_t pir, const cs_real_t pipr, const cs_real_t coefap, const cs_real_t coefbp, const cs_real_t coface, const cs_real_t cofbce, const cs_real_t b_massflux, cs_real_t *flux)
Add convective flux (substracting the mass accumulation from it) to flux at boundary face...
Definition: cs_convection_diffusion.h:1412
#define END_C_DECLS
Definition: cs_defs.h:420
static void cs_i_cd_steady_upwind(const int ircflp, const cs_real_t relaxp, const cs_real_t weight, const cs_real_3_t cell_ceni, const cs_real_3_t cell_cenj, const cs_real_3_t i_face_cog, const cs_real_3_t dijpf, const cs_real_3_t gradi, const cs_real_3_t gradj, const cs_real_t pi, const cs_real_t pj, const cs_real_t pia, const cs_real_t pja, cs_real_t *pifri, cs_real_t *pifrj, cs_real_t *pjfri, cs_real_t *pjfrj, cs_real_t *pip, cs_real_t *pjp, cs_real_t *pipr, cs_real_t *pjpr)
Handle preparation of internal face values for the fluxes computation in case of a steady algorithm a...
Definition: cs_convection_diffusion.h:539
static void cs_centered_f_val(const double pnd, const cs_real_t pip, const cs_real_t pjp, const cs_real_t pipr, const cs_real_t pjpr, cs_real_t *pifri, cs_real_t *pifrj, cs_real_t *pjfri, cs_real_t *pjfrj)
Prepare value at face ij by using a centered scheme.
Definition: cs_convection_diffusion.h:304
double cs_real_t
Definition: cs_defs.h:296
void cs_face_anisotropic_diffusion_potential(const cs_mesh_t *m, cs_mesh_quantities_t *fvq, int init, int inc, int imrgra, int iccocg, int nswrgp, int imligp, int ircflp, int iphydp, int iwarnp, double epsrgp, double climgp, double extrap, cs_real_3_t *restrict frcxt, cs_real_t *restrict pvar, const cs_real_t coefap[], const cs_real_t coefbp[], const cs_real_t cofafp[], const cs_real_t cofbfp[], const cs_real_t i_visc[], const cs_real_t b_visc[], cs_real_6_t *restrict viscel, const cs_real_2_t weighf[], const cs_real_t weighb[], cs_real_t *restrict i_massflux, cs_real_t *restrict b_massflux)
Add the explicit part of the pressure gradient term to the mass flux in case of anisotropic diffusion...
Definition: cs_convection_diffusion.c:5975
static void cs_i_compute_quantities(const int ircflp, const double pnd, const cs_real_3_t cell_ceni, const cs_real_3_t cell_cenj, const cs_real_3_t i_face_cog, const cs_real_3_t dijpf, const cs_real_3_t gradi, const cs_real_3_t gradj, const cs_real_t pi, const cs_real_t pj, cs_real_t *recoi, cs_real_t *recoj, cs_real_t *pip, cs_real_t *pjp)
Reconstruct values in I' and J'.
Definition: cs_convection_diffusion.h:146
cs_numbering_t * b_face_numbering
Definition: cs_mesh.h:131
cs_numbering_t * i_face_numbering
Definition: cs_mesh.h:130
#define CS_PROCF(x, y)
Definition: cs_defs.h:443
void bilsct(const cs_int_t *const idtvar, const cs_int_t *const f_id, const cs_var_cal_opt_t *const var_cal_opt, const cs_int_t *const inc, const cs_int_t *const iccocg, const cs_int_t *const ifaccp, cs_real_t pvar[], const cs_real_t pvara[], const cs_int_t bc_type[], const cs_real_t coefap[], const cs_real_t coefbp[], const cs_real_t cofafp[], const cs_real_t cofbfp[], const cs_real_t i_massflux[], const cs_real_t b_massflux[], const cs_real_t i_visc[], const cs_real_t b_visc[], const cs_real_t xcpp[], cs_real_t rhs[])
Definition: cs_convection_diffusion.c:263
int n_threads
Definition: cs_numbering.h:84
static void cs_i_cd_unsteady(const int ircflp, const int ischcp, const double blencp, const cs_real_t weight, const cs_real_3_t cell_ceni, const cs_real_3_t cell_cenj, const cs_real_3_t i_face_cog, const cs_real_3_t dijpf, const cs_real_3_t gradi, const cs_real_3_t gradj, const cs_real_t pi, const cs_real_t pj, cs_real_t *pifri, cs_real_t *pifrj, cs_real_t *pjfri, cs_real_t *pjfrj, cs_real_t *pip, cs_real_t *pjp, cs_real_t *pipr, cs_real_t *pjpr)
Handle preparation of internal face values for the fluxes computation in case of a unsteady algorithm...
Definition: cs_convection_diffusion.h:851
cs_real_t cs_real_33_t[3][3]
3x3 matrix of floating-point values
Definition: cs_defs.h:311
cs_real_t * b_face_normal
Definition: cs_mesh_quantities.h:59
int have_rotation_perio
Definition: cs_mesh.h:114
cs_real_t * diipb
Definition: cs_mesh_quantities.h:75
void cs_halo_perio_sync_var_vect(const cs_halo_t *halo, cs_halo_type_t sync_mode, cs_real_t var[], int incvar)
Definition: cs_halo_perio.c:576
cs_real_t * cell_vol
Definition: cs_mesh_quantities.h:54
static void cs_i_cd_steady(const int ircflp, const int ischcp, const double relaxp, const double blencp, const cs_real_t weight, const cs_real_3_t cell_ceni, const cs_real_3_t cell_cenj, const cs_real_3_t i_face_cog, const cs_real_3_t dijpf, const cs_real_3_t gradi, const cs_real_3_t gradj, const cs_real_t pi, const cs_real_t pj, const cs_real_t pia, const cs_real_t pja, cs_real_t *pifri, cs_real_t *pifrj, cs_real_t *pjfri, cs_real_t *pjfrj, cs_real_t *pip, cs_real_t *pjp, cs_real_t *pipr, cs_real_t *pjpr)
Handle preparation of internal face values for the fluxes computation in case of a steady algorithm a...
Definition: cs_convection_diffusion.h:717
void bilsc4(const cs_int_t *const idtvar, const cs_int_t *const f_id, const cs_var_cal_opt_t *const var_cal_opt, const cs_int_t *const icvflb, const cs_int_t *const inc, const cs_int_t *const ifaccp, const cs_int_t *const ivisep, cs_real_3_t pvar[], const cs_real_3_t pvara[], const cs_int_t bc_type[], const cs_int_t icvfli[], const cs_real_3_t coefav[], const cs_real_33_t coefbv[], const cs_real_3_t cofafv[], const cs_real_33_t cofbfv[], const cs_real_t i_massflux[], const cs_real_t b_massflux[], const cs_real_t i_visc[], const cs_real_t b_visc[], const cs_real_t secvif[], cs_real_3_t rhs[])
Definition: cs_convection_diffusion.c:211
cs_lnum_2_t * i_face_cells
Definition: cs_mesh.h:86
static void cs_b_diff_flux(const int idiffp, const int inc, const cs_real_t pipr, const cs_real_t cofafp, const cs_real_t cofbfp, const cs_real_t b_visc, cs_real_t *flux)
Add diffusive flux to flux at boundary face.
Definition: cs_convection_diffusion.h:1640
double precision, dimension(:,:), pointer dijpf
Definition: mesh.f90:208
static void cs_i_no_relax_c_val(const cs_real_t pi, const cs_real_t pj, const cs_real_t pip, const cs_real_t pjp, cs_real_t *pir, cs_real_t *pjr, cs_real_t *pipr, cs_real_t *pjpr)
Copy reconstructed or not cell values for consistency with relaxation case.
Definition: cs_convection_diffusion.h:240
static void cs_solu_f_val(const cs_real_3_t cell_ceni, const cs_real_3_t cell_cenj, const cs_real_3_t i_face_cog, const cs_real_3_t gradi, const cs_real_3_t gradj, const cs_real_t pi, const cs_real_t pj, const cs_real_t pir, const cs_real_t pjr, cs_real_t *pifri, cs_real_t *pifrj, cs_real_t *pjfri, cs_real_t *pjfrj)
Prepare value at face ij by using a Second Order Linear Upwind scheme.
Definition: cs_convection_diffusion.h:341
void cs_convection_diffusion_scalar(int idtvar, int f_id, const cs_var_cal_opt_t var_cal_opt, int icvflb, int inc, int iccocg, int ifaccp, cs_real_t *restrict pvar, const cs_real_t *restrict pvara, const cs_int_t bc_type[], const cs_int_t icvfli[], const cs_real_t coefap[], const cs_real_t coefbp[], const cs_real_t cofafp[], const cs_real_t cofbfp[], const cs_real_t i_massflux[], const cs_real_t b_massflux[], const cs_real_t i_visc[], const cs_real_t b_visc[], cs_real_t *restrict rhs)
Add the explicit part of the convection/diffusion terms of a standard transport equation of a scalar ...
Definition: cs_convection_diffusion.c:712
void cs_convection_diffusion_thermal(int idtvar, int f_id, const cs_var_cal_opt_t var_cal_opt, int inc, int iccocg, int ifaccp, cs_real_t *restrict pvar, const cs_real_t *restrict pvara, const cs_int_t bc_type[], const cs_real_t coefap[], const cs_real_t coefbp[], const cs_real_t cofafp[], const cs_real_t cofbfp[], const cs_real_t i_massflux[], const cs_real_t b_massflux[], const cs_real_t i_visc[], const cs_real_t b_visc[], const cs_real_t xcpp[], cs_real_t *restrict rhs)
Add the explicit part of the convection/diffusion terms of a transport equation of a scalar field su...
Definition: cs_convection_diffusion.c:3286
cs_real_t * i_face_cog
Definition: cs_mesh_quantities.h:65
static void cs_i_conv_flux_cons(const int iconvp, const cs_real_t pifri, const cs_real_t pifrj, const cs_real_t pjfri, const cs_real_t pjfrj, const cs_real_t i_massflux, const cs_real_t xcppi, const cs_real_t xcppj, cs_real_2_t fluxij)
Add convective fluxes (cons. formulation) to fluxes at face ij.
Definition: cs_convection_diffusion.h:463
void itrgrp(const cs_int_t *const f_id, const cs_int_t *const init, const cs_int_t *const inc, const cs_int_t *const imrgra, const cs_int_t *const iccocg, const cs_int_t *const nswrgp, const cs_int_t *const imligp, const cs_int_t *const iphydp, const cs_int_t *const iwarnp, const cs_real_t *const epsrgp, const cs_real_t *const climgp, const cs_real_t *const extrap, cs_real_3_t frcxt[], cs_real_t pvar[], const cs_real_t coefap[], const cs_real_t coefbp[], const cs_real_t cofafp[], const cs_real_t cofbfp[], const cs_real_t i_visc[], const cs_real_t b_visc[], const cs_real_t viselx[], const cs_real_t visely[], const cs_real_t viselz[], cs_real_t diverg[])
Definition: cs_convection_diffusion.c:529
integer(c_int), pointer, save imrgra
type of gradient reconstruction
Definition: optcal.f90:276
cs_halo_t * halo
Definition: cs_mesh.h:127
cs_lnum_t * b_face_cells
Definition: cs_mesh.h:87
integer, save ifaccp
indicator coupling face / face only
Definition: cplsat.f90:45