TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Eq_couch_lim.cpp
1/****************************************************************************
2* Copyright (c) 2015 - 2016, 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 <Eq_couch_lim.h>
17#include <SFichier.h>
18
19Implemente_instanciable_sans_constructeur_ni_destructeur(Eq_couch_lim,"Eq_couch_lim",Objet_U);
20
25
30
32{
33 return os;
34}
35
37{
38 return is;
39}
40
41// Initialisation
42
43void Eq_couch_lim::initialiser(int n1, int n2, double n8,
44 double epsilon, int max_ite, int dyn_nu_t)
45{
46 N_comp = n1 ; // Nombre de composante a resoudre dans Eq_couch_lim
47 N = n2 ; // Nbre de points dans le maillage fin
48 facteur = n8; // facteur geometrique de raffinement du maillage fin
49 eps = epsilon; // Seuil de convergence de la resolution numerique dans aller_au_temps
50 max_it = max_ite; // Nbre d'iterations maximum dans aller_au_temps
51
52 nu_t_dyn = dyn_nu_t; //determination dynamique de nu_t dans TBLE
53
54 utau=0;
55 utau_old=0;
56
57 F.resize_array(N_comp*(N+1));
58 Un_old.resize_array(N_comp*(N+1));
59 Unp1.resize_array(N_comp*(N+1));
60 aa.resize_array(N_comp*N);
61
62
63 cis.resize_array(N_comp);
64 visco_tot.resize_array(N);
65 bb.resize_array(N);
66 cc.resize_array(N);
67 dd.resize_array(N);
68
69 v.resize_array(N+1);
70 v=0.;
71
72 y_.resize_array(N+1);
73 yc.resize_array(N+1);
74
76
77}
78
80{
81
82 //********************************
83 // Mise en place du maillage fin *
84 //********************************
85
86 double delta;
87 y_[0]=y0;
88 y_[N]=yn;
89 yc[0]=y0;
90 yc[N]=yn;
91
92 if(facteur==1.)
93 {
94 delta=(yn-y0)/(N-1);
95 for (int i=1 ; i<N ; i++)
96 {
97 yc[i]=yc[i-1]+delta;
98 }
99 }
100 else
101 {
102 delta = yn*(1.-facteur)/(1.-pow(facteur,N-1));
103 for (int i=1 ; i<N ; i++)
104 {
105 yc[i]=yc[i-1]+delta*pow(facteur,i-1);
106 }
107 }
108 for (int i=1 ; i<N ; i++)
109 {
110 y_[i]=0.5*(yc[i]+yc[i-1]);
111 }
112
114 {
115 SFichier fic_mesh("tble_mesh.dat",ios::app); // ouverture du fichier conv.dat
116 for(int i=0 ; i<N+1 ; i++)
117 {
118 fic_mesh << i << " " << y_[i] << finl;
119 }
120 fic_mesh << finl;
121 }
122
123 //************************************
124 // Fin mise en place du maillage fin *
125 //************************************
126}
127//************************************************
128//*************** aller_au_temps ***********
129//************************************************
130
131
133{
134 it=0;
135
136 utau=0.;
137 utau_old = 0;
138 double criterion;
139 Diffu_totale_base& le_a = a.valeur();
140
141 if(t_final==0)
142 {
143 for (int j = 0 ; j < N_comp ; j++)
144 for(int i=0 ; i<N+1 ; i++)
145 {
146 tabdouble(F,j,i) = 0;
147 }
148 }
149
150 visco_tot = le_a.calculer_a_local(0);
151
152 do
153 {
154
155 for(int i= 0; i<N ; i++)
156 visco_tot[i] = le_a.calculer_a_local(i);
157
158 //bb evaluation
159 for(int i=1 ; i<N ; i++)
160 {
161 bb[i] = visco_tot[i]/(y_[i+1]-y_[i]);
162 dd[i]=1./(yc[i]-yc[i-1]);
163 }
164
165 dd[1] = 1./(yc[1]-y0);
166
167 bb[0] = visco_tot[0]/(2.*(y_[1]-y_[0]));
168
169 //cc evaluation
170 cc[N-1] = dd[N-1]*(bb[N-1]+bb[N-2])+(1./dt);
171
172 for(int i=N-2 ; i>0 ; i--)
173 {
174 cc[i] = dd[i]*(bb[i]+bb[i-1])-((dd[i]*dd[i+1]*bb[i]*bb[i])/cc[i+1])+(1./dt);
175 }
176
177 //a evaluation
178 for (int j = 0 ; j < N_comp ; j++)
179 tabdouble(aa,j,N-1) = tabdouble(F,j,N-1) + dd[N-1]*bb[N-1]*tabdouble(Unp1,j,N) + (tabdouble(Un_old,j,N-1)/dt);
180
181 for (int j = 0 ; j < N_comp ; j++)
182 for(int i=N-2 ; i>0 ; i--)
183 {
184 tabdouble(aa,j,i) = tabdouble(F,j,i) + dd[i]*bb[i]*tabdouble(aa,j,i+1)/cc[i+1] + (tabdouble(Un_old,j,i)/dt);
185 }
186
187 //Velocity computation
188 for (int j = 0 ; j < N_comp ; j++)
189 {
190 tabdouble(Unp1,j,1) = (tabdouble(aa,j,1)+2*bb[0]*dd[1]*tabdouble(Unp1,j,0))/(cc[1]+bb[0]*dd[1]);
191 }
192 for (int j = 0 ; j < N_comp ; j++)
193 {
194 for (int i=2 ; i<N ; i++)
195 {
196 tabdouble(Unp1,j,i) = (dd[i]*bb[i-1]/cc[i])*tabdouble(Unp1,j,i-1)+(tabdouble(aa,j,i)/cc[i]);
197 }
198 }//FIN RESOLUTION Un
199
200
201
202 /*criterion=-1;
203 DoubleVect Vect_carre(N_comp);
204 DoubleVect Vect_carre_old(N_comp);
205 Vect_carre_old=0;
206 IntVect itstd::max(N_comp);
207
208 for(int k=0 ; k < N_comp ; k++)
209 {
210 itmax=0;
211 Vect_carre(k)=0;
212
213 for(int i=0 ; i < N+1 ; i++)
214 {
215 Vect_carre(k)+=(tabdouble(Unp1,k,i)-tabdouble(Un_old,k,i))*(tabdouble(Unp1,k,i)-tabdouble(Un_old,k,i));
216 Vect_carre_old(k)+=tabdouble(Un_old,k,i)*tabdouble(Un_old,k,i);
217 }
218
219 Vect_carre(k) = sqrt(Vect_carre(k));
220 Vect_carre_old(k)=sqrt(Vect_carre_old(k));
221
222 double criterion1=0.;
223 if(Vect_carre(k)<1.e-20 || Vect_carre_old(k)<1.e-20 )
224 criterion1=Vect_carre(k);
225 else
226 criterion1=(Vect_carre(k)/(Vect_carre_old(k)+DMINFLOAT));
227
228 criterion=std::max(criterion,criterion1);
229
230 itstd::max(k)+=it;
231 } */
232
233 double frottement=0.;
234
235 for (int j = 0 ; j < N_comp ; j++)
236 {
237
238 cis[j] = le_a.calculer_a_local(0)*(tabdouble(Unp1,j,1)-tabdouble(Unp1,j,0))/((y_[1]-y0));
239 frottement += cis[j]*cis[j];
240 }
241
242 //frottement : carre de la densite de flux diffusifs sur le bord
243 //frottement pour TBLE hydr
244 //densite de flux de chaleur parietal pour TBLE scal
245
246 utau = sqrt(sqrt(frottement));
247
248 criterion = (std::fabs(utau_old-utau))/(std::fabs(utau)+DMINFLOAT);
249
250 utau_old = utau;
251
252 it++;
253 if(it>=max_it)
254 Cerr << "Warning : NON convergence in the TBLE resolution !!!" << finl;
255 }
256 while((criterion > eps)&&(it<max_it));
257
258 // FIN ITERATION DE CONVERGENCE
259
260 nu_t_yn = le_a.calculer_a_local(N-1)-le_a.calculer_a_local(0);
261
262 utau_old = utau;
263
264 Un_old = Unp1;// Sauvegarde du champ fin de l'instant N
265}
266
267
268void Eq_couch_lim::aller_jusqu_a_convergence(int itmax, double erreur)
269{
270 int ite=0;
271 double critere=1e10;
272 double utau_nm1=0.;
273 while (ite<itmax && critere>erreur)
274 {
275 aller_au_temps(1.);
276 critere = (std::fabs(utau_nm1-utau))/(std::fabs(utau)+DMINFLOAT);
277 utau_nm1 = utau;
278 ite++;
279 }
280 // Cout << "NITE TBLE = " << ite << finl;
281 // Cout << "critere TBLE = " << critere << finl;
282}
Classe Diffu_totale_base Classe abstraite calculant la diffusivite totale (somme diffusivite.
virtual double calculer_a_local(int ind)=0
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
void initialiser(int, int, double, double, int, int)
~Eq_couch_lim() override
void aller_au_temps(double)
void aller_jusqu_a_convergence(int, double)
classe Objet_U Cette classe est la classe de base des Objets de TRUST
Definition Objet_U.h:73
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
static int je_suis_maitre()
renvoie 1 si on est sur le processeur maitre du groupe courant (c'est a dire me() == 0),...
Definition Process.cpp:86
Cette classe est a la classe C++ ofstream ce que la classe Sortie est a la classe C++ ostream Elle re...
Definition SFichier.h:27
Classe de base des flux de sortie.
Definition Sortie.h:52