7.0
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-2021 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  * tr_dim <-- 0 if pvar does not match a tensor
93  * or there is no periodicity of rotation
94  * 2 for Reynolds stress
95  * pvar <-> variable
96  *----------------------------------------------------------------------------*/
97 
98 inline static void
100  cs_halo_type_t halo_type,
101  int tr_dim,
102  cs_real_t pvar[])
103 {
104  if (m->halo != NULL) {
105  if (tr_dim > 0)
107  pvar);
108  else
109  cs_halo_sync_var(m->halo, halo_type, pvar);
110  }
111 }
112 
113 /*----------------------------------------------------------------------------
114  * Return pointer to slope test indicator field values if active.
115  *
116  * parameters:
117  * f_id <-- field id (or -1)
118  * var_cal_opt <-- variable calculation options
119  *
120  * return:
121  * pointer to local values array, or NULL;
122  *----------------------------------------------------------------------------*/
123 
124 inline static cs_real_t *
127 {
128  const int iconvp = var_cal_opt.iconv;
129  const int isstpp = var_cal_opt.isstpc;
130  const double blencp = var_cal_opt.blencv;
131 
132  cs_real_t *v_slope_test = NULL;
133 
134  if (f_id > -1 && iconvp > 0 && blencp > 0. && isstpp == 0) {
135 
136  static int _k_slope_test_f_id = -1;
137 
138  cs_field_t *f = cs_field_by_id(f_id);
139 
140  int f_track_slope_test_id = -1;
141 
142  if (_k_slope_test_f_id < 0)
143  _k_slope_test_f_id = cs_field_key_id_try("slope_test_upwind_id");
144  if (_k_slope_test_f_id > -1 && isstpp == 0)
145  f_track_slope_test_id = cs_field_get_key_int(f, _k_slope_test_f_id);
146 
147  if (f_track_slope_test_id > -1)
148  v_slope_test = (cs_field_by_id(f_track_slope_test_id))->val;
149 
150  if (v_slope_test != NULL) {
151  const cs_lnum_t n_cells_ext = cs_glob_mesh->n_cells_with_ghosts;
152 # pragma omp parallel for
153  for (cs_lnum_t cell_id = 0; cell_id < n_cells_ext; cell_id++)
154  v_slope_test[cell_id] = 0.;
155  }
156 
157  }
158 
159  return v_slope_test;
160 }
161 
162 /*----------------------------------------------------------------------------
163  * Compute the local cell Courant number as the maximum of all cell face based
164  * Courant number at each cell.
165  *
166  * parameters:
167  * f_id <-- field id (or -1)
168  * courant --> cell Courant number
169  */
170 /*----------------------------------------------------------------------------*/
171 
172 inline static void
173 cs_cell_courant_number(const int f_id,
174  cs_real_t *courant)
175 {
176  const cs_mesh_t *m = cs_glob_mesh;
178 
179  const cs_lnum_t n_cells_ext = m->n_cells_with_ghosts;
180  const int n_i_groups = m->i_face_numbering->n_groups;
181  const int n_i_threads = m->i_face_numbering->n_threads;
182  const int n_b_groups = m->b_face_numbering->n_groups;
183  const int n_b_threads = m->b_face_numbering->n_threads;
184  const cs_lnum_t *restrict i_group_index = m->i_face_numbering->group_index;
185  const cs_lnum_t *restrict b_group_index = m->b_face_numbering->group_index;
186 
187  const cs_lnum_2_t *restrict i_face_cells
188  = (const cs_lnum_2_t *restrict)m->i_face_cells;
189  const cs_lnum_t *restrict b_face_cells
190  = (const cs_lnum_t *restrict)m->b_face_cells;
191 
192  const cs_real_t *restrict vol
193  = (cs_real_t *restrict)fvq->cell_vol;
194 
195  cs_field_t *f = cs_field_by_id(f_id);
196  const int kimasf = cs_field_key_id("inner_mass_flux_id");
197  const int kbmasf = cs_field_key_id("boundary_mass_flux_id");
198  const cs_real_t *restrict i_massflux
200  const cs_real_t *restrict b_massflux
202 
203  const cs_real_t *restrict dt
204  = (const cs_real_t *restrict)CS_F_(dt)->val;
205 
206  /* Initialisation */
207 
208 # pragma omp parallel for
209  for (cs_lnum_t ii = 0; ii < n_cells_ext; ii++) {
210  courant[ii] = 0.;
211  }
212 
213  /* ---> Contribution from interior faces */
214 
215  cs_real_t cnt;
216 
217  for (int g_id = 0; g_id < n_i_groups; g_id++) {
218 # pragma omp parallel for
219  for (int t_id = 0; t_id < n_i_threads; t_id++) {
220  for (cs_lnum_t face_id = i_group_index[(t_id*n_i_groups + g_id)*2];
221  face_id < i_group_index[(t_id*n_i_groups + g_id)*2 + 1];
222  face_id++) {
223  cs_lnum_t ii = i_face_cells[face_id][0];
224  cs_lnum_t jj = i_face_cells[face_id][1];
225 
226  cnt = CS_ABS(i_massflux[face_id])*dt[ii]/vol[ii];
227  courant[ii] = CS_MAX(courant[ii], cnt);
228 
229  cnt = CS_ABS(i_massflux[face_id])*dt[jj]/vol[jj];
230  courant[jj] = CS_MAX(courant[jj], cnt);
231  }
232  }
233  }
234 
235  /* ---> Contribution from boundary faces */
236 
237  for (int g_id = 0; g_id < n_b_groups; g_id++) {
238 # pragma omp parallel for
239  for (int t_id = 0; t_id < n_b_threads; t_id++) {
240  for (cs_lnum_t face_id = b_group_index[(t_id*n_b_groups + g_id)*2];
241  face_id < b_group_index[(t_id*n_b_groups + g_id)*2 + 1];
242  face_id++) {
243  cs_lnum_t ii = b_face_cells[face_id];
244 
245  cnt = CS_ABS(b_massflux[face_id])*dt[ii]/vol[ii];
246  courant[ii] = CS_MAX(courant[ii], cnt);
247  }
248  }
249  }
250 }
251 
252 /*----------------------------------------------------------------------------*/
263 /*----------------------------------------------------------------------------*/
264 
265 inline static cs_real_t
267  const cs_real_t nvf_p_c,
268  const cs_real_t nvf_r_f,
269  const cs_real_t nvf_r_c)
270 {
271  cs_real_t nvf_p_f;
272 
273  cs_real_t beta_m, rfc, r1f, r1, r2, r3, b1, b2;
274 
275  switch (limiter) {
276  case CS_NVD_GAMMA: /* Gamma scheme */
277  beta_m = 0.1; /* in [0.1, 0.5] */
278  rfc = (nvf_r_f-nvf_r_c)/(1.-nvf_r_c);
279 
280  if (nvf_p_c < beta_m) {
281  nvf_p_f = nvf_p_c*(1.+rfc*(1.-nvf_p_c)/beta_m);
282  } else {
283  r1f = (1.-nvf_r_f)/(1.-nvf_r_c);
284 
285  nvf_p_f = r1f*nvf_p_c+rfc;
286  }
287 
288  break;
289 
290  case CS_NVD_SMART: /* SMART scheme */
291  if (nvf_p_c < (nvf_r_c/3.)) {
292  r1 = nvf_r_f*(1.-3.*nvf_r_c+2.*nvf_r_f);
293  r2 = nvf_r_c*(1.-nvf_r_c);
294 
295  nvf_p_f = nvf_p_c*r1/r2;
296  } else if (nvf_p_c <= (nvf_r_c*(1.+nvf_r_f-nvf_r_c)/nvf_r_f)) {
297  rfc = (nvf_r_f-nvf_r_c)/(1.-nvf_r_c);
298  r1f = (1.-nvf_r_f)/(1.-nvf_r_c);
299 
300  nvf_p_f = nvf_r_f*(r1f*nvf_p_c/nvf_r_c + rfc);
301  } else {
302  nvf_p_f = 1.;
303  }
304 
305  break;
306 
307  case CS_NVD_CUBISTA: /* CUBISTA scheme */
308  if (nvf_p_c < (3.*nvf_r_c/4.)) {
309  rfc = (nvf_r_f-nvf_r_c)/(1.-nvf_r_c);
310 
311  nvf_p_f = nvf_r_f*(1.+rfc/3.)*nvf_p_c/nvf_r_c;
312  } else if (nvf_p_c <= (nvf_r_c*(1.+2.*(nvf_r_f-nvf_r_c))/(2.*nvf_r_f-nvf_r_c))) {
313  rfc = (nvf_r_f-nvf_r_c)/(1.-nvf_r_c);
314  r1f = (1.-nvf_r_f)/(1.-nvf_r_c);
315 
316  nvf_p_f = nvf_r_f*(r1f*nvf_p_c/nvf_r_c+rfc);
317  } else {
318  r1f = (1.-nvf_r_f)/(1.-nvf_r_c);
319 
320  nvf_p_f = 1.-.5*r1f*(1.-nvf_p_c);
321  }
322 
323  break;
324 
325  case CS_NVD_SUPERBEE: /* SuperBee scheme */
326  if (nvf_p_c < (nvf_r_c/(2.-nvf_r_c))) {
327  nvf_p_f = (2.*nvf_r_f-nvf_r_c)*nvf_p_c/nvf_r_c;
328  } else if (nvf_p_c < nvf_r_c) {
329  rfc = (nvf_r_f-nvf_r_c)/(1.-nvf_r_c);
330  r1f = (1.-nvf_r_f)/(1.-nvf_r_c);
331 
332  nvf_p_f = r1f*nvf_p_c+rfc;
333  } else if (nvf_p_c < (nvf_r_c/nvf_r_f)) {
334  nvf_p_f = nvf_r_f*nvf_p_c/nvf_r_c;
335  } else {
336  nvf_p_f = 1.;
337  }
338 
339  break;
340 
341  case CS_NVD_MUSCL: /* MUSCL scheme */
342  if (nvf_p_c < (.5*nvf_r_c)) {
343  nvf_p_f = (2.*nvf_r_f-nvf_r_c)*nvf_p_c/nvf_r_c;
344  } else if (nvf_p_c < (1.+nvf_r_c-nvf_r_f)) {
345  nvf_p_f = nvf_p_c+nvf_r_f-nvf_r_c;
346  } else {
347  nvf_p_f = 1.;
348  }
349 
350  break;
351 
352  case CS_NVD_MINMOD: /* MINMOD scheme */
353  if (nvf_p_c < nvf_r_c) {
354  nvf_p_f = nvf_r_f*nvf_p_c/nvf_r_c;
355  } else {
356  rfc = (nvf_r_f-nvf_r_c)/(1.-nvf_r_c);
357  r1f = (1.-nvf_r_f)/(1.-nvf_r_c);
358 
359  nvf_p_f = r1f*nvf_p_c+rfc;
360  }
361 
362  break;
363 
364  case CS_NVD_CLAM: /* CLAM scheme */
365  r1 = nvf_r_c*nvf_r_c-nvf_r_f;
366  r2 = nvf_r_c*(nvf_r_c-1.);
367  r3 = nvf_r_f-nvf_r_c;
368 
369  nvf_p_f = nvf_p_c*(r1+r3*nvf_p_c)/r2;
370 
371  break;
372 
373  case CS_NVD_STOIC: /* STOIC scheme */
374  b1 = (nvf_r_c-nvf_r_f)*nvf_r_c;
375  b2 = nvf_r_c+nvf_r_f+2.*nvf_r_f*nvf_r_f-4.*nvf_r_f*nvf_r_c;
376 
377  if (nvf_p_c < (b1/b2)) {
378  r1 = -nvf_r_f*(1.-3.*nvf_r_c+2.*nvf_r_f);
379  r2 = nvf_r_c*(nvf_r_c-1.);
380 
381  nvf_p_f = nvf_p_c*r1/r2;
382  } else if (nvf_p_c < nvf_r_c) {
383  rfc = (nvf_r_f-nvf_r_c)/(1.-nvf_r_c);
384  r1f = (1.-nvf_r_f)/(1.-nvf_r_c);
385 
386  nvf_p_f = r1f*nvf_p_c+rfc;
387  } else if (nvf_p_c < (nvf_r_c*(1.+nvf_r_f-nvf_r_c)/nvf_r_f)) {
388  rfc = (nvf_r_f-nvf_r_c)/(1.-nvf_r_c);
389  r1f = (1.-nvf_r_f)/(1.-nvf_r_c);
390 
391  nvf_p_f = nvf_r_f*(nvf_p_c*r1f/nvf_r_c+rfc);
392  } else {
393  nvf_p_f = 1.;
394  }
395 
396  break;
397 
398  case CS_NVD_OSHER: /* OSHER scheme */
399  if (nvf_p_c < (nvf_r_c/nvf_r_f)) {
400  nvf_p_f = nvf_r_f*nvf_p_c/nvf_r_c;
401  } else {
402  nvf_p_f = 1.;
403  }
404 
405  break;
406 
407  case CS_NVD_WASEB: /* WASEB scheme */
408  r1 = nvf_r_c*nvf_r_f*(nvf_r_f-nvf_r_c);
409  r2 = 2.*nvf_r_c*(1.-nvf_r_c)-nvf_r_f*(1.-nvf_r_f);
410 
411  if (nvf_p_c < (r1/r2)) {
412  nvf_p_f = 2.*nvf_p_c;
413  } else if (nvf_p_c <= (nvf_r_c*(1.+nvf_r_f-nvf_r_c)/nvf_r_f)) {
414  rfc = (nvf_r_f-nvf_r_c)/(1.-nvf_r_c);
415  r1f = (1.-nvf_r_f)/(1.-nvf_r_c);
416 
417  nvf_p_f = nvf_r_f*(nvf_p_c*r1f/nvf_r_c+rfc);
418  } else {
419  nvf_p_f = 1.;
420  }
421 
422  break;
423 
424  default: /* Upwinding */
425  nvf_p_f = nvf_p_c;
426  break;
427  }
428 
429  return nvf_p_f;
430 }
431 
432 /*----------------------------------------------------------------------------*/
448 /*----------------------------------------------------------------------------*/
449 
450 inline static cs_real_t
452  const cs_real_3_t i_face_normal,
453  const cs_real_t nvf_p_c,
454  const cs_real_t nvf_r_f,
455  const cs_real_t nvf_r_c,
456  const cs_real_3_t gradv_c,
457  const cs_real_t c_courant)
458 {
459  assert(limiter >= CS_NVD_VOF_HRIC);
460 
461  cs_real_t nvf_p_f;
462  cs_real_t blend, high_order, low_order, ratio;
463 
464  /* Compute gradient angle indicator */
465  cs_real_t dotp = CS_ABS(cs_math_3_dot_product(gradv_c, i_face_normal));
466  cs_real_t sgrad = cs_math_3_norm(gradv_c);
467  cs_real_t snorm = cs_math_3_norm(i_face_normal);
468  cs_real_t denom = snorm*sgrad;
469 
470  if (limiter == CS_NVD_VOF_HRIC) { /* M-HRIC scheme */
471  /* High order scheme : Bounded Downwind */
472  if (nvf_p_c <= .5) {
473  high_order = 2.*nvf_p_c;
474  } else {
475  high_order = 1.;
476  }
477 
478  /* Low order scheme : MUSCL */
480  nvf_p_c,
481  nvf_r_f,
482  nvf_r_c);
483 
484  /* Compute the blending factor */
485  if (denom <= (cs_math_epzero*dotp)) {
486  blend = 1.;
487  } else {
488  ratio = dotp/denom;
489  blend = CS_MIN(1., pow(ratio, .5));
490  }
491 
492  /* Blending */
493  nvf_p_f = blend*high_order + (1.-blend)*low_order;
494 
495  /* Extra blending due to the cell Courant number */
496  if (c_courant < .7 && c_courant > .3) {
497  nvf_p_f = nvf_p_f + (nvf_p_f - low_order)*(.7 - c_courant )/.4;
498  } else if (c_courant >= .7) {
499  nvf_p_f = low_order;
500  }
501  } else if (limiter == CS_NVD_VOF_CICSAM) { /* M-CICSAM scheme */
502  /* High order scheme : HYPER-C + SUPERBEE */
503  if (c_courant <= .3) {
504  high_order = CS_MIN(1., nvf_p_c/(c_courant+cs_math_epzero));
505  } else if (c_courant <= .6) {
506  high_order = CS_MIN(1., nvf_p_c/.3);
507  } else if (c_courant <= .7) {
509  nvf_p_c,
510  nvf_r_f,
511  nvf_r_c);
512  high_order = 10.*( (.7-c_courant)*CS_MIN(1., nvf_p_c/.3)
513  + (c_courant-.6)*superbee);
514  }
515  else {
517  nvf_p_c,
518  nvf_r_f,
519  nvf_r_c);
520  }
521 
522  /* Low order scheme : MUSCL */
524  nvf_p_c,
525  nvf_r_f,
526  nvf_r_c);
527 
528  /* Compute the blending factor */
529  if (denom <= (cs_math_epzero*dotp)) {
530  blend = 1.;
531  } else {
532  ratio = dotp/denom;
533  blend = CS_MIN(1., pow(ratio, 2.));
534  }
535 
536  /* Blending */
537  nvf_p_f = blend*high_order + (1.-blend)*low_order;
538  } else { /* STACS scheme */
539  /* High order scheme : SUPERBEE */
541  nvf_p_c,
542  nvf_r_f,
543  nvf_r_c);
544 
545  /* Low order scheme : STOIC */
547  nvf_p_c,
548  nvf_r_f,
549  nvf_r_c);
550 
551  /* Compute the blending factor */
552  if (denom <= (cs_math_epzero*dotp)) {
553  blend = 1.;
554  } else {
555  ratio = dotp/denom;
556  blend = CS_MIN(1., pow(ratio, 4.));
557  }
558 
559  /* Blending */
560  nvf_p_f = blend*high_order + (1.-blend)*low_order;
561  }
562 
563  return nvf_p_f;
564 }
565 
566 /*----------------------------------------------------------------------------*/
583 /*----------------------------------------------------------------------------*/
584 
585 inline static void
587  const cs_real_t pj,
588  const cs_real_t distf,
589  const cs_real_t srfan,
590  const cs_real_t i_face_normal[3],
591  const cs_real_t gradi[3],
592  const cs_real_t gradj[3],
593  const cs_real_t grdpai[3],
594  const cs_real_t grdpaj[3],
595  const cs_real_t i_massflux,
596  cs_real_t *testij,
597  cs_real_t *tesqck)
598 {
599  cs_real_t testi, testj;
600  cs_real_t dcc, ddi, ddj;
601 
602  /* Slope test */
603 
604  testi = grdpai[0]*i_face_normal[0]
605  + grdpai[1]*i_face_normal[1]
606  + grdpai[2]*i_face_normal[2];
607  testj = grdpaj[0]*i_face_normal[0]
608  + grdpaj[1]*i_face_normal[1]
609  + grdpaj[2]*i_face_normal[2];
610 
611  *testij = grdpai[0]*grdpaj[0]
612  + grdpai[1]*grdpaj[1]
613  + grdpai[2]*grdpaj[2];
614 
615  if (i_massflux>0.) {
616  dcc = gradi[0]*i_face_normal[0]
617  + gradi[1]*i_face_normal[1]
618  + gradi[2]*i_face_normal[2];
619  ddi = testi;
620  ddj = (pj-pi)/distf *srfan;
621  } else {
622  dcc = gradj[0]*i_face_normal[0]
623  + gradj[1]*i_face_normal[1]
624  + gradj[2]*i_face_normal[2];
625  ddi = (pj-pi)/distf *srfan;
626  ddj = testj;
627  }
628 
629  *tesqck = cs_math_sq(dcc) - cs_math_sq(ddi-ddj);
630 }
631 
632 /*----------------------------------------------------------------------------*/
649 /*----------------------------------------------------------------------------*/
650 
651 inline static void
653  const cs_real_t pj[3],
654  const cs_real_t distf,
655  const cs_real_t srfan,
656  const cs_real_t i_face_normal[3],
657  const cs_real_t gradi[3][3],
658  const cs_real_t gradj[3][3],
659  const cs_real_t gradsti[3][3],
660  const cs_real_t gradstj[3][3],
661  const cs_real_t i_massflux,
662  cs_real_t *testij,
663  cs_real_t *tesqck)
664 {
665  cs_real_t testi[3], testj[3];
666  cs_real_t dcc[3], ddi[3], ddj[3];
667  *testij = 0.;
668  *tesqck = 0.;
669 
670  /* Slope test */
671 
672  for (int i = 0; i < 3; i++) {
673  *testij += gradsti[i][0]*gradstj[i][0]
674  + gradsti[i][1]*gradstj[i][1]
675  + gradsti[i][2]*gradstj[i][2];
676 
677  testi[i] = gradsti[i][0]*i_face_normal[0]
678  + gradsti[i][1]*i_face_normal[1]
679  + gradsti[i][2]*i_face_normal[2];
680  testj[i] = gradstj[i][0]*i_face_normal[0]
681  + gradstj[i][1]*i_face_normal[1]
682  + gradstj[i][2]*i_face_normal[2];
683 
684  if (i_massflux > 0.) {
685  dcc[i] = gradi[i][0]*i_face_normal[0]
686  + gradi[i][1]*i_face_normal[1]
687  + gradi[i][2]*i_face_normal[2];
688  ddi[i] = testi[i];
689  ddj[i] = (pj[i]-pi[i])/distf *srfan;
690  } else {
691  dcc[i] = gradj[i][0]*i_face_normal[0]
692  + gradj[i][1]*i_face_normal[1]
693  + gradj[i][2]*i_face_normal[2];
694  ddi[i] = (pj[i]-pi[i])/distf *srfan;
695  ddj[i] = testj[i];
696  }
697  }
698 
699  *tesqck = cs_math_3_square_norm(dcc) - cs_math_3_square_distance(ddi, ddj);
700 }
701 
702 /*----------------------------------------------------------------------------*/
719 /*----------------------------------------------------------------------------*/
720 
721 inline static void
723  const cs_real_t pj[6],
724  const cs_real_t distf,
725  const cs_real_t srfan,
726  const cs_real_t i_face_normal[3],
727  const cs_real_t gradi[6][3],
728  const cs_real_t gradj[6][3],
729  const cs_real_t gradsti[6][3],
730  const cs_real_t gradstj[6][3],
731  const cs_real_t i_massflux,
732  cs_real_t *testij,
733  cs_real_t *tesqck)
734 {
735  cs_real_t testi[6], testj[6];
736  cs_real_t dcc[6], ddi[6], ddj[6];
737 
738  *testij = 0.;
739  *tesqck = 0.;
740 
741  /* Slope test */
742 
743  for (int ij = 0; ij < 6; ij++) {
744  *testij += gradsti[ij][0]*gradstj[ij][0]
745  + gradsti[ij][1]*gradstj[ij][1]
746  + gradsti[ij][2]*gradstj[ij][2];
747  testi[ij] = gradsti[ij][0]*i_face_normal[0]
748  + gradsti[ij][1]*i_face_normal[1]
749  + gradsti[ij][2]*i_face_normal[2];
750  testj[ij] = gradstj[ij][0]*i_face_normal[0]
751  + gradstj[ij][1]*i_face_normal[1]
752  + gradstj[ij][2]*i_face_normal[2];
753 
754  if (i_massflux > 0.) {
755  dcc[ij] = gradi[ij][0]*i_face_normal[0]
756  + gradi[ij][1]*i_face_normal[1]
757  + gradi[ij][2]*i_face_normal[2];
758  ddi[ij] = testi[ij];
759  ddj[ij] = (pj[ij]-pi[ij])/distf *srfan;
760  }
761  else {
762  dcc[ij] = gradj[ij][0]*i_face_normal[0]
763  + gradj[ij][1]*i_face_normal[1]
764  + gradj[ij][2]*i_face_normal[2];
765  ddi[ij] = (pj[ij]-pi[ij])/distf *srfan;
766  ddj[ij] = testj[ij];
767  }
768 
769  *tesqck += cs_math_sq(dcc[ij]) - cs_math_sq(ddi[ij]-ddj[ij]);
770  }
771 }
772 
773 /*----------------------------------------------------------------------------*/
789 /*----------------------------------------------------------------------------*/
790 
791 inline static void
793  const cs_real_3_t diipf,
794  const cs_real_3_t djjpf,
795  const cs_real_3_t gradi,
796  const cs_real_3_t gradj,
797  const cs_real_t pi,
798  const cs_real_t pj,
799  cs_real_t *recoi,
800  cs_real_t *recoj,
801  cs_real_t *pip,
802  cs_real_t *pjp)
803 {
804  cs_real_t gradpf[3] = {0.5*(gradi[0] + gradj[0]),
805  0.5*(gradi[1] + gradj[1]),
806  0.5*(gradi[2] + gradj[2])};
807 
808  /* reconstruction only if IRCFLP = 1 */
809  *recoi = bldfrp*(cs_math_3_dot_product(gradpf, diipf));
810  *recoj = bldfrp*(cs_math_3_dot_product(gradpf, djjpf));
811  *pip = pi + *recoi;
812  *pjp = pj + *recoj;
813 }
814 
815 /*----------------------------------------------------------------------------*/
831 /*----------------------------------------------------------------------------*/
832 
833 inline static void
835  const cs_real_3_t diipf,
836  const cs_real_3_t djjpf,
837  const cs_real_33_t gradi,
838  const cs_real_33_t gradj,
839  const cs_real_3_t pi,
840  const cs_real_3_t pj,
841  cs_real_t recoi[3],
842  cs_real_t recoj[3],
843  cs_real_t pip[3],
844  cs_real_t pjp[3])
845 {
846  cs_real_3_t dpvf;
847 
848  /* x-y-z components, p = u, v, w */
849 
850  for (int isou = 0; isou < 3; isou++) {
851 
852  for (int jsou = 0; jsou < 3; jsou++)
853  dpvf[jsou] = 0.5*( gradi[isou][jsou]
854  + gradj[isou][jsou]);
855 
856  /* reconstruction only if IRCFLP = 1 */
857 
858  recoi[isou] = bldfrp*(cs_math_3_dot_product(dpvf, diipf));
859  recoj[isou] = bldfrp*(cs_math_3_dot_product(dpvf, djjpf));
860 
861  pip[isou] = pi[isou] + recoi[isou];
862  pjp[isou] = pj[isou] + recoj[isou];
863 
864  }
865 }
866 
867 /*----------------------------------------------------------------------------*/
883 /*----------------------------------------------------------------------------*/
884 
885 inline static void
887  const cs_real_3_t diipf,
888  const cs_real_3_t djjpf,
889  const cs_real_63_t gradi,
890  const cs_real_63_t gradj,
891  const cs_real_6_t pi,
892  const cs_real_6_t pj,
893  cs_real_t recoi[6],
894  cs_real_t recoj[6],
895  cs_real_t pip[6],
896  cs_real_t pjp[6])
897 {
898  cs_real_3_t dpvf;
899 
900  /* x-y-z components, p = u, v, w */
901 
902  for (int isou = 0; isou < 6; isou++) {
903 
904  for (int jsou = 0; jsou < 3; jsou++)
905  dpvf[jsou] = 0.5*( gradi[isou][jsou]
906  + gradj[isou][jsou]);
907 
908  /* reconstruction only if IRCFLP = 1 */
909 
910  recoi[isou] = bldfrp*(cs_math_3_dot_product(dpvf, diipf));
911  recoj[isou] = bldfrp*(cs_math_3_dot_product(dpvf, djjpf));
912 
913  pip[isou] = pi[isou] + recoi[isou];
914  pjp[isou] = pj[isou] + recoj[isou];
915 
916  }
917 }
918 
919 /*----------------------------------------------------------------------------*/
935 /*----------------------------------------------------------------------------*/
936 
937 inline static void
938 cs_i_relax_c_val(const double relaxp,
939  const cs_real_t pia,
940  const cs_real_t pja,
941  const cs_real_t recoi,
942  const cs_real_t recoj,
943  const cs_real_t pi,
944  const cs_real_t pj,
945  cs_real_t *pir,
946  cs_real_t *pjr,
947  cs_real_t *pipr,
948  cs_real_t *pjpr)
949 {
950  *pir = pi/relaxp - (1.-relaxp)/relaxp * pia;
951  *pjr = pj/relaxp - (1.-relaxp)/relaxp * pja;
952 
953  *pipr = *pir + recoi;
954  *pjpr = *pjr + recoj;
955 }
956 
957 /*----------------------------------------------------------------------------*/
973 /*----------------------------------------------------------------------------*/
974 
975 inline static void
976 cs_i_relax_c_val_vector(const double relaxp,
977  const cs_real_3_t pia,
978  const cs_real_3_t pja,
979  const cs_real_3_t recoi,
980  const cs_real_3_t recoj,
981  const cs_real_3_t pi,
982  const cs_real_3_t pj,
983  cs_real_t pir[3],
984  cs_real_t pjr[3],
985  cs_real_t pipr[3],
986  cs_real_t pjpr[3])
987 {
988  for (int isou = 0; isou < 3; isou++) {
989  pir[isou] = pi[isou] /relaxp - (1.-relaxp)/relaxp * pia[isou];
990  pjr[isou] = pj[isou] /relaxp - (1.-relaxp)/relaxp * pja[isou];
991 
992  pipr[isou] = pir[isou] + recoi[isou];
993  pjpr[isou] = pjr[isou] + recoj[isou];
994  }
995 }
996 
997 /*----------------------------------------------------------------------------*/
1013 /*----------------------------------------------------------------------------*/
1014 
1015 inline static void
1017  const cs_real_t pia[6],
1018  const cs_real_t pja[6],
1019  const cs_real_t recoi[6],
1020  const cs_real_t recoj[6],
1021  const cs_real_t pi[6],
1022  const cs_real_t pj[6],
1023  cs_real_t pir[6],
1024  cs_real_t pjr[6],
1025  cs_real_t pipr[6],
1026  cs_real_t pjpr[6])
1027 {
1028  for (int isou = 0; isou < 6; isou++) {
1029  pir[isou] = pi[isou] /relaxp - (1.-relaxp)/relaxp * pia[isou];
1030  pjr[isou] = pj[isou] /relaxp - (1.-relaxp)/relaxp * pja[isou];
1031 
1032  pipr[isou] = pir[isou] + recoi[isou];
1033  pjpr[isou] = pjr[isou] + recoj[isou];
1034  }
1035 }
1036 
1037 /*----------------------------------------------------------------------------*/
1044 /*----------------------------------------------------------------------------*/
1045 
1046 inline static void
1048  cs_real_t *pf)
1049 {
1050  *pf = p;
1051 }
1052 
1053 /*----------------------------------------------------------------------------*/
1060 /*----------------------------------------------------------------------------*/
1061 
1062 inline static void
1064  cs_real_t pf[3])
1065 {
1066  for (int isou = 0; isou < 3; isou++)
1067  pf[isou] = p[isou];
1068 }
1069 
1070 /*----------------------------------------------------------------------------*/
1077 /*----------------------------------------------------------------------------*/
1078 
1079 inline static void
1081  cs_real_t pf[6])
1082 {
1083  for (int isou = 0; isou < 6; isou++)
1084  pf[isou] = p[isou];
1085 }
1086 
1087 /*----------------------------------------------------------------------------*/
1096 /*----------------------------------------------------------------------------*/
1097 
1098 inline static void
1099 cs_centered_f_val(const double pnd,
1100  const cs_real_t pip,
1101  const cs_real_t pjp,
1102  cs_real_t *pf)
1103 {
1104  *pf = pnd*pip + (1.-pnd)*pjp;
1105 }
1106 
1107 /*----------------------------------------------------------------------------*/
1116 /*----------------------------------------------------------------------------*/
1117 
1118 inline static void
1119 cs_centered_f_val_vector(const double pnd,
1120  const cs_real_3_t pip,
1121  const cs_real_3_t pjp,
1122  cs_real_t pf[3])
1123 {
1124  for (int isou = 0; isou < 3; isou++)
1125  pf[isou] = pnd*pip[isou] + (1.-pnd)*pjp[isou];
1126 }
1127 
1128 /*----------------------------------------------------------------------------*/
1137 /*----------------------------------------------------------------------------*/
1138 
1139 inline static void
1140 cs_centered_f_val_tensor(const double pnd,
1141  const cs_real_6_t pip,
1142  const cs_real_6_t pjp,
1143  cs_real_t pf[6])
1144 {
1145  for (int isou = 0; isou < 6; isou++)
1146  pf[isou] = pnd*pip[isou] + (1.-pnd)*pjp[isou];
1147 }
1148 
1149 /*----------------------------------------------------------------------------*/
1159 /*----------------------------------------------------------------------------*/
1160 
1161 inline static void
1163  const cs_real_3_t i_face_cog,
1164  const cs_real_3_t grad,
1165  const cs_real_t p,
1166  cs_real_t *pf)
1167 {
1168  cs_real_t df[3];
1169 
1170  df[0] = i_face_cog[0] - cell_cen[0];
1171  df[1] = i_face_cog[1] - cell_cen[1];
1172  df[2] = i_face_cog[2] - cell_cen[2];
1173 
1174  *pf = p + cs_math_3_dot_product(df, grad);
1175 }
1176 
1177 /*----------------------------------------------------------------------------*/
1187 /*----------------------------------------------------------------------------*/
1188 
1189 inline static void
1191  const cs_real_3_t i_face_cog,
1192  const cs_real_33_t grad,
1193  const cs_real_3_t p,
1194  cs_real_t pf[3])
1195 {
1196  cs_real_t df[3];
1197 
1198  for (int jsou = 0; jsou < 3; jsou++)
1199  df[jsou] = i_face_cog[jsou] - cell_cen[jsou];
1200 
1201  for (int isou = 0; isou < 3; isou++) {
1202  pf[isou] = p[isou] + df[0]*grad[isou][0]
1203  + df[1]*grad[isou][1]
1204  + df[2]*grad[isou][2];
1205 
1206  }
1207 }
1208 
1209 /*----------------------------------------------------------------------------*/
1219 /*----------------------------------------------------------------------------*/
1220 
1221 inline static void
1223  const cs_real_3_t i_face_cog,
1224  const cs_real_63_t grad,
1225  const cs_real_6_t p,
1226  cs_real_t pf[6])
1227 {
1228  cs_real_t df[3];
1229 
1230  for (int jsou = 0; jsou < 3; jsou++)
1231  df[jsou] = i_face_cog[jsou] - cell_cen[jsou];
1232 
1233  for (int isou = 0; isou < 6; isou++) {
1234  pf[isou] = p[isou] + df[0]*grad[isou][0]
1235  + df[1]*grad[isou][1]
1236  + df[2]*grad[isou][2];
1237  }
1238 }
1239 
1240 /*----------------------------------------------------------------------------*/
1250 /*----------------------------------------------------------------------------*/
1251 
1252 inline static void
1253 cs_blend_f_val(const double blencp,
1254  const cs_real_t p,
1255  cs_real_t *pf)
1256 {
1257  *pf = blencp * (*pf) + (1. - blencp) * p;
1258 }
1259 
1260 /*----------------------------------------------------------------------------*/
1270 /*----------------------------------------------------------------------------*/
1271 
1272 inline static void
1273 cs_blend_f_val_vector(const double blencp,
1274  const cs_real_3_t p,
1275  cs_real_t pf[3])
1276 {
1277  for (int isou = 0; isou < 3; isou++)
1278  pf[isou] = blencp*(pf[isou])+(1.-blencp)*p[isou];
1279 }
1280 
1281 /*----------------------------------------------------------------------------*/
1291 /*----------------------------------------------------------------------------*/
1292 
1293 inline static void
1294 cs_blend_f_val_tensor(const double blencp,
1295  const cs_real_t p[6],
1296  cs_real_t pf[6])
1297 {
1298  for (int isou = 0; isou < 6; isou++)
1299  pf[isou] = blencp*(pf[isou])+(1.-blencp)*p[isou];
1300 }
1301 
1302 /*----------------------------------------------------------------------------*/
1323 /*----------------------------------------------------------------------------*/
1324 
1325 inline static void
1326 cs_i_conv_flux(const int iconvp,
1327  const cs_real_t thetap,
1328  const int imasac,
1329  const cs_real_t pi,
1330  const cs_real_t pj,
1331  const cs_real_t pifri,
1332  const cs_real_t pifrj,
1333  const cs_real_t pjfri,
1334  const cs_real_t pjfrj,
1335  const cs_real_t i_massflux,
1336  const cs_real_t xcppi,
1337  const cs_real_t xcppj,
1338  cs_real_2_t fluxij)
1339 {
1340  cs_real_t flui, fluj;
1341 
1342  flui = 0.5*(i_massflux + fabs(i_massflux));
1343  fluj = 0.5*(i_massflux - fabs(i_massflux));
1344 
1345  fluxij[0] += iconvp*xcppi*(thetap*(flui*pifri + fluj*pjfri) - imasac*i_massflux*pi);
1346  fluxij[1] += iconvp*xcppj*(thetap*(flui*pifrj + fluj*pjfrj) - imasac*i_massflux*pj);
1347 }
1348 
1349 /*----------------------------------------------------------------------------*/
1367 /*----------------------------------------------------------------------------*/
1368 
1369 inline static void
1370 cs_i_conv_flux_vector(const int iconvp,
1371  const cs_real_t thetap,
1372  const int imasac,
1373  const cs_real_t pi[3],
1374  const cs_real_t pj[3],
1375  const cs_real_t pifri[3],
1376  const cs_real_t pifrj[3],
1377  const cs_real_t pjfri[3],
1378  const cs_real_t pjfrj[3],
1379  const cs_real_t i_massflux,
1380  cs_real_t fluxi[3],
1381  cs_real_t fluxj[3])
1382 {
1383  cs_real_t flui, fluj;
1384 
1385  flui = 0.5*(i_massflux + fabs(i_massflux));
1386  fluj = 0.5*(i_massflux - fabs(i_massflux));
1387 
1388  for (int isou = 0; isou < 3; isou++) {
1389 
1390  fluxi[isou] += iconvp*( thetap*(flui*pifri[isou] + fluj*pjfri[isou])
1391  - imasac*i_massflux*pi[isou]);
1392  fluxj[isou] += iconvp*( thetap*(flui*pifrj[isou] + fluj*pjfrj[isou])
1393  - imasac*i_massflux*pj[isou]);
1394  }
1395 }
1396 
1397 /*----------------------------------------------------------------------------*/
1415 /*----------------------------------------------------------------------------*/
1416 
1417 inline static void
1418 cs_i_conv_flux_tensor(const int iconvp,
1419  const cs_real_t thetap,
1420  const int imasac,
1421  const cs_real_t pi[6],
1422  const cs_real_t pj[6],
1423  const cs_real_t pifri[6],
1424  const cs_real_t pifrj[6],
1425  const cs_real_t pjfri[6],
1426  const cs_real_t pjfrj[6],
1427  const cs_real_t i_massflux,
1428  cs_real_t fluxi[6],
1429  cs_real_t fluxj[6])
1430 {
1431  cs_real_t flui, fluj;
1432 
1433  flui = 0.5*(i_massflux + fabs(i_massflux));
1434  fluj = 0.5*(i_massflux - fabs(i_massflux));
1435 
1436  for (int isou = 0; isou < 6; isou++) {
1437  fluxi[isou] += iconvp*( thetap*(flui*pifri[isou] + fluj*pjfri[isou])
1438  - imasac*i_massflux*pi[isou]);
1439  fluxj[isou] += iconvp*( thetap*(flui*pifrj[isou] + fluj*pjfrj[isou])
1440  - imasac*i_massflux*pj[isou]);
1441  }
1442 }
1443 
1444 /*----------------------------------------------------------------------------*/
1457 /*----------------------------------------------------------------------------*/
1458 
1459 inline static void
1460 cs_i_diff_flux(const int idiffp,
1461  const cs_real_t thetap,
1462  const cs_real_t pip,
1463  const cs_real_t pjp,
1464  const cs_real_t pipr,
1465  const cs_real_t pjpr,
1466  const cs_real_t i_visc,
1467  cs_real_t fluxij[2])
1468 {
1469  fluxij[0] += idiffp*thetap*i_visc*(pipr -pjp);
1470  fluxij[1] += idiffp*thetap*i_visc*(pip -pjpr);
1471 }
1472 
1473 /*----------------------------------------------------------------------------*/
1487 /*----------------------------------------------------------------------------*/
1488 
1489 inline static void
1490 cs_i_diff_flux_vector(const int idiffp,
1491  const cs_real_t thetap,
1492  const cs_real_t pip[3],
1493  const cs_real_t pjp[3],
1494  const cs_real_t pipr[3],
1495  const cs_real_t pjpr[3],
1496  const cs_real_t i_visc,
1497  cs_real_t fluxi[3],
1498  cs_real_t fluxj[3])
1499 {
1500  for (int isou = 0; isou < 3; isou++) {
1501  fluxi[isou] += idiffp*thetap*i_visc*(pipr[isou] -pjp[isou]);
1502  fluxj[isou] += idiffp*thetap*i_visc*(pip[isou] -pjpr[isou]);
1503  }
1504 }
1505 
1506 /*----------------------------------------------------------------------------*/
1520 /*----------------------------------------------------------------------------*/
1521 
1522 inline static void
1523 cs_i_diff_flux_tensor(const int idiffp,
1524  const cs_real_t thetap,
1525  const cs_real_t pip[6],
1526  const cs_real_t pjp[6],
1527  const cs_real_t pipr[6],
1528  const cs_real_t pjpr[6],
1529  const cs_real_t i_visc,
1530  cs_real_t fluxi[6],
1531  cs_real_t fluxj[6])
1532 {
1533  for (int isou = 0; isou < 6; isou++) {
1534  fluxi[isou] += idiffp*thetap*i_visc*(pipr[isou] -pjp[isou]);
1535  fluxj[isou] += idiffp*thetap*i_visc*(pip[isou] -pjpr[isou]);
1536  }
1537 }
1538 
1539 /*----------------------------------------------------------------------------*/
1563 /*----------------------------------------------------------------------------*/
1564 
1565 inline static void
1567  const cs_real_t relaxp,
1568  const cs_real_t diipf[3],
1569  const cs_real_t djjpf[3],
1570  const cs_real_t gradi[3],
1571  const cs_real_t gradj[3],
1572  const cs_real_t pi,
1573  const cs_real_t pj,
1574  const cs_real_t pia,
1575  const cs_real_t pja,
1576  cs_real_t *pifri,
1577  cs_real_t *pifrj,
1578  cs_real_t *pjfri,
1579  cs_real_t *pjfrj,
1580  cs_real_t *pip,
1581  cs_real_t *pjp,
1582  cs_real_t *pipr,
1583  cs_real_t *pjpr)
1584 {
1585  cs_real_t pir, pjr;
1586  cs_real_t recoi, recoj;
1587 
1588  cs_i_compute_quantities(bldfrp,
1589  diipf,
1590  djjpf,
1591  gradi,
1592  gradj,
1593  pi,
1594  pj,
1595  &recoi,
1596  &recoj,
1597  pip,
1598  pjp);
1599 
1600  cs_i_relax_c_val(relaxp,
1601  pia,
1602  pja,
1603  recoi,
1604  recoj,
1605  pi,
1606  pj,
1607  &pir,
1608  &pjr,
1609  pipr,
1610  pjpr);
1611 
1613  pifrj);
1614  cs_upwind_f_val(pir,
1615  pifri);
1616  cs_upwind_f_val(pj,
1617  pjfri);
1618  cs_upwind_f_val(pjr,
1619  pjfrj);
1620 }
1621 
1622 /*----------------------------------------------------------------------------*/
1646 /*----------------------------------------------------------------------------*/
1647 
1648 inline static void
1650  const cs_real_t relaxp,
1651  const cs_real_t diipf[3],
1652  const cs_real_t djjpf[3],
1653  const cs_real_t gradi[3][3],
1654  const cs_real_t gradj[3][3],
1655  const cs_real_t pi[3],
1656  const cs_real_t pj[3],
1657  const cs_real_t pia[3],
1658  const cs_real_t pja[3],
1659  cs_real_t pifri[3],
1660  cs_real_t pifrj[3],
1661  cs_real_t pjfri[3],
1662  cs_real_t pjfrj[3],
1663  cs_real_t pip[3],
1664  cs_real_t pjp[3],
1665  cs_real_t pipr[3],
1666  cs_real_t pjpr[3])
1667 {
1668  cs_real_t pir[3], pjr[3];
1669  cs_real_t recoi[3], recoj[3];
1670 
1672  diipf,
1673  djjpf,
1674  gradi,
1675  gradj,
1676  pi,
1677  pj,
1678  recoi,
1679  recoj,
1680  pip,
1681  pjp);
1682 
1683  cs_i_relax_c_val_vector(relaxp,
1684  pia,
1685  pja,
1686  recoi,
1687  recoj,
1688  pi,
1689  pj,
1690  pir,
1691  pjr,
1692  pipr,
1693  pjpr);
1694 
1696  pifrj);
1698  pifri);
1700  pjfri);
1702  pjfrj);
1703 }
1704 
1705 /*----------------------------------------------------------------------------*/
1729 /*----------------------------------------------------------------------------*/
1730 
1731 inline static void
1733  const cs_real_t relaxp,
1734  const cs_real_t diipf[3],
1735  const cs_real_t djjpf[3],
1736  const cs_real_t gradi[6][3],
1737  const cs_real_t gradj[6][3],
1738  const cs_real_t pi[6],
1739  const cs_real_t pj[6],
1740  const cs_real_t pia[6],
1741  const cs_real_t pja[6],
1742  cs_real_t pifri[6],
1743  cs_real_t pifrj[6],
1744  cs_real_t pjfri[6],
1745  cs_real_t pjfrj[6],
1746  cs_real_t pip[6],
1747  cs_real_t pjp[6],
1748  cs_real_t pipr[6],
1749  cs_real_t pjpr[6])
1750 {
1751  cs_real_t pir[6], pjr[6];
1752  cs_real_t recoi[6], recoj[6];
1753 
1755  diipf,
1756  djjpf,
1757  gradi,
1758  gradj,
1759  pi,
1760  pj,
1761  recoi,
1762  recoj,
1763  pip,
1764  pjp);
1765 
1766  cs_i_relax_c_val_tensor(relaxp,
1767  pia,
1768  pja,
1769  recoi,
1770  recoj,
1771  pi,
1772  pj,
1773  pir,
1774  pjr,
1775  pipr,
1776  pjpr);
1777 
1779  pifrj);
1781  pifri);
1783  pjfri);
1785  pjfrj);
1786 }
1787 
1788 /*----------------------------------------------------------------------------*/
1805 /*----------------------------------------------------------------------------*/
1806 
1807 inline static void
1809  const cs_real_t diipf[3],
1810  const cs_real_t djjpf[3],
1811  const cs_real_t gradi[3],
1812  const cs_real_t gradj[3],
1813  const cs_real_t pi,
1814  const cs_real_t pj,
1815  cs_real_t *pif,
1816  cs_real_t *pjf,
1817  cs_real_t *pip,
1818  cs_real_t *pjp)
1819 {
1820  cs_real_t recoi, recoj;
1821 
1822  cs_i_compute_quantities(bldfrp,
1823  diipf,
1824  djjpf,
1825  gradi,
1826  gradj,
1827  pi,
1828  pj,
1829  &recoi,
1830  &recoj,
1831  pip,
1832  pjp);
1833 
1834  cs_upwind_f_val(pi, pif);
1835  cs_upwind_f_val(pj, pjf);
1836 }
1837 
1838 /*----------------------------------------------------------------------------*/
1855 /*----------------------------------------------------------------------------*/
1856 
1857 inline static void
1859  const cs_real_t diipf[3],
1860  const cs_real_t djjpf[3],
1861  const cs_real_t gradi[3][3],
1862  const cs_real_t gradj[3][3],
1863  const cs_real_t pi[3],
1864  const cs_real_t pj[3],
1865  cs_real_t pif[3],
1866  cs_real_t pjf[3],
1867  cs_real_t pip[3],
1868  cs_real_t pjp[3])
1869 {
1870  cs_real_t recoi[3], recoj[3];
1871 
1873  diipf,
1874  djjpf,
1875  gradi,
1876  gradj,
1877  pi,
1878  pj,
1879  recoi,
1880  recoj,
1881  pip,
1882  pjp);
1883 
1884  cs_upwind_f_val_vector(pi, pif);
1885  cs_upwind_f_val_vector(pj, pjf);
1886 }
1887 
1888 /*----------------------------------------------------------------------------*/
1905 /*----------------------------------------------------------------------------*/
1906 
1907 inline static void
1909  const cs_real_t diipf[3],
1910  const cs_real_t djjpf[3],
1911  const cs_real_t gradi[6][3],
1912  const cs_real_t gradj[6][3],
1913  const cs_real_t pi[6],
1914  const cs_real_t pj[6],
1915  cs_real_t pif[6],
1916  cs_real_t pjf[6],
1917  cs_real_t pip[6],
1918  cs_real_t pjp[6])
1919 {
1920  cs_real_t recoi[6], recoj[6];
1921 
1923  diipf,
1924  djjpf,
1925  gradi,
1926  gradj,
1927  pi,
1928  pj,
1929  recoi,
1930  recoj,
1931  pip,
1932  pjp);
1933 
1934  cs_upwind_f_val_tensor(pi, pif);
1935  cs_upwind_f_val_tensor(pj, pjf);
1936 
1937 }
1938 
1939 /*----------------------------------------------------------------------------*/
1972 /*----------------------------------------------------------------------------*/
1973 
1974 inline static void
1976  const int ischcp,
1977  const double relaxp,
1978  const double blencp,
1979  const cs_real_t weight,
1980  const cs_real_t cell_ceni[3],
1981  const cs_real_t cell_cenj[3],
1982  const cs_real_t i_face_cog[3],
1983  const cs_real_t diipf[3],
1984  const cs_real_t djjpf[3],
1985  const cs_real_t gradi[3],
1986  const cs_real_t gradj[3],
1987  const cs_real_t gradupi[3],
1988  const cs_real_t gradupj[3],
1989  const cs_real_t pi,
1990  const cs_real_t pj,
1991  const cs_real_t pia,
1992  const cs_real_t pja,
1993  cs_real_t *pifri,
1994  cs_real_t *pifrj,
1995  cs_real_t *pjfri,
1996  cs_real_t *pjfrj,
1997  cs_real_t *pip,
1998  cs_real_t *pjp,
1999  cs_real_t *pipr,
2000  cs_real_t *pjpr)
2001 {
2002  cs_real_t pir, pjr;
2003  cs_real_t recoi, recoj;
2004 
2005  cs_i_compute_quantities(bldfrp,
2006  diipf,
2007  djjpf,
2008  gradi,
2009  gradj,
2010  pi,
2011  pj,
2012  &recoi,
2013  &recoj,
2014  pip,
2015  pjp);
2016 
2017  cs_i_relax_c_val(relaxp,
2018  pia,
2019  pja,
2020  recoi,
2021  recoj,
2022  pi,
2023  pj,
2024  &pir,
2025  &pjr,
2026  pipr,
2027  pjpr);
2028 
2029  if (ischcp == 1) {
2030 
2031  /* Centered
2032  --------*/
2033 
2034  cs_centered_f_val(weight,
2035  *pip,
2036  *pjpr,
2037  pifrj);
2038  cs_centered_f_val(weight,
2039  *pipr,
2040  *pjp,
2041  pifri);
2042  cs_centered_f_val(weight,
2043  *pipr,
2044  *pjp,
2045  pjfri);
2046  cs_centered_f_val(weight,
2047  *pip,
2048  *pjpr,
2049  pjfrj);
2050 
2051  } else if (ischcp == 0) {
2052 
2053  /* Original SOLU
2054  --------------*/
2055 
2056  cs_solu_f_val(cell_ceni,
2057  i_face_cog,
2058  gradi,
2059  pi,
2060  pifrj);
2061  cs_solu_f_val(cell_ceni,
2062  i_face_cog,
2063  gradi,
2064  pir,
2065  pifri);
2066  cs_solu_f_val(cell_cenj,
2067  i_face_cog,
2068  gradj,
2069  pj,
2070  pjfri);
2071  cs_solu_f_val(cell_cenj,
2072  i_face_cog,
2073  gradj,
2074  pjr,
2075  pjfrj);
2076 
2077  } else {
2078 
2079  /* SOLU
2080  ----*/
2081 
2082  cs_solu_f_val(cell_ceni,
2083  i_face_cog,
2084  gradupi,
2085  pi,
2086  pifrj);
2087  cs_solu_f_val(cell_ceni,
2088  i_face_cog,
2089  gradupi,
2090  pir,
2091  pifri);
2092  cs_solu_f_val(cell_cenj,
2093  i_face_cog,
2094  gradupj,
2095  pj,
2096  pjfri);
2097  cs_solu_f_val(cell_cenj,
2098  i_face_cog,
2099  gradupj,
2100  pjr,
2101  pjfrj);
2102 
2103  }
2104 
2105  /* Blending
2106  --------*/
2107 
2108  cs_blend_f_val(blencp,
2109  pi,
2110  pifrj);
2111  cs_blend_f_val(blencp,
2112  pir,
2113  pifri);
2114  cs_blend_f_val(blencp,
2115  pj,
2116  pjfri);
2117  cs_blend_f_val(blencp,
2118  pjr,
2119  pjfrj);
2120 }
2121 
2122 /*----------------------------------------------------------------------------*/
2153 /*----------------------------------------------------------------------------*/
2154 
2155 inline static void
2157  const int ischcp,
2158  const double relaxp,
2159  const double blencp,
2160  const cs_real_t weight,
2161  const cs_real_3_t cell_ceni,
2162  const cs_real_3_t cell_cenj,
2163  const cs_real_3_t i_face_cog,
2164  const cs_real_3_t diipf,
2165  const cs_real_3_t djjpf,
2166  const cs_real_33_t gradi,
2167  const cs_real_33_t gradj,
2168  const cs_real_3_t pi,
2169  const cs_real_3_t pj,
2170  const cs_real_3_t pia,
2171  const cs_real_3_t pja,
2172  cs_real_t pifri[3],
2173  cs_real_t pifrj[3],
2174  cs_real_t pjfri[3],
2175  cs_real_t pjfrj[3],
2176  cs_real_t pip[3],
2177  cs_real_t pjp[3],
2178  cs_real_t pipr[3],
2179  cs_real_t pjpr[3])
2180 {
2181  cs_real_t pir[3], pjr[3];
2182  cs_real_t recoi[3], recoj[3];
2183 
2185  diipf,
2186  djjpf,
2187  gradi,
2188  gradj,
2189  pi,
2190  pj,
2191  recoi,
2192  recoj,
2193  pip,
2194  pjp);
2195 
2196  cs_i_relax_c_val_vector(relaxp,
2197  pia,
2198  pja,
2199  recoi,
2200  recoj,
2201  pi,
2202  pj,
2203  pir,
2204  pjr,
2205  pipr,
2206  pjpr);
2207 
2208  if (ischcp == 1) {
2209 
2210  /* Centered
2211  --------*/
2212 
2213  cs_centered_f_val_vector(weight,
2214  pip,
2215  pjpr,
2216  pifrj);
2217  cs_centered_f_val_vector(weight,
2218  pipr,
2219  pjp,
2220  pifri);
2221  cs_centered_f_val_vector(weight,
2222  pipr,
2223  pjp,
2224  pjfri);
2225  cs_centered_f_val_vector(weight,
2226  pip,
2227  pjpr,
2228  pjfrj);
2229 
2230  } else {
2231 
2232  /* Second order
2233  ------------*/
2234 
2235  cs_solu_f_val_vector(cell_ceni,
2236  i_face_cog,
2237  gradi,
2238  pi,
2239  pifrj);
2240  cs_solu_f_val_vector(cell_ceni,
2241  i_face_cog,
2242  gradi,
2243  pir,
2244  pifri);
2245  cs_solu_f_val_vector(cell_cenj,
2246  i_face_cog,
2247  gradj,
2248  pj,
2249  pjfri);
2250  cs_solu_f_val_vector(cell_cenj,
2251  i_face_cog,
2252  gradj,
2253  pjr,
2254  pjfrj);
2255 
2256  }
2257 
2258  /* Blending
2259  --------*/
2260  cs_blend_f_val_vector(blencp,
2261  pi,
2262  pifrj);
2263  cs_blend_f_val_vector(blencp,
2264  pir,
2265  pifri);
2266  cs_blend_f_val_vector(blencp,
2267  pj,
2268  pjfri);
2269  cs_blend_f_val_vector(blencp,
2270  pjr,
2271  pjfrj);
2272 
2273 }
2274 
2275 /*----------------------------------------------------------------------------*/
2306 /*----------------------------------------------------------------------------*/
2307 
2308 inline static void
2310  const int ischcp,
2311  const double relaxp,
2312  const double blencp,
2313  const cs_real_t weight,
2314  const cs_real_3_t cell_ceni,
2315  const cs_real_3_t cell_cenj,
2316  const cs_real_3_t i_face_cog,
2317  const cs_real_3_t diipf,
2318  const cs_real_3_t djjpf,
2319  const cs_real_63_t gradi,
2320  const cs_real_63_t gradj,
2321  const cs_real_6_t pi,
2322  const cs_real_6_t pj,
2323  const cs_real_6_t pia,
2324  const cs_real_6_t pja,
2325  cs_real_t pifri[6],
2326  cs_real_t pifrj[6],
2327  cs_real_t pjfri[6],
2328  cs_real_t pjfrj[6],
2329  cs_real_t pip[6],
2330  cs_real_t pjp[6],
2331  cs_real_t pipr[6],
2332  cs_real_t pjpr[6])
2333 
2334 {
2335  cs_real_t pir[6], pjr[6];
2336  cs_real_t recoi[6], recoj[6];
2337 
2339  diipf,
2340  djjpf,
2341  gradi,
2342  gradj,
2343  pi,
2344  pj,
2345  recoi,
2346  recoj,
2347  pip,
2348  pjp);
2349 
2350  cs_i_relax_c_val_tensor(relaxp,
2351  pia,
2352  pja,
2353  recoi,
2354  recoj,
2355  pi,
2356  pj,
2357  pir,
2358  pjr,
2359  pipr,
2360  pjpr);
2361 
2362  if (ischcp == 1) {
2363 
2364  /* Centered
2365  --------*/
2366 
2367  cs_centered_f_val_tensor(weight,
2368  pip,
2369  pjpr,
2370  pifrj);
2371  cs_centered_f_val_tensor(weight,
2372  pipr,
2373  pjp,
2374  pifri);
2375  cs_centered_f_val_tensor(weight,
2376  pipr,
2377  pjp,
2378  pjfri);
2379  cs_centered_f_val_tensor(weight,
2380  pip,
2381  pjpr,
2382  pjfrj);
2383 
2384  } else {
2385 
2386  /* Second order
2387  ------------*/
2388 
2389  cs_solu_f_val_tensor(cell_ceni,
2390  i_face_cog,
2391  gradi,
2392  pi,
2393  pifrj);
2394  cs_solu_f_val_tensor(cell_ceni,
2395  i_face_cog,
2396  gradi,
2397  pir,
2398  pifri);
2399  cs_solu_f_val_tensor(cell_cenj,
2400  i_face_cog,
2401  gradj,
2402  pj,
2403  pjfri);
2404  cs_solu_f_val_tensor(cell_cenj,
2405  i_face_cog,
2406  gradj,
2407  pjr,
2408  pjfrj);
2409 
2410  }
2411 
2412  /* Blending
2413  --------*/
2414 
2415  cs_blend_f_val_tensor(blencp,
2416  pi,
2417  pifrj);
2418  cs_blend_f_val_tensor(blencp,
2419  pir,
2420  pifri);
2421  cs_blend_f_val_tensor(blencp,
2422  pj,
2423  pjfri);
2424  cs_blend_f_val_tensor(blencp,
2425  pjr,
2426  pjfrj);
2427 }
2428 
2429 /*----------------------------------------------------------------------------*/
2459 /*----------------------------------------------------------------------------*/
2460 
2461 inline static void
2463  const int ischcp,
2464  const double blencp,
2465  const cs_real_t weight,
2466  const cs_real_3_t cell_ceni,
2467  const cs_real_3_t cell_cenj,
2468  const cs_real_3_t i_face_cog,
2469  const cs_real_t hybrid_blend_i,
2470  const cs_real_t hybrid_blend_j,
2471  const cs_real_3_t diipf,
2472  const cs_real_3_t djjpf,
2473  const cs_real_3_t gradi,
2474  const cs_real_3_t gradj,
2475  const cs_real_3_t gradupi,
2476  const cs_real_3_t gradupj,
2477  const cs_real_t pi,
2478  const cs_real_t pj,
2479  cs_real_t *pif,
2480  cs_real_t *pjf,
2481  cs_real_t *pip,
2482  cs_real_t *pjp)
2483 {
2484  cs_real_t recoi, recoj;
2485 
2486  cs_i_compute_quantities(bldfrp,
2487  diipf,
2488  djjpf,
2489  gradi,
2490  gradj,
2491  pi,
2492  pj,
2493  &recoi,
2494  &recoj,
2495  pip,
2496  pjp);
2497 
2498 
2499  if (ischcp == 1) {
2500 
2501  /* Centered
2502  --------*/
2503 
2504  cs_centered_f_val(weight,
2505  *pip,
2506  *pjp,
2507  pif);
2508  cs_centered_f_val(weight,
2509  *pip,
2510  *pjp,
2511  pjf);
2512 
2513  } else if (ischcp == 0) {
2514 
2515  /* Legacy SOLU
2516  -----------*/
2517 
2518  cs_solu_f_val(cell_ceni,
2519  i_face_cog,
2520  gradi,
2521  pi,
2522  pif);
2523  cs_solu_f_val(cell_cenj,
2524  i_face_cog,
2525  gradj,
2526  pj,
2527  pjf);
2528 
2529  } else if (ischcp == 3) {
2530 
2531  /* Centered
2532  --------*/
2533 
2534  cs_centered_f_val(weight,
2535  *pip,
2536  *pjp,
2537  pif);
2538  cs_centered_f_val(weight,
2539  *pip,
2540  *pjp,
2541  pjf);
2542 
2543  /* Legacy SOLU
2544  -----------*/
2545  cs_real_t pif_up, pjf_up;
2546  cs_real_t hybrid_blend_interp;
2547 
2548  cs_solu_f_val(cell_ceni,
2549  i_face_cog,
2550  gradi,
2551  pi,
2552  &pif_up);
2553  cs_solu_f_val(cell_cenj,
2554  i_face_cog,
2555  gradj,
2556  pj,
2557  &pjf_up);
2558 
2559  hybrid_blend_interp = fmin(hybrid_blend_i,hybrid_blend_j);
2560  *pif = hybrid_blend_interp*(*pif) + (1. - hybrid_blend_interp)*pif_up;
2561  *pjf = hybrid_blend_interp*(*pjf) + (1. - hybrid_blend_interp)*pjf_up;
2562 
2563  } else {
2564 
2565  /* SOLU
2566  ----*/
2567 
2568  cs_solu_f_val(cell_ceni,
2569  i_face_cog,
2570  gradupi,
2571  pi,
2572  pif);
2573  cs_solu_f_val(cell_cenj,
2574  i_face_cog,
2575  gradupj,
2576  pj,
2577  pjf);
2578 
2579  }
2580 
2581 
2582  /* Blending
2583  --------*/
2584 
2585  cs_blend_f_val(blencp,
2586  pi,
2587  pif);
2588  cs_blend_f_val(blencp,
2589  pj,
2590  pjf);
2591 }
2592 
2593 /*----------------------------------------------------------------------------*/
2619 /*----------------------------------------------------------------------------*/
2620 
2621 inline static void
2623  const int ischcp,
2624  const double blencp,
2625  const cs_real_t weight,
2626  const cs_real_3_t cell_ceni,
2627  const cs_real_3_t cell_cenj,
2628  const cs_real_3_t i_face_cog,
2629  const cs_real_t hybrid_blend_i,
2630  const cs_real_t hybrid_blend_j,
2631  const cs_real_3_t diipf,
2632  const cs_real_3_t djjpf,
2633  const cs_real_33_t gradi,
2634  const cs_real_33_t gradj,
2635  const cs_real_3_t pi,
2636  const cs_real_3_t pj,
2637  cs_real_t pif[3],
2638  cs_real_t pjf[3],
2639  cs_real_t pip[3],
2640  cs_real_t pjp[3])
2641 
2642 {
2643  cs_real_t recoi[3], recoj[3];
2644 
2646  diipf,
2647  djjpf,
2648  gradi,
2649  gradj,
2650  pi,
2651  pj,
2652  recoi,
2653  recoj,
2654  pip,
2655  pjp);
2656 
2657  if (ischcp == 1) {
2658 
2659  /* Centered
2660  --------*/
2661 
2662  cs_centered_f_val_vector(weight,
2663  pip,
2664  pjp,
2665  pif);
2666  cs_centered_f_val_vector(weight,
2667  pip,
2668  pjp,
2669  pjf);
2670  } else if (ischcp == 3) {
2671 
2672  /* Centered
2673  --------*/
2674 
2675  cs_centered_f_val_vector(weight,
2676  pip,
2677  pjp,
2678  pif);
2679  cs_centered_f_val_vector(weight,
2680  pip,
2681  pjp,
2682  pjf);
2683 
2684  /* SOLU
2685  -----*/
2686  cs_real_t pif_up[3], pjf_up[3];
2687  cs_real_t hybrid_blend_interp;
2688 
2689  cs_solu_f_val_vector(cell_ceni,
2690  i_face_cog,
2691  gradi,
2692  pi,
2693  pif_up);
2694  cs_solu_f_val_vector(cell_cenj,
2695  i_face_cog,
2696  gradj,
2697  pj,
2698  pjf_up);
2699 
2700  hybrid_blend_interp = fmin(hybrid_blend_i,hybrid_blend_j);
2701  for (int isou = 0; isou < 3; isou++) {
2702  pif[isou] = hybrid_blend_interp *pif[isou]
2703  + (1. - hybrid_blend_interp)*pif_up[isou];
2704  pjf[isou] = hybrid_blend_interp *pjf[isou]
2705  + (1. - hybrid_blend_interp)*pjf_up[isou];
2706  }
2707  } else {
2708 
2709  /* Second order
2710  ------------*/
2711 
2712  cs_solu_f_val_vector(cell_ceni,
2713  i_face_cog,
2714  gradi,
2715  pi,
2716  pif);
2717  cs_solu_f_val_vector(cell_cenj,
2718  i_face_cog,
2719  gradj,
2720  pj,
2721  pjf);
2722 
2723  }
2724 
2725  /* Blending
2726  --------*/
2727 
2728  cs_blend_f_val_vector(blencp,
2729  pi,
2730  pif);
2731  cs_blend_f_val_vector(blencp,
2732  pj,
2733  pjf);
2734 
2735 }
2736 
2737 /*----------------------------------------------------------------------------*/
2761 /*----------------------------------------------------------------------------*/
2762 
2763 inline static void
2765  const int ischcp,
2766  const double blencp,
2767  const cs_real_t weight,
2768  const cs_real_3_t cell_ceni,
2769  const cs_real_3_t cell_cenj,
2770  const cs_real_3_t i_face_cog,
2771  const cs_real_3_t diipf,
2772  const cs_real_3_t djjpf,
2773  const cs_real_63_t gradi,
2774  const cs_real_63_t gradj,
2775  const cs_real_6_t pi,
2776  const cs_real_6_t pj,
2777  cs_real_t pif[6],
2778  cs_real_t pjf[6],
2779  cs_real_t pip[6],
2780  cs_real_t pjp[6])
2781 
2782 {
2783  cs_real_t recoi[6], recoj[6];
2784 
2786  diipf,
2787  djjpf,
2788  gradi,
2789  gradj,
2790  pi,
2791  pj,
2792  recoi,
2793  recoj,
2794  pip,
2795  pjp);
2796 
2797  if (ischcp == 1) {
2798 
2799  /* Centered
2800  --------*/
2801 
2802  cs_centered_f_val_tensor(weight,
2803  pip,
2804  pjp,
2805  pif);
2806  cs_centered_f_val_tensor(weight,
2807  pip,
2808  pjp,
2809  pjf);
2810 
2811  } else {
2812 
2813  /* Second order
2814  ------------*/
2815 
2816  cs_solu_f_val_tensor(cell_ceni,
2817  i_face_cog,
2818  gradi,
2819  pi,
2820  pif);
2821  cs_solu_f_val_tensor(cell_cenj,
2822  i_face_cog,
2823  gradj,
2824  pj,
2825  pjf);
2826 
2827  }
2828 
2829  /* Blending
2830  --------*/
2831 
2832  cs_blend_f_val_tensor(blencp,
2833  pi,
2834  pif);
2835  cs_blend_f_val_tensor(blencp,
2836  pj,
2837  pjf);
2838 
2839 }
2840 
2841 /*----------------------------------------------------------------------------*/
2885 /*----------------------------------------------------------------------------*/
2886 
2887 inline static void
2888 cs_i_cd_steady_slope_test(bool *upwind_switch,
2889  const int iconvp,
2890  const cs_real_t bldfrp,
2891  const int ischcp,
2892  const double relaxp,
2893  const double blencp,
2894  const double blend_st,
2895  const cs_real_t weight,
2896  const cs_real_t i_dist,
2897  const cs_real_t i_face_surf,
2898  const cs_real_3_t cell_ceni,
2899  const cs_real_3_t cell_cenj,
2900  const cs_real_3_t i_face_normal,
2901  const cs_real_3_t i_face_cog,
2902  const cs_real_3_t diipf,
2903  const cs_real_3_t djjpf,
2904  const cs_real_t i_massflux,
2905  const cs_real_3_t gradi,
2906  const cs_real_3_t gradj,
2907  const cs_real_3_t gradupi,
2908  const cs_real_3_t gradupj,
2909  const cs_real_3_t gradsti,
2910  const cs_real_3_t gradstj,
2911  const cs_real_t pi,
2912  const cs_real_t pj,
2913  const cs_real_t pia,
2914  const cs_real_t pja,
2915  cs_real_t *pifri,
2916  cs_real_t *pifrj,
2917  cs_real_t *pjfri,
2918  cs_real_t *pjfrj,
2919  cs_real_t *pip,
2920  cs_real_t *pjp,
2921  cs_real_t *pipr,
2922  cs_real_t *pjpr)
2923 {
2924  cs_real_t pir, pjr;
2925  cs_real_t recoi, recoj;
2926  cs_real_t testij, tesqck;
2927 
2928  *upwind_switch = false;
2929 
2930  cs_i_compute_quantities(bldfrp,
2931  diipf,
2932  djjpf,
2933  gradi,
2934  gradj,
2935  pi,
2936  pj,
2937  &recoi,
2938  &recoj,
2939  pip,
2940  pjp);
2941 
2942  cs_i_relax_c_val(relaxp,
2943  pia,
2944  pja,
2945  recoi,
2946  recoj,
2947  pi,
2948  pj,
2949  &pir,
2950  &pjr,
2951  pipr,
2952  pjpr);
2953 
2954  /* Convection slope test is needed only when iconv >0 */
2955  if (iconvp > 0) {
2956  cs_slope_test(pi,
2957  pj,
2958  i_dist,
2959  i_face_surf,
2960  i_face_normal,
2961  gradi,
2962  gradj,
2963  gradsti,
2964  gradstj,
2965  i_massflux,
2966  &testij,
2967  &tesqck);
2968 
2969  if (ischcp==1) {
2970 
2971  /* Centered
2972  --------*/
2973 
2974  cs_centered_f_val(weight,
2975  *pip,
2976  *pjpr,
2977  pifrj);
2978  cs_centered_f_val(weight,
2979  *pipr,
2980  *pjp,
2981  pifri);
2982  cs_centered_f_val(weight,
2983  *pipr,
2984  *pjp,
2985  pjfri);
2986  cs_centered_f_val(weight,
2987  *pip,
2988  *pjpr,
2989  pjfrj);
2990 
2991  } else if (ischcp == 0) {
2992 
2993  /* Second order
2994  ------------*/
2995 
2996  cs_solu_f_val(cell_ceni,
2997  i_face_cog,
2998  gradi,
2999  pi,
3000  pifrj);
3001  cs_solu_f_val(cell_ceni,
3002  i_face_cog,
3003  gradi,
3004  pir,
3005  pifri);
3006  cs_solu_f_val(cell_cenj,
3007  i_face_cog,
3008  gradj,
3009  pj,
3010  pjfri);
3011  cs_solu_f_val(cell_cenj,
3012  i_face_cog,
3013  gradj,
3014  pjr,
3015  pjfrj);
3016 
3017  } else {
3018 
3019  /* SOLU
3020  -----*/
3021 
3022  cs_solu_f_val(cell_ceni,
3023  i_face_cog,
3024  gradupi,
3025  pi,
3026  pifrj);
3027  cs_solu_f_val(cell_ceni,
3028  i_face_cog,
3029  gradupi,
3030  pir,
3031  pifri);
3032  cs_solu_f_val(cell_cenj,
3033  i_face_cog,
3034  gradupj,
3035  pj,
3036  pjfri);
3037  cs_solu_f_val(cell_cenj,
3038  i_face_cog,
3039  gradupj,
3040  pjr,
3041  pjfrj);
3042  }
3043 
3044 
3045  /* Slope test: Pourcentage of upwind
3046  ----------------------------------*/
3047 
3048  if (tesqck <= 0. || testij <= 0.) {
3049 
3050  cs_blend_f_val(blend_st,
3051  pi,
3052  pifrj);
3053  cs_blend_f_val(blend_st,
3054  pir,
3055  pifri);
3056  cs_blend_f_val(blend_st,
3057  pj,
3058  pjfri);
3059  cs_blend_f_val(blend_st,
3060  pjr,
3061  pjfrj);
3062 
3063  *upwind_switch = true;
3064 
3065  }
3066 
3067 
3068  /* Blending
3069  --------*/
3070 
3071  cs_blend_f_val(blencp,
3072  pi,
3073  pifrj);
3074  cs_blend_f_val(blencp,
3075  pir,
3076  pifri);
3077  cs_blend_f_val(blencp,
3078  pj,
3079  pjfri);
3080  cs_blend_f_val(blencp,
3081  pjr,
3082  pjfrj);
3083 
3084  /* If iconv=0 p*fr* are useless */
3085  } else {
3087  pifrj);
3088  cs_upwind_f_val(pir,
3089  pifri);
3090  cs_upwind_f_val(pj,
3091  pjfri);
3092  cs_upwind_f_val(pjr,
3093  pjfrj);
3094  }
3095 
3096 }
3097 
3098 /*----------------------------------------------------------------------------*/
3140 /*----------------------------------------------------------------------------*/
3141 
3142 inline static void
3144  const int iconvp,
3145  const cs_real_t bldfrp,
3146  const int ischcp,
3147  const double relaxp,
3148  const double blencp,
3149  const double blend_st,
3150  const cs_real_t weight,
3151  const cs_real_t i_dist,
3152  const cs_real_t i_face_surf,
3153  const cs_real_3_t cell_ceni,
3154  const cs_real_3_t cell_cenj,
3155  const cs_real_3_t i_face_normal,
3156  const cs_real_3_t i_face_cog,
3157  const cs_real_3_t diipf,
3158  const cs_real_3_t djjpf,
3159  const cs_real_t i_massflux,
3160  const cs_real_33_t gradi,
3161  const cs_real_33_t gradj,
3162  const cs_real_33_t grdpai,
3163  const cs_real_33_t grdpaj,
3164  const cs_real_3_t pi,
3165  const cs_real_3_t pj,
3166  const cs_real_3_t pia,
3167  const cs_real_3_t pja,
3168  cs_real_t pifri[3],
3169  cs_real_t pifrj[3],
3170  cs_real_t pjfri[3],
3171  cs_real_t pjfrj[3],
3172  cs_real_t pip[3],
3173  cs_real_t pjp[3],
3174  cs_real_t pipr[3],
3175  cs_real_t pjpr[3])
3176 {
3177  cs_real_t pir[3], pjr[3];
3178  cs_real_t recoi[3], recoj[3];
3179  cs_real_t testij, tesqck;
3180  int isou;
3181 
3183  diipf,
3184  djjpf,
3185  gradi,
3186  gradj,
3187  pi,
3188  pj,
3189  recoi,
3190  recoj,
3191  pip,
3192  pjp);
3193 
3194  cs_i_relax_c_val_vector(relaxp,
3195  pia,
3196  pja,
3197  recoi,
3198  recoj,
3199  pi,
3200  pj,
3201  pir,
3202  pjr,
3203  pipr,
3204  pjpr);
3205 
3206  /* Convection slope test is needed only when iconv >0 */
3207  if (iconvp > 0) {
3209  pj,
3210  i_dist,
3211  i_face_surf,
3212  i_face_normal,
3213  gradi,
3214  gradj,
3215  grdpai,
3216  grdpaj,
3217  i_massflux,
3218  &testij,
3219  &tesqck);
3220 
3221  for (isou = 0; isou < 3; isou++) {
3222  if (ischcp==1) {
3223 
3224  /* Centered
3225  --------*/
3226 
3227  cs_centered_f_val(weight,
3228  pip[isou],
3229  pjpr[isou],
3230  &pifrj[isou]);
3231  cs_centered_f_val(weight,
3232  pipr[isou],
3233  pjp[isou],
3234  &pifri[isou]);
3235  cs_centered_f_val(weight,
3236  pipr[isou],
3237  pjp[isou],
3238  &pjfri[isou]);
3239  cs_centered_f_val(weight,
3240  pip[isou],
3241  pjpr[isou],
3242  &pjfrj[isou]);
3243 
3244  } else {
3245 
3246  /* Second order
3247  ------------*/
3248 
3249  cs_solu_f_val(cell_ceni,
3250  i_face_cog,
3251  gradi[isou],
3252  pi[isou],
3253  &pifrj[isou]);
3254  cs_solu_f_val(cell_ceni,
3255  i_face_cog,
3256  gradi[isou],
3257  pir[isou],
3258  &pifri[isou]);
3259  cs_solu_f_val(cell_cenj,
3260  i_face_cog,
3261  gradj[isou],
3262  pj[isou],
3263  &pjfri[isou]);
3264  cs_solu_f_val(cell_cenj,
3265  i_face_cog,
3266  gradj[isou],
3267  pjr[isou],
3268  &pjfrj[isou]);
3269 
3270  }
3271 
3272  }
3273 
3274  /* Slope test: Pourcentage of upwind
3275  ----------------------------------*/
3276 
3277  if (tesqck <= 0. || testij <= 0.) {
3278  cs_blend_f_val_vector(blend_st,
3279  pi,
3280  pifrj);
3281  cs_blend_f_val_vector(blend_st,
3282  pir,
3283  pifri);
3284  cs_blend_f_val_vector(blend_st,
3285  pj,
3286  pjfri);
3287  cs_blend_f_val_vector(blend_st,
3288  pjr,
3289  pjfrj);
3290 
3291  *upwind_switch = true;
3292  }
3293 
3294 
3295  /* Blending
3296  --------*/
3297  cs_blend_f_val_vector(blencp,
3298  pi,
3299  pifrj);
3300  cs_blend_f_val_vector(blencp,
3301  pir,
3302  pifri);
3303  cs_blend_f_val_vector(blencp,
3304  pj,
3305  pjfri);
3306  cs_blend_f_val_vector(blencp,
3307  pjr,
3308  pjfrj);
3309 
3310  /* If iconv=0 p*fr* are useless */
3311  } else {
3312  for (isou = 0; isou < 3; isou++) {
3313  cs_upwind_f_val(pi[isou],
3314  &pifrj[isou]);
3315  cs_upwind_f_val(pir[isou],
3316  &pifri[isou]);
3317  cs_upwind_f_val(pj[isou],
3318  &pjfri[isou]);
3319  cs_upwind_f_val(pjr[isou],
3320  &pjfrj[isou]);
3321  }
3322  }
3323 
3324 }
3325 
3326 /*----------------------------------------------------------------------------*/
3368 /*----------------------------------------------------------------------------*/
3369 
3370 inline static void
3372  const int iconvp,
3373  const cs_real_t bldfrp,
3374  const int ischcp,
3375  const double relaxp,
3376  const double blencp,
3377  const double blend_st,
3378  const cs_real_t weight,
3379  const cs_real_t i_dist,
3380  const cs_real_t i_face_surf,
3381  const cs_real_3_t cell_ceni,
3382  const cs_real_3_t cell_cenj,
3383  const cs_real_3_t i_face_normal,
3384  const cs_real_3_t i_face_cog,
3385  const cs_real_3_t diipf,
3386  const cs_real_3_t djjpf,
3387  const cs_real_t i_massflux,
3388  const cs_real_63_t gradi,
3389  const cs_real_63_t gradj,
3390  const cs_real_63_t grdpai,
3391  const cs_real_63_t grdpaj,
3392  const cs_real_6_t pi,
3393  const cs_real_6_t pj,
3394  const cs_real_6_t pia,
3395  const cs_real_6_t pja,
3396  cs_real_t pifri[6],
3397  cs_real_t pifrj[6],
3398  cs_real_t pjfri[6],
3399  cs_real_t pjfrj[6],
3400  cs_real_t pip[6],
3401  cs_real_t pjp[6],
3402  cs_real_t pipr[6],
3403  cs_real_t pjpr[6])
3404 {
3405  cs_real_t pir[6], pjr[6];
3406  cs_real_t recoi[6], recoj[6];
3407  cs_real_t testij, tesqck;
3408  int isou;
3409 
3411  diipf,
3412  djjpf,
3413  gradi,
3414  gradj,
3415  pi,
3416  pj,
3417  recoi,
3418  recoj,
3419  pip,
3420  pjp);
3421 
3422  cs_i_relax_c_val_tensor(relaxp,
3423  pia,
3424  pja,
3425  recoi,
3426  recoj,
3427  pi,
3428  pj,
3429  pir,
3430  pjr,
3431  pipr,
3432  pjpr);
3433 
3434  /* Convection slope test is needed only when iconv >0 */
3435  if (iconvp > 0) {
3437  pj,
3438  i_dist,
3439  i_face_surf,
3440  i_face_normal,
3441  gradi,
3442  gradj,
3443  grdpai,
3444  grdpaj,
3445  i_massflux,
3446  &testij,
3447  &tesqck);
3448 
3449  for (isou = 0; isou < 6; isou++) {
3450  if (ischcp==1) {
3451 
3452  /* Centered
3453  --------*/
3454 
3455  cs_centered_f_val(weight,
3456  pip[isou],
3457  pjpr[isou],
3458  &pifrj[isou]);
3459  cs_centered_f_val(weight,
3460  pipr[isou],
3461  pjp[isou],
3462  &pifri[isou]);
3463  cs_centered_f_val(weight,
3464  pipr[isou],
3465  pjp[isou],
3466  &pjfri[isou]);
3467  cs_centered_f_val(weight,
3468  pip[isou],
3469  pjpr[isou],
3470  &pjfrj[isou]);
3471 
3472  } else {
3473 
3474  /* Second order
3475  ------------*/
3476 
3477  cs_solu_f_val(cell_ceni,
3478  i_face_cog,
3479  gradi[isou],
3480  pi[isou],
3481  &pifrj[isou]);
3482  cs_solu_f_val(cell_ceni,
3483  i_face_cog,
3484  gradi[isou],
3485  pir[isou],
3486  &pifri[isou]);
3487  cs_solu_f_val(cell_cenj,
3488  i_face_cog,
3489  gradj[isou],
3490  pj[isou],
3491  &pjfri[isou]);
3492  cs_solu_f_val(cell_cenj,
3493  i_face_cog,
3494  gradj[isou],
3495  pjr[isou],
3496  &pjfrj[isou]);
3497 
3498  }
3499 
3500  }
3501 
3502  /* Slope test: Pourcentage of upwind
3503  ----------------------------------*/
3504 
3505  if (tesqck <= 0. || testij <= 0.) {
3506 
3507  cs_blend_f_val_tensor(blend_st,
3508  pi,
3509  pifrj);
3510  cs_blend_f_val_tensor(blend_st,
3511  pir,
3512  pifri);
3513  cs_blend_f_val_tensor(blend_st,
3514  pj,
3515  pjfri);
3516  cs_blend_f_val_tensor(blend_st,
3517  pjr,
3518  pjfrj);
3519 
3520  *upwind_switch = true;
3521 
3522  }
3523 
3524 
3525  /* Blending
3526  --------*/
3527 
3528  cs_blend_f_val_tensor(blencp,
3529  pi,
3530  pifrj);
3531  cs_blend_f_val_tensor(blencp,
3532  pir,
3533  pifri);
3534  cs_blend_f_val_tensor(blencp,
3535  pj,
3536  pjfri);
3537  cs_blend_f_val_tensor(blencp,
3538  pjr,
3539  pjfrj);
3540 
3541  /* If iconv=0 p*fr* are useless */
3542  } else {
3543  for (isou = 0; isou < 6; isou++) {
3544  cs_upwind_f_val(pi[isou],
3545  &pifrj[isou]);
3546  cs_upwind_f_val(pir[isou],
3547  &pifri[isou]);
3548  cs_upwind_f_val(pj[isou],
3549  &pjfri[isou]);
3550  cs_upwind_f_val(pjr[isou],
3551  &pjfrj[isou]);
3552  }
3553  }
3554 
3555 }
3556 
3557 /*----------------------------------------------------------------------------*/
3594 /*----------------------------------------------------------------------------*/
3595 
3596 inline static void
3597 cs_i_cd_unsteady_slope_test(bool *upwind_switch,
3598  const int iconvp,
3599  const cs_real_t bldfrp,
3600  const int ischcp,
3601  const double blencp,
3602  const double blend_st,
3603  const cs_real_t weight,
3604  const cs_real_t i_dist,
3605  const cs_real_t i_face_surf,
3606  const cs_real_3_t cell_ceni,
3607  const cs_real_3_t cell_cenj,
3608  const cs_real_3_t i_face_normal,
3609  const cs_real_3_t i_face_cog,
3610  const cs_real_3_t diipf,
3611  const cs_real_3_t djjpf,
3612  const cs_real_t i_massflux,
3613  const cs_real_3_t gradi,
3614  const cs_real_3_t gradj,
3615  const cs_real_3_t gradupi,
3616  const cs_real_3_t gradupj,
3617  const cs_real_3_t gradsti,
3618  const cs_real_3_t gradstj,
3619  const cs_real_t pi,
3620  const cs_real_t pj,
3621  cs_real_t *pif,
3622  cs_real_t *pjf,
3623  cs_real_t *pip,
3624  cs_real_t *pjp)
3625 {
3626  CS_UNUSED(blend_st);
3627 
3628  cs_real_t recoi, recoj;
3629  cs_real_t testij, tesqck;
3630 
3631  *upwind_switch = false;
3632 
3633  cs_i_compute_quantities(bldfrp,
3634  diipf,
3635  djjpf,
3636  gradi,
3637  gradj,
3638  pi,
3639  pj,
3640  &recoi,
3641  &recoj,
3642  pip,
3643  pjp);
3644 
3645  /* Convection slope test is needed only when iconv >0 */
3646  if (iconvp > 0) {
3647  cs_slope_test(pi,
3648  pj,
3649  i_dist,
3650  i_face_surf,
3651  i_face_normal,
3652  gradi,
3653  gradj,
3654  gradsti,
3655  gradstj,
3656  i_massflux,
3657  &testij,
3658  &tesqck);
3659 
3660  if (ischcp==1) {
3661 
3662  /* Centered
3663  --------*/
3664 
3665  cs_centered_f_val(weight,
3666  *pip,
3667  *pjp,
3668  pif);
3669  cs_centered_f_val(weight,
3670  *pip,
3671  *pjp,
3672  pjf);
3673 
3674  } else if (ischcp == 0) {
3675 
3676  /* Original SOLU
3677  --------------*/
3678 
3679  cs_solu_f_val(cell_ceni,
3680  i_face_cog,
3681  gradi,
3682  pi,
3683  pif);
3684  cs_solu_f_val(cell_cenj,
3685  i_face_cog,
3686  gradj,
3687  pj,
3688  pjf);
3689 
3690  } else {
3691 
3692  /* SOLU
3693  -----*/
3694 
3695  cs_solu_f_val(cell_ceni,
3696  i_face_cog,
3697  gradupi,
3698  pi,
3699  pif);
3700  cs_solu_f_val(cell_cenj,
3701  i_face_cog,
3702  gradupj,
3703  pj,
3704  pjf);
3705 
3706  }
3707 
3708  /* Slope test: Pourcentage of upwind
3709  ----------------------------------*/
3710 
3711  if (tesqck<=0. || testij<=0.) {
3712 
3713  cs_blend_f_val(blend_st,
3714  pi,
3715  pif);
3716  cs_blend_f_val(blend_st,
3717  pj,
3718  pjf);
3719 
3720  *upwind_switch = true;
3721 
3722  }
3723 
3724  /* Blending
3725  --------*/
3726 
3727  cs_blend_f_val(blencp,
3728  pi,
3729  pif);
3730  cs_blend_f_val(blencp,
3731  pj,
3732  pjf);
3733 
3734  /* If iconv=0 p*f are useless */
3735  } else {
3737  pif);
3738  cs_upwind_f_val(pj,
3739  pjf);
3740  }
3741 
3742 }
3743 
3744 /*----------------------------------------------------------------------------*/
3755 /*----------------------------------------------------------------------------*/
3756 
3757 inline static void
3759  const cs_lnum_t jj,
3760  const cs_real_t i_massflux,
3761  cs_lnum_t *ic,
3762  cs_lnum_t *id)
3763 {
3764  if (i_massflux >= 0.) {
3765  *ic = ii;
3766  *id = jj;
3767  } else {
3768  *ic = jj;
3769  *id = ii;
3770  }
3771 }
3772 
3773 /*----------------------------------------------------------------------------*/
3795 /*----------------------------------------------------------------------------*/
3796 
3797 inline static void
3799  const double beta,
3800  const cs_real_3_t cell_cen_c,
3801  const cs_real_3_t cell_cen_d,
3802  const cs_real_3_t i_face_normal,
3803  const cs_real_3_t i_face_cog,
3804  const cs_real_3_t gradv_c,
3805  const cs_real_t p_c,
3806  const cs_real_t p_d,
3807  const cs_real_t local_max_c,
3808  const cs_real_t local_min_c,
3809  const cs_real_t courant_c,
3810  cs_real_t *pif,
3811  cs_real_t *pjf)
3812 {
3813  /* distance between face center and central cell center */
3814  cs_real_t dist_fc;
3815  cs_real_3_t nfc;
3816  cs_math_3_length_unitv(cell_cen_c, i_face_cog, &dist_fc, nfc);
3817 
3818  /* unit vector and distance between central and downwind cells centers */
3819  cs_real_t dist_dc;
3820  cs_real_3_t ndc;
3821  cs_math_3_length_unitv(cell_cen_c, cell_cen_d, &dist_dc, ndc);
3822 
3823  /* Place the upwind point on the line that joins
3824  the two cells on the upwind side and the same
3825  distance as that between the two cells */
3826  const cs_real_t dist_cu = dist_dc;
3827  const cs_real_t dist_du = dist_dc + dist_cu;
3828 
3829  /* Compute the property on the upwind assuming a parabolic
3830  variation of the property between the two cells */
3831  const cs_real_t gradc = cs_math_3_dot_product(gradv_c, ndc);
3832 
3833  const cs_real_t grad2c = ((p_d - p_c)/dist_dc - gradc)/dist_dc;
3834 
3835  cs_real_t p_u = p_c + (grad2c*dist_cu - gradc)*dist_cu;
3836  p_u = CS_MAX(CS_MIN(p_u, local_max_c), local_min_c);
3837 
3838  /* Compute the normalised distances */
3839  const cs_real_t nvf_r_f = (dist_fc+dist_cu)/dist_du;
3840  const cs_real_t nvf_r_c = dist_cu/dist_du;
3841 
3842  /* Check for the bounds of the NVD diagram and compute the face
3843  property according to the selected NVD scheme */
3844  const cs_real_t _small = cs_math_epzero
3845  * (CS_ABS(p_u)+CS_ABS(p_c)+CS_ABS(p_d));
3846 
3847  if (CS_ABS(p_d-p_u) <= _small) {
3848  *pif = p_c;
3849  *pjf = p_c;
3850  } else {
3851  const cs_real_t nvf_p_c = (p_c - p_u)/(p_d - p_u);
3852 
3853  if (nvf_p_c <= 0. || nvf_p_c >= 1.) {
3854  *pif = p_c;
3855  *pjf = p_c;
3856  } else {
3857  cs_real_t nvf_p_f;
3858 
3859  /* Highly compressive NVD scheme for VOF */
3860  if (limiter >= CS_NVD_VOF_HRIC) {
3861  nvf_p_f = cs_nvd_vof_scheme_scalar(limiter,
3862  i_face_normal,
3863  nvf_p_c,
3864  nvf_r_f,
3865  nvf_r_c,
3866  gradv_c,
3867  courant_c);
3868  } else { /* Regular NVD scheme */
3869  nvf_p_f = cs_nvd_scheme_scalar(limiter,
3870  nvf_p_c,
3871  nvf_r_f,
3872  nvf_r_c);
3873  }
3874 
3875  *pif = p_u + nvf_p_f*(p_d - p_u);
3876  *pif = CS_MAX(CS_MIN(*pif, local_max_c), local_min_c);
3877 
3879  p_c,
3880  pif);
3881 
3882  *pjf = *pif;
3883  }
3884  }
3885 }
3886 
3887 /*----------------------------------------------------------------------------*/
3922 /*----------------------------------------------------------------------------*/
3923 
3924 inline static void
3926  const int iconvp,
3927  const cs_real_t bldfrp,
3928  const int ischcp,
3929  const double blencp,
3930  const double blend_st,
3931  const cs_real_t weight,
3932  const cs_real_t i_dist,
3933  const cs_real_t i_face_surf,
3934  const cs_real_3_t cell_ceni,
3935  const cs_real_3_t cell_cenj,
3936  const cs_real_3_t i_face_normal,
3937  const cs_real_3_t i_face_cog,
3938  const cs_real_3_t diipf,
3939  const cs_real_3_t djjpf,
3940  const cs_real_t i_massflux,
3941  const cs_real_33_t gradi,
3942  const cs_real_33_t gradj,
3943  const cs_real_33_t grdpai,
3944  const cs_real_33_t grdpaj,
3945  const cs_real_3_t pi,
3946  const cs_real_3_t pj,
3947  cs_real_t pif[3],
3948  cs_real_t pjf[3],
3949  cs_real_t pip[3],
3950  cs_real_t pjp[3])
3951 {
3952  cs_real_t recoi[3], recoj[3];
3953  cs_real_t testij, tesqck;
3954 
3956  diipf,
3957  djjpf,
3958  gradi,
3959  gradj,
3960  pi,
3961  pj,
3962  recoi,
3963  recoj,
3964  pip,
3965  pjp);
3966 
3967  /* Convection slope test is needed only when iconv >0 */
3968  if (iconvp > 0) {
3970  pj,
3971  i_dist,
3972  i_face_surf,
3973  i_face_normal,
3974  gradi,
3975  gradj,
3976  grdpai,
3977  grdpaj,
3978  i_massflux,
3979  &testij,
3980  &tesqck);
3981 
3982  for (int isou = 0; isou < 3; isou++) {
3983  if (ischcp == 1) {
3984 
3985  /* Centered
3986  --------*/
3987 
3988  cs_centered_f_val(weight,
3989  pip[isou],
3990  pjp[isou],
3991  &pif[isou]);
3992  cs_centered_f_val(weight,
3993  pip[isou],
3994  pjp[isou],
3995  &pjf[isou]);
3996 
3997  } else {
3998 
3999  /* Second order
4000  ------------*/
4001 
4002  cs_solu_f_val(cell_ceni,
4003  i_face_cog,
4004  gradi[isou],
4005  pi[isou],
4006  &pif[isou]);
4007  cs_solu_f_val(cell_cenj,
4008  i_face_cog,
4009  gradj[isou],
4010  pj[isou],
4011  &pjf[isou]);
4012 
4013  }
4014 
4015  }
4016 
4017  /* Slope test: Pourcentage of upwind
4018  ----------------------------------*/
4019 
4020  if (tesqck <= 0. || testij <= 0.) {
4021 
4022  cs_blend_f_val_vector(blend_st,
4023  pi,
4024  pif);
4025  cs_blend_f_val_vector(blend_st,
4026  pj,
4027  pjf);
4028 
4029  *upwind_switch = true;
4030 
4031  }
4032 
4033 
4034  /* Blending
4035  --------*/
4036  cs_blend_f_val_vector(blencp,
4037  pi,
4038  pif);
4039  cs_blend_f_val_vector(blencp,
4040  pj,
4041  pjf);
4042 
4043  /* If iconv=0 p*f are useless */
4044  } else {
4045 
4046  for (int isou = 0; isou < 3; isou++) {
4047  cs_upwind_f_val(pi[isou],
4048  &pif[isou]);
4049  cs_upwind_f_val(pj[isou],
4050  &pjf[isou]);
4051 
4052  }
4053  }
4054 
4055 }
4056 
4057 /*----------------------------------------------------------------------------*/
4092 /*----------------------------------------------------------------------------*/
4093 
4094 inline static void
4096  const int iconvp,
4097  const cs_real_t bldfrp,
4098  const int ischcp,
4099  const double blencp,
4100  const double blend_st,
4101  const cs_real_t weight,
4102  const cs_real_t i_dist,
4103  const cs_real_t i_face_surf,
4104  const cs_real_3_t cell_ceni,
4105  const cs_real_3_t cell_cenj,
4106  const cs_real_3_t i_face_normal,
4107  const cs_real_3_t i_face_cog,
4108  const cs_real_3_t diipf,
4109  const cs_real_3_t djjpf,
4110  const cs_real_t i_massflux,
4111  const cs_real_63_t gradi,
4112  const cs_real_63_t gradj,
4113  const cs_real_63_t grdpai,
4114  const cs_real_63_t grdpaj,
4115  const cs_real_6_t pi,
4116  const cs_real_6_t pj,
4117  cs_real_t pif[6],
4118  cs_real_t pjf[6],
4119  cs_real_t pip[6],
4120  cs_real_t pjp[6])
4121 {
4122  cs_real_t recoi[6], recoj[6];
4123  cs_real_t testij, tesqck;
4124  int isou;
4125 
4127  diipf,
4128  djjpf,
4129  gradi,
4130  gradj,
4131  pi,
4132  pj,
4133  recoi,
4134  recoj,
4135  pip,
4136  pjp);
4137 
4138  /* Convection slope test is needed only when iconv >0 */
4139  if (iconvp > 0) {
4141  pj,
4142  i_dist,
4143  i_face_surf,
4144  i_face_normal,
4145  gradi,
4146  gradj,
4147  grdpai,
4148  grdpaj,
4149  i_massflux,
4150  &testij,
4151  &tesqck);
4152 
4153  for (isou = 0; isou < 6; isou++) {
4154 
4155  if (ischcp==1) {
4156 
4157  /* Centered
4158  --------*/
4159 
4160  cs_centered_f_val(weight,
4161  pip[isou],
4162  pjp[isou],
4163  &pif[isou]);
4164  cs_centered_f_val(weight,
4165  pip[isou],
4166  pjp[isou],
4167  &pjf[isou]);
4168 
4169  } else {
4170 
4171  /* Second order
4172  ------------*/
4173 
4174  cs_solu_f_val(cell_ceni,
4175  i_face_cog,
4176  gradi[isou],
4177  pi[isou],
4178  &pif[isou]);
4179  cs_solu_f_val(cell_cenj,
4180  i_face_cog,
4181  gradj[isou],
4182  pj[isou],
4183  &pjf[isou]);
4184  }
4185 
4186  }
4187 
4188  /* Slope test activated: poucentage of upwind */
4189  if (tesqck <= 0. || testij <= 0.) {
4190 
4191  /* Upwind
4192  --------*/
4193 
4194  cs_blend_f_val_tensor(blend_st,
4195  pi,
4196  pif);
4197  cs_blend_f_val_tensor(blend_st,
4198  pj,
4199  pjf);
4200 
4201  *upwind_switch = true;
4202  }
4203 
4204 
4205  /* Blending
4206  --------*/
4207 
4208  cs_blend_f_val_tensor(blencp,
4209  pi,
4210  pif);
4211  cs_blend_f_val_tensor(blencp,
4212  pj,
4213  pjf);
4214 
4215  /* If iconv=0 p*fr* are useless */
4216  } else {
4217 
4218  for (isou = 0; isou < 6; isou++) {
4219  cs_upwind_f_val(pi[isou],
4220  &pif[isou]);
4221  cs_upwind_f_val(pj[isou],
4222  &pjf[isou]);
4223  }
4224  }
4225 }
4226 
4227 /*----------------------------------------------------------------------------*/
4236 /*----------------------------------------------------------------------------*/
4237 
4238 inline static void
4240  const cs_real_3_t gradi,
4241  const cs_real_t bldfrp,
4242  cs_real_t *recoi)
4243 {
4244  *recoi = bldfrp * ( gradi[0]*diipb[0]
4245  + gradi[1]*diipb[1]
4246  + gradi[2]*diipb[2]);
4247 }
4248 
4249 /*----------------------------------------------------------------------------*/
4258 /*----------------------------------------------------------------------------*/
4259 
4260 inline static void
4262  const cs_real_33_t gradi,
4263  const cs_real_t bldfrp,
4264  cs_real_t recoi[3])
4265 {
4266  for (int isou = 0; isou < 3; isou++) {
4267  recoi[isou] = bldfrp * ( gradi[isou][0]*diipb[0]
4268  + gradi[isou][1]*diipb[1]
4269  + gradi[isou][2]*diipb[2]);
4270  }
4271 }
4272 
4273 /*----------------------------------------------------------------------------*/
4282 /*----------------------------------------------------------------------------*/
4283 
4284 inline static void
4286  const cs_real_63_t gradi,
4287  const cs_real_t bldfrp,
4288  cs_real_t recoi[6])
4289 {
4290  for (int isou = 0; isou < 6; isou++) {
4291  recoi[isou] = bldfrp * ( gradi[isou][0]*diipb[0]
4292  + gradi[isou][1]*diipb[1]
4293  + gradi[isou][2]*diipb[2]);
4294  }
4295 }
4296 
4297 /*----------------------------------------------------------------------------*/
4308 /*----------------------------------------------------------------------------*/
4309 
4310 inline static void
4311 cs_b_relax_c_val(const double relaxp,
4312  const cs_real_t pi,
4313  const cs_real_t pia,
4314  const cs_real_t recoi,
4315  cs_real_t *pir,
4316  cs_real_t *pipr)
4317 {
4318  *pir = pi/relaxp - (1.-relaxp)/relaxp*pia;
4319  *pipr = *pir + recoi;
4320 }
4321 
4322 /*----------------------------------------------------------------------------*/
4333 /*----------------------------------------------------------------------------*/
4334 
4335 inline static void
4336 cs_b_relax_c_val_vector(const double relaxp,
4337  const cs_real_3_t pi,
4338  const cs_real_3_t pia,
4339  const cs_real_3_t recoi,
4340  cs_real_t pir[3],
4341  cs_real_t pipr[3])
4342 {
4343  for (int isou = 0; isou < 3; isou++) {
4344  pir[isou] = pi[isou]/relaxp - (1.-relaxp)/relaxp*pia[isou];
4345  pipr[isou] = pir[isou] + recoi[isou];
4346  }
4347 }
4348 
4349 /*----------------------------------------------------------------------------*/
4360 /*----------------------------------------------------------------------------*/
4361 
4362 inline static void
4363 cs_b_relax_c_val_tensor(const double relaxp,
4364  const cs_real_6_t pi,
4365  const cs_real_6_t pia,
4366  const cs_real_6_t recoi,
4367  cs_real_t pir[6],
4368  cs_real_t pipr[6])
4369 {
4370  for (int isou = 0; isou < 6; isou++) {
4371  pir[isou] = pi[isou]/relaxp - (1.-relaxp)/relaxp*pia[isou];
4372  pipr[isou] = pir[isou] + recoi[isou];
4373  }
4374 }
4375 
4376 /*----------------------------------------------------------------------------*/
4400 /*----------------------------------------------------------------------------*/
4401 
4402 inline static void
4404  cs_real_t thetap,
4405  int imasac,
4406  int inc,
4407  int bc_type,
4408  int icvfli,
4409  cs_real_t pi,
4410  cs_real_t pir,
4411  cs_real_t pipr,
4412  cs_real_t coefap,
4413  cs_real_t coefbp,
4414  cs_real_t coface,
4415  cs_real_t cofbce,
4416  cs_real_t b_massflux,
4417  cs_real_t xcpp,
4418  cs_real_t *flux)
4419 {
4420  cs_real_t flui, fluj, pfac;
4421 
4422  /* Computed convective flux */
4423 
4424  if (icvfli == 0) {
4425 
4426  /* Remove decentering for coupled faces */
4427  if (bc_type == CS_COUPLED_FD) {
4428  flui = 0.0;
4429  fluj = b_massflux;
4430  } else {
4431  flui = 0.5*(b_massflux +fabs(b_massflux));
4432  fluj = 0.5*(b_massflux -fabs(b_massflux));
4433  }
4434 
4435  pfac = inc*coefap + coefbp*pipr;
4436  *flux += iconvp*xcpp*(thetap*(flui*pir + fluj*pfac) -imasac*( b_massflux*pi));
4437 
4438  /* Imposed convective flux */
4439 
4440  } else {
4441 
4442  pfac = inc*coface + cofbce*pipr;
4443  *flux += iconvp*xcpp*(-imasac*(b_massflux*pi) + thetap*(pfac));
4444 
4445  }
4446 }
4447 
4448 /*----------------------------------------------------------------------------*/
4470 /*----------------------------------------------------------------------------*/
4471 
4472 inline static void
4474  cs_real_t thetap,
4475  int imasac,
4476  int inc,
4477  int bc_type,
4478  int icvfli,
4479  const cs_real_t pi[restrict 3],
4480  const cs_real_t pir[restrict 3],
4481  const cs_real_t pipr[restrict 3],
4482  const cs_real_t coefap[restrict 3],
4483  const cs_real_t coefbp[restrict 3][3],
4484  const cs_real_t coface[restrict 3],
4485  const cs_real_t cofbce[restrict 3][3],
4486  cs_real_t b_massflux,
4487  cs_real_t flux[restrict 3])
4488 {
4489  cs_real_t flui, fluj, pfac;
4490 
4491  /* Computed convective flux */
4492 
4493  if (icvfli == 0) {
4494 
4495  /* Remove decentering for coupled faces */
4496  if (bc_type == CS_COUPLED_FD) {
4497  flui = 0.0;
4498  fluj = b_massflux;
4499  } else {
4500  flui = 0.5*(b_massflux +fabs(b_massflux));
4501  fluj = 0.5*(b_massflux -fabs(b_massflux));
4502  }
4503  for (int isou = 0; isou < 3; isou++) {
4504  pfac = inc*coefap[isou];
4505  for (int jsou = 0; jsou < 3; jsou++) {
4506  pfac += coefbp[isou][jsou]*pipr[jsou];
4507  }
4508  flux[isou] += iconvp*( thetap*(flui*pir[isou] + fluj*pfac)
4509  - imasac*b_massflux*pi[isou]);
4510  }
4511 
4512  /* Imposed convective flux */
4513 
4514  } else {
4515 
4516  for (int isou = 0; isou < 3; isou++) {
4517  pfac = inc*coface[isou];
4518  for (int jsou = 0; jsou < 3; jsou++) {
4519  pfac += cofbce[isou][jsou]*pipr[jsou];
4520  }
4521  flux[isou] += iconvp*( thetap*pfac
4522  - imasac*b_massflux*pi[isou]);
4523  }
4524 
4525  }
4526 }
4527 
4528 /*----------------------------------------------------------------------------*/
4548 /*----------------------------------------------------------------------------*/
4549 
4550 inline static void
4551 cs_b_upwind_flux(const int iconvp,
4552  const cs_real_t thetap,
4553  const int imasac,
4554  const int inc,
4555  const int bc_type,
4556  const cs_real_t pi,
4557  const cs_real_t pir,
4558  const cs_real_t pipr,
4559  const cs_real_t coefap,
4560  const cs_real_t coefbp,
4561  const cs_real_t b_massflux,
4562  const cs_real_t xcpp,
4563  cs_real_t *flux)
4564 {
4565  cs_real_t flui, fluj, pfac;
4566 
4567  /* Remove decentering for coupled faces */
4568  if (bc_type == CS_COUPLED_FD) {
4569  flui = 0.0;
4570  fluj = b_massflux;
4571  } else {
4572  flui = 0.5*(b_massflux +fabs(b_massflux));
4573  fluj = 0.5*(b_massflux -fabs(b_massflux));
4574  }
4575 
4576  pfac = inc*coefap + coefbp*pipr;
4577  *flux += iconvp*xcpp*(thetap*(flui*pir + fluj*pfac) -imasac*( b_massflux*pi));
4578 }
4579 
4580 /*----------------------------------------------------------------------------*/
4600 /*----------------------------------------------------------------------------*/
4601 
4602 inline static void
4603 cs_b_upwind_flux_vector(const int iconvp,
4604  const cs_real_t thetap,
4605  const int imasac,
4606  const int inc,
4607  const int bc_type,
4608  const cs_real_3_t pi,
4609  const cs_real_3_t pir,
4610  const cs_real_3_t pipr,
4611  const cs_real_3_t coefa,
4612  const cs_real_33_t coefb,
4613  const cs_real_t b_massflux,
4614  cs_real_t flux[3])
4615 {
4616  cs_real_t flui, fluj, pfac;
4617 
4618  /* Remove decentering for coupled faces */
4619  if (bc_type == CS_COUPLED_FD) {
4620  flui = 0.0;
4621  fluj = b_massflux;
4622  } else {
4623  flui = 0.5*(b_massflux +fabs(b_massflux));
4624  fluj = 0.5*(b_massflux -fabs(b_massflux));
4625  }
4626  for (int isou = 0; isou < 3; isou++) {
4627  pfac = inc*coefa[isou];
4628  for (int jsou = 0; jsou < 3; jsou++) {
4629  pfac += coefb[isou][jsou]*pipr[jsou];
4630  }
4631  flux[isou] += iconvp*( thetap*(flui*pir[isou] + fluj*pfac)
4632  - imasac*b_massflux*pi[isou]);
4633  }
4634 }
4635 
4636 /*----------------------------------------------------------------------------*/
4656 /*----------------------------------------------------------------------------*/
4657 
4658 inline static void
4659 cs_b_upwind_flux_tensor(const int iconvp,
4660  const cs_real_t thetap,
4661  const int imasac,
4662  const int inc,
4663  const int bc_type,
4664  const cs_real_6_t pi,
4665  const cs_real_6_t pir,
4666  const cs_real_6_t pipr,
4667  const cs_real_6_t coefa,
4668  const cs_real_66_t coefb,
4669  const cs_real_t b_massflux,
4670  cs_real_t flux[6])
4671 {
4672  cs_real_t flui, fluj, pfac;
4673 
4674  /* Remove decentering for coupled faces */
4675  if (bc_type == CS_COUPLED_FD) {
4676  flui = 0.0;
4677  fluj = b_massflux;
4678  } else {
4679  flui = 0.5*(b_massflux +fabs(b_massflux));
4680  fluj = 0.5*(b_massflux -fabs(b_massflux));
4681  }
4682  for (int isou = 0; isou < 6; isou++) {
4683  pfac = inc*coefa[isou];
4684  for (int jsou = 0; jsou < 6; jsou++) {
4685  pfac += coefb[isou][jsou]*pipr[jsou];
4686  }
4687  flux[isou] += iconvp*( thetap*(flui*pir[isou] + fluj*pfac)
4688  - imasac*b_massflux*pi[isou]);
4689  }
4690 }
4691 
4692 /*----------------------------------------------------------------------------*/
4705 /*----------------------------------------------------------------------------*/
4706 
4707 inline static void
4708 cs_b_diff_flux(const int idiffp,
4709  const cs_real_t thetap,
4710  const int inc,
4711  const cs_real_t pipr,
4712  const cs_real_t cofafp,
4713  const cs_real_t cofbfp,
4714  const cs_real_t b_visc,
4715  cs_real_t *flux)
4716 {
4717  cs_real_t pfacd = inc*cofafp + cofbfp*pipr;
4718  *flux += idiffp*thetap*b_visc*pfacd;
4719 }
4720 
4721 /*----------------------------------------------------------------------------*/
4734 /*----------------------------------------------------------------------------*/
4735 
4736 inline static void
4737 cs_b_diff_flux_vector(const int idiffp,
4738  const cs_real_t thetap,
4739  const int inc,
4740  const cs_real_3_t pipr,
4741  const cs_real_3_t cofaf,
4742  const cs_real_33_t cofbf,
4743  const cs_real_t b_visc,
4744  cs_real_t flux[3])
4745 {
4746  cs_real_t pfacd ;
4747  for (int isou = 0; isou < 3; isou++) {
4748  pfacd = inc*cofaf[isou];
4749  for (int jsou = 0; jsou < 3; jsou++) {
4750  pfacd += cofbf[isou][jsou]*pipr[jsou];
4751  }
4752  flux[isou] += idiffp*thetap*b_visc*pfacd;
4753  }
4754 }
4755 
4756 /*----------------------------------------------------------------------------*/
4769 /*----------------------------------------------------------------------------*/
4770 
4771 inline static void
4772 cs_b_diff_flux_tensor(const int idiffp,
4773  const cs_real_t thetap,
4774  const int inc,
4775  const cs_real_6_t pipr,
4776  const cs_real_6_t cofaf,
4777  const cs_real_66_t cofbf,
4778  const cs_real_t b_visc,
4779  cs_real_t flux[6])
4780 {
4781  cs_real_t pfacd ;
4782  for (int isou = 0; isou < 6; isou++) {
4783  pfacd = inc*cofaf[isou];
4784  for (int jsou = 0; jsou < 6; jsou++) {
4785  pfacd += cofbf[isou][jsou]*pipr[jsou];
4786  }
4787  flux[isou] += idiffp*thetap*b_visc*pfacd;
4788  }
4789 }
4790 
4791 /*----------------------------------------------------------------------------*/
4805 /*----------------------------------------------------------------------------*/
4806 
4807 inline static void
4809  const double relaxp,
4810  const cs_real_3_t diipb,
4811  const cs_real_3_t gradi,
4812  const cs_real_t pi,
4813  const cs_real_t pia,
4814  cs_real_t *pir,
4815  cs_real_t *pipr)
4816 {
4817  cs_real_t recoi;
4818 
4820  gradi,
4821  bldfrp,
4822  &recoi);
4823 
4824  cs_b_relax_c_val(relaxp,
4825  pi,
4826  pia,
4827  recoi,
4828  pir,
4829  pipr);
4830 }
4831 
4832 /*----------------------------------------------------------------------------*/
4846 /*----------------------------------------------------------------------------*/
4847 
4848 inline static void
4850  const double relaxp,
4851  const cs_real_3_t diipb,
4852  const cs_real_33_t gradi,
4853  const cs_real_3_t pi,
4854  const cs_real_3_t pia,
4855  cs_real_t pir[3],
4856  cs_real_t pipr[3])
4857 {
4858  cs_real_3_t recoi;
4859 
4861  gradi,
4862  bldfrp,
4863  recoi);
4864 
4865  cs_b_relax_c_val_vector(relaxp,
4866  pi,
4867  pia,
4868  recoi,
4869  pir,
4870  pipr);
4871 }
4872 
4873 /*----------------------------------------------------------------------------*/
4887 /*----------------------------------------------------------------------------*/
4888 
4889 inline static void
4891  const double relaxp,
4892  const cs_real_3_t diipb,
4893  const cs_real_63_t gradi,
4894  const cs_real_6_t pi,
4895  const cs_real_6_t pia,
4896  cs_real_t pir[6],
4897  cs_real_t pipr[6])
4898 {
4899  cs_real_6_t recoi;
4900 
4902  gradi,
4903  bldfrp,
4904  recoi);
4905 
4906  cs_b_relax_c_val_tensor(relaxp,
4907  pi,
4908  pia,
4909  recoi,
4910  pir,
4911  pipr);
4912 }
4913 
4914 /*----------------------------------------------------------------------------*/
4925 /*----------------------------------------------------------------------------*/
4926 
4927 inline static void
4929  const cs_real_3_t diipb,
4930  const cs_real_3_t gradi,
4931  const cs_real_t pi,
4932  cs_real_t *pip)
4933 {
4934  cs_real_t recoi;
4935 
4937  gradi,
4938  bldfrp,
4939  &recoi);
4940 
4941  *pip = pi + recoi;
4942 }
4943 
4944 /*----------------------------------------------------------------------------*/
4955 /*----------------------------------------------------------------------------*/
4956 
4957 inline static void
4959  const cs_real_3_t diipb,
4960  const cs_real_33_t gradi,
4961  const cs_real_3_t pi,
4962  cs_real_t pip[3])
4963 {
4964  cs_real_3_t recoi;
4965 
4967  gradi,
4968  bldfrp,
4969  recoi);
4970 
4971  for (int isou = 0; isou < 3; isou++)
4972  pip[isou] = pi[isou] + recoi[isou];
4973 }
4974 
4975 /*----------------------------------------------------------------------------*/
4986 /*----------------------------------------------------------------------------*/
4987 
4988 inline static void
4990  const cs_real_3_t diipb,
4991  const cs_real_63_t gradi,
4992  const cs_real_6_t pi,
4993  cs_real_t pip[6])
4994 {
4995  cs_real_6_t recoi;
4996 
4998  gradi,
4999  bldfrp,
5000  recoi);
5001 
5002  for(int isou = 0; isou< 6; isou++)
5003  pip[isou] = pi[isou] + recoi[isou];
5004 }
5005 
5006 /*----------------------------------------------------------------------------*/
5017 /*----------------------------------------------------------------------------*/
5018 
5019 inline static void
5021  cs_real_t pi,
5022  cs_real_t pj,
5023  cs_real_t b_visc,
5024  cs_real_t *fluxi)
5025 {
5026  *fluxi += idiffp*b_visc*(pi - pj);
5027 }
5028 
5029 /*----------------------------------------------------------------------------*/
5040 /*----------------------------------------------------------------------------*/
5041 
5042 inline static void
5044  const cs_real_t pi[3],
5045  const cs_real_t pj[3],
5046  cs_real_t b_visc,
5047  cs_real_t fluxi[3])
5048 {
5049  for (int k = 0; k < 3; k++)
5050  fluxi[k] += idiffp*b_visc*(pi[k] - pj[k]);
5051 }
5052 
5053 
5054 /*============================================================================
5055  * Public function prototypes for Fortran API
5056  *============================================================================*/
5057 
5058 /*----------------------------------------------------------------------------
5059  * Wrapper to cs_face_diffusion_potential
5060  *----------------------------------------------------------------------------*/
5061 
5062 void CS_PROCF (itrmas, ITRMAS)
5063 (
5064  const int *const f_id,
5065  const int *const init,
5066  const int *const inc,
5067  const int *const imrgra,
5068  const int *const iccocg,
5069  const int *const nswrgp,
5070  const int *const imligp,
5071  const int *const iphydp,
5072  const int *const iwgrp,
5073  const int *const iwarnp,
5074  const cs_real_t *const epsrgp,
5075  const cs_real_t *const climgp,
5076  const cs_real_t *const extrap,
5077  cs_real_3_t frcxt[],
5078  cs_real_t pvar[],
5079  const cs_real_t coefap[],
5080  const cs_real_t coefbp[],
5081  const cs_real_t cofafp[],
5082  const cs_real_t cofbfp[],
5083  const cs_real_t i_visc[],
5084  const cs_real_t b_visc[],
5085  cs_real_t visel[],
5086  cs_real_t i_massflux[],
5087  cs_real_t b_massflux[]
5088 );
5089 
5090 /*----------------------------------------------------------------------------
5091  * Wrapper to cs_face_anisotropic_diffusion_potential
5092  *----------------------------------------------------------------------------*/
5093 
5094 void CS_PROCF (itrmav, ITRMAV)
5095 (
5096  const int *const f_id,
5097  const int *const init,
5098  const int *const inc,
5099  const int *const imrgra,
5100  const int *const iccocg,
5101  const int *const nswrgp,
5102  const int *const imligp,
5103  const int *const ircflp,
5104  const int *const iphydp,
5105  const int *const iwgrp,
5106  const int *const iwarnp,
5107  const cs_real_t *const epsrgp,
5108  const cs_real_t *const climgp,
5109  const cs_real_t *const extrap,
5110  cs_real_3_t frcxt[],
5111  cs_real_t pvar[],
5112  const cs_real_t coefap[],
5113  const cs_real_t coefbp[],
5114  const cs_real_t cofafp[],
5115  const cs_real_t cofbfp[],
5116  const cs_real_t i_visc[],
5117  const cs_real_t b_visc[],
5118  cs_real_6_t viscel[],
5119  const cs_real_2_t weighf[],
5120  const cs_real_t weighb[],
5121  cs_real_t i_massflux[],
5122  cs_real_t b_massflux[]
5123 );
5124 
5125 /*----------------------------------------------------------------------------
5126  * Wrapper to cs_diffusion_potential
5127  *----------------------------------------------------------------------------*/
5128 
5129 void CS_PROCF (itrgrp, ITRGRP)
5130 (
5131  const int *const f_id,
5132  const int *const init,
5133  const int *const inc,
5134  const int *const imrgra,
5135  const int *const iccocg,
5136  const int *const nswrgp,
5137  const int *const imligp,
5138  const int *const iphydp,
5139  const int *const iwgrp,
5140  const int *const iwarnp,
5141  const cs_real_t *const epsrgp,
5142  const cs_real_t *const climgp,
5143  const cs_real_t *const extrap,
5144  cs_real_3_t frcxt[],
5145  cs_real_t pvar[],
5146  const cs_real_t coefap[],
5147  const cs_real_t coefbp[],
5148  const cs_real_t cofafp[],
5149  const cs_real_t cofbfp[],
5150  const cs_real_t i_visc[],
5151  const cs_real_t b_visc[],
5152  cs_real_t visel[],
5153  cs_real_t diverg[]
5154 );
5155 
5156 /*----------------------------------------------------------------------------
5157  * Wrapper to cs_anisotropic_diffusion_potential
5158  *----------------------------------------------------------------------------*/
5159 
5160 void CS_PROCF (itrgrv, ITRGRV)
5161 (
5162  const int *const f_id,
5163  const int *const init,
5164  const int *const inc,
5165  const int *const imrgra,
5166  const int *const iccocg,
5167  const int *const nswrgp,
5168  const int *const imligp,
5169  const int *const ircflp,
5170  const int *const iphydp,
5171  const int *const iwgrp,
5172  const int *const iwarnp,
5173  const cs_real_t *const epsrgp,
5174  const cs_real_t *const climgp,
5175  const cs_real_t *const extrap,
5176  cs_real_3_t frcxt[],
5177  cs_real_t pvar[],
5178  const cs_real_t coefap[],
5179  const cs_real_t coefbp[],
5180  const cs_real_t cofafp[],
5181  const cs_real_t cofbfp[],
5182  const cs_real_t i_visc[],
5183  const cs_real_t b_visc[],
5184  cs_real_6_t viscel[],
5185  const cs_real_2_t weighf[],
5186  const cs_real_t weighb[],
5187  cs_real_t diverg[]
5188 );
5189 
5190 /*=============================================================================
5191  * Public function prototypes
5192  *============================================================================*/
5193 
5194 /*----------------------------------------------------------------------------*/
5213 /*----------------------------------------------------------------------------*/
5214 
5215 void
5216 cs_slope_test_gradient(int f_id,
5217  int inc,
5218  cs_halo_type_t halo_type,
5219  const cs_real_3_t *grad,
5220  cs_real_3_t *grdpa,
5221  const cs_real_t *pvar,
5222  const cs_real_t *coefap,
5223  const cs_real_t *coefbp,
5224  const cs_real_t *i_massflux);
5225 
5226 /*----------------------------------------------------------------------------*/
5242 /*----------------------------------------------------------------------------*/
5243 
5244 void
5245 cs_upwind_gradient(const int f_id,
5246  const int inc,
5247  const cs_halo_type_t halo_type,
5248  const cs_real_t coefap[],
5249  const cs_real_t coefbp[],
5250  const cs_real_t i_massflux[],
5251  const cs_real_t b_massflux[],
5252  const cs_real_t *restrict pvar,
5253  cs_real_3_t *restrict grdpa);
5254 
5255 /*----------------------------------------------------------------------------*/
5273 /*----------------------------------------------------------------------------*/
5274 
5275 void
5276 cs_slope_test_gradient_vector(const int inc,
5277  const cs_halo_type_t halo_type,
5278  const cs_real_33_t *grad,
5279  cs_real_33_t *grdpa,
5280  const cs_real_3_t *pvar,
5281  const cs_real_3_t *coefa,
5282  const cs_real_33_t *coefb,
5283  const cs_real_t *i_massflux);
5284 
5285 /*----------------------------------------------------------------------------*/
5303 /*----------------------------------------------------------------------------*/
5304 
5305 void
5306 cs_slope_test_gradient_tensor(const int inc,
5307  const cs_halo_type_t halo_type,
5308  const cs_real_63_t *grad,
5309  cs_real_63_t *grdpa,
5310  const cs_real_6_t *pvar,
5311  const cs_real_6_t *coefa,
5312  const cs_real_66_t *coefb,
5313  const cs_real_t *i_massflux);
5314 
5315 /*----------------------------------------------------------------------------*/
5324 /*----------------------------------------------------------------------------*/
5325 
5326 void
5327 cs_beta_limiter_building(int f_id,
5328  int inc,
5329  const cs_real_t rovsdt[]);
5330 
5331 /*----------------------------------------------------------------------------*/
5383 /*----------------------------------------------------------------------------*/
5384 
5385 void
5387  int f_id,
5389  int icvflb,
5390  int inc,
5391  int iccocg,
5392  int imasac,
5393  cs_real_t *restrict pvar,
5394  const cs_real_t *restrict pvara,
5395  const int icvfli[],
5396  const cs_real_t coefap[],
5397  const cs_real_t coefbp[],
5398  const cs_real_t cofafp[],
5399  const cs_real_t cofbfp[],
5400  const cs_real_t i_massflux[],
5401  const cs_real_t b_massflux[],
5402  const cs_real_t i_visc[],
5403  const cs_real_t b_visc[],
5404  cs_real_t *restrict rhs);
5405 
5406 /*----------------------------------------------------------------------------*/
5445 /*----------------------------------------------------------------------------*/
5446 
5447 void
5449  int f_id,
5451  int icvflb,
5452  int inc,
5453  int iccocg,
5454  int imasac,
5455  cs_real_t *restrict pvar,
5456  const cs_real_t *restrict pvara,
5457  const int icvfli[],
5458  const cs_real_t coefap[],
5459  const cs_real_t coefbp[],
5460  const cs_real_t i_massflux[],
5461  const cs_real_t b_massflux[],
5462  cs_real_2_t i_conv_flux[],
5463  cs_real_t b_conv_flux[]);
5464 
5465 /*----------------------------------------------------------------------------*/
5525 /*----------------------------------------------------------------------------*/
5526 
5527 void
5529  int f_id,
5531  int icvflb,
5532  int inc,
5533  int ivisep,
5534  int imasac,
5535  cs_real_3_t *restrict pvar,
5536  const cs_real_3_t *restrict pvara,
5537  const int icvfli[],
5538  const cs_real_3_t coefav[],
5539  const cs_real_33_t coefbv[],
5540  const cs_real_3_t cofafv[],
5541  const cs_real_33_t cofbfv[],
5542  const cs_real_t i_massflux[],
5543  const cs_real_t b_massflux[],
5544  const cs_real_t i_visc[],
5545  const cs_real_t b_visc[],
5546  const cs_real_t i_secvis[],
5547  const cs_real_t b_secvis[],
5548  cs_real_3_t *restrict rhs);
5549 
5550 /*----------------------------------------------------------------------------*/
5595 /*----------------------------------------------------------------------------*/
5596 
5597 void
5599  int f_id,
5601  int icvflb,
5602  int inc,
5603  int imasac,
5604  cs_real_6_t *restrict pvar,
5605  const cs_real_6_t *restrict pvara,
5606  const cs_real_6_t coefa[],
5607  const cs_real_66_t coefb[],
5608  const cs_real_6_t cofaf[],
5609  const cs_real_66_t cofbf[],
5610  const cs_real_t i_massflux[],
5611  const cs_real_t b_massflux[],
5612  const cs_real_t i_visc[],
5613  const cs_real_t b_visc[],
5614  cs_real_6_t *restrict rhs);
5615 
5616 /*----------------------------------------------------------------------------*/
5662 /*----------------------------------------------------------------------------*/
5663 
5664 void
5666  int f_id,
5668  int inc,
5669  int iccocg,
5670  int imasac,
5671  cs_real_t *restrict pvar,
5672  const cs_real_t *restrict pvara,
5673  const cs_real_t coefap[],
5674  const cs_real_t coefbp[],
5675  const cs_real_t cofafp[],
5676  const cs_real_t cofbfp[],
5677  const cs_real_t i_massflux[],
5678  const cs_real_t b_massflux[],
5679  const cs_real_t i_visc[],
5680  const cs_real_t b_visc[],
5681  const cs_real_t xcpp[],
5682  cs_real_t *restrict rhs);
5683 
5684 /*----------------------------------------------------------------------------*/
5732 /*----------------------------------------------------------------------------*/
5733 
5734 void
5736  int f_id,
5738  int inc,
5739  int iccocg,
5740  cs_real_t *restrict pvar,
5741  const cs_real_t *restrict pvara,
5742  const cs_real_t coefap[],
5743  const cs_real_t coefbp[],
5744  const cs_real_t cofafp[],
5745  const cs_real_t cofbfp[],
5746  const cs_real_t i_visc[],
5747  const cs_real_t b_visc[],
5748  cs_real_6_t *restrict viscel,
5749  const cs_real_2_t weighf[],
5750  const cs_real_t weighb[],
5751  cs_real_t *restrict rhs);
5752 
5753 /*-----------------------------------------------------------------------------*/
5803 /*----------------------------------------------------------------------------*/
5804 
5805 void
5807  int f_id,
5809  int inc,
5810  int ivisep,
5811  cs_real_3_t *restrict pvar,
5812  const cs_real_3_t *restrict pvara,
5813  const cs_real_3_t coefav[],
5814  const cs_real_33_t coefbv[],
5815  const cs_real_3_t cofafv[],
5816  const cs_real_33_t cofbfv[],
5817  const cs_real_33_t i_visc[],
5818  const cs_real_t b_visc[],
5819  const cs_real_t i_secvis[],
5820  cs_real_3_t *restrict rhs);
5821 
5822 /*-----------------------------------------------------------------------------*/
5867 /*----------------------------------------------------------------------------*/
5868 
5869 void
5871  int f_id,
5873  int inc,
5874  cs_real_3_t *restrict pvar,
5875  const cs_real_3_t *restrict pvara,
5876  const cs_real_3_t coefav[],
5877  const cs_real_33_t coefbv[],
5878  const cs_real_3_t cofafv[],
5879  const cs_real_33_t cofbfv[],
5880  const cs_real_t i_visc[],
5881  const cs_real_t b_visc[],
5882  cs_real_6_t *restrict viscel,
5883  const cs_real_2_t weighf[],
5884  const cs_real_t weighb[],
5885  cs_real_3_t *restrict rhs);
5886 
5887 /*----------------------------------------------------------------------------*/
5931 /*----------------------------------------------------------------------------*/
5932 
5933 void
5935  int f_id,
5937  int inc,
5938  cs_real_6_t *restrict pvar,
5939  const cs_real_6_t *restrict pvara,
5940  const cs_real_6_t coefa[],
5941  const cs_real_66_t coefb[],
5942  const cs_real_6_t cofaf[],
5943  const cs_real_66_t cofbf[],
5944  const cs_real_t i_visc[],
5945  const cs_real_t b_visc[],
5946  cs_real_6_t *restrict viscel,
5947  const cs_real_2_t weighf[],
5948  const cs_real_t weighb[],
5949  cs_real_6_t *restrict rhs);
5950 
5951 /*----------------------------------------------------------------------------*/
6010 /*----------------------------------------------------------------------------*/
6011 
6012 void
6013 cs_face_diffusion_potential(const int f_id,
6014  const cs_mesh_t *m,
6015  cs_mesh_quantities_t *fvq,
6016  int init,
6017  int inc,
6018  int imrgra,
6019  int iccocg,
6020  int nswrgp,
6021  int imligp,
6022  int iphydp,
6023  int iwgrp,
6024  int iwarnp,
6025  double epsrgp,
6026  double climgp,
6027  cs_real_3_t *restrict frcxt,
6028  cs_real_t *restrict pvar,
6029  const cs_real_t coefap[],
6030  const cs_real_t coefbp[],
6031  const cs_real_t cofafp[],
6032  const cs_real_t cofbfp[],
6033  const cs_real_t i_visc[],
6034  const cs_real_t b_visc[],
6035  cs_real_t *restrict visel,
6036  cs_real_t *restrict i_massflux,
6037  cs_real_t *restrict b_massflux);
6038 
6039 /*----------------------------------------------------------------------------*/
6109 /*----------------------------------------------------------------------------*/
6110 
6111 void
6113  const cs_mesh_t *m,
6114  cs_mesh_quantities_t *fvq,
6115  int init,
6116  int inc,
6117  int imrgra,
6118  int iccocg,
6119  int nswrgp,
6120  int imligp,
6121  int ircflp,
6122  int iphydp,
6123  int iwgrp,
6124  int iwarnp,
6125  double epsrgp,
6126  double climgp,
6127  cs_real_3_t *restrict frcxt,
6128  cs_real_t *restrict pvar,
6129  const cs_real_t coefap[],
6130  const cs_real_t coefbp[],
6131  const cs_real_t cofafp[],
6132  const cs_real_t cofbfp[],
6133  const cs_real_t i_visc[],
6134  const cs_real_t b_visc[],
6135  cs_real_6_t *restrict viscel,
6136  const cs_real_2_t weighf[],
6137  const cs_real_t weighb[],
6138  cs_real_t *restrict i_massflux,
6139  cs_real_t *restrict b_massflux);
6140 
6141 /*----------------------------------------------------------------------------*/
6199 /*----------------------------------------------------------------------------*/
6200 
6201 void
6202 cs_diffusion_potential(const int f_id,
6203  const cs_mesh_t *m,
6204  cs_mesh_quantities_t *fvq,
6205  int init,
6206  int inc,
6207  int imrgra,
6208  int iccocg,
6209  int nswrgp,
6210  int imligp,
6211  int iphydp,
6212  int iwgrp,
6213  int iwarnp,
6214  double epsrgp,
6215  double climgp,
6216  cs_real_3_t *restrict frcxt,
6217  cs_real_t *restrict pvar,
6218  const cs_real_t coefap[],
6219  const cs_real_t coefbp[],
6220  const cs_real_t cofafp[],
6221  const cs_real_t cofbfp[],
6222  const cs_real_t i_visc[],
6223  const cs_real_t b_visc[],
6224  cs_real_t visel[],
6225  cs_real_t *restrict diverg);
6226 
6227 /*----------------------------------------------------------------------------*/
6298 /*----------------------------------------------------------------------------*/
6299 
6300 void
6301 cs_anisotropic_diffusion_potential(const int f_id,
6302  const cs_mesh_t *m,
6303  cs_mesh_quantities_t *fvq,
6304  int init,
6305  int inc,
6306  int imrgra,
6307  int iccocg,
6308  int nswrgp,
6309  int imligp,
6310  int ircflp,
6311  int iphydp,
6312  int iwgrp,
6313  int iwarnp,
6314  double epsrgp,
6315  double climgp,
6316  cs_real_3_t *restrict frcxt,
6317  cs_real_t *restrict pvar,
6318  const cs_real_t coefap[],
6319  const cs_real_t coefbp[],
6320  const cs_real_t cofafp[],
6321  const cs_real_t cofbfp[],
6322  const cs_real_t i_visc[],
6323  const cs_real_t b_visc[],
6324  cs_real_6_t *restrict viscel,
6325  const cs_real_2_t weighf[],
6326  const cs_real_t weighb[],
6327  cs_real_t *restrict diverg);
6328 
6329 /*----------------------------------------------------------------------------*/
6330 
6332 
6333 #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:4403
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:1119
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:8923
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:792
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:3798
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:8168
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:1566
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:10801
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:4473
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:11639
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:1858
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:1294
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:266
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:4363
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:3758
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:938
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:1325
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:4772
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:652
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:2309
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:4928
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:4708
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:1418
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:4551
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:747
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:4808
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:2888
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:4849
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:1162
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:1063
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:12022
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:2622
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:1975
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:1622
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:4336
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:1253
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:1326
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:4989
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:1490
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:807
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:1099
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:6830
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:4311
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:4890
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:2156
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:1908
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:5020
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:4285
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:4603
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:1808
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:4261
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:4174
static void cs_sync_scalar_halo(const cs_mesh_t *m, cs_halo_type_t halo_type, int tr_dim, cs_real_t pvar[])
Definition: cs_convection_diffusion.h:99
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:1649
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:586
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:9471
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:1222
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:4659
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:4239
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:679
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:1080
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:1190
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:1732
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:1016
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:4958
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:722
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:5864
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:3371
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:886
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:1523
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:1140
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:1170
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:2462
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:3060
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:3925
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:5043
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:1273
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:834
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:11152
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:3597
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:3143
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:617
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:1047
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:125
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:4095
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:1460
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:1370
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:894
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:451
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:1471
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:4737
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:10184
static void cs_cell_courant_number(const int f_id, cs_real_t *courant)
Definition: cs_convection_diffusion.h:173
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:976
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:2764
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:1038
#define restrict
Definition: cs_defs.h:124
#define BEGIN_C_DECLS
Definition: cs_defs.h:492
double cs_real_t
Floating-point value.
Definition: cs_defs.h:304
#define CS_MIN(a, b)
Definition: cs_defs.h:455
cs_lnum_t cs_lnum_2_t[2]
vector of 2 local mesh-entity ids
Definition: cs_defs.h:310
#define CS_ABS(a)
Definition: cs_defs.h:454
#define CS_MAX(a, b)
Definition: cs_defs.h:456
#define CS_PROCF(x, y)
Definition: cs_defs.h:506
cs_real_t cs_real_66_t[6][6]
6x6 matrix of floating-point values
Definition: cs_defs.h:325
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:317
cs_real_t cs_real_2_t[2]
vector of 2 floating-point values
Definition: cs_defs.h:316
cs_real_t cs_real_6_t[6]
vector of 6 floating-point values
Definition: cs_defs.h:319
#define CS_UNUSED(x)
Definition: cs_defs.h:478
#define END_C_DECLS
Definition: cs_defs.h:493
cs_real_t cs_real_33_t[3][3]
3x3 matrix of floating-point values
Definition: cs_defs.h:324
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:298
cs_real_t cs_real_63_t[6][3]
Definition: cs_defs.h:332
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_component(const cs_halo_t *halo, cs_halo_type_t sync_mode, cs_halo_rotation_t rotation_op, cs_real_t var[])
Definition: cs_halo.c:1754
void cs_halo_sync_var(const cs_halo_t *halo, cs_halo_type_t sync_mode, cs_real_t var[])
Definition: cs_halo.c:1434
@ CS_HALO_ROTATION_IGNORE
Definition: cs_halo.h:64
cs_halo_type_t
Definition: cs_halo.h:50
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 (euclidien 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:304
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:397
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:413
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:326
static cs_real_t cs_math_sq(cs_real_t x)
Compute the square of a real value.
Definition: cs_math.h:193
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:113
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:251
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:374
double precision, save fmin
Definition: coincl.f90:133
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:202
double blencv
Definition: cs_equation_param.h:472
int isstpc
Definition: cs_equation_param.h:463
int iconv
Definition: cs_equation_param.h:453
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:98
int n_threads
Definition: cs_numbering.h:89
int n_groups
Definition: cs_numbering.h:90