TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Cut_cell_FT_Disc.h
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#ifndef Cut_cell_FT_Disc_included
17#define Cut_cell_FT_Disc_included
18
19#include <Descripteur_FT.h>
20#include <Maillage_FT_Disc.h>
21#include <IJK_Field.h>
22#include <Domaine_IJK.h>
23#include <ConstIJK_ptr.h>
24#include <TRUSTTabFT_cut_cell.h>
25#include <IJK_Field_simd_tools.h>
26#include <IJK_Navier_Stokes_tools.h>
27
30class IJK_Interfaces;
31
32/*! @brief : class Cut_cell_FT_Disc
33 *
34 * Cette classe decrit un maillage cut-cell, c'est-a-dire permettant
35 * des tableaux a valeurs dans les mailles diphasiques uniquement.
36 *
37 */
38
39class IJK_FT_cut_cell;
40class IJK_Interfaces;
41
43{
44public:
46
47 void add_to_persistent_data(DoubleTabFT_cut_cell& field, int dimension);
48 void add_to_transient_data(DoubleTabFT_cut_cell& field, int dimension);
49 void add_to_lazy_data(DoubleTabFT_cut_cell& field, int dimension);
50 void add_to_persistent_data(IntTabFT_cut_cell& field, int dimension);
51 void add_to_transient_data(IntTabFT_cut_cell& field, int dimension);
52 void add_to_lazy_data(IntTabFT_cut_cell& field, int dimension);
53
54 void initialise(IJK_Interfaces& interfaces, Domaine_IJK& splitting, Domaine_IJK::Localisation loc);
55 void initialise(IJK_Interfaces& interfaces, Domaine_IJK& splitting, Domaine_IJK::Localisation loc, const IJK_Field_double& old_indicatrice, const IJK_Field_double& next_indicatrice);
56
57 int initialise_independent_index(const IJK_Field_double& old_indicatrice, const IJK_Field_double& next_indicatrice);
60
61 void set_coord();
62
63 void update(const IJK_Field_double& old_indicatrice, const IJK_Field_double& next_indicatrice);
64
65 int add_and_remove_local_elements(const IJK_Field_double& old_indicatrice, const IJK_Field_double& next_indicatrice);
66
67 void resize_data(int size);
69
74
76 void update_index_sorted_by_indicatrice(const IJK_Field_double& old_indicatrice, const IJK_Field_double& next_indicatrice);
77 void update_index_sorted_by_statut_diphasique(const IJK_Field_double& old_indicatrice, const IJK_Field_double& next_indicatrice);
78
79 template<typename T>
80 void fill_buffer_with_variable(const TRUSTTabFT<T>& array, int component = 0) const; // Attention : fonction const, mais modifie write_buffer_
81
82 template<typename T>
83 void fill_variable_with_buffer(TRUSTTabFT<T>& array, int component = 0) const;
84
86 void remove_dead_and_virtual_cells(const IJK_Field_double& next_indicatrice);
87
90
93
95 {
96 REGULIER = 0, // Les deux phases sont regulieres (hors des cas diphasiques suivants)
97 MOURRANT = 1, // Une des deux phases est mourrante, l'autre occupera toute la cellule au temps suivant
98 MONOPHASIQUE = 2, // La cellule est purement monophasique. Une des deux phases n'existe pas sur la cellule.
99 NAISSANT = 3, // Une des deux phases est naissante, l'autre occupe initialement toute la cellule
100 DESEQUILIBRE_FINAL = 4, // Une des deux phases forme une cellule petite au temps suivant, sans indication sur l'etat initial
101 DESEQUILIBRE_INITIAL = 5, // Une des deux phases forme une cellule petite au temps initial uniquement
103 };
104
105 const IntTabFT_cut_cell& get_independent_index() const { return independent_index_; }
106 int get_independent_index(int n) const { return independent_index_(n); }
107 int get_ghost_size() const { return ghost_size_; }
108 int get_n_loc() const { return n_loc_; }
109 int get_n_tot() const { return n_tot_; }
110 const IJK_Interfaces& get_interfaces() const;
111 const Domaine_IJK& get_domaine() const;
113
114 IJK_Field_double& get_write_buffer() const { return write_buffer_; }
115
116 inline Int3 ijk_per_of_index(int i, int j, int k, int index) const;
117 inline int next_index_ijk_per(int i, int j, int k, int index, int negative_ghost_size, int positive_ghost_size) const;
118 inline Int3 get_ijk(int n) const;
119 inline int get_n(int i, int j, int k) const;
120 inline int get_n_face(int num_face, int n, int i, int j, int k) const;
121
122 double indic_pure(const int i, const int j, const int k) const;
123
124 inline bool within_ghost(int n, int negative_ghost_size, int positive_ghost_size) const;
125
126 template <int _DIR_>
127 inline bool within_ghost_(int n, int negative_ghost_size, int positive_ghost_size) const;
128
129 inline int get_k_value_index(int k) const;
130 inline int get_n_from_k_index(int index) const;
131 inline int get_n_from_indicatrice_index(int index) const;
132 inline int get_statut_diphasique_value_index(int statut_diphasique) const;
133 inline int get_n_from_statut_diphasique_index(int index) const;
134
135protected:
136 template<typename T>
137 static int find_value_unsorted(T value, const TRUSTTabFT<T>& array, int imin, int imax);
138
139 static bool verifier_toujours_meme_signe_et_non_nul(const IntTabFT_cut_cell& array);
140 static bool verifier_tableau_jamais_nul(const DoubleTabFT_cut_cell& array);
141 static bool verifier_valide_permutation(const IntTabFT_cut_cell& array);
142 static bool verifier_pas_de_doublons(const IntTabFT_cut_cell& array);
143
144 template<typename T>
145 static void apply_permutation(TRUSTTabFT<T>& array, const IntTabFT_cut_cell& permutation_indices, IntTabFT_cut_cell& processed);
146
147 static bool verifier_si_ordonne(const IntTabFT_cut_cell& array, int imin, int imax);
148
151
152 // Champ IJK_Field utilise pour le post-traitement des champs cut-cell
153 mutable IJK_Field_double write_buffer_;
154
155 // Champ IJK_Field de l'indice dans la structure diphasique
156 // Ce tableau semble pertinent pour acceder aux cellules diphasiques voisines.
157 IJK_Field_int indice_diphasique_;
158
161
162 OBS_PTR(IJK_Interfaces) ref_interfaces_;
163 OBS_PTR(Domaine_IJK) ref_domaine_;
166
167 // Compteur du nombre de mise a jour des champs diphasiques
169
170 // Les champs diphasiques sont stockes dans l'ordre :
171 // 0 < i < n_loc_ elements locaux
172 // n_loc_ < i < n_tot_ elements virtuels
175
176 // Tableaux pour permettre le parcours des cellules diphasiques pour une
177 // hauteur k donnee (au sein du calcul des flux)
178 IntTabFT_cut_cell_vector2 index_sorted_by_k_;
180
181 // Tableaux pour permettre le parcours des cellules diphasiques dans le
182 // sens d'une indicatrice croissante
183 DoubleTabFT_cut_cell_vector3 index_sorted_by_indicatrice_;
184
185 // Tableaux pour permettre le parcours des cellules diphasiques selon le
186 // statut_diphasique (pour les cellules naissantes ou mourrantes)
187 IntTabFT_cut_cell_vector3 index_sorted_by_statut_diphasique_;
189
190 // independent_index_ est l'indice lineaire IJK de la cellule diphasique.
191 // Pour les elements locaus, les indices sont determines directement
192 // et les cellules sont ordonnees dans le sens des indices croissants.
193 // Pour les elements virtuels, les indices sont recalcules a partir
194 // du vecteur des coordonnees sans ordre particulier.
195 IntTabFT_cut_cell_scalar independent_index_;
196
197 // permutation_ est un tableau d'indices utilise pour le reordonnement des
198 // cellules diphasiques dans le sens des indices lineaires croissants.
199 IntTabFT_cut_cell_scalar permutation_;
200
201 // processed_ indique pour chaque cellule l'iteration de l'ajout.
202 // Egal a processed_count_ pour les elements nouvellement diphasiques.
203 // Le signe de processed est modifie lors de la permutation des champs.
204 // Il peut etre positif ou negatif mais tous les elements de processed_
205 // doivent etre de meme signe
206 IntTabFT_cut_cell_scalar processed_;
207
208 // coord_ est utilise pour donner l'emplacement absolue des cellules lors
209 // des communications entre processeurs.
210 DoubleTabFT_cut_cell_vector3 coord_;
211
212 // Tableau des champs diphasiques (persistant, avec reordonnement a chaque pas de temps)
213 LIST(OBS_PTR(DoubleTabFT_cut_cell)) persistent_double_data_;
214 LIST(OBS_PTR(IntTabFT_cut_cell)) persistent_int_data_;
215
216 // Tableau des champs diphasiques (ephemeres, avec reinitilisation a chaque pas de temps)
217 LIST(OBS_PTR(DoubleTabFT_cut_cell)) transient_double_data_;
218 LIST(OBS_PTR(IntTabFT_cut_cell)) transient_int_data_;
219
220 // Tableau des champs diphasiques (paresseux, sans modifications entre chaque pas de temps)
221 LIST(OBS_PTR(DoubleTabFT_cut_cell)) lazy_double_data_;
222 LIST(OBS_PTR(IntTabFT_cut_cell)) lazy_int_data_;
223};
224
225inline void Cut_cell_FT_Disc::add_to_persistent_data(DoubleTabFT_cut_cell& field, int dimension)
226{
227 field.resize(n_tot_, dimension);
228 persistent_double_data_.add(field);
229}
230
231inline void Cut_cell_FT_Disc::add_to_transient_data(DoubleTabFT_cut_cell& field, int dimension)
232{
233 field.resize(n_tot_, dimension);
234 transient_double_data_.add(field);
235}
236
237inline void Cut_cell_FT_Disc::add_to_lazy_data(DoubleTabFT_cut_cell& field, int dimension)
238{
239 field.resize(n_tot_, dimension);
240 lazy_double_data_.add(field);
241}
242
243inline void Cut_cell_FT_Disc::add_to_persistent_data(IntTabFT_cut_cell& field, int dimension)
244{
245 field.resize(n_tot_, dimension);
246 persistent_int_data_.add(field);
247}
248
249inline void Cut_cell_FT_Disc::add_to_transient_data(IntTabFT_cut_cell& field, int dimension)
250{
251 field.resize(n_tot_, dimension);
252 transient_int_data_.add(field);
253}
254
255inline void Cut_cell_FT_Disc::add_to_lazy_data(IntTabFT_cut_cell& field, int dimension)
256{
257 field.resize(n_tot_, dimension);
258 lazy_int_data_.add(field);
259}
260
261inline Int3 Cut_cell_FT_Disc::ijk_per_of_index(int i, int j, int k, int index) const
262{
263 assert(index >= 0);
264 assert(index <= 26);
265 if (index == 0)
266 {
267 return {i, j, k};
268 }
269 else
270 {
271 int per_z = index/9;
272 int per_y = (index%9)/3;
273 int per_x = (index%9)%3;
274
275 assert((per_x == 0) || ref_domaine_->get_periodic_flag(0));
276 assert((per_y == 0) || ref_domaine_->get_periodic_flag(1));
277 assert((per_z == 0) || ref_domaine_->get_periodic_flag(2));
278
279 int n_dir_x = ref_domaine_->get_nb_elem_local(0);
280 int n_dir_y = ref_domaine_->get_nb_elem_local(1);
281 int n_dir_z = ref_domaine_->get_nb_elem_local(2);
282 assert((per_x == 0) || (n_dir_x == ref_domaine_->get_nb_elem_tot(0)));
283 assert((per_y == 0) || (n_dir_y == ref_domaine_->get_nb_elem_tot(1)));
284 assert((per_z == 0) || (n_dir_z == ref_domaine_->get_nb_elem_tot(2)));
285
286 assert((per_x == 0) || ((i < ghost_size_) || (i >= n_dir_x - ghost_size_)));
287 assert((per_y == 0) || ((j < ghost_size_) || (j >= n_dir_y - ghost_size_)));
288 assert((per_z == 0) || ((k < ghost_size_) || (k >= n_dir_z - ghost_size_)));
289 int i_per = (per_x == 0)*i + (per_x == 1)*(n_dir_x + i) + (per_x == 2)*(i - n_dir_x);
290 int j_per = (per_y == 0)*j + (per_y == 1)*(n_dir_y + j) + (per_y == 2)*(j - n_dir_y);
291 int k_per = (per_z == 0)*k + (per_z == 1)*(n_dir_z + k) + (per_z == 2)*(k - n_dir_z);
292 return {i_per, j_per, k_per};
293
294 }
295}
296
297inline int Cut_cell_FT_Disc::next_index_ijk_per(int i, int j, int k, int index, int negative_ghost_size, int positive_ghost_size) const
298{
299 // per =
300 // 0: no change in the given direction
301 // 1: periodic towards the negative values in the given direction
302 // 2: periodic towards the positive values in the given direction
303 //
304 // index = per_z * 9 + per_y * 3 + per_x
305 //
306 if (index == 26)
307 {
308 return -1;
309 }
310 else
311 {
312 int max_dir = 3;
313 int min_dir = ((index >= 16) ? 2 : ((index >= 10) ? 1 : 0));
314 assert(index >= 0);
315 assert(min_dir >= 0 && min_dir <=2);
316 for (int dir_1 = min_dir; dir_1 < max_dir ; dir_1++)
317 {
318 if (ref_domaine_->get_periodic_flag(dir_1))
319 {
320 int n_dir_1 = ref_domaine_->get_nb_elem_local(dir_1);
321 int n_dir_tot_1 = ref_domaine_->get_nb_elem_tot(dir_1);
322
323 if (n_dir_1 == n_dir_tot_1)
324 {
325 int i_dir_1 = select_dir(dir_1, i, j, k);
326
327 if (i_dir_1 < positive_ghost_size)
328 {
329 int per_x = (dir_1 == 0)*1;
330 int per_y = (dir_1 == 1)*1;
331 int per_z = (dir_1 == 2)*1;
332
333 int next_index = per_x + per_y*3 + per_z*9;
334 if (next_index > index)
335 {
336 return next_index;
337 }
338
339 int per_x_debut_boucle_2 = per_x;
340 int per_y_debut_boucle_2 = per_y;
341 int per_z_debut_boucle_2 = per_z;
342 for (int dir_2 = 0; dir_2 < dir_1 ; dir_2++)
343 {
344 if (ref_domaine_->get_periodic_flag(dir_2))
345 {
346 int n_dir_2 = ref_domaine_->get_nb_elem_local(dir_2);
347 int n_dir_tot_2 = ref_domaine_->get_nb_elem_tot(dir_2);
348
349 if (n_dir_2 == n_dir_tot_2)
350 {
351 int i_dir_2 = select_dir(dir_2, i, j, k);
352
353 if (i_dir_2 < positive_ghost_size)
354 {
355 per_x = per_x_debut_boucle_2 + (dir_2 == 0)*1;
356 per_y = per_y_debut_boucle_2 + (dir_2 == 1)*1;
357 per_z = per_z_debut_boucle_2 + (dir_2 == 2)*1;
358
359 next_index = per_x + per_y*3 + per_z*9;
360 if (next_index > index)
361 {
362 return next_index;
363 }
364
365 int per_x_debut_boucle_3 = per_x;
366 int per_y_debut_boucle_3 = per_y;
367 int per_z_debut_boucle_3 = per_z;
368 for (int dir_3 = 0; dir_3 < dir_2 ; dir_3++)
369 {
370 if (ref_domaine_->get_periodic_flag(dir_3))
371 {
372 int n_dir_3 = ref_domaine_->get_nb_elem_local(dir_3);
373 int n_dir_tot_3 = ref_domaine_->get_nb_elem_tot(dir_3);
374
375 if (n_dir_3 == n_dir_tot_3)
376 {
377 int i_dir_3 = select_dir(dir_3, i, j, k);
378
379 if (i_dir_3 < positive_ghost_size)
380 {
381 per_x = per_x_debut_boucle_3 + (dir_3 == 0)*1;
382 per_y = per_y_debut_boucle_3 + (dir_3 == 1)*1;
383 per_z = per_z_debut_boucle_3 + (dir_3 == 2)*1;
384
385 next_index = per_x + per_y*3 + per_z*9;
386 if (next_index > index)
387 {
388 return next_index;
389 }
390 }
391 if (i_dir_3 >= n_dir_3 - negative_ghost_size)
392 {
393 per_x = per_x_debut_boucle_3 + (dir_3 == 0)*2;
394 per_y = per_y_debut_boucle_3 + (dir_3 == 1)*2;
395 per_z = per_z_debut_boucle_3 + (dir_3 == 2)*2;
396
397 next_index = per_x + per_y*3 + per_z*9;
398 if (next_index > index)
399 {
400 return next_index;
401 }
402 }
403 }
404 }
405 }
406 }
407 if (i_dir_2 >= n_dir_2 - negative_ghost_size)
408 {
409 per_x = per_x_debut_boucle_2 + (dir_2 == 0)*2;
410 per_y = per_y_debut_boucle_2 + (dir_2 == 1)*2;
411 per_z = per_z_debut_boucle_2 + (dir_2 == 2)*2;
412
413 next_index = per_x + per_y*3 + per_z*9;
414 if (next_index > index)
415 {
416 return next_index;
417 }
418
419 int per_x_debut_boucle_3 = per_x;
420 int per_y_debut_boucle_3 = per_y;
421 int per_z_debut_boucle_3 = per_z;
422 for (int dir_3 = 0; dir_3 < dir_2 ; dir_3++)
423 {
424 if (ref_domaine_->get_periodic_flag(dir_3))
425 {
426 int n_dir_3 = ref_domaine_->get_nb_elem_local(dir_3);
427 int n_dir_tot_3 = ref_domaine_->get_nb_elem_tot(dir_3);
428
429 if (n_dir_3 == n_dir_tot_3)
430 {
431 int i_dir_3 = select_dir(dir_3, i, j, k);
432
433 if (i_dir_3 < positive_ghost_size)
434 {
435 per_x = per_x_debut_boucle_3 + (dir_3 == 0)*1;
436 per_y = per_y_debut_boucle_3 + (dir_3 == 1)*1;
437 per_z = per_z_debut_boucle_3 + (dir_3 == 2)*1;
438
439 next_index = per_x + per_y*3 + per_z*9;
440 if (next_index > index)
441 {
442 return next_index;
443 }
444 }
445 if (i_dir_3 >= n_dir_3 - negative_ghost_size)
446 {
447 per_x = per_x_debut_boucle_3 + (dir_3 == 0)*2;
448 per_y = per_y_debut_boucle_3 + (dir_3 == 1)*2;
449 per_z = per_z_debut_boucle_3 + (dir_3 == 2)*2;
450
451 next_index = per_x + per_y*3 + per_z*9;
452 if (next_index > index)
453 {
454 return next_index;
455 }
456 }
457 }
458 }
459 }
460 }
461 }
462 }
463 }
464 }
465 if (i_dir_1 >= n_dir_1 - negative_ghost_size)
466 {
467 int per_x = (dir_1 == 0)*2;
468 int per_y = (dir_1 == 1)*2;
469 int per_z = (dir_1 == 2)*2;
470
471 int next_index = per_x + per_y*3 + per_z*9;
472 if (next_index > index)
473 {
474 return next_index;
475 }
476
477 int per_x_debut_boucle_2 = per_x;
478 int per_y_debut_boucle_2 = per_y;
479 int per_z_debut_boucle_2 = per_z;
480 for (int dir_2 = 0; dir_2 < dir_1 ; dir_2++)
481 {
482 if (ref_domaine_->get_periodic_flag(dir_2))
483 {
484 int n_dir_2 = ref_domaine_->get_nb_elem_local(dir_2);
485 int n_dir_tot_2 = ref_domaine_->get_nb_elem_tot(dir_2);
486
487 if (n_dir_2 == n_dir_tot_2)
488 {
489 int i_dir_2 = select_dir(dir_2, i, j, k);
490
491 if (i_dir_2 < positive_ghost_size)
492 {
493 per_x = per_x_debut_boucle_2 + (dir_2 == 0)*1;
494 per_y = per_y_debut_boucle_2 + (dir_2 == 1)*1;
495 per_z = per_z_debut_boucle_2 + (dir_2 == 2)*1;
496
497 next_index = per_x + per_y*3 + per_z*9;
498 if (next_index > index)
499 {
500 return next_index;
501 }
502
503 int per_x_debut_boucle_3 = per_x;
504 int per_y_debut_boucle_3 = per_y;
505 int per_z_debut_boucle_3 = per_z;
506 for (int dir_3 = 0; dir_3 < dir_2 ; dir_3++)
507 {
508 if (ref_domaine_->get_periodic_flag(dir_3))
509 {
510 int n_dir_3 = ref_domaine_->get_nb_elem_local(dir_3);
511 int n_dir_tot_3 = ref_domaine_->get_nb_elem_tot(dir_3);
512
513 if (n_dir_3 == n_dir_tot_3)
514 {
515 int i_dir_3 = select_dir(dir_3, i, j, k);
516
517 if (i_dir_3 < positive_ghost_size)
518 {
519 per_x = per_x_debut_boucle_3 + (dir_3 == 0)*1;
520 per_y = per_y_debut_boucle_3 + (dir_3 == 1)*1;
521 per_z = per_z_debut_boucle_3 + (dir_3 == 2)*1;
522
523 next_index = per_x + per_y*3 + per_z*9;
524 if (next_index > index)
525 {
526 return next_index;
527 }
528 }
529 if (i_dir_3 >= n_dir_3 - negative_ghost_size)
530 {
531 per_x = per_x_debut_boucle_3 + (dir_3 == 0)*2;
532 per_y = per_y_debut_boucle_3 + (dir_3 == 1)*2;
533 per_z = per_z_debut_boucle_3 + (dir_3 == 2)*2;
534
535 next_index = per_x + per_y*3 + per_z*9;
536 if (next_index > index)
537 {
538 return next_index;
539 }
540 }
541 }
542 }
543 }
544 }
545 if (i_dir_2 >= n_dir_2 - negative_ghost_size)
546 {
547 per_x = per_x_debut_boucle_2 + (dir_2 == 0)*2;
548 per_y = per_y_debut_boucle_2 + (dir_2 == 1)*2;
549 per_z = per_z_debut_boucle_2 + (dir_2 == 2)*2;
550
551 next_index = per_x + per_y*3 + per_z*9;
552 if (next_index > index)
553 {
554 return next_index;
555 }
556
557 int per_x_debut_boucle_3 = per_x;
558 int per_y_debut_boucle_3 = per_y;
559 int per_z_debut_boucle_3 = per_z;
560 for (int dir_3 = 0; dir_3 < dir_2 ; dir_3++)
561 {
562 if (ref_domaine_->get_periodic_flag(dir_3))
563 {
564 int n_dir_3 = ref_domaine_->get_nb_elem_local(dir_3);
565 int n_dir_tot_3 = ref_domaine_->get_nb_elem_tot(dir_3);
566
567 if (n_dir_3 == n_dir_tot_3)
568 {
569 int i_dir_3 = select_dir(dir_3, i, j, k);
570
571 if (i_dir_3 < positive_ghost_size)
572 {
573 per_x = per_x_debut_boucle_3 + (dir_3 == 0)*1;
574 per_y = per_y_debut_boucle_3 + (dir_3 == 1)*1;
575 per_z = per_z_debut_boucle_3 + (dir_3 == 2)*1;
576
577 next_index = per_x + per_y*3 + per_z*9;
578 if (next_index > index)
579 {
580 return next_index;
581 }
582 }
583 if (i_dir_3 >= n_dir_3 - negative_ghost_size)
584 {
585 per_x = per_x_debut_boucle_3 + (dir_3 == 0)*2;
586 per_y = per_y_debut_boucle_3 + (dir_3 == 1)*2;
587 per_z = per_z_debut_boucle_3 + (dir_3 == 2)*2;
588
589 next_index = per_x + per_y*3 + per_z*9;
590 if (next_index > index)
591 {
592 return next_index;
593 }
594 }
595 }
596 }
597 }
598 }
599 }
600 }
601 }
602 }
603 }
604 }
605 }
606 return -1;
607 }
608}
609
610inline Int3 Cut_cell_FT_Disc::get_ijk(int n) const
611{
612 int independent_index = independent_index_(n);
613 Int3 ijk = ref_domaine_->get_ijk_from_independent_index(independent_index);
614
615 return ijk;
616}
617
618inline int Cut_cell_FT_Disc::get_n(int i, int j, int k) const
619{
620 // Note: La condition sur n_tot_ est ajoute pour le cas ou indice_diphasique_ n'est pas encore alloue.
621 int indice_diphasique = n_tot_ == 0 ? -1 : indice_diphasique_(i,j,k);
622 return indice_diphasique;
623}
624
625inline int Cut_cell_FT_Disc::get_n_face(int num_face, int n, int i, int j, int k) const
626{
627 int decalage = num_face/3; // 0 pour 0,1,2 et 1 pour 3,4,5
628 if (!decalage)
629 {
630 return n;
631 }
632 else
633 {
634 int dir = num_face%3;
635 int di = decalage*(dir == 0);
636 int dj = decalage*(dir == 1);
637 int dk = decalage*(dir == 2);
638
639 int n_face = get_n(i+di,j+dj,k+dk);
640 return n_face;
641 }
642}
643
644inline bool Cut_cell_FT_Disc::within_ghost(int n, int negative_ghost_size, int positive_ghost_size) const
645{
646 Int3 ijk = get_ijk(n);
647
648 int i = ijk[0];
649 int j = ijk[1];
650 int k = ijk[2];
651
652 return ref_domaine_->within_ghost(i, j, k, negative_ghost_size, positive_ghost_size);
653}
654
655template <int _DIR_>
656inline bool Cut_cell_FT_Disc::within_ghost_(int n, int negative_ghost_size, int positive_ghost_size) const
657{
658 Int3 ijk = get_ijk(n);
659
660 int i = ijk[0];
661 int j = ijk[1];
662 int k = ijk[2];
663
664 return ref_domaine_->within_ghost_<_DIR_>(i, j, k, negative_ghost_size, positive_ghost_size);
665}
666
668{
669 assert(k <= ref_domaine_->get_nb_elem_local(2) + 2*ghost_size_);
670 return k_value_index_(k + ghost_size_);
671}
672
673inline int Cut_cell_FT_Disc::get_n_from_k_index(int index) const
674{
675 assert(index >= 0);
676 return index_sorted_by_k_(index,0);
677}
678
680{
681 assert(index >= 0);
682
683 union
684 {
685 double d;
686 long long int i;
687 } u;
688 u.d = index_sorted_by_indicatrice_(index,0);
689
690 // Retrieving the bits of the index, which were stored into a double variable.
691 return (int)(u.i);
692}
693
694inline int Cut_cell_FT_Disc::get_statut_diphasique_value_index(int statut_diphasique) const
695{
696 assert(statut_diphasique <= static_cast<int>(STATUT_DIPHASIQUE::count));
697 return statut_diphasique_value_index_(statut_diphasique);
698}
699
701{
702 assert(index >= 0);
704}
705
706#endif /* Cut_cell_FT_Disc_included */
const Domaine_IJK & get_domaine() const
bool within_ghost(int n, int negative_ghost_size, int positive_ghost_size) const
const IntTabFT_cut_cell & get_independent_index() const
void add_to_lazy_data(DoubleTabFT_cut_cell &field, int dimension)
const IJK_Interfaces & get_interfaces() const
int get_n_from_k_index(int index) const
void update_index_sorted_by_indicatrice(const IJK_Field_double &old_indicatrice, const IJK_Field_double &next_indicatrice)
int get_n_from_indicatrice_index(int index) const
static bool verifier_toujours_meme_signe_et_non_nul(const IntTabFT_cut_cell &array)
LIST(OBS_PTR(DoubleTabFT_cut_cell)) persistent_double_data_
Desc_Structure_FT desc_
int get_ghost_size() const
void compute_virtual_independent_index()
Int3 ijk_per_of_index(int i, int j, int k, int index) const
int next_index_ijk_per(int i, int j, int k, int index, int negative_ghost_size, int positive_ghost_size) const
LIST(OBS_PTR(IntTabFT_cut_cell)) transient_int_data_
int add_and_remove_local_elements(const IJK_Field_double &old_indicatrice, const IJK_Field_double &next_indicatrice)
Schema_Comm schema_comm_
bool verifier_coherence_coord_independent_index()
OBS_PTR(IJK_Interfaces) ref_interfaces_
const Desc_Structure_FT & get_desc_structure() const
IntTabFT_cut_cell_scalar permutation_
static bool verifier_pas_de_doublons(const IntTabFT_cut_cell &array)
Int3 get_ijk(int n) const
static int find_value_unsorted(T value, const TRUSTTabFT< T > &array, int imin, int imax)
IntTabFT_cut_cell_vector2 index_sorted_by_k_
LIST(OBS_PTR(IntTabFT_cut_cell)) persistent_int_data_
int get_k_value_index(int k) const
void add_to_transient_data(DoubleTabFT_cut_cell &field, int dimension)
bool within_ghost_(int n, int negative_ghost_size, int positive_ghost_size) const
void resize_data(int size)
void update_index_sorted_by_statut_diphasique(const IJK_Field_double &old_indicatrice, const IJK_Field_double &next_indicatrice)
static bool verifier_si_ordonne(const IntTabFT_cut_cell &array, int imin, int imax)
IJK_Field_int indice_diphasique_
IntTabFT_cut_cell_scalar independent_index_
int get_independent_index(int n) const
LIST(OBS_PTR(DoubleTabFT_cut_cell)) lazy_double_data_
int initialise_independent_index(const IJK_Field_double &old_indicatrice, const IJK_Field_double &next_indicatrice)
DoubleTabFT_cut_cell_vector3 index_sorted_by_indicatrice_
void fill_buffer_with_variable(const TRUSTTabFT< T > &array, int component=0) const
LIST(OBS_PTR(IntTabFT_cut_cell)) lazy_int_data_
void add_to_persistent_data(DoubleTabFT_cut_cell &field, int dimension)
void fill_variable_with_buffer(TRUSTTabFT< T > &array, int component=0) const
int get_n_face(int num_face, int n, int i, int j, int k) const
OBS_PTR(Domaine_IJK) ref_domaine_
void update(const IJK_Field_double &old_indicatrice, const IJK_Field_double &next_indicatrice)
IntTabFT_cut_cell_vector3 index_sorted_by_statut_diphasique_
double indic_pure(const int i, const int j, const int k) const
Domaine_IJK::Localisation localisation_
int get_n_from_statut_diphasique_index(int index) const
int get_statut_diphasique_value_index(int statut_diphasique) const
static bool verifier_tableau_jamais_nul(const DoubleTabFT_cut_cell &array)
int get_n(int i, int j, int k) const
static void apply_permutation(TRUSTTabFT< T > &array, const IntTabFT_cut_cell &permutation_indices, IntTabFT_cut_cell &processed)
IJK_Field_double & get_write_buffer() const
LIST(OBS_PTR(DoubleTabFT_cut_cell)) transient_double_data_
IJK_Field_double write_buffer_
DoubleTabFT_cut_cell_vector3 coord_
static bool verifier_valide_permutation(const IntTabFT_cut_cell &array)
IntTabFT_cut_cell_scalar processed_
void remove_dead_and_virtual_cells(const IJK_Field_double &next_indicatrice)
IntTabFT statut_diphasique_value_index_
void initialise(IJK_Interfaces &interfaces, Domaine_IJK &splitting, Domaine_IJK::Localisation loc)
: class Desc_Structure_FT
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 IJK_Interfaces
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Definition TRUSTTab.tpp:469