TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Entree_fluide_T_h_imposee.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 <Entree_fluide_T_h_imposee.h>
17
18Implemente_instanciable(Entree_fluide_T_h_imposee, "Frontiere_ouverte_T_h_imposee", Dirichlet_entree_fluide);
19
20Sortie& Entree_fluide_T_h_imposee::printOn(Sortie& s) const { return s << que_suis_je() << finl; }
21
22/*! @brief Types le_champ_front as "Champ_front_uniforme".
23 *
24 * Reads the values of the external field if the boundary conditions
25 * are specified as: "T_ext", "C_ext", "Y_ext" or "K_Eps_ext"
26 * Raises an error otherwise.
27 *
28 * @param (Entree& s) input stream
29 * @return (Entree& s) the modified input stream
30 * @throws external field type not recognized;
31 * recognized types are: "T_ext", "C_ext", "Y_ext" or "K_Eps_ext"
32 */
34{
35 if (app_domains.size() == 0) app_domains = { Motcle("Thermique"), Motcle("indetermine") };
36
37 le_champ_front.typer("Champ_front_uniforme");
38 le_champ_Text.typer("Champ_front_uniforme");
39 le_champ_hext.typer("Champ_front_uniforme");
40 Motcle motlu;
41 Motcles les_motcles(6);
42 {
43 les_motcles[0] = "T_ext";
44 les_motcles[1] = "C_ext";
45 les_motcles[2] = "K_Eps_ext";
46 les_motcles[3] = "H_ext";
47 les_motcles[4] = "Y_ext";
48 les_motcles[5] = "K_Omega_ext";
49 }
50
51 Motcle accfermee = "}";
52 Motcle accouverte = "{";
53 s >> motlu;
54 int rang;
55 if (motlu != accouverte)
56 {
57 Cerr << "Expected a { when reading the interface " << finl;
58 exit();
59 }
60 s >> motlu;
61 while (motlu != accfermee)
62 {
63 rang = les_motcles.search(motlu);
64 switch(rang)
65 {
66 case 0:
67 {
68 s >> le_champ_Text;
69 break;
70 }
71 case 1:
72 case 2:
73 case 3:
74 case 4:
75 {
76 s >> le_champ_hext;
77 break;
78 }
79 default:
80 {
81 Cerr << "Error reading boundary condition of type: " << finl;
82 Cerr << que_suis_je() << finl;
83 Cerr << "Expected " << les_motcles << " instead of " << motlu << finl;
84 exit();
85 }
86 }
87 s >> motlu;
88 }
89
90 return s;
91}
92
93/*! @brief Returns the value of the i-th component of the field imposed on the exterior of the boundary.
94 *
95 * @param (int i) index along the first dimension of the field
96 * @return (double) the value imposed on the specified component of the field
97 * @throws second dimension of the boundary field greater than 1
98 */
100{
101 if (type_cond_lim == 0)
102 {
103 // Cerr<<"Entree_fluide_T_h_imposee Condition limite en temperature"<<finl;
104 if (le_champ_Text->valeurs().size() == 1)
105 return le_champ_Text->valeurs()(0, 0);
106 else if (le_champ_Text->valeurs().dimension(1) == 1)
107 return le_champ_Text->valeurs()(i, 0);
108 else
109 Cerr << "Entree_fluide_T_h_imposee::val_ext" << finl;
110 exit();
111 return 0.;
112 }
113 else
114 {
115 // Cerr<<"Entree_fluide_T_h_imposee Condition limite en enthalpie"<<finl;
116 if (le_champ_hext->valeurs().size() == 1)
117 return le_champ_hext->valeurs()(0, 0);
118 else if (le_champ_hext->valeurs().dimension(1) == 1)
119 return le_champ_hext->valeurs()(i, 0);
120 else
121 Cerr << "Entree_fluide_T_h_imposee::val_ext" << finl;
122 exit();
123 return 0.;
124 }
125}
126
127/*! @brief Returns the value of the (i,j)-th component of the field imposed on the exterior of the boundary.
128 *
129 * @param (int i) index along the first dimension of the field
130 * @param (int j) index along the second dimension of the field
131 * @return (double) the value imposed on the specified component of the field
132 */
133double Entree_fluide_T_h_imposee::val_imp(int i, int j) const
134{
135 if (type_cond_lim == 0)
136 {
137 // Temperature boundary condition
138 if (le_champ_Text->valeurs().dimension(0) == 1)
139 return le_champ_Text->valeurs()(0, j);
140 else
141 return le_champ_Text->valeurs()(i, j);
142 }
143 else
144 {
145 // Enthalpy boundary condition
146 if (le_champ_hext->valeurs().dimension(0) == 1)
147 return le_champ_hext->valeurs()(0, j);
148 else
149 return le_champ_hext->valeurs()(i, j);
150 }
151}
std::vector< Motcle > app_domains
Dirichlet_entree_fluide This class represents a boundary condition imposing a quantity.
Entree_fluide_temperature_imposee Special case of the Dirichlet_entree_fluide class.
double val_imp(int i) const override
Returns the value of the i-th component of the field imposed on the exterior of the boundary.
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
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
Base class for output streams.
Definition Sortie.h:52