TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
IJK_Composantes_Connex.cpp
1/****************************************************************************
2* Copyright (c) 2023, 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_Composantes_Connex.h>
17#include <Probleme_FTD_IJK.h>
18#include <IJK_Interfaces.h>
19#include <IJK_Bubble_tools.h>
20
21Implemente_instanciable( IJK_Composantes_Connex, "IJK_Composantes_Connex", Objet_U ) ;
22
23static int decoder_numero_bulle(const int code)
24{
25 const int num_bulle = code >> 6;
26 return num_bulle;
27}
28
30{
31 Objet_U::printOn( os );
32 return os;
33}
34
36{
37 Objet_U::readOn( is );
38 return is;
39}
40
42 const bool is_switch)
43{
44 is_switch_ = is_switch;
45 if (!is_switch)
46 interfaces_ = &interfaces;
47}
48
50 const int& allocate_compo_fields)
51{
52 compute_compo_fields_ = allocate_compo_fields;
53 if (!is_switch_ && allocate_compo_fields)
54 {
56 {
57 eulerian_compo_connex_ft_.allocate(ref_ijk_ft_->get_domaine_ft(), Domaine_IJK::ELEM, 2);
58 eulerian_compo_connex_ft_.data() = -1.;
59 eulerian_compo_connex_ft_.echange_espace_virtuel(eulerian_compo_connex_ft_.ghost());
60
61 eulerian_compo_connex_ghost_ft_.allocate(ref_ijk_ft_->get_domaine_ft(), Domaine_IJK::ELEM, 2);
64
65 eulerian_compo_connex_ns_.allocate(splitting, Domaine_IJK::ELEM, 0);
66 eulerian_compo_connex_ns_.echange_espace_virtuel(eulerian_compo_connex_ns_.ghost());
67
70 }
71 eulerian_compo_connex_from_interface_ft_.allocate(ref_ijk_ft_->get_domaine_ft(), Domaine_IJK::ELEM, 0);
73
76
77 eulerian_compo_connex_from_interface_ghost_ft_.allocate(ref_ijk_ft_->get_domaine_ft(), Domaine_IJK::ELEM, 0);
79
82
86
90
94 }
95}
96
98{
99 ref_ijk_ft_ = ijk_ft;
100}
101
106
108 const int& compute_rising_velocities,
109 const int& fill_rising_velocities,
110 const int& use_bubbles_velocities_from_interface,
111 const int& use_bubbles_velocities_from_barycentres)
112{
114 {
116 fill_rising_velocities_ = fill_rising_velocities;
117 use_bubbles_velocities_from_interface_ = use_bubbles_velocities_from_interface;
118 use_bubbles_velocities_from_barycentres_ = use_bubbles_velocities_from_barycentres;
122 {
123 eulerian_rising_velocities_.allocate(splitting, Domaine_IJK::ELEM, 0);
125 eulerian_rising_velocities_.echange_espace_virtuel(eulerian_rising_velocities_.ghost());
126 }
127 }
128}
129
131{
132 statistics().create_custom_counter("Compo Connex - Bounding Box",3,"FrontTracking");
133 statistics().begin_count("Compo Connex - Bounding Box",statistics().get_last_opened_counter_level()+1);
134
136 {
138 interfaces_->calculer_bounding_box_bulles(bounding_box_);
139 else
140 {
141 compute_bounding_box_fill_compo(*interfaces_,
147 eulerian_compo_connex_ft_.echange_espace_virtuel(eulerian_compo_connex_ft_.ghost());
149
150 eulerian_compo_connex_ns_.data() = -1;
151 eulerian_compo_connex_ns_.echange_espace_virtuel(eulerian_compo_connex_ns_.ghost());
152 ref_ijk_ft_->eq_ns().redistribute_from_splitting_ft_elem(eulerian_compo_connex_ft_, eulerian_compo_connex_ns_);
153 eulerian_compo_connex_ns_.echange_espace_virtuel(eulerian_compo_connex_ns_.ghost());
154
157 ref_ijk_ft_->eq_ns().redistribute_from_splitting_ft_elem(eulerian_compo_connex_ghost_ft_, eulerian_compo_connex_ghost_ns_);
159 }
160 }
161
162 statistics().end_count("Compo Connex - Bounding Box");
163}
164
166{
167 statistics().create_custom_counter("Compo Connex - From interface",3,"FrontTracking");
168 statistics().begin_count("Compo Connex - From interface",statistics().get_last_opened_counter_level()+1);
169
170
172 {
173 // interfaces_->calculer_volume_bulles(bubbles_volume_, bubbles_barycentre_);
174 interfaces_->compute_bubbles_volume_and_barycentres(bubbles_volume_, bubbles_barycentre_, 1);
175
177
178 const Domaine_IJK& splitting = eulerian_compo_connex_from_interface_int_ns_.get_domaine();
179
183 ArrOfInt elems_valid;
184 for (int k=0; k < nz ; k++)
185 for (int j=0; j< ny; j++)
186 for (int i=0; i < nx; i++)
188 elems_valid.append_array(splitting.convert_ijk_cell_to_packed(i,j,k));
189
190
191 int elems_valid_size = elems_valid.size_array();
192 while (elems_valid_size > 0)
193 {
194 ArrOfInt elems_valid_copy = elems_valid;
195 elems_valid.reset();
196 for (int elem=0; elem<elems_valid_copy.size_array(); elem++)
197 {
198 const Int3 num_elem_ijk = splitting.convert_packed_to_ijk_cell(elems_valid_copy[elem]);
199 const int i = num_elem_ijk[DIRECTION_I];
200 const int j = num_elem_ijk[DIRECTION_J];
201 const int k = num_elem_ijk[DIRECTION_K];
202 const int num_compo = eulerian_compo_connex_from_interface_int_ns_(i,j,k);
203 const int num_compo_ghost = eulerian_compo_connex_from_interface_ghost_int_ns_(i,j,k);
204 for (int l = 0; l < 6; l++)
205 {
206 const int ii = NEIGHBOURS_I[l];
207 const int jj = NEIGHBOURS_J[l];
208 const int kk = NEIGHBOURS_K[l];
209 if((i + ii < 0 || j + jj < 0 || k + kk < 0) || (i + ii >= nx || j + jj >= ny || k + kk >= nz))
210 break;
211 const int num = eulerian_compo_connex_from_interface_int_ns_(i + ii,j + jj,k + kk);
212 const double indic_neighbour = interfaces_->In()(i + ii,j + jj,k + kk);
213 if (num == -1 && indic_neighbour < VAPOUR_INDICATOR_TEST)
214 {
215 const int num_elem = splitting.convert_ijk_cell_to_packed(i + ii,j + jj,k + kk);
216 elems_valid.append_array(num_elem);
217 eulerian_compo_connex_from_interface_int_ns_(i + ii,j + jj,k + kk) = num_compo;
218 eulerian_compo_connex_from_interface_ghost_int_ns_(i + ii,j + jj,k + kk) = num_compo_ghost;
219 }
220 }
221 }
222 elems_valid_size = elems_valid.size_array();
223 }
226 }
227
228 statistics().end_count("Compo Connex - From interface");
229}
230
232{
233 statistics().create_custom_counter("Fill Compo connex",3,"FrontTracking");
234 statistics().begin_count("Fill Compo connex",statistics().get_last_opened_counter_level()+1);
235
236 const Domaine_dis_base& mon_dom_dis = interfaces_->get_domaine_dis();
237 const int nb_elem = mon_dom_dis.domaine().nb_elem();
238 const Maillage_FT_IJK& maillage = interfaces_->maillage_ft_ijk();
239
240 // Same splitting for the normal vector field
241 const Domaine_IJK& splitting_ft = ref_ijk_ft_->get_domaine_ft();
242
243 const Intersections_Elem_Facettes& intersections = maillage.intersections_elem_facettes();
244 const ArrOfInt& index_elem = intersections.index_elem();
249 // Loop on the elements
250 const ArrOfInt& compo_facettes = maillage.compo_connexe_facettes();
251 ArrOfInt compo_per_cell;
252 ArrOfInt compo_ghost_per_cell;
253 ArrOfInt count_compo_per_cell;
254 ArrOfInt count_compo_ghost_per_cell;
255 int counter, counter_ghost;
256 FixedVector<IJK_Field_double *,2> compo_connex_non_ghost_ghost;
257 compo_connex_non_ghost_ghost[0] = &eulerian_compo_connex_from_interface_ft_;
258 compo_connex_non_ghost_ghost[1] = &eulerian_compo_connex_from_interface_ghost_ft_;
259 const int nbulles_reelles = interfaces_->get_nb_bulles_reelles();
260 int l;
261 for (int elem = 0; elem < nb_elem; elem++)
262 {
263 int index = index_elem[elem];
264 compo_per_cell.reset();
265 compo_ghost_per_cell.reset();
266 count_compo_per_cell.reset();
267 count_compo_ghost_per_cell.reset();
268 // Loop on the facets which cross the element
269 while (index >= 0)
270 {
271 const Intersections_Elem_Facettes_Data& data = intersections.data_intersection(index);
272 const int num_facette = data.numero_facette_;
273 // const int n = mesh.nb_facettes();
274 const int compo_facet = compo_facettes[num_facette];
275 const int compo_size_array = compo_per_cell.size_array();
276 const int compo_ghost_size_array = compo_ghost_per_cell.size_array();
277 int compo_real;
278 int compo_ghost;
279 if (compo_facet < 0)
280 {
281 compo_real = decoder_numero_bulle(-compo_facet);
282 compo_ghost = compo_real + nbulles_reelles;
283 }
284 else
285 {
286 compo_real = compo_facet;
287 compo_ghost = compo_facet;
288 }
289 counter = 0;
290 counter_ghost = 0;
291 for (l=0; l<compo_size_array; l++)
292 {
293 if (compo_real == compo_per_cell(l))
294 {
295 count_compo_per_cell(l) += 1;
296 break;
297 }
298 counter++;
299 }
300 for (l=0; l<compo_ghost_size_array; l++)
301 {
302 if (compo_ghost == compo_ghost_per_cell(l))
303 {
304 count_compo_ghost_per_cell(l) += 1;
305 break;
306 }
307 counter_ghost++;
308 }
309 if (counter == compo_size_array)
310 {
311
312 compo_per_cell.append_array(compo_real);
313 count_compo_per_cell.append_array(1);
314 }
315 if (counter_ghost == compo_ghost_size_array)
316 {
317
318 compo_ghost_per_cell.append_array(compo_ghost);
319 count_compo_ghost_per_cell.append_array(1);
320 }
321 index = data.index_facette_suivante_;
322 }
323 const int n = compo_per_cell.size_array();
324 const int n_ghost = compo_ghost_per_cell.size_array();
325 if (n > 0)
326 {
327 std::vector<int> indices(n);
328 for (int j=0; j<n; j++)
329 indices[j]=j;
330 std::sort(indices.begin(), indices.end(), [&count_compo_per_cell](int i, int j) {return count_compo_per_cell[i] < count_compo_per_cell[j];});
331 const int max_compo_per_cell = compo_per_cell(indices[n-1]);
332 const Int3 num_elem_ijk = splitting_ft.convert_packed_to_ijk_cell(elem);
333 eulerian_compo_connex_from_interface_ft_(num_elem_ijk[DIRECTION_I],num_elem_ijk[DIRECTION_J],num_elem_ijk[DIRECTION_K]) = (double) max_compo_per_cell;
334 }
335 if (n_ghost > 0)
336 {
337 std::vector<int> indices(n);
338 for (int j=0; j<n; j++)
339 indices[j]=j;
340 std::sort(indices.begin(), indices.end(), [&count_compo_ghost_per_cell](int i, int j) {return count_compo_ghost_per_cell[i] < count_compo_ghost_per_cell[j];});
341 const int max_compo_ghost_per_cell = compo_ghost_per_cell(indices[n-1]);
342 const Int3 num_elem_ijk = splitting_ft.convert_packed_to_ijk_cell(elem);
343 eulerian_compo_connex_from_interface_ghost_ft_(num_elem_ijk[DIRECTION_I],num_elem_ijk[DIRECTION_J],num_elem_ijk[DIRECTION_K]) = (double) max_compo_ghost_per_cell;
344 }
345 }
350 ref_ijk_ft_->eq_ns().redistribute_from_splitting_ft_elem(eulerian_compo_connex_from_interface_ft_, eulerian_compo_connex_from_interface_ns_);
351 ref_ijk_ft_->eq_ns().redistribute_from_splitting_ft_elem(eulerian_compo_connex_from_interface_ghost_ft_, eulerian_compo_connex_from_interface_ghost_ns_);
360 for (int k=0; k < nz ; k++)
361 for (int j=0; j< ny; j++)
362 for (int i=0; i < nx; i++)
363 {
368 }
372
373 statistics().end_count("Fill Compo connex");
374}
375
377{
378 statistics().create_custom_counter("Compute and fill rising velocity",3,"FrontTracking");
379 statistics().begin_count("Compute and fill rising velocity",statistics().get_last_opened_counter_level()+1);
380
382 {
383 const DoubleTab& bubbles_velocities_from_interface = interfaces_->get_bubble_velocities_from_interface();
384 const DoubleTab& bubbles_velocities_from_barycentres = interfaces_->get_bubble_velocities_from_barycentres();
385 int nb_bubbles = ref_ijk_ft_->get_interface().get_nb_bulles_reelles();
386 rising_velocities_ = ArrOfDouble(nb_bubbles);
387 rising_vectors_ = DoubleTab(nb_bubbles, 3);
388
389 int use_bubbles_velocities_from_interface_tmp = use_bubbles_velocities_from_interface_;
390 if (bubbles_velocities_from_interface.size() == 0)
391 use_bubbles_velocities_from_interface_tmp = 0;
392
393 int use_bubbles_velocities_from_barycentres_tmp = use_bubbles_velocities_from_barycentres_;
394 if (ref_ijk_ft_->schema_temps_ijk().get_tstep() == 0)
395 use_bubbles_velocities_from_barycentres_tmp = 0;
396
397 compute_rising_velocity(ref_ijk_ft_->eq_ns().get_velocity(),
398 ref_ijk_ft_->get_interface(),
400 ref_ijk_ft_->milieu_ijk().get_direction_gravite(),
404 bubbles_velocities_from_interface,
405 use_bubbles_velocities_from_interface_tmp,
406 bubbles_velocities_from_barycentres,
407 use_bubbles_velocities_from_barycentres_tmp);
408
409 compute_rising_velocity_overall(ref_ijk_ft_->get_interface(),
414 bubbles_velocities_from_interface,
415 use_bubbles_velocities_from_interface_tmp,
416 bubbles_velocities_from_barycentres,
417 use_bubbles_velocities_from_barycentres_tmp);
419 {
420 eulerian_rising_velocities_.data() = 0.;
421 eulerian_rising_velocities_.echange_espace_virtuel(eulerian_rising_velocities_.ghost());
423 }
424 }
425 else
426 Cerr << "Don't compute the ghost temperature field" << finl;
427
428 statistics().end_count("Compute and fill rising velocity");
429}
int_t nb_elem() const
Definition Domaine.h:131
This class encapsulates all the information related to the eulerian mesh for TrioIJK.
Definition Domaine_IJK.h:47
int convert_ijk_cell_to_packed(const FixedVector< int, 3 > ijk) const
Converts the ijk index of an element to a cell index.
FixedVector< int, 3 > convert_packed_to_ijk_cell(int index) const
Convert the local index of an element to a vector with IJK indices.
classe Domaine_dis_base Cette classe est la base de la hierarchie des domaines discretisees.
const Domaine & domaine() const
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
IJK_Field_double eulerian_compo_connex_from_interface_ghost_ft_
IJK_Field_double eulerian_compo_connex_ft_
IJK_Field_int eulerian_compo_connex_from_interface_int_ns_
void associate_rising_velocities_parameters(const Domaine_IJK &splitting, const int &compute_rising_velocities, const int &fill_rising_velocities, const int &use_bubbles_velocities_from_interface, const int &use_bubbles_velocities_from_barycentres)
IJK_Field_double eulerian_compo_connex_from_interface_ghost_ns_
void initialize(IJK_Interfaces &interfaces, const bool is_switch)
void associer(const Probleme_FTD_IJK_base &ijk_ft)
IJK_Field_double eulerian_compo_connex_from_interface_ns_
IJK_Field_double eulerian_compo_connex_ghost_ft_
IJK_Field_double eulerian_compo_connex_ghost_ns_
IJK_Field_int eulerian_compo_connex_valid_compo_field_
IJK_Field_double eulerian_rising_velocities_
void allocate_fields(const Domaine_IJK &splitting, const int &compute_compo_fields)
IJK_Field_int eulerian_compo_connex_from_interface_ghost_int_ns_
IJK_Field_double eulerian_compo_connex_ns_
IJK_Field_double eulerian_compo_connex_from_interface_ft_
: class IJK_Interfaces
: class Intersections_Elem_Facettes
const ArrOfInt & index_elem() const
Renvoie un tableau de taille domaine.
const Intersections_Elem_Facettes_Data & data_intersection(int index) const
Renvoie les donnees de l'intersection stockee a l'indice "index" dans le tableau "data" ( 0 <= index ...
const Intersections_Elem_Facettes & intersections_elem_facettes() const
: class Maillage_FT_IJK
const ArrOfInt & compo_connexe_facettes() const
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 nproc()
renvoie le nombre de processeurs dans le groupe courant Voir Comm_Group::nproc() et PE_Groups::curren...
Definition Process.cpp:104
Classe de base des flux de sortie.
Definition Sortie.h:52
virtual void reset()
Definition TRUSTArray.h:240
void append_array(_TYPE_ valeur)
_SIZE_ size_array() const
_SIZE_ size() const
Definition TRUSTVect.tpp:45