16#include <Domaine_IJK.h>
20#define print_vect(x) (Nom("[") + Nom(x[0]) + Nom(" ") + Nom(x[1]) + Nom(" ") + Nom(x[2]) + Nom("]"))
39 delta_xyz_.dimensionner(3);
40 node_coordinates_xyz_.dimensionner(3);
41 offsets_all_slices_.dimensionner(3);
42 sizes_all_slices_.dimensionner(3);
45 for(
int i = 0; i < 3; ++i)
47 nb_elem_local_[i] = 0;
48 nb_nodes_local_[i] = 0;
50 nproc_per_direction_[i] = 0;
51 for(
int j = 0; j < 3; ++j)
53 nb_faces_local_[i][j] = 0;
54 nb_edges_local_[i][j] = 0;
56 for(
int j = 0; j < 2; ++j)
57 neighbour_processors_[j][i] = -1;
63 Cerr <<
"Domain loaded for this subclass" << finl;
71 Cerr <<
"Reading Domaine_IJK (" <<
le_nom() <<
")" << finl;
74 Process::exit(
"Dimension must be set before declaring the domain.");
76 ArrOfDouble origin(dim);
77 ArrOfInt perio_flags(dim);
80 ArrOfDouble size_dom(dim);
81 Noms file_coords(dim);
98 Process::exit(
" The symbol { was expected after 'read|lire'");
100 Motcles les_mots(50);
102 les_mots[0] =
"nbelem";
103 les_mots[1] =
"size_dom";
104 les_mots[2] =
"file_coords";
105 les_mots[3] =
"origin";
106 les_mots[4] =
"perio";
107 les_mots[5] =
"nproc";
108 les_mots[6] =
"process_grouping";
109 les_mots[7] =
"ijk_splitting_ft_extension";
115 rang = les_mots.search(motlu);
119 for(
int i = 0; i < dim; ++i)
123 for(
int i = 0; i < dim; ++i)
127 for(
int i = 0; i < dim; ++i)
128 is >> file_coords[i];
131 for(
int i = 0; i < dim; ++i)
135 for(
int i = 0; i < dim; ++i)
136 is >> perio_flags[i];
139 for(
int i = 0; i < dim; ++i)
143 for(
int i = 0; i < dim; ++i)
150 Cerr <<
"Keyword : " << motlu <<
" not understood by Domaine_IJK::readOn. Either update if needed or change the keyword." << finl;
158 VECT(ArrOfDouble) delta_dir(3);
159 for (
int i = 0; i < 3; ++i)
161 if (file_coords[i] !=
"??")
165 Cerr <<
"Reading coordinates for direction " << i <<
" in file " << file_coords[i] << finl;
166 EFichier EFcoord(file_coords[i]);
168 double previous_x = 0.;
179 delta_dir[i].append_array(next_x - previous_x);
183 if (delta_dir[i].size_array() < 1)
184 Cerr <<
"Error in Domaine_IJK::readOn: input file contains less than 2 values" << finl;
186 envoyer_broadcast(delta_dir[i], 0);
188 else if (ndir[i] != -1)
190 if (ndir[i] < 1 || size_dom[i] <= 0.)
192 Cerr <<
"Error in Domaine_IJK::readOn: wrong value of nbelem or uniform_domain_size for direction " << i
193 <<
"\n : nbelem = " << ndir[i] <<
" domain_size = " << size_dom[i] << finl;
196 delta_dir[i].resize_array(ndir[i]);
197 delta_dir[i] = size_dom[i] / ndir[i];
201 Cerr <<
"Error in Domaine_IJK::readOn: you must provide (nbelem x y z)\n"
202 <<
" or file_coords for each direction i, j and k" << finl;
206 for (
int j = 0; j < delta_dir[i].size_array(); j++)
208 if (delta_dir[i][j] <= 0.)
210 Cerr <<
"Error in Domaine_IJK::readOn: size of element " << j <<
" in direction " << i <<
" is not positive" << finl;
213 x += delta_dir[i][j];
215 Cerr <<
"Direction " << i <<
" has " << delta_dir[i].size_array() <<
" elements. Total domain size = " << x << finl;
219 for (
int j = 0; j < dim; j++)
222 Process::exit(
"Proc number in every direction must be strictly positive! Did you forget 'nprocs'?");
223 tot_proc *= nprocs[j];
227 Cerr <<
"!! ERROR: Domaine_IJK is built with a total number of " << tot_proc <<
" procs, but TRUST/Trio was launched with " <<
Process::nproc() <<
" procs!!" << finl;
231 Cerr <<
"nproc in i, j, k directions = " << nprocs[0] <<
" " << nprocs[1] <<
" " << nprocs[2] << finl;
232 Cerr <<
"grouping processes in i, j, k directions (node topology) = "
233 << groups[0] <<
" " << groups[1] <<
" " << groups[2] << finl;
236 delta_dir[2], perio_flags[0], perio_flags[1], perio_flags[2]);
243static void retirer_doublons(ArrOfDouble& tab,
double epsilon)
248 double last_value = tab[0];
250 for (
int i = 1; i < n; i++)
253 if (x > last_value + epsilon)
262static void find_unique_coord(
const DoubleTab& src,
int column, ArrOfDouble& result)
267 for (i = 0; i < n; i++)
268 tmp[i] = src(i, column);
281 for (i = 1; i < np; i++)
283 recevoir(tmp, i, 53 );
284 int m1Loc = tmp.size_array();
293 envoyer_broadcast(result, 0);
304 bool perio_x,
bool perio_y,
bool perio_z)
306 if (!sub_type(Hexaedre, domaine.type_elem().valeur()))
308 Cerr <<
"Error in Domaine_IJK::initialize_from_unstructured:\n"
309 <<
" the provided domaine does not have Hexaedre element type" << finl;
312 periodic_[0] = perio_x;
313 periodic_[1] = perio_y;
314 periodic_[2] = perio_z;
317 const DoubleTab& coord_som = domaine.les_sommets();
318 Cout <<
"Domaine_IJK::initialize_from_unstructured maps x->" << direction_for_x
319 <<
" y->" << direction_for_y <<
" z->" << direction_for_z << finl;
321 find_unique_coord(coord_som, 0 , node_coordinates_xyz_[direction_for_x]);
322 find_unique_coord(coord_som, 1 , node_coordinates_xyz_[direction_for_y]);
323 find_unique_coord(coord_som, 2 , node_coordinates_xyz_[direction_for_z]);
326 for (
int dir = 0; dir < 3; dir++)
328 const ArrOfDouble& coord = node_coordinates_xyz_[dir];
329 ArrOfDouble& delta = delta_xyz_[dir];
331 Cout <<
" Direction " << dir <<
" has " << nelem <<
" elements. coord[0]="
332 << coord[0] <<
" coord[" << nelem <<
"]=" << coord[nelem];
334 double mindelta = 1e30;
335 double maxdelta = 0.;
336 for (
int i = 0; i < nelem; i++)
338 const double d = coord[i+1] - coord[i];
340 mindelta = std::min(d, mindelta);
341 maxdelta = std::max(d, maxdelta);
343 if (maxdelta - mindelta < eps)
346 double d = (coord[nelem] - coord[0]) / (
double) nelem;
348 Cout <<
" Uniform, delta=" << d << finl;
349 uniform_[dir] =
true;
353 Cout <<
"Domaine_IJK::initialize_from_unstructured direction " << dir
354 <<
" Not uniform, min delta=" << mindelta
355 <<
" max delta=" << maxdelta << finl;
356 uniform_[dir] =
false;
378 int nproc_i,
int nproc_j,
int nproc_k,
379 int process_grouping_i,
380 int process_grouping_j,
381 int process_grouping_k)
383 assert(nproc_i % process_grouping_i == 0 &&
"While this will still work, may not bring expected results. Try having a process grouping number that divides the number of proc allocated to this direction.");
384 assert(nproc_j % process_grouping_j == 0 &&
"While this will still work, may not bring expected results. Try having a process grouping number that divides the number of proc allocated to this direction.");
385 assert(nproc_k % process_grouping_k == 0 &&
"While this will still work, may not bring expected results. Try having a process grouping number that divides the number of proc allocated to this direction.");
388 if (nproc_i * nproc_j * nproc_k > available_nproc)
390 Cerr <<
"Error in Domaine_IJK::initialize_splitting(nproc_i =" << nproc_i
391 <<
", nproc_j =" << nproc_j
392 <<
", nproc_k =" << nproc_k
393 <<
"): requested splitting larger than available processor number (" << available_nproc <<
")" << finl;
401 Cerr <<
"Error in Domaine_IJK::initialize_splitting(nproc_i = " << nproc_i
402 <<
", nproc_j = " << nproc_j
403 <<
", nproc_k = " << nproc_k
404 <<
"): requested splitting larger than total number of cells in one direction";
405 Cerr <<
"\n (number of cells: "
413 VECT(ArrOfInt) sizes_all_slices(3);
415 mapping.
resize(nproc_i, nproc_j, nproc_k);
422 process_grouping[0] = process_grouping_i;
423 process_grouping[1] = process_grouping_j;
424 process_grouping[2] = process_grouping_k;
426 nprocdir[0] = nproc_i;
427 nprocdir[1] = nproc_j;
428 nprocdir[2] = nproc_k;
430 for (
int i = 0; i < 3; i++)
432 while (nprocdir[i] % process_grouping[i] != 0)
433 process_grouping[i] /= 2;
434 ngroups[i] = nprocdir[i] / process_grouping[i];
439 for (
int k = 0; k < ngroups[2]; k++)
441 for (
int j = 0; j < ngroups[1]; j++)
443 for (
int i = 0; i < ngroups[0]; i++)
446 for (
int k2 = 0; k2 < process_grouping[2]; k2++)
448 for (
int j2 = 0; j2 < process_grouping[1]; j2++)
450 for (
int i2 = 0; i2 < process_grouping[0]; i2++)
453 p = (p * ngroups[1]) + j;
454 p = (p * ngroups[0]) + i;
455 p = (p * process_grouping[2]) + k2;
456 p = (p * process_grouping[1]) + j2;
457 p = (p * process_grouping[0]) + i2;
458 int iposition = i * process_grouping[0] + i2;
459 int jposition = j * process_grouping[1] + j2;
460 int kposition = k * process_grouping[2] + k2;
461 mapping(iposition, jposition, kposition) = p;
470 for (
int i = 0; i < 3; i++)
474 sizes_all_slices[i].resize_array(n);
475 for (
int j = 0; j < n; j++)
477 sizes_all_slices[i][j] = (ne * (j+1) / n) - (ne * j / n);
482 envoyer_broadcast(mapping, 0);
483 envoyer_broadcast(sizes_all_slices, 0);
486 initialize_mapping(geom, sizes_all_slices[0], sizes_all_slices[1], sizes_all_slices[2], mapping);
505 const ArrOfInt& slice_size_j,
506 const ArrOfInt& slice_size_k,
507 const IntTab& processor_mapping)
516 mapping_ = processor_mapping;
517 sizes_all_slices_[0] = slice_size_i;
518 sizes_all_slices_[1] = slice_size_j;
519 sizes_all_slices_[2] = slice_size_k;
520 for (
int i = 0; i < 3; i++)
522 const int n = sizes_all_slices_[i].size_array();
523 nproc_per_direction_[i] = n;
524 offsets_all_slices_[i].resize_array(n);
525 offsets_all_slices_[i][0] = 0;
526 for (
int j = 1; j < n; ++j)
527 offsets_all_slices_[i][j] = offsets_all_slices_[i][j - 1] + sizes_all_slices_[i][j - 1];
528 assert(offsets_all_slices_[i][n - 1] + sizes_all_slices_[i][n - 1] == geom.
get_nb_elem_tot(i));
532 processor_position_[0] = processor_position_[1] = processor_position_[2] = -1;
534 int pos_i = -1, pos_j = -1, pos_k = -1;
536 for (pos_k = 0; pos_k < nproc_per_direction_[2]; pos_k++)
538 for (pos_j = 0; pos_j < nproc_per_direction_[1]; pos_j++)
540 for (pos_i = 0; pos_i < nproc_per_direction_[0]; pos_i++)
542 int numproc = mapping_(pos_i, pos_j, pos_k);
544 if (numproc == myrank)
548 processor_position_[0] = pos_i;
549 processor_position_[1] = pos_j;
550 processor_position_[2] = pos_k;
560 for (
int i = 0; i < 3; ++i)
562 nb_elem_local_[i] = 0;
563 nb_nodes_local_[i] = 0;
564 for (
int j = 0; j < 3; ++j)
566 nb_faces_local_[i][j] = 0;
567 nb_edges_local_[i][j] = 0;
570 neighbour_processors_[0][i] = -1;
571 neighbour_processors_[1][i] = -1;
576 for (
int i = 0; i < 3; ++i)
578 nb_elem_local_[i] = sizes_all_slices_[i][processor_position_[i]];
579 nb_nodes_local_[i] = nb_elem_local_[i];
580 if (!geom.
get_periodic_flag(i) && processor_position_[i] == nproc_per_direction_[i] -1)
584 nb_nodes_local_[i]++;
586 for (
int j = 0; j < 3; ++j)
592 nb_faces_local_[j][i] = nb_nodes_local_[i];
594 nb_faces_local_[j][i] = nb_elem_local_[i];
596 nb_edges_local_[j][i] = nb_elem_local_[i];
598 nb_edges_local_[j][i] = nb_nodes_local_[i];
600 offset_[i] = offsets_all_slices_[i][processor_position_[i]];
603 for (
int i = 0; i < 3; ++i)
605 for (
int previous_or_next = 0; previous_or_next < 2; previous_or_next++)
608 if (previous_or_next == 0)
612 if (other_pos[i] < 0 || other_pos[i] >= nproc_per_direction_[i])
617 other_pos[i] = nproc_per_direction_[i] - 1 - processor_position_[i];
622 if (other_pos[i] >= 0)
624 neighbour_processors_[previous_or_next][i] = mapping_(other_pos[0], other_pos[1], other_pos[2]);
629 neighbour_processors_[previous_or_next][i] = -1;
634 Journal() <<
"Domaine_IJK::initialize_mapping:\n"
635 <<
" processor_position =" << print_vect(processor_position_) <<
"\n"
636 <<
" offset =" << print_vect(offset_) <<
"\n"
637 <<
" nb_elem_local =" << print_vect(nb_elem_local_) <<
"\n";
638 Journal() <<
" neighbour_procs = left:" << print_vect(neighbour_processors_[0])
639 <<
" right:" << print_vect(neighbour_processors_[1]) << finl;
656 const ArrOfDouble& delta_x,
657 const ArrOfDouble& delta_y,
658 const ArrOfDouble& delta_z,
659 bool perio_x,
bool perio_y,
bool perio_z)
661 periodic_[0] = perio_x;
662 periodic_[1] = perio_y;
663 periodic_[2] = perio_z;
667 delta_xyz_[0] = delta_x;
668 delta_xyz_[1] = delta_y;
669 delta_xyz_[2] = delta_z;
670 for (
int dir = 0; dir < 3; ++dir)
672 int n = delta_xyz_[dir].size_array();
673 node_coordinates_xyz_[dir].resize_array(n+1);
674 node_coordinates_xyz_[dir][0] = (dir == 0) ? x0 : ((dir == 1) ? y0 : z0);
675 double mindelta = 1e30;
676 double maxdelta = 0.;
677 for (
int i = 0; i < n; i++)
679 const double d = delta_xyz_[dir][i];
680 node_coordinates_xyz_[dir][i+1] = node_coordinates_xyz_[dir][i] + d;
681 mindelta = std::min(d, mindelta);
682 maxdelta = std::max(d, maxdelta);
684 if (maxdelta - mindelta < eps)
686 uniform_[dir] =
true;
690 uniform_[dir] =
false;
716 int offset_i,
int offset_j,
int offset_k,
717 const Nom& subregion_name,
718 bool perio_x,
bool perio_y,
bool perio_z )
727 assert(src.nproc_per_direction_[0] == 1 || (ni == src.
get_nb_elem_tot(0) && offset_i == 0));
728 assert(src.nproc_per_direction_[1] == 1 || (nj == src.
get_nb_elem_tot(1) && offset_j == 0));
729 assert(src.nproc_per_direction_[2] == 1 || (nk == src.
get_nb_elem_tot(2) && offset_k == 0));
738 ArrOfDouble dx, dy, dz;
747 int nproc_i = src.nproc_per_direction_[0];
748 int nproc_j = src.nproc_per_direction_[1];
749 int nproc_k = src.nproc_per_direction_[2];
767 const ArrOfInt& slice_size_j,
768 const ArrOfInt& slice_size_k,
769 const IntTab& processor_mapping)
779 mapping_ = processor_mapping;
780 sizes_all_slices_[0] = slice_size_i;
781 sizes_all_slices_[1] = slice_size_j;
782 sizes_all_slices_[2] = slice_size_k;
783 for (
int i = 0; i < 3; i++)
785 const int n = sizes_all_slices_[i].size_array();
786 nproc_per_direction_[i] = n;
787 offsets_all_slices_[i].resize_array(n);
788 offsets_all_slices_[i][0] = 0;
789 for (
int j = 1; j < n; j++)
791 offsets_all_slices_[i][j] = offsets_all_slices_[i][j-1] + sizes_all_slices_[i][j-1];
793 assert(offsets_all_slices_[i][n-1] + sizes_all_slices_[i][n-1] ==
get_nb_elem_tot(i));
797 processor_position_[0] = processor_position_[1] = processor_position_[2] = -1;
799 int pos_i = -1, pos_j = -1, pos_k = -1;
801 for (pos_k = 0; pos_k < nproc_per_direction_[2]; pos_k++)
803 for (pos_j = 0; pos_j < nproc_per_direction_[1]; pos_j++)
805 for (pos_i = 0; pos_i < nproc_per_direction_[0]; pos_i++)
807 int numproc = mapping_(pos_i,pos_j,pos_k);
809 if (numproc == myrank)
813 processor_position_[0] = pos_i;
814 processor_position_[1] = pos_j;
815 processor_position_[2] = pos_k;
825 for (
int i = 0; i < 3; i++)
827 nb_elem_local_[i] = 0;
828 nb_nodes_local_[i] = 0;
829 for (
int j = 0; j < 3; j++)
830 nb_faces_local_[i][j] = 0;
832 neighbour_processors_[0][i] = -1;
833 neighbour_processors_[1][i] = -1;
838 for (
int i = 0; i < 3; i++)
840 nb_elem_local_[i] = sizes_all_slices_[i][processor_position_[i]];
841 nb_nodes_local_[i] = nb_elem_local_[i];
842 if (!
get_periodic_flag(i) && processor_position_[i] == nproc_per_direction_[i]-1)
846 nb_nodes_local_[i]++;
848 for (
int j = 0; j < 3; j++)
854 nb_faces_local_[j][i] = nb_nodes_local_[i];
856 nb_faces_local_[j][i] = nb_elem_local_[i];
858 offset_[i] = offsets_all_slices_[i][processor_position_[i]];
861 for (
int i = 0; i < 3; i++)
863 for (
int previous_or_next = 0; previous_or_next < 2; previous_or_next++)
865 Int3 other_pos(processor_position_);
866 if (previous_or_next == 0)
870 if (other_pos[i] < 0 || other_pos[i] >= nproc_per_direction_[i])
875 other_pos[i] = nproc_per_direction_[i] - 1 - processor_position_[i];
882 if (other_pos[i] >= 0)
884 neighbour_processors_[previous_or_next][i] = mapping_(other_pos[0], other_pos[1], other_pos[2]);
889 neighbour_processors_[previous_or_next][i] = -1;
894 Journal() <<
"Domaine_IJK::initialize_with_mapping:\n"
895 <<
" processor_position=" << print_vect(processor_position_) <<
"\n"
896 <<
" offset =" << print_vect(offset_) <<
"\n"
897 <<
" nb_elem_local =" << print_vect(nb_elem_local_) <<
"\n";
898 Journal() <<
" neighbour_procs = left:" << print_vect(neighbour_processors_[0])
899 <<
" right:" << print_vect(neighbour_processors_[1]) << finl;
906 Faces* les_faces =
new(Faces);
922 assert(direction >= 0 && direction < 3);
954 assert(direction >= 0 && direction < 3);
973 ArrOfDouble_with_ghost& delta)
const
977 const ArrOfDouble& global_delta =
get_delta(direction);
979 delta.
resize(nlocal, ghost_cells);
981 if (ghost_cells > ntot)
983 Cerr <<
"Error in Domaine_IJK::get_local_mesh_delta(dir = "<<direction<<
",ghost_cells = "<<ghost_cells<<
")\n"
984 <<
"Number of ghost cells larger than number of nodes (" << ntot <<
") in the domain !" << finl;
988 for (
int ilocal = -ghost_cells; ilocal < nlocal + ghost_cells; ilocal++)
990 const int iglobal = ilocal + offset;
995 d = global_delta[iglobal + ntot];
999 else if (iglobal >= ntot)
1002 d = global_delta[iglobal - ntot];
1004 d = global_delta[ntot - 1];
1007 d = global_delta[iglobal];
1026 assert(direction >= 0 && direction < 3);
1029 if (!periodic_[direction])
1080 assert(direction >= 0 && direction < 3);
1081 tab = sizes_all_slices_[direction];
1083 if (!periodic_[direction])
1093 if (direction != 0) tab[n]++;
1096 if (direction != 1) tab[n]++;
1099 if (direction != 2) tab[n]++;
1102 if (direction == 0) tab[n]++;
1105 if (direction == 1) tab[n]++;
1108 if (direction == 2) tab[n]++;
1131 int gi = i + offset_[0];
1132 int gj = j + offset_[1];
1133 int gk = k + offset_[2];
1163 return (k * nbmailles_euler_j + j) * nbmailles_euler_i + i;
1180 ijk[0] = ijk[1] = ijk[2] = -1;
1183 ijk[0] = index % nbmailles_euler_i;
1184 index /= nbmailles_euler_i;
1185 ijk[1] = index % nbmailles_euler_j;
1186 index /= nbmailles_euler_j;
1214 for (
int dir = 0; dir < 3; ++dir)
1218 const double val = (coords[dir] - o) / d;
1219 const int ival = (int)std::lrint(std::floor(val));
1220 ijk_global[dir] = ival;
1224 if ((ival >= ioff) && (ival < ioff + n_loc))
1227 ijk_local[dir] = ival - ioff;
1237 if(volume_elem_status_ ==
DONE)
1248 const int nsize = nx * ny * nz;
1249 volume_elem_.resize(nsize);
1252 double size_elem = 0.;
1254 int nb_uniform_axis = 0;
1255 int not_uniform = -1;
1256 for(
int dir = 0; dir < 3; ++dir)
1263 const ArrOfDouble& sizes_x =
get_delta(0);
1264 const ArrOfDouble& sizes_y =
get_delta(1);
1265 const ArrOfDouble& sizes_z =
get_delta(2);
1266 switch(nb_uniform_axis)
1269 size_elem = size_x * size_y * size_z;
1270 volume_elem_ = size_elem;
1271 volume_elem_status_ =
DONE;
1274 for(
int dir = 0; dir < 3; ++dir)
1277 if(not_uniform == 0)
1280 for(
int idz = 0; idz < nz; ++idz)
1281 for(
int idy = 0; idy < ny; ++idy)
1282 for(
int idx = 0; idx < nx; ++idx)
1284 size_elem = sizes_x[idx] * size_y * size_z;
1285 volume_elem_[(idz * ny * nx) +(idy * nx) + idx] = size_elem;
1288 else if(not_uniform == 1)
1291 for(
int idz = 0; idz < nz; ++idz)
1292 for(
int idy = 0; idy < ny; ++idy)
1293 for(
int idx = 0; idx < nx; ++idx)
1295 size_elem = size_x * sizes_y[idy] * size_z;
1296 volume_elem_[(idz * ny * nx) +(idy * nx) + idx] = size_elem;
1299 else if(not_uniform == 2)
1302 for(
int idz = 0; idz < nz; ++idz)
1303 for(
int idy = 0; idy < ny; ++idy)
1304 for(
int idx = 0; idx < nx; ++idx)
1306 size_elem = size_x * size_y * sizes_z[idz];
1307 volume_elem_[(idz * ny * nx) +(idy * nx) + idx] = size_elem;
1312 Cerr <<
"Error in Maillage_Ft_IJK::update_volume_elem !!! No direction selected?!" <<finl;
1316 volume_elem_status_ =
DONE;
1325 if(not_uniform == 23)
1329 for(
int idz = 0; idz < nz; ++idz)
1330 for(
int idy = 0; idy < ny; ++idy)
1331 for(
int idx = 0; idx < nx; ++idx)
1333 size_elem = size_x * sizes_y[idy] * sizes_z[idz];
1334 volume_elem_[(idz * ny * nx) +(idy * nx) + idx] = size_elem;
1337 else if(not_uniform == 13)
1341 for(
int idz = 0; idz < nz; ++idz)
1342 for(
int idy = 0; idy < ny; ++idy)
1343 for(
int idx = 0; idx < nx; ++idx)
1345 size_elem = sizes_x[idx] * size_y * sizes_z[idz];
1346 volume_elem_[(idz * ny * nx) +(idy * nx) + idx] = size_elem;
1349 else if(not_uniform == 12)
1353 for(
int idz = 0; idz < nz; ++idz)
1354 for(
int idy = 0; idy < ny; ++idy)
1355 for(
int idx = 0; idx < nx; ++idx)
1357 size_elem = sizes_x[idx] * sizes_y[idy] * size_z;
1358 volume_elem_[(idz * ny * nx) +(idy * nx) + idx] = size_elem;
1363 Cerr <<
"Error in Maillage_Ft_IJK::update_volume_elem !!! No direction selected?!" <<finl;
1367 volume_elem_status_ =
DONE;
1374 for(
int idz = 0; idz < nz; ++idz)
1375 for(
int idy = 0; idy < ny; ++idy)
1376 for(
int idx = 0; idx < nx; ++idx)
1378 size_elem = sizes_x[idx] * sizes_y[idy] * sizes_z[idz];
1379 volume_elem_[(idz * ny * nx) +(idy * nx) + idx] = size_elem;
1381 volume_elem_status_ =
DONE;
1384 Cerr <<
"Error Maillage_FT_IJK::update_volume_elem" << finl;
1393 int ijk_splitting_ft_extension_from_diameter = 0;
1394 for (
int c=0; c<3; c++)
1397 ijk_splitting_ft_extension_from_diameter = std::max(ijk_splitting_ft_extension_from_diameter, (
int) ceil(diam_bulle/delta));
1399 ft_extension_ = (ijk_splitting_ft_extension_from_diameter > ft_extension_) ? ijk_splitting_ft_extension_from_diameter : ft_extension_;
1406 int periodic_slice_i = slice_i;
1407 int periodic_slice_j = slice_j;
1408 int periodic_slice_k = slice_k;
1456 int ghost_size = 256;
1460 int offset = ghost_size + (ni + 2*ghost_size)*ghost_size + (ni + 2*ghost_size)*(nj + 2*ghost_size)*ghost_size;
1461 int independent_index = offset + i + (ni + 2*ghost_size)*j + (ni + 2*ghost_size)*(nj + 2*ghost_size)*k;
1463 return independent_index;
1468 int ghost_size = 256;
1473 int k = (independent_index)/((ni + 2*ghost_size)*(nj + 2*ghost_size));
1474 int j = ((independent_index) - (ni + 2*ghost_size)*(nj + 2*ghost_size)*k)/(ni + 2*ghost_size);
1475 int i = (independent_index) - (ni + 2*ghost_size)*(nj + 2*ghost_size)*k - (ni + 2*ghost_size)*j;
1482 Int3 ijk = {i, j, k};
1493 return signed_independent_index;
1498 int independent_index = (signed_independent_index < 0) ? -1 - signed_independent_index : signed_independent_index;
1499 return independent_index;
1504 int phase = (signed_independent_index < 0) ? 1 : 0;
1512 bool i_within_ghost = ((i >= -negative_ghost_size) && (i <
get_nb_elem_local(0) + positive_ghost_size));
1513 bool j_within_ghost = ((j >= -negative_ghost_size) && (j <
get_nb_elem_local(1) + positive_ghost_size));
1514 bool k_within_ghost = ((k >= -negative_ghost_size) && (k <
get_nb_elem_local(2) + positive_ghost_size));
1516 return (i_within_ghost && j_within_ghost && k_within_ghost);
1523 assert(dir >= 0 && dir < 3);
1529 bool i_within_ghost = ((i >= -negative_ghost_size) && (i <
get_nb_elem_local(0) + positive_ghost_size));
1530 bool j_within_ghost = ((j >= -negative_ghost_size) && (j <
get_nb_elem_local(1) + positive_ghost_size));
1531 bool k_within_ghost = ((k >= -negative_ghost_size) && (k <
get_nb_elem_local(2) + positive_ghost_size));
1533 bool case_i_outside = (i_within_ghost && j_local && k_local);
1534 bool case_j_outside = (i_local && j_within_ghost && k_local);
1535 bool case_k_outside = (i_local && j_local && k_within_ghost);
1537 return select_dir(dir, case_i_outside, case_j_outside, case_k_outside);
1552 if ((index < 0) && (index + ng - n + 1 < -index))
1556 else if ((index >= n) && (-(index - ng) < index - n + 1))
1564 Cerr <<
"Error: In correct_perio_i_local(), the case of a non-uniform mesh along direction " << direction <<
" is not implemented." << finl;
1578 double origin_dir =
get_origin(direction) - .5*d*loc_equal_dir;
1583 index = (int)(std::floor((coord_dir - origin_dir)/d)) - offset_dir;
1587 Cerr <<
"Error: get_i_along_dir_no_perio(), the case of a non-uniform mesh along direction " << direction <<
" is not implemented." << finl;
1607 Int3 ijk = {i, j, k};
This class encapsulates all the information related to the eulerian mesh for TrioIJK.
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_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_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".
bool get_periodic_flag(int direction) const
Method returns true if periodic in this direction.
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.
double get_constant_delta(int direction) const
Returns the size of cells in a direction.
int get_phase_from_signed_independent_index(int signed_independent_index) const
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
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.
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.
Localisation
Localisation sub class.
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...
void nommer(const Nom &nom) override
Donne un nom a l'Objet_U Methode virtuelle a surcharger.
const Nom & le_nom() const override
Donne le nom de l'Objet_U Methode a surcharger : renvoie "neant" dans cette implementation.
Class defining operators and methods for all reading operation in an input flow (file,...
void resize(int n, int new_ghost)
class Nom Une chaine de caractere pour nommer les objets de TRUST
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
static double precision_geom
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
static Sortie & Journal(int message_level=0)
Renvoie un objet statique de type Sortie qui sert de journal d'evenements.
static int nproc()
renvoie le nombre de processeurs dans le groupe courant Voir Comm_Group::nproc() et PE_Groups::curren...
static int me()
renvoie mon rang dans le groupe de communication courant.
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
static int je_suis_maitre()
renvoie 1 si on est sur le processeur maitre du groupe courant (c'est a dire me() == 0),...
Classe de base des flux de sortie.
_SIZE_ size_array() const
virtual void ref_array(TRUSTArray &, _SIZE_ start=0, _SIZE_ sz=-1)
TRUSTArray & inject_array(const TRUSTArray &source, _SIZE_ nb_elements=-1, _SIZE_ first_element_dest=0, _SIZE_ first_element_source=0)
void resize_array(_SIZE_ new_size, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
_SIZE_ dimension(int d) const