1#ifndef CS_BOUNDARY_CONDITIONS_SET_COEFFS_H
2#define CS_BOUNDARY_CONDITIONS_SET_COEFFS_H
180 for (
size_t i = 0; i < 3; i++) {
181 a[i] = -qimpv[i] / fmax(hint, 1.e-300);
184 b[0][0] = 1., b[0][1] = 0., b[0][2] = 0.;
185 b[1][0] = 0., b[1][1] = 1., b[1][2] = 0.;
186 b[2][0] = 0., b[2][1] = 0., b[2][2] = 1.;
190 for (
size_t i = 0; i < 3; i++) {
193 for (
size_t j = 0; j < 3; j++)
219 cs_real_t m[6] = {0., 0., 0., 0., 0., 0.};
220 m[0] = hint[1]*hint[2] - hint[4]*hint[4];
221 m[1] = hint[0]*hint[2] - hint[5]*hint[5];
222 m[2] = hint[0]*hint[1] - hint[3]*hint[3];
223 m[3] = hint[4]*hint[5] - hint[3]*hint[2];
224 m[4] = hint[3]*hint[5] - hint[0]*hint[4];
225 m[5] = hint[3]*hint[4] - hint[1]*hint[5];
227 cs_real_t invdet = 1./(hint[0]*m[0] + hint[3]*m[3] + hint[5]*m[5]);
229 cs_real_t invh[6] = {0., 0., 0., 0., 0., 0.};
230 invh[0] = m[0] * invdet;
231 invh[1] = m[1] * invdet;
232 invh[2] = m[2] * invdet;
233 invh[3] = m[3] * invdet;
234 invh[4] = m[4] * invdet;
235 invh[5] = m[5] * invdet;
242 b[0][0] = 1.0, b[0][1] = 0.0, b[0][2] = 0.0;
243 b[1][0] = 0.0, b[1][1] = 1.0, b[1][2] = 0.0;
244 b[2][0] = 0.0, b[2][1] = 0.0, b[2][2] = 1.0;
249 for (
cs_lnum_t jsou = 0; jsou < 3; jsou++)
274 for (
int i = 0; i < 6; i++) {
277 a[i] = -qimpts[i]/
cs::max(hint, 1.e-300);
278 for (
int jsou = 0; jsou < 6; jsou++) {
287 for (
int jsou = 0; jsou < 6; jsou++)
316 for (
int i = 0; i < 3; i++) {
321 for (
int jsou = 0; jsou < 3; jsou++)
325 af[i] = -hint*pimpv[i];
327 bf[0][0] = hint, bf[0][1] = 0., bf[0][2] = 0.;
328 bf[1][0] = 0., bf[1][1] = hint, bf[1][2] = 0.;
329 bf[2][0] = 0., bf[2][1] = 0., bf[2][2] = hint;
334 const cs_real_t val = hint/(hint + hextv[i]);
338 a[i] = hextv[i]*pimpv[i]/(hint + hextv[i]);
340 b[0][0] = val, b[0][1] = 0., b[0][2] = 0.;
341 b[1][0] = 0., b[1][1] = val, b[1][2] = 0.;
342 b[2][0] = 0., b[2][1] = 0., b[2][2] = val;
345 af[i] = -heq*pimpv[i];
347 bf[0][0] = heq, bf[0][1] = 0., bf[0][2] = 0.;
348 bf[1][0] = 0., bf[1][1] = heq, bf[1][2] = 0.;
349 bf[2][0] = 0., bf[2][1] = 0., bf[2][2] = heq;
406 for (
int i = 0; i < 3; i++) {
409 for (
int jsou = 0; jsou < 3; jsou++)
414#if defined(CS_DEVICE_COMPILE)
418 _(
" %s: hextv not set for component %d."),
426 for (
int i = 0; i < 3; i++)
463 for (
int i = 0; i < 6; i++) {
468 for (
int jsou = 0; jsou < 6; jsou++)
472 af[i] = -hint * pimpts[i];
473 for (
int jsou = 0; jsou < 6; jsou++) {
483 const cs_real_t heq = hint * hextts[i] / (hint + hextts[i]);
486 a[i] = hextts[i] * pimpts[i] / (hint + hextts[i]);
487 for (
int jsou = 0; jsou < 6; jsou++) {
489 b[i][jsou] = hint / (hint + hextts[i]);
495 af[i] = -heq * pimpts[i];
496 for (
int jsou = 0; jsou < 6; jsou++) {
532 for (
int i = 0; i < 3; i++) {
535 a[i] = - qimpv[i]/
cs::max(hint, 1.e-300);
537 for (
int j = 0; j < 3; j++) {
539 a[i] = a[i] + normal[i]*normal[j]
540 * (pimpv[j] + qimpv[j] /
cs::max(hint, 1.e-300));
543 b[i][j] = 1.0 - normal[i] * normal[j];
545 b[i][j] = - normal[i] * normal[j];
551 for (
int j = 0; j < 3; j++){
553 af[i] = af[i] - normal[i]*normal[j]
554 * (hint * pimpv[j] + qimpv[j]);
556 bf[i][j] = hint * normal[i] * normal[j];
615 for (
int i = 0; i < 3; i++) {
620 for (
int j = 0; j < 3; j++) {
622 a[i] = a[i] - normal[i]*normal[j]
623 * (pimpv[j] + qimpv[j] /
cs::max(hint, 1.e-300));
625 b[i][j] = normal[i] * normal[j];
630 af[i] = -hint*pimpv[i];
631 for (
int j = 0; j < 3; j++) {
633 af[i] = af[i] + normal[i]*normal[j]
634 * (qimpv[j] + pimpv[j] * hint);
637 bf[i][j] = hint * (1.0 - normal[i] * normal[j]);
639 bf[i][j] = - hint * normal[i] * normal[j];
673 const int iv2t[6] = {0, 1, 2, 0, 1, 0};
674 const int jv2t[6] = {0, 1, 2, 1, 2, 2};
675 const cs_real_t delta[3][3] = {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}};
680 for (
int ij = 0; ij < 6; ij++) {
688 for (
int kl = 0; kl < 6; kl++) {
693 d[ij][kl] = (delta[i][
k] - normal[i]*normal[
k]) * normal[l]*normal[j]
694 + normal[i]*normal[
k] * (delta[j][l] - normal[l]*normal[j]);
696 n[ij][kl] = normal[i]*normal[
k]*normal[l]*normal[j]
697 + (delta[i][
k] - normal[i]*normal[
k])
698 * (delta[j][l] - normal[j]*normal[l]);
700 a[ij] += d[ij][kl]*pimpv[kl]
701 - n[ij][kl]*qimpv[kl]/(
cs::max(hint, 1.e-300));
703 b[ij][kl] = n[ij][kl];
710 for (
int kl = 0; kl < 6; kl++) {
715 d[ij][kl] = (delta[i][
k] - normal[i]*normal[
k]) * normal[l]*normal[j]
716 + normal[i]*normal[
k] * (delta[j][l] - normal[l]*normal[j]);
718 n[ij][kl] = normal[i]*normal[
k]*normal[l]*normal[j]
719 + (delta[i][
k] - normal[i]*normal[
k])
720 * (delta[j][l] - normal[l]*normal[j]);
722 af[ij] += n[ij][kl]*qimpv[kl]
723 - hint*d[ij][kl]*pimpv[kl];
725 bf[ij][kl] = hint*d[ij][kl];
782 for (
int i = 0; i < 3; i++) {
785 for (
int j = 0; j < 3; j ++) {
787 b[i][j] = cflv[i] / (1.0 + cflv[i]);
791 a[i] = pimpv[i] * (1.0 - b[i][i]);
794 af[i] = -hint * a[i];
795 for (
int j = 0; j < 3; j++) {
797 bf[i][j] = hint * (1.0 - b[i][j]);
827 for (
int ij = 0; ij < 6; ij++) {
830 for (
int kl = 0; kl < 6; kl++) {
832 b[ij][kl] = cflts[ij] / (1.0 + cflts[ij]);
836 a[ij] = (1.0 - b[ij][ij]) * pimpts[ij];
839 af[ij] = -hint*a[ij];
840 for (
int kl = 0; kl < 6; kl++) {
842 bf[ij][kl] = hint * (1.0 - b[ij][kl]);
873 for(
int i = 0; i < 3; i++) {
876 for (
int j = 0; j < 3; j++) {
878 b[i][j] = cflv[i]/(1.0+cflv[i]);
882 a[i] = (1.0-b[i][i])*pimpv[i];
888 for (
int i = 0; i < 3; i++)
891 bf[0][0] = hintt[0]*(1.0 - b[0][0]);
892 bf[1][1] = hintt[1]*(1.0 - b[1][1]);
893 bf[2][2] = hintt[2]*(1.0 - b[2][2]);
894 bf[0][1] = hintt[3]*(1.0 - b[0][0]);
895 bf[1][0] = hintt[3]*(1.0 - b[0][0]);
896 bf[1][2] = hintt[4]*(1.0 - b[1][1]);
897 bf[2][1] = hintt[4]*(1.0 - b[1][1]);
898 bf[0][2] = hintt[5]*(1.0 - b[2][2]);
899 bf[2][0] = hintt[5]*(1.0 - b[2][2]);
925 for (
int i = 0; i < 3; i++) {
929 for (
int j = 0; j < 3; j++)
934 for (
int j = 0; j < 3; j++)
962 for (
int ij = 0; ij < 6; ij++) {
968 for (
int kl = 0; kl < 6; kl++)
973 for (
int kl = 0; kl < 6; kl++)
1000 a = -qimp/
cs::max(hint, 1.e-300);
1072 a = hext*pimp/(hint + hext);
1073 b = hint /(hint + hext);
1076 cs_real_t heq = hint*hext/(hint + hext);
1149 bf = hint * (1. - b);
1277 const bool need_compute_bc_grad,
1278 const bool need_compute_bc_flux,
1309 const bool need_compute_bc_grad,
1310 const bool need_compute_bc_flux,
1336template <cs_lnum_t str
ide>
1357template <cs_lnum_t str
ide>
void bft_error(const char *const file_name, const int line_num, const int sys_error_code, const char *const format,...)
Calls the error handler (set by bft_error_handler_set() or default).
Definition: bft_error.cpp:187
Definition: cs_dispatch.h:2288
Field boundary condition descriptor (for variables)
Definition: cs_field.h:107
Field descriptor.
Definition: cs_field.h:275
CS_F_HOST_DEVICE void cs_boundary_conditions_set_neumann_vector_aniso(cs_real_t a[3], cs_real_t af[3], cs_real_t b[3][3], cs_real_t bf[3][3], const cs_real_t qimpv[3], const cs_real_t hint[6])
Set neumann BC for an anisotropic vector for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:212
CS_F_HOST_DEVICE void cs_boundary_conditions_set_neumann_scalar_hmg(cs_real_t &a, cs_real_t &af, cs_real_t &b, cs_real_t &bf)
Set homogeneous Neumann BC for a scalar for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:1020
CS_F_HOST_DEVICE void cs_boundary_conditions_set_dirichlet_conv_neumann_diff_vector(cs_real_t a[3], cs_real_t af[3], cs_real_t b[3][3], cs_real_t bf[3][3], const cs_real_t pimpv[3], const cs_real_t qimpv[3])
Imposed value for the convection operator, imposed flux for diffusion, for a vector.
Definition: cs_boundary_conditions_set_coeffs.h:918
CS_F_HOST_DEVICE void cs_boundary_conditions_set_dirichlet_tensor(cs_real_t a[6], cs_real_t af[6], cs_real_t b[6][6], cs_real_t bf[6][6], const cs_real_t pimpts[6], cs_real_t hint, const cs_real_t hextts[6])
Set Dirichlet BC for a tensor for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:455
void cs_boundary_conditions_ensure_bc_coeff_face_values_allocated(cs_field_bc_coeffs_t *bc_coeffs, cs_lnum_t n_b_faces, cs_lnum_t dim, cs_alloc_mode_t amode)
Allocate BC coefficients face values if needed.
Definition: cs_boundary_conditions_set_coeffs.cpp:4935
void cs_boundary_conditions_set_coeffs(int nvar, int iterns, int isvhb, int italim, int itrfin, int ineefl, int itrfup, int isostd[], cs_real_t *visvdr, cs_real_t hbord[], cs_real_t theipb[], int nftcdt)
Translation of the boundary conditions given by the user in a form that fits to the solver.
Definition: cs_boundary_conditions_set_coeffs.cpp:751
CS_F_HOST_DEVICE void cs_boundary_conditions_set_convective_outlet_tensor(cs_real_t a[6], cs_real_t af[6], cs_real_t b[6][6], cs_real_t bf[6][6], const cs_real_t pimpts[6], const cs_real_t cflts[6], cs_real_t hint)
Set convective outlet BC for a tensor for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:819
CS_F_HOST_DEVICE void cs_boundary_conditions_set_generalized_sym_vector(cs_real_t a[3], cs_real_t af[3], cs_real_t b[3][3], cs_real_t bf[3][3], const cs_real_t pimpv[3], const cs_real_t qimpv[3], cs_real_t hint, const cs_nreal_t normal[3])
Set generalized BC for a symmetric vector for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:523
CS_F_HOST_DEVICE void cs_boundary_conditions_set_total_flux(cs_real_t &a, cs_real_t &af, cs_real_t &b, cs_real_t &bf, cs_real_t hext, cs_real_t dimp)
Set total flux as a Robin condition.
Definition: cs_boundary_conditions_set_coeffs.h:1200
void cs_boundary_conditions_update_bc_coeff_face_values(cs_dispatch_context &ctx, const cs_field_t *f, cs_field_bc_coeffs_t *bc_coeffs, const int inc, const cs_equation_param_t *eqp, const bool need_compute_bc_grad, const bool need_compute_bc_flux, int hyd_p_flag, cs_real_t f_ext[][3], cs_real_t *c_weight, const cs_real_t weighb[], const cs_real_t pvar[])
Update face value for gradient and diffusion when solving in increment.
Definition: cs_boundary_conditions_set_coeffs.cpp:4359
CS_F_HOST_DEVICE void cs_boundary_conditions_set_dirichlet_conv_neumann_diff_tensor(cs_real_t a[6], cs_real_t af[6], cs_real_t b[6][6], cs_real_t bf[6][6], const cs_real_t pimpts[6], const cs_real_t qimpts[6])
Imposed value for the convection operator, imposed flux for diffusion, for a tensor.
Definition: cs_boundary_conditions_set_coeffs.h:955
CS_F_HOST_DEVICE void cs_boundary_conditions_set_dirichlet_vector_aniso(cs_real_t a[3], cs_real_t af[3], cs_real_t b[3][3], cs_real_t bf[3][3], const cs_real_t pimpv[3], const cs_real_t hintt[6], const cs_real_t hextv[3])
Set Dirichlet BC for a vector for a given face with left anisotropic diffusion.
Definition: cs_boundary_conditions_set_coeffs.h:397
CS_F_HOST_DEVICE void cs_boundary_conditions_set_generalized_dirichlet_vector(cs_real_t a[3], cs_real_t af[3], cs_real_t b[3][3], cs_real_t bf[3][3], const cs_real_t pimpv[3], const cs_real_t qimpv[3], cs_real_t hint, const cs_nreal_t normal[3])
Set generalized Dirichlet BC for a vector for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:606
CS_F_HOST_DEVICE void cs_boundary_conditions_set_neumann_conv_h_neumann_diff_scalar(cs_real_t &a, cs_real_t &af, cs_real_t &b, cs_real_t &bf, cs_real_t dimp, cs_real_t hint)
Set Neumann BC for the convection operator, zero flux for diffusion.
Definition: cs_boundary_conditions_set_coeffs.h:1098
CS_F_HOST_DEVICE void cs_boundary_conditions_set_generalized_dirichlet_vector_aniso(cs_real_t a[3], cs_real_t af[3], cs_real_t b[3][3], cs_real_t bf[3][3], const cs_real_t pimpv[3], const cs_real_t qimpv[3], const cs_real_t hint[6], const cs_nreal_t normal[3])
Set generalized Dirichlet BC for an anisotropic vector for a given face.
Definition: cs_boundary_conditions_set_coeffs.cpp:4265
void cs_boundary_conditions_set_coeffs_pressure(cs_dispatch_context &ctx, cs_field_t *f_p)
Update pressure boundary condition coefficients.
Definition: cs_boundary_conditions_set_coeffs.cpp:3882
void cs_boundary_conditions_set_coeffs_init(void)
Initialization of boundary condition arrays.
Definition: cs_boundary_conditions_set_coeffs.cpp:3738
CS_F_HOST_DEVICE void cs_boundary_conditions_set_affine_function_scalar(cs_real_t &a, cs_real_t &af, cs_real_t &b, cs_real_t &bf, cs_real_t pinf, cs_real_t ratio, cs_real_t hint)
Set BC for an affine scalar function for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:1135
CS_F_HOST_DEVICE void cs_boundary_conditions_set_convective_outlet_vector_aniso(cs_real_t a[3], cs_real_t af[3], cs_real_t b[3][3], cs_real_t bf[3][3], const cs_real_t pimpv[3], const cs_real_t cflv[3], const cs_real_t hintt[6])
Set convective outlet BC for an anisotropic vector for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:865
CS_F_HOST_DEVICE void cs_boundary_conditions_set_dirichlet_scalar(cs_real_t &a, cs_real_t &af, cs_real_t &b, cs_real_t &bf, cs_real_t pimp, cs_real_t hint, cs_real_t hext)
Set Dirichlet BC for a scalar for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:1050
CS_F_HOST_DEVICE void cs_boundary_conditions_set_neumann_scalar(cs_real_t &a, cs_real_t &af, cs_real_t &b, cs_real_t &bf, cs_real_t qimp, cs_real_t hint)
Set Neumann BC for a scalar for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:992
void cs_boundary_conditions_update_bc_coeff_face_values_strided(cs_dispatch_context &ctx, cs_field_t *f, cs_field_bc_coeffs_t *bc_coeffs, const int inc, const cs_equation_param_t *eqp, const cs_real_t pvar[][stride])
Update face value for gradient and diffusion when solving in increments.
Definition: cs_boundary_conditions_set_coeffs.cpp:4662
CS_F_HOST_DEVICE void cs_boundary_conditions_set_neumann_vector(cs_real_t a[3], cs_real_t af[3], cs_real_t b[3][3], cs_real_t bf[3][3], const cs_real_t qimpv[3], cs_real_t hint)
Set Neumann BC for a scalar for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:171
CS_F_HOST_DEVICE void cs_boundary_conditions_set_convective_outlet_vector(cs_real_t a[3], cs_real_t af[3], cs_real_t b[3][3], cs_real_t bf[3][3], const cs_real_t pimpv[3], const cs_real_t cflv[3], cs_real_t hint)
Set convective outlet BC for a vector for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:774
CS_F_HOST_DEVICE void cs_boundary_conditions_set_convective_outlet_scalar(cs_real_t &a, cs_real_t &af, cs_real_t &b, cs_real_t &bf, cs_real_t pimp, cs_real_t cfl, cs_real_t hint)
Set convective oulet boundary condition for a scalar.
Definition: cs_boundary_conditions_set_coeffs.cpp:4147
CS_F_HOST_DEVICE void cs_boundary_conditions_set_affine_function_conv_neumann_diff_scalar(cs_real_t &a, cs_real_t &af, cs_real_t &b, cs_real_t &bf, cs_real_t pinf, cs_real_t ratio, cs_real_t dimp)
Set Neumann BC for the convection operator, imposed flux for diffusion.
Definition: cs_boundary_conditions_set_coeffs.h:1169
CS_F_HOST_DEVICE void cs_boundary_conditions_set_generalized_sym_vector_aniso(cs_real_t a[3], cs_real_t af[3], cs_real_t b[3][3], cs_real_t bf[3][3], const cs_real_t pimpv[3], const cs_real_t qimpv[3], const cs_real_t hint[6], const cs_nreal_t normal[3])
Set generalized BC for an anisotropic symmetric vector for a given face.
Definition: cs_boundary_conditions_set_coeffs.cpp:4182
CS_F_HOST_DEVICE void cs_boundary_conditions_set_dirichlet_vector(cs_real_t a[3], cs_real_t af[3], cs_real_t b[3][3], cs_real_t bf[3][3], const cs_real_t pimpv[3], cs_real_t hint, const cs_real_t hextv[3])
Set Dirichlet BC for a vector for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:308
CS_F_HOST_DEVICE void cs_boundary_conditions_set_neumann_tensor(cs_real_t a[6], cs_real_t af[6], cs_real_t b[6][6], cs_real_t bf[6][6], const cs_real_t qimpts[6], cs_real_t hint)
Set Neumann boundary conditions for a tensor for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:267
CS_F_HOST_DEVICE void cs_boundary_conditions_set_dirichlet_conv_neumann_diff_scalar(cs_real_t &a, cs_real_t &af, cs_real_t &b, cs_real_t &bf, cs_real_t pimp, cs_real_t dimp)
Imposed value for the convection operator, imposed flux for diffusion, for a scalar.
Definition: cs_boundary_conditions_set_coeffs.h:1232
CS_F_HOST_DEVICE void cs_boundary_conditions_set_generalized_dirichlet_sym_tensor(cs_real_t a[6], cs_real_t af[6], cs_real_t b[6][6], cs_real_t bf[6][6], const cs_real_t pimpv[6], const cs_real_t qimpv[6], cs_real_t hint, const cs_nreal_t normal[3])
Set generalized Dirichlet BC for a symmetric tensor for a given face.
Definition: cs_boundary_conditions_set_coeffs.h:664
#define CS_F_HOST_DEVICE
Definition: cs_defs.h:555
double cs_real_t
Floating-point value.
Definition: cs_defs.h:332
#define _(String)
Definition: cs_defs.h:61
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:325
double cs_nreal_t
Definition: cs_defs.h:336
@ k
Definition: cs_field_pointer.h:68
CS_F_HOST_DEVICE void cs_math_sym_33_3_product(const T m[6], const U v[3], V *restrict mv)
Compute the product of a symmetric matrix of 3x3 real values by a vector of 3 real values....
Definition: cs_math.h:416
static constexpr cs_real_t cs_math_infinite_r
Definition: cs_math.h:105
cs_alloc_mode_t
Definition: cs_mem.h:46
CS_F_HOST_DEVICE T max(const T a, const T b)
Definition: cs_defs.h:735
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources.
Definition: cs_equation_param.h:190