1#ifndef __CS_BOUNDARY_CONDITIONS_SET_COEFFS_H__
2#define __CS_BOUNDARY_CONDITIONS_SET_COEFFS_H__
171 for (
size_t i = 0; i < 3; i++) {
172 a[i] = -qimpv[i] / fmax(hint, 1.e-300);
175 b[0][0] = 1., b[0][1] = 0., b[0][2] = 0.;
176 b[1][0] = 0., b[1][1] = 1., b[1][2] = 0.;
177 b[2][0] = 0., b[2][1] = 0., b[2][2] = 1.;
181 for (
size_t i = 0; i < 3; i++) {
184 for (
size_t j = 0; j < 3; j++)
210 cs_real_t m[6] = {0., 0., 0., 0., 0., 0.};
211 m[0] = hint[1]*hint[2] - hint[4]*hint[4];
212 m[1] = hint[0]*hint[2] - hint[5]*hint[5];
213 m[2] = hint[0]*hint[1] - hint[3]*hint[3];
214 m[3] = hint[4]*hint[5] - hint[3]*hint[2];
215 m[4] = hint[3]*hint[5] - hint[0]*hint[4];
216 m[5] = hint[3]*hint[4] - hint[1]*hint[5];
218 cs_real_t invdet = 1./(hint[0]*m[0] + hint[3]*m[3] + hint[5]*m[5]);
220 cs_real_t invh[6] = {0., 0., 0., 0., 0., 0.};
221 invh[0] = m[0] * invdet;
222 invh[1] = m[1] * invdet;
223 invh[2] = m[2] * invdet;
224 invh[3] = m[3] * invdet;
225 invh[4] = m[4] * invdet;
226 invh[5] = m[5] * invdet;
233 b[0][0] = 1.0, b[0][1] = 0.0, b[0][2] = 0.0;
234 b[1][0] = 0.0, b[1][1] = 1.0, b[1][2] = 0.0;
235 b[2][0] = 0.0, b[2][1] = 0.0, b[2][2] = 1.0;
240 for (
cs_lnum_t jsou = 0; jsou < 3; jsou++)
265 for (
int i = 0; i < 6; i++) {
268 a[i] = -qimpts[i]/
cs::max(hint, 1.e-300);
269 for (
int jsou = 0; jsou < 6; jsou++) {
278 for (
int jsou = 0; jsou < 6; jsou++)
307 for (
int i = 0; i < 3; i++) {
312 for (
int jsou = 0; jsou < 3; jsou++)
316 af[i] = -hint*pimpv[i];
318 bf[0][0] = hint, bf[0][1] = 0., bf[0][2] = 0.;
319 bf[1][0] = 0., bf[1][1] = hint, bf[1][2] = 0.;
320 bf[2][0] = 0., bf[2][1] = 0., bf[2][2] = hint;
325 const cs_real_t val = hint/(hint + hextv[i]);
329 a[i] = hextv[i]*pimpv[i]/(hint + hextv[i]);
331 b[0][0] = val, b[0][1] = 0., b[0][2] = 0.;
332 b[1][0] = 0., b[1][1] = val, b[1][2] = 0.;
333 b[2][0] = 0., b[2][1] = 0., b[2][2] = val;
336 af[i] = -heq*pimpv[i];
338 bf[0][0] = heq, bf[0][1] = 0., bf[0][2] = 0.;
339 bf[1][0] = 0., bf[1][1] = heq, bf[1][2] = 0.;
340 bf[2][0] = 0., bf[2][1] = 0., bf[2][2] = heq;
397 for (
int i = 0; i < 3; i++) {
400 for (
int jsou = 0; jsou < 3; jsou++)
405#if defined(CS_DEVICE_COMPILE)
409 _(
" %s: hextv not set for component %d."),
417 for (
int i = 0; i < 3; i++)
454 for (
int i = 0; i < 6; i++) {
459 for (
int jsou = 0; jsou < 6; jsou++)
463 af[i] = -hint * pimpts[i];
464 for (
int jsou = 0; jsou < 6; jsou++) {
474 const cs_real_t heq = hint * hextts[i] / (hint + hextts[i]);
477 a[i] = hextts[i] * pimpts[i] / (hint + hextts[i]);
478 for (
int jsou = 0; jsou < 6; jsou++) {
480 b[i][jsou] = hint / (hint + hextts[i]);
486 af[i] = -heq * pimpts[i];
487 for (
int jsou = 0; jsou < 6; jsou++) {
523 for (
int i = 0; i < 3; i++) {
526 a[i] = - qimpv[i]/
cs::max(hint, 1.e-300);
528 for (
int j = 0; j < 3; j++) {
530 a[i] = a[i] + normal[i]*normal[j]
531 * (pimpv[j] + qimpv[j] /
cs::max(hint, 1.e-300));
534 b[i][j] = 1.0 - normal[i] * normal[j];
536 b[i][j] = - normal[i] * normal[j];
542 for (
int j = 0; j < 3; j++){
544 af[i] = af[i] - normal[i]*normal[j]
545 * (hint * pimpv[j] + qimpv[j]);
547 bf[i][j] = hint * normal[i] * normal[j];
606 for (
int i = 0; i < 3; i++) {
611 for (
int j = 0; j < 3; j++) {
613 a[i] = a[i] - normal[i]*normal[j]
614 * (pimpv[j] + qimpv[j] /
cs::max(hint, 1.e-300));
616 b[i][j] = normal[i] * normal[j];
621 af[i] = -hint*pimpv[i];
622 for (
int j = 0; j < 3; j++) {
624 af[i] = af[i] + normal[i]*normal[j]
625 * (qimpv[j] + pimpv[j] * hint);
628 bf[i][j] = hint * (1.0 - normal[i] * normal[j]);
630 bf[i][j] = - hint * normal[i] * normal[j];
664 const int iv2t[6] = {0, 1, 2, 0, 1, 0};
665 const int jv2t[6] = {0, 1, 2, 1, 2, 2};
666 const cs_real_t delta[3][3] = {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}};
671 for (
int ij = 0; ij < 6; ij++) {
679 for (
int kl = 0; kl < 6; kl++) {
684 d[ij][kl] = (delta[i][
k] - normal[i]*normal[
k]) * normal[l]*normal[j]
685 + normal[i]*normal[
k] * (delta[j][l] - normal[l]*normal[j]);
687 n[ij][kl] = normal[i]*normal[
k]*normal[l]*normal[j]
688 + (delta[i][
k] - normal[i]*normal[
k])
689 * (delta[j][l] - normal[j]*normal[l]);
691 a[ij] += d[ij][kl]*pimpv[kl]
692 - n[ij][kl]*qimpv[kl]/(
cs::max(hint, 1.e-300));
694 b[ij][kl] = n[ij][kl];
701 for (
int kl = 0; kl < 6; kl++) {
706 d[ij][kl] = (delta[i][
k] - normal[i]*normal[
k]) * normal[l]*normal[j]
707 + normal[i]*normal[
k] * (delta[j][l] - normal[l]*normal[j]);
709 n[ij][kl] = normal[i]*normal[
k]*normal[l]*normal[j]
710 + (delta[i][
k] - normal[i]*normal[
k])
711 * (delta[j][l] - normal[l]*normal[j]);
713 af[ij] += n[ij][kl]*qimpv[kl]
714 - hint*d[ij][kl]*pimpv[kl];
716 bf[ij][kl] = hint*d[ij][kl];
773 for (
int i = 0; i < 3; i++) {
776 for (
int j = 0; j < 3; j ++) {
778 b[i][j] = cflv[i] / (1.0 + cflv[i]);
782 a[i] = pimpv[i] * (1.0 - b[i][i]);
785 af[i] = -hint * a[i];
786 for (
int j = 0; j < 3; j++) {
788 bf[i][j] = hint * (1.0 - b[i][j]);
818 for (
int ij = 0; ij < 6; ij++) {
821 for (
int kl = 0; kl < 6; kl++) {
823 b[ij][kl] = cflts[ij] / (1.0 + cflts[ij]);
827 a[ij] = (1.0 - b[ij][ij]) * pimpts[ij];
830 af[ij] = -hint*a[ij];
831 for (
int kl = 0; kl < 6; kl++) {
833 bf[ij][kl] = hint * (1.0 - b[ij][kl]);
864 for(
int i = 0; i < 3; i++) {
867 for (
int j = 0; j < 3; j++) {
869 b[i][j] = cflv[i]/(1.0+cflv[i]);
873 a[i] = (1.0-b[i][i])*pimpv[i];
879 for (
int i = 0; i < 3; i++)
882 bf[0][0] = hintt[0]*(1.0 - b[0][0]);
883 bf[1][1] = hintt[1]*(1.0 - b[1][1]);
884 bf[2][2] = hintt[2]*(1.0 - b[2][2]);
885 bf[0][1] = hintt[3]*(1.0 - b[0][0]);
886 bf[1][0] = hintt[3]*(1.0 - b[0][0]);
887 bf[1][2] = hintt[4]*(1.0 - b[1][1]);
888 bf[2][1] = hintt[4]*(1.0 - b[1][1]);
889 bf[0][2] = hintt[5]*(1.0 - b[2][2]);
890 bf[2][0] = hintt[5]*(1.0 - b[2][2]);
916 for (
int i = 0; i < 3; i++) {
920 for (
int j = 0; j < 3; j++)
925 for (
int j = 0; j < 3; j++)
953 for (
int ij = 0; ij < 6; ij++) {
959 for (
int kl = 0; kl < 6; kl++)
964 for (
int kl = 0; kl < 6; kl++)
1001 a = -qimp/
cs::max(hint, 1.e-300);
1073 a = hext*pimp/(hint + hext);
1074 b = hint /(hint + hext);
1077 cs_real_t heq = hint*hext/(hint + hext);
1150 bf = hint * (1. - b);
1283 const bool need_compute_bc_grad,
1284 const bool need_compute_bc_flux,
1320 const bool need_compute_bc_grad,
1321 const bool need_compute_bc_flux,
1347template <cs_lnum_t str
ide>
1372template <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:193
Definition: cs_dispatch.h:1711
void cs_init_bc_coeffs_solve(cs_bc_coeffs_solve_t &c, cs_lnum_t n_b_faces, cs_lnum_t stride, cs_alloc_mode_t amode, bool limiter)
Initialize boundary condition coefficients solve arrays.
Definition: cs_boundary_conditions_set_coeffs.cpp:5172
static 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:597
static 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:1233
static 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:993
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:758
void cs_clear_bc_coeffs_solve(cs_bc_coeffs_solve_t &c)
Free boundary condition coefficients solve arrays.
Definition: cs_boundary_conditions_set_coeffs.cpp:5204
static 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:1136
static 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:299
static 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:765
static 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:946
void cs_boundary_conditions_update_bc_coeff_face_values_strided(cs_dispatch_context &ctx, cs_field_t *f, const cs_field_bc_coeffs_t *bc_coeffs, const int inc, const cs_equation_param_t *eqp, const cs_real_t pvar[][stride], cs_real_t val_ip[][stride], cs_real_t val_f[][stride], cs_real_t flux[][stride], cs_real_t flux_lim[][stride])
Update face value for gradient and diffusion when solving in increments.
Definition: cs_boundary_conditions_set_coeffs.cpp:4751
static 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:1051
static 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:203
void cs_boundary_conditions_update_bc_coeff_face_values(cs_dispatch_context &ctx, const cs_field_t *f, const 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 visel[], cs_real_t viscel[][6], const cs_real_t weighb[], const cs_real_t pvar[], cs_real_t val_f[], cs_real_t flux[])
Update face value for gradient and diffusion when solving in increment.
Definition: cs_boundary_conditions_set_coeffs.cpp:4319
static 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:1021
static 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:446
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, bool limiter)
Allocate BC coefficients face values if needed.
Definition: cs_boundary_conditions_set_coeffs.cpp:5128
static 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:258
static 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:388
static 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:1170
static 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:162
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:4216
static 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:810
void cs_boundary_conditions_set_coeffs_init(void)
Initialization of boundary condition arrays.
Definition: cs_boundary_conditions_set_coeffs.cpp:3946
static 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:1099
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:4099
static 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:909
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:4134
static 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:655
static 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:856
static 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:1201
static 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:514
#define BEGIN_C_DECLS
Definition: cs_defs.h:554
#define CS_F_HOST_DEVICE
Definition: cs_defs.h:585
double cs_real_t
Floating-point value.
Definition: cs_defs.h:357
#define _(String)
Definition: cs_defs.h:67
#define END_C_DECLS
Definition: cs_defs.h:555
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:350
double cs_nreal_t
Definition: cs_defs.h:361
@ k
Definition: cs_field_pointer.h:72
const cs_real_t cs_math_infinite_r
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:301
cs_alloc_mode_t
Definition: cs_mem.h:50
CS_F_HOST_DEVICE T max(const T a, const T b)
Definition: cs_defs.h:769
Definition: cs_field.h:105
Set of parameters to handle an unsteady convection-diffusion-reaction equation with term sources.
Definition: cs_equation_param.h:194
Field boundary condition descriptor (for variables)
Definition: cs_field.h:120
Field descriptor.
Definition: cs_field.h:156