16#include <Corrige_flux_FT_temperature_subresolution.h>
17#include <IJK_Field_vector.h>
18#include <Probleme_FTD_IJK.h>
22Corrige_flux_FT_temperature_subresolution::Corrige_flux_FT_temperature_subresolution()
145 for (
int k=0; k<(int) indices_to_clear.size(); k++)
146 indices_to_clear[k].reset();
150 for (
int k=0; k<(int) values_to_clear.size(); k++)
151 values_to_clear[k].reset();
154static int compute_periodic_index(
const int index,
const int n)
156 return (n + index % n) % n;
160 const IJK_Field_double& field,
184 Cerr <<
"The intersections have been updated" << finl;
204 int index_i_problem = 0;
205 int index_j_problem = 0;
206 int index_k_problem = 0;
208 for (problem_index=0; problem_index<nb_effective_subproblems; problem_index++)
210 thermal_subproblems_->get_subproblem_ijk_indices(index_i_problem, index_j_problem, index_k_problem, problem_index);
211 const int ijk_intersections_index = (*intersection_ijk_cell_)(index_i_problem, index_j_problem, index_k_problem);
212 if (ijk_intersections_index > -1)
219 Cerr <<
"Inconsistency between intersection_ijk_cell and the thermal_subproblem (index " << problem_index <<
")" << finl;
226 Cerr <<
"There is an inconsistency between the LRS sub-problem and the intersection_ijk_elem" << finl;
231 Cerr <<
"Inconsistency has already be checked" << finl;
249 DoubleTab dist_interf;
259 double dist_sub_res = 0;
260 double temperature_ghost = 0.;
261 int intersection_ijk_cell_index = 0;
262 int ijk_indices_i = 0;
263 int ijk_indices_j = 0;
264 int ijk_indices_k = 0;
269 dist = dist_interf(intersection_ijk_cell_index, 0);
271 ijk_indices_i = (*intersection_ijk_cell_)(intersection_ijk_cell_index, 0);
272 ijk_indices_j = (*intersection_ijk_cell_)(intersection_ijk_cell_index, 1);
273 ijk_indices_k = (*intersection_ijk_cell_)(intersection_ijk_cell_index, 2);
278 thermal_subproblems_->get_subproblem_ijk_indices(ijk_indices_i, ijk_indices_j, ijk_indices_k, i);
281 temperature(ijk_indices_i, ijk_indices_j, ijk_indices_k) = temperature_ghost;
285 Cerr <<
"Time-step: " << ref_ijk_ft_->schema_temps_ijk().get_tstep() <<
"--" << ref_ijk_ft_->schema_temps_ijk().get_timestep() <<
" s" << finl;
288 Cerr <<
"Distance at cell : " << intersection_ijk_cell_index <<
289 ", subproblem " << i <<
"."<<
290 " -- (" << ijk_indices_i <<
", " << ijk_indices_j <<
", " << ijk_indices_k <<
")" << finl;
291 Cerr <<
"Distance from intersection_ijk_cell: " << dist << finl;
293 Cerr <<
"Distance from sub-resolution: " << dist_sub_res << finl;
295 Cerr <<
"Facet barycentre: " << bary_facet_debug[0] <<
";"
296 << bary_facet_debug[1] <<
";"
297 << bary_facet_debug[2] << finl;
299 const IJK_Field_double& indicator = ref_ijk_ft_->get_interface().I();
300 const double indic = indicator(ijk_indices_i, ijk_indices_j, ijk_indices_k);
301 if (temperature_ghost < min_temperature && indic > 0.5)
302 Cerr <<
"Ghost temperature: " << temperature_ghost <<
" is lower than the minimum temperature:" << min_temperature << finl;
303 if (temperature_ghost > max_temperature && indic > 0.5)
304 Cerr <<
"Ghost temperature: " << temperature_ghost <<
" is higher than the maximum temperature:" << max_temperature << finl;
310 IJK_Field_int& neighbours_weighting,
311 IJK_Field_double& neighbours_weighting_colinearity)
316 const int ni = neighbours_weighting.
ni();
317 const int nj = neighbours_weighting.
nj();
318 const int nk = neighbours_weighting.
nk();
328 neighbours_weighting.
data() = 0;
330 temperature_neighbours.
data() = 0.;
334 neighbours_weighting_colinearity.
data() = 0.;
337 std::vector<std::vector<std::vector<double>>> pure_neighbours_corrected_colinearity;
338 int index_i_problem, index_j_problem, index_k_problem;
339 int index_i_neighbour, index_j_neighbour, index_k_neighbour;
340 int index_i_procs, index_j_procs, index_k_procs;
341 int index_i_neighbour_global, index_j_neighbour_global, index_k_neighbour_global;
343 double neighbours_colinearity = 0.;
348 thermal_subproblems_->get_subproblem_ijk_indices(index_i_problem, index_j_problem, index_k_problem, i);
350 const std::vector<std::vector<std::vector<bool>>>& pure_neighbours_to_correct =
thermal_subproblems_->get_pure_neighbours_to_correct(i);
351 const std::vector<std::vector<std::vector<double>>>& pure_neighbours_corrected_distance =
thermal_subproblems_->get_pure_neighbours_corrected_distance(i);
353 pure_neighbours_corrected_colinearity =
thermal_subproblems_->get_pure_neighbours_corrected_colinearity(i);
354 const int l_dir_size = (int) pure_neighbours_to_correct.size() -1;
355 const int m_dir_size = (int) pure_neighbours_to_correct[0].size() -1;
356 const int n_dir_size = (int) pure_neighbours_to_correct[0][0].size() -1;
357 for (l=l_dir_size; l>=0; l--)
358 for (m=m_dir_size; m>=0; m--)
359 for (n=n_dir_size; n>=0; n--)
360 if (pure_neighbours_to_correct[l][m][n])
362 const double dist_sub_res = pure_neighbours_corrected_distance[l][m][n];
363 const double temperature_ghost =
thermal_subproblems_->get_temperature_profile_at_point(i, dist_sub_res);
364 index_i_neighbour = index_i_problem + ((pure_neighbours_corrected_sign[0]) ? l * (-1) : l);
365 index_j_neighbour = index_j_problem + ((pure_neighbours_corrected_sign[1]) ? m * (-1) : m);
366 index_k_neighbour = index_k_problem + ((pure_neighbours_corrected_sign[2]) ? n * (-1) : n);
370 index_i_neighbour_global = compute_periodic_index((index_i_neighbour + offset_i), ni_tot);
371 index_j_neighbour_global = compute_periodic_index((index_j_neighbour + offset_j), nj_tot);
372 index_k_neighbour_global = compute_periodic_index((index_k_neighbour + offset_k), nk_tot);
373 index_i_procs = compute_periodic_index(index_i_neighbour, ni);
374 index_j_procs = compute_periodic_index(index_j_neighbour, nj);
375 index_k_procs = compute_periodic_index(index_k_neighbour, nk);
377 neighbours_colinearity = pure_neighbours_corrected_colinearity[l][m][n];
378 if (index_i_procs == index_i_neighbour
379 && index_j_procs == index_j_neighbour
380 && index_k_procs == index_k_neighbour)
384 neighbours_weighting_colinearity(index_i_neighbour, index_j_neighbour, index_k_neighbour)
385 += neighbours_colinearity;
386 temperature_neighbours(index_i_neighbour, index_j_neighbour, index_k_neighbour)
387 += temperature_ghost * neighbours_colinearity;
390 temperature_neighbours(index_i_neighbour, index_j_neighbour, index_k_neighbour) += temperature_ghost;
391 neighbours_weighting(index_i_neighbour, index_j_neighbour, index_k_neighbour) += 1;
396 neighbours_colinearity,
397 index_i_neighbour_global,
398 index_j_neighbour_global,
399 index_k_neighbour_global);
406 neighbours_weighting,
407 neighbours_weighting_colinearity,
423 const double& neighbours_weighting_colinearity,
424 const int& index_i_neighbour_global,
425 const int& index_j_neighbour_global,
426 const int& index_k_neighbour_global)
438 Cerr <<
"Copy temperature on every processors" << finl;
445 ArrOfInt local_indices_tmp;
446 ArrOfDouble local_values_tmp;
449 int size_vector_total = size_vector;
452 ArrOfInt overall_numerotation(nb_procs);
453 ArrOfInt start_indices(nb_procs);
454 overall_numerotation(proc_num) = size_vector;
457 for (l=1; l<overall_numerotation.
size_array(); l++)
458 start_indices(l) = start_indices(l-1) + overall_numerotation(l-1);
460 for (
int c=0; c<3; c++)
465 for (l=0; l<local_indices_tmp.
size_array(); l++)
468 local_indices_tmp.
reset();
473 for (l=0; l<local_values_tmp.
size_array(); l++)
480 for (l=0; l<local_values_tmp.
size_array(); l++)
484 for (
int c=0; c<3; c++)
498 IJK_Field_int& neighbours_weighting,
499 IJK_Field_double& neighbours_weighting_colinearity,
507 Cerr <<
"Combine temperature on every processors" << finl;
511 int index_i_local, index_j_local, index_k_local;
512 for (
int l=0; l<size_array; l++)
517 if ((0 <= index_i_local && index_i_local < ni) &&
518 (0 <= index_j_local && index_j_local < nj) &&
519 (0 <= index_k_local && index_k_local < nk))
522 neighbours_weighting(index_i_local, index_j_local, index_k_local) += 1;
526 neighbours_weighting_colinearity(index_i_local, index_j_local, index_k_local) += colinearity;
527 temperature_neighbours(index_i_local, index_j_local, index_k_local) += colinearity * temperature_ghost;
530 temperature_neighbours(index_i_local, index_j_local, index_k_local) += temperature_ghost;
537 const int nb_k_layer)
539 for (
int l=0; l<2; l++)
541 for (
int dir=0; dir<2; dir++)
542 fixed_vectors[l][dir].resize(nb_k_layer);
543 fixed_vectors[l][2].resize(nb_k_layer + 1);
548 const int nb_k_layer)
550 for (
int dir=0; dir<2; dir++)
551 fixed_vector[dir].resize(nb_k_layer);
552 fixed_vector[2].resize(nb_k_layer + 1);
556 const int nb_k_layer)
558 for (
int dir=0; dir<2; dir++)
559 fixed_vector_values[dir].resize(nb_k_layer);
560 fixed_vector_values[2].resize(nb_k_layer + 1);
564 const int global_indices)
568 nb_k_layer = ref_ijk_ft_->get_interface().I().get_domaine().get_nb_elem_tot(2);
570 nb_k_layer = ref_ijk_ft_->get_interface().I().nk();
572 const int first_iter = !(ref_ijk_ft_->schema_temps_ijk().get_tstep());
579 for (dir=0; dir<3; dir++)
580 for (
int k_layer=0; k_layer<nb_k_layer+1; k_layer++)
582 if ((dir==DIRECTION_I || dir==DIRECTION_J) && k_layer==nb_k_layer)
584 index_face_ij_flux_xyz_faces_sorted[l][dir][k_layer].reset();
590 FixedVector<std::vector<ArrOfInt>,3>& weighting_flux_xyz_faces_sorted,
591 FixedVector<std::vector<ArrOfDouble>,3>& colinearity_flux_xyz_faces_sorted,
592 FixedVector<std::vector<ArrOfDouble>,3>& temperature_flux_xyz_faces_sorted,
593 const bool& ini_index,
594 const int global_indices,
595 const int weighting_colinearity)
603 nb_k_layer = ref_ijk_ft_->get_interface().I().get_domaine().get_nb_elem_tot(2);
605 nb_k_layer = ref_ijk_ft_->get_interface().I().nk();
607 const int first_iter = !(ref_ijk_ft_->schema_temps_ijk().get_tstep());
612 if (weighting_colinearity && !ini_index)
622 for (dir=0; dir<3; dir++)
623 for (
int k_layer=0; k_layer<nb_k_layer+1; k_layer++)
625 if ((dir==DIRECTION_I || dir==DIRECTION_J) && k_layer==nb_k_layer)
627 fluxes[dir][k_layer].reset();
628 if (weighting_colinearity && !ini_index)
630 weighting_flux_xyz_faces_sorted[dir][k_layer].reset();
631 colinearity_flux_xyz_faces_sorted[dir][k_layer].reset();
632 temperature_flux_xyz_faces_sorted[dir][k_layer].reset();
662 Cerr <<
"Thermal Sub-resolutions all reachable convective fluxes variables are now initialised" << finl;
675 Cerr <<
"Thermal Sub-resolutions all reachable diffusive fluxes variables are now initialised" << finl;
686 Cerr <<
"Sort the thermal min-max reachable convective fluxes" << finl;
695 Cerr <<
"Thermal Sub-resolutions min-max reachable convective fluxes variables are now initialised" << finl;
700 Cerr <<
"Sort the thermal diffusive min-max reachable fluxes" << finl;
709 Cerr <<
"Thermal Sub-resolutions min-max reachable diffusive fluxes variables are now initialised" << finl;
724 for (
int c=0; c<3; c++)
726 (*cell_faces_neighbours_corrected_bool_).echange_espace_virtuel();
727 const int nb_i_layer = ref_ijk_ft_->get_interface().I().ni();
728 const int nb_j_layer = ref_ijk_ft_->get_interface().I().nj();
729 const int nb_k_layer = ref_ijk_ft_->get_interface().I().nk();
734 int index_i_problem, index_j_problem, index_k_problem;
739 thermal_subproblems_->get_subproblem_ijk_indices(index_i_problem, index_j_problem, index_k_problem, i);
741 const std::vector<std::vector<std::vector<bool>>>& pure_neighbours_to_correct =
thermal_subproblems_->get_pure_neighbours_to_correct(i);
742 const int l_dir_size = (int) pure_neighbours_to_correct.size() -1;
743 const int m_dir_size = (int) pure_neighbours_to_correct[0].size() -1;
744 const int n_dir_size = (int) pure_neighbours_to_correct[0][0].size() -1;
745 for (l=l_dir_size; l>=0; l--)
746 for (m=m_dir_size; m>=0; m--)
747 for (n=n_dir_size; n>=0; n--)
748 if (l <= n_iter_distance && m <= n_iter_distance && n <= n_iter_distance)
749 if (pure_neighbours_to_correct[l][m][n] && ((l!=0 && m!=0) || (l!=0 && n!=0) || (m!=0 && n!=0)))
751 const int i_offset = ((pure_neighbours_corrected_sign[0]) ? l * (-1) : l);
752 const int j_offset = ((pure_neighbours_corrected_sign[1]) ? m * (-1) : m);
753 const int k_offset = ((pure_neighbours_corrected_sign[2]) ? n * (-1) : n);
754 const int index_i_neighbour = index_i_problem + i_offset;
755 const int index_j_neighbour = index_j_problem + j_offset;
756 const int index_k_neighbour = index_k_problem + k_offset;
757 const int i_offset_face = ((signbit(i_offset)) ? (index_i_neighbour + 1) : index_i_neighbour);
758 const int j_offset_face = ((signbit(j_offset)) ? (index_j_neighbour + 1) : index_j_neighbour);
759 const int k_offset_face = ((signbit(k_offset)) ? (index_k_neighbour + 1) : index_k_neighbour);
767 (*cell_faces_neighbours_corrected_bool_)[0](i_offset_face, index_j_neighbour, index_k_neighbour) += 1;
768 if (i_offset_face == 0)
775 (*cell_faces_neighbours_corrected_bool_)[0](nb_i_layer, index_j_neighbour, index_k_neighbour) += 1;
777 if (i_offset_face == nb_i_layer)
784 (*cell_faces_neighbours_corrected_bool_)[0](0, index_j_neighbour, index_k_neighbour) += 1;
794 (*cell_faces_neighbours_corrected_bool_)[1](index_i_neighbour, j_offset_face, index_k_neighbour) += 1;
795 if (j_offset_face == 0)
802 (*cell_faces_neighbours_corrected_bool_)[1](index_i_neighbour, nb_j_layer, index_k_neighbour) += 1;
804 if (i_offset_face == nb_j_layer)
811 (*cell_faces_neighbours_corrected_bool_)[1](index_i_neighbour, 0, index_k_neighbour) += 1;
821 (*cell_faces_neighbours_corrected_bool_)[2](index_i_neighbour, index_j_neighbour, k_offset_face) += 1;
822 if (j_offset_face == 0)
829 (*cell_faces_neighbours_corrected_bool_)[2](index_i_neighbour, index_j_neighbour, nb_k_layer) += 1;
831 if (i_offset_face == nb_k_layer)
838 (*cell_faces_neighbours_corrected_bool_)[2](index_i_neighbour, index_j_neighbour, 0) += 1;
844 (*cell_faces_neighbours_corrected_bool_).echange_espace_virtuel();
861 bool_a = (*cell_faces_neighbours_corrected_bool_)[dir](i, j, k_layer);
862 bool_a = bool_a || (*cell_faces_neighbours_corrected_bool_)[dir](i, j, k_layer);
863 bool_a = bool_a || (*cell_faces_neighbours_corrected_bool_)[dir](i, j, k_layer);
864 bool_b = (*cell_faces_neighbours_corrected_bool_)[dir](i+1, j, k_layer);
865 bool_b = bool_b || (*cell_faces_neighbours_corrected_bool_)[dir](i, j+1, k_layer);
866 bool_b = bool_b || (*cell_faces_neighbours_corrected_bool_)[dir](i, j, k_layer + 1);
867 if (bool_a || bool_b)
878 IJK_Field_vector3_double& cell_faces_neighbours_corrected_velocity_temperature,
879 IJK_Field_vector3_double& cell_faces_neighbours_corrected_convective_mixed_cell,
880 IJK_Field_vector3_double& cell_faces_neighbours_corrected_diffusive_mixed_cell,
881 IJK_Field_vector3_double& neighbours_weighting_colinearity_mixed_cell)
887 const int ni = ref_ijk_ft_->get_interface().I().ni();
888 const int nj = ref_ijk_ft_->get_interface().I().nj();
889 const int nk = ref_ijk_ft_->get_interface().I().nk();
891 IJK_Field_local_int cell_faces_neighbours_corrected_bool_tmp;
892 cell_faces_neighbours_corrected_bool_tmp.
allocate(ni, nj, nk, 1);
895 for (
int c=0; c<3; c++)
897 const int index_ini = 2*c;
898 cell_faces_neighbours_corrected_bool_tmp.
data() = 0;
899 for (
int k = 0; k < nk; k++)
900 for (
int j = 0; j < nj; j++)
901 for (
int i = 0; i < ni; i++)
903 const double indic = ref_ijk_ft_->get_interface().I()(i,j,k);
904 if (indic < LIQUID_INDICATOR_TEST && indic > VAPOUR_INDICATOR_TEST)
906 for (
int l=index_ini; l<index_ini + 2; l++)
908 const int i_neighbour = NEIGHBOURS_I[l];
909 const int j_neighbour = NEIGHBOURS_J[l];
910 const int k_neighbour = NEIGHBOURS_K[l];
911 const int ii = NEIGHBOURS_FACES_I[l];
912 const int jj = NEIGHBOURS_FACES_J[l];
913 const int kk = NEIGHBOURS_FACES_K[l];
914 const int cell_faces_neighbours_ijk = cell_faces_neighbours_corrected_bool_mixed_cell[c](i + ii,j + jj, k + kk);
915 const double indic_neighbour = ref_ijk_ft_->get_interface().I()(i+i_neighbour,j+j_neighbour,k+k_neighbour);
916 if (cell_faces_neighbours_ijk && indic_neighbour > LIQUID_INDICATOR_TEST)
917 cell_faces_neighbours_corrected_bool_tmp(i+ii,j+jj,k+kk) = cell_faces_neighbours_ijk;
920 if (indic > LIQUID_INDICATOR_TEST)
922 for (
int l=index_ini; l<index_ini + 2; l++)
924 const int i_neighbour = NEIGHBOURS_I[l];
925 const int j_neighbour = NEIGHBOURS_J[l];
926 const int k_neighbour = NEIGHBOURS_K[l];
927 const int ii = NEIGHBOURS_FACES_I[l];
928 const int jj = NEIGHBOURS_FACES_J[l];
929 const int kk = NEIGHBOURS_FACES_K[l];
930 const int cell_faces_neighbours_ijk = cell_faces_neighbours_corrected_bool_mixed_cell[c](i + ii,j + jj, k + kk);
931 const double indic_neighbour = ref_ijk_ft_->get_interface().I()(i+i_neighbour,j+j_neighbour,k+k_neighbour);
932 if (cell_faces_neighbours_ijk && (indic_neighbour < LIQUID_INDICATOR_TEST && indic_neighbour > VAPOUR_INDICATOR_TEST))
933 cell_faces_neighbours_corrected_bool_tmp(i+ii,j+jj,k+kk) = cell_faces_neighbours_ijk;
937 for (
int k = 0; k < nk; k++)
938 for (
int j = 0; j < nj; j++)
939 for (
int i = 0; i < ni; i++)
940 cell_faces_neighbours_corrected_bool_mixed_cell[c](i,j,k) = cell_faces_neighbours_corrected_bool_tmp(i,j,k);
945 IJK_Field_local_double cell_faces_neighbours_corrected_field_tmp;
948 cell_faces_neighbours_corrected_field_tmp.
allocate(ni, nj, nk, 0);
955 cell_faces_neighbours_corrected_field_tmp,
956 cell_faces_neighbours_corrected_convective_mixed_cell);
959 cell_faces_neighbours_corrected_field_tmp,
960 cell_faces_neighbours_corrected_velocity_temperature);
966 cell_faces_neighbours_corrected_field_tmp,
967 cell_faces_neighbours_corrected_diffusive_mixed_cell);
971 cell_faces_neighbours_corrected_field_tmp,
972 neighbours_weighting_colinearity_mixed_cell);
978 IJK_Field_local_double& cell_faces_neighbours_corrected_field,
979 IJK_Field_vector3_double& cell_faces_neighbours_corrected_field_mixed_cell)
981 const int ni = cell_faces_neighbours_corrected_field_mixed_cell[0].ni();
982 const int nj = cell_faces_neighbours_corrected_field_mixed_cell[1].nj();
983 const int nk = cell_faces_neighbours_corrected_field_mixed_cell[2].nk();
985 for (
int c=0; c<3; c++)
987 cell_faces_neighbours_corrected_field.
data() = 0;
988 for (
int k = 0; k < nk; k++)
989 for (
int j = 0; j < nj; j++)
990 for (
int i = 0; i < ni; i++)
991 if (cell_faces_neighbours_corrected_bool[c](i,j,k))
992 cell_faces_neighbours_corrected_field(i,j,k) = cell_faces_neighbours_corrected_field_mixed_cell[c](i,j,k);
993 cell_faces_neighbours_corrected_field_mixed_cell[c].data() = 0.;
994 for (
int k = 0; k < nk; k++)
995 for (
int j = 0; j < nj; j++)
996 for (
int i = 0; i < ni; i++)
997 cell_faces_neighbours_corrected_field_mixed_cell[c](i,j,k) = cell_faces_neighbours_corrected_field(i,j,k);
1004 IJK_Field_vector3_double& cell_faces_neighbours_corrected_velocity_temperature,
1005 IJK_Field_vector3_double& cell_faces_neighbours_corrected_convective,
1006 IJK_Field_vector3_double& cell_faces_neighbours_corrected_diffusive,
1007 IJK_Field_vector3_double& neighbours_weighting_colinearity)
1011 for (
int c=0; c<3; c++)
1012 cell_faces_neighbours_corrected_bool[c].data() = 0;
1017 for (
int c=0; c<3; c++)
1018 neighbours_weighting_colinearity[c].data() = 0;
1024 for (
int c=0; c<3; c++)
1025 cell_faces_neighbours_corrected_convective[c].data() = 0;
1029 for (
int c=0; c<3; c++)
1030 cell_faces_neighbours_corrected_velocity_temperature[c].data() = 0;
1037 for (
int c=0; c<3; c++)
1038 cell_faces_neighbours_corrected_diffusive[c].data() = 0;
1044 const int nb_i_layer = cell_faces_neighbours_corrected_bool[0].ni();
1045 const int nb_j_layer = cell_faces_neighbours_corrected_bool[0].nj();
1046 const int nb_k_layer = cell_faces_neighbours_corrected_bool[0].nk();
1048 const Domaine_IJK& dom_ns = ref_ijk_ft_->get_interface().I().get_domaine();
1058 int index_i_problem, index_j_problem, index_k_problem;
1059 int index_i_neighbour, index_j_neighbour, index_k_neighbour;
1060 int index_i_procs, index_j_procs, index_k_procs;
1061 int index_i_neighbour_global, index_j_neighbour_global, index_k_neighbour_global;
1062 int l_dir, m_dir, n_dir;
1063 double distance, colinearity, convective_flux, diffusive_flux;
1068 thermal_subproblems_->get_subproblem_ijk_indices(index_i_problem, index_j_problem, index_k_problem, i);
1070 const std::vector<std::vector<std::vector<std::vector<bool>>>>& pure_neighbours_to_correct =
thermal_subproblems_->get_pure_neighbours_last_faces_to_correct(i);
1071 const std::vector<std::vector<std::vector<std::vector<double>>>>& pure_neighbours_distance_to_correct =
thermal_subproblems_->get_pure_neighbours_last_faces_corrected_distance(i);
1072 const std::vector<std::vector<std::vector<std::vector<double>>>>& pure_neighbours_colinearity_to_correct =
thermal_subproblems_->get_pure_neighbours_last_faces_corrected_colinearity(i);
1073 for (
int c=0; c<3; c++)
1075 const int l_dir_size = (int) pure_neighbours_to_correct[c].size() -1;
1076 const int m_dir_size = (int) pure_neighbours_to_correct[c][0].size() -1;
1077 const int n_dir_size = (int) pure_neighbours_to_correct[c][0][0].size() -1;
1078 for (l=l_dir_size; l>=0; l--)
1079 for (m=m_dir_size; m>=0; m--)
1080 for (n=n_dir_size; n>=0; n--)
1081 if (pure_neighbours_to_correct[c][l][m][n])
1087 l_dir = (pure_neighbours_corrected_sign[0]) ? l * (-1) + 1 : l;
1088 m_dir = (pure_neighbours_corrected_sign[1]) ? m * (-1) : m;
1089 n_dir = (pure_neighbours_corrected_sign[2]) ? n * (-1) : n;
1092 l_dir = (pure_neighbours_corrected_sign[0]) ? l * (-1) : l;
1093 m_dir = (pure_neighbours_corrected_sign[1]) ? m * (-1) + 1 : m;
1094 n_dir = (pure_neighbours_corrected_sign[2]) ? n * (-1) : n;
1097 l_dir = (pure_neighbours_corrected_sign[0]) ? l * (-1) : l;
1098 m_dir = (pure_neighbours_corrected_sign[1]) ? m * (-1) : m;
1099 n_dir = (pure_neighbours_corrected_sign[2]) ? n * (-1) + 1 : n;
1102 l_dir = (pure_neighbours_corrected_sign[0]) ? l * (-1) + 1 : l;
1103 m_dir = (pure_neighbours_corrected_sign[1]) ? m * (-1) : m;
1104 n_dir = (pure_neighbours_corrected_sign[2]) ? n * (-1) : n;
1110 index_i_neighbour = (index_i_problem + l_dir);
1111 index_j_neighbour = (index_j_problem + m_dir);
1112 index_k_neighbour = (index_k_problem + n_dir);
1113 index_i_neighbour_global = compute_periodic_index((index_i_neighbour + offset_i), nb_i_layer_tot);
1114 index_j_neighbour_global = compute_periodic_index((index_j_neighbour + offset_j), nb_j_layer_tot);
1115 index_k_neighbour_global = compute_periodic_index((index_k_neighbour + offset_k), nb_k_layer_tot);
1116 index_i_procs = compute_periodic_index(index_i_neighbour, nb_i_layer);
1117 index_j_procs = compute_periodic_index(index_j_neighbour, nb_j_layer);
1118 index_k_procs = compute_periodic_index(index_k_neighbour, nb_k_layer);
1120 distance = pure_neighbours_distance_to_correct[c][l][m][n];
1122 colinearity = pure_neighbours_colinearity_to_correct[c][l][m][n];
1123 if ((index_i_procs == index_i_neighbour
1124 && index_j_procs == index_j_neighbour
1125 && index_k_procs == index_k_neighbour)
1132 neighbours_weighting_colinearity,
1133 cell_faces_neighbours_corrected_convective,
1134 cell_faces_neighbours_corrected_diffusive,
1135 cell_faces_neighbours_corrected_velocity_temperature,
1150 index_j_neighbour_global,
1151 index_k_neighbour_global,
1166 Cerr <<
"Fluxes have been received from procs" << finl;
1169 cell_faces_neighbours_corrected_velocity_temperature,
1170 cell_faces_neighbours_corrected_convective,
1171 cell_faces_neighbours_corrected_diffusive,
1172 neighbours_weighting_colinearity);
1174 Cerr <<
"Fluxes have been combined on procs" << finl;
1178 cell_faces_neighbours_corrected_velocity_temperature,
1179 cell_faces_neighbours_corrected_convective,
1180 cell_faces_neighbours_corrected_diffusive,
1181 neighbours_weighting_colinearity,
1184 Cerr <<
"Weighted calculation of all fluxes has been performed" << finl;
1188 cell_faces_neighbours_corrected_velocity_temperature,
1189 cell_faces_neighbours_corrected_convective,
1190 cell_faces_neighbours_corrected_diffusive,
1191 neighbours_weighting_colinearity);
1193 Cerr <<
"Only the fluxes in the immediate interface vicinity have been eventually kept" << finl;
1199 const int& index_j_neighbour_global,
1200 const int& index_k_neighbour_global,
1201 const int& subproblem_index,
1204 const double& colinearity,
1208 const double& convective_flux_computed,
1209 const double& diffusive_flux_computed)
1211 double convective_flux = convective_flux_computed;
1212 double diffusive_flux = diffusive_flux_computed;
1213 double temperature = 0.;
1252 index_j_neighbour_global,
1253 index_k_neighbour_global,
1307 for (
int c=0; c<3; c++)
1310 for (
int k=0; k<size_k_layers; k++)
1313 int size_array_global = size_array;
1315 ArrOfInt overall_numerotation(nb_procs);
1316 ArrOfInt start_indices(nb_procs);
1317 overall_numerotation(proc_num) = size_array;
1320 for (l=1; l<overall_numerotation.
size_array(); l++)
1321 start_indices(l) = start_indices(l-1) + overall_numerotation(l-1);
1325 Cerr <<
"Size array" << size_array << finl;
1326 Cerr <<
"Size array global" << size_array_global << finl;
1327 Cerr <<
"Overall_numerotation" << overall_numerotation(0) <<
"-" << overall_numerotation(1) << finl;
1330 ArrOfInt local_indices_i_tmp;
1331 ArrOfInt local_indices_j_tmp;
1332 ArrOfInt local_weighting_tmp;
1338 local_indices_i_tmp = global_indices_i_tmp;
1339 local_indices_j_tmp = global_indices_j_tmp;
1340 local_weighting_tmp = global_weighting_tmp;
1342 global_indices_i_tmp.
resize(size_array_global);
1343 global_indices_j_tmp.
resize(size_array_global);
1344 global_weighting_tmp.
resize(size_array_global);
1346 global_indices_i_tmp *= 0;
1347 global_indices_j_tmp *= 0;
1348 global_weighting_tmp *= 0;
1350 for (l=0; l<local_indices_i_tmp.
size_array(); l++)
1352 global_indices_i_tmp(start_indices(proc_num) + l) = local_indices_i_tmp(l);
1353 global_indices_j_tmp(start_indices(proc_num) + l) = local_indices_j_tmp(l);
1354 global_weighting_tmp(start_indices(proc_num) + l) = local_weighting_tmp(l);
1365 ArrOfDouble local_colinearity_tmp;
1367 local_colinearity_tmp = global_colinearity_tmp;
1368 global_colinearity_tmp.
resize(size_array_global);
1369 global_colinearity_tmp *= 0.;
1370 for (l=0; l<local_indices_i_tmp.
size_array(); l++)
1371 global_colinearity_tmp(start_indices(proc_num) + l) = local_colinearity_tmp(l);
1378 ArrOfDouble local_convective_flux_values_tmp;
1380 local_convective_flux_values_tmp = global_convective_flux_values_tmp;
1381 global_convective_flux_values_tmp.
resize(size_array_global);
1382 global_convective_flux_values_tmp *= 0.;
1383 for (l=0; l<local_indices_i_tmp.
size_array(); l++)
1384 global_convective_flux_values_tmp(start_indices(proc_num) + l) = local_convective_flux_values_tmp(l);
1389 ArrOfDouble local_temperature_flux_values_tmp;
1391 local_temperature_flux_values_tmp = global_temperature_flux_values_tmp;
1392 global_temperature_flux_values_tmp.
resize(size_array_global);
1393 global_temperature_flux_values_tmp *= 0.;
1394 for (l=0; l<local_indices_i_tmp.
size_array(); l++)
1395 global_temperature_flux_values_tmp(start_indices(proc_num) + l) = local_temperature_flux_values_tmp(l);
1404 ArrOfDouble local_diffusive_flux_values_tmp;
1406 local_diffusive_flux_values_tmp = global_diffusive_flux_values_tmp;
1407 global_diffusive_flux_values_tmp.
resize(size_array_global);
1408 global_diffusive_flux_values_tmp *= 0.;
1409 for (l=0; l<local_indices_i_tmp.
size_array(); l++)
1410 global_diffusive_flux_values_tmp(start_indices(proc_num) + l) = local_diffusive_flux_values_tmp(l);
1421 IJK_Field_vector3_double& cell_faces_neighbours_corrected_velocity_temperature,
1422 IJK_Field_vector3_double& cell_faces_neighbours_corrected_convective,
1423 IJK_Field_vector3_double& cell_faces_neighbours_corrected_diffusive,
1424 IJK_Field_vector3_double& neighbours_weighting_colinearity)
1426 const IJK_Field_double& indicator = ref_ijk_ft_->get_interface().I();
1427 const int ni = indicator.
ni();
1428 const int nj = indicator.
nj();
1429 const int nk = indicator.
nk();
1431 const Domaine_IJK& dom_ns = ref_ijk_ft_->get_interface().I().get_domaine();
1436 double convective_flux = 0.;
1437 double diffusive_flux = 0.;
1438 double colinearity = 0.;
1439 double temperature = 0.;
1440 for (
int dir=0; dir<3; dir++)
1443 for (
int k_global=0; k_global<size_k_layers; k_global++)
1446 for (
int l=0; l<global_size_array; l++)
1464 const int i = i_global - offset_i;
1465 const int j = j_global - offset_j;
1466 const int k = k_global - offset_k;
1467 if ((0 <= i && i < ni) && (0 <= j && j < nj) && (0 <= k && k < nk))
1484 neighbours_weighting_colinearity[dir](i,j,k) += colinearity;
1486 cell_faces_neighbours_corrected_bool[dir](i,j,k) += local_weighting;
1494 IJK_Field_vector3_double& cell_faces_neighbours_corrected_convective_diffusive_flux,
1499 double& convective_diffusive_flux)
1523 double& convective_diffusive_flux,
1524 const double& replace_weighting_values)
1528 const double current_flux_value = cell_faces_neighbours_corrected_convective_diffusive_flux[dir](i,j,k);
1529 const int sign_flux = signbit(convective_diffusive_flux);
1530 convective_diffusive_flux = std::max(abs(convective_diffusive_flux), abs(current_flux_value));
1531 convective_diffusive_flux = sign_flux ? -convective_diffusive_flux: convective_diffusive_flux;
1532 cell_faces_neighbours_corrected_convective_diffusive_flux[dir](i,j,k) = convective_diffusive_flux;
1536 cell_faces_neighbours_corrected_convective_diffusive_flux[dir](i,j,k) += convective_diffusive_flux;
1540 IJK_Field_vector3_double& cell_faces_neighbours_corrected_velocity_temperature,
1541 IJK_Field_vector3_double& cell_faces_neighbours_corrected_convective,
1542 IJK_Field_vector3_double& cell_faces_neighbours_corrected_diffusive,
1543 IJK_Field_vector3_double& neighbours_weighting_colinearity,
1544 const int& compute_fluxes_values)
1547 if (compute_fluxes_values)
1555 const int ni = cell_faces_neighbours_corrected_bool[0].ni();
1556 const int nj = cell_faces_neighbours_corrected_bool[0].nj();
1557 const int nk = cell_faces_neighbours_corrected_bool[0].nk();
1560 for (
int k = 0; k < nk; k++)
1561 for (
int j = 0; j < nj; j++)
1562 for (
int i = 0; i < ni; i++)
1563 for (
int c=0; c<3; c++)
1564 if(cell_faces_neighbours_corrected_bool[c](i,j,k))
1568 const double colinearity = neighbours_weighting_colinearity[c](i,j,k);
1569 if (colinearity > 1e-12)
1573 cell_faces_neighbours_corrected_convective[c](i,j,k) /= colinearity;
1575 cell_faces_neighbours_corrected_velocity_temperature[c](i,j,k) /= colinearity;
1578 cell_faces_neighbours_corrected_diffusive[c](i,j,k) /= colinearity;
1583 const double weighting = (double) (cell_faces_neighbours_corrected_bool[c](i,j,k));
1586 cell_faces_neighbours_corrected_convective[c](i,j,k) /= weighting;
1588 cell_faces_neighbours_corrected_velocity_temperature[c](i,j,k) /= weighting;
1591 cell_faces_neighbours_corrected_diffusive[c](i,j,k) /= weighting;
1609 IJK_Field_vector3_double& neighbours_weighting_colinearity,
1610 IJK_Field_vector3_double& cell_faces_neighbours_corrected_convective,
1611 IJK_Field_vector3_double& cell_faces_neighbours_corrected_diffusive,
1612 IJK_Field_vector3_double& cell_faces_neighbours_corrected_velocity_temperature,
1613 const int& subproblem_index,
1614 const int& index_i,
const int& index_j,
const int& index_k,
1617 const double& colinearity,
1618 const int& compute_fluxes_values,
1619 double& convective_flux,
1620 double& diffusive_flux)
1622 bool valid_flux_value =
true;
1623 if (compute_fluxes_values)
1637 cell_faces_neighbours_corrected_convective,
1643 if (valid_flux_value)
1644 get_add_replace_flux_value(cell_faces_neighbours_corrected_convective, dir, index_i, index_j, index_k, convective_flux, colinearity);
1647 double temperature = 0.;
1657 get_add_replace_flux_value(cell_faces_neighbours_corrected_velocity_temperature, dir, index_i, index_j, index_k, temperature, colinearity);
1671 cell_faces_neighbours_corrected_convective,
1677 if (valid_flux_value)
1678 get_add_replace_flux_value(cell_faces_neighbours_corrected_diffusive, dir, index_i, index_j, index_k, diffusive_flux, colinearity);
1681 if (valid_flux_value)
1683 cell_faces_neighbours_corrected_bool[dir](index_i, index_j, index_k) += 1;
1685 neighbours_weighting_colinearity[dir](index_i, index_j, index_k) += colinearity;
1690 const int& subproblem_index,
1693 const double& colinearity,
1697 const int& temperature)
1724 const int& subproblem_index,
1727 const double& colinearity,
1731 const int& temperature)
1745 const int& subproblem_index,
1748 const double& colinearity,
1764 const int& subproblem_index,
1767 const double& colinearity,
1796 const int& subproblem_index,
1799 const double& colinearity,
1815 const int& subproblem_index,
1818 const double& colinearity,
1834 const int fluxes_type,
1835 const int& subproblem_index,
1838 const double& colinearity,
1842 const int& temperature)
1844 bool valid_flux_value =
true;
1845 int flux_sign[2][6] = FLUX_SIGN;
1846 double surf_face = 1.;
1847 for (
int c = 0; c < 3; c++)
1849 surf_face *= domaine_->get_constant_delta(c);
1850 surf_face *= flux_sign[fluxes_type][(int) (2*dir)];
1863 flux *= colinearity;
1864 return valid_flux_value;
1868 const int fluxes_type,
1869 const int& subproblem_index,
1872 const double& colinearity,
1877 int flux_sign[2][6] = FLUX_SIGN;
1878 double surf_face = 1.;
1879 surf_face *= flux_sign[fluxes_type][(int) (2*dir)];
1880 DoubleVect discrete_flux_integral;
1882 for (
int val=0; val < discrete_flux_integral.
size(); val++)
1883 flux += discrete_flux_integral[val];
1886 flux *= colinearity;
1890 const IJK_Field_vector3_int& cell_faces_neighbours_corrected_all_bool,
1891 const IJK_Field_vector3_double& cell_faces_neighbours_fluxes_corrected,
1892 const int& fluxes_type)
1896 Cerr <<
"Replace cell neighbours thermal_convective diffusive fluxes faces" << finl;
1900 cell_faces_neighbours_corrected_all_bool,
1901 cell_faces_neighbours_fluxes_corrected,
1909 cell_faces_neighbours_corrected_all_bool,
1910 cell_faces_neighbours_fluxes_corrected,
1918 const IJK_Field_vector3_int& cell_faces_neighbours_corrected_all_bool,
1919 const IJK_Field_vector3_double& cell_faces_neighbours_fluxes_corrected,
1920 FixedVector<std::vector<ArrOfDouble>,3>& flux_xyz,
1923 const IJK_Field_vector3_int * cell_faces_neighbours_corrected_bool =
nullptr;
1925 cell_faces_neighbours_corrected_bool = &cell_faces_neighbours_corrected_all_bool;
1927 cell_faces_neighbours_corrected_bool = &cell_faces_neighbours_corrected_min_max_bool;
1928 const int ni = (*cell_faces_neighbours_corrected_bool)[0].ni();
1929 const int nj = (*cell_faces_neighbours_corrected_bool)[0].nj();
1930 const int nk = (*cell_faces_neighbours_corrected_bool)[0].nk();
1931 for (
int c=0; c<3; c++)
1933 const int ni_max = (c == 0 ? ni + 1 : ni);
1934 const int nj_max = (c == 1 ? nj + 1 : nj);
1935 const int nk_max = (c == 2 ? nk + 1 : nk);
1936 for (
int k = 0; k < nk_max; k++)
1937 for (
int j = 0; j < nj_max; j++)
1938 for (
int i = 0; i < ni_max; i++)
1939 if ((*cell_faces_neighbours_corrected_bool)[c](i,j,k))
1941 flux_xyz[c][k].append_array(cell_faces_neighbours_fluxes_corrected[c](i,j,k));
1952 IJK_Field_double& temperature_neighbours,
1953 IJK_Field_int& neighbours_weighting,
1954 IJK_Field_double& neighbours_weighting_colinearity)
const
1957 Cerr <<
"Corrige flux - Replace temperature cell neighbours - INI" << finl;
1964 const int ni = temperature.
ni();
1965 const int nj = temperature.
nj();
1966 const int nk = temperature.
nk();
1969 ArrOfInt corrected_values;
1970 ArrOfInt out_of_bounds_corrected_values;
1971 ArrOfDouble out_of_bounds_values;
1973 for (
int k = 0; k < nk; k++)
1974 for (
int j = 0; j < nj; j++)
1975 for (
int i = 0; i < ni; i++)
1977 double neighbours_weighting_ijk;
1978 const double temperature_old = temperature(i,j,k);
1980 neighbours_weighting_ijk = neighbours_weighting_colinearity(i,j,k);
1982 neighbours_weighting_ijk = (double) neighbours_weighting(i,j,k);
1984 if (neighbours_weighting(i,j,k))
1986 temperature(i,j,k) = temperature_neighbours(i,j,k) / neighbours_weighting_ijk;
1993 const double local_temperature = temperature(i,j,k);
1994 const double indic = ref_ijk_ft_->get_interface().I()(i,j,k);
1995 if (local_temperature > 0)
1997 if (indic < LIQUID_INDICATOR_TEST && indic > VAPOUR_INDICATOR_TEST)
2002 if (dist_sub_res > 0)
2006 Cerr <<
"Thermal subproblem is: " << rank << finl;
2007 Cerr <<
"Temperature value has the wrong sign at i: " << i <<
", j: " << j <<
", k: " << k << finl;
2008 Cerr <<
"Temperature value is: " << local_temperature << finl;
2009 Cerr <<
"Distance to cell centre is: " << dist_sub_res << finl;
2010 Cerr <<
"Enforce zero value" << finl;
2015 temperature(i,j,k) = temperature_old;
2018 if (indic > LIQUID_INDICATOR_TEST)
2022 Cerr <<
"Temperature value has the wrong sign at i: " << i <<
", j: " << j <<
", k: " << k << finl;
2023 Cerr <<
"Temperature value is: " << local_temperature << finl;
2024 Cerr <<
"Enforce zero value" << finl;
2029 temperature(i,j,k) = temperature_old;
2037 out_of_bounds_corrected_values,
2038 out_of_bounds_values,
2043 Cerr <<
"Corrige flux - Replace temperature cell neighbours - END" << finl;
2047 ArrOfInt& corrected_values,
2048 ArrOfInt& out_of_bounds_corrected_values,
2049 ArrOfDouble& out_of_bounds_values,
2050 IJK_Field_double& distance)
const
2058 ArrOfDouble temperature_smoothed;
2060 double temperature_neighbour;
2061 for (
int ielem=0; ielem<out_of_bounds_corrected_values.
size_array(); ielem++)
2063 const int elem = out_of_bounds_corrected_values[ielem];
2065 const int i = num_elem_ijk[DIRECTION_I];
2066 const int j = num_elem_ijk[DIRECTION_J];
2067 const int k = num_elem_ijk[DIRECTION_K];
2069 const double temperature_old_subres = out_of_bounds_values[ielem];
2070 const double temperature_old = temperature(i,j,k);
2072 temperature_neighbour=0;
2073 for (
int l=0; l<6; l++)
2075 const int ii = NEIGHBOURS_I[l];
2076 const int jj = NEIGHBOURS_J[l];
2077 const int kk = NEIGHBOURS_K[l];
2078 const double indic = ref_ijk_ft_->get_interface().I()(i+ii, j+jj, k+kk);
2080 if (indic > LIQUID_INDICATOR_TEST)
2082 temperature_neighbour += temperature(i+ii, j+jj, k+kk);
2086 double mean_temperature = 1e20;
2088 mean_temperature = (temperature_neighbour / counter + temperature_old_subres) * 0.5;
2091 if (mean_temperature < 0.)
2094 temperature_smoothed.
append_array(temperature_neighbour/counter);
2100 for (
int ielem=0; ielem<out_of_bounds_corrected_values.
size_array(); ielem++)
2102 const int elem = out_of_bounds_corrected_values[ielem];
2104 const int i = num_elem_ijk[DIRECTION_I];
2105 const int j = num_elem_ijk[DIRECTION_J];
2106 const int k = num_elem_ijk[DIRECTION_K];
2107 temperature(i,j,k) = temperature_smoothed(ielem);
2109 Cerr <<
"Smoothed temperature value is:" << temperature_smoothed(ielem) << finl;
2134 int ijk_indices_i, ijk_indices_j, ijk_indices_k;
2135 thermal_subproblems_->get_subproblem_ijk_indices(ijk_indices_i, ijk_indices_j, ijk_indices_k, i);
2136 d_temperature(ijk_indices_i, ijk_indices_j, ijk_indices_k) = 0.;
2159 const int fluxes_type,
2160 const int& last_flux)
2162 const int flux_out[6] = FLUXES_OUT;
2163 const int faces_dir[6] = FACES_DIR;
2164 const int flux_sign[2][6] = FLUX_SIGN;
2167 fluxes.
resize(nb_faces_to_correct);
2169 dist_.resize(nb_faces_to_correct);
2170 int counter_faces = 0;
2175 for (
int l=0; l<6; l++)
2177 const int is_neighbour_pure_liquid =
intersection_ijk_cell_->get_ijk_pure_face_neighbours(intersection_ijk_cell_index, l);
2178 double surf_face = 1.;
2179 const int dir = faces_dir[l];
2180 if (is_neighbour_pure_liquid)
2182 for (
int c = 0; c < 3; c++)
2183 if (c!= faces_dir[l])
2184 surf_face *= domaine_->get_constant_delta(c);
2185 const double dist = dist_interf(intersection_ijk_cell_index, l);
2187 double local_flux_face = 0.;
2188 bool valid_flux =
true;
2193 double flux_face = local_flux_face * surf_face;
2195 flux_face *= flux_sign[fluxes_type][l];
2197 fluxes[counter_faces] = flux_face;
2198 dist_[counter_faces] = dist;
2227 DoubleVect * fluxes =
nullptr;
2235 const int& fluxes_correction_conservations)
2237 if (fluxes_correction_conservations)
2239 int counter_faces = 0;
2240 const int flux_sign[2][6] = FLUX_SIGN;
2241 const int flux_out[6] = FLUXES_OUT;
2245 for (
int l=0; l<6; l++)
2247 const int is_neighbour_pure_liquid =
intersection_ijk_cell_->get_ijk_pure_face_neighbours(intersection_ijk_cell_index, l);
2248 if (is_neighbour_pure_liquid)
2253 flux_corr *= (flux_sign[1][l]);
2254 const double flux_final = (*fluxes)[counter_faces] - flux_corr;
2255 (*fluxes)[counter_faces] = flux_final;
2256 thermal_subproblems_->set_pure_flux_corrected(flux_final * flux_out[l] * flux_sign[1][l], i, l, 1);
2265 const int& index_subproblem,
2273 const int& temperature)
2288 return thermal_subproblems_->get_temperature_gradient_times_conductivity_profile_at_point(index_subproblem, dist, dir, valid_val);
2314 const int flux_out[6] = FLUXES_OUT;
2315 const int faces_dir[6] = FACES_DIR;
2316 const int flux_sign[2][6] = FLUX_SIGN;
2319 fluxes.
resize(nb_faces_to_correct);
2321 dist_.resize(nb_faces_to_correct);
2323 int counter_faces = 0;
2330 for (
int l=0; l<6; l++)
2332 const int dir = faces_dir[l];
2333 const int is_neighbour_pure_liquid =
intersection_ijk_cell_->get_ijk_pure_face_neighbours(intersection_ijk_cell_index, l);
2334 if (is_neighbour_pure_liquid)
2336 const double dist = dist_interf(intersection_ijk_cell_index, l);
2338 DoubleVect discrete_flux_integral;
2343 double flux_face = 0;
2344 for (
int val=0; val < discrete_flux_integral.
size(); val++)
2345 flux_face += discrete_flux_integral[val];
2347 flux_face *= flux_sign[fluxes_type][l];
2348 fluxes[counter_faces] = flux_face;
2349 dist_[counter_faces] = dist;
2363 const int& index_subproblem,
2371 return thermal_subproblems_->get_temperature_times_velocity_profile_discrete_integral_at_point(index_subproblem,
2377 return thermal_subproblems_->get_temperature_gradient_times_conductivity_profile_discrete_integral_at_point(index_subproblem,
2382 return thermal_subproblems_->get_temperature_times_velocity_profile_discrete_integral_at_point(index_subproblem,
2391 const IJK_Field_int& neighbours_temperature_to_correct,
2392 IJK_Field_vector3_int& cell_faces_neighbours_corrected_min_max_bool,
2393 const int& max_flux_per_dir,
2394 const int& check_cell_center_neighbour,
2395 const int& remove_external_neighbour_values,
2396 IJK_Field_int& neighbours_temperature_to_correct_trimmed)
2409 cell_faces_neighbours_corrected_min_max_bool_local);
2411 const int ni = cell_faces_neighbours_corrected_all_bool[0].ni();
2412 const int nj = cell_faces_neighbours_corrected_all_bool[0].nj();
2413 const int nk = cell_faces_neighbours_corrected_all_bool[0].nk();
2415 for (c = 0; c < 3; c++)
2416 cell_faces_neighbours_corrected_min_max_bool[c].data() = 0.;
2420 if (remove_external_neighbour_values)
2422 for (k = 0; k < nk; k++)
2423 for (j = 0; j < nj; j++)
2424 for (i = 0; i < ni; i++)
2425 neighbours_temperature_to_correct_trimmed(i,j,k) = neighbours_temperature_to_correct(i,j,k);
2431 if (max_flux_per_dir)
2436 int index_neighbour_cell = 0;
2437 bool index_found =
false;
2438 bool centre_neighbour_bool =
false;
2439 for (c = c_ini; c < c_end; c++)
2440 for (k = 0; k < nk; k++)
2441 for (j = 0; j < nj; j++)
2443 for (i = 0; i < ni; i++)
2445 if (neighbours_temperature_to_correct(i,j,k) && !index_found)
2447 index_neighbour_cell = i;
2450 if(cell_faces_neighbours_corrected_min_max_bool_local[c](i,j,k))
2452 if (neighbours_temperature_to_correct(i - 1,j,k) && check_cell_center_neighbour && !remove_external_neighbour_values)
2453 centre_neighbour_bool =
true;
2454 if (!centre_neighbour_bool)
2455 cell_faces_neighbours_corrected_min_max_bool[c](i,j,k) = cell_faces_neighbours_corrected_min_max_bool_local[c](i,j,k);
2456 centre_neighbour_bool =
false;
2457 index_found =
false;
2458 for(
int ii = index_neighbour_cell; ii < i; ii++)
2459 neighbours_temperature_to_correct_trimmed(ii,j,k) = 0;
2463 for (i = ni - 1; i >=0; i--)
2465 if (neighbours_temperature_to_correct(i,j,k) && !index_found)
2467 index_neighbour_cell = i;
2470 if(cell_faces_neighbours_corrected_min_max_bool_local[c](i,j,k))
2472 if (neighbours_temperature_to_correct(i,j,k) && check_cell_center_neighbour && !remove_external_neighbour_values)
2473 centre_neighbour_bool =
true;
2474 if (!centre_neighbour_bool)
2475 cell_faces_neighbours_corrected_min_max_bool[c](i,j,k) = cell_faces_neighbours_corrected_min_max_bool_local[c](i,j,k);
2476 centre_neighbour_bool =
false;
2477 index_found =
false;
2478 for(
int ii = index_neighbour_cell; ii >= i; ii--)
2479 neighbours_temperature_to_correct_trimmed(ii,j,k) = 0;
2487 if (max_flux_per_dir)
2492 for (c = c_ini; c < c_end; c++)
2493 for (k = 0; k < nk; k++)
2494 for (i = 0; i < ni; i++)
2496 for (j = 0; j < nj; j++)
2498 if (neighbours_temperature_to_correct(i,j,k) && !index_found)
2500 index_neighbour_cell = j;
2503 if(cell_faces_neighbours_corrected_min_max_bool_local[c](i,j,k))
2505 if (neighbours_temperature_to_correct(i,j - 1,k) && check_cell_center_neighbour && !remove_external_neighbour_values)
2506 centre_neighbour_bool =
true;
2507 if (!centre_neighbour_bool)
2508 cell_faces_neighbours_corrected_min_max_bool[c](i,j,k) = cell_faces_neighbours_corrected_min_max_bool_local[c](i,j,k);
2509 centre_neighbour_bool =
false;
2510 index_found =
false;
2511 for(
int jj = index_neighbour_cell; jj < j; jj++)
2512 neighbours_temperature_to_correct_trimmed(i,jj,k) = 0;
2516 for (j = nj - 1; j >=0; j--)
2518 if (neighbours_temperature_to_correct(i,j,k) && !index_found)
2520 index_neighbour_cell = j;
2523 if(cell_faces_neighbours_corrected_min_max_bool_local[c](i,j,k))
2525 if (neighbours_temperature_to_correct(i,j,k) && check_cell_center_neighbour && !remove_external_neighbour_values)
2526 centre_neighbour_bool =
true;
2527 if (!centre_neighbour_bool)
2528 cell_faces_neighbours_corrected_min_max_bool[c](i,j,k) = cell_faces_neighbours_corrected_min_max_bool_local[c](i,j,k);
2529 centre_neighbour_bool =
false;
2530 index_found =
false;
2531 for(
int jj = index_neighbour_cell; jj >= j; jj--)
2532 neighbours_temperature_to_correct_trimmed(i,jj,k) = 0;
2540 if (max_flux_per_dir)
2545 for (c = c_ini; c < c_end; c++)
2546 for (i = 0; i < ni; i++)
2547 for (j = 0; j < nj; j++)
2549 for (k = 0; k < nk; k++)
2551 if (neighbours_temperature_to_correct(i,j,k) && !index_found)
2553 index_neighbour_cell = k;
2556 if(cell_faces_neighbours_corrected_min_max_bool_local[c](i,j,k))
2558 if (neighbours_temperature_to_correct(i,j,k - 1) && check_cell_center_neighbour && !remove_external_neighbour_values)
2559 centre_neighbour_bool =
true;
2560 if (!centre_neighbour_bool)
2561 cell_faces_neighbours_corrected_min_max_bool[c](i,j,k) = cell_faces_neighbours_corrected_min_max_bool_local[c](i,j,k);
2562 centre_neighbour_bool =
false;
2563 index_found =
false;
2564 for(
int kk = index_neighbour_cell; kk < k; kk++)
2565 neighbours_temperature_to_correct_trimmed(i,j,kk) = 0;
2569 for (k = nk - 1; k >=0; k--)
2571 if (neighbours_temperature_to_correct(i,j,k) && !index_found)
2573 index_neighbour_cell = k;
2576 if(cell_faces_neighbours_corrected_min_max_bool_local[c](i,j,k))
2578 if (neighbours_temperature_to_correct(i,j,k) && check_cell_center_neighbour && !remove_external_neighbour_values)
2579 centre_neighbour_bool =
true;
2580 if (!centre_neighbour_bool)
2581 cell_faces_neighbours_corrected_min_max_bool[c](i,j,k) = cell_faces_neighbours_corrected_min_max_bool_local[c](i,j,k);
2582 centre_neighbour_bool =
false;
2583 index_found =
false;
2584 for(
int kk = index_neighbour_cell; kk >= k; kk--)
2585 neighbours_temperature_to_correct_trimmed(i,j,kk) = 0;
2597 const IJK_Field_int& neighbours_temperature_to_correct,
2598 IJK_Field_vector3_int& cell_faces_neighbours_corrected_min_max_bool,
2599 const int& max_flux_per_dir,
2600 const int& check_cell_center_neighbour,
2601 const int& remove_external_neighbour_values,
2602 IJK_Field_int& neighbours_temperature_to_correct_trimmed)
2612 cell_faces_neighbours_corrected_min_max_bool_local);
2615 for (c = 0; c < 3; c++)
2616 cell_faces_neighbours_corrected_min_max_bool[c].data() = 0.;
2618 const int ni = cell_faces_neighbours_corrected_all_bool[0].ni();
2619 const int nj = cell_faces_neighbours_corrected_all_bool[0].nj();
2620 const int nk = cell_faces_neighbours_corrected_all_bool[0].nk();
2624 if (remove_external_neighbour_values)
2626 for (k = 0; k < nk; k++)
2627 for (j = 0; j < nj; j++)
2628 for (i = 0; i < ni; i++)
2629 neighbours_temperature_to_correct_trimmed(i,j,k) = neighbours_temperature_to_correct(i,j,k);
2634 ArrOfInt indices_found_ini, indices_found_end;
2635 ArrOfInt indices_flux_found_ini, indices_flux_found_end;
2636 ArrOfInt indices_to_remove;
2637 ArrOfInt indices_fluxes_to_remove;
2646 const int * n_first =
nullptr;
2647 const int * n_bis =
nullptr;
2648 const int * n_ter =
nullptr;
2649 int * i_ref =
nullptr;
2650 int * j_ref =
nullptr;
2651 int * k_ref =
nullptr;
2652 int * i_ref_remove =
nullptr;
2653 int * j_ref_remove =
nullptr;
2654 int * k_ref_remove =
nullptr;
2655 int index_first = 0, index_bis = 0, index_ter = 0;
2657 const int factor_pos[3][3] = {{1, 0, 0},{0, 1, 0},{0, 0, 1}};
2658 for (c = c_ini; c < c_end; c++)
2666 k_ref = &index_first;
2669 k_ref_remove = &index_first;
2670 j_ref_remove = &index_bis;
2671 i_ref_remove = &val;
2677 k_ref = &index_first;
2680 k_ref_remove = &index_first;
2681 i_ref_remove = &index_bis;
2682 j_ref_remove = &val;
2688 i_ref = &index_first;
2691 i_ref_remove = &index_first;
2692 j_ref_remove = &index_bis;
2693 k_ref_remove = &val;
2698 for (index_first = 0; index_first < *n_first; index_first++)
2699 for (index_bis = 0; index_bis < *n_bis; index_bis++)
2701 indices_found_ini.
reset();
2702 indices_found_end.
reset();
2703 indices_flux_found_ini.
reset();
2704 indices_flux_found_end.
reset();
2705 indices_to_remove.
reset();
2706 indices_fluxes_to_remove.
reset();
2707 for (
int l=0; l<2; l++)
2709 indices_sorted[l].reset();
2710 indices_fluxes_sorted[l].reset();
2712 for (index_ter = 0; index_ter < *n_ter; index_ter++)
2714 if (neighbours_temperature_to_correct(*i_ref,*j_ref,*k_ref))
2716 if (!neighbours_temperature_to_correct(*i_ref + factor_pos[c][0],*j_ref + factor_pos[c][1],*k_ref + factor_pos[c][2]))
2718 if (!neighbours_temperature_to_correct(*i_ref - factor_pos[c][0],*j_ref - factor_pos[c][1],*k_ref - factor_pos[c][2]))
2721 if(cell_faces_neighbours_corrected_min_max_bool_local[c](*i_ref,*j_ref,*k_ref))
2723 if (!cell_faces_neighbours_corrected_min_max_bool_local[c](*i_ref + factor_pos[c][0],*j_ref + factor_pos[c][1],*k_ref + factor_pos[c][2]))
2725 if (!cell_faces_neighbours_corrected_min_max_bool_local[c](*i_ref - factor_pos[c][0],*j_ref - factor_pos[c][1],*k_ref - factor_pos[c][2]))
2739 const int indices_flux_test = indices_flux_found_ini.
size_array() || indices_flux_found_end.
size_array();
2740 if (indices_flux_test)
2747 indices_flux_found_end,
2748 indices_fluxes_sorted,
2751 if (indices_test || indices_flux_test)
2753 indices_fluxes_sorted,
2755 indices_fluxes_to_remove,
2756 index_first, index_bis, c);
2771 for (index_ter = 0; index_ter < indices_flux_found_ini.
size_array(); index_ter++)
2773 val = indices_flux_found_ini(index_ter);
2774 const double indic_ini = ref_ijk_ft_->get_interface().I()(*i_ref_remove,
2777 const double indic_ini_prev = ref_ijk_ft_->get_interface().I()(*i_ref_remove - factor_pos[c][0],
2778 *j_ref_remove - factor_pos[c][1],
2779 *k_ref_remove - factor_pos[c][2]);
2780 if(indic_ini > LIQUID_INDICATOR_TEST && indic_ini_prev > LIQUID_INDICATOR_TEST)
2782 cell_faces_neighbours_corrected_min_max_bool[c](*i_ref_remove, *j_ref_remove, *k_ref_remove) =
2783 cell_faces_neighbours_corrected_min_max_bool_local[c](*i_ref_remove, *j_ref_remove, *k_ref_remove);
2787 for (index_ter = 0; index_ter < indices_flux_found_end.
size_array(); index_ter++)
2789 val = indices_flux_found_end(index_ter);
2790 const double indic_end = ref_ijk_ft_->get_interface().I()(*i_ref_remove,
2793 const double indic_end_prev = ref_ijk_ft_->get_interface().I()(*i_ref_remove - factor_pos[c][0],
2794 *j_ref_remove - factor_pos[c][1],
2795 *k_ref_remove - factor_pos[c][2]);
2796 if(indic_end > LIQUID_INDICATOR_TEST && indic_end_prev > LIQUID_INDICATOR_TEST)
2798 cell_faces_neighbours_corrected_min_max_bool[c](*i_ref_remove, *j_ref_remove, *k_ref_remove) =
2799 cell_faces_neighbours_corrected_min_max_bool_local[c](*i_ref_remove, *j_ref_remove, *k_ref_remove);
2807 for (index_ter = 0; index_ter < indices_to_remove.
size_array(); index_ter++)
2809 val = indices_to_remove(index_ter);
2810 neighbours_temperature_to_correct_trimmed(*i_ref_remove, *j_ref_remove, *k_ref_remove) = 0;
2813 for (index_ter = 0; index_ter < indices_fluxes_to_remove.
size_array(); index_ter++)
2815 val = indices_fluxes_to_remove(index_ter);
2816 cell_faces_neighbours_corrected_min_max_bool[c](*i_ref_remove, *j_ref_remove, *k_ref_remove) = 0;
2822 Cerr <<
"Echange espace virtuel" << finl;
2828 ArrOfInt& indices_found_end,
2830 const int& max_n_layer)
2832 int counter_ini = 0;
2833 int counter_end = 0;
2835 counters[0] = &counter_ini;
2836 counters[1] = &counter_end;
2838 indices_references[0] = &indices_found_ini;
2839 indices_references[1] = &indices_found_end;
2840 int size_ini = indices_found_ini.
size_array();
2841 int size_end = indices_found_end.
size_array();
2843 size_references[0] = &size_ini;
2844 size_references[1] = &size_end;
2845 int max_counter = 0;
2846 const int max_index = size_ini + size_end;
2847 std::vector<int> index_tmp;
2848 while(counter_ini < size_ini || counter_end < size_end)
2850 for (
int l=0; l<2; l++)
2852 const int index_int_tmp = (*counters[l] < *size_references[l]) ? (*indices_references[l])(*counters[l]) : std::numeric_limits<int>::max();
2853 index_tmp.push_back(index_int_tmp);
2855 const int index_min = (int) std::distance(index_tmp.begin(), std::min_element(index_tmp.begin(), index_tmp.end()));
2858 indices_sorted[0].append_array((*indices_references[index_min])(*counters[index_min]));
2859 if (max_counter == max_index - 1)
2860 indices_sorted[1].append_array(max_n_layer - 1);
2864 indices_sorted[1].append_array((*indices_references[index_min])(*counters[index_min]));
2865 if (!indices_sorted[0].size_array())
2866 indices_sorted[0].append_array(0);
2868 (*(counters[index_min]))++;
2872 assert(indices_sorted[0].size_array() == indices_sorted[1].size_array());
2877 ArrOfInt& indices_to_remove,
2878 ArrOfInt& indices_fluxes_to_remove,
2907 const int factor_pos[3][3] = {{1, 0, 0},{0, 1, 0},{0, 0, 1}};
2908 std::vector<int> is_in_interval = {0, 0};
2911 for(
int l=0; l<indices_sorted[0].size_array(); l++)
2912 if (m < indices_fluxes_sorted[0].size_array())
2915 for (
int n=0; n<2; n++)
2918 val = indices_fluxes_sorted[n][m];
2919 const double indic = ref_ijk_ft_->get_interface().I()(*i, *j, *k);
2920 const double indic_prev = ref_ijk_ft_->get_interface().I()(*i - factor_pos[dir][0], *j - factor_pos[dir][1], *k - factor_pos[dir][2]);
2921 const int indic_test = (indic > LIQUID_INDICATOR_TEST && indic_prev > LIQUID_INDICATOR_TEST);
2926 is_in_interval[n] = (indices_fluxes_sorted[n][m] > indices_sorted[n][l]) ? 1 : 0;
2929 is_in_interval[n] = (indices_fluxes_sorted[n][m] <= indices_sorted[n][l]) ? 1 : 0;
2935 if (is_in_interval[0] || is_in_interval[1])
2937 if (is_in_interval[0])
2938 for (ll=indices_sorted[0][l]; ll<indices_fluxes_sorted[0][m]; ll++)
2940 if (is_in_interval[1])
2941 for (ll=indices_fluxes_sorted[1][m]; ll<=indices_sorted[1][l]; ll++)
2945 is_in_interval = {0, 0};
2947 for (m=0; m<indices_fluxes_sorted[0].size_array(); m++)
2948 if (indices_fluxes_sorted[0][m] == indices_fluxes_sorted[1][m])
2949 indices_fluxes_to_remove.
append_array(indices_fluxes_sorted[0][m]);
2955 const int ni = cell_faces_neighbours_corrected_all_bool[0].ni();
2956 const int nj = cell_faces_neighbours_corrected_all_bool[0].nj();
2957 const int nk = cell_faces_neighbours_corrected_all_bool[0].nk();
2960 const int nb_ghost = 1;
2962 for (c = 0; c < 3; c++)
2963 cell_faces_neighbours_corrected_min_max_bool[c].allocate(ni,nj,nk,nb_ghost);
2965 for (c = 0; c < 3; c++)
2966 for (k = -nb_ghost; k < nk + nb_ghost; k++)
2967 for (j = -nb_ghost; j < nj + nb_ghost; j++)
2968 for (i = -nb_ghost; i < ni + nb_ghost; i++)
2969 cell_faces_neighbours_corrected_min_max_bool[c](i,j,k) = cell_faces_neighbours_corrected_all_bool[c](i,j,k);
2971 const int neighbouring_face_index_from_sign[2] = {1, -1};
2972 const int neighbouring_cell_index_from_sign[2] = {0, -1};
2973 const int neighbouring_face_first_second_index_from_sign[2] = {1, 0};
2974 int neighbouring_face_index;
2975 int n_sign_mean, n_sign_first_dir, n_sign_second_dir;
2977 for (c = 0; c < 3; c++)
2978 for (k = 0; k < nk; k++)
2979 for (j = 0; j < nj; j++)
2980 for (i = 0; i < ni; i++)
2982 if (cell_faces_neighbours_corrected_all_bool[c](i,j,k))
2988 neighbouring_face_index = neighbouring_face_index_from_sign[n_sign_mean];
2989 if (!cell_faces_neighbours_corrected_min_max_bool[0](i + neighbouring_face_index,j,k))
2991 const int neighbouring_cell_index = neighbouring_cell_index_from_sign[n_sign_mean];
2995 const int j_face = neighbouring_face_first_second_index_from_sign[n_sign_first_dir];
2996 cell_faces_neighbours_corrected_min_max_bool[1](i+neighbouring_cell_index, j+j_face, k) = 0;
2997 const int k_face = neighbouring_face_first_second_index_from_sign[n_sign_second_dir];
2998 cell_faces_neighbours_corrected_min_max_bool[2](i+neighbouring_cell_index, j, k+k_face) = 0;
3003 neighbouring_face_index = neighbouring_face_index_from_sign[n_sign_mean];
3004 if (!cell_faces_neighbours_corrected_min_max_bool[1](i,j + neighbouring_face_index,k))
3006 const int neighbouring_cell_index = neighbouring_cell_index_from_sign[n_sign_mean];
3010 const int i_face = neighbouring_face_first_second_index_from_sign[n_sign_first_dir];
3011 cell_faces_neighbours_corrected_min_max_bool[0](i+i_face, j+neighbouring_cell_index, k) = 0;
3012 const int k_face = neighbouring_face_first_second_index_from_sign[n_sign_second_dir];
3013 cell_faces_neighbours_corrected_min_max_bool[2](i, j+neighbouring_cell_index, k+k_face) = 0;
3019 neighbouring_face_index = neighbouring_face_index_from_sign[n_sign_mean];
3020 if (!cell_faces_neighbours_corrected_min_max_bool[2](i,j,k + neighbouring_face_index))
3022 const int neighbouring_cell_index = neighbouring_cell_index_from_sign[n_sign_mean];
3026 const int i_face = neighbouring_face_first_second_index_from_sign[n_sign_first_dir];
3027 cell_faces_neighbours_corrected_min_max_bool[0](i+i_face, j, k+neighbouring_cell_index) = 0;
3028 const int j_face = neighbouring_face_first_second_index_from_sign[n_sign_second_dir];
3029 cell_faces_neighbours_corrected_min_max_bool[1](i, j+j_face, k+neighbouring_cell_index) = 0;
3045 const int faces_dir[6] = FACES_DIR;
3047 int nb_faces_to_correct = 0;
3055 i_pure_face_to_correct.
resize(nb_faces_to_correct_from_ijk);
3056 j_pure_face_to_correct.
resize(nb_faces_to_correct_from_ijk);
3057 k_pure_face_to_correct.
resize(nb_faces_to_correct_from_ijk);
3058 dir_pure_face_to_correct.
resize(nb_faces_to_correct_from_ijk);
3065 const int ijk_indices_i = (*intersection_ijk_cell_)(intersection_ijk_cell_index, 0);
3066 const int ijk_indices_j = (*intersection_ijk_cell_)(intersection_ijk_cell_index, 1);
3067 const int ijk_indices_k = (*intersection_ijk_cell_)(intersection_ijk_cell_index, 2);
3068 for (
int l=0; l<6; l++)
3070 const int is_neighbour_pure_liquid =
intersection_ijk_cell_->get_ijk_pure_face_neighbours(intersection_ijk_cell_index, l);
3071 if (is_neighbour_pure_liquid)
3073 const int ii_f = NEIGHBOURS_FACES_I[l];
3074 const int jj_f = NEIGHBOURS_FACES_J[l];
3075 const int kk_f = NEIGHBOURS_FACES_K[l];
3076 i_pure_face_to_correct[nb_faces_to_correct] = (ijk_indices_i + ii_f);
3077 j_pure_face_to_correct[nb_faces_to_correct] = (ijk_indices_j + jj_f);
3078 k_pure_face_to_correct[nb_faces_to_correct] = (ijk_indices_k + kk_f);
3079 dir_pure_face_to_correct[nb_faces_to_correct] = faces_dir[l];
3080 nb_faces_to_correct++;
3084 assert(nb_faces_to_correct== nb_faces_to_correct_from_ijk);
3087 if (convective_fluxes_size > 0)
3088 assert(convective_fluxes_size == nb_faces_to_correct);
3089 if (diffusive_fluxes_size > 0)
3090 assert(diffusive_fluxes_size == nb_faces_to_correct);
3095 FixedVector<std::vector<ArrOfDouble>, 3>& flux_xyz,
3096 FixedVector<std::vector<ArrOfDouble>, 3>& flux_xyz_remaining_global,
3097 FixedVector<std::map<int, int>, 3>& flux_frontier_map,
3098 const DoubleVect& fluxes_subgrid,
3099 const int ini_index)
3103 const IJK_Field_double& indicator = ref_ijk_ft_->get_interface().I();
3104 const int nb_i_layer = indicator.
ni();
3105 const int nb_j_layer = indicator.
nj();
3106 const int nb_k_layer = indicator.
nk();
3109 const Domaine_IJK& dom_ns = ref_ijk_ft_->get_interface().I().get_domaine();
3132 flux_xyz_remaining_global,
3146 for (
int i_flux=0; i_flux < nb_fluxes; i_flux++)
3148 const int k = k_pure_face_to_correct[i_flux];
3149 const int dir = dir_pure_face_to_correct[i_flux];
3150 const double flux = fluxes_subgrid[i_flux];
3152 const int i = i_pure_face_to_correct[i_flux];
3153 const int j = j_pure_face_to_correct[i_flux];
3156 index_face_ij_flux_xyz[0][dir][k].append_array(i);
3157 index_face_ij_flux_xyz[1][dir][k].append_array(j);
3168 index_face_ij_flux_xyz[0][dir][k].append_array(nb_i_layer);
3169 index_face_ij_flux_xyz[1][dir][k].append_array(j);
3171 flux_xyz[dir][k].append_array(fluxes_subgrid[i_flux]);
3174 if (i == nb_i_layer)
3178 index_face_ij_flux_xyz[0][dir][k].append_array(0);
3179 index_face_ij_flux_xyz[1][dir][k].append_array(j);
3181 flux_xyz[dir][k].append_array(fluxes_subgrid[i_flux]);
3186 if (i == 0 || i == nb_i_layer)
3188 const int i_global = (i + offset_i);
3189 const int j_global = (j + offset_j);
3190 const int k_global = (k + offset_k);
3191 const int index_flux = flux_xyz[dir][k].size_array() - 1;
3196 flux_frontier_map[dir][linear_index] = index_flux;
3197 index_face_ij_flux_xyz_remaining_global[0][dir][k_global].append_array(i_global);
3198 index_face_ij_flux_xyz_remaining_global[1][dir][k_global].append_array(j_global);
3205 index_face_ij_flux_xyz_remaining_global[0][dir][k_global].append_array(nb_i_layer_tot);
3206 index_face_ij_flux_xyz_remaining_global[1][dir][k_global].append_array(j_global);
3208 if (i_global == nb_i_layer_tot)
3210 index_face_ij_flux_xyz_remaining_global[0][dir][k_global].append_array(i_global);
3211 index_face_ij_flux_xyz_remaining_global[1][dir][k_global].append_array(j_global);
3213 flux_xyz_remaining_global[dir][k_global].append_array(flux);
3214 if (i_global == 0 || i_global == nb_i_layer_tot)
3215 flux_xyz_remaining_global[dir][k_global].append_array(flux);
3226 index_face_ij_flux_xyz[0][dir][k].append_array(i);
3227 index_face_ij_flux_xyz[1][dir][k].append_array(nb_j_layer);
3229 flux_xyz[dir][k].append_array(fluxes_subgrid[i_flux]);
3232 if (j == nb_j_layer)
3236 index_face_ij_flux_xyz[0][dir][k].append_array(i);
3237 index_face_ij_flux_xyz[1][dir][k].append_array(0);
3239 flux_xyz[dir][k].append_array(fluxes_subgrid[i_flux]);
3244 if (j == 0 || j == nb_j_layer)
3246 const int i_global = (i + offset_i);
3247 const int j_global = (j + offset_j);
3248 const int k_global = (k + offset_k);
3249 const int index_flux = flux_xyz[dir][k].size_array() - 1;
3254 flux_frontier_map[dir][linear_index] = index_flux;
3255 index_face_ij_flux_xyz_remaining_global[0][dir][k_global].append_array(i_global);
3256 index_face_ij_flux_xyz_remaining_global[1][dir][k_global].append_array(j_global);
3263 index_face_ij_flux_xyz_remaining_global[0][dir][k_global].append_array(i_global);
3264 index_face_ij_flux_xyz_remaining_global[1][dir][k_global].append_array(nb_j_layer_tot);
3266 if (j_global == nb_j_layer_tot)
3268 index_face_ij_flux_xyz_remaining_global[0][dir][k_global].append_array(i_global);
3269 index_face_ij_flux_xyz_remaining_global[1][dir][k_global].append_array(0);
3272 flux_xyz_remaining_global[dir][k_global].append_array(flux);
3273 if (j_global == 0 || j_global == nb_j_layer_tot)
3274 flux_xyz_remaining_global[dir][k_global].append_array(flux);
3285 index_face_ij_flux_xyz[0][dir][nb_k_layer_tot].append_array(i);
3286 index_face_ij_flux_xyz[1][dir][nb_k_layer_tot].append_array(j);
3288 flux_xyz[dir][nb_k_layer].append_array(fluxes_subgrid[i_flux]);
3290 if (k == nb_k_layer)
3294 index_face_ij_flux_xyz[0][dir][0].append_array(i);
3295 index_face_ij_flux_xyz[1][dir][0].append_array(j);
3297 flux_xyz[dir][0].append_array(fluxes_subgrid[i_flux]);
3302 if (k == 0 || k == nb_k_layer)
3304 const int i_global = (i + offset_i);
3305 const int j_global = (j + offset_j);
3306 const int k_global = (k + offset_k);
3307 const int index_flux = flux_xyz[dir][k].size_array() - 1;
3312 flux_frontier_map[dir][linear_index] = index_flux;
3313 index_face_ij_flux_xyz_remaining_global[0][dir][k_global].append_array(i_global);
3314 index_face_ij_flux_xyz_remaining_global[1][dir][k_global].append_array(j_global);
3321 index_face_ij_flux_xyz_remaining_global[0][dir][nb_k_layer_tot].append_array(i_global);
3322 index_face_ij_flux_xyz_remaining_global[1][dir][nb_k_layer_tot].append_array(j_global);
3324 if (k_global == nb_k_layer_tot)
3326 index_face_ij_flux_xyz_remaining_global[0][dir][0].append_array(i_global);
3327 index_face_ij_flux_xyz_remaining_global[1][dir][0].append_array(0);
3329 flux_xyz_remaining_global[dir][k_global].append_array(flux);
3331 flux_xyz_remaining_global[dir][nb_k_layer_tot].append_array(flux);
3332 if (k_global == nb_k_layer_tot)
3333 flux_xyz_remaining_global[dir][0].append_array(flux);
3341 flux_xyz_remaining_global,
3344 Cerr <<
"Fluxes have been received from procs" << finl;
3346 index_face_ij_flux_xyz_remaining_global,
3348 flux_xyz_remaining_global,
3352 Cerr <<
"Fluxes have been combined on procs" << finl;
3357 int nb_i_layer_tot = ref_ijk_ft_->get_interface().I().ni();
3358 int nb_j_layer_tot = ref_ijk_ft_->get_interface().I().nj();
3360 nb_i_layer_tot += 1;
3362 nb_j_layer_tot += 1;
3363 return (i + j * (nb_i_layer_tot) + k * (nb_i_layer_tot * nb_j_layer_tot));
3368 const Domaine_IJK& geometry = ref_ijk_ft_->get_interface().I().get_domaine();
3372 nb_i_layer_tot += 1;
3374 nb_j_layer_tot += 1;
3375 return (i + j * (nb_i_layer_tot) + k * (nb_i_layer_tot * nb_j_layer_tot));
3380 FixedVector<std::vector<ArrOfDouble>,3>& flux_xyz_remaining_global,
3381 const int ini_index)
3396 const int size_k_layers = (int) flux_xyz_remaining_global[c].size();
3397 overall_numerotation_array[c].resize(size_k_layers);
3398 start_indices_array[c].resize(size_k_layers);
3399 size_array_global_array[c] = ArrOfInt(size_k_layers);
3400 for (k=0; k<size_k_layers; k++)
3402 const int size_array = flux_xyz_remaining_global[c][k].size_array();
3403 int size_array_global = size_array;
3405 size_array_global_array[c](k) = size_array_global;
3406 overall_numerotation_array[c][k] = ArrOfInt(nb_procs);
3407 start_indices_array[c][k] = ArrOfInt(nb_procs);
3408 overall_numerotation_array[c][k](proc_num) = size_array;
3410 for (l=1; l<overall_numerotation_array[c][k].size_array(); l++)
3411 start_indices_array[c][k](l) = start_indices_array[c][k](l-1) + overall_numerotation_array[c][k](l-1);
3416 Cerr <<
"Size array" << size_array << finl;
3417 Cerr <<
"Size array global" << size_array_global << finl;
3418 Cerr <<
"Overall_numerotation" << overall_numerotation_array[c][k](0) <<
"-" << overall_numerotation_array[c][k](1) << finl;
3421 ArrOfDouble local_flux_values_tmp;
3422 ArrOfDouble& global_flux_values_tmp = flux_xyz_remaining_global[c][k];
3424 local_flux_values_tmp = global_flux_values_tmp;
3425 global_flux_values_tmp.
resize(size_array_global);
3426 global_flux_values_tmp *= 0.;
3428 for (l=0; l<local_flux_values_tmp.
size_array(); l++)
3429 global_flux_values_tmp(start_indices_array[c][k](proc_num) + l) = local_flux_values_tmp(l);
3440 const int size_k_layers = (int) index_face_ij_flux_xyz_remaining_global[0][c].size();
3441 for (k=0; k<size_k_layers; k++)
3443 const int size_array_global = size_array_global_array[c](k);
3444 ArrOfInt& start_indices = start_indices_array[c][k];
3445 ArrOfInt local_indices_i_tmp;
3446 ArrOfInt local_indices_j_tmp;
3448 ArrOfInt& global_indices_i_tmp = index_face_ij_flux_xyz_remaining_global[0][c][k];
3449 ArrOfInt& global_indices_j_tmp = index_face_ij_flux_xyz_remaining_global[1][c][k];
3451 local_indices_i_tmp = global_indices_i_tmp;
3452 local_indices_j_tmp = global_indices_j_tmp;
3454 global_indices_i_tmp.
resize(size_array_global);
3455 global_indices_j_tmp.
resize(size_array_global);
3457 global_indices_i_tmp *= 0;
3458 global_indices_j_tmp *= 0;
3460 for (l=0; l<local_indices_i_tmp.
size_array(); l++)
3462 global_indices_i_tmp(start_indices(proc_num) + l) = local_indices_i_tmp(l);
3463 global_indices_j_tmp(start_indices(proc_num) + l) = local_indices_j_tmp(l);
3476 FixedVector<std::vector<ArrOfDouble>,3>& flux_xyz,
3477 FixedVector<std::vector<ArrOfDouble>,3>& flux_xyz_remaining_global,
3478 FixedVector<std::map<int, int>, 3>& flux_frontier_map,
3479 const int ini_index)
3482 const IJK_Field_double& indicator = ref_ijk_ft_->get_interface().I();
3483 const int ni = indicator.
ni();
3484 const int nj = indicator.
nj();
3485 const int nk = indicator.
nk();
3487 const Domaine_IJK& dom_ns = ref_ijk_ft_->get_interface().I().get_domaine();
3498 for (
int dir=0; dir<3; dir++)
3500 const int size_k_layers = (int) index_face_ij_flux_xyz_remaining_global[0][dir].size();
3501 for (
int k_global=0; k_global<size_k_layers; k_global++)
3503 const int global_size_array = index_face_ij_flux_xyz_remaining_global[0][dir][k_global].size_array();
3504 for (
int l=0; l<global_size_array; l++)
3506 const int i_global = index_face_ij_flux_xyz_remaining_global[0][dir][k_global](l);
3507 const int j_global = index_face_ij_flux_xyz_remaining_global[1][dir][k_global](l);
3508 const double flux = flux_xyz_remaining_global[dir][k_global](l);
3509 const int i = i_global - offset_i;
3510 const int j = j_global - offset_j;
3511 const int k = k_global - offset_k;
3512 const int ni_max = (dir == 0 ? ni + 1 : ni);
3513 const int nj_max = (dir == 1 ? nj + 1 : nj);
3514 const int nk_max = (dir == 2 ? nk + 1 : nk);
3515 if ((0 <= i && i < ni_max) && (0 <= j && j < nj_max) && (0 <= k && k < nk_max))
3518 const int non_zero_value_local = (int) flux_frontier_map_tmp[dir].count(linear_local_index);
3519 if (!non_zero_value_local)
3522 flux_xyz[dir][k].append_array(flux);
3525 index_face_ij_flux_xyz[0][dir][k].append_array(i);
3526 index_face_ij_flux_xyz[1][dir][k].append_array(j);
3528 const int local_size_array = flux_xyz[dir][k].size_array() - 1;
3529 flux_frontier_map_tmp[dir][linear_local_index] = local_size_array;
3530 multiple_flux_values_count[dir][linear_local_index] = 1;
3531 multiple_flux_values_sum[dir][linear_local_index] = flux;
3532 multiple_flux_values_k[dir][linear_local_index] = k;
3536 const int non_zero_local_count = (int) multiple_flux_values_count[dir].count(linear_local_index);
3538 if (!non_zero_local_count)
3545 multiple_flux_values_count[dir][linear_local_index] = 0;
3546 multiple_flux_values_sum[dir][linear_local_index] = 0.;
3547 multiple_flux_values_k[dir][linear_local_index] = k;
3549 multiple_flux_values_count[dir][linear_local_index] += 1;
3550 multiple_flux_values_sum[dir][linear_local_index] += flux;
3555 for(std::map<int,double>::iterator it=multiple_flux_values_sum[dir].begin(); it!=multiple_flux_values_sum[dir].end(); ++it)
3557 const int key = it->first;
3558 const double val_flux_sum = it->second;
3559 const double count_val = (double) multiple_flux_values_count[dir][key];
3560 const int array_index = (int) flux_frontier_map_tmp[dir][key];
3561 const int k_local = (int) multiple_flux_values_k[dir][key];
3562 flux_xyz[dir][k_local](array_index) = val_flux_sum / count_val;
3566 flux_frontier_map = flux_frontier_map_tmp;
3570 FixedVector<std::vector<std::vector<ArrOfDouble>>,3>& flux_xyz,
3571 const int ini_index)
3577 for(
int l=0; l<2; l++)
3579 index_face_ij_flux_xyz[l][c].resize(nb_proc);
3582 flux_xyz[c].resize(nb_proc);
3587 FixedVector<std::vector<ArrOfDouble>,3>& flux_xyz,
3588 FixedVector<std::vector<ArrOfDouble>,3>& flux_xyz_remaining_global,
3589 const int ini_index)
3595 IJK_Field_vector3_double& cell_faces_corrected_convective,
3596 IJK_Field_vector3_double& cell_faces_corrected_diffusive)
3604 cell_faces_corrected_convective,
3622 cell_faces_corrected_diffusive,
3638 IJK_Field_vector3_double& cell_faces_corrected,
3639 const DoubleVect& fluxes,
3640 FixedVector<std::vector<ArrOfDouble>,3>& flux_xyz,
3643 for (
int c=0; c<3; c++)
3646 cell_faces_corrected_bool[c].data() = 0.;
3647 cell_faces_corrected[c].data() = 0.;
3657 for (
int i_flux=0; i_flux < nb_fluxes; i_flux++)
3659 i = i_pure_face_to_correct[i_flux];
3660 j = j_pure_face_to_correct[i_flux];
3661 k = k_pure_face_to_correct[i_flux];
3662 const int dir = dir_pure_face_to_correct[i_flux];
3664 cell_faces_corrected_bool[dir](i,j,k) += 1;
3665 cell_faces_corrected[dir](i,j,k) += fluxes[i_flux];
3670 const IJK_Field_double& indicator = ref_ijk_ft_->get_interface().I();
3671 const int ni = indicator.
ni();
3672 const int nj = indicator.
nj();
3673 const int nk = indicator.
nk();
3675 for (
int dir=0; dir<3; dir++)
3677 const int size_k = (int) index_face_ij_flux_xyz_sorted[0][dir].size();
3678 for (
int k=0; k<size_k; k++)
3680 const int size_array = index_face_ij_flux_xyz_sorted[0][dir][k].size_array();
3681 for (
int l=0; l<size_array; l++)
3683 const int i = index_face_ij_flux_xyz_sorted[0][dir][k](l);
3684 const int j = index_face_ij_flux_xyz_sorted[1][dir][k](l);
3685 const double flux = flux_xyz[dir][k](l);
3692 const int i_display = (i >= ni ? i: i);
3693 const int j_display = (j >= nj ? j: j);
3694 const int k_display = (k >= nk ? k: k);
3696 cell_faces_corrected_bool[dir](i_display, j_display, k_display) += 1;
3697 cell_faces_corrected[dir](i_display,j_display,k_display) += flux;
3708 Cerr <<
"Sort the thermal convective fluxes" << finl;
3716 Cerr <<
"Thermal Sub-resolutions convective fluxes are now sorted" << finl;
3721 Cerr <<
"Sort the thermal diffusive fluxes" << finl;
3729 Cerr <<
"Thermal Sub-resolutions diffusive fluxes are now sorted" << finl;
3779 FixedVector<std::vector<ArrOfDouble>,3>& subgrid_fluxes_xyz,
3783 const int nb_fluxes = subgrid_fluxes_xyz[dir][k_layer].size_array();
3784 for (
int i_flux=0; i_flux<nb_fluxes; i_flux++)
3786 const int i=index_face_ij_flux_xyz_sorted[0][dir][k_layer][i_flux];
3787 const int j=index_face_ij_flux_xyz_sorted[1][dir][k_layer][i_flux];
3788 const double flux_ij = subgrid_fluxes_xyz[dir][k_layer][i_flux];
3789 (*flux)(i,j,0) = flux_ij;
3794 DoubleVect& fluxes_unique,
3795 IntVect& pure_face_unique,
3796 const int known_unique)
3800 const int nb_fluxes = fluxes.
size();
3801 fluxes_unique.
reset();
3805 const int size_face_unique = pure_face_unique.
size();
3806 for (i=0; i<size_face_unique; i++)
3808 fluxes_unique.
append_array(fluxes(pure_face_unique(i)));
3813 DoubleVect shared_face;
3814 shared_face.
reset();
3815 for (i=0; i<nb_fluxes; i++)
3817 const int i_f = pure_face_to_correct[0](i);
3818 const int j_f = pure_face_to_correct[1](i);
3819 const int k_f = pure_face_to_correct[2](i);
3820 for (
int j=i; j<nb_fluxes; j++)
3823 const int i_ff = pure_face_to_correct[0](j);
3824 const int j_ff = pure_face_to_correct[1](j);
3825 const int k_ff = pure_face_to_correct[2](j);
3826 if ((i_f==i_ff) && (j_f==j_ff) && (k_f==k_ff))
3828 if (shared_face.
size() == 0)
3836 const int nb_duplicates = shared_face.
size();
3837 int min_dist_index = 0;
3838 double min_dist =
dist_[i];
3839 for (
int j=1; j<nb_duplicates; j++)
3840 if (min_dist >
dist_[j])
3842 min_dist =
dist_[j];
: class Corrige_flux_FT API pour modifier un champ de flux à partir de donnees à l'interface....
Intersection_Interface_ijk_cell * intersection_ijk_cell_
virtual void initialize_with_subproblems(const Domaine_IJK &splitting, const IJK_Field_double &field, const IJK_Interfaces &interfaces, const Probleme_FTD_IJK_base &ijk_ft, Intersection_Interface_ijk_face &intersection_ijk_face, Intersection_Interface_ijk_cell &intersection_ijk_cell, IJK_One_Dimensional_Subproblems &thermal_local_subproblems)
void initialize_with_subproblems(const Domaine_IJK &splitting, const IJK_Field_double &field, const IJK_Interfaces &interfaces, const Probleme_FTD_IJK_base &ijk_ft, Intersection_Interface_ijk_face &intersection_ijk_face, Intersection_Interface_ijk_cell &intersection_ijk_cell, IJK_One_Dimensional_Subproblems &thermal_subproblems) override
void get_add_replace_flux_value(IJK_Field_vector3_double &cell_faces_neighbours_corrected_convective_diffusive_flux, const int &dir, const int &i, const int &j, const int &k, double &convective_diffusive_flux, const double &replace_weighting_values)
void store_any_cell_faces_corrected(IJK_Field_vector3_int &cell_faces_corrected_bool, FixedVector< FixedVector< std::vector< ArrOfInt >, 3 >, 2 > &index_face_ij_flux_xyz_sorted, IJK_Field_vector3_double &cell_faces_corrected, const DoubleVect &fluxes, FixedVector< std::vector< ArrOfDouble >, 3 > &flux_xyz, const int counter)
void compute_cell_neighbours_faces_indices_to_correct(IJK_Field_vector3_int &cell_faces_neighbours_corrected_bool, IJK_Field_vector3_double &cell_faces_neighbours_corrected_velocity_temperature, IJK_Field_vector3_double &cell_faces_neighbours_corrected_convective, IJK_Field_vector3_double &cell_faces_neighbours_corrected_diffusive, IJK_Field_vector3_double &neighbours_weighting_colinearity) override
bool compute_cell_neighbours_thermal_convective_fluxes_face_centre(double &convective_flux, const int &subproblem_index, const double &dist, const int &dir, const double &colinearity, const int &index_i, const int &index_j, const int &index_k, const int &temperature=0)
void sort_ijk_intersections_subproblems_indices_by_k_layers() override
void compute_cell_neighbours_thermal_fluxes_face_centre_discrete_integral(double &flux, const int fluxes_type, const int &subproblem_index, const double &dist, const int &dir, const double &colinearity, const int &index_i, const int &index_j, const int &index_k)
int diffusion_negligible_
void combine_all_fluxes_from_outisde_frontier_on_procs(IJK_Field_vector3_int &cell_faces_neighbours_corrected_bool, IJK_Field_vector3_double &cell_faces_neighbours_corrected_velocity_temperature, IJK_Field_vector3_double &cell_faces_neighbours_corrected_convective, IJK_Field_vector3_double &cell_faces_neighbours_corrected_diffusive, IJK_Field_vector3_double &neighbours_weighting_colinearity)
void clear_vectors() override
void redistribute_indices_fluxes_by_k_layers(FixedVector< FixedVector< std::vector< ArrOfInt >, 3 >, 2 > &index_face_i_flux_x, FixedVector< FixedVector< std::vector< ArrOfInt >, 3 >, 2 > &index_face_i_flux_x_remaining_global, FixedVector< std::vector< ArrOfDouble >, 3 > &flux_xyz, FixedVector< std::vector< ArrOfDouble >, 3 > &flux_xyz_remaining_global, const int ini_index)
void receive_temperature_cell_centre_neighbours_from_procs()
int keep_first_reachable_fluxes_
void corrige_flux_diff_faceIJ(IJK_Field_local_double *const flux, const int k_layer, const int dir) override
void compute_cell_neighbours_faces_indices_for_spherical_correction(const int &n_iter_distance) override
FixedVector< ArrOfInt, 3 > indices_temperature_neighbours_on_procs_
ArrOfDouble temperature_neighbours_on_procs_
void replace_cell_neighbours_thermal_convective_diffusive_fluxes_faces(const IJK_Field_vector3_int &cell_faces_neighbours_corrected_min_max_bool, const IJK_Field_vector3_int &cell_faces_neighbours_corrected_all_bool, const IJK_Field_vector3_double &cell_faces_neighbours_fluxes_corrected, const int &fluxes_type) override
FixedVector< std::map< int, int >, 3 > flux_frontier_map_
bool has_checked_consistency_
FixedVector< FixedVector< std::vector< ArrOfDouble >, 3 >, 2 > convective_diffusive_flux_xyz_sorted_
void sort_ijk_intersections_subproblems_indices_fluxes_by_k_layers(FixedVector< FixedVector< std::vector< ArrOfInt >, 3 >, 2 > &index_face_ij_flux_xyz, FixedVector< FixedVector< std::vector< ArrOfInt >, 3 >, 2 > &index_face_ij_flux_xyz_remaining_global, FixedVector< std::vector< ArrOfDouble >, 3 > &flux_xyz, FixedVector< std::vector< ArrOfDouble >, 3 > &flux_xyz_remaining_global, FixedVector< std::map< int, int >, 3 > &flux_frontier_map, const DoubleVect &fluxes_subgrid, const int ini_index)
void combine_fluxes_from_frontier_on_procs(FixedVector< FixedVector< std::vector< ArrOfInt >, 3 >, 2 > &index_face_ij_flux_xyz, FixedVector< FixedVector< std::vector< ArrOfInt >, 3 >, 2 > &index_face_ij_flux_xyz_remaining_global, FixedVector< std::vector< ArrOfDouble >, 3 > &flux_xyz, FixedVector< std::vector< ArrOfDouble >, 3 > &flux_xyz_remaining_global, FixedVector< std::map< int, int >, 3 > &flux_frontier_map, const int ini_index)
void initialise_any_cell_neighbours_indices_to_correct(FixedVector< FixedVector< std::vector< ArrOfInt >, 3 >, 2 > &index_face_ij_flux_xyz_faces_sorted, const int global_indices=0)
void clear_std_vectors_array_of_double(std::vector< ArrOfDouble > &values_to_clear)
int get_linear_index_local(const int &i, const int &j, const int &k, const int &dir)
void remove_min_max_ijk_reachable_fluxes_discontinuous(const IJK_Field_vector3_int &cell_faces_neighbours_corrected_all_bool, FixedVector< IJK_Field_local_int, 3 > &cell_faces_neighbours_corrected_min_max_bool)
void associate_indices_and_check_subproblems_consistency()
void check_pure_fluxes_duplicates(const DoubleVect &fluxes, DoubleVect &fluxes_unique, IntVect &pure_face_unique, const int known_unique)
void receive_fluxes_from_frontier_on_procs(FixedVector< FixedVector< std::vector< ArrOfInt >, 3 >, 2 > &index_face_ij_flux_xyz_remaining_global, FixedVector< std::vector< ArrOfDouble >, 3 > &flux_xyz_remaining_global, const int ini_index)
int copy_temperature_on_every_procs_
int find_reachable_fluxes_
int get_linear_index_global(const int &i, const int &j, const int &k, const int &dir)
FixedVector< FixedVector< std::vector< ArrOfDouble >, 3 >, 2 > convective_diffusive_flux_xyz_remaining_global_sorted_
ArrOfDouble neighbours_weighting_colinearity_on_procs_
DoubleVect convective_fluxes_
void replace_temperature_cell_centre_neighbours(IJK_Field_double &temperature, IJK_Field_double &temperature_neighbours, IJK_Field_int &neighbours_weighting, IJK_Field_double &neighbours_weighting_colinearity) const override
void store_cell_faces_corrected(IJK_Field_vector3_int &cell_faces_corrected_bool, IJK_Field_vector3_double &cell_faces_corrected_convective, IJK_Field_vector3_double &cell_faces_corrected_diffusive) override
void compute_thermal_fluxes_face_centre(DoubleVect &fluxes, const int fluxes_type, const int &last_flux)
bool compute_cell_neighbours_diffusive_fluxes_to_correct(double &diffusive_flux, const int &subproblem_index, const double &dist, const int &dir, const double &colinearity, const int &index_i, const int &index_j, const int &index_k)
FixedVector< std::map< int, int >, 3 > flux_frontier_all_map_
FixedVector< std::vector< ArrOfDouble >, 3 > colinearity_flux_xyz_neighbours_all_faces_remaining_global_sorted_
IJK_One_Dimensional_Subproblems * thermal_subproblems_
void initialise_fixed_vectors(FixedVector< FixedVector< std::vector< ArrOfInt >, 3 >, 2 > &fixed_vectors, const int nb_k_layer)
void compute_thermal_diffusive_fluxes(const int &last_flux) override
FixedVector< std::vector< ArrOfDouble >, 3 > temperature_flux_all_faces_remaining_global_sorted_
FixedVector< FixedVector< std::vector< ArrOfInt >, 3 >, 2 > index_face_ij_flux_xyz_remaining_global_sorted_
void compute_cell_neighbours_thermal_convective_fluxes_face_centre_discrete_integral(double &convective_flux, const int &subproblem_index, const double &dist, const int &dir, const double &colinearity, const int &index_i, const int &index_j, const int &index_k)
void corrige_flux_faceIJ(IJK_Field_local_double *const flux, const int k_layer, const int dir) override
void compute_flux_neighbours_on_procs(const int &index_i_neighbour_global, const int &index_j_neighbour_global, const int &index_k_neighbour_global, const int &subproblem_index, const double &dist, const int &dir, const double &colinearity, const int &index_i, const int &index_j, const int &index_k, const double &convective_flux_computed=0, const double &diffusive_flux_computed=0)
FixedVector< std::vector< ArrOfInt >, 3 > weighting_flux_xyz_neighbours_all_faces_remaining_global_sorted_
void clear_std_vectors_array_of_int(std::vector< ArrOfInt > &indices_to_clear)
DoubleVect compute_thermal_flux_face_centre_discrete_integral(const int fluxes_type, const int &index_subproblem, const double &dist, const int &dir, const int &l=-1)
void update_intersections() override
const IJK_Field_vector3_double * eulerian_normal_vectors_ns_normed_
bool compute_cell_neighbours_thermal_fluxes_face_centre(double &flux, const int fluxes_type, const int &subproblem_index, const double &dist, const int &dir, const double &colinearity, const int &index_i, const int &index_j, const int &index_k, const int &temperature=0)
void compute_ijk_pure_faces_indices() override
void receive_all_fluxes_from_outisde_frontier_on_procs()
void smooth_temperature_cell_centre_neighbours(IJK_Field_double &temperature, ArrOfInt &corrected_values, ArrOfInt &out_of_bounds_corrected_values, ArrOfDouble &out_of_bounds_values, IJK_Field_double &distance) const
void initialise_any_cell_neighbours_indices_to_correct_with_flux(FixedVector< FixedVector< std::vector< ArrOfInt >, 3 >, 2 > &index_face_ij_flux_xyz_faces_sorted, FixedVector< std::vector< ArrOfDouble >, 3 > &fluxes, FixedVector< std::vector< ArrOfInt >, 3 > &weighting_flux_xyz_faces_sorted, FixedVector< std::vector< ArrOfDouble >, 3 > &colinearity_flux_xyz_faces_sorted, FixedVector< std::vector< ArrOfDouble >, 3 > &temperature_flux_xyz_faces_sorted, const bool &ini_index, const int global_indices=0, const int weighting_colinearity=0)
double compute_thermal_flux_face_centre(const int fluxes_type, const int &index_subproblem, const double &dist, const int &dir, bool &valid_val, const int &l=-1, const int &index_i=INVALID_INDEX, const int &index_j=INVALID_INDEX, const int &index_k=INVALID_INDEX, const int &temperature=0)
void set_zero_temperature_increment(IJK_Field_double &d_temperature) const override
int use_reachable_fluxes_
int convection_negligible_
void compute_min_max_ijk_any_reachable_fluxes(const IJK_Field_vector3_int &cell_faces_neighbours_corrected_all_bool, const IJK_Field_int &neighbours_temperature_to_correct, IJK_Field_vector3_int &cell_faces_neighbours_corrected_min_max_bool, const int &max_flux_per_dir, const int &check_cell_center_neighbour, const int &remove_external_neighbour_values, IJK_Field_int &neighbours_temperature_to_correct_trimmed) override
void replace_cell_neighbours_thermal_fluxes_faces(const IJK_Field_vector3_int &cell_faces_neighbours_corrected_min_max_bool, const IJK_Field_vector3_int &cell_faces_neighbours_corrected_all_bool, const IJK_Field_vector3_double &cell_faces_neighbours_fluxes_corrected, FixedVector< std::vector< ArrOfDouble >, 3 > &flux_xyz, const int counter)
void compute_temperature_cell_centre_neighbours(IJK_Field_double &temperature_neighbours, IJK_Field_int &neighbours_weighting, IJK_Field_double &neighbours_weighting_colinearity) override
void compute_cell_neighbours_mixed_cell_faces_any_field(IJK_Field_vector3_int &cell_faces_neighbours_corrected_bool, IJK_Field_local_double &cell_faces_neighbours_corrected_field, IJK_Field_vector3_double &cell_faces_neighbours_corrected_field_mixed_cell)
FixedVector< FixedVector< std::vector< ArrOfDouble >, 3 >, 2 > convective_diffusive_flux_all_faces_remaining_global_sorted_
int convective_flux_correction_
int keep_max_flux_correction_
void corrige_flux_faceIJ_any_flux(IJK_Field_local_double *const flux, FixedVector< FixedVector< std::vector< ArrOfInt >, 3 >, 2 > &index_face_ij_flux_xyz_sorted, FixedVector< std::vector< ArrOfDouble >, 3 > &subgrid_fluxes_xyz, const int k_layer, const int dir)
void complete_neighbours_and_weighting_colinearity(IJK_Field_vector3_int &cell_faces_neighbours_corrected_bool, IJK_Field_vector3_double &cell_faces_neighbours_corrected_velocity_temperature, IJK_Field_vector3_double &cell_faces_neighbours_corrected_convective, IJK_Field_vector3_double &cell_faces_neighbours_corrected_diffusive, IJK_Field_vector3_double &neighbours_weighting_colinearity, const int &compute_fluxes_values)
void sort_ini_end_arrays(ArrOfInt &indices_found_transition_ini, ArrOfInt &indices_found_transition_end, ArrOfInt &indices_found_ini, ArrOfInt &indices_found_end, FixedVector< ArrOfInt, 2 > &indices_sorted, const int &max_n_layer)
bool compute_cell_neighbours_convective_fluxes_to_correct(double &convective_flux, const int &subproblem_index, const double &dist, const int &dir, const double &colinearity, const int &index_i, const int &index_j, const int &index_k, const int &temperature=0)
IJK_Field_vector3_int * cell_faces_neighbours_corrected_bool_
void compute_thermal_diffusive_fluxes_face_centre_discrete_integral()
int use_cell_neighbours_for_fluxes_spherical_correction_
void compute_cell_neighbours_fluxes_to_correct(IJK_Field_vector3_int &cell_faces_neighbours_corrected_bool, IJK_Field_vector3_double &neighbours_weighting_colinearity, IJK_Field_vector3_double &cell_faces_neighbours_corrected_convective, IJK_Field_vector3_double &cell_faces_neighbours_corrected_diffusive, IJK_Field_vector3_double &cell_faces_neighbours_corrected_velocity_temperature, const int &subproblem_index, const int &index_i, const int &index_j, const int &index_k, const double &dist, const int &dir, const double &colinearity, const int &compute_fluxes_values, double &convective_flux, double &diffusive_flux)
int diffusive_flux_correction_
void compute_min_max_ijk_reachable_fluxes(const IJK_Field_vector3_int &cell_faces_neighbours_corrected_all_bool, const IJK_Field_int &neighbours_temperature_to_correct, IJK_Field_vector3_int &cell_faces_neighbours_corrected_min_max_bool, const int &max_flux_per_dir, const int &check_cell_center_neighbour, const int &remove_external_neighbour_values, IJK_Field_int &neighbours_temperature_to_correct_trimmed) override
DoubleVect diffusive_fluxes_
void associate_thermal_problems(IJK_One_Dimensional_Subproblems &thermal_subproblems)
int smooth_temperature_field_
ArrOfInt ijk_intersections_subproblems_indices_
FixedVector< FixedVector< std::vector< ArrOfInt >, 3 >, 2 > index_face_ij_flux_xyz_sorted_
bool compute_cell_neighbours_thermal_diffusive_fluxes_face_centre(double &diffusive_flux, const int &subproblem_index, const double &dist, const int &dir, const double &colinearity, const int &index_i, const int &index_j, const int &index_k)
void compute_thermal_convective_fluxes_face_centre_discrete_integral()
int find_cell_neighbours_for_fluxes_spherical_correction_
FixedVector< FixedVector< std::vector< ArrOfInt >, 3 >, 2 > index_face_ij_flux_xyz_neighbours_min_max_faces_sorted_
bool identify_wrong_predicted_values(IJK_Field_vector3_int &cell_faces_neighbours_corrected_bool, IJK_Field_vector3_double &cell_faces_neighbours_corrected_convective_diffusive_flux, const int &dir, const int &index_i, const int &index_j, const int &index_k, double &convective_diffusive_flux)
void compute_thermal_convective_fluxes_face_centre(const int &last_flux)
void initialise_fixed_vector(FixedVector< std::vector< ArrOfInt >, 3 > &fixed_vector, const int nb_k_layer)
void complete_thermal_fluxes_face_centre(const int &fluxes_correction_conservations) override
void compute_thermal_diffusive_fluxes_face_centre(const int &last_flux)
void initialise_cell_neighbours_indices_to_correct() override
FixedVector< IntVect, 4 > ijk_faces_to_correct_
FixedVector< std::map< int, int >, 3 > flux_outside_frontier_all_map_
int store_flux_operators_for_energy_balance_
int distance_cell_faces_from_lrs_
void combine_temperature_cell_centre_neighbours_from_procs(IJK_Field_double &temperature_neighbours, IJK_Field_int &neighbours_weighting, IJK_Field_double &neighbours_weighting_colinearity, const int &ni, const int &nj, const int &nk, const int &offset_i, const int &offset_j, const int &offset_k)
FixedVector< FixedVector< std::vector< ArrOfInt >, 3 >, 2 > index_face_ij_flux_xyz_neighbours_all_faces_sorted_
void initialise_any_cell_neighbours_indices_to_correct_on_processors(FixedVector< FixedVector< std::vector< std::vector< ArrOfInt > >, 3 >, 2 > &index_face_ij_flux_xyz, FixedVector< std::vector< std::vector< ArrOfDouble > >, 3 > &flux_xyz, const int ini_index)
int find_temperature_cell_neighbours_
void compute_cell_neighbours_thermal_diffusive_fluxes_face_centre_discrete_integral(double &diffusive_flux, const int &subproblem_index, const double &dist, const int &dir, const double &colinearity, const int &index_i, const int &index_j, const int &index_k)
void correct_flux_spherical(Simd_double &a, Simd_double &b, const int &i, const int &j, const int &k_layer, const int dir) override
int neighbours_colinearity_weighting_
FixedVector< FixedVector< std::vector< ArrOfDouble >, 3 >, 2 > convective_diffusive_flux_xyz_min_max_faces_sorted_
void remove_non_overlapping_fluxes_values(const FixedVector< ArrOfInt, 2 > &indices_sorted, const FixedVector< ArrOfInt, 2 > &indices_fluxes_sorted, ArrOfInt &indices_to_remove, ArrOfInt &indices_fluxes_to_remove, int &index_bis, int &index_ter, const int &dir)
void compute_temperature_cell_centre_neighbours_on_procs(const double &temperature_neighbours, const double &neighbours_weighting_colinearity, const int &index_i_neighbour_global, const int &index_j_neighbour_global, const int &index_k_neighbour_global)
FixedVector< FixedVector< std::vector< ArrOfInt >, 3 >, 2 > index_face_ij_flux_xyz_neighbours_diag_faces_sorted_
void initialise_fixed_vector_values(FixedVector< std::vector< ArrOfDouble >, 3 > &fixed_vector_values, const int nb_k_layer)
FixedVector< FixedVector< std::vector< ArrOfInt >, 3 >, 2 > index_face_ij_flux_xyz_neighbours_all_faces_remaining_global_sorted_
void compute_thermal_convective_fluxes(const int &last_flux) override
void compute_temperature_cell_centre(IJK_Field_double &temperature) const override
void compute_thermal_fluxes_face_centre_discrete_integral(DoubleVect &fluxes, const int fluxes_type)
int copy_fluxes_on_every_procs_
void compute_cell_neighbours_mixed_cell_faces_indices_to_correct(IJK_Field_vector3_int &cell_faces_neighbours_corrected_bool_mixed_cell, IJK_Field_vector3_double &cell_faces_neighbours_corrected_velocity_temperature, IJK_Field_vector3_double &cell_faces_neighbours_corrected_convective_mixed_cell, IJK_Field_vector3_double &cell_faces_neighbours_corrected_diffusive_mixed_cell, IJK_Field_vector3_double &neighbours_weighting_colinearity_mixed_cell)
This class encapsulates all the information related to the eulerian mesh for TrioIJK.
int get_offset_local(int direction) const
Returns the local offset in requested direction.
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.
FixedVector< int, 3 > convert_packed_to_ijk_cell(int index) const
Convert the local index of an element to a vector with IJK indices.
Class defining operators and methods for all reading operation in an input flow (file,...
void allocate(int ni, int nj, int nk, int ghosts, int additional_k_layers=0, int nb_compo=1, bool external_storage=false)
void echange_espace_virtuel(int ghost)
Exchange data over "ghost" number of cells.
const Domaine_IJK & get_domaine() const
void echange_espace_virtuel()
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
static int check_int_overflow(trustIdType)
static void mp_sum_for_each_item(TRUSTArray< _TYPE_ > &x, int n=-1)
static int nproc()
renvoie le nombre de processeurs dans le groupe courant Voir Comm_Group::nproc() et PE_Groups::curren...
static double mp_sum(double)
Calcule la somme de x sur tous les processeurs du groupe courant.
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.
Classe de base des flux de sortie.
void append_array(_TYPE_ valeur)
_SIZE_ size_array() const
void resize(_SIZE_ new_size, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
void reset() override
met l'objet dans l'etat obtenu par le constructeur par defaut.
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)