TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Perte_Charge_Reguliere.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 <Perte_Charge_Reguliere.h>
17#include <Motcle.h>
18
19// XD perte_charge_reguliere source_base perte_charge_reguliere NO_BRACE Source term modelling the presence of a bundle
20// XD_CONT of tubes in a flow.
21// XD attr spec spec_pdcr_base spec REQ Description of longitudinale or transversale type.
22// XD attr zone_name chaine name_of_zone REQ Name of the sub-area occupied by the tube bundle. A Sous_Zone (Sub-area)
23// XD_CONT type object called zone_name should have been previously created.
24
25// XD spec_pdcr_base objet_lecture spec_pdcr_base NO_BRACE Class to read the source term modelling the presence of a
26// XD_CONT bundle of tubes in a flow. Cf=A Re-B.
27
28// XD longitudinale spec_pdcr_base longitudinale NO_BRACE Class to define the pressure loss in the direction of the tube
29// XD_CONT bundle.
30// XD attr dir chaine(into=["x","y","z"]) dir REQ Direction.
31// XD attr dd floattant dd REQ Tube bundle hydraulic diameter value. This value is expressed in m.
32// XD attr ch_a chaine(into=["a","cf"]) ch_a REQ Keyword to be used to set law coefficient values for the coefficient of
33// XD_CONT regular pressure losses.
34// XD attr a floattant a REQ Value of a law coefficient for regular pressure losses.
35// XD attr ch_b chaine(into=["b"]) ch_b OPT Keyword to be used to set law coefficient values for regular pressure
36// XD_CONT losses.
37// XD attr b floattant b OPT Value of a law coefficient for regular pressure losses.
38
39// XD transversale spec_pdcr_base transversale NO_BRACE Class to define the pressure loss in the direction perpendicular
40// XD_CONT to the tube bundle.
41// XD attr dir chaine(into=["x","y","z"]) dir REQ Direction.
42// XD attr dd floattant dd REQ Value of the tube bundle step.
43// XD attr chaine_d chaine(into=["d"]) chaine_d REQ Keyword to be used to set the value of the tube external diameter.
44// XD attr d floattant d REQ Value of the tube external diameter.
45// XD attr ch_a chaine(into=["a","cf"]) ch_a REQ Keyword to be used to set law coefficient values for the coefficient of
46// XD_CONT regular pressure losses.
47// XD attr a floattant a REQ Value of a law coefficient for regular pressure losses.
48// XD attr ch_b chaine(into=["b"]) ch_b OPT Keyword to be used to set law coefficient values for regular pressure
49// XD_CONT losses.
50// XD attr b floattant b OPT Value of a law coefficient for regular pressure losses.
51
52
53//Add a constructor for initialization
55{
56
57 D_ = - 1e3;
58 d_ = - 1e3;
59 a_ = - 1e3;
60 b_ = - 1e3;
61 Cf_ = -1e3;
62
63 couronne_tube = -1e3; ;
64 Cf_utilisateur = -1e3 ;
65 xo = -1e3;
66 yo = -1e3;
67 zo = -1e3;
68 dir[ 0 ] = -1e3 ;
69 dir[ 1 ] = -1e3 ;
70 dir[ 2 ] = -1e3 ;
71 h0 = -1e3;
72 h = -1e3 ;
73
74}
75
76/*! @brief Reads the specifications of a regular pressure drop from an input stream.
77 *
78 * @param (Entree& is) an input stream
79 * @return (Entree&) the modified input stream
80 * @throws unexpected keyword, expected "X","Y" or "Z"
81 * @throws unexpected keyword, expected "d"
82 * @throws unexpected keyword, expected "longitudinale" or "transversale"
83 */
85{
86 int dimension = Objet_U::dimension ;
87
88 for (int i =0; i<dimension; i++ ) dir[i] = 0 ;
89
90 couronne_tube = 0 ;
91 Cf_utilisateur = 0 ;
92
93 Motcle motlu;
94 Motcles les_motcles(6);
95 les_motcles[0] = "X";
96 les_motcles[1] = "Y";
97 les_motcles[2] = "Z";
98 les_motcles[3] = "A";
99 les_motcles[4] = "B";
100 les_motcles[5] = "CF";
101
102 is >> motlu;
103 if (motlu == "longitudinale")
104 {
105 is >> motlu;
106 int rang = les_motcles.search(motlu);
107 if (rang == -1)
108 {
109 Cerr << "Error reading Perte_Charge_Reguliere data" << finl;
110 Cerr << "Expected one of the keywords" << les_motcles << finl;
111 Cerr << "instead of " << motlu << finl;
113 }
114 else
115 {
117 is >> D_;
118 Cerr << "D_ " << D_ << finl;
119 }
120 d_ = D_;
121 }
122 else if (motlu == "transversale")
123 {
124 is >> motlu;
125 int rang = les_motcles.search(motlu);
126 if (rang == -1)
127 {
128 Cerr << "Error reading Perte_Charge_Reguliere data" << finl;
129 Cerr << "Expected one of the keywords" << les_motcles << finl;
130 Cerr << "instead of " << motlu << finl;
132 }
133 else
134 {
136 is >> D_;
137 }
138 is >> motlu;
139 if (motlu != "d")
140 {
141 Cerr << "Error reading Perte_Charge_Reguliere data" << finl;
142 Cerr << "Expected keyword d instead of " << motlu << finl;
144 }
145 else
146 {
147 is >> d_;
148 }
149 }
150 else if (motlu == "couronne")
151 {
152 couronne_tube = 1 ;
153
154 if(dimension!=2)
155 {
156 // A ring (couronne) is in 2D only!
157 Cerr << "A ring (couronne) is in 2D only: in 3D use Tube "<< finl;
159 }
160 is >> motlu;
161 if(motlu!=Motcle("Origine"))
162 {
163 Cerr << "Expected keyword ORIGINE" << finl;
165 }
166
167 is >> xo >> yo ;
168 is >> motlu;
169 if (motlu != "d")
170 {
171 Cerr << "Error reading Perte_Charge_Reguliere data" << finl;
172 Cerr << "Expected keyword d instead of " << motlu << finl;
174 }
175 else
176 {
177 is >> d_;
178 D_ = d_;
179 }
181 dir[0] = 1 ;
182 dir[1] = 1 ;
183 }
184 else if (motlu == "tube")
185 {
186 couronne_tube = 1 ;
187 if(dimension!=3)
188 {
189 // A tube is in 3D only!
190 Cerr << "A tube is in 3D only: in 2D use couronne "<< finl;
192 }
193 is >> motlu;
194 if(motlu!=Motcle("Origine"))
195 {
196 Cerr << "Expected keyword ORIGINE" << finl;
198 }
199 is >> xo >> yo >> zo;
200 is >> motlu;
201 if(motlu!=Motcle("DIR"))
202 {
203 Cerr << "Expected the tube direction keyword: DIR" << finl;
205 }
206 int idir;
207 is >> idir;
208 switch(idir)
209 {
210 case 0:
211 dir[0]=0;
212 dir[1]=dir[2]=1;
213 h0=xo;
214 break;
215 case 1:
216 dir[1]=0;
217 dir[0]=dir[2]=1;
218 h0=yo;
219 break;
220 case 2:
221 dir[2]=0;
222 dir[1]=dir[0]=1;
223 h0=zo;
224 break;
225 default:
226 h0=-1;
227 Cerr << "DIR is 0 for tube // OX ; 1 for a tube // OY and 2 for a tube // OZ " << finl;
229 }
230 is >> motlu;
231 if (motlu != "d")
232 {
233 Cerr << "Error reading Perte_Charge_Reguliere data" << finl;
234 Cerr << "Expected keyword d instead of " << motlu << finl;
236 }
237 else
238 {
239 is >> d_;
240 D_ = d_;
241 }
243 }
244 else
245 {
246 Cerr << "Error reading Perte_Charge_Reguliere data" << finl;
247 Cerr << "Expected keyword longitudinale or transversale or couronne (2D) or tube (3D)" << finl;
248 Cerr << "instead of " << motlu << finl;
250 }
251
252 // Mandatory reading of a_ and b_:
253 int err=0;
254 is >> motlu;
255 if (motlu == "A")
256 is >> a_;
257 else
258 err=1;
259 if (err)
260 {
261 if (motlu == "CF")
262 {
263 is >> Cf_;
264 Cf_utilisateur = 1;
265 Cerr << " Cf_ " << Cf_ << finl;
266 }
267 }
268 else
269 {
270 is >> motlu;
271 if (motlu == "B")
272 is >> b_;
273 else
274 err=1;
275
276 }
277 if (err)
278 {
279 if (!Cf_utilisateur)
280 {
281 Cerr << "Error reading Perte_Charge_Reguliere data" << finl;
282 Cerr << "You must now specify the values of the pressure drop law:" << finl;
283 Cerr << "Example: Perte_Charge_Reguliere longitudinale X val A val B val" << finl;
284 Cerr << "With A and B, for a pressure drop law A.Re**(-B)" << finl;
285 Cerr << "For Blasius law: A=0.316, B=0.25" << finl;
287 }
288 }
289 else
290 Cerr << a_ << " " << b_ << finl;
291
292 return is;
293}
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
A character string (Nom) in uppercase.
Definition Motcle.h:26
An array of Motcle objects.
Definition Motcle.h:63
int search(const Motcle &t) const
Definition Motcle.cpp:319
static int dimension
Definition Objet_U.h:94
Entree & lire_donnees(Entree &)
Reads the specifications of a regular pressure drop from an input stream.
Classe Perte_Charge This class represents a pressure drop term that is introduced.
int direction_perte_charge_
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466