TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Sortie_libre_Text_H_ext.cpp
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#include <Sortie_libre_Text_H_ext.h>
17#include <Equation_base.h>
18#include <Motcle.h>
19
20Implemente_instanciable(Sortie_libre_Text_H_ext, "Sortie_libre_Text_H_ext", Neumann);
21
22Sortie& Sortie_libre_Text_H_ext::printOn(Sortie& s) const { return s << que_suis_je() << finl; }
23
24/*! @brief Types le_champ_front as "Champ_front_uniforme".
25 *
26 * Reads the values of the external field if the boundary conditions
27 * are specified as: "T_ext", "C_ext", "Y_ext" or "K_Eps_ext"
28 * Raises an error otherwise.
29 *
30 * @param (Entree& s) input stream
31 * @return (Entree& s) the modified input stream
32 * @throws external field type not recognized;
33 * recognized types are: "T_ext", "C_ext", "Y_ext" or "K_Eps_ext"
34 */
36{
37 if (app_domains.size() == 0)
38 app_domains = {Motcle("Transport_Keps"), Motcle("Transport_Komega"),
39 Motcle("Thermique"), Motcle("Concentration"),
40 Motcle("indetermine")
41 };
42
43 le_champ_front.typer("Champ_front_uniforme");
44 le_champ_Text.typer("Champ_front_uniforme");
45 le_champ_hext.typer("Champ_front_uniforme");
46 Motcle motlu;
47 Motcles les_motcles(6);
48 {
49 les_motcles[0] = "T_ext";
50 les_motcles[1] = "C_ext";
51 les_motcles[2] = "K_Eps_ext";
52 les_motcles[3] = "H_ext";
53 les_motcles[4] = "Y_ext";
54 les_motcles[5] = "K_Omega_ext";
55 }
56
57 Motcle accfermee = "}";
58 Motcle accouverte = "{";
59 s >> motlu;
60 int rang;
61 if (motlu != accouverte)
62 {
63 Cerr << "Expected a { when reading the interface " << finl;
64 exit();
65 }
66 s >> motlu;
67 while (motlu != accfermee)
68 {
69 rang = les_motcles.search(motlu);
70 switch(rang)
71 {
72 case 0:
73 {
74 s >> le_champ_Text;
75 break;
76 }
77 case 1:
78 case 2:
79 case 3:
80 case 4:
81 {
82 s >> le_champ_hext;
83 break;
84 }
85 default:
86 {
87 Cerr << "Error reading boundary condition of type: " << finl;
88 Cerr << que_suis_je() << finl;
89 Cerr << "Expected " << les_motcles << " instead of " << motlu << finl;
90 exit();
91 }
92 }
93 s >> motlu;
94 }
95
96 return s;
97}
98
99/*! @brief Returns the value of the i-th component of the field imposed on the exterior of the boundary.
100 *
101 * @param (int i) index along the first dimension of the field
102 * @return (double) the value imposed on the specified component of the field
103 * @throws second dimension of the boundary field greater than 1
104 */
106{
107 if (type_cond_lim == 0)
108 {
109 // Cerr<<"Sortie_libre_Text_H_ext Condition limite en temperature"<<finl;
110 if (le_champ_Text->valeurs().size() == 1)
111 return le_champ_Text->valeurs()(0, 0);
112 else if (le_champ_Text->valeurs().dimension(1) == 1)
113 return le_champ_Text->valeurs()(i, 0);
114 else
115 Cerr << "Sortie_libre_Text_H_ext::val_ext" << finl;
116 exit();
117 return 0.;
118 }
119 else
120 {
121 // Cerr<<"Sortie_libre_Text_H_ext Condition limite en enthalpie"<<finl;
122 if (le_champ_hext->valeurs().size() == 1)
123 return le_champ_hext->valeurs()(0, 0);
124 else if (le_champ_hext->valeurs().dimension(1) == 1)
125 return le_champ_hext->valeurs()(i, 0);
126 else
127 Cerr << "Sortie_libre_Text_H_ext::val_ext" << finl;
128 exit();
129 return 0.;
130 }
131}
132
133/*! @brief Returns the value of the (i,j)-th component of the field imposed on the exterior of the boundary.
134 *
135 * @param (int i) index along the first dimension of the field
136 * @param (int j) index along the second dimension of the field
137 * @return (double) the value imposed on the specified component of the field
138 */
139double Sortie_libre_Text_H_ext::val_ext(int i, int j) const
140{
141 if (type_cond_lim == 0)
142 {
143 // Temperature boundary condition
144 if (le_champ_Text->valeurs().dimension(0) == 1)
145 return le_champ_Text->valeurs()(0, j);
146 else
147 return le_champ_Text->valeurs()(i, j);
148 }
149 else
150 {
151 // Enthalpy boundary condition
152 if (le_champ_hext->valeurs().dimension(0) == 1)
153 return le_champ_hext->valeurs()(0, j);
154 else
155 return le_champ_hext->valeurs()(i, j);
156 }
157}
158
159/*! @brief Returns the value of the imposed flux on the i-th component of the field representing the flux at the boundary.
160 *
161 * The boundary field is considered constant over all
162 * elements of the boundary.
163 * The imposed flux value at the boundary equals
164 * the value of the (constant) boundary field.
165 *
166 * @param (int i) index along the first dimension of the field
167 * @return (double) the value imposed on the specified component of the field
168 * @throws second dimension of the boundary field greater than 1
169 */
171{
172 if (type_cond_lim == 0)
173 {
174 if (le_champ_Text->valeurs().size() == 1)
175 return le_champ_Text->valeurs()(0, 0);
176 else if (le_champ_Text->valeurs().dimension(1) == 1)
177 return le_champ_Text->valeurs()(i, 0);
178 else
179 Cerr << "Sortie_libre_Text_H_ext::flux_impose" << finl;
180 exit();
181 return 0.;
182 }
183 else
184 {
185 if (le_champ_hext->valeurs().size() == 1)
186 return le_champ_hext->valeurs()(0, 0);
187 else if (le_champ_hext->valeurs().dimension(1) == 1)
188 return le_champ_hext->valeurs()(i, 0);
189 else
190 Cerr << "Sortie_libre_Text_H_ext::flux impose" << finl;
191 exit();
192 return 0.;
193 }
194}
195
196/*! @brief Returns the value of the imposed flux on the (i,j)-th component of the field representing the flux at the boundary.
197 *
198 * The boundary field is NOT constant over all elements
199 * of the boundary.
200 *
201 * @param (int i) index along the first dimension of the field
202 * @param (int j) index along the second dimension of the field
203 * @return (double) the value imposed on the specified component of the field
204 */
205double Sortie_libre_Text_H_ext::flux_impose(int i, int j) const
206{
207 if (type_cond_lim == 0)
208 {
209 // Temperature boundary condition
210 if (le_champ_Text->valeurs().dimension(0) == 1)
211 return le_champ_Text->valeurs()(0, j);
212 else
213 return le_champ_Text->valeurs()(i, j);
214 }
215 else
216 {
217 // Enthalpy boundary condition
218 if (le_champ_hext->valeurs().dimension(0) == 1)
219 return le_champ_hext->valeurs()(0, j);
220 else
221 return le_champ_hext->valeurs()(i, j);
222 }
223}
std::vector< Motcle > app_domains
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Classe Neumann This class is the base class of the hierarchy of Neumann-type boundary conditions.
Definition Neumann.h:31
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
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Neumann_sortie_libre This class represents an open boundary without imposed velocity.
virtual double val_ext(int i) const
Returns the value of the i-th component of the field imposed on the exterior of the boundary.
double flux_impose(int i) const override
Returns the value of the imposed flux on the i-th component of the field representing the flux at the...
Base class for output streams.
Definition Sortie.h:52