TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Domaine_IJK.h
1/****************************************************************************
2* Copyright (c) 2026, 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 Domaine_IJK_included
17#define Domaine_IJK_included
18
19#include <FixedVector.h>
20#include <Vecteur3.h>
21#include <TRUSTArrays.h>
22#include <TRUSTTab.h>
23#include <Domaine_base.h>
24#include <Front_VF.h>
25#include <IJK_Field_forward.h>
26#include <Domaine_forward.h>
27#include <Param.h>
28#include <Faces.h>
29#include <Joint.h>
30#include <Static_Int_Lists.h>
31#include <Faces_builder.h>
32#include <Probleme_base.h>
33#include <Interprete_bloc.h>
34#include <Linear_algebra_tools.h>
35#include <IJKArray_with_ghost.h>
36#include <Analyse_Angle.h>
37#include <Connectivite_som_elem.h>
38#include <Scatter.h>
39
40using Int3 = FixedVector<int,3>;
41
42/*! @brief This class encapsulates all the information related to the eulerian mesh for TrioIJK
43 *
44 * Multiples methods regarding how to navigates through it, volume of the each cells, etc...
45 */
47{
48 Declare_instanciable_sans_constructeur(Domaine_IJK);
49public:
50
51 /*! @brief Localisation sub class
52 */
54
55 /*! @brief status sub class to not compute the same structure twitce when not needed
56 */
58 /*! @brief Returns the face according to the direction
59 *
60 * @param direction In IJK, x(0), y(1) or z(2).
61 * @return A face
62 */
64 {
65 Localisation faces[] = {FACES_I, FACES_J, FACES_K};
66 assert(direction >= 0 && direction <= 2);
67 return faces[direction];
68 }
69
71 {
72 Localisation edges[] = {EDGES_I, EDGES_J, EDGES_K};
73 assert(direction >= 0 && direction <= 2);
74 return edges[direction];
75 }
76
78
79 // Initializes the object by analysing the provided VDF domaine (works for a distributed mesh)
80 void initialize_from_unstructured(const Domaine&,
81 int direction_for_x,
82 int direction_for_y,
83 int direction_for_z,
84 bool perio_x, bool perio_y, bool perio_z);
85
86 /*! @brief Buils a splitting of the given deometry on the requested number of processors
87 * in each direction.
88 *
89 * Process_grouping allows to rearrange process ranks by packets of ni*nj*nk processes
90 * to matc the topology of the cluster/node. ex: 8 cores node/machine => use groups
91 * of size 2x2x2 to minimize extra-node messages.
92 *
93 * @param nproc_i Number of processors in i direction.
94 * @param nproc_j Number of processors in j direction.
95 * @param nproc_k Number of processors in k direction.
96 * @param process_grouping_i 1 by default. Number of processors per subdomain in i direction.
97 * @param process_grouping_j 1 by default. Number of processors per subdomain in j direction.
98 * @param process_grouping_k 1 by default. Number of processors per subdomain in k direction.
99 */
101 int nproc_i, int nproc_j, int nproc_k,
102 int process_grouping_i = 1, int process_grouping_j = 1,
103 int process_grouping_k = 1);
104
105 /*! @brief Creates a splitting of the domain by specifying the slice
106 * sizes and the processor mapping.
107 *
108 * The total cell number in directions i, j, and k must match the
109 * total number of cells in the whole geometry for each direction.
110 * The number of slices in each direction must match each corresponding
111 * dimensions of the mapping array.
112 * All processors do not have to be used!
113 *
114 * @param slice_size_i Contains for each slice in the i direction, the number of cells this slice.
115 * @param slice_size_j Contains for each slice in the j direction, the number of cells this slice.
116 * @param slice_size_k Contains for each slice in the k direction, the number of cells this slice.
117 * @param processor_mapping Provides the rank of the mpi process that will own this subdomain.
118 */
119 void initialize_mapping(Domaine_IJK& dom, const ArrOfInt& slice_size_i,
120 const ArrOfInt& slice_size_j,
121 const ArrOfInt& slice_size_k,
122 const IntTab& processor_mapping);
123
124 /*! @brief Initializes class elements given dataset's parameters.
125 *
126 * @param x0 Origin of the whole domain on the x axis.
127 * @param y0 Origin of the whole domain on the y axis.
128 * @param z0 Origin of the whole domain on the z axis.
129 * @param delta_x Array with the sizes of the elements on the x axis.
130 * @param delta_y Array with the sizes of the elements on the y axis.
131 * @param delta_z Array with the sizes of the elements on the z axis.
132 * @param perio_x Periodic flag along x axis.
133 * @param perio_y Periodic flag along y axis.
134 * @param perio_z Periodic flag along z axis.
135 */
136 void initialize_origin_deltas(double x0, double y0, double z0,
137 const ArrOfDouble& delta_x,
138 const ArrOfDouble& delta_y,
139 const ArrOfDouble& delta_z,
140 bool perio_x, bool perio_y, bool perio_z);
141
142 /*! @brief Builds the geometry, parallel splitting and DOF correspondance
143 * between a "father" region and a "son" region which is a subpart
144 * of the father region.
145 *
146 * Only conformal subregion is supported for now, with ELEMENT types.
147 * Missing features: be able to build a subregion which is the boundary
148 * of another, eg: father is "3D elements", son is "2D faces".
149 *
150 * @param ni Number of elements in direction(0)
151 * @param nj Number of elements in direction(1)
152 * @param nk Number of elements in direction(2)
153 * @param offset_i Offset along x axis for the "son" subregion
154 * @param offset_j Offset along x axis for the "son" subregion
155 * @param offset_k Offset along x axis for the "son" subregion
156 * @param subregion_name Name of the "son" subregion
157 * @param perio_x Whether if domain is periodic along x axis
158 * @param perio_y Whether if domain is periodic along y axis
159 * @param perio_z Whether if domain is periodic along z axis
160 */
161 void init_subregion(const Domaine_IJK& src, int ni, int nj, int nk,
162 int offset_i, int offset_j, int offset_k,
163 const Nom& subregion,
164 bool perio_x = false, bool perio_y = false, bool perio_z = false);
165
166 /*! @brief Creates a splitting of the domain by specifying the mapping.
167 *
168 * The total cell number in directions i,j,k must match the total
169 * number of cells in each direction.
170 * The number of slices in direction i, j , k must match dimensions
171 * 0,1 and 2 of the processor_mapping() array.
172 *
173 * @param slice_size_i Contains, for each slice in the x direction, the number of cells in this slice.
174 * @param slice_size_j Contains, for each slice in the y direction, the number of cells in this slice.
175 * @param slice_size_k Contains, for each slice in the z direction, the number of cells in this slice.
176 * @param processor_mapping Provides the rank of the mpi process that will have this subdomain.
177 */
178 void initialize_with_mapping(const ArrOfInt& slice_size_i,
179 const ArrOfInt& slice_size_j,
180 const ArrOfInt& slice_size_k,
181 const IntTab& processor_mapping);
182
183 /*! @brief
184 *
185 */
186// void discretiser();
187
188 /*! @brief renvoie new(Faces) ! elle est surchargee par Domaine_VDF par ex.
189 */
190 Faces* creer_faces();
191
192 /*! @brief Returns the number of elements owned by this processor in the given direction
193 *
194 * @param direction In IJK, x(0), y(1) or z(2)
195 * @return nb_elem_local_[direction]
196 */
197 inline int get_nb_elem_local(int direction) const
198 {
199 assert(direction >= 0 && direction < 3);
200 return nb_elem_local_[direction];
201 }
202
203 /*! @brief Returns the number of element owned by this processor.
204 */
205 inline int get_nb_elem_local() const
206 {
207 assert(Objet_U::dimension == 3);
208 assert(nb_elem_local_[0] > 0);
209 assert(nb_elem_local_[1] > 0);
210 assert(nb_elem_local_[2] > 0);
211 return nb_elem_local_[0] * nb_elem_local_[1] * nb_elem_local_[2];
212 }
213
214 /*! @brief Returns the number of nodes owned by this processor (generally equal to nb_elem_local())
215 *
216 * The last node of the last element is owned by the next processor.
217 *
218 * @param direction In IJK, x(0), y(1) or z(2)
219 * @return nb_nodes_local_[dir]
220 */
221 inline int get_nb_nodes_local(int direction) const
222 {
223 assert(direction >= 0 && direction < 3);
224 return nb_nodes_local_[direction];
225 }
226
227 /*! @brief Returns the number, in requested direction, of faces that are oriented in direction of "compo"
228 *
229 * The last face of the last element is owned by the next processor.
230 *
231 * @param compo direction In IJK, horizontal(0), vertical(1) or z-axis depth(2)
232 * @param direction In IJK, x(0), y(1) or z(2)
233 * @return nb_faces_local_[compo][direction]
234 */
235 inline int get_nb_faces_local(int compo, int direction) const
236 {
237 assert(compo >= 0 && compo < 3);
238 assert(direction >= 0 && direction < 3);
239 return nb_faces_local_[compo][direction];
240 }
241
242 /*! @brief Returns the number, in requested direction, of edges of faces in direction of "compo"
243 *
244 * The last face of the last element is owned by the next processor.
245 *
246 * @param compo direction In IJK, horizontal(0), vertical(1) or z-axis depth(2)
247 * @param direction In IJK, x(0), y(1) or z(2)
248 * @return nb_faces_local_[compo][direction]
249 */
250 inline int get_nb_edges_local(int compo, int direction) const
251 {
252 assert(compo >= 0 && compo < 3);
253 assert(direction >= 0 && direction < 3);
254 return nb_edges_local_[compo][direction];
255 }
256
257 /*! @brief Returns the number of local items (on this processor) for the given localisation in the requested direction
258 *
259 * @param loc In IJK, ELEM, NODES, EDGES_I, EDGES_J, EDGES_K, FACES_I, FACES_J or FACES_K
260 * @param direction In IJK, x(0), y(1) or z(2)
261 * @return Number of requested items
262 */
263 int get_nb_items_local(Localisation loc, int direction) const;
264
265 /*! @brief Returns the total (global) number of mesh cells in requested direction
266 * @param direction In IJK, x(0), y(1) or z(2).
267 * @return Number of elements
268 */
269 inline int get_nb_elem_tot(int direction) const
270 {
271 assert(direction >= 0 && direction < 3);
272 return get_delta(direction).size_array();
273 }
274
275 /*! @brief Returns the total (global) number of mesh cells.
276 */
277 inline int get_nb_elem_tot() const
278 {
279 assert(Objet_U::dimension == 3);
281 }
282
283 /*! @brief Returns the length of the entire domain in requested direction
284 * @param direction In IJK, x(0), y(1) or z(2).
285 * @return Global length of the domain
286 */
287 double get_domain_length(int direction) const;
288
289 /*! @brief Returns the number of local items (on this processor) for the given localisation in the requested direction
290 *
291 * If periodic along requested direction, need to add the last item for nodes and faces.
292 *
293 * @param loc In IJK, ELEM, NODES, EDGES_I, EDGES_J, EDGES_K, FACES_I, FACES_J or FACES_K
294 * @param direction In IJK, x(0), y(1) or z(2)
295 * @return Number of requested items
296 */
297 int get_nb_items_global(Localisation loc, int direction) const;
298
299 /*! @brief Returns the local offset in requested direction
300 *
301 * @param direction In IJK, x(0), y(1) or z(2)
302 * @return offset_[direction]
303 */
304 inline int get_offset_local(int direction) const
305 {
306 assert(direction >= 0 && direction < 3);
307 return offset_[direction];
308 }
309
310 /*! @brief Returns the position of the local subdomain in the requested direction
311 *
312 * @param direction In IJK, x(0), y(1) or z(2)
313 * @return processor_position_[direction]
314 */
315 inline int get_local_slice_index(int direction) const
316 {
317 assert(direction >= 0 && direction < 3);
318 return processor_position_[direction];
319 }
320
321 /*! @brief Returns the index of the requested neighbour processor (-1 if no neighbour).
322 *
323 * previous_or_next = 0 => get processor at left (in the direction of smaller indices).
324 * previous_or_next = 1 => get processor at right (in the direction of the larger indices).
325 *
326 * @param preivous_or_next 0 or 1, previous or next one respectively.
327 * @param direction In IJK, x(0), y(1) or z(2).
328 *
329 * @return neighbour_processors_[previous_or_next][dir]
330 */
331 inline int get_neighbour_processor(int previous_or_next, int direction) const
332 {
333 assert(direction >= 0 && direction < 3);
334 assert(previous_or_next == 0 || previous_or_next == 1);
335 return neighbour_processors_[previous_or_next][direction];
336 }
337
338 /*! @brief Returns the number of slices in the given direction
339 *
340 * @param direction In IJK, x(0), y(1) or z(2).
341 * @return nproc_per_direction_[direction]
342 */
343 inline int get_nprocessor_per_direction(int direction) const
344 {
345 assert(direction >= 0 && direction < 3);
346 return nproc_per_direction_[direction];
347 }
348
349 /*! @brief Returns an array with the coordinates of all nodes in the mesh in requested direction.
350 * @param direction In IJK, x(0), y(1) or z(2).
351 * @return node_coordinates_xyz_[direction]
352 */
353 const ArrOfDouble& get_node_coordinates(int direction) const
354 {
355 assert(direction >= 0 && direction < 3);
356 return node_coordinates_xyz_[direction];
357 }
358
359 /*! @brief Returns the coordinate of the first node (global) of the mesh in the requested direction
360 * @param direction In IJK, x(0), y(1) or z(2).
361 * @return coordinate.
362 */
363 inline double get_origin(int direction) const
364 {
365 assert(direction >= 0 && direction < 3);
366 return node_coordinates_xyz_[direction][0];
367 }
368
369 /*! @brief Returns the array of mesh cell sizes in requested direction
370 * @param direction In IJK, x(0), y(1) or z(2).
371 * @return Array with the sizes.
372 */
373 const ArrOfDouble& get_delta(int direction) const
374 {
375 assert(direction >= 0 && direction < 3);
376 return delta_xyz_[direction];
377 }
378
379 /*! @brief Returns the size of cells in a direction
380 *
381 * This requires the size of all cells in this direction to be the same,
382 * Which means is_uniform(direction) has to be true.
383 *
384 * @param direction In IJK, x(0), y(1) or z(2).
385 * @return length of cells in this direction.
386 */
387 inline double get_constant_delta(int direction) const
388 {
389 assert(direction >= 0 && direction < 3);
390 if (!is_uniform(direction))
391 {
392 Cerr << "Error in Domaine_IJK::get_constant_delta: grid is not uniform in direction : " << direction << finl;
394 }
395 return delta_xyz_[direction][0];
396 }
397
398 /*! @brief Fills the "delta" array with the size of the cells owned by the processor in the requested direction.
399 *
400 *
401 * "delta" is redimensionned with the specified number of ghost cells and filled.
402 * If domain is periodic, takes periodic mesh size in ghost cells on first and last subdomain,
403 * if domain is not periodic, copy the size of the first and last cell into ghost cells in the walls.
404 *
405 * @param direction In IJK, x(0), y(1) or z(2).
406 * @param ghost_cells Size of the ghost cells
407 * @param delta Size of cells in each direction
408 */
409 void get_local_mesh_delta(int direction, int ghost_cells,
410 ArrOfDouble_with_ghost& delta) const;
411
412 /*! @brief Fills an array containing the mapping of processors
413 *
414 *
415 * For 3 slices indices i,j,k, the processor that owns
416 * the intersection of these slices is mapping(i,j,k).
417 *
418 * @param mapping Table in which we'll copy the mapping
419 */
420 inline void get_processor_mapping(IntTab& mapping) const { mapping = mapping_; }
421
422 /*! @brief Returns the indices of the first cell in requested direction
423 * of every slices in this direction
424 *
425 * @param direction In IJK, x(0), y(1) or z(2).
426 * @param tab Array in which we'll store the offsets in that direction
427 */
428 inline void get_slice_offsets(int direction, ArrOfInt& tab) const
429 {
430 assert(direction >= 0 && direction < 3);
431 tab = offsets_all_slices_[direction];
432 }
433
434 /*! @brief Returns the number of items of given location (elements, nodes, faces...)
435 * for all slices in the requested direction.
436 *
437 * @param direction In IJK, x(0), y(1) or z(2).
438 * @param loc In IJK, ELEM, NODES, EDGES_I, EDGES_J, EDGES_K, FACES_I, FACES_J or FACES_K
439 * @param tab Array in which we'll store the number of slices in given direction
440 */
441 void get_slice_size(int direction, Localisation loc, ArrOfInt& tab) const;
442
443 /*! @brief Return the global index of the processor according to its position.
444 *
445 * @param slice Vector with the x, y, and z coordinate of the processor.
446 * @return mapping_(slice[0], slice[1], slice[2])
447 */
448 inline int get_processor_by_ijk(const FixedVector<int, 3>& slice) const
449 {
450 return mapping_(slice[0], slice[1], slice[2]);
451 }
452
453 /*! @brief Return the global index of the processor according to its position.
454 *
455 * @param slice_i First index of the processor in the global mapping
456 * @param slice_j Second index of the processor in the global mapping
457 * @param slice_k Third index of the processor in the global mapping
458 * @return return mapping_(slice_i, slice_j, slice_k)
459 */
460 inline int get_processor_by_ijk(int slice_i, int slice_j, int slice_k) const
461 {
462 return mapping_(slice_i, slice_j, slice_k);
463 }
464
465 /*! Returns the processor associated with slice indices i,j,k accounting for periodicity
466 * e.g. a slice index -1 can refer to the last slice along a periodic direction.
467 */
468 int periodic_get_processor_by_ijk(int slice_i, int slice_j, int slice_k) const;
469
470 /*! @brief Determines the dof of an element along a localisation
471 *
472 * TODO: Not sure about the brief?
473 *
474 * @param i Local index of an element along x axis.
475 * @param j Local index of an element along y axis.
476 * @param k Local index of an element along z axis.
477 * @param In IJK, ELEM, NODES, EDGES_I, EDGES_J, EDGES_K, FACES_I, FACES_J or FACES_K.
478 *
479 * @return A vector with the coordinates of dof
480 */
481 Vecteur3 get_coords_of_dof(int i, int j, int k, Localisation loc) const;
482
483 inline double get_coord_of_dof_along_dir(int dir, int i, Localisation loc) const;
484
485
486 /*! independent_index adds a ghost_size to the packed index.
487 * It is similar to the linear_index defined in IJK_Field_local_template, but with
488 * a universal, predefined ghost_size of 256 instead of a field-dependent ghost_size.
489 * Since the ghost_size_ value is larger than any ghost_size expected to be used in
490 * practice, any virtual cell can be represented by the independent index.
491 */
492 int get_independent_index(int i, int j, int k) const;
493 Int3 get_ijk_from_independent_index(int independent_index) const;
494
495 /*! signed_independent_index: encodes in the sign the phase of the cell in a
496 * two-phase flow: positive sign for phase 0, and negative sign for phase 1.
497 * With a cut-cell method, this can be used to disambiguate the sub-cell.
498 */
499 int get_signed_independent_index(int phase, int i, int j, int k) const;
500 int get_independent_index_from_signed_independent_index(int signed_independent_index) const;
501 int get_phase_from_signed_independent_index(int signed_independent_index) const;
502
503 /*! Check whether the cell (i,j,k) is contained within the specified ghost along any direction.
504 */
505 bool within_ghost(int i, int j, int k, int negative_ghost_size, int positive_ghost_size) const;
506
507 /*! Check whether the cell (i,j,k) is contained within the specified ghost along a specific direction.
508 */
509 bool within_ghost_along_dir(int dir, int i, int j, int k, int negative_ghost_size, int positive_ghost_size) const;
510
511 template <int _DIR_>
512 bool within_ghost_(int i, int j, int k, int negative_ghost_size, int positive_ghost_size) const
513 {
514 int dir = static_cast<int>(_DIR_);
515 return within_ghost_along_dir(dir, i, j, k, negative_ghost_size, positive_ghost_size);
516 }
517
518 int correct_perio_i_local(int direction, int i) const;
519 int get_i_along_dir_no_perio(int direction, double coord_dir, Localisation loc) const;
520 int get_i_along_dir_perio(int direction, double coord_dir, Localisation loc) const;
521
522 Int3 get_ijk_from_coord(double coord_x, double coord_y, double coord_z, Localisation loc) const;
523
524 /*! @brief Converts the ijk index of an element to a cell index.
525 *
526 * Adapted from Maillage_FT_IJK.h
527 *
528 * @param ijk Vector with the x, y, and z coordinates.
529 * @return The LOCAL index of an element.
530 */
532 {
533 return convert_ijk_cell_to_packed(ijk[0], ijk[1], ijk[2]);
534 }
535
536 /*! @brief With three indices, find the local index of an element
537 *
538 * @param i Local index of an element along x axis.
539 * @param j Local index of an element along y axis.
540 * @param k Local index of an element along z axis.
541 *
542 * @return The LOCAL index of an element.
543 */
544 int convert_ijk_cell_to_packed(int i, int j, int k) const;
545
546 /*! @brief Convert the local index of an element to a vector with IJK indices.
547 *
548 * Adapted from Maillage_FT_IJK.h
549 *
550 * @param index Local index of the element.
551 * @return Vector with IJK coordinates.
552 */
554
555 /*! @brief Find the element which contains the item's coodirnates.
556 *
557 * The element's coordinates can be outside of this processor's subdomain.
558 *
559 * @param x First coordinate of an item in the mesh.
560 * @param y Second coordinate of an item in the mesh.
561 * @param z Third coordinate of an item in the mesh.
562 * @param ijk_global The global coordinates of the cell.
563 * @param ijk_local The local coordinates of the cell.
564 * @param ijk_me A sort of 3D flag. Will be [1,1,1] if the element belongs to me.
565 */
566 void search_elem(const double& x, const double& y, const double& z,
567 FixedVector<int, 3>& ijk_global,
568 FixedVector<int, 3>& ijk_local,
569 FixedVector<int, 3>& ijk_me) const;
570
571 /*! @brief Method returns true if periodic in this direction
572 * @param direction In IJK, x(0), y(1) or z(2).
573 * @return true or false
574 */
575 inline bool get_periodic_flag(int direction) const
576 {
577 assert(direction >= 0 && direction < 3);
578 return periodic_[direction];
579 }
580
581 /*! @brief Method returns true if uniform in this direction
582 * @param direction In IJK, x(0), y(1) or z(2).
583 * @return true or false
584 */
585 inline bool is_uniform(int direction) const
586 {
587 assert(direction >= 0 && direction < 3);
588 return uniform_[direction];
589 }
590
591 /*! @brief Updates volume_elem_
592 * / ! \ If the grid changes, this needs to be called again!
593 */
594 void update_volume_elem();
595
596 /*! @brief Returns volume_elem_
597 */
598 inline const DoubleVect& get_volume_elem() const
599 {
600 assert(volume_elem_.size_array() > 0 && "volume_elem_ is empty. Update before trying to read it.");
601 assert(volume_elem_.size_array() == get_nb_elem_local() && "volume_elem_ is not up to date. Update before trying to read it.");
602 assert(volume_elem_status_ == DONE);
603 return volume_elem_;
604 }
605
606 inline int ft_extension() const { return ft_extension_; }
607
608 void set_extension_from_bulle_param(double vol_bulle, double diam_bulle);
609
610private:
611
612 /*! @brief Coordinates of all nodes (when cell size is needed, take delta_xyz_ which is more accurate) in directions i, j and k.
613 *
614 * We have: node_coordinates_xyz_.size() == 3 (3 directions in space)
615 * node_coordinates_xyz_[DIRECTION_I/J/K] == number of cells in direction i,j,k plus one
616 * The coordinate of the last node is the end coordinate of the mesh: if mesh is periodic, the last
617 * node coordinate is not equal to the first one.
618 */
619 VECT(ArrOfDouble) node_coordinates_xyz_;
620 /*! @brief Mesh cell sizes for the entire mesh.
621 *
622 * The size of each array is equal to the total number of cells in each direction.
623 * If possible, this data is not computed from nodes (less truncation errors for uniform meshes)
624 */
625 VECT(ArrOfDouble) delta_xyz_;
626 /*! Number of processors in each direction */
627 FixedVector<int, 3> nproc_per_direction_;
628 /*! @brief Global processor mapping: for each subdomain, which processor has it (indexed like this: mapping_(i, j, k)) */
629 IntTab mapping_;
630 /*! For each direction, offsets of all slices */
631 VECT(ArrOfInt) offsets_all_slices_; ///< F
632 /*! @brief For each direction, size of all slices */
633 VECT(ArrOfInt) sizes_all_slices_;
634 /*! @brief Stores the uniform flag for each direction */
635 bool uniform_[3] = {false, false, false};
636 /*! @brief Stores the periodic flag for each direction */
637 bool periodic_[3] = {false, false, false};
638
639
640 // Local data (processor dependent)
641 // --------------------------------
642
643 /*! @brief Where is this processor in the global domain (slice number in each direction, -1 if processor has no data) */
644 FixedVector<int, 3> processor_position_;
645 /*! @brief Number of element in requested direction.
646 * If the current processor has an empty subdomain, the number of elements, nodes, faces is zero.
647 */
648 FixedVector<int, 3> nb_elem_local_;
649 /*! @brief Number of nodes in requested direction.
650 * If the current processor has an empty subdomain, the number of elements, nodes, faces is zero.
651 */
652 FixedVector<int, 3> nb_nodes_local_;
653 /*! indexing is nb_faces_local_[for orientation i][number of faces in direction j] */
654 FixedVector<FixedVector<int, 3>, 3> nb_faces_local_;
655 /*! same indexing for nb_edges_local_[for orientation i][number of faces in direction j] */
656 FixedVector<FixedVector<int, 3>, 3> nb_edges_local_;
657 /*! Index in the global mesh of the first (non ghost) element on this processor, in each direction */
658 FixedVector<int, 3> offset_;
659 /*! @brief MPI ranks of the processors that hold the neighbour domains.
660 * Indexing is neighbour_processors_[previous=0, next=1][direction].
661 * Contains -1 if no neighbour.
662 * Wraps if periodic domain, if there is only one processor in a direction, the neighbour might be myself.
663 */
664 FixedVector<FixedVector<int, 3>, 2> neighbour_processors_;
665 /*! Volume of each element on this processor */
666 DoubleVect volume_elem_;
667 /*! State of volume_elem_ on this processor */
668 grid_status volume_elem_status_;
669 /*! Number of element used to extend the computational domain at each side of periodic boundary to accommodate for bubble evolution. */
670 int ft_extension_ = 0;
671
672};
673
674inline double Domaine_IJK::get_coord_of_dof_along_dir(int dir, int i, Localisation loc) const
675{
676 int gi = i + offset_[dir];
677 double x = get_node_coordinates(dir)[gi];
678
679 bool loc_edges = (loc == EDGES_I) || (loc == EDGES_J) || (loc == EDGES_K);
680 bool loc_equal_dir = (((loc == FACES_I) && (dir == 0)) || ((loc == FACES_J) && (dir == 1)) || ((loc == FACES_K) && (dir == 2)));
681 bool loc_equal_dir_or_nodes_or_edges = loc_equal_dir || loc_edges || (loc == NODES);
682
683 bool loc_equal_edge_dir = (((loc == EDGES_I) && (dir == 0)) || ((loc == EDGES_J) && (dir == 1)) || ((loc == EDGES_K) && (dir == 2)));
684
685 if (!loc_equal_dir_or_nodes_or_edges)
686 x += get_delta(dir)[gi] * 0.5;
687
688 if (loc_equal_edge_dir)
689 x += get_delta(dir)[gi] * 0.5;
690
691 return x;
692}
693
694
695#endif
This class encapsulates all the information related to the eulerian mesh for TrioIJK.
Definition Domaine_IJK.h:47
void set_extension_from_bulle_param(double vol_bulle, double diam_bulle)
int get_offset_local(int direction) const
Returns the local offset in requested direction.
int get_neighbour_processor(int previous_or_next, int direction) const
Returns the index of the requested neighbour processor (-1 if no neighbour).
int get_nb_elem_local() const
Returns the number of element owned by this processor.
int get_processor_by_ijk(const FixedVector< int, 3 > &slice) const
Return the global index of the processor according to its position.
int get_independent_index(int i, int j, int k) const
void update_volume_elem()
Updates volume_elem_ / ! \ If the grid changes, this needs to be called again!
bool within_ghost(int i, int j, int k, int negative_ghost_size, int positive_ghost_size) const
int periodic_get_processor_by_ijk(int slice_i, int slice_j, int slice_k) const
void init_subregion(const Domaine_IJK &src, int ni, int nj, int nk, int offset_i, int offset_j, int offset_k, const Nom &subregion, bool perio_x=false, bool perio_y=false, bool perio_z=false)
Builds the geometry, parallel splitting and DOF correspondance between a "father" region and a "son" ...
bool within_ghost_along_dir(int dir, int i, int j, int k, int negative_ghost_size, int positive_ghost_size) const
bool is_uniform(int direction) const
Method returns true if uniform in this direction.
int get_nb_faces_local(int compo, int direction) const
Returns the number, in requested direction, of faces that are oriented in direction of "compo".
Faces * creer_faces()
renvoie new(Faces) ! elle est surchargee par Domaine_VDF par ex.
int get_nb_elem_local(int direction) const
Returns the number of elements owned by this processor in the given direction.
int get_nb_elem_tot() const
Returns the total (global) number of mesh cells.
int get_nb_edges_local(int compo, int direction) const
Returns the number, in requested direction, of edges of faces in direction of "compo".
grid_status
status sub class to not compute the same structure twitce when not needed
Definition Domaine_IJK.h:57
bool get_periodic_flag(int direction) const
Method returns true if periodic in this direction.
static Localisation Faces_Dir_To_Localisation(int direction)
Returns the face according to the direction.
Definition Domaine_IJK.h:63
double get_domain_length(int direction) const
Returns the length of the entire domain in requested direction.
int get_nprocessor_per_direction(int direction) const
Returns the number of slices in the given direction.
int get_i_along_dir_no_perio(int direction, double coord_dir, Localisation loc) const
Int3 get_ijk_from_independent_index(int independent_index) const
void initialize_from_unstructured(const Domaine &, int direction_for_x, int direction_for_y, int direction_for_z, bool perio_x, bool perio_y, bool perio_z)
int get_nb_items_local(Localisation loc, int direction) const
Returns the number of local items (on this processor) for the given localisation in the requested dir...
void get_local_mesh_delta(int direction, int ghost_cells, ArrOfDouble_with_ghost &delta) const
Fills the "delta" array with the size of the cells owned by the processor in the requested direction.
int get_processor_by_ijk(int slice_i, int slice_j, int slice_k) const
Return the global index of the processor according to its position.
double get_coord_of_dof_along_dir(int dir, int i, Localisation loc) const
int ft_extension() const
double get_constant_delta(int direction) const
Returns the size of cells in a direction.
static Localisation Edges_Dir_To_Localisation(int direction)
Definition Domaine_IJK.h:70
int get_phase_from_signed_independent_index(int signed_independent_index) const
void get_processor_mapping(IntTab &mapping) const
Fills an array containing the mapping of processors.
int get_i_along_dir_perio(int direction, double coord_dir, Localisation loc) const
const ArrOfDouble & get_delta(int direction) const
Returns the array of mesh cell sizes in requested direction.
double get_origin(int direction) const
Returns the coordinate of the first node (global) of the mesh in the requested direction.
int get_signed_independent_index(int phase, int i, int j, int k) const
void initialize_splitting(Domaine_IJK &dom, int nproc_i, int nproc_j, int nproc_k, int process_grouping_i=1, int process_grouping_j=1, int process_grouping_k=1)
Buils a splitting of the given deometry on the requested number of processors in each direction.
int correct_perio_i_local(int direction, int i) const
int get_independent_index_from_signed_independent_index(int signed_independent_index) const
void get_slice_offsets(int direction, ArrOfInt &tab) const
Returns the indices of the first cell in requested direction of every slices in this direction.
int get_nb_items_global(Localisation loc, int direction) const
Returns the number of local items (on this processor) for the given localisation in the requested dir...
void initialize_mapping(Domaine_IJK &dom, const ArrOfInt &slice_size_i, const ArrOfInt &slice_size_j, const ArrOfInt &slice_size_k, const IntTab &processor_mapping)
Creates a splitting of the domain by specifying the slice sizes and the processor mapping.
Vecteur3 get_coords_of_dof(int i, int j, int k, Localisation loc) const
Determines the dof of an element along a localisation.
int convert_ijk_cell_to_packed(const FixedVector< int, 3 > ijk) const
Converts the ijk index of an element to a cell index.
int get_nb_elem_tot(int direction) const
Returns the total (global) number of mesh cells in requested direction.
void get_slice_size(int direction, Localisation loc, ArrOfInt &tab) const
Returns the number of items of given location (elements, nodes, faces...) for all slices in the reque...
const ArrOfDouble & get_node_coordinates(int direction) const
Returns an array with the coordinates of all nodes in the mesh in requested direction.
int get_nb_nodes_local(int direction) const
Returns the number of nodes owned by this processor (generally equal to nb_elem_local()).
FixedVector< int, 3 > convert_packed_to_ijk_cell(int index) const
Convert the local index of an element to a vector with IJK indices.
void initialize_origin_deltas(double x0, double y0, double z0, const ArrOfDouble &delta_x, const ArrOfDouble &delta_y, const ArrOfDouble &delta_z, bool perio_x, bool perio_y, bool perio_z)
Initializes class elements given dataset's parameters.
int get_local_slice_index(int direction) const
Returns the position of the local subdomain in the requested direction.
bool within_ghost_(int i, int j, int k, int negative_ghost_size, int positive_ghost_size) const
void initialize_with_mapping(const ArrOfInt &slice_size_i, const ArrOfInt &slice_size_j, const ArrOfInt &slice_size_k, const IntTab &processor_mapping)
Creates a splitting of the domain by specifying the mapping.
const DoubleVect & get_volume_elem() const
Returns volume_elem_.
Localisation
Localisation sub class.
Definition Domaine_IJK.h:53
void search_elem(const double &x, const double &y, const double &z, FixedVector< int, 3 > &ijk_global, FixedVector< int, 3 > &ijk_local, FixedVector< int, 3 > &ijk_me) const
Find the element which contains the item's coodirnates.
Int3 get_ijk_from_coord(double coord_x, double coord_y, double coord_z, Localisation loc) const
Base class for domains description. This class holds all the data shared by all domains and not sensi...
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
static int dimension
Definition Objet_U.h:99
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
_SIZE_ size_array() const