TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Flux_parietal_bilineaire.cpp
1/****************************************************************************
2* Copyright (c) 2025, 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
17#include <Flux_parietal_bilineaire.h>
18#include <Milieu_composite.h>
19#include <Pb_Multiphase.h>
20#include <Sources_helpers_Multiphase.h>
21#include <cmath>
22
23
24Implemente_instanciable( Flux_parietal_bilineaire, "Flux_parietal_bilineaire", Flux_parietal_base) ;
25
27{
28 return os;
29}
30
32{
33 Param param(que_suis_je());
34 param.ajouter("coeff_echange_monophasique|single_phase_exchange_coeff", &h_mono_, Param::REQUIRED);
35 param.ajouter("coeff_echange_diphasique|multi_phase_exchange_coeff", &h_diph_, Param::REQUIRED);
36 param.ajouter("coeff_osv|osv_coeff", &coeff_, Param::REQUIRED);
37 param.ajouter("offset", &b_);
38 param.lire_avec_accolades_depuis(is);
39
40 /* n_l / n_g : phases liquide / gaz continu */
41 const Pb_Multiphase *pbm = sub_type(Pb_Multiphase, pb_.valeur()) ? &ref_cast(Pb_Multiphase, pb_.valeur()) : nullptr;
42
43 if (!pbm || pbm->nb_phases() == 1) // pas un Pb_Multiphase -> monophasique liquide
44 Process::exit("Flux_parietal_bilineaire can only be used for a multiphase problem with 2 phases!");
45
46 n_l = find_liquid_phase(*pbm, que_suis_je());
47
48 // recherche de n_g : phase gaz_continu en priorite
49 for (int n = 0; n < pbm->nb_phases(); n++)
50 if (pbm->nom_phase(n).debute_par("gaz")
51 && (n_g < 0 || pbm->nom_phase(n).finit_par("continu")))
52 n_g = n;
53
54 assert (n_l >= 0 && n_g >= 0);
55
56 const Milieu_composite *mc = sub_type(Milieu_composite, pb_->milieu()) ? &ref_cast(Milieu_composite, pb_->milieu()) : nullptr;
57
58 if (mc->has_saturation(n_l, n_g))
59 sat = &mc->get_saturation(n_l, n_g);
60
61 if (!sat)
62 Process::exit("Flux_parietal_bilineaire needs saturation!");
63
64 return is;
65}
66
68 double dTf_phi, double dp_phi,
69 double dTp_phi, double& dTf_eps,
70 double& dp_eps, double& dTp_eps) const
71{
72 const double Ts = sat->Tsat(in.p);
73 const double Tld = Ts - phi * coeff_;
74 const double dp_Tld = sat->dP_Tsat(in.p) - dp_phi * coeff_;
75 const double dTp_Tld = -dTp_phi * coeff_;
76 const double dTf_Tld = -dTf_phi * coeff_;
77
78 const double eps = std::clamp((in.T[n_l] - Tld) / (Ts - Tld), 0.0, 1.0);
79
80 if (Tld < in.T[n_l] && in.T[n_l] < Ts)
81 {
82 const double delT = in.T[n_l] - Tld;
83 const double delTs = Ts - Tld;
84 const double fac = 1./(delTs*delTs);
85 dTf_eps = (delTs * (1 - dTf_Tld) + delT * dTf_Tld) * fac;
86 dp_eps = (delTs * (-dp_Tld) - delT * (sat->dP_Tsat(in.p) - dp_Tld)) * fac;
87 dTp_eps = (delTs * (-dTp_Tld) + delT * dTp_Tld) * fac;
88 }
89
90 return eps;
91}
92
94{
95 const double Ts = sat->Tsat(in.p) ;
96 const Milieu_composite& milc = ref_cast(Milieu_composite, pb_->milieu());
97
98 if (out.nonlinear)
99 (*out.nonlinear) = 1; // we turn on nonlinear in case it goes to two-phase during the newton
100
101 for (int k = 0; k < in.N; k++)
102 if (n_l != k)
103 if (milc.has_saturation(n_l, k))
104 {
105 const double P_mono = h_mono_ * (in.Tp - in.T[n_l]);
106 const double P_diph= h_diph_ * (in.Tp - Ts) + b_;
107
108 if (in.Tp < Ts) //monophasique
109 {
110 if (out.qpk)
111 (*out.qpk)(n_l) = P_mono;
112 if (out.dTp_qpk)
113 (*out.dTp_qpk)(n_l) = h_mono_;
114 if (out.dTf_qpk)
115 (*out.dTf_qpk)(n_l, n_l) = 0;
116 }
117 else
118 {
119 if (Ts <= in.T[n_l]) // Everything in the evaporative term
120 {
121 if (out.qpi)
122 (*out.qpi)(n_l, k) = P_diph;
123 if (out.dTp_qpi)
124 (*out.dTp_qpi)(n_l, k) = h_diph_;
125 if (out.dTf_qpi)
126 (*out.dTf_qpi)(n_l, k, n_l) = 0;
127 if (out.dp_qpi)
128 (*out.dp_qpi)(n_l, k, n_l) = -h_diph_*sat->dP_Tsat(in.p);
129 }
130 else
131 {
132 double dTf_eps = 0.0, dp_eps = 0.0, dTp_eps = 0.0;
133 const double eps = fraction_flux_vap(in, P_diph, 0,
134 -h_diph_*sat->dP_Tsat(in.p),
135 h_diph_, dTf_eps, dp_eps, dTp_eps);
136
137 // Fill in the outputs : heat flux towards liquid
138 if (out.qpk)
139 (*out.qpk)(n_l) = (1.0 - eps) * P_diph;
140 if (out.dTp_qpk)
141 (*out.dTp_qpk)(n_l) = (1.0 - eps) * h_diph_ - P_diph * dTp_eps;
142 if (out.dTf_qpk)
143 (*out.dTf_qpk)(n_l, n_l) = -P_diph*dTf_eps;
144 if (out.dp_qpk)
145 (*out.dp_qpk)(n_l, k, n_l) = -h_diph_*sat->dP_Tsat(in.p)*(1.0 - eps)
146 - P_diph*dp_eps;
147
148 // Evaporation
149 if (out.qpi)
150 (*out.qpi)(n_l, k) = eps * P_diph;
151 if (out.dTp_qpi)
152 (*out.dTp_qpi)(n_l, k) = dTp_eps * P_diph+ eps * h_diph_;
153 if (out.dTf_qpi)
154 (*out.dTf_qpi)(n_l, k, n_l) = P_diph*dTf_eps;
155 if (out.dp_qpi)
156 (*out.dp_qpi)(n_l, k, n_l) = -h_diph_*sat->dP_Tsat(in.p)*eps
157 + P_diph*dp_eps;
158 }
159 }
160 }
161}
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
classe Flux_parietal_base correlations de flux parietal de la forme
: class Flux_parietal_bilineaire
double fraction_flux_vap(const input_t &in, double phi, double dTf_phi, double dp_phi, double dTp_phi, double &dTf_eps, double &dp_eps, double &dTp_eps) const
void qp(const input_t &input, output_t &output) const override
Classe Milieu_composite Cette classe represente un fluide reel ainsi que.
bool has_saturation(int k, int l) const
Saturation_base & get_saturation(int k, int l) const
virtual int debute_par(const char *const n) const
Definition Nom.cpp:319
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
@ REQUIRED
Definition Param.h:115
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
Classe de base des flux de sortie.
Definition Sortie.h:52