1 #ifndef __CS_BALANCE_H__ 2 #define __CS_BALANCE_H__ 3 4 /*============================================================================ 5 * Building of the right hand side for a transport of a field. 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 * Standard C library headers 34 *----------------------------------------------------------------------------*/ 35 36 /*---------------------------------------------------------------------------- 37 * Local headers 38 *----------------------------------------------------------------------------*/ 39 40 #include "cs_parameters.h" 41 42 /*----------------------------------------------------------------------------*/ 43 BEGIN_C_DECLS 44 45 /*============================================================================= 46 * Public function prototypes 47 *============================================================================*/ 48 49 /*----------------------------------------------------------------------------*/ 50 /*! 51 * \brief Wrapper to the function which adds the explicit part of the 52 * convection/diffusion 53 * terms of a transport equation of a scalar field \f$ \varia \f$. 54 * 55 * More precisely, the right hand side \f$ Rhs \f$ is updated as 56 * follows: 57 * \f[ 58 * Rhs = Rhs - \sum_{\fij \in \Facei{\celli}} \left( 59 * \dot{m}_\ij \left( \varia_\fij - \varia_\celli \right) 60 * - \mu_\fij \gradv_\fij \varia \cdot \vect{S}_\ij \right) 61 * \f] 62 * 63 * Warning: 64 * - \f$ Rhs \f$ has already been initialized 65 * before calling cs_balance_scalar! 66 * - mind the minus sign 67 * 68 * Options for the convective scheme: 69 * - blencp = 0: upwind scheme for the advection 70 * - blencp = 1: no upwind scheme except in the slope test 71 * - ischcp = 0: second order 72 * - ischcp = 1: centered 73 * - imucpp = 0: do not multiply the convective part by \f$ C_p \f$ 74 * - imucpp = 1: multiply the convective part by \f$ C_p \f$ 75 * 76 * \param[in] idtvar indicator of the temporal scheme 77 * \param[in] f_id field id (or -1) 78 * \param[in] imucpp indicator 79 * - 0 do not multiply the convectiv term by Cp 80 * - 1 do multiply the convectiv term by Cp 81 * \param[in] imasac take mass accumulation into account? 82 * \param[in] inc indicator 83 * - 0 when solving an increment 84 * - 1 otherwise 85 * \param[in] iccocg indicator 86 * - 1 re-compute cocg matrix (for iterative gradients) 87 * - 0 otherwise 88 * \param[in] var_cal_opt pointer to a cs_var_cal_opt_t structure which 89 * contains variable calculation options 90 * \param[in] pvar solved variable (current time step) 91 * \param[in] pvara solved variable (previous time step) 92 * \param[in] coefap boundary condition array for the variable 93 * (explicit part) 94 * \param[in] coefbp boundary condition array for the variable 95 * (implicit part) 96 * \param[in] cofafp boundary condition array for the diffusion 97 * of the variable (explicit part) 98 * \param[in] cofbfp boundary condition array for the diffusion 99 * of the variable (implicit part) 100 * \param[in] i_massflux mass flux at interior faces 101 * \param[in] b_massflux mass flux at boundary faces 102 * \param[in] i_visc \f$ \mu_\fij \dfrac{S_\fij}{\ipf \jpf} \f$ 103 * at interior faces for the r.h.s. 104 * \param[in] b_visc \f$ \mu_\fib \dfrac{S_\fib}{\ipf \centf} \f$ 105 * at boundary faces for the r.h.s. 106 * \param[in] viscel symmetric cell tensor \f$ \tens{\mu}_\celli \f$ 107 * \param[in] xcpp array of specific heat (Cp) 108 * \param[in] weighf internal face weight between cells i j in case 109 * of tensor diffusion 110 * \param[in] weighb boundary face weight for cells i in case 111 * of tensor diffusion 112 * \param[in] icvflb global indicator of boundary convection flux 113 * - 0 upwind scheme at all boundary faces 114 * - 1 imposed flux at some boundary faces 115 * \param[in] icvfli boundary face indicator array of convection flux 116 * - 0 upwind scheme 117 * - 1 imposed flux 118 * \param[in,out] smbrp right hand side \f$ \vect{Rhs} \f$ 119 */ 120 /*----------------------------------------------------------------------------*/ 121 122 void 123 cs_balance_scalar(int idtvar, 124 int f_id, 125 int imucpp, 126 int imasac, 127 int inc, 128 int iccocg, 129 cs_var_cal_opt_t *var_cal_opt, 130 cs_real_t pvar[], 131 const cs_real_t pvara[], 132 const cs_real_t coefap[], 133 const cs_real_t coefbp[], 134 const cs_real_t cofafp[], 135 const cs_real_t cofbfp[], 136 const cs_real_t i_massflux[], 137 const cs_real_t b_massflux[], 138 const cs_real_t i_visc[], 139 const cs_real_t b_visc[], 140 cs_real_6_t viscel[], 141 const cs_real_t xcpp[], 142 const cs_real_2_t weighf[], 143 const cs_real_t weighb[], 144 int icvflb, 145 const int icvfli[], 146 cs_real_t smbrp[]); 147 148 /*----------------------------------------------------------------------------*/ 149 /*! 150 * \brief Wrapper to the function which adds the explicit part of the 151 * convection/diffusion 152 * terms of a transport equation of a vector field \f$ \vect{\varia} \f$. 153 * 154 * More precisely, the right hand side \f$ \vect{Rhs} \f$ is updated as 155 * follows: 156 * \f[ 157 * \vect{Rhs} = \vect{Rhs} - \sum_{\fij \in \Facei{\celli}} \left( 158 * \dot{m}_\ij \left( \vect{\varia}_\fij - \vect{\varia}_\celli \right) 159 * - \mu_\fij \gradt_\fij \vect{\varia} \cdot \vect{S}_\ij \right) 160 * \f] 161 * 162 * Remark: 163 * if ivisep = 1, then we also take \f$ \mu \transpose{\gradt\vect{\varia}} 164 * + \lambda \trace{\gradt\vect{\varia}} \f$, where \f$ \lambda \f$ is 165 * the secondary viscosity, i.e. usually \f$ -\frac{2}{3} \mu \f$. 166 * 167 * Warning: 168 * - \f$ \vect{Rhs} \f$ has already been initialized 169 * before calling cs_balance_vector! 170 * - mind the sign minus 171 * 172 * Options for the convective scheme: 173 * - blencp = 0: upwind scheme for the advection 174 * - blencp = 1: no upwind scheme except in the slope test 175 * - ischcp = 0: second order 176 * - ischcp = 1: centered 177 * 178 * \param[in] idtvar indicator of the temporal scheme 179 * \param[in] f_id field id (or -1) 180 * \param[in] imasac take mass accumulation into account? 181 * \param[in] inc indicator 182 * - 0 when solving an increment 183 * - 1 otherwise 184 * \param[in] ivisep indicator to take \f$ \divv 185 * \left(\mu \gradt \transpose{\vect{a}} \right) 186 * -2/3 \grad\left( \mu \dive \vect{a} \right)\f$ 187 * - 1 take into account, 188 * - 0 otherwise 189 * \param[in] var_cal_opt pointer to a cs_var_cal_opt_t structure which 190 * contains variable calculation options 191 * \param[in] pvar solved velocity (current time step) 192 * \param[in] pvara solved velocity (previous time step) 193 * \param[in] coefav boundary condition array for the variable 194 * (explicit part) 195 * \param[in] coefbv boundary condition array for the variable 196 * (implicit part) 197 * \param[in] cofafv boundary condition array for the diffusion 198 * of the variable (explicit part) 199 * \param[in] cofbfv boundary condition array for the diffusion 200 * of the variable (implicit part) 201 * \param[in] i_massflux mass flux at interior faces 202 * \param[in] b_massflux mass flux at boundary faces 203 * \param[in] i_visc \f$ \mu_\fij \dfrac{S_\fij}{\ipf \jpf} \f$ 204 * at interior faces for the r.h.s. 205 * \param[in] b_visc \f$ \mu_\fib \dfrac{S_\fib}{\ipf \centf} \f$ 206 * at boundary faces for the r.h.s. 207 * \param[in] secvif secondary viscosity at interior faces 208 * \param[in] secvib secondary viscosity at boundary faces 209 * \param[in] viscel symmetric cell tensor \f$ \tens{\mu}_\celli \f$ 210 * \param[in] weighf internal face weight between cells i j in case 211 * of tensor diffusion 212 * \param[in] weighb boundary face weight for cells i in case 213 * of tensor diffusion 214 * \param[in] icvflb global indicator of boundary convection flux 215 * - 0 upwind scheme at all boundary faces 216 * - 1 imposed flux at some boundary faces 217 * \param[in] icvfli boundary face indicator array of convection flux 218 * - 0 upwind scheme 219 * - 1 imposed flux 220 * \param[in,out] smbr right hand side \f$ \vect{Rhs} \f$ 221 */ 222 /*----------------------------------------------------------------------------*/ 223 224 void 225 cs_balance_vector(int idtvar, 226 int f_id, 227 int imasac, 228 int inc, 229 int ivisep, 230 cs_var_cal_opt_t *var_cal_opt, 231 cs_real_3_t pvar[], 232 const cs_real_3_t pvara[], 233 const cs_real_3_t coefav[], 234 const cs_real_33_t coefbv[], 235 const cs_real_3_t cofafv[], 236 const cs_real_33_t cofbfv[], 237 const cs_real_t i_massflux[], 238 const cs_real_t b_massflux[], 239 const cs_real_t i_visc[], 240 const cs_real_t b_visc[], 241 const cs_real_t secvif[], 242 const cs_real_t secvib[], 243 cs_real_6_t viscel[], 244 const cs_real_2_t weighf[], 245 const cs_real_t weighb[], 246 int icvflb, 247 const int icvfli[], 248 cs_real_3_t smbr[]); 249 250 /*----------------------------------------------------------------------------*/ 251 /*! 252 * \brief Wrapper to the function which adds the explicit part of the 253 * convection/diffusion 254 * terms of a transport equation of a tensor field \f$ \tens{\varia} \f$. 255 * 256 * More precisely, the right hand side \f$ \vect{Rhs} \f$ is updated as 257 * follows: 258 * \f[ 259 * \tens{Rhs} = \tens{Rhs} - \sum_{\fij \in \Facei{\celli}} \left( 260 * \dot{m}_\ij \left( \tens{\varia}_\fij - \tens{\varia}_\celli \right) 261 * - \mu_\fij \gradt_\fij \tens{\varia} \cdot \tens{S}_\ij \right) 262 * \f] 263 * 264 * Warning: 265 * - \f$ \tens{Rhs} \f$ has already been initialized before calling bilscts! 266 * - mind the sign minus 267 * 268 * Options for the convective scheme: 269 * - blencp = 0: upwind scheme for the advection 270 * - blencp = 1: no upwind scheme except in the slope test 271 * - ischcp = 0: second order 272 * - ischcp = 1: centered 273 * 274 * \param[in] idtvar indicator of the temporal scheme 275 * \param[in] f_id field id (or -1) 276 * \param[in] imasac take mass accumulation into account? 277 * \param[in] inc indicator 278 * \param[in] var_cal_opt pointer to a cs_var_cal_opt_t structure which 279 * contains variable calculation options 280 * \param[in] pvar solved velocity (current time step) 281 * \param[in] pvara solved velocity (previous time step) 282 * \param[in] coefa boundary condition array for the variable 283 * (Explicit part) 284 * \param[in] coefb boundary condition array for the variable 285 * (Impplicit part) 286 * \param[in] cofaf boundary condition array for the diffusion 287 * of the variable (Explicit part) 288 * \param[in] cofbf boundary condition array for the diffusion 289 * of the variable (Implicit part) 290 * \param[in] i_massflux mass flux at interior faces 291 * \param[in] b_massflux mass flux at boundary faces 292 * \param[in] i_visc \f$ \mu_\fij \dfrac{S_\fij}{\ipf \jpf} \f$ 293 * at interior faces for the r.h.s. 294 * \param[in] b_visc \f$ \mu_\fib \dfrac{S_\fib}{\ipf \centf} \f$ 295 * at boundary faces for the r.h.s. 296 * \param[in] viscel symmetric cell tensor \f$ \tens{\mu}_\celli \f$ 297 * \param[in] weighf internal face weight between cells i j in case 298 * of tensor diffusion 299 * \param[in] weighb boundary face weight for cells i in case 300 * of tensor diffusion 301 * \param[in] icvflb global indicator of boundary convection flux 302 * - 0 upwind scheme at all boundary faces 303 * - 1 imposed flux at some boundary faces 304 * \param[in] icvfli boundary face indicator array of convection flux 305 * - 0 upwind scheme 306 * - 1 imposed flux 307 * \param[in,out] smbrp right hand side \f$ \vect{Rhs} \f$ 308 */ 309 /*----------------------------------------------------------------------------*/ 310 311 void 312 cs_balance_tensor(int idtvar, 313 int f_id, 314 int imasac, 315 int inc, 316 cs_var_cal_opt_t *var_cal_opt, 317 cs_real_6_t pvar[], 318 const cs_real_6_t pvara[], 319 const cs_real_6_t coefa[], 320 const cs_real_66_t coefb[], 321 const cs_real_6_t cofaf[], 322 const cs_real_66_t cofbf[], 323 const cs_real_t i_massflux[], 324 const cs_real_t b_massflux[], 325 const cs_real_t i_visc[], 326 const cs_real_t b_visc[], 327 cs_real_6_t viscel[], 328 const cs_real_2_t weighf[], 329 const cs_real_t weighb[], 330 int icvflb, 331 const int icvfli[], 332 cs_real_6_t smbrp[]); 333 334 /*----------------------------------------------------------------------------*/ 335 336 END_C_DECLS 337 338 #endif /* __CS_BALANCE_H__ */ 339