TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
IJK_switch.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 <IJK_switch.h>
17#include <math.h>
18#include <Probleme_base.h>
19#include <SChaine.h>
20
21Implemente_base(Switch_double, "Switch_double", Interprete);
22// XD Switch_double interprete Switch_double BRACE not_set
24{
25 return s;
26}
28{
29 return s;
30}
31
32// Interpole source dans cible les champs sont aux faces.
33void Switch_double::switch_vit(DoubleTab coeff_i, IntTab Indice_i,
34 DoubleTab coeff_j ,IntTab Indice_j,
35 DoubleTab coeff_k ,IntTab Indice_k,
36 const int dir)
37{
38 for (int k = 0; k < new_nk_; k++)
39 for (int j = 0; j < new_nj_; j++)
40 for (int i = 0; i < new_ni_; i++)
41 {
42 const int i2 = Indice_i[i];
43 const int j2 = Indice_j[j];
44 const int k2 = Indice_k[k];
45 double x = 0.;
46 for (int di = 0; di < 2; di++)
47 for (int dj = 0; dj < 2; dj++)
48 for (int dk = 0; dk < 2; dk++)
49 x += coeff_i(i, di) * coeff_j(j, dj) * coeff_k(k, dk) * old_velocity_[dir](i2+di, j2+dj, k2+dk);
50 new_velocity_[dir](i,j,k) = x;
51 }
52}
53
54// Interpole source dans cible les champs sont aux faces.
56{
57 DoubleTab coeff_i[3], coeff_j[3], coeff_k[3];
58 IntTab Indice_i[3], Indice_j[3], Indice_k[3];
59 for (int dir = 0; dir < 3; dir++)
60 {
62 calculer_coeff(coeff_i[dir],Indice_i[dir],
63 coeff_j[dir],Indice_j[dir],
64 coeff_k[dir],Indice_k[dir]);
65
66 }
67 for (int k = 0; k < new_nk_; k++)
68 {
69 ArrOfFloat tmp((new_ni_+1) * (new_nj_+1) * 3);
70 tmp = 0.;
71 for (int dir = 0; dir < 3; dir++)
72 for (int j = 0; j < new_nj_; j++)
73 for (int i = 0; i < new_ni_; i++)
74 {
75 const int i2 = Indice_i[dir][i];
76 const int j2 = Indice_j[dir][j];
77 const int k2 = Indice_k[dir][k];
78 double x = 0.;
79 for (int di = 0; di < 2; di++)
80 for (int dj = 0; dj < 2; dj++)
81 for (int dk = 0; dk < 2; dk++)
82 x += coeff_i[dir](i, di) * coeff_j[dir](j, dj) * coeff_k[dir](k, dk) * old_velocity_[dir](i2+di, j2+dj, k2+dk);
83 tmp[(j * (new_ni_+1) + i) * 3 + dir] = (float)x;
84 }
85 Cerr << "Writing velocity, layer " << k << " / " << new_nk_ << endl;
86 binary_file.put(tmp.addr(), tmp.size_array(), 1);
87 }
88 // Last layer, write zeros.
89 // In z velocities are on the wall, x and y velocities are filling values
90 // not used.
91 {
92 int k = new_nk_;
93 ArrOfFloat tmp((new_ni_+1) * (new_nj_+1) * 3);
94 tmp = 0.;
95 Cerr << "Writing velocity, layer " << k << " / " << new_nk_ << endl;
96 binary_file.put(tmp.addr(), tmp.size_array(), 1);
97 }
98}
99
101{
102 // Recuperation des donnees de maillage
105 // On garde en memoire si on a un cas perio :
106 perio_k_ = old_mesh_.get_periodic_flag(DIRECTION_K);
107
109}
110
112{
113 param.ajouter("old_ijk_splitting", &old_mesh_name_, Param::REQUIRED); // XD_ADD_P chaine
114 // XD_CONT not_set
115 param.ajouter("new_ijk_splitting", &new_mesh_name_, Param::REQUIRED); // XD_ADD_P chaine
116 // XD_CONT not_set
117
118 param.ajouter("nom_sauvegarde", &nom_sauvegarde_, Param::REQUIRED); // XD_ADD_P chaine
119 // XD_CONT not_set
120 param.ajouter("nom_reprise", &nom_reprise_, Param::REQUIRED); // XD_ADD_P chaine
121 // XD_CONT not_set
122 param.ajouter("direct_write", &direct_write_); // XD_ADD_P entier
123 // XD_CONT not_set
124}
125
127{
128 Param param(que_suis_je());
129 set_param(param);
130 param.lire_avec_accolades(is);
131
132 prepare_run();
133
134 run();
135 return is;
136}
137
139{
140 const Nom& oldgeomname = old_mesh_.le_nom();
141
142 Cout << "Lecture vitesse initiale dans fichier " << fichier_old_vitesse_ << " timestep= " << timestep_reprise_vitesse_ << finl;
143 lire_dans_lata(fichier_old_vitesse_, timestep_reprise_vitesse_, oldgeomname, "VELOCITY",
144 old_velocity_[0], old_velocity_[1], old_velocity_[2]); // fonction qui lit un champ a partir d'un lata .
145
146 old_ni_ = old_mesh_.get_nb_items_local(Domaine_IJK::ELEM, DIRECTION_I);
147 old_nj_ = old_mesh_.get_nb_items_local(Domaine_IJK::ELEM, DIRECTION_J);
148 old_nk_ = old_mesh_.get_nb_items_local(Domaine_IJK::ELEM, DIRECTION_K);
149
150 new_ni_ = new_mesh_.get_nb_items_local(Domaine_IJK::ELEM, DIRECTION_I);
151 new_nj_ = new_mesh_.get_nb_items_local(Domaine_IJK::ELEM, DIRECTION_J);
152 new_nk_ = new_mesh_.get_nb_items_local(Domaine_IJK::ELEM, DIRECTION_K);
153}
154
156{
157 param.ajouter("tinit", &current_time_);
158 param.ajouter("terme_acceleration_init", &terme_source_acceleration_);
159 param.ajouter("terme_acceleration_init_z", &terme_source_acceleration_z_);
160
161 // GAB : gabriel.ramirez@cea.fr
162 /* Voir reprendre probleme dans IJK_FT.cpp */
163 /*
164 param.ajouter("forcage", &forcage_);
165 param.ajouter("reprise_qdm_source", &qdm_source_);
166 param.ajouter("reprise_vap_velocity_tmoy", &vap_velocity_tmoy_);
167 param.ajouter("reprise_liq_velocity_tmoy", &liq_velocity_tmoy_);
168 param.ajouter("last_source_qdm_update_time", &last_source_qdm_update_time_);
169 param.ajouter("offset_list_index_", &offset_list_index_);
170 param.ajouter("reprise_size_listes_moyennes_glissantes", &size_listes_source_);
171 liste_instants_.resize_array(size_listes_source_);
172 liste_vap_dl_.resize_array(size_listes_source_);
173 liste_liq_dl_.resize_array(size_listes_source_);
174 param.ajouter("reprise_liste_instants", &liste_instants_);
175 param.ajouter("reprise_liste_vap_dl", &liste_vap_dl_);
176 param.ajouter("reprise_liste_liq_dl", &liste_liq_dl_);
177 param.ajouter("reprise_v_target", &reprise_v_target_);
178 */
179 // fin GAB : gabriel.ramirez@cea.fr
180
181 param.ajouter("fichier_reprise_vitesse", &fichier_old_vitesse_);
182 param.ajouter("timestep_reprise_vitesse", &timestep_reprise_vitesse_);
183 param.ajouter_non_std("statistiques_FT", this);
184}
185
187{
188 if (mot == "statistiques_FT")
189 {
190 Motcle m;
191 int acc = 0;
192 while (acc <2)
193 {
194 is >> m;
195 if (m == '}')
196 {
197 acc++;
198 }
199 }
200 return 1;
201 }
202 else
203 return 0;
204}
205
206
207void Switch_double::lire_fichier_reprise(const char *fichier_reprise)
208{
209 // Lecture par tous les processeurs, on retire les commentaires etc...
210 LecFicDiffuse_JDD fichier(fichier_reprise);
211 Param param(que_suis_je());
212 set_param_reprise(param);
213 param.lire_avec_accolades(fichier);
214 // Appeler ensuite initialize() pour lire les fichiers lata etc...
215}
216
217
218void Switch_double::calculer_coeff(DoubleTab& coeff_i, IntTab& Indice_i,
219 DoubleTab& coeff_j ,IntTab& Indice_j,
220 DoubleTab& coeff_k ,IntTab& Indice_k)
221{
222 coeff_i.resize(new_ni_,2);
223 Indice_i.resize(new_ni_);
224 for (int i = 0; i < new_ni_; i++)
225 {
226 // trouver le plus petit i2 tel que coord[i2] >= coord[i]
227 int i2 = 0 ;
228 for (i2 = -old_x_.ghost(); i2 < old_ni_ + old_x_.ghost() && old_x_[i2] < new_x_[i]; i2++)
229 ;
230 if (i2 > -old_x_.ghost())
231 i2--;
232 Indice_i[i] = i2;
233
234 const double delta = old_x_[i2+1] - old_x_[i2];
235 coeff_i(i,0) = (old_x_[i2+1] - new_x_[i]) / delta;
236 coeff_i(i,1) = 1. - coeff_i(i,0);
237 }
238
239 coeff_j.resize(new_nj_,2);
240 Indice_j.resize(new_nj_);
241 for (int j = 0; j < new_nj_; j++)
242 {
243 // trouver le plus petit i2 tel que coord[i2] >= coord[i]
244 int j2 = 0 ;
245 for (j2 = -old_y_.ghost(); j2 < old_nj_ + old_y_.ghost() && old_y_[j2] < new_y_[j]; j2++)
246 ;
247 if (j2 > -old_y_.ghost())
248 j2--;
249 Indice_j[j] = j2;
250
251 const double delta = old_y_[j2+1] - old_y_[j2];
252 coeff_j(j,0) = (old_y_[j2+1] - new_y_[j]) / delta;
253 coeff_j(j,1) = 1. - coeff_j(j,0);
254 }
255 coeff_k.resize(new_nk_,2);
256 Indice_k.resize(new_nk_);
257 for (int k = 0; k < new_nk_; k++)
258 {
259 // trouver le plus petit i2 tel que coord[i2] >= coord[i]
260 int k2 = 0 ;
261 for (k2 = -old_z_.ghost(); k2 < old_nk_ + old_z_.ghost() && old_z_[k2] < new_z_[k]; k2++)
262 ;
263
264 if (k2 > -old_z_.ghost())
265 k2--;
266
267 if (k2+1==old_nk_ + old_z_.ghost())
268 k2--;
269 double delta = old_z_[k2+1] - old_z_[k2];
270 if (delta<DMINFLOAT)
271 {
272 // Les points (old_z_[k2+1] et old_z_[k2]) sont confondus (z_ghost et rempli avec la coord de la paroi...)
273 // on se decalle d'un cran :
274 k2++;
275 delta = old_z_[k2+1] - old_z_[k2];
276 }
277 Indice_k[k] = k2;
278 coeff_k(k,0) = (old_z_[k2+1] - new_z_[k]) / delta;
279 coeff_k(k,1) = 1. - coeff_k(k,0);
280 }
281
282 // Quand ce n'est pas perio, il n'y a pas de cellules ghost pour le champ aux elem.
283 // Donc impossible d'interroger ce champ en [-1] ou en [nk].
284 // Dans l'absolu, il faudrait changer la technique d'interpolation dans ce cas, pour tenir compte de la CL.
285 // Il est beaucoup plus simple de reduire la precision de la methode d'interpolation a l'ordre 0,
286 // en mettant pour cela simplement tout le poids sur l'autre element.
287 if (!perio_k_)
288 {
289 const int kmin = old_mesh_.get_offset_local(DIRECTION_K);
290 const bool own_last = (kmin+old_nk_ == old_mesh_.get_nb_elem_tot(DIRECTION_K));
291 if (kmin == 0)
292 {
293 Indice_k[0] = 0;
294 coeff_k(0,0) = 1. ; // tous le poids sur l'elem de bord.
295 coeff_k(0,1) = 0.; // On va quand meme pas aller prendre le voisin dedans... Et pourquoi pas?
296 // On pourrait construire une technique d'extrapolation basee sur l'evaluation du gradient entre cell[1] et cell[0].
297 // Le coeff serait alors negatif.
298 }
299 if (own_last)
300 {
301 Indice_k[new_nk_-1] = old_nk_-2; // Je crains que si je ne mets pas n-2, pour le coeff[...,1] il utilisera la case +1 qui va sortir du tableau.
302 // Cela ouvre aussi l'option a l'extrapolation.
303 coeff_k(new_nk_-1,0) = 0;
304 coeff_k(new_nk_-1,1) = 1.; // Du coup, c'est bien lui qui doit etre a 1.
305 }
306 }
307}
308
310{
311 // ancien maillage
312 const double s_dx = old_mesh_.get_constant_delta(DIRECTION_I);
313 const double s_dy = old_mesh_.get_constant_delta(DIRECTION_J);
314 const ArrOfDouble& s_dz = old_mesh_.get_delta(DIRECTION_K);
315 /*
316 const int old_offset_i = old_geom.get_offset_local(DIRECTION_I);
317 const int old_offset_j = old_geom.get_offset_local(DIRECTION_J);
318 const int old_offset_k = old_geom.get_offset_local(DIRECTION_K);
319 double s_origin_x = old_geom.get_origin(DIRECTION_I)
320 + ((loc==Domaine_IJK::FACES_J || loc==Domaine_IJK::FACES_K || loc==Domaine_IJK::ELEM) ? (s_dx * 0.5) : 0. ) ;
321 double s_origin_y = old_geom.get_origin(DIRECTION_J)
322 + ((loc==Domaine_IJK::FACES_K || loc==Domaine_IJK::FACES_I || loc==Domaine_IJK::ELEM) ? (s_dy * 0.5) : 0. ) ;
323 double s_origin_z = old_geom.get_origin(DIRECTION_K)
324 + ((loc==Domaine_IJK::FACES_I || loc==Domaine_IJK::FACES_J || loc==Domaine_IJK::ELEM) ? (s_dz[0] * 0.5) : 0. ) ;
325 */
326 // Coords of the local origin :
327 Vecteur3 old_xyz0 = old_mesh_.get_coords_of_dof(0,0,0,loc);
328 double s_origin_x = old_xyz0[DIRECTION_I] ;
329 double s_origin_y = old_xyz0[DIRECTION_J] ;
330 double s_origin_z = old_xyz0[DIRECTION_K] ;
331
332 old_z_[0] = s_origin_z;
333 for (int k=1; k < old_nk_ ; k++)
334 old_z_[k] = old_z_[k-1] + 0.5*s_dz[k-1] + 0.5 * s_dz[k];
335
336 // Il faut donner la position des ghosts :
337 old_z_[-1]= old_z_[0]-s_dz[0];
338 old_z_[old_nk_] = old_z_[old_nk_-1] +s_dz[old_nk_-1];
339 if (!perio_k_)
340 {
341 // Il faut peut-etre corriger la position des ghosts :
342 const int kmin = old_mesh_.get_offset_local(DIRECTION_K);
343 const bool own_last = (kmin+old_nk_ == old_mesh_.get_nb_elem_tot(DIRECTION_K));
344 if (kmin == 0)
345 old_z_[-1]= old_z_[0]-0.5*s_dz[0]; /* CL K_min*/
346 if (own_last)
347 old_z_[old_nk_] = old_z_[old_nk_-1]+ 0.5*s_dz[old_nk_-1]; /* CL K_max*/
348 }
349
350 /* DIR I */
351 old_x_[-1]= s_origin_x-s_dx;
352 for (int i =0 ; i <= old_ni_ ; i++)
353 old_x_[i] = old_x_[i-1]+s_dx;
354
355 /* DIR J */
356 old_y_[-1]=s_origin_y-s_dy;
357 for (int j =0 ; j <= old_nj_ ; j++)
358 old_y_[j] = old_y_[j-1]+s_dy;
359
360 // nouveau maillage
361 const double c_dx = new_mesh_.get_constant_delta(DIRECTION_I);
362 const double c_dy = new_mesh_.get_constant_delta(DIRECTION_J);
363 const ArrOfDouble& c_dz = new_mesh_.get_delta(DIRECTION_K);
364 /*
365 double c_origin_x = new_geom.get_origin(DIRECTION_I)
366 + ((loc==Domaine_IJK::FACES_J || loc==Domaine_IJK::FACES_K || loc==Domaine_IJK::ELEM) ? (c_dx * 0.5) : 0. ) ;
367 double c_origin_y = new_geom.get_origin(DIRECTION_J)
368 + ((loc==Domaine_IJK::FACES_K || loc==Domaine_IJK::FACES_I || loc==Domaine_IJK::ELEM) ? (c_dy * 0.5) : 0. ) ;
369 double c_origin_z = new_geom.get_origin(DIRECTION_K)
370 + ((loc==Domaine_IJK::FACES_I || loc==Domaine_IJK::FACES_J || loc==Domaine_IJK::ELEM) ? (c_dz[0] * 0.5) : 0. ) ;
371 */
372 // Coords of the local origin :
373 Vecteur3 new_xyz0 = new_mesh_.get_coords_of_dof(0,0,0,loc);
374 double c_origin_x = new_xyz0[DIRECTION_I] ;
375 double c_origin_y = new_xyz0[DIRECTION_J] ;
376 double c_origin_z = new_xyz0[DIRECTION_K] ;
377
378 new_z_[0] = c_origin_z;
379 for (int k=1; k < new_nk_ ; k++)
380 new_z_[k] = new_z_[k-1] + 0.5*c_dz[k-1] + 0.5 * c_dz[k];
381
382 if (perio_k_)
383 {
384 // new_z_[-1]= ...ori...-c_dz[0]; new_z_ n'a pas de ghost car pas necessaire !
385 // new_z_[new_nk_] = new_z_[new_nk_-1] + c_dz[new_nk_-1];
386 }
387 else
388 {
389 // new_z_ n'a pas de ghost car pas necessaire !
390 // new_z_[-1]= 0 ; /* CL K_min*/
391 // new_z_[new_nk_] = new_z_[new_nk_-1]+ 0.5*c_dz[new_nk_-1]; /* CL K_max*/
392 }
393
394 /* DIR I */
395 new_x_[0]=c_origin_x;
396 for (int i =1 ; i < new_ni_ ; i++)
397 new_x_[i] = new_x_[i-1]+c_dx;
398
399 /* DIR J */
400 new_y_[0]=c_origin_y;
401 for (int j =1 ; j < new_nj_ ; j++)
402 new_y_[j] = new_y_[j-1]+c_dy;
403}
404
406{
407 // const Domaine_IJK::Localisation loc = field.get_localisation();
409 calculer_coords(loc);
410 return;
411}
412
414{
415 switch(dir)
416 {
417 case 0:
419 break;
420 case 1:
422 break;
423 case 2:
425 break;
426 default:
427 Cerr << "Error in calculer_coords_Vi: wrong dir" << finl;
429 };
430 return;
431}
432
433void Switch_double::ecrire_header_lata(const Nom lata_name) // const
434{
435 Cout << "Dumping lata header and time into " << lata_name << finl;
436 dumplata_header(lata_name, new_velocity_[0] /* on passe un champ pour ecrire la geometrie */);
437 dumplata_newtime(lata_name, current_time_);
438}
439
440void Switch_double::switch_scalar_field(const IJK_Field_double& oldf, IJK_Field_double& newf,
441 DoubleTab coeff_i, IntTab Indice_i,
442 DoubleTab coeff_j ,IntTab Indice_j,
443 DoubleTab coeff_k ,IntTab Indice_k) const
444{
445 // Interpole source dans cible les champs sont aux elements
446 // Pas besoin de ghost dans new, donc pas de parcours des ghosts.
447 const int ni = newf.ni();
448 const int nj = newf.nj();
449 const int nk = newf.nk();
450 for (int k = 0; k < nk; k++)
451 for (int j = 0; j < nj; j++)
452 for (int i = 0; i < ni; i++)
453 {
454 const int i2 = Indice_i[i];
455 const int j2 = Indice_j[j];
456 const int k2 = Indice_k[k];
457 double x = 0.;
458 for (int di = 0; di < 2; di++)
459 for (int dj = 0; dj < 2; dj++)
460 for (int dk = 0; dk < 2; dk++)
461 x += coeff_i(i, di) * coeff_j(j, dj) * coeff_k(k, dk) * oldf(i2+di, j2+dj, k2+dk);
462 newf(i,j,k) = x;
463 }
464}
465
466
468 const IJK_Field_double& fld,
469 DoubleTab coeff_i, IntTab Indice_i,
470 DoubleTab coeff_j ,IntTab Indice_j,
471 DoubleTab coeff_k ,IntTab Indice_k)
472{
473 // Swap J et K et interpole, ecrit le resultat directement dans un fichier lata
474 for (int k = 0; k < new_nk_; k++)
475 {
476 ArrOfFloat tmp(new_ni_ * new_nj_);
477 for (int j = 0; j < new_nj_; j++)
478 for (int i = 0; i < new_ni_; i++)
479 {
480 const int i2 = Indice_i[i];
481 const int j2 = Indice_j[j];
482 const int k2 = Indice_k[k];
483 double x = 0.;
484 for (int di = 0; di < 2; di++)
485 for (int dj = 0; dj < 2; dj++)
486 for (int dk = 0; dk < 2; dk++)
487 x += coeff_i(i, di) * coeff_j(j, dj) * coeff_k(k, dk) * fld(i2+di, j2+dj, k2+dk);
488 tmp[j * new_ni_ + i] = (float)x;
489 }
490 Cerr << "Writing field, layer " << k << " / " << new_nk_ << endl;
491 binary_file.put(tmp.addr(), tmp.size_array(), 1);
492 }
493}
494
496{
497 // Velocity
498 if (!direct_write_)
499 {
500 allocate_velocity(new_velocity_, new_mesh_, 0);
501 new_velocity_[0].data() = 0 ;
502 new_velocity_[1].data() = 0 ;
503 new_velocity_[2].data() = 0 ;
504 }
505 allocate_velocity(old_velocity_, old_mesh_, 2);
506
507 // Fill with valid floating point data in walls and ghost cells:
508 old_velocity_[0].data() = 0 ;
509 old_velocity_[1].data() = 0 ;
510 old_velocity_[2].data() = 0 ;
511
513
514 sz_arr = old_velocity_[0].data().size_array();
515}
516
517void Switch_double::write_velocity(const Nom lata_name) const
518{
519 Cout << "Adding velocities to " << lata_name << finl;
520 if (!direct_write_)
521 dumplata_vector(lata_name,"VELOCITY", new_velocity_[0], new_velocity_[1], new_velocity_[2], 0);
522 else
523 {
524 // Ecrit a la main les lignes dans le fichier lata maitre:
526 {
527 SFichier f;
528 f.ouvrir(lata_name, ios::app);
529 // Attention, peut ne pas tenir dans un int:
530 long long n;
531 char sz_string[100];
532 n = ((long long) new_mesh_.get_nb_elem_tot(DIRECTION_I)+1)
533 * ((long long) new_mesh_.get_nb_elem_tot(DIRECTION_J)+1)
534 * ((long long) new_mesh_.get_nb_elem_tot(DIRECTION_K)+1);
535 snprintf(sz_string, 100, "%lld", n); // Apparemment %lld est la bonne syntaxe pour les long long
536 f << "Champ VELOCITY " << (lata_name + Nom(".VELOCITY.data")) << " geometrie=" << new_mesh_.le_nom() << " size=" << sz_string
537 << " localisation=FACES composantes=3 nature=vector" << finl;
538 }
539 }
540}
541
542
544{
545 Cerr << "IJK_problem_double::run()" << finl;
546
547 // Field allocation:
548 double sz_arr;
549
550 allocate_fields(sz_arr);
551
552 // Intitialize other fields (velocity, interfaces, rho):
553 initialise();
554
555 // ghost cells not needed for new as we never do interpolation on it (or gradient or whatever...)
556 old_mesh_.get_local_mesh_delta(DIRECTION_I, 1 /* ghost cells */, old_x_);
557 new_mesh_.get_local_mesh_delta(DIRECTION_I, 0 /* ghost cells not needed for new */, new_x_);
558
559 old_mesh_.get_local_mesh_delta(DIRECTION_J, 1 /* ghost cells */, old_y_);
560 new_mesh_.get_local_mesh_delta(DIRECTION_J, 0 /* ghost cells */, new_y_);
561
562 old_mesh_.get_local_mesh_delta(DIRECTION_K, 1 /* ghost cells */, old_z_);
563 new_mesh_.get_local_mesh_delta(DIRECTION_K, 0 /* ghost cells */, new_z_);
564
565 DoubleTab coeff_i(new_ni_,2);
566 DoubleTab coeff_j(new_nj_,2);
567 DoubleTab coeff_k(new_nk_,2);
568
569 IntTab Indice_i(new_ni_);
570 IntTab Indice_j(new_nj_);
571 IntTab Indice_k(new_nk_);
572
573 coeff_i =0;
574 coeff_j =0;
575 coeff_k =0;
576 Indice_i=0;
577 Indice_j=0;
578 Indice_k=0;
579
580 // We have to fill a single layer of ghost to get a better interpolation at procs boundaries (I'm not sure?)
581 old_velocity_[0].echange_espace_virtuel(1 /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_I*/);
582 old_velocity_[1].echange_espace_virtuel(1 /*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_J*/);
583 old_velocity_[2].echange_espace_virtuel(1/*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_K*/);
584 // useless??
585 // old_rho_.echange_espace_virtuel(1/*, IJK_Field_double::EXCHANGE_GET_AT_RIGHT_K*/);
586
587 Nom lata_name = nom_sauvegarde_ + Nom(".lata");
588 prepare_thermals(lata_name);
589
590 // force les conditions de bords
591 // remplir_gost(); -> I don't understand the use of this method
592 if (!perio_k_)
593 {
594 Cout << "Forcing zero velocities at walls on the old velocity field" << finl;
595 force_zero_on_walls(old_velocity_[DIRECTION_K]);
596 }
597
598 // Sortie des donnees (sauv + header du lata + interfaces dans le lata)
600 ecrire_header_lata(lata_name);
601
602 // Interpolate fields:
603 if (!direct_write_)
604 {
605 Cout << "direct_write est nul ";
606 // Compute and write velocity:
607 for (int dir = 0 ; dir < 3 ; dir ++)
608 {
610 calculer_coeff(coeff_i,Indice_i,
611 coeff_j,Indice_j,
612 coeff_k,Indice_k);
613 switch_vit(coeff_i,Indice_i,
614 coeff_j,Indice_j,
615 coeff_k,Indice_k,
616 dir);
617 // Il faut mener les actions pour ajouter les modes ou que sais-ja a process_b et pour remplir correctement forcage
618 }
619
620 if (!perio_k_)
621 {
622 Cout << "Forcing zero velocities at walls on the new velocity field" << finl;
623 force_zero_on_walls(new_velocity_[DIRECTION_K]);
624 }
625 write_velocity(lata_name);
626
627 // Compute and write IJK_Thermals if needed:
628 compute_and_write_extra_fields(lata_name, coeff_i,Indice_i,
629 coeff_j,Indice_j,
630 coeff_k,Indice_k);
631 }
632 else
633 {
634 SFichier file;
635 file.set_bin(1);
637
638 // Direct writing of velocity:
639 file.ouvrir(nom_sauvegarde_ + Nom(".lata.VELOCITY.data"));
640 switch_vit_direct(file);
641 file.close();
642
643 // Direct writing of extra fields:
644 compute_and_write_extra_fields_direct(file, coeff_i,Indice_i,
645 coeff_j,Indice_j,
646 coeff_k,Indice_k);
647 }
648}
649
650
This class encapsulates all the information related to the eulerian mesh for TrioIJK.
Definition Domaine_IJK.h:47
Localisation
Localisation sub class.
Definition Domaine_IJK.h:53
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
static Objet_U & objet_global(const Nom &nom)
cherche l'objet demande dans l'Interprete_bloc courant (Interprete_bloc::interprete_courant()) et dan...
Classe de base des objets "interprete".
Definition Interprete.h:38
Cette classe implemente les operateurs et les methodes virtuelles de la classe EFichier de la facon s...
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
friend class Entree
Definition Objet_U.h:76
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
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
void ajouter(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
Definition Param.cpp:364
@ REQUIRED
Definition Param.h:115
void ajouter_non_std(const char *keyword, const Objet_U *value, Param::Nature nat=Param::OPTIONAL)
Register a keyword handled by Objet_U::lire_motcle_non_standard.
Definition Param.cpp:489
int lire_avec_accolades(Entree &is)
Alias of lire_avec_accolades_depuis.
Definition Param.h:577
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
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
virtual int ouvrir(const char *name, IOS_OPEN_MODE mode=ios::out)
Classe de base des flux de sortie.
Definition Sortie.h:52
virtual int put(const unsigned *ob, std::streamsize n, std::streamsize nb_colonnes=1)
Definition Sortie.cpp:101
void set_bin(bool bin) override
Change le mode d'ecriture du fichier.
Definition Sortie.cpp:255
virtual void ecrire_fichier_reprise(const char *fichier_sauvegarde, const bool and_lata=true)=0
int lire_motcle_non_standard(const Motcle &mot, Entree &is) override
Lecture des parametres de type non simple d'un objet_U a partir d'un flot d'entree.
void calculer_coeff(DoubleTab &coeff_i, IntTab &Indice_i, DoubleTab &coeff_j, IntTab &Indice_j, DoubleTab &coeff_k, IntTab &Indice_k)
virtual void set_param_reprise(Param &param)
virtual void compute_and_write_extra_fields(const Nom &lata_name, DoubleTab &coeff_i, IntTab Indice_i, DoubleTab &coeff_j, IntTab Indice_j, DoubleTab &coeff_k, IntTab Indice_k)=0
void switch_vit_direct(SFichier &binary_file)
double current_time_
Definition IJK_switch.h:129
void switch_vit(DoubleTab coeff_i, IntTab Indice_i, DoubleTab coeff_j, IntTab Indice_j, DoubleTab coeff_k, IntTab Indice_k, const int dir)
virtual void ecrire_header_lata(const Nom lata_name)
Domaine_IJK old_mesh_
Definition IJK_switch.h:95
void calculer_coords_Vi(const int dir)
ArrOfDouble_with_ghost new_x_
Definition IJK_switch.h:113
virtual void initialise()
double terme_source_acceleration_
Definition IJK_switch.h:130
ArrOfDouble_with_ghost old_z_
Definition IJK_switch.h:116
virtual void lire_fichier_reprise(const char *fichier_reprise)
IJK_Field_vector3_double new_velocity_
Definition IJK_switch.h:104
virtual void prepare_run()
double terme_source_acceleration_z_
Definition IJK_switch.h:131
int timestep_reprise_vitesse_
Definition IJK_switch.h:157
ArrOfDouble_with_ghost old_x_
Definition IJK_switch.h:112
Nom fichier_old_vitesse_
Definition IJK_switch.h:154
IJK_Field_vector3_double old_velocity_
Definition IJK_switch.h:105
void calculer_coords_elem()
virtual void init_thermals()
Definition IJK_switch.h:65
Entree & interpreter(Entree &) override
void switch_scalar_field_direct(SFichier &binary_file, const IJK_Field_double &fld, DoubleTab coeff_i, IntTab Indice_i, DoubleTab coeff_j, IntTab Indice_j, DoubleTab coeff_k, IntTab Indice_k)
virtual void set_param(Param &param) const override
virtual void compute_and_write_extra_fields_direct(SFichier &file, DoubleTab &coeff_i, IntTab Indice_i, DoubleTab &coeff_j, IntTab Indice_j, DoubleTab &coeff_k, IntTab Indice_k)=0
virtual void allocate_fields(double &sz_arr)
void write_velocity(const Nom lata_name) const
ArrOfDouble_with_ghost old_y_
Definition IJK_switch.h:114
void switch_scalar_field(const IJK_Field_double &oldf, IJK_Field_double &newf, DoubleTab coeff_i, IntTab Indice_i, DoubleTab coeff_j, IntTab Indice_j, DoubleTab coeff_k, IntTab Indice_k) const
ArrOfDouble_with_ghost new_z_
Definition IJK_switch.h:117
virtual void prepare_thermals(const Nom lata_name)
Definition IJK_switch.h:66
void calculer_coords(const Domaine_IJK::Localisation loc)
Domaine_IJK new_mesh_
Definition IJK_switch.h:94
ArrOfDouble_with_ghost new_y_
Definition IJK_switch.h:115
_SIZE_ size_array() const
_TYPE_ * addr()
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469