TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Vitesse_derive_Forces.cpp
1/****************************************************************************
2* Copyright (c) 2026, 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#include <Frottement_interfacial_base.h>
17#include <Dispersion_bulles_base.h>
18#include <Portance_interfaciale_base.h>
19#include <Vitesse_derive_Forces.h>
20#include <Pb_Multiphase.h>
21#include <cmath>
22
23Implemente_instanciable(Vitesse_derive_Forces, "Vitesse_relative_derive_Forces", Vitesse_derive_base);
24
27
29{
30 param.ajouter("alpha_lim", &alpha_lim_);
32}
33
35{
36 Pb_Multiphase& pbm = ref_cast(Pb_Multiphase, pb_.valeur());
37 if (!pbm.has_correlation("frottement_interfacial")) Process::exit(que_suis_je() + " : there must be an interfacial friction correlation in the problem !");
38 if (pbm.has_correlation("dispersion_bulles")) needs_grad_alpha_ = 1;
39 if (pbm.has_correlation("portance_interfaciale")) needs_vort_ = 1, pbm.creer_champ("vorticite");
40}
41
43{
44 const Pb_Multiphase& pbm = ref_cast(Pb_Multiphase, pb_.valeur());
45 const int D = dimension, N = in.alpha.dimension(0);
46 const double norm_g = sqrt(local_carre_norme_vect(in.g));
47
48 // Newton method to determine dv along gravity
49 double dv0 = 0.2, epsilon = 1.e-4; // Initialize dv at random
50 int step = 1, iter_max = 20;
51 DoubleTab p, T, dv(N, N), coeff(N, N, 2), alpha_l(N);
52 const Frottement_interfacial_base& correlation_fi = ref_cast(Frottement_interfacial_base, pbm.get_correlation("frottement_interfacial"));
53 double sum_alpha = 0;
54 for (int n=0; n<N ; n++) alpha_l(n)= std::max(in.alpha(n), alpha_lim_), sum_alpha+=alpha_l(n);
55 for (int n=0; n<N ; n++) alpha_l(n)/=sum_alpha;
56
57 do
58 {
59 dv(n_g,n_l) = dv0;
60 dv(n_l,n_g) = dv0;
61 correlation_fi.coefficient(alpha_l, p, T, in.rho, in.mu, in.sigma, in.dh, dv, in.d_bulles, coeff);
62 dv0 = dv0 - (coeff(n_l, n_g, 0)*dv0 - norm_g*alpha_l(n_g)*(in.rho[n_l]*in.alpha[n_l]+in.rho[n_g]*in.alpha[n_g] - in.rho[n_g])) / (coeff(n_l, n_g, 1)*dv0 + coeff(n_l, n_g, 0));
63 step = step+1;
64 if(step > iter_max) Process::exit(que_suis_je() + " : Newton algorithm not converging to find relative velocity !");
65 }
66 while(std::abs(coeff(n_l, n_g, 0)*dv0 - norm_g*alpha_l(n_g)*(in.rho[n_l]*in.alpha[n_l]+in.rho[n_g]*in.alpha[n_g]- in.rho[n_g])) > epsilon);
67
68 /* distribution parameter */
69 C0 = 1;
70
71 /* drift velocity along gravity */
72 for (int d = 0; d < D; d++) vg0(d) = - dv0 * in.g(d) / norm_g;
73
74 DoubleTrav forces(D);
75 if (pbm.has_correlation("dispersion_bulles"))
76 {
77 const Dispersion_bulles_base& correlation_db = ref_cast(Dispersion_bulles_base, pbm.get_correlation("dispersion_bulles"));
80 out_td.Ctd.resize(N,N);
81 dv(n_g,n_l) = ( dv(n_l,n_g) = dv0) ;
82 correlation_fi.coefficient(alpha_l, p, T, in.rho, in.mu, in.sigma, in.dh, dv, in.d_bulles, coeff); // update interfacial friction coefficient
83 in_td.alpha = alpha_l, in_td.rho = in.rho, in_td.mu = in.mu, in_td.sigma = in.sigma, in_td.nut = in.nut, in_td.k_turb = in.k, in_td.d_bulles = in.d_bulles, in_td.nv = dv;
84 correlation_db.coefficient(in_td, out_td); // correlation identifies the liquid phase
85 for (int d = 0; d < D; d++) forces(d) += - out_td.Ctd(n_g, n_l) * in.gradAlpha(d, n_g) + out_td.Ctd(n_l, n_g) * in.gradAlpha(d, n_l);
86 }
87
88 if (pbm.has_correlation("portance_interfaciale"))
89 {
90 const Portance_interfaciale_base& correlation_pi = ref_cast(Portance_interfaciale_base, pbm.get_correlation("portance_interfaciale"));
93 out_pi.Cl.resize(N,N);
94 dv(n_g,n_l) = ( dv(n_l,n_g) = dv0) ;
95 correlation_fi.coefficient(alpha_l, p, T, in.rho, in.mu, in.sigma, in.dh, dv, in.d_bulles, coeff); // update interfacial friction coefficient
96 in_pi.alpha = alpha_l, in_pi.rho = in.rho, in_pi.mu = in.mu, in_pi.sigma = in.sigma, in_pi.k_turb = in.k, in_pi.d_bulles = in.d_bulles, in_pi.nv = dv;
97 correlation_pi.coefficient(in_pi, out_pi); // correlation identifies the liquid phase
98 if (D==2)
99 {
100 forces(0) -= out_pi.Cl(n_l, n_g) * (- dv0 * in.g(1) / norm_g * in.vort(0, n_l)) ;
101 forces(1) += out_pi.Cl(n_l, n_g) * (- dv0 * in.g(0) / norm_g * in.vort(0, n_l)) ;
102 }
103 if (D==3)
104 {
105 forces(0) -= out_pi.Cl(n_l, n_g) * (- dv0 * in.g(1) / norm_g * in.vort(2, n_l) + dv0 * in.g(2) / norm_g * in.vort(1, n_l)) ;
106 forces(1) -= out_pi.Cl(n_l, n_g) * (- dv0 * in.g(2) / norm_g * in.vort(0, n_l) + dv0 * in.g(0) / norm_g * in.vort(2, n_l)) ;
107 forces(2) -= out_pi.Cl(n_l, n_g) * (- dv0 * in.g(0) / norm_g * in.vort(1, n_l) + dv0 * in.g(1) / norm_g * in.vort(0, n_l)) ;
108 }
109 }
110
111
112 for (int d = 0; d < D; d++) vg0(d) += forces(d)/coeff(n_g,n_l,0) ;
113 for (int d = 0; d < D; d++) vg0(d) *= (1.0 - C0 * in.alpha(n_g)) ;
114}
Base class for turbulent bubble dispersion operators, where the force.
virtual void coefficient(const input_t &input, output_t &output) const =0
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Frottement_interfacial_base class: utility for interfacial friction operators taking the form.
virtual void coefficient(const DoubleTab &alpha, const DoubleTab &p, const DoubleTab &T, const DoubleTab &rho, const DoubleTab &mu, const DoubleTab &sigma, double Dh, const DoubleTab &ndv, const DoubleTab &d_bulles, DoubleTab &coeff) const =0
static int dimension
Definition Objet_U.h:94
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
void ajouter(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
Definition Param.cpp:364
Multiphase thermohydraulics problem of type "3*N equations":
Base class for interfacial lift force operators of the form:
virtual void coefficient(const input_t &input, output_t &output) const =0
void creer_champ(const Motcle &motlu) override
int has_correlation(std::string nom_correlation) const
const Correlation_base & get_correlation(std::string nom_correlation) const
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Base class for output streams.
Definition Sortie.h:52
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469
_SIZE_ dimension(int d) const
Definition TRUSTTab.tpp:133
Force-based drift velocity between a gas phase and a liquid phase.
void evaluate_C0_vg0(const input_t &input) const override
void set_param(Param &param) const override
Vitesse_derive_base class.
void set_param(Param &param) const override