TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Sources_helpers_Multiphase.h
1/****************************************************************************
2* Copyright (c) 2024, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#ifndef Sources_helpers_Multiphase_included
17#define Sources_helpers_Multiphase_included
18
19#include <Milieu_composite.h>
20#include <Pb_Multiphase.h>
21
22#include <algorithm>
23#include <cmath>
24
25/*! @brief Shared helpers for multiphase source terms and correlations
26 * (surface tension indexing, liquid phase finder, drag, Eotvos, etc.)
27 * used across the CMFD module.
28 */
29
30/*! @brief Finds the liquid phase index in a multiphase problem.
31 * Prefers a phase named "liquide...continu" if available.
32 */
33inline int find_liquid_phase(const Pb_Multiphase& pbm, const Nom& class_name)
34{
35 if (pbm.nb_phases() == 1)
36 Process::exit(class_name + " : not needed for single-phase flow!");
37
38 int n_l = -1;
39 for (int n = 0; n < pbm.nb_phases(); n++)
40 if (pbm.nom_phase(n).debute_par("liquide")
41 && (n_l < 0 || pbm.nom_phase(n).finit_par("continu")))
42 n_l = n;
43
44 if (n_l < 0)
45 Process::exit(class_name + " : liquid phase not found!");
46
47 return n_l;
48}
49
50/*! @brief Computes the upper-triangular pair index for phases (k, l)
51 * with k < l, used to index the sigma table.
52 */
53inline int sigma_pair_index(int k, int l, int N)
54{
55 const int lo = std::min(k, l), hi = std::max(k, l);
56 return (lo * (N - 1) - (lo - 1) * lo / 2) + (hi - lo - 1);
57}
58
59/*! @brief Fills a (ne, nb_pairs) table with surface tension values
60 * for all phase pairs.
61 */
62inline void compute_sigma_table(const Milieu_composite& milc,
63 const DoubleTab& press, const DoubleTab& temp,
64 int ne, int N, DoubleTrav& Sigma_tab)
65{
66 const int Np = press.line_size();
67 for (int k = 0; k < N; k++)
68 for (int l = k + 1; l < N; l++)
69 {
70 const Interface_base& sat = milc.get_interface(k, l);
71 const int idx = sigma_pair_index(k, l, N);
72 for (int i = 0; i < ne; i++)
73 Sigma_tab(i, idx) = sat.sigma(temp(i, k), press(i, k * (Np > 1)));
74 }
75}
76
77/*! @brief Computes the norm of the relative velocity between phase k
78 * and the liquid phase n_l at element e.
79 * Velocity is a PolyMAC_MPFA face+elem field with element values
80 * stored at offset nf_tot.
81 */
82inline double relative_velocity_norm(const DoubleTab& vit, int nf_tot, int D,
83 int e, int k, int n_l)
84{
85 double u_r_sq = 0.;
86 for (int d = 0; d < D; d++)
87 {
88 const double dv = vit(nf_tot + D * e + d, k) - vit(nf_tot + D * e + d, n_l);
89 u_r_sq += dv * dv;
90 }
91 return std::sqrt(u_r_sq);
92}
93
94/*! @brief Tomiyama (1998) drag coefficient correlation.
95 * Cd = clamp(16/Re*(1+0.15*Re^0.687), 8*Eo/(3*(Eo+4)), 48/Re)
96 * Returns 0 when u_r == 0 (i.e. Reb == 0).
97 */
98inline double Tomiyama_Cd(double Reb, double Eo)
99{
100 if (Reb == 0.)
101 return 0.;
102 return std::clamp(16. / Reb * (1 + 0.15 * std::pow(Reb, 0.687)),
103 8. * Eo / (3. * (Eo + 4.)),
104 48. / Reb);
105}
106
107/*! @brief Computes the Eotvos number: Eo = g * |rho_l - rho_k| * d^2 / sigma */
108inline double eotvos_number(double g, double rho_l, double rho_k, double d_k, double sigma)
109{
110 return g * std::abs(rho_l - rho_k) * d_k * d_k / sigma;
111}
112
113#endif /* Sources_helpers_Multiphase_included */
double sigma(const double T, const double P) const
Classe Milieu_composite Cette classe represente un fluide reel ainsi que.
Interface_base & get_interface(int k, int l) const
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
virtual int finit_par(const char *const n) const
Definition Nom.cpp:324
virtual int debute_par(const char *const n) const
Definition Nom.cpp:319
classe Pb_Multiphase Cette classe represente un probleme de thermohydraulique multiphase de type "3*N...
const Nom & nom_phase(int i) const
int nb_phases() const
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
int line_size() const
Definition TRUSTVect.tpp:67