7.2
general 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-2022 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 #include "cs_math.h"
39 #include "cs_mesh_quantities.h"
40 #include "cs_parameters.h"
41 #include "cs_field_pointer.h"
42 
43 /*----------------------------------------------------------------------------*/
44 
46 
47 /*=============================================================================
48  * Macro definitions
49  *============================================================================*/
50 
51 /*============================================================================
52  * Type definition
53  *============================================================================*/
54 
55 /*----------------------------------------------------------------------------
56  * NVD/TVD Advection Scheme
57  *----------------------------------------------------------------------------*/
58 
59 typedef enum {
60 
61  CS_NVD_GAMMA = 0, /* GAMMA */
62  CS_NVD_SMART = 1, /* SMART */
63  CS_NVD_CUBISTA = 2, /* CUBISTA */
64  CS_NVD_SUPERBEE = 3, /* SUPERBEE */
65  CS_NVD_MUSCL = 4, /* MUSCL */
66  CS_NVD_MINMOD = 5, /* MINMOD */
67  CS_NVD_CLAM = 6, /* CLAM */
68  CS_NVD_STOIC = 7, /* STOIC */
69  CS_NVD_OSHER = 8, /* OSHER */
70  CS_NVD_WASEB = 9, /* WASEB */
71  CS_NVD_VOF_HRIC = 10, /* M-HRIC for VOF */
72  CS_NVD_VOF_CICSAM = 11, /* M-CICSAM for VOF */
73  CS_NVD_VOF_STACS = 12, /* STACS for VOF */
74  CS_NVD_N_TYPES = 13 /* number of NVD schemes */
75 
77 
78 /*============================================================================
79  * Global variables
80  *============================================================================*/
81 
82 /*============================================================================
83  * Public inlined function
84  *============================================================================*/
85 
86 /*----------------------------------------------------------------------------
87  * Synchronize halos for scalar variables.
88  *
89  * parameters:
90  * m <-- pointer to associated mesh structure
91  * halo_type <-> halo type
92  * pvar <-> variable
93  *----------------------------------------------------------------------------*/
94 
95 inline static void
97  cs_halo_type_t halo_type,
98  cs_real_t pvar[])
99 {
100  if (m->halo != NULL)
101  cs_halo_sync_var(m->halo, halo_type, pvar);
102 }
103 
104 /*----------------------------------------------------------------------------
105  * Return pointer to slope test indicator field values if active.
106  *
107  * parameters:
108  * f_id <-- field id (or -1)
109  * var_cal_opt <-- variable calculation options
110  *
111  * return:
112  * pointer to local values array, or NULL;
113  *----------------------------------------------------------------------------*/
114 
115 inline static cs_real_t *
118 {
119  const int iconvp = var_cal_opt.iconv;
120  const int isstpp = var_cal_opt.isstpc;
121  const double blencp = var_cal_opt.blencv;
122 
123  cs_real_t *v_slope_test = NULL;
124 
125  if (f_id > -1 && iconvp > 0 && blencp > 0. && isstpp == 0) {
126 
127  static int _k_slope_test_f_id = -1;
128 
129  cs_field_t *f = cs_field_by_id(f_id);
130 
131  int f_track_slope_test_id = -1;
132 
133  if (_k_slope_test_f_id < 0)
134  _k_slope_test_f_id = cs_field_key_id_try("slope_test_upwind_id");
135  if (_k_slope_test_f_id > -1 && isstpp == 0)
136  f_track_slope_test_id = cs_field_get_key_int(f, _k_slope_test_f_id);
137 
138  if (f_track_slope_test_id > -1)
139  v_slope_test = (cs_field_by_id(f_track_slope_test_id))->val;
140 
141  if (v_slope_test != NULL) {
142  const cs_lnum_t n_cells_ext = cs_glob_mesh->n_cells_with_ghosts;
143 # pragma omp parallel for
144  for (cs_lnum_t cell_id = 0; cell_id < n_cells_ext; cell_id++)
145  v_slope_test[cell_id] = 0.;
146  }
147 
148  }
149 
150  return v_slope_test;
151 }
152 
153 /*----------------------------------------------------------------------------
154  * Compute the local cell Courant number as the maximum of all cell face based
155  * Courant number at each cell.
156  *
157  * parameters:
158  * f_id <-- field id (or -1)
159  * courant --> cell Courant number
160  */
161 /*----------------------------------------------------------------------------*/
162 
163 inline static void
164 cs_cell_courant_number(const int f_id,
165  cs_real_t *courant)
166 {
167  const cs_mesh_t *m = cs_glob_mesh;
169 
170  const cs_lnum_t n_cells_ext = m->n_cells_with_ghosts;
171  const int n_i_groups = m->i_face_numbering->n_groups;
172  const int n_i_threads = m->i_face_numbering->n_threads;
173  const int n_b_groups = m->b_face_numbering->n_groups;
174  const int n_b_threads = m->b_face_numbering->n_threads;
175  const cs_lnum_t *restrict i_group_index = m->i_face_numbering->group_index;
176  const cs_lnum_t *restrict b_group_index = m->b_face_numbering->group_index;
177 
178  const cs_lnum_2_t *restrict i_face_cells
179  = (const cs_lnum_2_t *restrict)m->i_face_cells;
180  const cs_lnum_t *restrict b_face_cells
181  = (const cs_lnum_t *restrict)m->b_face_cells;
182 
183  const cs_real_t *restrict vol
184  = (cs_real_t *restrict)fvq->cell_vol;
185 
186  cs_field_t *f = cs_field_by_id(f_id);
187  const int kimasf = cs_field_key_id("inner_mass_flux_id");
188  const int kbmasf = cs_field_key_id("boundary_mass_flux_id");
189  const cs_real_t *restrict i_massflux
191  const cs_real_t *restrict b_massflux
193 
194  const cs_real_t *restrict dt
195  = (const cs_real_t *restrict)CS_F_(dt)->val;
196 
197  /* Initialisation */
198 
199 # pragma omp parallel for
200  for (cs_lnum_t ii = 0; ii < n_cells_ext; ii++) {
201  courant[ii] = 0.;
202  }
203 
204  /* ---> Contribution from interior faces */
205 
206  cs_real_t cnt;
207 
208  for (int g_id = 0; g_id < n_i_groups; g_id++) {
209 # pragma omp parallel for
210  for (int t_id = 0; t_id < n_i_threads; t_id++) {
211  for (cs_lnum_t face_id = i_group_index[(t_id*n_i_groups + g_id)*2];
212  face_id < i_group_index[(t_id*n_i_groups + g_id)*2 + 1];
213  face_id++) {
214  cs_lnum_t ii = i_face_cells[face_id][0];
215  cs_lnum_t jj = i_face_cells[face_id][1];
216 
217  cnt = CS_ABS(i_massflux[face_id])*dt[ii]/vol[ii];
218  courant[ii] = CS_MAX(courant[ii], cnt);
219 
220  cnt = CS_ABS(i_massflux[face_id])*dt[jj]/vol[jj];
221  courant[jj] = CS_MAX(courant[jj], cnt);
222  }
223  }
224  }
225 
226  /* ---> Contribution from boundary faces */
227 
228  for (int g_id = 0; g_id < n_b_groups; g_id++) {
229 # pragma omp parallel for
230  for (int t_id = 0; t_id < n_b_threads; t_id++) {
231  for (cs_lnum_t face_id = b_group_index[(t_id*n_b_groups + g_id)*2];
232  face_id < b_group_index[(t_id*n_b_groups + g_id)*2 + 1];
233  face_id++) {
234  cs_lnum_t ii = b_face_cells[face_id];
235 
236  cnt = CS_ABS(b_massflux[face_id])*dt[ii]/vol[ii];
237  courant[ii] = CS_MAX(courant[ii], cnt);
238  }
239  }
240  }
241 }
242 
243 /*----------------------------------------------------------------------------*/
254 /*----------------------------------------------------------------------------*/
255 
256 inline static cs_real_t
258  const cs_real_t nvf_p_c,
259  const cs_real_t nvf_r_f,
260  const cs_real_t nvf_r_c)
261 {
262  cs_real_t nvf_p_f;
263 
264  cs_real_t beta_m, rfc, r1f, r1, r2, r3, b1, b2;
265 
266  switch (limiter) {
267  case CS_NVD_GAMMA: /* Gamma scheme */
268  beta_m = 0.1; /* in [0.1, 0.5] */
269  rfc = (nvf_r_f-nvf_r_c)/(1.-nvf_r_c);
270 
271  if (nvf_p_c < beta_m) {
272  nvf_p_f = nvf_p_c*(1.+rfc*(1.-nvf_p_c)/beta_m);
273  } else {
274  r1f = (1.-nvf_r_f)/(1.-nvf_r_c);
275 
276  nvf_p_f = r1f*nvf_p_c+rfc;
277  }
278 
279  break;
280 
281  case CS_NVD_SMART: /* SMART scheme */
282  if (nvf_p_c < (nvf_r_c/3.)) {
283  r1 = nvf_r_f*(1.-3.*nvf_r_c+2.*nvf_r_f);
284  r2 = nvf_r_c*(1.-nvf_r_c);
285 
286  nvf_p_f = nvf_p_c*r1/r2;
287  } else if (nvf_p_c <= (nvf_r_c*(1.+nvf_r_f-nvf_r_c)/nvf_r_f)) {
288  rfc = (nvf_r_f-nvf_r_c)/(1.-nvf_r_c);
289  r1f = (1.-nvf_r_f)/(1.-nvf_r_c);
290 
291  nvf_p_f = nvf_r_f*(r1f*nvf_p_c/nvf_r_c + rfc);
292  } else {
293  nvf_p_f = 1.;
294  }
295 
296  break;
297 
298  case CS_NVD_CUBISTA: /* CUBISTA scheme */
299  if (nvf_p_c < (3.*nvf_r_c/4.)) {
300  rfc = (nvf_r_f-nvf_r_c)/(1.-nvf_r_c);
301 
302  nvf_p_f = nvf_r_f*(1.+rfc/3.)*nvf_p_c/nvf_r_c;
303  } else if (nvf_p_c <= (nvf_r_c*(1.+2.*(nvf_r_f-nvf_r_c))/(2.*nvf_r_f-nvf_r_c))) {
304  rfc = (nvf_r_f-nvf_r_c)/(1.-nvf_r_c);
305  r1f = (1.-nvf_r_f)/(1.-nvf_r_c);
306 
307  nvf_p_f = nvf_r_f*(r1f*nvf_p_c/nvf_r_c+rfc);
308  } else {
309  r1f = (1.-nvf_r_f)/(1.-nvf_r_c);
310 
311  nvf_p_f = 1.-.5*r1f*(1.-nvf_p_c);
312  }
313 
314  break;
315 
316  case CS_NVD_SUPERBEE: /* SuperBee scheme */
317  if (nvf_p_c < (nvf_r_c/(2.-nvf_r_c))) {
318  nvf_p_f = (2.*nvf_r_f-nvf_r_c)*nvf_p_c/nvf_r_c;
319  } else if (nvf_p_c < nvf_r_c) {
320  rfc = (nvf_r_f-nvf_r_c)/(1.-nvf_r_c);
321  r1f = (1.-nvf_r_f)/(1.-nvf_r_c);
322 
323  nvf_p_f = r1f*nvf_p_c+rfc;
324  } else if (nvf_p_c < (nvf_r_c/nvf_r_f)) {
325  nvf_p_f = nvf_r_f*nvf_p_c/nvf_r_c;
326  } else {
327  nvf_p_f = 1.;
328  }
329 
330  break;
331 
332  case CS_NVD_MUSCL: /* MUSCL scheme */
333  if (nvf_p_c < (.5*nvf_r_c)) {
334  nvf_p_f = (2.*nvf_r_f-nvf_r_c)*nvf_p_c/nvf_r_c;
335  } else if (nvf_p_c < (1.+nvf_r_c-nvf_r_f)) {
336  nvf_p_f = nvf_p_c+nvf_r_f-nvf_r_c;
337  } else {
338  nvf_p_f = 1.;
339  }
340 
341  break;
342 
343  case CS_NVD_MINMOD: /* MINMOD scheme */
344  if (nvf_p_c < nvf_r_c) {
345  nvf_p_f = nvf_r_f*nvf_p_c/nvf_r_c;
346  } else {
347  rfc = (nvf_r_f-nvf_r_c)/(1.-nvf_r_c);
348  r1f = (1.-nvf_r_f)/(1.-nvf_r_c);
349 
350  nvf_p_f = r1f*nvf_p_c+rfc;
351  }
352 
353  break;
354 
355  case CS_NVD_CLAM: /* CLAM scheme */
356  r1 = nvf_r_c*nvf_r_c-nvf_r_f;
357  r2 = nvf_r_c*(nvf_r_c-1.);
358  r3 = nvf_r_f-nvf_r_c;
359 
360  nvf_p_f = nvf_p_c*(r1+r3*nvf_p_c)/r2;
361 
362  break;
363 
364  case CS_NVD_STOIC: /* STOIC scheme */
365  b1 = (nvf_r_c-nvf_r_f)*nvf_r_c;
366  b2 = nvf_r_c+nvf_r_f+2.*nvf_r_f*nvf_r_f-4.*nvf_r_f*nvf_r_c;
367 
368  if (nvf_p_c < (b1/b2)) {
369  r1 = -nvf_r_f*(1.-3.*nvf_r_c+2.*nvf_r_f);
370  r2 = nvf_r_c*(nvf_r_c-1.);
371 
372  nvf_p_f = nvf_p_c*r1/r2;
373  } else if (nvf_p_c < nvf_r_c) {
374  rfc = (nvf_r_f-nvf_r_c)/(1.-nvf_r_c);
375  r1f = (1.-nvf_r_f)/(1.-nvf_r_c);
376 
377  nvf_p_f = r1f*nvf_p_c+rfc;
378  } else if (nvf_p_c < (nvf_r_c*(1.+nvf_r_f-nvf_r_c)/nvf_r_f)) {
379  rfc = (nvf_r_f-nvf_r_c)/(1.-nvf_r_c);
380  r1f = (1.-nvf_r_f)/(1.-nvf_r_c);
381 
382  nvf_p_f = nvf_r_f*(nvf_p_c*r1f/nvf_r_c+rfc);
383  } else {
384  nvf_p_f = 1.;
385  }
386 
387  break;
388 
389  case CS_NVD_OSHER: /* OSHER scheme */
390  if (nvf_p_c < (nvf_r_c/nvf_r_f)) {
391  nvf_p_f = nvf_r_f*nvf_p_c/nvf_r_c;
392  } else {
393  nvf_p_f = 1.;
394  }
395 
396  break;
397 
398  case CS_NVD_WASEB: /* WASEB scheme */
399  r1 = nvf_r_c*nvf_r_f*(nvf_r_f-nvf_r_c);
400  r2 = 2.*nvf_r_c*(1.-nvf_r_c)-nvf_r_f*(1.-nvf_r_f);
401 
402  if (nvf_p_c < (r1/r2)) {
403  nvf_p_f = 2.*nvf_p_c;
404  } else if (nvf_p_c <= (nvf_r_c*(1.+nvf_r_f-nvf_r_c)/nvf_r_f)) {
405  rfc = (nvf_r_f-nvf_r_c)/(1.-nvf_r_c);
406  r1f = (1.-nvf_r_f)/(1.-nvf_r_c);
407 
408  nvf_p_f = nvf_r_f*(nvf_p_c*r1f/nvf_r_c+rfc);
409  } else {
410  nvf_p_f = 1.;
411  }
412 
413  break;
414 
415  default: /* Upwinding */
416  nvf_p_f = nvf_p_c;
417  break;
418  }
419 
420  return nvf_p_f;
421 }
422 
423 /*----------------------------------------------------------------------------*/
439 /*----------------------------------------------------------------------------*/
440 
441 inline static cs_real_t
443  const cs_real_3_t i_face_normal,
444  const cs_real_t nvf_p_c,
445  const cs_real_t nvf_r_f,
446  const cs_real_t nvf_r_c,
447  const cs_real_3_t gradv_c,
448  const cs_real_t c_courant)
449 {
450  assert(limiter >= CS_NVD_VOF_HRIC);
451 
452  cs_real_t nvf_p_f;
453  cs_real_t blend, high_order, low_order, ratio;
454 
455  /* Compute gradient angle indicator */
456  cs_real_t dotp = CS_ABS(cs_math_3_dot_product(gradv_c, i_face_normal));
457  cs_real_t sgrad = cs_math_3_norm(gradv_c);
458  cs_real_t snorm = cs_math_3_norm(i_face_normal);
459  cs_real_t denom = snorm*sgrad;
460 
461  if (limiter == CS_NVD_VOF_HRIC) { /* M-HRIC scheme */
462  /* High order scheme : Bounded Downwind */
463  if (nvf_p_c <= .5) {
464  high_order = 2.*nvf_p_c;
465  } else {
466  high_order = 1.;
467  }
468 
469  /* Low order scheme : MUSCL */
471  nvf_p_c,
472  nvf_r_f,
473  nvf_r_c);
474 
475  /* Compute the blending factor */
476  if (denom <= (cs_math_epzero*dotp)) {
477  blend = 1.;
478  } else {
479  ratio = dotp/denom;
480  blend = CS_MIN(1., pow(ratio, .5));
481  }
482 
483  /* Blending */
484  nvf_p_f = blend*high_order + (1.-blend)*low_order;
485 
486  /* Extra blending due to the cell Courant number */
487  if (c_courant < .7 && c_courant > .3) {
488  nvf_p_f = nvf_p_f + (nvf_p_f - low_order)*(.7 - c_courant )/.4;
489  } else if (c_courant >= .7) {
490  nvf_p_f = low_order;
491  }
492  } else if (limiter == CS_NVD_VOF_CICSAM) { /* M-CICSAM scheme */
493  /* High order scheme : HYPER-C + SUPERBEE */
494  if (c_courant <= .3) {
495  high_order = CS_MIN(1., nvf_p_c/(c_courant+cs_math_epzero));
496  } else if (c_courant <= .6) {
497  high_order = CS_MIN(1., nvf_p_c/.3);
498  } else if (c_courant <= .7) {
500  nvf_p_c,
501  nvf_r_f,
502  nvf_r_c);
503  high_order = 10.*( (.7-c_courant)*CS_MIN(1., nvf_p_c/.3)
504  + (c_courant-.6)*superbee);
505  }
506  else {
508  nvf_p_c,
509  nvf_r_f,
510  nvf_r_c);
511  }
512 
513  /* Low order scheme : MUSCL */
515  nvf_p_c,
516  nvf_r_f,
517  nvf_r_c);
518 
519  /* Compute the blending factor */
520  if (denom <= (cs_math_epzero*dotp)) {
521  blend = 1.;
522  } else {
523  ratio = dotp/denom;
524  blend = CS_MIN(1., pow(ratio, 2.));
525  }
526 
527  /* Blending */
528  nvf_p_f = blend*high_order + (1.-blend)*low_order;
529  } else { /* STACS scheme */
530  /* High order scheme : SUPERBEE */
532  nvf_p_c,
533  nvf_r_f,
534  nvf_r_c);
535 
536  /* Low order scheme : STOIC */
538  nvf_p_c,
539  nvf_r_f,
540  nvf_r_c);
541 
542  /* Compute the blending factor */
543  if (denom <= (cs_math_epzero*dotp)) {
544  blend = 1.;
545  } else {
546  ratio = dotp/denom;
547  blend = CS_MIN(1., pow(ratio, 4.));
548  }
549 
550  /* Blending */
551  nvf_p_f = blend*high_order + (1.-blend)*low_order;
552  }
553 
554  return nvf_p_f;
555 }
556 
557 /*----------------------------------------------------------------------------*/
574 /*----------------------------------------------------------------------------*/
575 
576 inline static void
578  const cs_real_t pj,
579  const cs_real_t distf,
580  const cs_real_t srfan,
581  const cs_real_t i_face_normal[3],
582  const cs_real_t gradi[3],
583  const cs_real_t gradj[3],
584  const cs_real_t grdpai[3],
585  const cs_real_t grdpaj[3],
586  const cs_real_t i_massflux,
587  cs_real_t *testij,
588  cs_real_t *tesqck)
589 {
590  cs_real_t testi, testj;
591  cs_real_t dcc, ddi, ddj;
592 
593  /* Slope test */
594 
595  testi = grdpai[0]*i_face_normal[0]
596  + grdpai[1]*i_face_normal[1]
597  + grdpai[2]*i_face_normal[2];
598  testj = grdpaj[0]*i_face_normal[0]
599  + grdpaj[1]*i_face_normal[1]
600  + grdpaj[2]*i_face_normal[2];
601 
602  *testij = grdpai[0]*grdpaj[0]
603  + grdpai[1]*grdpaj[1]
604  + grdpai[2]*grdpaj[2];
605 
606  if (i_massflux>0.) {
607  dcc = gradi[0]*i_face_normal[0]
608  + gradi[1]*i_face_normal[1]
609  + gradi[2]*i_face_normal[2];
610  ddi = testi;
611  ddj = (pj-pi)/distf *srfan;
612  } else {
613  dcc = gradj[0]*i_face_normal[0]
614  + gradj[1]*i_face_normal[1]
615  + gradj[2]*i_face_normal[2];
616  ddi = (pj-pi)/distf *srfan;
617  ddj = testj;
618  }
619 
620  *tesqck = cs_math_sq(dcc) - cs_math_sq(ddi-ddj);
621 }
622 
623 /*----------------------------------------------------------------------------*/
640 /*----------------------------------------------------------------------------*/
641 
642 inline static void
644  const cs_real_t pj[3],
645  const cs_real_t distf,
646  const cs_real_t srfan,
647  const cs_real_t i_face_normal[3],
648  const cs_real_t gradi[3][3],
649  const cs_real_t gradj[3][3],
650  const cs_real_t gradsti[3][3],
651  const cs_real_t gradstj[3][3],
652  const cs_real_t i_massflux,
653  cs_real_t *testij,
654  cs_real_t *tesqck)
655 {
656  cs_real_t testi[3], testj[3];
657  cs_real_t dcc[3], ddi[3], ddj[3];
658  *testij = 0.;
659  *tesqck = 0.;
660 
661  /* Slope test */
662 
663  for (int i = 0; i < 3; i++) {
664  *testij += gradsti[i][0]*gradstj[i][0]
665  + gradsti[i][1]*gradstj[i][1]
666  + gradsti[i][2]*gradstj[i][2];
667 
668  testi[i] = gradsti[i][0]*i_face_normal[0]
669  + gradsti[i][1]*i_face_normal[1]
670  + gradsti[i][2]*i_face_normal[2];
671  testj[i] = gradstj[i][0]*i_face_normal[0]
672  + gradstj[i][1]*i_face_normal[1]
673  + gradstj[i][2]*i_face_normal[2];
674 
675  if (i_massflux > 0.) {
676  dcc[i] = gradi[i][0]*i_face_normal[0]
677  + gradi[i][1]*i_face_normal[1]
678  + gradi[i][2]*i_face_normal[2];
679  ddi[i] = testi[i];
680  ddj[i] = (pj[i]-pi[i])/distf *srfan;
681  } else {
682  dcc[i] = gradj[i][0]*i_face_normal[0]
683  + gradj[i][1]*i_face_normal[1]
684  + gradj[i][2]*i_face_normal[2];
685  ddi[i] = (pj[i]-pi[i])/distf *srfan;
686  ddj[i] = testj[i];
687  }
688  }
689 
690  *tesqck = cs_math_3_square_norm(dcc) - cs_math_3_square_distance(ddi, ddj);
691 }
692 
693 /*----------------------------------------------------------------------------*/
710 /*----------------------------------------------------------------------------*/
711 
712 inline static void
714  const cs_real_t pj[6],
715  const cs_real_t distf,
716  const cs_real_t srfan,
717  const cs_real_t i_face_normal[3],
718  const cs_real_t gradi[6][3],
719  const cs_real_t gradj[6][3],
720  const cs_real_t gradsti[6][3],
721  const cs_real_t gradstj[6][3],
722  const cs_real_t i_massflux,
723  cs_real_t *testij,
724  cs_real_t *tesqck)
725 {
726  cs_real_t testi[6], testj[6];
727  cs_real_t dcc[6], ddi[6], ddj[6];
728 
729  *testij = 0.;
730  *tesqck = 0.;
731 
732  /* Slope test */
733 
734  for (int ij = 0; ij < 6; ij++) {
735  *testij += gradsti[ij][0]*gradstj[ij][0]
736  + gradsti[ij][1]*gradstj[ij][1]
737  + gradsti[ij][2]*gradstj[ij][2];
738  testi[ij] = gradsti[ij][0]*i_face_normal[0]
739  + gradsti[ij][1]*i_face_normal[1]
740  + gradsti[ij][2]*i_face_normal[2];
741  testj[ij] = gradstj[ij][0]*i_face_normal[0]
742  + gradstj[ij][1]*i_face_normal[1]
743  + gradstj[ij][2]*i_face_normal[2];
744 
745  if (i_massflux > 0.) {
746  dcc[ij] = gradi[ij][0]*i_face_normal[0]
747  + gradi[ij][1]*i_face_normal[1]
748  + gradi[ij][2]*i_face_normal[2];
749  ddi[ij] = testi[ij];
750  ddj[ij] = (pj[ij]-pi[ij])/distf *srfan;
751  }
752  else {
753  dcc[ij] = gradj[ij][0]*i_face_normal[0]
754  + gradj[ij][1]*i_face_normal[1]
755  + gradj[ij][2]*i_face_normal[2];
756  ddi[ij] = (pj[ij]-pi[ij])/distf *srfan;
757  ddj[ij] = testj[ij];
758  }
759 
760  *tesqck += cs_math_sq(dcc[ij]) - cs_math_sq(ddi[ij]-ddj[ij]);
761  }
762 }
763 
764 /*----------------------------------------------------------------------------*/
780 /*----------------------------------------------------------------------------*/
781 
782 inline static void
784  const cs_real_3_t diipf,
785  const cs_real_3_t djjpf,
786  const cs_real_3_t gradi,
787  const cs_real_3_t gradj,
788  const cs_real_t pi,
789  const cs_real_t pj,
790  cs_real_t *recoi,
791  cs_real_t *recoj,
792  cs_real_t *pip,
793  cs_real_t *pjp)
794 {
795  cs_real_t gradpf[3] = {0.5*(gradi[0] + gradj[0]),
796  0.5*(gradi[1] + gradj[1]),
797  0.5*(gradi[2] + gradj[2])};
798 
799  /* reconstruction only if IRCFLP = 1 */
800  *recoi = bldfrp*(cs_math_3_dot_product(gradpf, diipf));
801  *recoj = bldfrp*(cs_math_3_dot_product(gradpf, djjpf));
802  *pip = pi + *recoi;
803  *pjp = pj + *recoj;
804 }
805 
806 /*----------------------------------------------------------------------------*/
822 /*----------------------------------------------------------------------------*/
823 
824 inline static void
826  const cs_real_3_t diipf,
827  const cs_real_3_t djjpf,
828  const cs_real_33_t gradi,
829  const cs_real_33_t gradj,
830  const cs_real_3_t pi,
831  const cs_real_3_t pj,
832  cs_real_t recoi[3],
833  cs_real_t recoj[3],
834  cs_real_t pip[3],
835  cs_real_t pjp[3])
836 {
837  cs_real_3_t dpvf;
838 
839  /* x-y-z components, p = u, v, w */
840 
841  for (int isou = 0; isou < 3; isou++) {
842 
843  for (int jsou = 0; jsou < 3; jsou++)
844  dpvf[jsou] = 0.5*( gradi[isou][jsou]
845  + gradj[isou][jsou]);
846 
847  /* reconstruction only if IRCFLP = 1 */
848 
849  recoi[isou] = bldfrp*(cs_math_3_dot_product(dpvf, diipf));
850  recoj[isou] = bldfrp*(cs_math_3_dot_product(dpvf, djjpf));
851 
852  pip[isou] = pi[isou] + recoi[isou];
853  pjp[isou] = pj[isou] + recoj[isou];
854 
855  }
856 }
857 
858 /*----------------------------------------------------------------------------*/
874 /*----------------------------------------------------------------------------*/
875 
876 inline static void
878  const cs_real_3_t diipf,
879  const cs_real_3_t djjpf,
880  const cs_real_63_t gradi,
881  const cs_real_63_t gradj,
882  const cs_real_6_t pi,
883  const cs_real_6_t pj,
884  cs_real_t recoi[6],
885  cs_real_t recoj[6],
886  cs_real_t pip[6],
887  cs_real_t pjp[6])
888 {
889  cs_real_3_t dpvf;
890 
891  /* x-y-z components, p = u, v, w */
892 
893  for (int isou = 0; isou < 6; isou++) {
894 
895  for (int jsou = 0; jsou < 3; jsou++)
896  dpvf[jsou] = 0.5*( gradi[isou][jsou]
897  + gradj[isou][jsou]);
898 
899  /* reconstruction only if IRCFLP = 1 */
900 
901  recoi[isou] = bldfrp*(cs_math_3_dot_product(dpvf, diipf));
902  recoj[isou] = bldfrp*(cs_math_3_dot_product(dpvf, djjpf));
903 
904  pip[isou] = pi[isou] + recoi[isou];
905  pjp[isou] = pj[isou] + recoj[isou];
906 
907  }
908 }
909 
910 /*----------------------------------------------------------------------------*/
926 /*----------------------------------------------------------------------------*/
927 
928 inline static void
929 cs_i_relax_c_val(const double relaxp,
930  const cs_real_t pia,
931  const cs_real_t pja,
932  const cs_real_t recoi,
933  const cs_real_t recoj,
934  const cs_real_t pi,
935  const cs_real_t pj,
936  cs_real_t *pir,
937  cs_real_t *pjr,
938  cs_real_t *pipr,
939  cs_real_t *pjpr)
940 {
941  *pir = pi/relaxp - (1.-relaxp)/relaxp * pia;
942  *pjr = pj/relaxp - (1.-relaxp)/relaxp * pja;
943 
944  *pipr = *pir + recoi;
945  *pjpr = *pjr + recoj;
946 }
947 
948 /*----------------------------------------------------------------------------*/
964 /*----------------------------------------------------------------------------*/
965 
966 inline static void
967 cs_i_relax_c_val_vector(const double relaxp,
968  const cs_real_3_t pia,
969  const cs_real_3_t pja,
970  const cs_real_3_t recoi,
971  const cs_real_3_t recoj,
972  const cs_real_3_t pi,
973  const cs_real_3_t pj,
974  cs_real_t pir[3],
975  cs_real_t pjr[3],
976  cs_real_t pipr[3],
977  cs_real_t pjpr[3])
978 {
979  for (int isou = 0; isou < 3; isou++) {
980  pir[isou] = pi[isou] /relaxp - (1.-relaxp)/relaxp * pia[isou];
981  pjr[isou] = pj[isou] /relaxp - (1.-relaxp)/relaxp * pja[isou];
982 
983  pipr[isou] = pir[isou] + recoi[isou];
984  pjpr[isou] = pjr[isou] + recoj[isou];
985  }
986 }
987 
988 /*----------------------------------------------------------------------------*/
1004 /*----------------------------------------------------------------------------*/
1005 
1006 inline static void
1008  const cs_real_t pia[6],
1009  const cs_real_t pja[6],
1010  const cs_real_t recoi[6],
1011  const cs_real_t recoj[6],
1012  const cs_real_t pi[6],
1013  const cs_real_t pj[6],
1014  cs_real_t pir[6],
1015  cs_real_t pjr[6],
1016  cs_real_t pipr[6],
1017  cs_real_t pjpr[6])
1018 {
1019  for (int isou = 0; isou < 6; isou++) {
1020  pir[isou] = pi[isou] /relaxp - (1.-relaxp)/relaxp * pia[isou];
1021  pjr[isou] = pj[isou] /relaxp - (1.-relaxp)/relaxp * pja[isou];
1022 
1023  pipr[isou] = pir[isou] + recoi[isou];
1024  pjpr[isou] = pjr[isou] + recoj[isou];
1025  }
1026 }
1027 
1028 /*----------------------------------------------------------------------------*/
1035 /*----------------------------------------------------------------------------*/
1036 
1037 inline static void
1039  cs_real_t *pf)
1040 {
1041  *pf = p;
1042 }
1043 
1044 /*----------------------------------------------------------------------------*/
1051 /*----------------------------------------------------------------------------*/
1052 
1053 inline static void
1055  cs_real_t pf[3])
1056 {
1057  for (int isou = 0; isou < 3; isou++)
1058  pf[isou] = p[isou];
1059 }
1060 
1061 /*----------------------------------------------------------------------------*/
1068 /*----------------------------------------------------------------------------*/
1069 
1070 inline static void
1072  cs_real_t pf[6])
1073 {
1074  for (int isou = 0; isou < 6; isou++)
1075  pf[isou] = p[isou];
1076 }
1077 
1078 /*----------------------------------------------------------------------------*/
1087 /*----------------------------------------------------------------------------*/
1088 
1089 inline static void
1090 cs_centered_f_val(const double pnd,
1091  const cs_real_t pip,
1092  const cs_real_t pjp,
1093  cs_real_t *pf)
1094 {
1095  *pf = pnd*pip + (1.-pnd)*pjp;
1096 }
1097 
1098 /*----------------------------------------------------------------------------*/
1107 /*----------------------------------------------------------------------------*/
1108 
1109 inline static void
1110 cs_centered_f_val_vector(const double pnd,
1111  const cs_real_3_t pip,
1112  const cs_real_3_t pjp,
1113  cs_real_t pf[3])
1114 {
1115  for (int isou = 0; isou < 3; isou++)
1116  pf[isou] = pnd*pip[isou] + (1.-pnd)*pjp[isou];
1117 }
1118 
1119 /*----------------------------------------------------------------------------*/
1128 /*----------------------------------------------------------------------------*/
1129 
1130 inline static void
1131 cs_centered_f_val_tensor(const double pnd,
1132  const cs_real_6_t pip,
1133  const cs_real_6_t pjp,
1134  cs_real_t pf[6])
1135 {
1136  for (int isou = 0; isou < 6; isou++)
1137  pf[isou] = pnd*pip[isou] + (1.-pnd)*pjp[isou];
1138 }
1139 
1140 /*----------------------------------------------------------------------------*/
1150 /*----------------------------------------------------------------------------*/
1151 
1152 inline static void
1154  const cs_real_3_t i_face_cog,
1155  const cs_real_3_t grad,
1156  const cs_real_t p,
1157  cs_real_t *pf)
1158 {
1159  cs_real_t df[3];
1160 
1161  df[0] = i_face_cog[0] - cell_cen[0];
1162  df[1] = i_face_cog[1] - cell_cen[1];
1163  df[2] = i_face_cog[2] - cell_cen[2];
1164 
1165  *pf = p + cs_math_3_dot_product(df, grad);
1166 }
1167 
1168 /*----------------------------------------------------------------------------*/
1178 /*----------------------------------------------------------------------------*/
1179 
1180 inline static void
1182  const cs_real_3_t i_face_cog,
1183  const cs_real_33_t grad,
1184  const cs_real_3_t p,
1185  cs_real_t pf[3])
1186 {
1187  cs_real_t df[3];
1188 
1189  for (int jsou = 0; jsou < 3; jsou++)
1190  df[jsou] = i_face_cog[jsou] - cell_cen[jsou];
1191 
1192  for (int isou = 0; isou < 3; isou++) {
1193  pf[isou] = p[isou] + df[0]*grad[isou][0]
1194  + df[1]*grad[isou][1]
1195  + df[2]*grad[isou][2];
1196 
1197  }
1198 }
1199 
1200 /*----------------------------------------------------------------------------*/
1210 /*----------------------------------------------------------------------------*/
1211 
1212 inline static void
1214  const cs_real_3_t i_face_cog,
1215  const cs_real_63_t grad,
1216  const cs_real_6_t p,
1217  cs_real_t pf[6])
1218 {
1219  cs_real_t df[3];
1220 
1221  for (int jsou = 0; jsou < 3; jsou++)
1222  df[jsou] = i_face_cog[jsou] - cell_cen[jsou];
1223 
1224  for (int isou = 0; isou < 6; isou++) {
1225  pf[isou] = p[isou] + df[0]*grad[isou][0]
1226  + df[1]*grad[isou][1]
1227  + df[2]*grad[isou][2];
1228  }
1229 }
1230 
1231 /*----------------------------------------------------------------------------*/
1241 /*----------------------------------------------------------------------------*/
1242 
1243 inline static void
1244 cs_blend_f_val(const double blencp,
1245  const cs_real_t p,
1246  cs_real_t *pf)
1247 {
1248  *pf = blencp * (*pf) + (1. - blencp) * p;
1249 }
1250 
1251 /*----------------------------------------------------------------------------*/
1261 /*----------------------------------------------------------------------------*/
1262 
1263 inline static void
1264 cs_blend_f_val_vector(const double blencp,
1265  const cs_real_3_t p,
1266  cs_real_t pf[3])
1267 {
1268  for (int isou = 0; isou < 3; isou++)
1269  pf[isou] = blencp*(pf[isou])+(1.-blencp)*p[isou];
1270 }
1271 
1272 /*----------------------------------------------------------------------------*/
1282 /*----------------------------------------------------------------------------*/
1283 
1284 inline static void
1285 cs_blend_f_val_tensor(const double blencp,
1286  const cs_real_t p[6],
1287  cs_real_t pf[6])
1288 {
1289  for (int isou = 0; isou < 6; isou++)
1290  pf[isou] = blencp*(pf[isou])+(1.-blencp)*p[isou];
1291 }
1292 
1293 /*----------------------------------------------------------------------------*/
1314 /*----------------------------------------------------------------------------*/
1315 
1316 inline static void
1317 cs_i_conv_flux(const int iconvp,
1318  const cs_real_t thetap,
1319  const int imasac,
1320  const cs_real_t pi,
1321  const cs_real_t pj,
1322  const cs_real_t pifri,
1323  const cs_real_t pifrj,
1324  const cs_real_t pjfri,
1325  const cs_real_t pjfrj,
1326  const cs_real_t i_massflux,
1327  const cs_real_t xcppi,
1328  const cs_real_t xcppj,
1329  cs_real_2_t fluxij)
1330 {
1331  cs_real_t flui, fluj;
1332 
1333  flui = 0.5*(i_massflux + fabs(i_massflux));
1334  fluj = 0.5*(i_massflux - fabs(i_massflux));
1335 
1336  fluxij[0] += iconvp*xcppi*(thetap*(flui*pifri + fluj*pjfri) - imasac*i_massflux*pi);
1337  fluxij[1] += iconvp*xcppj*(thetap*(flui*pifrj + fluj*pjfrj) - imasac*i_massflux*pj);
1338 }
1339 
1340 /*----------------------------------------------------------------------------*/
1358 /*----------------------------------------------------------------------------*/
1359 
1360 inline static void
1361 cs_i_conv_flux_vector(const int iconvp,
1362  const cs_real_t thetap,
1363  const int imasac,
1364  const cs_real_t pi[3],
1365  const cs_real_t pj[3],
1366  const cs_real_t pifri[3],
1367  const cs_real_t pifrj[3],
1368  const cs_real_t pjfri[3],
1369  const cs_real_t pjfrj[3],
1370  const cs_real_t i_massflux,
1371  cs_real_t fluxi[3],
1372  cs_real_t fluxj[3])
1373 {
1374  cs_real_t flui, fluj;
1375 
1376  flui = 0.5*(i_massflux + fabs(i_massflux));
1377  fluj = 0.5*(i_massflux - fabs(i_massflux));
1378 
1379  for (int isou = 0; isou < 3; isou++) {
1380 
1381  fluxi[isou] += iconvp*( thetap*(flui*pifri[isou] + fluj*pjfri[isou])
1382  - imasac*i_massflux*pi[isou]);
1383  fluxj[isou] += iconvp*( thetap*(flui*pifrj[isou] + fluj*pjfrj[isou])
1384  - imasac*i_massflux*pj[isou]);
1385  }
1386 }
1387 
1388 /*----------------------------------------------------------------------------*/
1406 /*----------------------------------------------------------------------------*/
1407 
1408 inline static void
1409 cs_i_conv_flux_tensor(const int iconvp,
1410  const cs_real_t thetap,
1411  const int imasac,
1412  const cs_real_t pi[6],
1413  const cs_real_t pj[6],
1414  const cs_real_t pifri[6],
1415  const cs_real_t pifrj[6],
1416  const cs_real_t pjfri[6],
1417  const cs_real_t pjfrj[6],
1418  const cs_real_t i_massflux,
1419  cs_real_t fluxi[6],
1420  cs_real_t fluxj[6])
1421 {
1422  cs_real_t flui, fluj;
1423 
1424  flui = 0.5*(i_massflux + fabs(i_massflux));
1425  fluj = 0.5*(i_massflux - fabs(i_massflux));
1426 
1427  for (int isou = 0; isou < 6; isou++) {
1428  fluxi[isou] += iconvp*( thetap*(flui*pifri[isou] + fluj*pjfri[isou])
1429  - imasac*i_massflux*pi[isou]);
1430  fluxj[isou] += iconvp*( thetap*(flui*pifrj[isou] + fluj*pjfrj[isou])
1431  - imasac*i_massflux*pj[isou]);
1432  }
1433 }
1434 
1435 /*----------------------------------------------------------------------------*/
1448 /*----------------------------------------------------------------------------*/
1449 
1450 inline static void
1451 cs_i_diff_flux(const int idiffp,
1452  const cs_real_t thetap,
1453  const cs_real_t pip,
1454  const cs_real_t pjp,
1455  const cs_real_t pipr,
1456  const cs_real_t pjpr,
1457  const cs_real_t i_visc,
1458  cs_real_t fluxij[2])
1459 {
1460  fluxij[0] += idiffp*thetap*i_visc*(pipr -pjp);
1461  fluxij[1] += idiffp*thetap*i_visc*(pip -pjpr);
1462 }
1463 
1464 /*----------------------------------------------------------------------------*/
1478 /*----------------------------------------------------------------------------*/
1479 
1480 inline static void
1481 cs_i_diff_flux_vector(const int idiffp,
1482  const cs_real_t thetap,
1483  const cs_real_t pip[3],
1484  const cs_real_t pjp[3],
1485  const cs_real_t pipr[3],
1486  const cs_real_t pjpr[3],
1487  const cs_real_t i_visc,
1488  cs_real_t fluxi[3],
1489  cs_real_t fluxj[3])
1490 {
1491  for (int isou = 0; isou < 3; isou++) {
1492  fluxi[isou] += idiffp*thetap*i_visc*(pipr[isou] -pjp[isou]);
1493  fluxj[isou] += idiffp*thetap*i_visc*(pip[isou] -pjpr[isou]);
1494  }
1495 }
1496 
1497 /*----------------------------------------------------------------------------*/
1511 /*----------------------------------------------------------------------------*/
1512 
1513 inline static void
1514 cs_i_diff_flux_tensor(const int idiffp,
1515  const cs_real_t thetap,
1516  const cs_real_t pip[6],
1517  const cs_real_t pjp[6],
1518  const cs_real_t pipr[6],
1519  const cs_real_t pjpr[6],
1520  const cs_real_t i_visc,
1521  cs_real_t fluxi[6],
1522  cs_real_t fluxj[6])
1523 {
1524  for (int isou = 0; isou < 6; isou++) {
1525  fluxi[isou] += idiffp*thetap*i_visc*(pipr[isou] -pjp[isou]);
1526  fluxj[isou] += idiffp*thetap*i_visc*(pip[isou] -pjpr[isou]);
1527  }
1528 }
1529 
1530 /*----------------------------------------------------------------------------*/
1554 /*----------------------------------------------------------------------------*/
1555 
1556 inline static void
1558  const cs_real_t relaxp,
1559  const cs_real_t diipf[3],
1560  const cs_real_t djjpf[3],
1561  const cs_real_t gradi[3],
1562  const cs_real_t gradj[3],
1563  const cs_real_t pi,
1564  const cs_real_t pj,
1565  const cs_real_t pia,
1566  const cs_real_t pja,
1567  cs_real_t *pifri,
1568  cs_real_t *pifrj,
1569  cs_real_t *pjfri,
1570  cs_real_t *pjfrj,
1571  cs_real_t *pip,
1572  cs_real_t *pjp,
1573  cs_real_t *pipr,
1574  cs_real_t *pjpr)
1575 {
1576  cs_real_t pir, pjr;
1577  cs_real_t recoi, recoj;
1578 
1579  cs_i_compute_quantities(bldfrp,
1580  diipf,
1581  djjpf,
1582  gradi,
1583  gradj,
1584  pi,
1585  pj,
1586  &recoi,
1587  &recoj,
1588  pip,
1589  pjp);
1590 
1591  cs_i_relax_c_val(relaxp,
1592  pia,
1593  pja,
1594  recoi,
1595  recoj,
1596  pi,
1597  pj,
1598  &pir,
1599  &pjr,
1600  pipr,
1601  pjpr);
1602 
1604  pifrj);
1605  cs_upwind_f_val(pir,
1606  pifri);
1607  cs_upwind_f_val(pj,
1608  pjfri);
1609  cs_upwind_f_val(pjr,
1610  pjfrj);
1611 }
1612 
1613 /*----------------------------------------------------------------------------*/
1637 /*----------------------------------------------------------------------------*/
1638 
1639 inline static void
1641  const cs_real_t relaxp,
1642  const cs_real_t diipf[3],
1643  const cs_real_t djjpf[3],
1644  const cs_real_t gradi[3][3],
1645  const cs_real_t gradj[3][3],
1646  const cs_real_t pi[3],
1647  const cs_real_t pj[3],
1648  const cs_real_t pia[3],
1649  const cs_real_t pja[3],
1650  cs_real_t pifri[3],
1651  cs_real_t pifrj[3],
1652  cs_real_t pjfri[3],
1653  cs_real_t pjfrj[3],
1654  cs_real_t pip[3],
1655  cs_real_t pjp[3],
1656  cs_real_t pipr[3],
1657  cs_real_t pjpr[3])
1658 {
1659  cs_real_t pir[3], pjr[3];
1660  cs_real_t recoi[3], recoj[3];
1661 
1663  diipf,
1664  djjpf,
1665  gradi,
1666  gradj,
1667  pi,
1668  pj,
1669  recoi,
1670  recoj,
1671  pip,
1672  pjp);
1673 
1674  cs_i_relax_c_val_vector(relaxp,
1675  pia,
1676  pja,
1677  recoi,
1678  recoj,
1679  pi,
1680  pj,
1681  pir,
1682  pjr,
1683  pipr,
1684  pjpr);
1685 
1687  pifrj);
1689  pifri);
1691  pjfri);
1693  pjfrj);
1694 }
1695 
1696 /*----------------------------------------------------------------------------*/
1720 /*----------------------------------------------------------------------------*/
1721 
1722 inline static void
1724  const cs_real_t relaxp,
1725  const cs_real_t diipf[3],
1726  const cs_real_t djjpf[3],
1727  const cs_real_t gradi[6][3],
1728  const cs_real_t gradj[6][3],
1729  const cs_real_t pi[6],
1730  const cs_real_t pj[6],
1731  const cs_real_t pia[6],
1732  const cs_real_t pja[6],
1733  cs_real_t pifri[6],
1734  cs_real_t pifrj[6],
1735  cs_real_t pjfri[6],
1736  cs_real_t pjfrj[6],
1737  cs_real_t pip[6],
1738  cs_real_t pjp[6],
1739  cs_real_t pipr[6],
1740  cs_real_t pjpr[6])
1741 {
1742  cs_real_t pir[6], pjr[6];
1743  cs_real_t recoi[6], recoj[6];
1744 
1746  diipf,
1747  djjpf,
1748  gradi,
1749  gradj,
1750  pi,
1751  pj,
1752  recoi,
1753  recoj,
1754  pip,
1755  pjp);
1756 
1757  cs_i_relax_c_val_tensor(relaxp,
1758  pia,
1759  pja,
1760  recoi,
1761  recoj,
1762  pi,
1763  pj,
1764  pir,
1765  pjr,
1766  pipr,
1767  pjpr);
1768 
1770  pifrj);
1772  pifri);
1774  pjfri);
1776  pjfrj);
1777 }
1778 
1779 /*----------------------------------------------------------------------------*/
1796 /*----------------------------------------------------------------------------*/
1797 
1798 inline static void
1800  const cs_real_t diipf[3],
1801  const cs_real_t djjpf[3],
1802  const cs_real_t gradi[3],
1803  const cs_real_t gradj[3],
1804  const cs_real_t pi,
1805  const cs_real_t pj,
1806  cs_real_t *pif,
1807  cs_real_t *pjf,
1808  cs_real_t *pip,
1809  cs_real_t *pjp)
1810 {
1811  cs_real_t recoi, recoj;
1812 
1813  cs_i_compute_quantities(bldfrp,
1814  diipf,
1815  djjpf,
1816  gradi,
1817  gradj,
1818  pi,
1819  pj,
1820  &recoi,
1821  &recoj,
1822  pip,
1823  pjp);
1824 
1825  cs_upwind_f_val(pi, pif);
1826  cs_upwind_f_val(pj, pjf);
1827 }
1828 
1829 /*----------------------------------------------------------------------------*/
1846 /*----------------------------------------------------------------------------*/
1847 
1848 inline static void
1850  const cs_real_t diipf[3],
1851  const cs_real_t djjpf[3],
1852  const cs_real_t gradi[3][3],
1853  const cs_real_t gradj[3][3],
1854  const cs_real_t pi[3],
1855  const cs_real_t pj[3],
1856  cs_real_t pif[3],
1857  cs_real_t pjf[3],
1858  cs_real_t pip[3],
1859  cs_real_t pjp[3])
1860 {
1861  cs_real_t recoi[3], recoj[3];
1862 
1864  diipf,
1865  djjpf,
1866  gradi,
1867  gradj,
1868  pi,
1869  pj,
1870  recoi,
1871  recoj,
1872  pip,
1873  pjp);
1874 
1875  cs_upwind_f_val_vector(pi, pif);
1876  cs_upwind_f_val_vector(pj, pjf);
1877 }
1878 
1879 /*----------------------------------------------------------------------------*/
1896 /*----------------------------------------------------------------------------*/
1897 
1898 inline static void
1900  const cs_real_t diipf[3],
1901  const cs_real_t djjpf[3],
1902  const cs_real_t gradi[6][3],
1903  const cs_real_t gradj[6][3],
1904  const cs_real_t pi[6],
1905  const cs_real_t pj[6],
1906  cs_real_t pif[6],
1907  cs_real_t pjf[6],
1908  cs_real_t pip[6],
1909  cs_real_t pjp[6])
1910 {
1911  cs_real_t recoi[6], recoj[6];
1912 
1914  diipf,
1915  djjpf,
1916  gradi,
1917  gradj,
1918  pi,
1919  pj,
1920  recoi,
1921  recoj,
1922  pip,
1923  pjp);
1924 
1925  cs_upwind_f_val_tensor(pi, pif);
1926  cs_upwind_f_val_tensor(pj, pjf);
1927 
1928 }
1929 
1930 /*----------------------------------------------------------------------------*/
1963 /*----------------------------------------------------------------------------*/
1964 
1965 inline static void
1967  const int ischcp,
1968  const double relaxp,
1969  const double blencp,
1970  const cs_real_t weight,
1971  const cs_real_t cell_ceni[3],
1972  const cs_real_t cell_cenj[3],
1973  const cs_real_t i_face_cog[3],
1974  const cs_real_t diipf[3],
1975  const cs_real_t djjpf[3],
1976  const cs_real_t gradi[3],
1977  const cs_real_t gradj[3],
1978  const cs_real_t gradupi[3],
1979  const cs_real_t gradupj[3],
1980  const cs_real_t pi,
1981  const cs_real_t pj,
1982  const cs_real_t pia,
1983  const cs_real_t pja,
1984  cs_real_t *pifri,
1985  cs_real_t *pifrj,
1986  cs_real_t *pjfri,
1987  cs_real_t *pjfrj,
1988  cs_real_t *pip,
1989  cs_real_t *pjp,
1990  cs_real_t *pipr,
1991  cs_real_t *pjpr)
1992 {
1993  cs_real_t pir, pjr;
1994  cs_real_t recoi, recoj;
1995 
1996  cs_i_compute_quantities(bldfrp,
1997  diipf,
1998  djjpf,
1999  gradi,
2000  gradj,
2001  pi,
2002  pj,
2003  &recoi,
2004  &recoj,
2005  pip,
2006  pjp);
2007 
2008  cs_i_relax_c_val(relaxp,
2009  pia,
2010  pja,
2011  recoi,
2012  recoj,
2013  pi,
2014  pj,
2015  &pir,
2016  &pjr,
2017  pipr,
2018  pjpr);
2019 
2020  if (ischcp == 1) {
2021 
2022  /* Centered
2023  --------*/
2024 
2025  cs_centered_f_val(weight,
2026  *pip,
2027  *pjpr,
2028  pifrj);
2029  cs_centered_f_val(weight,
2030  *pipr,
2031  *pjp,
2032  pifri);
2033  cs_centered_f_val(weight,
2034  *pipr,
2035  *pjp,
2036  pjfri);
2037  cs_centered_f_val(weight,
2038  *pip,
2039  *pjpr,
2040  pjfrj);
2041 
2042  } else if (ischcp == 0) {
2043 
2044  /* Original SOLU
2045  --------------*/
2046 
2047  cs_solu_f_val(cell_ceni,
2048  i_face_cog,
2049  gradi,
2050  pi,
2051  pifrj);
2052  cs_solu_f_val(cell_ceni,
2053  i_face_cog,
2054  gradi,
2055  pir,
2056  pifri);
2057  cs_solu_f_val(cell_cenj,
2058  i_face_cog,
2059  gradj,
2060  pj,
2061  pjfri);
2062  cs_solu_f_val(cell_cenj,
2063  i_face_cog,
2064  gradj,
2065  pjr,
2066  pjfrj);
2067 
2068  } else {
2069 
2070  /* SOLU
2071  ----*/
2072 
2073  cs_solu_f_val(cell_ceni,
2074  i_face_cog,
2075  gradupi,
2076  pi,
2077  pifrj);
2078  cs_solu_f_val(cell_ceni,
2079  i_face_cog,
2080  gradupi,
2081  pir,
2082  pifri);
2083  cs_solu_f_val(cell_cenj,
2084  i_face_cog,
2085  gradupj,
2086  pj,
2087  pjfri);
2088  cs_solu_f_val(cell_cenj,
2089  i_face_cog,
2090  gradupj,
2091  pjr,
2092  pjfrj);
2093 
2094  }
2095 
2096  /* Blending
2097  --------*/
2098 
2099  cs_blend_f_val(blencp,
2100  pi,
2101  pifrj);
2102  cs_blend_f_val(blencp,
2103  pir,
2104  pifri);
2105  cs_blend_f_val(blencp,
2106  pj,
2107  pjfri);
2108  cs_blend_f_val(blencp,
2109  pjr,
2110  pjfrj);
2111 }
2112 
2113 /*----------------------------------------------------------------------------*/
2144 /*----------------------------------------------------------------------------*/
2145 
2146 inline static void
2148  const int ischcp,
2149  const double relaxp,
2150  const double blencp,
2151  const cs_real_t weight,
2152  const cs_real_3_t cell_ceni,
2153  const cs_real_3_t cell_cenj,
2154  const cs_real_3_t i_face_cog,
2155  const cs_real_3_t diipf,
2156  const cs_real_3_t djjpf,
2157  const cs_real_33_t gradi,
2158  const cs_real_33_t gradj,
2159  const cs_real_3_t pi,
2160  const cs_real_3_t pj,
2161  const cs_real_3_t pia,
2162  const cs_real_3_t pja,
2163  cs_real_t pifri[3],
2164  cs_real_t pifrj[3],
2165  cs_real_t pjfri[3],
2166  cs_real_t pjfrj[3],
2167  cs_real_t pip[3],
2168  cs_real_t pjp[3],
2169  cs_real_t pipr[3],
2170  cs_real_t pjpr[3])
2171 {
2172  cs_real_t pir[3], pjr[3];
2173  cs_real_t recoi[3], recoj[3];
2174 
2176  diipf,
2177  djjpf,
2178  gradi,
2179  gradj,
2180  pi,
2181  pj,
2182  recoi,
2183  recoj,
2184  pip,
2185  pjp);
2186 
2187  cs_i_relax_c_val_vector(relaxp,
2188  pia,
2189  pja,
2190  recoi,
2191  recoj,
2192  pi,
2193  pj,
2194  pir,
2195  pjr,
2196  pipr,
2197  pjpr);
2198 
2199  if (ischcp == 1) {
2200 
2201  /* Centered
2202  --------*/
2203 
2204  cs_centered_f_val_vector(weight,
2205  pip,
2206  pjpr,
2207  pifrj);
2208  cs_centered_f_val_vector(weight,
2209  pipr,
2210  pjp,
2211  pifri);
2212  cs_centered_f_val_vector(weight,
2213  pipr,
2214  pjp,
2215  pjfri);
2216  cs_centered_f_val_vector(weight,
2217  pip,
2218  pjpr,
2219  pjfrj);
2220 
2221  } else {
2222 
2223  /* Second order
2224  ------------*/
2225 
2226  cs_solu_f_val_vector(cell_ceni,
2227  i_face_cog,
2228  gradi,
2229  pi,
2230  pifrj);
2231  cs_solu_f_val_vector(cell_ceni,
2232  i_face_cog,
2233  gradi,
2234  pir,
2235  pifri);
2236  cs_solu_f_val_vector(cell_cenj,
2237  i_face_cog,
2238  gradj,
2239  pj,
2240  pjfri);
2241  cs_solu_f_val_vector(cell_cenj,
2242  i_face_cog,
2243  gradj,
2244  pjr,
2245  pjfrj);
2246 
2247  }
2248 
2249  /* Blending
2250  --------*/
2251  cs_blend_f_val_vector(blencp,
2252  pi,
2253  pifrj);
2254  cs_blend_f_val_vector(blencp,
2255  pir,
2256  pifri);
2257  cs_blend_f_val_vector(blencp,
2258  pj,
2259  pjfri);
2260  cs_blend_f_val_vector(blencp,
2261  pjr,
2262  pjfrj);
2263 
2264 }
2265 
2266 /*----------------------------------------------------------------------------*/
2297 /*----------------------------------------------------------------------------*/
2298 
2299 inline static void
2301  const int ischcp,
2302  const double relaxp,
2303  const double blencp,
2304  const cs_real_t weight,
2305  const cs_real_3_t cell_ceni,
2306  const cs_real_3_t cell_cenj,
2307  const cs_real_3_t i_face_cog,
2308  const cs_real_3_t diipf,
2309  const cs_real_3_t djjpf,
2310  const cs_real_63_t gradi,
2311  const cs_real_63_t gradj,
2312  const cs_real_6_t pi,
2313  const cs_real_6_t pj,
2314  const cs_real_6_t pia,
2315  const cs_real_6_t pja,
2316  cs_real_t pifri[6],
2317  cs_real_t pifrj[6],
2318  cs_real_t pjfri[6],
2319  cs_real_t pjfrj[6],
2320  cs_real_t pip[6],
2321  cs_real_t pjp[6],
2322  cs_real_t pipr[6],
2323  cs_real_t pjpr[6])
2324 
2325 {
2326  cs_real_t pir[6], pjr[6];
2327  cs_real_t recoi[6], recoj[6];
2328 
2330  diipf,
2331  djjpf,
2332  gradi,
2333  gradj,
2334  pi,
2335  pj,
2336  recoi,
2337  recoj,
2338  pip,
2339  pjp);
2340 
2341  cs_i_relax_c_val_tensor(relaxp,
2342  pia,
2343  pja,
2344  recoi,
2345  recoj,
2346  pi,
2347  pj,
2348  pir,
2349  pjr,
2350  pipr,
2351  pjpr);
2352 
2353  if (ischcp == 1) {
2354 
2355  /* Centered
2356  --------*/
2357 
2358  cs_centered_f_val_tensor(weight,
2359  pip,
2360  pjpr,
2361  pifrj);
2362  cs_centered_f_val_tensor(weight,
2363  pipr,
2364  pjp,
2365  pifri);
2366  cs_centered_f_val_tensor(weight,
2367  pipr,
2368  pjp,
2369  pjfri);
2370  cs_centered_f_val_tensor(weight,
2371  pip,
2372  pjpr,
2373  pjfrj);
2374 
2375  } else {
2376 
2377  /* Second order
2378  ------------*/
2379 
2380  cs_solu_f_val_tensor(cell_ceni,
2381  i_face_cog,
2382  gradi,
2383  pi,
2384  pifrj);
2385  cs_solu_f_val_tensor(cell_ceni,
2386  i_face_cog,
2387  gradi,
2388  pir,
2389  pifri);
2390  cs_solu_f_val_tensor(cell_cenj,
2391  i_face_cog,
2392  gradj,
2393  pj,
2394  pjfri);
2395  cs_solu_f_val_tensor(cell_cenj,
2396  i_face_cog,
2397  gradj,
2398  pjr,
2399  pjfrj);
2400 
2401  }
2402 
2403  /* Blending
2404  --------*/
2405 
2406  cs_blend_f_val_tensor(blencp,
2407  pi,
2408  pifrj);
2409  cs_blend_f_val_tensor(blencp,
2410  pir,
2411  pifri);
2412  cs_blend_f_val_tensor(blencp,
2413  pj,
2414  pjfri);
2415  cs_blend_f_val_tensor(blencp,
2416  pjr,
2417  pjfrj);
2418 }
2419 
2420 /*----------------------------------------------------------------------------*/
2450 /*----------------------------------------------------------------------------*/
2451 
2452 inline static void
2454  const int ischcp,
2455  const double blencp,
2456  const cs_real_t weight,
2457  const cs_real_3_t cell_ceni,
2458  const cs_real_3_t cell_cenj,
2459  const cs_real_3_t i_face_cog,
2460  const cs_real_t hybrid_blend_i,
2461  const cs_real_t hybrid_blend_j,
2462  const cs_real_3_t diipf,
2463  const cs_real_3_t djjpf,
2464  const cs_real_3_t gradi,
2465  const cs_real_3_t gradj,
2466  const cs_real_3_t gradupi,
2467  const cs_real_3_t gradupj,
2468  const cs_real_t pi,
2469  const cs_real_t pj,
2470  cs_real_t *pif,
2471  cs_real_t *pjf,
2472  cs_real_t *pip,
2473  cs_real_t *pjp)
2474 {
2475  cs_real_t recoi, recoj;
2476 
2477  cs_i_compute_quantities(bldfrp,
2478  diipf,
2479  djjpf,
2480  gradi,
2481  gradj,
2482  pi,
2483  pj,
2484  &recoi,
2485  &recoj,
2486  pip,
2487  pjp);
2488 
2489 
2490  if (ischcp == 1) {
2491 
2492  /* Centered
2493  --------*/
2494 
2495  cs_centered_f_val(weight,
2496  *pip,
2497  *pjp,
2498  pif);
2499  cs_centered_f_val(weight,
2500  *pip,
2501  *pjp,
2502  pjf);
2503 
2504  } else if (ischcp == 0) {
2505 
2506  /* Legacy SOLU
2507  -----------*/
2508 
2509  cs_solu_f_val(cell_ceni,
2510  i_face_cog,
2511  gradi,
2512  pi,
2513  pif);
2514  cs_solu_f_val(cell_cenj,
2515  i_face_cog,
2516  gradj,
2517  pj,
2518  pjf);
2519 
2520  } else if (ischcp == 3) {
2521 
2522  /* Centered
2523  --------*/
2524 
2525  cs_centered_f_val(weight,
2526  *pip,
2527  *pjp,
2528  pif);
2529  cs_centered_f_val(weight,
2530  *pip,
2531  *pjp,
2532  pjf);
2533 
2534  /* Legacy SOLU
2535  -----------*/
2536  cs_real_t pif_up, pjf_up;
2537  cs_real_t hybrid_blend_interp;
2538 
2539  cs_solu_f_val(cell_ceni,
2540  i_face_cog,
2541  gradi,
2542  pi,
2543  &pif_up);
2544  cs_solu_f_val(cell_cenj,
2545  i_face_cog,
2546  gradj,
2547  pj,
2548  &pjf_up);
2549 
2550  hybrid_blend_interp = fmin(hybrid_blend_i,hybrid_blend_j);
2551  *pif = hybrid_blend_interp*(*pif) + (1. - hybrid_blend_interp)*pif_up;
2552  *pjf = hybrid_blend_interp*(*pjf) + (1. - hybrid_blend_interp)*pjf_up;
2553 
2554  } else {
2555 
2556  /* SOLU
2557  ----*/
2558 
2559  cs_solu_f_val(cell_ceni,
2560  i_face_cog,
2561  gradupi,
2562  pi,
2563  pif);
2564  cs_solu_f_val(cell_cenj,
2565  i_face_cog,
2566  gradupj,
2567  pj,
2568  pjf);
2569 
2570  }
2571 
2572 
2573  /* Blending
2574  --------*/
2575 
2576  cs_blend_f_val(blencp,
2577  pi,
2578  pif);
2579  cs_blend_f_val(blencp,
2580  pj,
2581  pjf);
2582 }
2583 
2584 /*----------------------------------------------------------------------------*/
2610 /*----------------------------------------------------------------------------*/
2611 
2612 inline static void
2614  const int ischcp,
2615  const double blencp,
2616  const cs_real_t weight,
2617  const cs_real_3_t cell_ceni,
2618  const cs_real_3_t cell_cenj,
2619  const cs_real_3_t i_face_cog,
2620  const cs_real_t hybrid_blend_i,
2621  const cs_real_t hybrid_blend_j,
2622  const cs_real_3_t diipf,
2623  const cs_real_3_t djjpf,
2624  const cs_real_33_t gradi,
2625  const cs_real_33_t gradj,
2626  const cs_real_3_t pi,
2627  const cs_real_3_t pj,
2628  cs_real_t pif[3],
2629  cs_real_t pjf[3],
2630  cs_real_t pip[3],
2631  cs_real_t pjp[3])
2632 
2633 {
2634  cs_real_t recoi[3], recoj[3];
2635 
2637  diipf,
2638  djjpf,
2639  gradi,
2640  gradj,
2641  pi,
2642  pj,
2643  recoi,
2644  recoj,
2645  pip,
2646  pjp);
2647 
2648  if (ischcp == 1) {
2649 
2650  /* Centered
2651  --------*/
2652 
2653  cs_centered_f_val_vector(weight,
2654  pip,
2655  pjp,
2656  pif);
2657  cs_centered_f_val_vector(weight,
2658  pip,
2659  pjp,
2660  pjf);
2661  } else if (ischcp == 3) {
2662 
2663  /* Centered
2664  --------*/
2665 
2666  cs_centered_f_val_vector(weight,
2667  pip,
2668  pjp,
2669  pif);
2670  cs_centered_f_val_vector(weight,
2671  pip,
2672  pjp,
2673  pjf);
2674 
2675  /* SOLU
2676  -----*/
2677  cs_real_t pif_up[3], pjf_up[3];
2678  cs_real_t hybrid_blend_interp;
2679 
2680  cs_solu_f_val_vector(cell_ceni,
2681  i_face_cog,
2682  gradi,
2683  pi,
2684  pif_up);
2685  cs_solu_f_val_vector(cell_cenj,
2686  i_face_cog,
2687  gradj,
2688  pj,
2689  pjf_up);
2690 
2691  hybrid_blend_interp = fmin(hybrid_blend_i,hybrid_blend_j);
2692  for (int isou = 0; isou < 3; isou++) {
2693  pif[isou] = hybrid_blend_interp *pif[isou]
2694  + (1. - hybrid_blend_interp)*pif_up[isou];
2695  pjf[isou] = hybrid_blend_interp *pjf[isou]
2696  + (1. - hybrid_blend_interp)*pjf_up[isou];
2697  }
2698  } else {
2699 
2700  /* Second order
2701  ------------*/
2702 
2703  cs_solu_f_val_vector(cell_ceni,
2704  i_face_cog,
2705  gradi,
2706  pi,
2707  pif);
2708  cs_solu_f_val_vector(cell_cenj,
2709  i_face_cog,
2710  gradj,
2711  pj,
2712  pjf);
2713 
2714  }
2715 
2716  /* Blending
2717  --------*/
2718 
2719  cs_blend_f_val_vector(blencp,
2720  pi,
2721  pif);
2722  cs_blend_f_val_vector(blencp,
2723  pj,
2724  pjf);
2725 
2726 }
2727 
2728 /*----------------------------------------------------------------------------*/
2752 /*----------------------------------------------------------------------------*/
2753 
2754 inline static void
2756  const int ischcp,
2757  const double blencp,
2758  const cs_real_t weight,
2759  const cs_real_3_t cell_ceni,
2760  const cs_real_3_t cell_cenj,
2761  const cs_real_3_t i_face_cog,
2762  const cs_real_3_t diipf,
2763  const cs_real_3_t djjpf,
2764  const cs_real_63_t gradi,
2765  const cs_real_63_t gradj,
2766  const cs_real_6_t pi,
2767  const cs_real_6_t pj,
2768  cs_real_t pif[6],
2769  cs_real_t pjf[6],
2770  cs_real_t pip[6],
2771  cs_real_t pjp[6])
2772 
2773 {
2774  cs_real_t recoi[6], recoj[6];
2775 
2777  diipf,
2778  djjpf,
2779  gradi,
2780  gradj,
2781  pi,
2782  pj,
2783  recoi,
2784  recoj,
2785  pip,
2786  pjp);
2787 
2788  if (ischcp == 1) {
2789 
2790  /* Centered
2791  --------*/
2792 
2793  cs_centered_f_val_tensor(weight,
2794  pip,
2795  pjp,
2796  pif);
2797  cs_centered_f_val_tensor(weight,
2798  pip,
2799  pjp,
2800  pjf);
2801 
2802  } else {
2803 
2804  /* Second order
2805  ------------*/
2806 
2807  cs_solu_f_val_tensor(cell_ceni,
2808  i_face_cog,
2809  gradi,
2810  pi,
2811  pif);
2812  cs_solu_f_val_tensor(cell_cenj,
2813  i_face_cog,
2814  gradj,
2815  pj,
2816  pjf);
2817 
2818  }
2819 
2820  /* Blending
2821  --------*/
2822 
2823  cs_blend_f_val_tensor(blencp,
2824  pi,
2825  pif);
2826  cs_blend_f_val_tensor(blencp,
2827  pj,
2828  pjf);
2829 
2830 }
2831 
2832 /*----------------------------------------------------------------------------*/
2876 /*----------------------------------------------------------------------------*/
2877 
2878 inline static void
2879 cs_i_cd_steady_slope_test(bool *upwind_switch,
2880  const int iconvp,
2881  const cs_real_t bldfrp,
2882  const int ischcp,
2883  const double relaxp,
2884  const double blencp,
2885  const double blend_st,
2886  const cs_real_t weight,
2887  const cs_real_t i_dist,
2888  const cs_real_t i_face_surf,
2889  const cs_real_3_t cell_ceni,
2890  const cs_real_3_t cell_cenj,
2891  const cs_real_3_t i_face_normal,
2892  const cs_real_3_t i_face_cog,
2893  const cs_real_3_t diipf,
2894  const cs_real_3_t djjpf,
2895  const cs_real_t i_massflux,
2896  const cs_real_3_t gradi,
2897  const cs_real_3_t gradj,
2898  const cs_real_3_t gradupi,
2899  const cs_real_3_t gradupj,
2900  const cs_real_3_t gradsti,
2901  const cs_real_3_t gradstj,
2902  const cs_real_t pi,
2903  const cs_real_t pj,
2904  const cs_real_t pia,
2905  const cs_real_t pja,
2906  cs_real_t *pifri,
2907  cs_real_t *pifrj,
2908  cs_real_t *pjfri,
2909  cs_real_t *pjfrj,
2910  cs_real_t *pip,
2911  cs_real_t *pjp,
2912  cs_real_t *pipr,
2913  cs_real_t *pjpr)
2914 {
2915  cs_real_t pir, pjr;
2916  cs_real_t recoi, recoj;
2917  cs_real_t testij, tesqck;
2918 
2919  *upwind_switch = false;
2920 
2921  cs_i_compute_quantities(bldfrp,
2922  diipf,
2923  djjpf,
2924  gradi,
2925  gradj,
2926  pi,
2927  pj,
2928  &recoi,
2929  &recoj,
2930  pip,
2931  pjp);
2932 
2933  cs_i_relax_c_val(relaxp,
2934  pia,
2935  pja,
2936  recoi,
2937  recoj,
2938  pi,
2939  pj,
2940  &pir,
2941  &pjr,
2942  pipr,
2943  pjpr);
2944 
2945  /* Convection slope test is needed only when iconv >0 */
2946  if (iconvp > 0) {
2947  cs_slope_test(pi,
2948  pj,
2949  i_dist,
2950  i_face_surf,
2951  i_face_normal,
2952  gradi,
2953  gradj,
2954  gradsti,
2955  gradstj,
2956  i_massflux,
2957  &testij,
2958  &tesqck);
2959 
2960  if (ischcp==1) {
2961 
2962  /* Centered
2963  --------*/
2964 
2965  cs_centered_f_val(weight,
2966  *pip,
2967  *pjpr,
2968  pifrj);
2969  cs_centered_f_val(weight,
2970  *pipr,
2971  *pjp,
2972  pifri);
2973  cs_centered_f_val(weight,
2974  *pipr,
2975  *pjp,
2976  pjfri);
2977  cs_centered_f_val(weight,
2978  *pip,
2979  *pjpr,
2980  pjfrj);
2981 
2982  } else if (ischcp == 0) {
2983 
2984  /* Second order
2985  ------------*/
2986 
2987  cs_solu_f_val(cell_ceni,
2988  i_face_cog,
2989  gradi,
2990  pi,
2991  pifrj);
2992  cs_solu_f_val(cell_ceni,
2993  i_face_cog,
2994  gradi,
2995  pir,
2996  pifri);
2997  cs_solu_f_val(cell_cenj,
2998  i_face_cog,
2999  gradj,
3000  pj,
3001  pjfri);
3002  cs_solu_f_val(cell_cenj,
3003  i_face_cog,
3004  gradj,
3005  pjr,
3006  pjfrj);
3007 
3008  } else {
3009 
3010  /* SOLU
3011  -----*/
3012 
3013  cs_solu_f_val(cell_ceni,
3014  i_face_cog,
3015  gradupi,
3016  pi,
3017  pifrj);
3018  cs_solu_f_val(cell_ceni,
3019  i_face_cog,
3020  gradupi,
3021  pir,
3022  pifri);
3023  cs_solu_f_val(cell_cenj,
3024  i_face_cog,
3025  gradupj,
3026  pj,
3027  pjfri);
3028  cs_solu_f_val(cell_cenj,
3029  i_face_cog,
3030  gradupj,
3031  pjr,
3032  pjfrj);
3033  }
3034 
3035 
3036  /* Slope test: Pourcentage of upwind
3037  ----------------------------------*/
3038 
3039  if (tesqck <= 0. || testij <= 0.) {
3040 
3041  cs_blend_f_val(blend_st,
3042  pi,
3043  pifrj);
3044  cs_blend_f_val(blend_st,
3045  pir,
3046  pifri);
3047  cs_blend_f_val(blend_st,
3048  pj,
3049  pjfri);
3050  cs_blend_f_val(blend_st,
3051  pjr,
3052  pjfrj);
3053 
3054  *upwind_switch = true;
3055 
3056  }
3057 
3058 
3059  /* Blending
3060  --------*/
3061 
3062  cs_blend_f_val(blencp,
3063  pi,
3064  pifrj);
3065  cs_blend_f_val(blencp,
3066  pir,
3067  pifri);
3068  cs_blend_f_val(blencp,
3069  pj,
3070  pjfri);
3071  cs_blend_f_val(blencp,
3072  pjr,
3073  pjfrj);
3074 
3075  /* If iconv=0 p*fr* are useless */
3076  } else {
3078  pifrj);
3079  cs_upwind_f_val(pir,
3080  pifri);
3081  cs_upwind_f_val(pj,
3082  pjfri);
3083  cs_upwind_f_val(pjr,
3084  pjfrj);
3085  }
3086 
3087 }
3088 
3089 /*----------------------------------------------------------------------------*/
3131 /*----------------------------------------------------------------------------*/
3132 
3133 inline static void
3135  const int iconvp,
3136  const cs_real_t bldfrp,
3137  const int ischcp,
3138  const double relaxp,
3139  const double blencp,
3140  const double blend_st,
3141  const cs_real_t weight,
3142  const cs_real_t i_dist,
3143  const cs_real_t i_face_surf,
3144  const cs_real_3_t cell_ceni,
3145  const cs_real_3_t cell_cenj,
3146  const cs_real_3_t i_face_normal,
3147  const cs_real_3_t i_face_cog,
3148  const cs_real_3_t diipf,
3149  const cs_real_3_t djjpf,
3150  const cs_real_t i_massflux,
3151  const cs_real_33_t gradi,
3152  const cs_real_33_t gradj,
3153  const cs_real_33_t grdpai,
3154  const cs_real_33_t grdpaj,
3155  const cs_real_3_t pi,
3156  const cs_real_3_t pj,
3157  const cs_real_3_t pia,
3158  const cs_real_3_t pja,
3159  cs_real_t pifri[3],
3160  cs_real_t pifrj[3],
3161  cs_real_t pjfri[3],
3162  cs_real_t pjfrj[3],
3163  cs_real_t pip[3],
3164  cs_real_t pjp[3],
3165  cs_real_t pipr[3],
3166  cs_real_t pjpr[3])
3167 {
3168  cs_real_t pir[3], pjr[3];
3169  cs_real_t recoi[3], recoj[3];
3170  cs_real_t testij, tesqck;
3171  int isou;
3172 
3174  diipf,
3175  djjpf,
3176  gradi,
3177  gradj,
3178  pi,
3179  pj,
3180  recoi,
3181  recoj,
3182  pip,
3183  pjp);
3184 
3185  cs_i_relax_c_val_vector(relaxp,
3186  pia,
3187  pja,
3188  recoi,
3189  recoj,
3190  pi,
3191  pj,
3192  pir,
3193  pjr,
3194  pipr,
3195  pjpr);
3196 
3197  /* Convection slope test is needed only when iconv >0 */
3198  if (iconvp > 0) {
3200  pj,
3201  i_dist,
3202  i_face_surf,
3203  i_face_normal,
3204  gradi,
3205  gradj,
3206  grdpai,
3207  grdpaj,
3208  i_massflux,
3209  &testij,
3210  &tesqck);
3211 
3212  for (isou = 0; isou < 3; isou++) {
3213  if (ischcp==1) {
3214 
3215  /* Centered
3216  --------*/
3217 
3218  cs_centered_f_val(weight,
3219  pip[isou],
3220  pjpr[isou],
3221  &pifrj[isou]);
3222  cs_centered_f_val(weight,
3223  pipr[isou],
3224  pjp[isou],
3225  &pifri[isou]);
3226  cs_centered_f_val(weight,
3227  pipr[isou],
3228  pjp[isou],
3229  &pjfri[isou]);
3230  cs_centered_f_val(weight,
3231  pip[isou],
3232  pjpr[isou],
3233  &pjfrj[isou]);
3234 
3235  } else {
3236 
3237  /* Second order
3238  ------------*/
3239 
3240  cs_solu_f_val(cell_ceni,
3241  i_face_cog,
3242  gradi[isou],
3243  pi[isou],
3244  &pifrj[isou]);
3245  cs_solu_f_val(cell_ceni,
3246  i_face_cog,
3247  gradi[isou],
3248  pir[isou],
3249  &pifri[isou]);
3250  cs_solu_f_val(cell_cenj,
3251  i_face_cog,
3252  gradj[isou],
3253  pj[isou],
3254  &pjfri[isou]);
3255  cs_solu_f_val(cell_cenj,
3256  i_face_cog,
3257  gradj[isou],
3258  pjr[isou],
3259  &pjfrj[isou]);
3260 
3261  }
3262 
3263  }
3264 
3265  /* Slope test: Pourcentage of upwind
3266  ----------------------------------*/
3267 
3268  if (tesqck <= 0. || testij <= 0.) {
3269  cs_blend_f_val_vector(blend_st,
3270  pi,
3271  pifrj);
3272  cs_blend_f_val_vector(blend_st,
3273  pir,
3274  pifri);
3275  cs_blend_f_val_vector(blend_st,
3276  pj,
3277  pjfri);
3278  cs_blend_f_val_vector(blend_st,
3279  pjr,
3280  pjfrj);
3281 
3282  *upwind_switch = true;
3283  }
3284 
3285 
3286  /* Blending
3287  --------*/
3288  cs_blend_f_val_vector(blencp,
3289  pi,
3290  pifrj);
3291  cs_blend_f_val_vector(blencp,
3292  pir,
3293  pifri);
3294  cs_blend_f_val_vector(blencp,
3295  pj,
3296  pjfri);
3297  cs_blend_f_val_vector(blencp,
3298  pjr,
3299  pjfrj);
3300 
3301  /* If iconv=0 p*fr* are useless */
3302  } else {
3303  for (isou = 0; isou < 3; isou++) {
3304  cs_upwind_f_val(pi[isou],
3305  &pifrj[isou]);
3306  cs_upwind_f_val(pir[isou],
3307  &pifri[isou]);
3308  cs_upwind_f_val(pj[isou],
3309  &pjfri[isou]);
3310  cs_upwind_f_val(pjr[isou],
3311  &pjfrj[isou]);
3312  }
3313  }
3314 
3315 }
3316 
3317 /*----------------------------------------------------------------------------*/
3359 /*----------------------------------------------------------------------------*/
3360 
3361 inline static void
3363  const int iconvp,
3364  const cs_real_t bldfrp,
3365  const int ischcp,
3366  const double relaxp,
3367  const double blencp,
3368  const double blend_st,
3369  const cs_real_t weight,
3370  const cs_real_t i_dist,
3371  const cs_real_t i_face_surf,
3372  const cs_real_3_t cell_ceni,
3373  const cs_real_3_t cell_cenj,
3374  const cs_real_3_t i_face_normal,
3375  const cs_real_3_t i_face_cog,
3376  const cs_real_3_t diipf,
3377  const cs_real_3_t djjpf,
3378  const cs_real_t i_massflux,
3379  const cs_real_63_t gradi,
3380  const cs_real_63_t gradj,
3381  const cs_real_63_t grdpai,
3382  const cs_real_63_t grdpaj,
3383  const cs_real_6_t pi,
3384  const cs_real_6_t pj,
3385  const cs_real_6_t pia,
3386  const cs_real_6_t pja,
3387  cs_real_t pifri[6],
3388  cs_real_t pifrj[6],
3389  cs_real_t pjfri[6],
3390  cs_real_t pjfrj[6],
3391  cs_real_t pip[6],
3392  cs_real_t pjp[6],
3393  cs_real_t pipr[6],
3394  cs_real_t pjpr[6])
3395 {
3396  cs_real_t pir[6], pjr[6];
3397  cs_real_t recoi[6], recoj[6];
3398  cs_real_t testij, tesqck;
3399  int isou;
3400 
3402  diipf,
3403  djjpf,
3404  gradi,
3405  gradj,
3406  pi,
3407  pj,
3408  recoi,
3409  recoj,
3410  pip,
3411  pjp);
3412 
3413  cs_i_relax_c_val_tensor(relaxp,
3414  pia,
3415  pja,
3416  recoi,
3417  recoj,
3418  pi,
3419  pj,
3420  pir,
3421  pjr,
3422  pipr,
3423  pjpr);
3424 
3425  /* Convection slope test is needed only when iconv >0 */
3426  if (iconvp > 0) {
3428  pj,
3429  i_dist,
3430  i_face_surf,
3431  i_face_normal,
3432  gradi,
3433  gradj,
3434  grdpai,
3435  grdpaj,
3436  i_massflux,
3437  &testij,
3438  &tesqck);
3439 
3440  for (isou = 0; isou < 6; isou++) {
3441  if (ischcp==1) {
3442 
3443  /* Centered
3444  --------*/
3445 
3446  cs_centered_f_val(weight,
3447  pip[isou],
3448  pjpr[isou],
3449  &pifrj[isou]);
3450  cs_centered_f_val(weight,
3451  pipr[isou],
3452  pjp[isou],
3453  &pifri[isou]);
3454  cs_centered_f_val(weight,
3455  pipr[isou],
3456  pjp[isou],
3457  &pjfri[isou]);
3458  cs_centered_f_val(weight,
3459  pip[isou],
3460  pjpr[isou],
3461  &pjfrj[isou]);
3462 
3463  } else {
3464 
3465  /* Second order
3466  ------------*/
3467 
3468  cs_solu_f_val(cell_ceni,
3469  i_face_cog,
3470  gradi[isou],
3471  pi[isou],
3472  &pifrj[isou]);
3473  cs_solu_f_val(cell_ceni,
3474  i_face_cog,
3475  gradi[isou],
3476  pir[isou],
3477  &pifri[isou]);
3478  cs_solu_f_val(cell_cenj,
3479  i_face_cog,
3480  gradj[isou],
3481  pj[isou],
3482  &pjfri[isou]);
3483  cs_solu_f_val(cell_cenj,
3484  i_face_cog,
3485  gradj[isou],
3486  pjr[isou],
3487  &pjfrj[isou]);
3488 
3489  }
3490 
3491  }
3492 
3493  /* Slope test: Pourcentage of upwind
3494  ----------------------------------*/
3495 
3496  if (tesqck <= 0. || testij <= 0.) {
3497 
3498  cs_blend_f_val_tensor(blend_st,
3499  pi,
3500  pifrj);
3501  cs_blend_f_val_tensor(blend_st,
3502  pir,
3503  pifri);
3504  cs_blend_f_val_tensor(blend_st,
3505  pj,
3506  pjfri);
3507  cs_blend_f_val_tensor(blend_st,
3508  pjr,
3509  pjfrj);
3510 
3511  *upwind_switch = true;
3512 
3513  }
3514 
3515 
3516  /* Blending
3517  --------*/
3518 
3519  cs_blend_f_val_tensor(blencp,
3520  pi,
3521  pifrj);
3522  cs_blend_f_val_tensor(blencp,
3523  pir,
3524  pifri);
3525  cs_blend_f_val_tensor(blencp,
3526  pj,
3527  pjfri);
3528  cs_blend_f_val_tensor(blencp,
3529  pjr,
3530  pjfrj);
3531 
3532  /* If iconv=0 p*fr* are useless */
3533  } else {
3534  for (isou = 0; isou < 6; isou++) {
3535  cs_upwind_f_val(pi[isou],
3536  &pifrj[isou]);
3537  cs_upwind_f_val(pir[isou],
3538  &pifri[isou]);
3539  cs_upwind_f_val(pj[isou],
3540  &pjfri[isou]);
3541  cs_upwind_f_val(pjr[isou],
3542  &pjfrj[isou]);
3543  }
3544  }
3545 
3546 }
3547 
3548 /*----------------------------------------------------------------------------*/
3585 /*----------------------------------------------------------------------------*/
3586 
3587 inline static void
3588 cs_i_cd_unsteady_slope_test(bool *upwind_switch,
3589  const int iconvp,
3590  const cs_real_t bldfrp,
3591  const int ischcp,
3592  const double blencp,
3593  const double blend_st,
3594  const cs_real_t weight,
3595  const cs_real_t i_dist,
3596  const cs_real_t i_face_surf,
3597  const cs_real_3_t cell_ceni,
3598  const cs_real_3_t cell_cenj,
3599  const cs_real_3_t i_face_normal,
3600  const cs_real_3_t i_face_cog,
3601  const cs_real_3_t diipf,
3602  const cs_real_3_t djjpf,
3603  const cs_real_t i_massflux,
3604  const cs_real_3_t gradi,
3605  const cs_real_3_t gradj,
3606  const cs_real_3_t gradupi,
3607  const cs_real_3_t gradupj,
3608  const cs_real_3_t gradsti,
3609  const cs_real_3_t gradstj,
3610  const cs_real_t pi,
3611  const cs_real_t pj,
3612  cs_real_t *pif,
3613  cs_real_t *pjf,
3614  cs_real_t *pip,
3615  cs_real_t *pjp)
3616 {
3617  CS_UNUSED(blend_st);
3618 
3619  cs_real_t recoi, recoj;
3620  cs_real_t testij, tesqck;
3621 
3622  *upwind_switch = false;
3623 
3624  cs_i_compute_quantities(bldfrp,
3625  diipf,
3626  djjpf,
3627  gradi,
3628  gradj,
3629  pi,
3630  pj,
3631  &recoi,
3632  &recoj,
3633  pip,
3634  pjp);
3635 
3636  /* Convection slope test is needed only when iconv >0 */
3637  if (iconvp > 0) {
3638  cs_slope_test(pi,
3639  pj,
3640  i_dist,
3641  i_face_surf,
3642  i_face_normal,
3643  gradi,
3644  gradj,
3645  gradsti,
3646  gradstj,
3647  i_massflux,
3648  &testij,
3649  &tesqck);
3650 
3651  if (ischcp==1) {
3652 
3653  /* Centered
3654  --------*/
3655 
3656  cs_centered_f_val(weight,
3657  *pip,
3658  *pjp,
3659  pif);
3660  cs_centered_f_val(weight,
3661  *pip,
3662  *pjp,
3663  pjf);
3664 
3665  } else if (ischcp == 0) {
3666 
3667  /* Original SOLU
3668  --------------*/
3669 
3670  cs_solu_f_val(cell_ceni,
3671  i_face_cog,
3672  gradi,
3673  pi,
3674  pif);
3675  cs_solu_f_val(cell_cenj,
3676  i_face_cog,
3677  gradj,
3678  pj,
3679  pjf);
3680 
3681  } else {
3682 
3683  /* SOLU
3684  -----*/
3685 
3686  cs_solu_f_val(cell_ceni,
3687  i_face_cog,
3688  gradupi,
3689  pi,
3690  pif);
3691  cs_solu_f_val(cell_cenj,
3692  i_face_cog,
3693  gradupj,
3694  pj,
3695  pjf);
3696 
3697  }
3698 
3699  /* Slope test: Pourcentage of upwind
3700  ----------------------------------*/
3701 
3702  if (tesqck<=0. || testij<=0.) {
3703 
3704  cs_blend_f_val(blend_st,
3705  pi,
3706  pif);
3707  cs_blend_f_val(blend_st,
3708  pj,
3709  pjf);
3710 
3711  *upwind_switch = true;
3712 
3713  }
3714 
3715  /* Blending
3716  --------*/
3717 
3718  cs_blend_f_val(blencp,
3719  pi,
3720  pif);
3721  cs_blend_f_val(blencp,
3722  pj,
3723  pjf);
3724 
3725  /* If iconv=0 p*f are useless */
3726  } else {
3728  pif);
3729  cs_upwind_f_val(pj,
3730  pjf);
3731  }
3732 
3733 }
3734 
3735 /*----------------------------------------------------------------------------*/
3746 /*----------------------------------------------------------------------------*/
3747 
3748 inline static void
3750  const cs_lnum_t jj,
3751  const cs_real_t i_massflux,
3752  cs_lnum_t *ic,
3753  cs_lnum_t *id)
3754 {
3755  if (i_massflux >= 0.) {
3756  *ic = ii;
3757  *id = jj;
3758  } else {
3759  *ic = jj;
3760  *id = ii;
3761  }
3762 }
3763 
3764 /*----------------------------------------------------------------------------*/
3786 /*----------------------------------------------------------------------------*/
3787 
3788 inline static void
3790  const double beta,
3791  const cs_real_3_t cell_cen_c,
3792  const cs_real_3_t cell_cen_d,
3793  const cs_real_3_t i_face_normal,
3794  const cs_real_3_t i_face_cog,
3795  const cs_real_3_t gradv_c,
3796  const cs_real_t p_c,
3797  const cs_real_t p_d,
3798  const cs_real_t local_max_c,
3799  const cs_real_t local_min_c,
3800  const cs_real_t courant_c,
3801  cs_real_t *pif,
3802  cs_real_t *pjf)
3803 {
3804  /* distance between face center and central cell center */
3805  cs_real_t dist_fc;
3806  cs_real_3_t nfc;
3807  cs_math_3_length_unitv(cell_cen_c, i_face_cog, &dist_fc, nfc);
3808 
3809  /* unit vector and distance between central and downwind cells centers */
3810  cs_real_t dist_dc;
3811  cs_real_3_t ndc;
3812  cs_math_3_length_unitv(cell_cen_c, cell_cen_d, &dist_dc, ndc);
3813 
3814  /* Place the upwind point on the line that joins
3815  the two cells on the upwind side and the same
3816  distance as that between the two cells */
3817  const cs_real_t dist_cu = dist_dc;
3818  const cs_real_t dist_du = dist_dc + dist_cu;
3819 
3820  /* Compute the property on the upwind assuming a parabolic
3821  variation of the property between the two cells */
3822  const cs_real_t gradc = cs_math_3_dot_product(gradv_c, ndc);
3823 
3824  const cs_real_t grad2c = ((p_d - p_c)/dist_dc - gradc)/dist_dc;
3825 
3826  cs_real_t p_u = p_c + (grad2c*dist_cu - gradc)*dist_cu;
3827  p_u = CS_MAX(CS_MIN(p_u, local_max_c), local_min_c);
3828 
3829  /* Compute the normalised distances */
3830  const cs_real_t nvf_r_f = (dist_fc+dist_cu)/dist_du;
3831  const cs_real_t nvf_r_c = dist_cu/dist_du;
3832 
3833  /* Check for the bounds of the NVD diagram and compute the face
3834  property according to the selected NVD scheme */
3835  const cs_real_t _small = cs_math_epzero
3836  * (CS_ABS(p_u)+CS_ABS(p_c)+CS_ABS(p_d));
3837 
3838  if (CS_ABS(p_d-p_u) <= _small) {
3839  *pif = p_c;
3840  *pjf = p_c;
3841  } else {
3842  const cs_real_t nvf_p_c = (p_c - p_u)/(p_d - p_u);
3843 
3844  if (nvf_p_c <= 0. || nvf_p_c >= 1.) {
3845  *pif = p_c;
3846  *pjf = p_c;
3847  } else {
3848  cs_real_t nvf_p_f;
3849 
3850  /* Highly compressive NVD scheme for VOF */
3851  if (limiter >= CS_NVD_VOF_HRIC) {
3852  nvf_p_f = cs_nvd_vof_scheme_scalar(limiter,
3853  i_face_normal,
3854  nvf_p_c,
3855  nvf_r_f,
3856  nvf_r_c,
3857  gradv_c,
3858  courant_c);
3859  } else { /* Regular NVD scheme */
3860  nvf_p_f = cs_nvd_scheme_scalar(limiter,
3861  nvf_p_c,
3862  nvf_r_f,
3863  nvf_r_c);
3864  }
3865 
3866  *pif = p_u + nvf_p_f*(p_d - p_u);
3867  *pif = CS_MAX(CS_MIN(*pif, local_max_c), local_min_c);
3868 
3870  p_c,
3871  pif);
3872 
3873  *pjf = *pif;
3874  }
3875  }
3876 }
3877 
3878 /*----------------------------------------------------------------------------*/
3913 /*----------------------------------------------------------------------------*/
3914 
3915 inline static void
3917  const int iconvp,
3918  const cs_real_t bldfrp,
3919  const int ischcp,
3920  const double blencp,
3921  const double blend_st,
3922  const cs_real_t weight,
3923  const cs_real_t i_dist,
3924  const cs_real_t i_face_surf,
3925  const cs_real_3_t cell_ceni,
3926  const cs_real_3_t cell_cenj,
3927  const cs_real_3_t i_face_normal,
3928  const cs_real_3_t i_face_cog,
3929  const cs_real_3_t diipf,
3930  const cs_real_3_t djjpf,
3931  const cs_real_t i_massflux,
3932  const cs_real_33_t gradi,
3933  const cs_real_33_t gradj,
3934  const cs_real_33_t grdpai,
3935  const cs_real_33_t grdpaj,
3936  const cs_real_3_t pi,
3937  const cs_real_3_t pj,
3938  cs_real_t pif[3],
3939  cs_real_t pjf[3],
3940  cs_real_t pip[3],
3941  cs_real_t pjp[3])
3942 {
3943  cs_real_t recoi[3], recoj[3];
3944  cs_real_t testij, tesqck;
3945 
3947  diipf,
3948  djjpf,
3949  gradi,
3950  gradj,
3951  pi,
3952  pj,
3953  recoi,
3954  recoj,
3955  pip,
3956  pjp);
3957 
3958  /* Convection slope test is needed only when iconv >0 */
3959  if (iconvp > 0) {
3961  pj,
3962  i_dist,
3963  i_face_surf,
3964  i_face_normal,
3965  gradi,
3966  gradj,
3967  grdpai,
3968  grdpaj,
3969  i_massflux,
3970  &testij,
3971  &tesqck);
3972 
3973  for (int isou = 0; isou < 3; isou++) {
3974  if (ischcp == 1) {
3975 
3976  /* Centered
3977  --------*/
3978 
3979  cs_centered_f_val(weight,
3980  pip[isou],
3981  pjp[isou],
3982  &pif[isou]);
3983  cs_centered_f_val(weight,
3984  pip[isou],
3985  pjp[isou],
3986  &pjf[isou]);
3987 
3988  } else {
3989 
3990  /* Second order
3991  ------------*/
3992 
3993  cs_solu_f_val(cell_ceni,
3994  i_face_cog,
3995  gradi[isou],
3996  pi[isou],
3997  &pif[isou]);
3998  cs_solu_f_val(cell_cenj,
3999  i_face_cog,
4000  gradj[isou],
4001  pj[isou],
4002  &pjf[isou]);
4003 
4004  }
4005 
4006  }
4007 
4008  /* Slope test: Pourcentage of upwind
4009  ----------------------------------*/
4010 
4011  if (tesqck <= 0. || testij <= 0.) {
4012 
4013  cs_blend_f_val_vector(blend_st,
4014  pi,
4015  pif);
4016  cs_blend_f_val_vector(blend_st,
4017  pj,
4018  pjf);
4019 
4020  *upwind_switch = true;
4021 
4022  }
4023 
4024 
4025  /* Blending
4026  --------*/
4027  cs_blend_f_val_vector(blencp,
4028  pi,
4029  pif);
4030  cs_blend_f_val_vector(blencp,
4031  pj,
4032  pjf);
4033 
4034  /* If iconv=0 p*f are useless */
4035  } else {
4036 
4037  for (int isou = 0; isou < 3; isou++) {
4038  cs_upwind_f_val(pi[isou],
4039  &pif[isou]);
4040  cs_upwind_f_val(pj[isou],
4041  &pjf[isou]);
4042 
4043  }
4044  }
4045 
4046 }
4047 
4048 /*----------------------------------------------------------------------------*/
4083 /*----------------------------------------------------------------------------*/
4084 
4085 inline static void
4087  const int iconvp,
4088  const cs_real_t bldfrp,
4089  const int ischcp,
4090  const double blencp,
4091  const double blend_st,
4092  const cs_real_t weight,
4093  const cs_real_t i_dist,
4094  const cs_real_t i_face_surf,
4095  const cs_real_3_t cell_ceni,
4096  const cs_real_3_t cell_cenj,
4097  const cs_real_3_t i_face_normal,
4098  const cs_real_3_t i_face_cog,
4099  const cs_real_3_t diipf,
4100  const cs_real_3_t djjpf,
4101  const cs_real_t i_massflux,
4102  const cs_real_63_t gradi,
4103  const cs_real_63_t gradj,
4104  const cs_real_63_t grdpai,
4105  const cs_real_63_t grdpaj,
4106  const cs_real_6_t pi,
4107  const cs_real_6_t pj,
4108  cs_real_t pif[6],
4109  cs_real_t pjf[6],
4110  cs_real_t pip[6],
4111  cs_real_t pjp[6])
4112 {
4113  cs_real_t recoi[6], recoj[6];
4114  cs_real_t testij, tesqck;
4115  int isou;
4116 
4118  diipf,
4119  djjpf,
4120  gradi,
4121  gradj,
4122  pi,
4123  pj,
4124  recoi,
4125  recoj,
4126  pip,
4127  pjp);
4128 
4129  /* Convection slope test is needed only when iconv >0 */
4130  if (iconvp > 0) {
4132  pj,
4133  i_dist,
4134  i_face_surf,
4135  i_face_normal,
4136  gradi,
4137  gradj,
4138  grdpai,
4139  grdpaj,
4140  i_massflux,
4141  &testij,
4142  &tesqck);
4143 
4144  for (isou = 0; isou < 6; isou++) {
4145 
4146  if (ischcp==1) {
4147 
4148  /* Centered
4149  --------*/
4150 
4151  cs_centered_f_val(weight,
4152  pip[isou],
4153  pjp[isou],
4154  &pif[isou]);
4155  cs_centered_f_val(weight,
4156  pip[isou],
4157  pjp[isou],
4158  &pjf[isou]);
4159 
4160  } else {
4161 
4162  /* Second order
4163  ------------*/
4164 
4165  cs_solu_f_val(cell_ceni,
4166  i_face_cog,
4167  gradi[isou],
4168  pi[isou],
4169  &pif[isou]);
4170  cs_solu_f_val(cell_cenj,
4171  i_face_cog,
4172  gradj[isou],
4173  pj[isou],
4174  &pjf[isou]);
4175  }
4176 
4177  }
4178 
4179  /* Slope test activated: poucentage of upwind */
4180  if (tesqck <= 0. || testij <= 0.) {
4181 
4182  /* Upwind
4183  --------*/
4184 
4185  cs_blend_f_val_tensor(blend_st,
4186  pi,
4187  pif);
4188  cs_blend_f_val_tensor(blend_st,
4189  pj,
4190  pjf);
4191 
4192  *upwind_switch = true;
4193  }
4194 
4195 
4196  /* Blending
4197  --------*/
4198 
4199  cs_blend_f_val_tensor(blencp,
4200  pi,
4201  pif);
4202  cs_blend_f_val_tensor(blencp,
4203  pj,
4204  pjf);
4205 
4206  /* If iconv=0 p*fr* are useless */
4207  } else {
4208 
4209  for (isou = 0; isou < 6; isou++) {
4210  cs_upwind_f_val(pi[isou],
4211  &pif[isou]);
4212  cs_upwind_f_val(pj[isou],
4213  &pjf[isou]);
4214  }
4215  }
4216 }
4217 
4218 /*----------------------------------------------------------------------------*/
4227 /*----------------------------------------------------------------------------*/
4228 
4229 inline static void
4231  const cs_real_3_t gradi,
4232  const cs_real_t bldfrp,
4233  cs_real_t *recoi)
4234 {
4235  *recoi = bldfrp * ( gradi[0]*diipb[0]
4236  + gradi[1]*diipb[1]
4237  + gradi[2]*diipb[2]);
4238 }
4239 
4240 /*----------------------------------------------------------------------------*/
4249 /*----------------------------------------------------------------------------*/
4250 
4251 inline static void
4253  const cs_real_33_t gradi,
4254  const cs_real_t bldfrp,
4255  cs_real_t recoi[3])
4256 {
4257  for (int isou = 0; isou < 3; isou++) {
4258  recoi[isou] = bldfrp * ( gradi[isou][0]*diipb[0]
4259  + gradi[isou][1]*diipb[1]
4260  + gradi[isou][2]*diipb[2]);
4261  }
4262 }
4263 
4264 /*----------------------------------------------------------------------------*/
4273 /*----------------------------------------------------------------------------*/
4274 
4275 inline static void
4277  const cs_real_63_t gradi,
4278  const cs_real_t bldfrp,
4279  cs_real_t recoi[6])
4280 {
4281  for (int isou = 0; isou < 6; isou++) {
4282  recoi[isou] = bldfrp * ( gradi[isou][0]*diipb[0]
4283  + gradi[isou][1]*diipb[1]
4284  + gradi[isou][2]*diipb[2]);
4285  }
4286 }
4287 
4288 /*----------------------------------------------------------------------------*/
4299 /*----------------------------------------------------------------------------*/
4300 
4301 inline static void
4302 cs_b_relax_c_val(const double relaxp,
4303  const cs_real_t pi,
4304  const cs_real_t pia,
4305  const cs_real_t recoi,
4306  cs_real_t *pir,
4307  cs_real_t *pipr)
4308 {
4309  *pir = pi/relaxp - (1.-relaxp)/relaxp*pia;
4310  *pipr = *pir + recoi;
4311 }
4312 
4313 /*----------------------------------------------------------------------------*/
4324 /*----------------------------------------------------------------------------*/
4325 
4326 inline static void
4327 cs_b_relax_c_val_vector(const double relaxp,
4328  const cs_real_3_t pi,
4329  const cs_real_3_t pia,
4330  const cs_real_3_t recoi,
4331  cs_real_t pir[3],
4332  cs_real_t pipr[3])
4333 {
4334  for (int isou = 0; isou < 3; isou++) {
4335  pir[isou] = pi[isou]/relaxp - (1.-relaxp)/relaxp*pia[isou];
4336  pipr[isou] = pir[isou] + recoi[isou];
4337  }
4338 }
4339 
4340 /*----------------------------------------------------------------------------*/
4351 /*----------------------------------------------------------------------------*/
4352 
4353 inline static void
4354 cs_b_relax_c_val_tensor(const double relaxp,
4355  const cs_real_6_t pi,
4356  const cs_real_6_t pia,
4357  const cs_real_6_t recoi,
4358  cs_real_t pir[6],
4359  cs_real_t pipr[6])
4360 {
4361  for (int isou = 0; isou < 6; isou++) {
4362  pir[isou] = pi[isou]/relaxp - (1.-relaxp)/relaxp*pia[isou];
4363  pipr[isou] = pir[isou] + recoi[isou];
4364  }
4365 }
4366 
4367 /*----------------------------------------------------------------------------*/
4391 /*----------------------------------------------------------------------------*/
4392 
4393 inline static void
4395  cs_real_t thetap,
4396  int imasac,
4397  int inc,
4398  int bc_type,
4399  int icvfli,
4400  cs_real_t pi,
4401  cs_real_t pir,
4402  cs_real_t pipr,
4403  cs_real_t coefap,
4404  cs_real_t coefbp,
4405  cs_real_t coface,
4406  cs_real_t cofbce,
4407  cs_real_t b_massflux,
4408  cs_real_t xcpp,
4409  cs_real_t *flux)
4410 {
4411  cs_real_t flui, fluj, pfac;
4412 
4413  /* Computed convective flux */
4414 
4415  if (icvfli == 0) {
4416 
4417  /* Remove decentering for coupled faces */
4418  if (bc_type == CS_COUPLED_FD) {
4419  flui = 0.0;
4420  fluj = b_massflux;
4421  } else {
4422  flui = 0.5*(b_massflux +fabs(b_massflux));
4423  fluj = 0.5*(b_massflux -fabs(b_massflux));
4424  }
4425 
4426  pfac = inc*coefap + coefbp*pipr;
4427  *flux += iconvp*xcpp*(thetap*(flui*pir + fluj*pfac) -imasac*( b_massflux*pi));
4428 
4429  /* Imposed convective flux */
4430 
4431  } else {
4432 
4433  pfac = inc*coface + cofbce*pipr;
4434  *flux += iconvp*xcpp*(-imasac*(b_massflux*pi) + thetap*(pfac));
4435 
4436  }
4437 }
4438 
4439 /*----------------------------------------------------------------------------*/
4461 /*----------------------------------------------------------------------------*/
4462 
4463 inline static void
4465  cs_real_t thetap,
4466  int imasac,
4467  int inc,
4468  int bc_type,
4469  int icvfli,
4470  const cs_real_t pi[restrict 3],
4471  const cs_real_t pir[restrict 3],
4472  const cs_real_t pipr[restrict 3],
4473  const cs_real_t coefap[restrict 3],
4474  const cs_real_t coefbp[restrict 3][3],
4475  const cs_real_t coface[restrict 3],
4476  const cs_real_t cofbce[restrict 3][3],
4477  cs_real_t b_massflux,
4478  cs_real_t flux[restrict 3])
4479 {
4480  cs_real_t flui, fluj, pfac;
4481 
4482  /* Computed convective flux */
4483 
4484  if (icvfli == 0) {
4485 
4486  /* Remove decentering for coupled faces */
4487  if (bc_type == CS_COUPLED_FD) {
4488  flui = 0.0;
4489  fluj = b_massflux;
4490  } else {
4491  flui = 0.5*(b_massflux +fabs(b_massflux));
4492  fluj = 0.5*(b_massflux -fabs(b_massflux));
4493  }
4494  for (int isou = 0; isou < 3; isou++) {
4495  pfac = inc*coefap[isou];
4496  for (int jsou = 0; jsou < 3; jsou++) {
4497  pfac += coefbp[isou][jsou]*pipr[jsou];
4498  }
4499  flux[isou] += iconvp*( thetap*(flui*pir[isou] + fluj*pfac)
4500  - imasac*b_massflux*pi[isou]);
4501  }
4502 
4503  /* Imposed convective flux */
4504 
4505  } else {
4506 
4507  for (int isou = 0; isou < 3; isou++) {
4508  pfac = inc*coface[isou];
4509  for (int jsou = 0; jsou < 3; jsou++) {
4510  pfac += cofbce[isou][jsou]*pipr[jsou];
4511  }
4512  flux[isou] += iconvp*( thetap*pfac
4513  - imasac*b_massflux*pi[isou]);
4514  }
4515 
4516  }
4517 }
4518 
4519 /*----------------------------------------------------------------------------*/
4539 /*----------------------------------------------------------------------------*/
4540 
4541 inline static void
4542 cs_b_upwind_flux(const int iconvp,
4543  const cs_real_t thetap,
4544  const int imasac,
4545  const int inc,
4546  const int bc_type,
4547  const cs_real_t pi,
4548  const cs_real_t pir,
4549  const cs_real_t pipr,
4550  const cs_real_t coefap,
4551  const cs_real_t coefbp,
4552  const cs_real_t b_massflux,
4553  const cs_real_t xcpp,
4554  cs_real_t *flux)
4555 {
4556  cs_real_t flui, fluj, pfac;
4557 
4558  /* Remove decentering for coupled faces */
4559  if (bc_type == CS_COUPLED_FD) {
4560  flui = 0.0;
4561  fluj = b_massflux;
4562  } else {
4563  flui = 0.5*(b_massflux +fabs(b_massflux));
4564  fluj = 0.5*(b_massflux -fabs(b_massflux));
4565  }
4566 
4567  pfac = inc*coefap + coefbp*pipr;
4568  *flux += iconvp*xcpp*(thetap*(flui*pir + fluj*pfac) -imasac*( b_massflux*pi));
4569 }
4570 
4571 /*----------------------------------------------------------------------------*/
4591 /*----------------------------------------------------------------------------*/
4592 
4593 inline static void
4594 cs_b_upwind_flux_vector(const int iconvp,
4595  const cs_real_t thetap,
4596  const int imasac,
4597  const int inc,
4598  const int bc_type,
4599  const cs_real_3_t pi,
4600  const cs_real_3_t pir,
4601  const cs_real_3_t pipr,
4602  const cs_real_3_t coefa,
4603  const cs_real_33_t coefb,
4604  const cs_real_t b_massflux,
4605  cs_real_t flux[3])
4606 {
4607  cs_real_t flui, fluj, pfac;
4608 
4609  /* Remove decentering for coupled faces */
4610  if (bc_type == CS_COUPLED_FD) {
4611  flui = 0.0;
4612  fluj = b_massflux;
4613  } else {
4614  flui = 0.5*(b_massflux +fabs(b_massflux));
4615  fluj = 0.5*(b_massflux -fabs(b_massflux));
4616  }
4617  for (int isou = 0; isou < 3; isou++) {
4618  pfac = inc*coefa[isou];
4619  for (int jsou = 0; jsou < 3; jsou++) {
4620  pfac += coefb[isou][jsou]*pipr[jsou];
4621  }
4622  flux[isou] += iconvp*( thetap*(flui*pir[isou] + fluj*pfac)
4623  - imasac*b_massflux*pi[isou]);
4624  }
4625 }
4626 
4627 /*----------------------------------------------------------------------------*/
4647 /*----------------------------------------------------------------------------*/
4648 
4649 inline static void
4650 cs_b_upwind_flux_tensor(const int iconvp,
4651  const cs_real_t thetap,
4652  const int imasac,
4653  const int inc,
4654  const int bc_type,
4655  const cs_real_6_t pi,
4656  const cs_real_6_t pir,
4657  const cs_real_6_t pipr,
4658  const cs_real_6_t coefa,
4659  const cs_real_66_t coefb,
4660  const cs_real_t b_massflux,
4661  cs_real_t flux[6])
4662 {
4663  cs_real_t flui, fluj, pfac;
4664 
4665  /* Remove decentering for coupled faces */
4666  if (bc_type == CS_COUPLED_FD) {
4667  flui = 0.0;
4668  fluj = b_massflux;
4669  } else {
4670  flui = 0.5*(b_massflux +fabs(b_massflux));
4671  fluj = 0.5*(b_massflux -fabs(b_massflux));
4672  }
4673  for (int isou = 0; isou < 6; isou++) {
4674  pfac = inc*coefa[isou];
4675  for (int jsou = 0; jsou < 6; jsou++) {
4676  pfac += coefb[isou][jsou]*pipr[jsou];
4677  }
4678  flux[isou] += iconvp*( thetap*(flui*pir[isou] + fluj*pfac)
4679  - imasac*b_massflux*pi[isou]);
4680  }
4681 }
4682 
4683 /*----------------------------------------------------------------------------*/
4696 /*----------------------------------------------------------------------------*/
4697 
4698 inline static void
4699 cs_b_diff_flux(const int idiffp,
4700  const cs_real_t thetap,
4701  const int inc,
4702  const cs_real_t pipr,
4703  const cs_real_t cofafp,
4704  const cs_real_t cofbfp,
4705  const cs_real_t b_visc,
4706  cs_real_t *flux)
4707 {
4708  cs_real_t pfacd = inc*cofafp + cofbfp*pipr;
4709  *flux += idiffp*thetap*b_visc*pfacd;
4710 }
4711 
4712 /*----------------------------------------------------------------------------*/
4725 /*----------------------------------------------------------------------------*/
4726 
4727 inline static void
4728 cs_b_diff_flux_vector(const int idiffp,
4729  const cs_real_t thetap,
4730  const int inc,
4731  const cs_real_3_t pipr,
4732  const cs_real_3_t cofaf,
4733  const cs_real_33_t cofbf,
4734  const cs_real_t b_visc,
4735  cs_real_t flux[3])
4736 {
4737  cs_real_t pfacd ;
4738  for (int isou = 0; isou < 3; isou++) {
4739  pfacd = inc*cofaf[isou];
4740  for (int jsou = 0; jsou < 3; jsou++) {
4741  pfacd += cofbf[isou][jsou]*pipr[jsou];
4742  }
4743  flux[isou] += idiffp*thetap*b_visc*pfacd;
4744  }
4745 }
4746 
4747 /*----------------------------------------------------------------------------*/
4760 /*----------------------------------------------------------------------------*/
4761 
4762 inline static void
4763 cs_b_diff_flux_tensor(const int idiffp,
4764  const cs_real_t thetap,
4765  const int inc,
4766  const cs_real_6_t pipr,
4767  const cs_real_6_t cofaf,
4768  const cs_real_66_t cofbf,
4769  const cs_real_t b_visc,
4770  cs_real_t flux[6])
4771 {
4772  cs_real_t pfacd ;
4773  for (int isou = 0; isou < 6; isou++) {
4774  pfacd = inc*cofaf[isou];
4775  for (int jsou = 0; jsou < 6; jsou++) {
4776  pfacd += cofbf[isou][jsou]*pipr[jsou];
4777  }
4778  flux[isou] += idiffp*thetap*b_visc*pfacd;
4779  }
4780 }
4781 
4782 /*----------------------------------------------------------------------------*/
4796 /*----------------------------------------------------------------------------*/
4797 
4798 inline static void
4800  const double relaxp,
4801  const cs_real_3_t diipb,
4802  const cs_real_3_t gradi,
4803  const cs_real_t pi,
4804  const cs_real_t pia,
4805  cs_real_t *pir,
4806  cs_real_t *pipr)
4807 {
4808  cs_real_t recoi;
4809 
4811  gradi,
4812  bldfrp,
4813  &recoi);
4814 
4815  cs_b_relax_c_val(relaxp,
4816  pi,
4817  pia,
4818  recoi,
4819  pir,
4820  pipr);
4821 }
4822 
4823 /*----------------------------------------------------------------------------*/
4837 /*----------------------------------------------------------------------------*/
4838 
4839 inline static void
4841  const double relaxp,
4842  const cs_real_3_t diipb,
4843  const cs_real_33_t gradi,
4844  const cs_real_3_t pi,
4845  const cs_real_3_t pia,
4846  cs_real_t pir[3],
4847  cs_real_t pipr[3])
4848 {
4849  cs_real_3_t recoi;
4850 
4852  gradi,
4853  bldfrp,
4854  recoi);
4855 
4856  cs_b_relax_c_val_vector(relaxp,
4857  pi,
4858  pia,
4859  recoi,
4860  pir,
4861  pipr);
4862 }
4863 
4864 /*----------------------------------------------------------------------------*/
4878 /*----------------------------------------------------------------------------*/
4879 
4880 inline static void
4882  const double relaxp,
4883  const cs_real_3_t diipb,
4884  const cs_real_63_t gradi,
4885  const cs_real_6_t pi,
4886  const cs_real_6_t pia,
4887  cs_real_t pir[6],
4888  cs_real_t pipr[6])
4889 {
4890  cs_real_6_t recoi;
4891 
4893  gradi,
4894  bldfrp,
4895  recoi);
4896 
4897  cs_b_relax_c_val_tensor(relaxp,
4898  pi,
4899  pia,
4900  recoi,
4901  pir,
4902  pipr);
4903 }
4904 
4905 /*----------------------------------------------------------------------------*/
4916 /*----------------------------------------------------------------------------*/
4917 
4918 inline static void
4920  const cs_real_3_t diipb,
4921  const cs_real_3_t gradi,
4922  const cs_real_t pi,
4923  cs_real_t *pip)
4924 {
4925  cs_real_t recoi;
4926 
4928  gradi,
4929  bldfrp,
4930  &recoi);
4931 
4932  *pip = pi + recoi;
4933 }
4934 
4935 /*----------------------------------------------------------------------------*/
4946 /*----------------------------------------------------------------------------*/
4947 
4948 inline static void
4950  const cs_real_3_t diipb,
4951  const cs_real_33_t gradi,
4952  const cs_real_3_t pi,
4953  cs_real_t pip[3])
4954 {
4955  cs_real_3_t recoi;
4956 
4958  gradi,
4959  bldfrp,
4960  recoi);
4961 
4962  for (int isou = 0; isou < 3; isou++)
4963  pip[isou] = pi[isou] + recoi[isou];
4964 }
4965 
4966 /*----------------------------------------------------------------------------*/
4977 /*----------------------------------------------------------------------------*/
4978 
4979 inline static void
4981  const cs_real_3_t diipb,
4982  const cs_real_63_t gradi,
4983  const cs_real_6_t pi,
4984  cs_real_t pip[6])
4985 {
4986  cs_real_6_t recoi;
4987 
4989  gradi,
4990  bldfrp,
4991  recoi);
4992 
4993  for(int isou = 0; isou< 6; isou++)
4994  pip[isou] = pi[isou] + recoi[isou];
4995 }
4996 
4997 /*----------------------------------------------------------------------------*/
5008 /*----------------------------------------------------------------------------*/
5009 
5010 inline static void
5012  cs_real_t pi,
5013  cs_real_t pj,
5014  cs_real_t b_visc,
5015  cs_real_t *fluxi)
5016 {
5017  *fluxi += idiffp*b_visc*(pi - pj);
5018 }
5019 
5020 /*----------------------------------------------------------------------------*/
5031 /*----------------------------------------------------------------------------*/
5032 
5033 inline static void
5035  const cs_real_t pi[3],
5036  const cs_real_t pj[3],
5037  cs_real_t b_visc,
5038  cs_real_t fluxi[3])
5039 {
5040  for (int k = 0; k < 3; k++)
5041  fluxi[k] += idiffp*b_visc*(pi[k] - pj[k]);
5042 }
5043 
5044 
5045 /*============================================================================
5046  * Public function prototypes for Fortran API
5047  *============================================================================*/
5048 
5049 /*----------------------------------------------------------------------------
5050  * Wrapper to cs_face_diffusion_potential
5051  *----------------------------------------------------------------------------*/
5052 
5053 void CS_PROCF (itrmas, ITRMAS)
5054 (
5055  const int *const f_id,
5056  const int *const init,
5057  const int *const inc,
5058  const int *const imrgra,
5059  const int *const iccocg,
5060  const int *const nswrgp,
5061  const int *const imligp,
5062  const int *const iphydp,
5063  const int *const iwgrp,
5064  const int *const iwarnp,
5065  const cs_real_t *const epsrgp,
5066  const cs_real_t *const climgp,
5067  const cs_real_t *const extrap,
5068  cs_real_3_t frcxt[],
5069  cs_real_t pvar[],
5070  const cs_real_t coefap[],
5071  const cs_real_t coefbp[],
5072  const cs_real_t cofafp[],
5073  const cs_real_t cofbfp[],
5074  const cs_real_t i_visc[],
5075  const cs_real_t b_visc[],
5076  cs_real_t visel[],
5077  cs_real_t i_massflux[],
5078  cs_real_t b_massflux[]
5079 );
5080 
5081 /*----------------------------------------------------------------------------
5082  * Wrapper to cs_face_anisotropic_diffusion_potential
5083  *----------------------------------------------------------------------------*/
5084 
5085 void CS_PROCF (itrmav, ITRMAV)
5086 (
5087  const int *const f_id,
5088  const int *const init,
5089  const int *const inc,
5090  const int *const imrgra,
5091  const int *const iccocg,
5092  const int *const nswrgp,
5093  const int *const imligp,
5094  const int *const ircflp,
5095  const int *const iphydp,
5096  const int *const iwgrp,
5097  const int *const iwarnp,
5098  const cs_real_t *const epsrgp,
5099  const cs_real_t *const climgp,
5100  const cs_real_t *const extrap,
5101  cs_real_3_t frcxt[],
5102  cs_real_t pvar[],
5103  const cs_real_t coefap[],
5104  const cs_real_t coefbp[],
5105  const cs_real_t cofafp[],
5106  const cs_real_t cofbfp[],
5107  const cs_real_t i_visc[],
5108  const cs_real_t b_visc[],
5109  cs_real_6_t viscel[],
5110  const cs_real_2_t weighf[],
5111  const cs_real_t weighb[],
5112  cs_real_t i_massflux[],
5113  cs_real_t b_massflux[]
5114 );
5115 
5116 /*----------------------------------------------------------------------------
5117  * Wrapper to cs_diffusion_potential
5118  *----------------------------------------------------------------------------*/
5119 
5120 void CS_PROCF (itrgrp, ITRGRP)
5121 (
5122  const int *const f_id,
5123  const int *const init,
5124  const int *const inc,
5125  const int *const imrgra,
5126  const int *const iccocg,
5127  const int *const nswrgp,
5128  const int *const imligp,
5129  const int *const iphydp,
5130  const int *const iwgrp,
5131  const int *const iwarnp,
5132  const cs_real_t *const epsrgp,
5133  const cs_real_t *const climgp,
5134  const cs_real_t *const extrap,
5135  cs_real_3_t frcxt[],
5136  cs_real_t pvar[],
5137  const cs_real_t coefap[],
5138  const cs_real_t coefbp[],
5139  const cs_real_t cofafp[],
5140  const cs_real_t cofbfp[],
5141  const cs_real_t i_visc[],
5142  const cs_real_t b_visc[],
5143  cs_real_t visel[],
5144  cs_real_t diverg[]
5145 );
5146 
5147 /*----------------------------------------------------------------------------
5148  * Wrapper to cs_anisotropic_diffusion_potential
5149  *----------------------------------------------------------------------------*/
5150 
5151 void CS_PROCF (itrgrv, ITRGRV)
5152 (
5153  const int *const f_id,
5154  const int *const init,
5155  const int *const inc,
5156  const int *const imrgra,
5157  const int *const iccocg,
5158  const int *const nswrgp,
5159  const int *const imligp,
5160  const int *const ircflp,
5161  const int *const iphydp,
5162  const int *const iwgrp,
5163  const int *const iwarnp,
5164  const cs_real_t *const epsrgp,
5165  const cs_real_t *const climgp,
5166  const cs_real_t *const extrap,
5167  cs_real_3_t frcxt[],
5168  cs_real_t pvar[],
5169  const cs_real_t coefap[],
5170  const cs_real_t coefbp[],
5171  const cs_real_t cofafp[],
5172  const cs_real_t cofbfp[],
5173  const cs_real_t i_visc[],
5174  const cs_real_t b_visc[],
5175  cs_real_6_t viscel[],
5176  const cs_real_2_t weighf[],
5177  const cs_real_t weighb[],
5178  cs_real_t diverg[]
5179 );
5180 
5181 /*=============================================================================
5182  * Public function prototypes
5183  *============================================================================*/
5184 
5185 /*----------------------------------------------------------------------------*/
5204 /*----------------------------------------------------------------------------*/
5205 
5206 void
5207 cs_slope_test_gradient(int f_id,
5208  int inc,
5209  cs_halo_type_t halo_type,
5210  const cs_real_3_t *grad,
5211  cs_real_3_t *grdpa,
5212  const cs_real_t *pvar,
5213  const cs_real_t *coefap,
5214  const cs_real_t *coefbp,
5215  const cs_real_t *i_massflux);
5216 
5217 /*----------------------------------------------------------------------------*/
5233 /*----------------------------------------------------------------------------*/
5234 
5235 void
5236 cs_upwind_gradient(const int f_id,
5237  const int inc,
5238  const cs_halo_type_t halo_type,
5239  const cs_real_t coefap[],
5240  const cs_real_t coefbp[],
5241  const cs_real_t i_massflux[],
5242  const cs_real_t b_massflux[],
5243  const cs_real_t *restrict pvar,
5244  cs_real_3_t *restrict grdpa);
5245 
5246 /*----------------------------------------------------------------------------*/
5264 /*----------------------------------------------------------------------------*/
5265 
5266 void
5267 cs_slope_test_gradient_vector(const int inc,
5268  const cs_halo_type_t halo_type,
5269  const cs_real_33_t *grad,
5270  cs_real_33_t *grdpa,
5271  const cs_real_3_t *pvar,
5272  const cs_real_3_t *coefa,
5273  const cs_real_33_t *coefb,
5274  const cs_real_t *i_massflux);
5275 
5276 /*----------------------------------------------------------------------------*/
5294 /*----------------------------------------------------------------------------*/
5295 
5296 void
5297 cs_slope_test_gradient_tensor(const int inc,
5298  const cs_halo_type_t halo_type,
5299  const cs_real_63_t *grad,
5300  cs_real_63_t *grdpa,
5301  const cs_real_6_t *pvar,
5302  const cs_real_6_t *coefa,
5303  const cs_real_66_t *coefb,
5304  const cs_real_t *i_massflux);
5305 
5306 /*----------------------------------------------------------------------------*/
5315 /*----------------------------------------------------------------------------*/
5316 
5317 void
5318 cs_beta_limiter_building(int f_id,
5319  int inc,
5320  const cs_real_t rovsdt[]);
5321 
5322 /*----------------------------------------------------------------------------*/
5374 /*----------------------------------------------------------------------------*/
5375 
5376 void
5378  int f_id,
5380  int icvflb,
5381  int inc,
5382  int iccocg,
5383  int imasac,
5384  cs_real_t *restrict pvar,
5385  const cs_real_t *restrict pvara,
5386  const int icvfli[],
5387  const cs_real_t coefap[],
5388  const cs_real_t coefbp[],
5389  const cs_real_t cofafp[],
5390  const cs_real_t cofbfp[],
5391  const cs_real_t i_massflux[],
5392  const cs_real_t b_massflux[],
5393  const cs_real_t i_visc[],
5394  const cs_real_t b_visc[],
5395  cs_real_t *restrict rhs);
5396 
5397 /*----------------------------------------------------------------------------*/
5436 /*----------------------------------------------------------------------------*/
5437 
5438 void
5440  int f_id,
5442  int icvflb,
5443  int inc,
5444  int iccocg,
5445  int imasac,
5446  cs_real_t *restrict pvar,
5447  const cs_real_t *restrict pvara,
5448  const int icvfli[],
5449  const cs_real_t coefap[],
5450  const cs_real_t coefbp[],
5451  const cs_real_t i_massflux[],
5452  const cs_real_t b_massflux[],
5453  cs_real_2_t i_conv_flux[],
5454  cs_real_t b_conv_flux[]);
5455 
5456 /*----------------------------------------------------------------------------*/
5516 /*----------------------------------------------------------------------------*/
5517 
5518 void
5520  int f_id,
5522  int icvflb,
5523  int inc,
5524  int ivisep,
5525  int imasac,
5526  cs_real_3_t *restrict pvar,
5527  const cs_real_3_t *restrict pvara,
5528  const int icvfli[],
5529  const cs_real_3_t coefav[],
5530  const cs_real_33_t coefbv[],
5531  const cs_real_3_t cofafv[],
5532  const cs_real_33_t cofbfv[],
5533  const cs_real_t i_massflux[],
5534  const cs_real_t b_massflux[],
5535  const cs_real_t i_visc[],
5536  const cs_real_t b_visc[],
5537  const cs_real_t i_secvis[],
5538  const cs_real_t b_secvis[],
5539  cs_real_3_t *restrict rhs);
5540 
5541 /*----------------------------------------------------------------------------*/
5586 /*----------------------------------------------------------------------------*/
5587 
5588 void
5590  int f_id,
5592  int icvflb,
5593  int inc,
5594  int imasac,
5595  cs_real_6_t *restrict pvar,
5596  const cs_real_6_t *restrict pvara,
5597  const cs_real_6_t coefa[],
5598  const cs_real_66_t coefb[],
5599  const cs_real_6_t cofaf[],
5600  const cs_real_66_t cofbf[],
5601  const cs_real_t i_massflux[],
5602  const cs_real_t b_massflux[],
5603  const cs_real_t i_visc[],
5604  const cs_real_t b_visc[],
5605  cs_real_6_t *restrict rhs);
5606 
5607 /*----------------------------------------------------------------------------*/
5653 /*----------------------------------------------------------------------------*/
5654 
5655 void
5657  int f_id,
5659  int inc,
5660  int iccocg,
5661  int imasac,
5662  cs_real_t *restrict pvar,
5663  const cs_real_t *restrict pvara,
5664  const cs_real_t coefap[],
5665  const cs_real_t coefbp[],
5666  const cs_real_t cofafp[],
5667  const cs_real_t cofbfp[],
5668  const cs_real_t i_massflux[],
5669  const cs_real_t b_massflux[],
5670  const cs_real_t i_visc[],
5671  const cs_real_t b_visc[],
5672  const cs_real_t xcpp[],
5673  cs_real_t *restrict rhs);
5674 
5675 /*----------------------------------------------------------------------------*/
5723 /*----------------------------------------------------------------------------*/
5724 
5725 void
5727  int f_id,
5729  int inc,
5730  int iccocg,
5731  cs_real_t *restrict pvar,
5732  const cs_real_t *restrict pvara,
5733  const cs_real_t coefap[],
5734  const cs_real_t coefbp[],
5735  const cs_real_t cofafp[],
5736  const cs_real_t cofbfp[],
5737  const cs_real_t i_visc[],
5738  const cs_real_t b_visc[],
5739  cs_real_6_t *restrict viscel,
5740  const cs_real_2_t weighf[],
5741  const cs_real_t weighb[],
5742  cs_real_t *restrict rhs);
5743 
5744 /*-----------------------------------------------------------------------------*/
5794 /*----------------------------------------------------------------------------*/
5795 
5796 void
5798  int f_id,
5800  int inc,
5801  int ivisep,
5802  cs_real_3_t *restrict pvar,
5803  const cs_real_3_t *restrict pvara,
5804  const cs_real_3_t coefav[],
5805  const cs_real_33_t coefbv[],
5806  const cs_real_3_t cofafv[],
5807  const cs_real_33_t cofbfv[],
5808  const cs_real_33_t i_visc[],
5809  const cs_real_t b_visc[],
5810  const cs_real_t i_secvis[],
5811  cs_real_3_t *restrict rhs);
5812 
5813 /*-----------------------------------------------------------------------------*/
5858 /*----------------------------------------------------------------------------*/
5859 
5860 void
5862  int f_id,
5864  int inc,
5865  cs_real_3_t *restrict pvar,
5866  const cs_real_3_t *restrict pvara,
5867  const cs_real_3_t coefav[],
5868  const cs_real_33_t coefbv[],
5869  const cs_real_3_t cofafv[],
5870  const cs_real_33_t cofbfv[],
5871  const cs_real_t i_visc[],
5872  const cs_real_t b_visc[],
5873  cs_real_6_t *restrict viscel,
5874  const cs_real_2_t weighf[],
5875  const cs_real_t weighb[],
5876  cs_real_3_t *restrict rhs);
5877 
5878 /*----------------------------------------------------------------------------*/
5922 /*----------------------------------------------------------------------------*/
5923 
5924 void
5926  int f_id,
5928  int inc,
5929  cs_real_6_t *restrict pvar,
5930  const cs_real_6_t *restrict pvara,
5931  const cs_real_6_t coefa[],
5932  const cs_real_66_t coefb[],
5933  const cs_real_6_t cofaf[],
5934  const cs_real_66_t cofbf[],
5935  const cs_real_t i_visc[],
5936  const cs_real_t b_visc[],
5937  cs_real_6_t *restrict viscel,
5938  const cs_real_2_t weighf[],
5939  const cs_real_t weighb[],
5940  cs_real_6_t *restrict rhs);
5941 
5942 /*----------------------------------------------------------------------------*/
6001 /*----------------------------------------------------------------------------*/
6002 
6003 void
6004 cs_face_diffusion_potential(const int f_id,
6005  const cs_mesh_t *m,
6006  cs_mesh_quantities_t *fvq,
6007  int init,
6008  int inc,
6009  int imrgra,
6010  int iccocg,
6011  int nswrgp,
6012  int imligp,
6013  int iphydp,
6014  int iwgrp,
6015  int iwarnp,
6016  double epsrgp,
6017  double climgp,
6018  cs_real_3_t *restrict frcxt,
6019  cs_real_t *restrict pvar,
6020  const cs_real_t coefap[],
6021  const cs_real_t coefbp[],
6022  const cs_real_t cofafp[],
6023  const cs_real_t cofbfp[],
6024  const cs_real_t i_visc[],
6025  const cs_real_t b_visc[],
6026  cs_real_t *restrict visel,
6027  cs_real_t *restrict i_massflux,
6028  cs_real_t *restrict b_massflux);
6029 
6030 /*----------------------------------------------------------------------------*/
6100 /*----------------------------------------------------------------------------*/
6101 
6102 void
6104  const cs_mesh_t *m,
6105  cs_mesh_quantities_t *fvq,
6106  int init,
6107  int inc,
6108  int imrgra,
6109  int iccocg,
6110  int nswrgp,
6111  int imligp,
6112  int ircflp,
6113  int iphydp,
6114  int iwgrp,
6115  int iwarnp,
6116  double epsrgp,
6117  double climgp,
6118  cs_real_3_t *restrict frcxt,
6119  cs_real_t *restrict pvar,
6120  const cs_real_t coefap[],
6121  const cs_real_t coefbp[],
6122  const cs_real_t cofafp[],
6123  const cs_real_t cofbfp[],
6124  const cs_real_t i_visc[],
6125  const cs_real_t b_visc[],
6126  cs_real_6_t *restrict viscel,
6127  const cs_real_2_t weighf[],
6128  const cs_real_t weighb[],
6129  cs_real_t *restrict i_massflux,
6130  cs_real_t *restrict b_massflux);
6131 
6132 /*----------------------------------------------------------------------------*/
6190 /*----------------------------------------------------------------------------*/
6191 
6192 void
6193 cs_diffusion_potential(const int f_id,
6194  const cs_mesh_t *m,
6195  cs_mesh_quantities_t *fvq,
6196  int init,
6197  int inc,
6198  int imrgra,
6199  int iccocg,
6200  int nswrgp,
6201  int imligp,
6202  int iphydp,
6203  int iwgrp,
6204  int iwarnp,
6205  double epsrgp,
6206  double climgp,
6207  cs_real_3_t *restrict frcxt,
6208  cs_real_t *restrict pvar,
6209  const cs_real_t coefap[],
6210  const cs_real_t coefbp[],
6211  const cs_real_t cofafp[],
6212  const cs_real_t cofbfp[],
6213  const cs_real_t i_visc[],
6214  const cs_real_t b_visc[],
6215  cs_real_t visel[],
6216  cs_real_t *restrict diverg);
6217 
6218 /*----------------------------------------------------------------------------*/
6289 /*----------------------------------------------------------------------------*/
6290 
6291 void
6292 cs_anisotropic_diffusion_potential(const int f_id,
6293  const cs_mesh_t *m,
6294  cs_mesh_quantities_t *fvq,
6295  int init,
6296  int inc,
6297  int imrgra,
6298  int iccocg,
6299  int nswrgp,
6300  int imligp,
6301  int ircflp,
6302  int iphydp,
6303  int iwgrp,
6304  int iwarnp,
6305  double epsrgp,
6306  double climgp,
6307  cs_real_3_t *restrict frcxt,
6308  cs_real_t *restrict pvar,
6309  const cs_real_t coefap[],
6310  const cs_real_t coefbp[],
6311  const cs_real_t cofafp[],
6312  const cs_real_t cofbfp[],
6313  const cs_real_t i_visc[],
6314  const cs_real_t b_visc[],
6315  cs_real_6_t *restrict viscel,
6316  const cs_real_2_t weighf[],
6317  const cs_real_t weighb[],
6318  cs_real_t *restrict diverg);
6319 
6320 /*----------------------------------------------------------------------------*/
6321 
6323 
6324 #endif /* __CS_CONVECTION_DIFFUSION_H__ */
static void cs_b_imposed_conv_flux(int iconvp, cs_real_t thetap, int imasac, int inc, int bc_type, int icvfli, cs_real_t pi, cs_real_t pir, cs_real_t pipr, cs_real_t coefap, cs_real_t coefbp, cs_real_t coface, cs_real_t cofbce, cs_real_t b_massflux, cs_real_t xcpp, cs_real_t *flux)
Add convective flux (substracting the mass accumulation from it) to flux at boundary face....
Definition: cs_convection_diffusion.h:4394
static void cs_centered_f_val_vector(const double pnd, const cs_real_3_t pip, const cs_real_3_t pjp, cs_real_t pf[3])
Prepare value at face ij by using a centered scheme.
Definition: cs_convection_diffusion.h:1110
void cs_anisotropic_left_diffusion_vector(int idtvar, int f_id, const cs_var_cal_opt_t var_cal_opt, int inc, int ivisep, cs_real_3_t *restrict pvar, const cs_real_3_t *restrict pvara, 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 i_secvis[], cs_real_3_t *restrict rhs)
Add explicit part of the terms of diffusion by a left-multiplying symmetric tensorial diffusivity for...
Definition: cs_convection_diffusion.c:8907
static void cs_i_compute_quantities(const cs_real_t bldfrp, const cs_real_3_t diipf, const cs_real_3_t djjpf, 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:783
static void cs_i_cd_unsteady_nvd(const cs_nvd_type_t limiter, const double beta, const cs_real_3_t cell_cen_c, const cs_real_3_t cell_cen_d, const cs_real_3_t i_face_normal, const cs_real_3_t i_face_cog, const cs_real_3_t gradv_c, const cs_real_t p_c, const cs_real_t p_d, const cs_real_t local_max_c, const cs_real_t local_min_c, const cs_real_t courant_c, cs_real_t *pif, cs_real_t *pjf)
Handle preparation of internal face values for the convection flux computation in case of an unsteady...
Definition: cs_convection_diffusion.h:3789
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:8154
static void cs_i_cd_steady_upwind(const cs_real_t bldfrp, const cs_real_t relaxp, const cs_real_t diipf[3], const cs_real_t djjpf[3], const cs_real_t gradi[3], const cs_real_t gradj[3], 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:1557
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 iwgrp, int iwarnp, double epsrgp, double climgp, 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_t *restrict visel, 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:10781
static void cs_b_imposed_conv_flux_vector(int iconvp, cs_real_t thetap, int imasac, int inc, int bc_type, int icvfli, const cs_real_t pi[restrict 3], const cs_real_t pir[restrict 3], const cs_real_t pipr[restrict 3], const cs_real_t coefap[restrict 3], const cs_real_t coefbp[restrict 3][3], const cs_real_t coface[restrict 3], const cs_real_t cofbce[restrict 3][3], cs_real_t b_massflux, cs_real_t flux[restrict 3])
Add convective flux (substracting the mass accumulation from it) to flux at boundary face....
Definition: cs_convection_diffusion.h:4464
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 iwgrp, int iwarnp, double epsrgp, double climgp, 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_t visel[], cs_real_t *restrict diverg)
Update the cell mass flux divergence with the face pressure (or pressure increment,...
Definition: cs_convection_diffusion.c:11615
static void cs_i_cd_unsteady_upwind_vector(const cs_real_t bldfrp, const cs_real_t diipf[3], const cs_real_t djjpf[3], const cs_real_t gradi[3][3], const cs_real_t gradj[3][3], const cs_real_t pi[3], const cs_real_t pj[3], cs_real_t pif[3], cs_real_t pjf[3], cs_real_t pip[3], cs_real_t pjp[3])
Handle preparation of internal face values for the fluxes computation in case of an unsteady algorith...
Definition: cs_convection_diffusion.h:1849
static void cs_blend_f_val_tensor(const double blencp, const cs_real_t p[6], cs_real_t pf[6])
Blend face values for a centered or SOLU scheme with face values for an upwind scheme.
Definition: cs_convection_diffusion.h:1285
static cs_real_t cs_nvd_scheme_scalar(const cs_nvd_type_t limiter, const cs_real_t nvf_p_c, const cs_real_t nvf_r_f, const cs_real_t nvf_r_c)
Compute the normalised face scalar using the specified NVD scheme.
Definition: cs_convection_diffusion.h:257
static void cs_b_relax_c_val_tensor(const double relaxp, const cs_real_6_t pi, const cs_real_6_t pia, const cs_real_6_t recoi, cs_real_t pir[6], cs_real_t pipr[6])
Compute relaxed values at boundary cell i.
Definition: cs_convection_diffusion.h:4354
static void cs_central_downwind_cells(const cs_lnum_t ii, const cs_lnum_t jj, const cs_real_t i_massflux, cs_lnum_t *ic, cs_lnum_t *id)
Determine the upwind and downwind sides of an internal face and matching cell indices.
Definition: cs_convection_diffusion.h:3749
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:929
void cs_slope_test_gradient_tensor(const int inc, const cs_halo_type_t halo_type, const cs_real_63_t *grad, cs_real_63_t *grdpa, const cs_real_6_t *pvar, const cs_real_6_t *coefa, const cs_real_66_t *coefb, const cs_real_t *i_massflux)
Compute the upwind gradient used in the slope tests.
Definition: cs_convection_diffusion.c:1328
static void cs_b_diff_flux_tensor(const int idiffp, const cs_real_t thetap, const int inc, const cs_real_6_t pipr, const cs_real_6_t cofaf, const cs_real_66_t cofbf, const cs_real_t b_visc, cs_real_t flux[6])
Add diffusive flux to flux at boundary face.
Definition: cs_convection_diffusion.h:4763
static void cs_slope_test_vector(const cs_real_t pi[3], const cs_real_t pj[3], const cs_real_t distf, const cs_real_t srfan, const cs_real_t i_face_normal[3], const cs_real_t gradi[3][3], const cs_real_t gradj[3][3], const cs_real_t gradsti[3][3], const cs_real_t gradstj[3][3], const cs_real_t i_massflux, cs_real_t *testij, cs_real_t *tesqck)
Compute slope test criteria at internal face between cell i and j.
Definition: cs_convection_diffusion.h:643
static void cs_i_cd_steady_tensor(const cs_real_t bldfrp, 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 diipf, const cs_real_3_t djjpf, const cs_real_63_t gradi, const cs_real_63_t gradj, const cs_real_6_t pi, const cs_real_6_t pj, const cs_real_6_t pia, const cs_real_6_t pja, cs_real_t pifri[6], cs_real_t pifrj[6], cs_real_t pjfri[6], cs_real_t pjfrj[6], cs_real_t pip[6], cs_real_t pjp[6], cs_real_t pipr[6], cs_real_t pjpr[6])
Handle preparation of internal face values for the fluxes computation in case of a steady algorithm a...
Definition: cs_convection_diffusion.h:2300
static void cs_b_cd_unsteady(const cs_real_t bldfrp, const cs_real_3_t diipb, const cs_real_3_t gradi, const cs_real_t pi, cs_real_t *pip)
Handle preparation of boundary face values for the flux computation in case of an unsteady algorithm.
Definition: cs_convection_diffusion.h:4919
static void cs_b_diff_flux(const int idiffp, const cs_real_t thetap, 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:4699
static void cs_i_conv_flux_tensor(const int iconvp, const cs_real_t thetap, const int imasac, const cs_real_t pi[6], const cs_real_t pj[6], const cs_real_t pifri[6], const cs_real_t pifrj[6], const cs_real_t pjfri[6], const cs_real_t pjfrj[6], const cs_real_t i_massflux, cs_real_t fluxi[6], cs_real_t fluxj[6])
Add convective fluxes (substracting the mass accumulation from them) to fluxes at face ij.
Definition: cs_convection_diffusion.h:1409
static void cs_b_upwind_flux(const int iconvp, const cs_real_t thetap, const int imasac, const int inc, 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, const cs_real_t xcpp, cs_real_t *flux)
Add convective flux (substracting the mass accumulation from it) to flux at boundary face....
Definition: cs_convection_diffusion.h:4542
void itrgrp(const int *const f_id, const int *const init, const int *const inc, const int *const imrgra, const int *const iccocg, const int *const nswrgp, const int *const imligp, const int *const iphydp, const int *const iwgrp, const int *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_t visel[], cs_real_t diverg[])
Definition: cs_convection_diffusion.c:750
static void cs_b_cd_steady(const cs_real_t bldfrp, 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:4799
static void cs_i_cd_steady_slope_test(bool *upwind_switch, const int iconvp, const cs_real_t bldfrp, const int ischcp, const double relaxp, const double blencp, const double blend_st, 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 diipf, const cs_real_3_t djjpf, const cs_real_t i_massflux, const cs_real_3_t gradi, const cs_real_3_t gradj, const cs_real_3_t gradupi, const cs_real_3_t gradupj, const cs_real_3_t gradsti, const cs_real_3_t gradstj, 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:2879
static void cs_b_cd_steady_vector(const cs_real_t bldfrp, const double relaxp, const cs_real_3_t diipb, const cs_real_33_t gradi, const cs_real_3_t pi, const cs_real_3_t pia, cs_real_t pir[3], cs_real_t pipr[3])
Handle preparation of boundary face values for the flux computation in case of a steady algorithm.
Definition: cs_convection_diffusion.h:4840
static void cs_solu_f_val(const cs_real_3_t cell_cen, const cs_real_3_t i_face_cog, const cs_real_3_t grad, const cs_real_t p, cs_real_t *pf)
Prepare value at face ij by using a Second Order Linear Upwind scheme.
Definition: cs_convection_diffusion.h:1153
static void cs_sync_scalar_halo(const cs_mesh_t *m, cs_halo_type_t halo_type, cs_real_t pvar[])
Definition: cs_convection_diffusion.h:96
static void cs_upwind_f_val_vector(const cs_real_3_t p, cs_real_t pf[3])
Prepare value at face ij by using an upwind scheme.
Definition: cs_convection_diffusion.h:1054
void cs_anisotropic_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 ircflp, int iphydp, int iwgrp, int iwarnp, double epsrgp, double climgp, 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:11993
static void cs_i_cd_unsteady_vector(const cs_real_t bldfrp, 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_t hybrid_blend_i, const cs_real_t hybrid_blend_j, const cs_real_3_t diipf, const cs_real_3_t djjpf, const cs_real_33_t gradi, const cs_real_33_t gradj, const cs_real_3_t pi, const cs_real_3_t pj, cs_real_t pif[3], cs_real_t pjf[3], cs_real_t pip[3], cs_real_t pjp[3])
Handle preparation of internal face values for the fluxes computation in case of an unsteady algorith...
Definition: cs_convection_diffusion.h:2613
static void cs_i_cd_steady(const cs_real_t bldfrp, const int ischcp, const double relaxp, const double blencp, const cs_real_t weight, const cs_real_t cell_ceni[3], const cs_real_t cell_cenj[3], const cs_real_t i_face_cog[3], const cs_real_t diipf[3], const cs_real_t djjpf[3], const cs_real_t gradi[3], const cs_real_t gradj[3], const cs_real_t gradupi[3], const cs_real_t gradupj[3], 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:1966
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 imasac, cs_real_t *restrict pvar, const cs_real_t *restrict pvara, const int 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:1625
static void cs_b_relax_c_val_vector(const double relaxp, const cs_real_3_t pi, const cs_real_3_t pia, const cs_real_3_t recoi, cs_real_t pir[3], cs_real_t pipr[3])
Compute relaxed values at boundary cell i.
Definition: cs_convection_diffusion.h:4327
static void cs_blend_f_val(const double blencp, const cs_real_t p, cs_real_t *pf)
Blend face values for a centered or SOLU scheme with face values for an upwind scheme.
Definition: cs_convection_diffusion.h:1244
static void cs_i_conv_flux(const int iconvp, const cs_real_t thetap, const int imasac, 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, const cs_real_t xcppi, const cs_real_t xcppj, cs_real_2_t fluxij)
Add convective fluxes (substracting the mass accumulation from them) to fluxes at face ij.
Definition: cs_convection_diffusion.h:1317
static void cs_b_cd_unsteady_tensor(const cs_real_t bldfrp, const cs_real_3_t diipb, const cs_real_63_t gradi, const cs_real_6_t pi, cs_real_t pip[6])
Handle preparation of boundary face values for the flux computation in case of a steady algorithm.
Definition: cs_convection_diffusion.h:4980
static void cs_i_diff_flux_vector(const int idiffp, const cs_real_t thetap, const cs_real_t pip[3], const cs_real_t pjp[3], const cs_real_t pipr[3], const cs_real_t pjpr[3], const cs_real_t i_visc, cs_real_t fluxi[3], cs_real_t fluxj[3])
Add diffusive fluxes to fluxes at face ij.
Definition: cs_convection_diffusion.h:1481
void itrgrv(const int *const f_id, const int *const init, const int *const inc, const int *const imrgra, const int *const iccocg, const int *const nswrgp, const int *const imligp, const int *const ircflp, const int *const iphydp, const int *const iwgrp, const int *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:812
static void cs_centered_f_val(const double pnd, const cs_real_t pip, const cs_real_t pjp, cs_real_t *pf)
Prepare value at face ij by using a centered scheme.
Definition: cs_convection_diffusion.h:1090
void cs_convection_diffusion_thermal(int idtvar, int f_id, const cs_var_cal_opt_t var_cal_opt, int inc, int iccocg, int imasac, 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_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:6820
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:4302
static void cs_b_cd_steady_tensor(const cs_real_t bldfrp, const double relaxp, const cs_real_3_t diipb, const cs_real_63_t gradi, const cs_real_6_t pi, const cs_real_6_t pia, cs_real_t pir[6], cs_real_t pipr[6])
Handle preparation of boundary face values for the flux computation in case of a steady algorithm.
Definition: cs_convection_diffusion.h:4881
static void cs_i_cd_steady_vector(const cs_real_t bldfrp, 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 diipf, const cs_real_3_t djjpf, const cs_real_33_t gradi, const cs_real_33_t gradj, const cs_real_3_t pi, const cs_real_3_t pj, const cs_real_3_t pia, const cs_real_3_t pja, cs_real_t pifri[3], cs_real_t pifrj[3], cs_real_t pjfri[3], cs_real_t pjfrj[3], cs_real_t pip[3], cs_real_t pjp[3], cs_real_t pipr[3], cs_real_t pjpr[3])
Handle preparation of internal face values for the fluxes computation in case of a steady algorithm a...
Definition: cs_convection_diffusion.h:2147
static void cs_i_cd_unsteady_upwind_tensor(const cs_real_t bldfrp, const cs_real_t diipf[3], const cs_real_t djjpf[3], const cs_real_t gradi[6][3], const cs_real_t gradj[6][3], const cs_real_t pi[6], const cs_real_t pj[6], cs_real_t pif[6], cs_real_t pjf[6], cs_real_t pip[6], cs_real_t pjp[6])
Handle preparation of internal face values for the fluxes computation in case of an unsteady algorith...
Definition: cs_convection_diffusion.h:1899
static void cs_b_diff_flux_coupling(int idiffp, cs_real_t pi, cs_real_t pj, cs_real_t b_visc, cs_real_t *fluxi)
Add diffusive flux to flux at an internal coupling face.
Definition: cs_convection_diffusion.h:5011
static void cs_b_compute_quantities_tensor(const cs_real_3_t diipb, const cs_real_63_t gradi, const cs_real_t bldfrp, cs_real_t recoi[6])
Reconstruct values in I' at boundary cell i.
Definition: cs_convection_diffusion.h:4276
static void cs_b_upwind_flux_vector(const int iconvp, const cs_real_t thetap, const int imasac, const int inc, const int bc_type, const cs_real_3_t pi, const cs_real_3_t pir, const cs_real_3_t pipr, const cs_real_3_t coefa, const cs_real_33_t coefb, const cs_real_t b_massflux, cs_real_t flux[3])
Add convective flux (substracting the mass accumulation from it) to flux at boundary face....
Definition: cs_convection_diffusion.h:4594
static void cs_i_cd_unsteady_upwind(const cs_real_t bldfrp, const cs_real_t diipf[3], const cs_real_t djjpf[3], const cs_real_t gradi[3], const cs_real_t gradj[3], const cs_real_t pi, const cs_real_t pj, cs_real_t *pif, cs_real_t *pjf, cs_real_t *pip, cs_real_t *pjp)
Handle preparation of internal face values for the fluxes computation in case of an unsteady algorith...
Definition: cs_convection_diffusion.h:1799
static void cs_b_compute_quantities_vector(const cs_real_3_t diipb, const cs_real_33_t gradi, const cs_real_t bldfrp, cs_real_t recoi[3])
Reconstruct values in I' at boundary cell i.
Definition: cs_convection_diffusion.h:4252
void cs_convection_diffusion_vector(int idtvar, int f_id, const cs_var_cal_opt_t var_cal_opt, int icvflb, int inc, int ivisep, int imasac, cs_real_3_t *restrict pvar, const cs_real_3_t *restrict pvara, const int 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 i_secvis[], const cs_real_t b_secvis[], 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:4169
static void cs_i_cd_steady_upwind_vector(const cs_real_t bldfrp, const cs_real_t relaxp, const cs_real_t diipf[3], const cs_real_t djjpf[3], const cs_real_t gradi[3][3], const cs_real_t gradj[3][3], const cs_real_t pi[3], const cs_real_t pj[3], const cs_real_t pia[3], const cs_real_t pja[3], cs_real_t pifri[3], cs_real_t pifrj[3], cs_real_t pjfri[3], cs_real_t pjfrj[3], cs_real_t pip[3], cs_real_t pjp[3], cs_real_t pipr[3], cs_real_t pjpr[3])
Handle preparation of internal face values for the fluxes computation in case of a steady algorithm a...
Definition: cs_convection_diffusion.h:1640
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_t i_face_normal[3], const cs_real_t gradi[3], const cs_real_t gradj[3], const cs_real_t grdpai[3], const cs_real_t grdpaj[3], const cs_real_t i_massflux, cs_real_t *testij, cs_real_t *tesqck)
Compute slope test criteria at internal face between cell i and j.
Definition: cs_convection_diffusion.h:577
void cs_anisotropic_right_diffusion_vector(int idtvar, int f_id, const cs_var_cal_opt_t var_cal_opt, int inc, cs_real_3_t *restrict pvar, const cs_real_3_t *restrict pvara, 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_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_3_t *restrict rhs)
Add explicit part of the terms of diffusion by a right-multiplying symmetric tensorial diffusivity fo...
Definition: cs_convection_diffusion.c:9453
static void cs_solu_f_val_tensor(const cs_real_3_t cell_cen, const cs_real_3_t i_face_cog, const cs_real_63_t grad, const cs_real_6_t p, cs_real_t pf[6])
Prepare value at face ij by using a Second Order Linear Upwind scheme.
Definition: cs_convection_diffusion.h:1213
static void cs_b_upwind_flux_tensor(const int iconvp, const cs_real_t thetap, const int imasac, const int inc, const int bc_type, const cs_real_6_t pi, const cs_real_6_t pir, const cs_real_6_t pipr, const cs_real_6_t coefa, const cs_real_66_t coefb, const cs_real_t b_massflux, cs_real_t flux[6])
Add convective flux (substracting the mass accumulation from it) to flux at boundary face....
Definition: cs_convection_diffusion.h:4650
static void cs_b_compute_quantities(const cs_real_3_t diipb, const cs_real_3_t gradi, const cs_real_t bldfrp, cs_real_t *recoi)
Reconstruct values in I' at boundary cell i.
Definition: cs_convection_diffusion.h:4230
void itrmav(const int *const f_id, const int *const init, const int *const inc, const int *const imrgra, const int *const iccocg, const int *const nswrgp, const int *const imligp, const int *const ircflp, const int *const iphydp, const int *const iwgrp, const int *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:680
static void cs_upwind_f_val_tensor(const cs_real_6_t p, cs_real_t pf[6])
Prepare value at face ij by using an upwind scheme.
Definition: cs_convection_diffusion.h:1071
static void cs_solu_f_val_vector(const cs_real_3_t cell_cen, const cs_real_3_t i_face_cog, const cs_real_33_t grad, const cs_real_3_t p, cs_real_t pf[3])
Prepare value at face ij by using a Second Order Linear Upwind scheme.
Definition: cs_convection_diffusion.h:1181
static void cs_i_cd_steady_upwind_tensor(const cs_real_t bldfrp, const cs_real_t relaxp, const cs_real_t diipf[3], const cs_real_t djjpf[3], const cs_real_t gradi[6][3], const cs_real_t gradj[6][3], const cs_real_t pi[6], const cs_real_t pj[6], const cs_real_t pia[6], const cs_real_t pja[6], cs_real_t pifri[6], cs_real_t pifrj[6], cs_real_t pjfri[6], cs_real_t pjfrj[6], cs_real_t pip[6], cs_real_t pjp[6], cs_real_t pipr[6], cs_real_t pjpr[6])
Handle preparation of internal face values for the fluxes computation in case of a steady algorithm a...
Definition: cs_convection_diffusion.h:1723
cs_nvd_type_t
Definition: cs_convection_diffusion.h:59
@ CS_NVD_SUPERBEE
Definition: cs_convection_diffusion.h:64
@ CS_NVD_SMART
Definition: cs_convection_diffusion.h:62
@ CS_NVD_CUBISTA
Definition: cs_convection_diffusion.h:63
@ CS_NVD_STOIC
Definition: cs_convection_diffusion.h:68
@ CS_NVD_WASEB
Definition: cs_convection_diffusion.h:70
@ CS_NVD_CLAM
Definition: cs_convection_diffusion.h:67
@ CS_NVD_OSHER
Definition: cs_convection_diffusion.h:69
@ CS_NVD_VOF_CICSAM
Definition: cs_convection_diffusion.h:72
@ CS_NVD_VOF_STACS
Definition: cs_convection_diffusion.h:73
@ CS_NVD_GAMMA
Definition: cs_convection_diffusion.h:61
@ CS_NVD_MINMOD
Definition: cs_convection_diffusion.h:66
@ CS_NVD_VOF_HRIC
Definition: cs_convection_diffusion.h:71
@ CS_NVD_MUSCL
Definition: cs_convection_diffusion.h:65
@ CS_NVD_N_TYPES
Definition: cs_convection_diffusion.h:74
static void cs_i_relax_c_val_tensor(const cs_real_t relaxp, const cs_real_t pia[6], const cs_real_t pja[6], const cs_real_t recoi[6], const cs_real_t recoj[6], const cs_real_t pi[6], const cs_real_t pj[6], cs_real_t pir[6], cs_real_t pjr[6], cs_real_t pipr[6], cs_real_t pjpr[6])
Compute relaxed values at cell i and j.
Definition: cs_convection_diffusion.h:1007
static void cs_b_cd_unsteady_vector(const cs_real_t bldfrp, const cs_real_3_t diipb, const cs_real_33_t gradi, const cs_real_3_t pi, cs_real_t pip[3])
Handle preparation of boundary face values for the flux computation in case of a steady algorithm.
Definition: cs_convection_diffusion.h:4949
static void cs_slope_test_tensor(const cs_real_t pi[6], const cs_real_t pj[6], const cs_real_t distf, const cs_real_t srfan, const cs_real_t i_face_normal[3], const cs_real_t gradi[6][3], const cs_real_t gradj[6][3], const cs_real_t gradsti[6][3], const cs_real_t gradstj[6][3], const cs_real_t i_massflux, cs_real_t *testij, cs_real_t *tesqck)
Compute slope test criteria at internal face between cell i and j.
Definition: cs_convection_diffusion.h:713
void cs_convection_diffusion_tensor(int idtvar, int f_id, const cs_var_cal_opt_t var_cal_opt, int icvflb, int inc, int imasac, cs_real_6_t *restrict pvar, const cs_real_6_t *restrict pvara, const cs_real_6_t coefa[], const cs_real_66_t coefb[], const cs_real_6_t cofaf[], const cs_real_66_t cofbf[], 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_6_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:5857
static void cs_i_cd_steady_slope_test_tensor(bool *upwind_switch, const int iconvp, const cs_real_t bldfrp, const int ischcp, const double relaxp, const double blencp, const double blend_st, 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 diipf, const cs_real_3_t djjpf, const cs_real_t i_massflux, const cs_real_63_t gradi, const cs_real_63_t gradj, const cs_real_63_t grdpai, const cs_real_63_t grdpaj, const cs_real_6_t pi, const cs_real_6_t pj, const cs_real_6_t pia, const cs_real_6_t pja, cs_real_t pifri[6], cs_real_t pifrj[6], cs_real_t pjfri[6], cs_real_t pjfrj[6], cs_real_t pip[6], cs_real_t pjp[6], cs_real_t pipr[6], cs_real_t pjpr[6])
Handle preparation of internal face values for the fluxes computation in case of a steady algorithm a...
Definition: cs_convection_diffusion.h:3362
static void cs_i_compute_quantities_tensor(const cs_real_t bldfrp, const cs_real_3_t diipf, const cs_real_3_t djjpf, const cs_real_63_t gradi, const cs_real_63_t gradj, const cs_real_6_t pi, const cs_real_6_t pj, cs_real_t recoi[6], cs_real_t recoj[6], cs_real_t pip[6], cs_real_t pjp[6])
Reconstruct values in I' and J'.
Definition: cs_convection_diffusion.h:877
static void cs_i_diff_flux_tensor(const int idiffp, const cs_real_t thetap, const cs_real_t pip[6], const cs_real_t pjp[6], const cs_real_t pipr[6], const cs_real_t pjpr[6], const cs_real_t i_visc, cs_real_t fluxi[6], cs_real_t fluxj[6])
Add diffusive fluxes to fluxes at face ij.
Definition: cs_convection_diffusion.h:1514
static void cs_centered_f_val_tensor(const double pnd, const cs_real_6_t pip, const cs_real_6_t pjp, cs_real_t pf[6])
Prepare value at face ij by using a centered scheme.
Definition: cs_convection_diffusion.h:1131
void cs_slope_test_gradient_vector(const int inc, const cs_halo_type_t halo_type, const cs_real_33_t *grad, cs_real_33_t *grdpa, const cs_real_3_t *pvar, const cs_real_3_t *coefa, const cs_real_33_t *coefb, const cs_real_t *i_massflux)
Compute the upwind gradient used in the slope tests.
Definition: cs_convection_diffusion.c:1173
static void cs_i_cd_unsteady(const cs_real_t bldfrp, 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_t hybrid_blend_i, const cs_real_t hybrid_blend_j, const cs_real_3_t diipf, const cs_real_3_t djjpf, const cs_real_3_t gradi, const cs_real_3_t gradj, const cs_real_3_t gradupi, const cs_real_3_t gradupj, const cs_real_t pi, const cs_real_t pj, cs_real_t *pif, cs_real_t *pjf, cs_real_t *pip, cs_real_t *pjp)
Handle preparation of internal face values for the fluxes computation in case of a unsteady algorithm...
Definition: cs_convection_diffusion.h:2453
void cs_face_convection_scalar(int idtvar, int f_id, const cs_var_cal_opt_t var_cal_opt, int icvflb, int inc, int iccocg, int imasac, cs_real_t *restrict pvar, const cs_real_t *restrict pvara, const int icvfli[], const cs_real_t coefap[], const cs_real_t coefbp[], const cs_real_t i_massflux[], const cs_real_t b_massflux[], cs_real_2_t i_conv_flux[], cs_real_t b_conv_flux[])
Update face flux with convection contribution of a standard transport equation of a scalar field .
Definition: cs_convection_diffusion.c:3058
static void cs_i_cd_unsteady_slope_test_vector(bool *upwind_switch, const int iconvp, const cs_real_t bldfrp, const int ischcp, const double blencp, const double blend_st, 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 diipf, const cs_real_3_t djjpf, const cs_real_t i_massflux, const cs_real_33_t gradi, const cs_real_33_t gradj, const cs_real_33_t grdpai, const cs_real_33_t grdpaj, const cs_real_3_t pi, const cs_real_3_t pj, cs_real_t pif[3], cs_real_t pjf[3], cs_real_t pip[3], cs_real_t pjp[3])
Handle preparation of internal face values for the fluxes computation in case of a unsteady algorithm...
Definition: cs_convection_diffusion.h:3916
static void cs_b_diff_flux_coupling_vector(int idiffp, const cs_real_t pi[3], const cs_real_t pj[3], cs_real_t b_visc, cs_real_t fluxi[3])
Add diffusive flux to flux at an internal coupling face for a vector.
Definition: cs_convection_diffusion.h:5034
static void cs_blend_f_val_vector(const double blencp, const cs_real_3_t p, cs_real_t pf[3])
Blend face values for a centered or SOLU scheme with face values for an upwind scheme.
Definition: cs_convection_diffusion.h:1264
static void cs_i_compute_quantities_vector(const cs_real_t bldfrp, const cs_real_3_t diipf, const cs_real_3_t djjpf, const cs_real_33_t gradi, const cs_real_33_t gradj, const cs_real_3_t pi, const cs_real_3_t pj, cs_real_t recoi[3], cs_real_t recoj[3], cs_real_t pip[3], cs_real_t pjp[3])
Reconstruct values in I' and J'.
Definition: cs_convection_diffusion.h:825
void cs_face_anisotropic_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 ircflp, int iphydp, int iwgrp, int iwarnp, double epsrgp, double climgp, 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:11130
static void cs_i_cd_unsteady_slope_test(bool *upwind_switch, const int iconvp, const cs_real_t bldfrp, const int ischcp, const double blencp, const double blend_st, 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 diipf, const cs_real_3_t djjpf, const cs_real_t i_massflux, const cs_real_3_t gradi, const cs_real_3_t gradj, const cs_real_3_t gradupi, const cs_real_3_t gradupj, const cs_real_3_t gradsti, const cs_real_3_t gradstj, const cs_real_t pi, const cs_real_t pj, cs_real_t *pif, cs_real_t *pjf, cs_real_t *pip, cs_real_t *pjp)
Handle preparation of internal face values for the fluxes computation in case of a steady algorithm a...
Definition: cs_convection_diffusion.h:3588
static void cs_i_cd_steady_slope_test_vector(bool *upwind_switch, const int iconvp, const cs_real_t bldfrp, const int ischcp, const double relaxp, const double blencp, const double blend_st, 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 diipf, const cs_real_3_t djjpf, const cs_real_t i_massflux, const cs_real_33_t gradi, const cs_real_33_t gradj, const cs_real_33_t grdpai, const cs_real_33_t grdpaj, const cs_real_3_t pi, const cs_real_3_t pj, const cs_real_3_t pia, const cs_real_3_t pja, cs_real_t pifri[3], cs_real_t pifrj[3], cs_real_t pjfri[3], cs_real_t pjfrj[3], cs_real_t pip[3], cs_real_t pjp[3], cs_real_t pipr[3], cs_real_t pjpr[3])
Handle preparation of internal face values for the fluxes computation in case of a steady algorithm a...
Definition: cs_convection_diffusion.h:3134
void itrmas(const int *const f_id, const int *const init, const int *const inc, const int *const imrgra, const int *const iccocg, const int *const nswrgp, const int *const imligp, const int *const iphydp, const int *const iwgrp, const int *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_t visel[], cs_real_t i_massflux[], cs_real_t b_massflux[])
Definition: cs_convection_diffusion.c:616
static void cs_upwind_f_val(const cs_real_t p, cs_real_t *pf)
Prepare value at face ij by using an upwind scheme.
Definition: cs_convection_diffusion.h:1038
static cs_real_t * cs_get_v_slope_test(int f_id, const cs_var_cal_opt_t var_cal_opt)
Definition: cs_convection_diffusion.h:116
static void cs_i_cd_unsteady_slope_test_tensor(bool *upwind_switch, const int iconvp, const cs_real_t bldfrp, const int ischcp, const double blencp, const double blend_st, 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 diipf, const cs_real_3_t djjpf, const cs_real_t i_massflux, const cs_real_63_t gradi, const cs_real_63_t gradj, const cs_real_63_t grdpai, const cs_real_63_t grdpaj, const cs_real_6_t pi, const cs_real_6_t pj, cs_real_t pif[6], cs_real_t pjf[6], cs_real_t pip[6], cs_real_t pjp[6])
Handle preparation of internal face values for the fluxes computation in case of a unsteady algorithm...
Definition: cs_convection_diffusion.h:4086
static void cs_i_diff_flux(const int idiffp, const cs_real_t thetap, 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_t fluxij[2])
Add diffusive fluxes to fluxes at face ij.
Definition: cs_convection_diffusion.h:1451
static void cs_i_conv_flux_vector(const int iconvp, const cs_real_t thetap, const int imasac, const cs_real_t pi[3], const cs_real_t pj[3], const cs_real_t pifri[3], const cs_real_t pifrj[3], const cs_real_t pjfri[3], const cs_real_t pjfrj[3], const cs_real_t i_massflux, cs_real_t fluxi[3], cs_real_t fluxj[3])
Add convective fluxes (substracting the mass accumulation from them) to fluxes at face ij.
Definition: cs_convection_diffusion.h:1361
void cs_slope_test_gradient(int f_id, int inc, cs_halo_type_t halo_type, const cs_real_3_t *grad, cs_real_3_t *grdpa, const 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.c:901
static cs_real_t cs_nvd_vof_scheme_scalar(const cs_nvd_type_t limiter, const cs_real_3_t i_face_normal, const cs_real_t nvf_p_c, const cs_real_t nvf_r_f, const cs_real_t nvf_r_c, const cs_real_3_t gradv_c, const cs_real_t c_courant)
Compute the normalised face scalar using the specified NVD scheme for the case of a Volume-of-Fluid (...
Definition: cs_convection_diffusion.h:442
void cs_beta_limiter_building(int f_id, int inc, const cs_real_t rovsdt[])
Compute the beta blending coefficient of the beta limiter (ensuring preservation of a given min/max p...
Definition: cs_convection_diffusion.c:1474
static void cs_b_diff_flux_vector(const int idiffp, const cs_real_t thetap, const int inc, const cs_real_3_t pipr, const cs_real_3_t cofaf, const cs_real_33_t cofbf, const cs_real_t b_visc, cs_real_t flux[3])
Add diffusive flux to flux at boundary face.
Definition: cs_convection_diffusion.h:4728
void cs_anisotropic_diffusion_tensor(int idtvar, int f_id, const cs_var_cal_opt_t var_cal_opt, int inc, cs_real_6_t *restrict pvar, const cs_real_6_t *restrict pvara, const cs_real_6_t coefa[], const cs_real_66_t coefb[], const cs_real_6_t cofaf[], const cs_real_66_t cofbf[], 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_6_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:10164
static void cs_cell_courant_number(const int f_id, cs_real_t *courant)
Definition: cs_convection_diffusion.h:164
static void cs_i_relax_c_val_vector(const double relaxp, const cs_real_3_t pia, const cs_real_3_t pja, const cs_real_3_t recoi, const cs_real_3_t recoj, const cs_real_3_t pi, const cs_real_3_t pj, cs_real_t pir[3], cs_real_t pjr[3], cs_real_t pipr[3], cs_real_t pjpr[3])
Compute relaxed values at cell i and j.
Definition: cs_convection_diffusion.h:967
static void cs_i_cd_unsteady_tensor(const cs_real_t bldfrp, 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 diipf, const cs_real_3_t djjpf, const cs_real_63_t gradi, const cs_real_63_t gradj, const cs_real_6_t pi, const cs_real_6_t pj, cs_real_t pif[6], cs_real_t pjf[6], cs_real_t pip[6], cs_real_t pjp[6])
Handle preparation of internal face values for the fluxes computation in case of an unsteady algorith...
Definition: cs_convection_diffusion.h:2755
void cs_upwind_gradient(const int f_id, const int inc, const cs_halo_type_t halo_type, const cs_real_t coefap[], const cs_real_t coefbp[], const cs_real_t i_massflux[], const cs_real_t b_massflux[], const cs_real_t *restrict pvar, cs_real_3_t *restrict grdpa)
Compute the upwind gradient in order to cope with SOLU schemes observed in the litterature.
Definition: cs_convection_diffusion.c:1043
#define restrict
Definition: cs_defs.h:139
#define BEGIN_C_DECLS
Definition: cs_defs.h:507
double cs_real_t
Floating-point value.
Definition: cs_defs.h:319
#define CS_MIN(a, b)
Definition: cs_defs.h:470
cs_lnum_t cs_lnum_2_t[2]
vector of 2 local mesh-entity ids
Definition: cs_defs.h:325
#define CS_ABS(a)
Definition: cs_defs.h:469
#define CS_MAX(a, b)
Definition: cs_defs.h:471
#define CS_PROCF(x, y)
Definition: cs_defs.h:521
cs_real_t cs_real_66_t[6][6]
6x6 matrix of floating-point values
Definition: cs_defs.h:340
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:332
cs_real_t cs_real_2_t[2]
vector of 2 floating-point values
Definition: cs_defs.h:331
cs_real_t cs_real_6_t[6]
vector of 6 floating-point values
Definition: cs_defs.h:334
#define CS_UNUSED(x)
Definition: cs_defs.h:493
#define END_C_DECLS
Definition: cs_defs.h:508
cs_real_t cs_real_33_t[3][3]
3x3 matrix of floating-point values
Definition: cs_defs.h:339
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:313
cs_real_t cs_real_63_t[6][3]
Definition: cs_defs.h:347
cs_field_t * cs_field_by_id(int id)
Return a pointer to a field based on its id.
Definition: cs_field.c:2314
int cs_field_get_key_int(const cs_field_t *f, int key_id)
Return a integer value for a given key associated with a field.
Definition: cs_field.c:2991
int cs_field_key_id(const char *name)
Return an id associated with a given key name.
Definition: cs_field.c:2497
int cs_field_key_id_try(const char *name)
Return an id associated with a given key name if present.
Definition: cs_field.c:2524
@ p
Definition: cs_field_pointer.h:67
@ k
Definition: cs_field_pointer.h:70
@ dt
Definition: cs_field_pointer.h:65
#define CS_F_(e)
Macro used to return a field pointer by its enumerated value.
Definition: cs_field_pointer.h:51
void cs_halo_sync_var(const cs_halo_t *halo, cs_halo_type_t sync_mode, cs_real_t var[])
Definition: cs_halo.c:1915
cs_halo_type_t
Definition: cs_halo.h:56
void cs_math_3_length_unitv(const cs_real_t xa[3], const cs_real_t xb[3], cs_real_t *len, cs_real_3_t unitv)
Compute the length (Euclidean norm) between two points xa and xb in a Cartesian coordinate system of ...
Definition: cs_math.c:438
static cs_real_t cs_math_3_square_distance(const cs_real_t xa[3], const cs_real_t xb[3])
Compute the squared distance between two points xa and xb in a Cartesian coordinate system of dimensi...
Definition: cs_math.h:310
static cs_real_t cs_math_3_norm(const cs_real_t v[3])
Compute the euclidean norm of a vector of dimension 3.
Definition: cs_math.h:403
static cs_real_t cs_math_3_square_norm(const cs_real_t v[3])
Compute the square norm of a vector of 3 real values.
Definition: cs_math.h:419
static cs_real_t cs_math_3_dot_product(const cs_real_t u[3], const cs_real_t v[3])
Compute the dot product of two vectors of 3 real values.
Definition: cs_math.h:332
static cs_real_t cs_math_sq(cs_real_t x)
Compute the square of a real value.
Definition: cs_math.h:199
const cs_real_t cs_math_epzero
cs_mesh_t * cs_glob_mesh
cs_mesh_quantities_t * cs_glob_mesh_quantities
@ CS_COUPLED_FD
Definition: cs_parameters.h:93
integer, dimension(:), allocatable icvfli
boundary convection flux indicator of a Rusanov or an analytical flux (some boundary contributions of...
Definition: cfpoin.f90:52
double precision pi
value with 16 digits
Definition: cstnum.f90:48
cs_equation_param_t * var_cal_opt
Definition: keywords.h:135
integer(c_int), pointer, save imrgra
type of gradient reconstruction
Definition: optcal.f90:260
double precision, dimension(:,:), pointer diipb
vector II' for interior faces for every boundary face, the three components of the vector ....
Definition: mesh.f90:212
integer, save kbmasf
Definition: numvar.f90:187
integer, save kimasf
interior and boundary convective mass flux key ids of the variables
Definition: numvar.f90:187
integer(c_int), pointer, save idtvar
option for a variable time step
Definition: optcal.f90:383
double precision, save fmin
Definition: coincl.f90:180
double precision, dimension(ncharm), save beta
Definition: cpincl.f90:99
double precision, dimension(ncharm), save b1
Definition: cpincl.f90:233
double precision, dimension(ncharm), save b2
Definition: cpincl.f90:233
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources.
Definition: cs_equation_param.h:186
double blencv
Definition: cs_equation_param.h:466
int isstpc
Definition: cs_equation_param.h:456
int iconv
Definition: cs_equation_param.h:446
Field descriptor.
Definition: cs_field.h:125
cs_real_t * val
Definition: cs_field.h:146
Definition: cs_mesh_quantities.h:89
cs_real_t * cell_vol
Definition: cs_mesh_quantities.h:92
Definition: cs_mesh.h:84
cs_lnum_t * b_face_cells
Definition: cs_mesh.h:111
cs_numbering_t * b_face_numbering
Definition: cs_mesh.h:162
cs_numbering_t * i_face_numbering
Definition: cs_mesh.h:161
cs_lnum_t n_cells_with_ghosts
Definition: cs_mesh.h:150
cs_halo_t * halo
Definition: cs_mesh.h:155
cs_lnum_2_t * i_face_cells
Definition: cs_mesh.h:110
cs_lnum_t * group_index
Definition: cs_numbering.h:102
int n_threads
Definition: cs_numbering.h:93
int n_groups
Definition: cs_numbering.h:94