798void FT_Field::Calculate_Facette_Intersection_Area(DoubleTab& Surface_fa7init, DoubleTab& Surface_fa7fin, DoubleTab& Surface_intersection, vector<Point3D> points_fa7_originale, vector<Point3D> points_fa7_finale, IntTab points_triangle_originaux, IntTab points_triangle_finaux, IntTab& normale_triangle_originaux, IntTab& normale_triangle_finaux)
806 if(points_fa7_originale.size()==0 and points_fa7_finale.size()==0)
811 int nbtriangle_originaux = points_triangle_originaux.
dimension(0);
812 int nbtriangle_finaux = points_triangle_finaux.
dimension(0);
818 array<double, 3> planeVector1 = eigenPairs[0].second;
819 array<double, 3> planeVector2 = eigenPairs[1].second;
822 vector<Point2D> projectedPoints_fa7_originale;
823 for (
const auto &point : points_fa7_originale)
825 projectedPoints_fa7_originale.push_back(
projectPointToPlane(point, centroid, planeVector1, planeVector2));
827 vector<Point2D> projectedPoints_fa7_finale;
828 for (
const auto &point : points_fa7_finale)
830 projectedPoints_fa7_finale.push_back(
projectPointToPlane(point, centroid, planeVector1, planeVector2));
836 for (
int to = 0; to < nbtriangle_originaux; to++)
838 const Point3D normale = {normale_facette_initiale_(to, 0),normale_facette_initiale_(to, 1),normale_facette_initiale_(to, 2)};
842 for (
int to = 0; to < nbtriangle_finaux; to++)
847 Point3D AB = {triangle_initiaux_(to, 1, 0)-triangle_initiaux_(to, 0, 0),
848 triangle_initiaux_(to, 1, 1)-triangle_initiaux_(to, 0, 1),
849 triangle_initiaux_(to, 1, 2)-triangle_initiaux_(to, 0, 2)
851 Point3D AC = {triangle_initiaux_(to, 2, 0)-triangle_initiaux_(to, 0, 0),
852 triangle_initiaux_(to, 2, 1)-triangle_initiaux_(to, 0, 1),
853 triangle_initiaux_(to, 2, 2)-triangle_initiaux_(to, 0, 2)
856 int orientation_normale_avant_deplacement =
orientation_triangle(normale, planeVector1, planeVector2);
857 AB = {triangle_finaux_(to, 1, 0)-triangle_finaux_(to, 0, 0),
858 triangle_finaux_(to, 1, 1)-triangle_finaux_(to, 0, 1),
859 triangle_finaux_(to, 1, 2)-triangle_finaux_(to, 0, 2)
861 AC = {triangle_finaux_(to, 2, 0)-triangle_finaux_(to, 0, 0),
862 triangle_finaux_(to, 2, 1)-triangle_finaux_(to, 0, 1),
863 triangle_finaux_(to, 2, 2)-triangle_finaux_(to, 0, 2)
866 int orientation_normale_apres_deplacement =
orientation_triangle(normale, planeVector1, planeVector2);
868 const Point3D normale_ref = {normale_facette_initiale_(to, 0),normale_facette_initiale_(to, 1),normale_facette_initiale_(to, 2)};
869 normale_triangle_finaux(to) =
orientation_triangle(normale_ref, planeVector1, planeVector2)*orientation_normale_apres_deplacement*orientation_normale_avant_deplacement;
874 for (
int tf = 0; tf < nbtriangle_finaux; tf++)
877 p1f = projectedPoints_fa7_finale[points_triangle_finaux(tf,0)];
878 p2f = projectedPoints_fa7_finale[points_triangle_finaux(tf,1)];
879 p3f = projectedPoints_fa7_finale[points_triangle_finaux(tf,2)];
881 Point2D t1[3] = {{p1f.
x, p1f.
y},{p2f.
x, p2f.
y},{p3f.
x, p3f.
y}};
884 for (
int to = 0; to < nbtriangle_originaux; to++)
887 p1o = projectedPoints_fa7_originale[points_triangle_originaux(to,0)];
888 p2o = projectedPoints_fa7_originale[points_triangle_originaux(to,1)];
889 p3o = projectedPoints_fa7_originale[points_triangle_originaux(to,2)];
890 Point2D t2[3] = {{p1o.
x, p1o.
y},{p2o.
x, p2o.
y},{p3o.
x, p3o.
y}};
900 bool triangle_already_sauv =
false;
901 if (avant_apres_remaillage==0)
908 if (check_triangle_duplicata_)
912 Point3D p1new = {facettes_sommets_full_compo_(i, 0),facettes_sommets_full_compo_(i, 1),facettes_sommets_full_compo_(i, 2)};
913 Point3D p2new = {facettes_sommets_full_compo_(i, 3),facettes_sommets_full_compo_(i, 4),facettes_sommets_full_compo_(i, 5)};
914 Point3D p3new = {facettes_sommets_full_compo_(i, 6),facettes_sommets_full_compo_(i, 7),facettes_sommets_full_compo_(i, 8)};
918 if (p1new == p1ref and p2new == p2ref and p3new == p3ref)
919 triangle_already_sauv =
true;
922 if(!triangle_already_sauv)
924 int index_triangle = triangle_initiaux_.dimension(0);
925 triangle_initiaux_.resize(index_triangle+1, 3, 3);
926 normale_facette_initiale_.resize(index_triangle+1, 3);
927 Surfactant_facette_initiale_.resize(index_triangle+1);
928 Surfactant_facette_initiale_(index_triangle) = facettes_sommets_full_compo_(i, 9);
929 for (
int i_som = 0; i_som < 3; i_som++)
930 for (
int dir = 0; dir < 3; dir++)
932 triangle_initiaux_(index_triangle, i_som, dir) = facettes_sommets_full_compo_(i, 3*i_som+dir);
934 for (
int dir = 0; dir < 3; dir++)
936 normale_facette_initiale_(index_triangle, dir) = facettes_sommets_full_compo_(i, 12+dir);
940 if (avant_apres_remaillage==1)
947 if (check_triangle_duplicata_)
951 Point3D p1new = {facettes_sommets_full_compo_(i, 0),facettes_sommets_full_compo_(i, 1),facettes_sommets_full_compo_(i, 2)};
952 Point3D p2new = {facettes_sommets_full_compo_(i, 3),facettes_sommets_full_compo_(i, 4),facettes_sommets_full_compo_(i, 5)};
953 Point3D p3new = {facettes_sommets_full_compo_(i, 6),facettes_sommets_full_compo_(i, 7),facettes_sommets_full_compo_(i, 8)};
957 if (p1new == p1ref and p2new == p2ref and p3new == p3ref)
958 triangle_already_sauv =
true;
961 if(!triangle_already_sauv)
963 int index_triangle = triangle_finaux_.dimension(0);
964 triangle_finaux_.resize(index_triangle+1, 3, 3);
965 normale_facette_finale_.resize(index_triangle+1, 3);
966 indice_facette_finaux_.resize(index_triangle+1);
967 indice_facette_finaux_(index_triangle)=i;
968 for (
int i_som = 0; i_som < 3; i_som++)
969 for (
int dir = 0; dir < 3; dir++)
970 triangle_finaux_(index_triangle, i_som, dir) = facettes_sommets_full_compo_(i, 3*i_som+dir);
971 for (
int dir = 0; dir < 3; dir++)
973 normale_facette_finale_(index_triangle, dir) = facettes_sommets_full_compo_(i, 12+dir);
984 int nb_triangle_fin = triangle_finaux_.dimension(0);
985 int nb_triangle_init = triangle_initiaux_.dimension(0);
987 if (nb_triangle_fin == 0 or nb_triangle_init==0)
991 if ((nb_triangle_fin == 0 or nb_triangle_init==0) and nb_triangle_fin!=nb_triangle_init)
993 std::cout <<
"Erreur : nb_triangle_fin = " << nb_triangle_fin <<
" et triangle_initiaux_= " << nb_triangle_init << std::endl;
996 if (!variable_intensive_)
998 std::cout <<
"Erreur : la variable doit etre intensive ici" ;
1002 ArrOfDouble surfactant_copy ;
1003 vector<Point3D> points_fa7_originale((nb_triangle_init)*3);
1004 vector<Point3D> points_fa7_finale((nb_triangle_fin)*3);
1007 for (
int ifaforsom = 0; ifaforsom < nb_triangle_init; ifaforsom++)
1010 for (i_sommet = 0; i_sommet < 3; i_sommet++)
1011 points_fa7_originale[3*ifaforsom+i_sommet]= {triangle_initiaux_(ifaforsom, i_sommet, 0),triangle_initiaux_(ifaforsom, i_sommet, 1),triangle_initiaux_(ifaforsom, i_sommet, 2)};
1013 for (
int ifaforsom= 0; ifaforsom < nb_triangle_fin; ifaforsom++)
1016 for (i_sommet = 0; i_sommet < 3; i_sommet++)
1017 points_fa7_finale[3*ifaforsom+i_sommet]= {triangle_finaux_(ifaforsom, i_sommet, 0),triangle_finaux_(ifaforsom, i_sommet, 1),triangle_finaux_(ifaforsom, i_sommet, 2)};
1021 vector<Point3D> points_fa7_finale_unique =
removeDuplicates(points_fa7_finale);
1022 vector<Point3D> points_fa7_originale_unique =
removeDuplicates(points_fa7_originale);
1025 IntTab points_triangle_originaux(nb_triangle_init,3);
1026 IntTab points_triangle_finaux(nb_triangle_fin,3);
1028 for (
int ifaforsom = 0; ifaforsom < nb_triangle_fin; ifaforsom++)
1032 for (i_sommet = 0; i_sommet < 3; i_sommet++)
1034 int n =
static_cast<int>(points_fa7_finale_unique.size());
1035 for (index_point = 0; index_point < n; index_point++)
1037 Point3D point_liste = points_fa7_finale_unique[index_point];
1038 Point3D point_triangle = {triangle_finaux_(ifaforsom, i_sommet, 0),triangle_finaux_(ifaforsom, i_sommet, 1),triangle_finaux_(ifaforsom, i_sommet, 2)};
1039 if(point_liste==point_triangle)
1041 points_triangle_finaux(ifaforsom, i_sommet)=index_point;
1047 for (
int ifaforsom = 0; ifaforsom < nb_triangle_init; ifaforsom++)
1052 for (i_sommet = 0; i_sommet < 3; i_sommet++)
1054 int n =
static_cast<int>(points_fa7_originale_unique.size());
1055 for (index_point = 0; index_point < n; index_point++)
1057 Point3D point_liste = points_fa7_originale_unique[index_point];
1058 Point3D point_triangle = {triangle_initiaux_(ifaforsom, i_sommet, 0),triangle_initiaux_(ifaforsom, i_sommet, 1),triangle_initiaux_(ifaforsom, i_sommet, 2)};
1059 if(point_liste==point_triangle)
1061 points_triangle_originaux(ifaforsom, i_sommet)=index_point;
1072 bool structure_complete =
true;
1073 int n =
static_cast<int>(points_fa7_originale_unique.size());
1074 for (
int index_point = 0; index_point < n; index_point++)
1076 int nb_triangle = 0;
1077 for (
int ifaforsom = 0; ifaforsom < nb_triangle_init; ifaforsom++)
1079 for (
int i_sommet = 0; i_sommet < 3; i_sommet++)
1081 if (points_triangle_originaux(ifaforsom, i_sommet)==index_point)
1089 structure_complete=
false;
1092 if(!structure_complete)
1094 std::cout <<
"WARNING : structure incomplete de fa7 pour le remaillage surfactant" << std::endl;
1095 std::cout <<
"la concentration initiale moyenne est appliquee a toute la structure en question" << std::endl;
1096 std::cout <<
"Cela peut provoquer des erreurs de conservation" << std::endl;
1100 DoubleTab Surface_intersection(nb_triangle_fin, nb_triangle_init);
1101 DoubleTab Surface_fa7init(nb_triangle_init);
1102 DoubleTab Surface_fa7fin(nb_triangle_fin);
1103 IntTab normale_triangle_originaux(nb_triangle_init);
1104 IntTab normale_triangle_finaux(nb_triangle_fin);
1105 Calculate_Facette_Intersection_Area(Surface_fa7init, Surface_fa7fin, Surface_intersection, points_fa7_originale_unique, points_fa7_finale_unique, points_triangle_originaux, points_triangle_finaux,normale_triangle_originaux,normale_triangle_finaux);
1110 surfactant_copy.
resize(facettes_sommets_full_compo_.dimension(0));
1111 for (
int fa = 0; fa < facettes_sommets_full_compo_.dimension(0); fa++)
1112 surfactant_copy(fa)=0.;
1117 int orientation_principale = 0;
1118 for (
int tf = 0; tf < nb_triangle_fin; tf++)
1120 orientation_principale+=normale_triangle_finaux(tf);
1122 if (orientation_principale>=0)
1123 orientation_principale = 1;
1125 orientation_principale = -1;
1129 ArrOfDouble surfactant_final(nb_triangle_fin);
1132 if (structure_complete)
1134 for (
int tf = 0; tf < nb_triangle_fin; tf++)
1136 int fa7 = indice_facette_finaux_(tf);
1138 double surfactant_facette_finale=0.;
1139 for (
int to = 0; to < nb_triangle_init; to++)
1141 if(normale_triangle_finaux(tf) == orientation_principale)
1143 surfactant_facette_finale+=Surfactant_facette_initiale_(to)*Surface_intersection(tf, to)/Surface_fa7init[to];
1146 surfactant_copy(fa7) = surfactant_facette_finale ;
1147 surfactant_final(tf) = surfactant_facette_finale ;
1150 double reste_surfactant = 0.;
1151 double tot_surfactant = 0.;
1152 for (
int to = 0; to < nb_triangle_init; to++)
1154 tot_surfactant+=Surfactant_facette_initiale_(to);
1156 reste_surfactant = tot_surfactant;
1157 for (
int tf = 0; tf < nb_triangle_fin; tf++)
1159 reste_surfactant-=surfactant_final(tf);
1163 double surface_finale_manquante = 0. ;
1164 double surface_structure_finale = 0.;
1165 for (
int tf = 0; tf < Surface_fa7fin.
size_array(); tf++)
1167 double conservation = 0. ;
1168 if(normale_triangle_finaux(tf) == orientation_principale)
1170 surface_structure_finale+=Surface_fa7fin[tf];
1172 for (
int to = 0; to < Surface_fa7init.
size_array(); to++)
1174 if(normale_triangle_finaux(tf) == orientation_principale)
1175 conservation += Surface_intersection(tf,to);
1177 conservation/=Surface_fa7fin[tf];
1178 if (abs(conservation-1.)>1.e-8)
1180 if(normale_triangle_finaux(tf) == orientation_principale)
1181 surface_finale_manquante += (1.-conservation)*Surface_fa7fin[tf];
1186 for (
int tf = 0; tf < Surface_fa7fin.
size_array(); tf++)
1188 double conservation = 0. ;
1189 for (
int to = 0; to < Surface_fa7init.
size_array(); to++)
1191 if(normale_triangle_finaux(tf) == orientation_principale)
1192 conservation += Surface_intersection(tf,to);
1194 conservation/=Surface_fa7fin[tf];
1203 if (surface_finale_manquante!=0.)
1205 if(normale_triangle_finaux(tf) == orientation_principale)
1207 surfactant_final(tf)+=reste_surfactant * ((1.-conservation) * Surface_fa7fin[tf]/surface_finale_manquante) ;
1208 int fa7 = indice_facette_finaux_(tf);
1209 surfactant_copy(fa7) = surfactant_final(tf);
1220 if(normale_triangle_finaux(tf) == orientation_principale)
1222 surfactant_final(tf)+=reste_surfactant * Surface_fa7fin[tf] / surface_structure_finale ;
1223 int fa7 = indice_facette_finaux_(tf);
1224 surfactant_copy(fa7) = surfactant_final(tf);
1234 double quantite_surf = 0.;
1235 double surf_tot = 0.;
1236 for (
int to = 0; to < nb_triangle_init; to++)
1238 if (nb_triangle_init>2)
1240 if(normale_triangle_finaux(to) == orientation_principale)
1242 quantite_surf += Surfactant_facette_initiale_(to);
1243 surf_tot += Surface_fa7init[to];
1248 quantite_surf += Surfactant_facette_initiale_(to);
1249 surf_tot += Surface_fa7init[to];
1253 for (
int tf = 0; tf < nb_triangle_fin; tf++)
1255 int fa7 = indice_facette_finaux_(tf);
1256 surfactant_copy(fa7) = (quantite_surf/surf_tot)*Surface_fa7fin[tf] ;
1257 surfactant_final(tf) = (quantite_surf/surf_tot)*Surface_fa7fin[tf] ;
1261 for (
int tf = 0; tf < nb_triangle_fin; tf++)
1263 int fa7 = indice_facette_finaux_(tf);
1264 facettes_sommets_full_compo_(fa7,9)=surfactant_copy(fa7);
1268 if (print_debug_surfactant_)
1270 double min_surfactant_init = 1.e+10;
1271 double max_surfactant_init = -1.e+10;
1272 for (
int ifaforsom = 0; ifaforsom < nb_triangle_init; ifaforsom++)
1274 if (normale_triangle_originaux(ifaforsom)==orientation_principale)
1276 Point3D p1 = {triangle_initiaux_(ifaforsom, 0, 0), triangle_initiaux_(ifaforsom, 0, 1), triangle_initiaux_(ifaforsom, 0, 2)};
1277 Point3D p2 = {triangle_initiaux_(ifaforsom, 1, 0), triangle_initiaux_(ifaforsom, 1, 1), triangle_initiaux_(ifaforsom, 1, 2)};
1278 Point3D p3 = {triangle_initiaux_(ifaforsom, 2, 0), triangle_initiaux_(ifaforsom, 2, 1), triangle_initiaux_(ifaforsom, 2, 2)};
1280 if (Surfactant_facette_initiale_(ifaforsom)/S > max_surfactant_init)
1281 max_surfactant_init = Surfactant_facette_initiale_(ifaforsom)/S;
1282 if (Surfactant_facette_initiale_(ifaforsom)/S < min_surfactant_init)
1283 min_surfactant_init = Surfactant_facette_initiale_(ifaforsom)/S;
1287 bool bizarre =
false;
1288 for (
int ifaforsom = 0; ifaforsom < nb_triangle_fin; ifaforsom++)
1290 if (normale_triangle_finaux(ifaforsom)==orientation_principale)
1292 Point3D p1 = {triangle_finaux_(ifaforsom, 0, 0), triangle_finaux_(ifaforsom, 0, 1), triangle_finaux_(ifaforsom, 0, 2)};
1293 Point3D p2 = {triangle_finaux_(ifaforsom, 1, 0), triangle_finaux_(ifaforsom, 1, 1), triangle_finaux_(ifaforsom, 1, 2)};
1294 Point3D p3 = {triangle_finaux_(ifaforsom, 2, 0), triangle_finaux_(ifaforsom, 2, 1), triangle_finaux_(ifaforsom, 2, 2)};
1296 if(surfactant_final(ifaforsom)/S > max_surfactant_init*1.5)
1303 std::cout <<
" valeur anormale de surfactant " <<std::endl;
1305 std::cout <<
"normale initiaux : " <<std::endl;
1306 for (
int ifaforsom = 0; ifaforsom < nb_triangle_init; ifaforsom++)
1308 std::cout << normale_triangle_originaux(ifaforsom) << std::endl;
1310 std::cout <<std::endl;
1311 std::cout <<
"normale finale : " <<std::endl;
1312 for (
int ifaforsom = 0; ifaforsom < nb_triangle_fin; ifaforsom++)
1314 std::cout << normale_triangle_finaux(ifaforsom) << std::endl;
1316 std::cout <<std::endl;
1318 std::cout <<
"triangle initiaux : "<<std::endl;
1319 for (
int ifaforsom = 0; ifaforsom < nb_triangle_init; ifaforsom++)
1324 for (i_sommet = 0; i_sommet < 3; i_sommet++)
1325 std::cout <<
"[ " << triangle_initiaux_(ifaforsom, i_sommet, 0) <<
"," << triangle_initiaux_(ifaforsom, i_sommet, 1) <<
"," << triangle_initiaux_(ifaforsom, i_sommet, 2) <<
"],";
1326 std::cout <<
"],"<<std::endl;
1328 std::cout <<
"triangle finaux : " <<std::endl;
1329 for (
int ifaforsom = 0; ifaforsom < nb_triangle_fin; ifaforsom++)
1334 for (i_sommet = 0; i_sommet < 3; i_sommet++)
1335 std::cout <<
"[ " << triangle_finaux_(ifaforsom, i_sommet, 0) <<
"," << triangle_finaux_(ifaforsom, i_sommet, 1) <<
"," << triangle_finaux_(ifaforsom, i_sommet, 2)<<
"],";
1336 std::cout <<
"],"<<std::endl;
1338 std::cout <<
"Surfactant initiaux : " <<std::endl;
1339 for (
int ifaforsom = 0; ifaforsom < nb_triangle_init; ifaforsom++)
1341 std::cout << Surfactant_facette_initiale_(ifaforsom) << std::endl;
1343 std::cout <<std::endl;
1345 std::cout <<
"Surfactant initiaux / Sfa7: " <<std::endl;
1346 for (
int ifaforsom = 0; ifaforsom < nb_triangle_init; ifaforsom++)
1348 Point3D p1 = {triangle_initiaux_(ifaforsom, 0, 0), triangle_initiaux_(ifaforsom, 0, 1), triangle_initiaux_(ifaforsom, 0, 2)};
1349 Point3D p2 = {triangle_initiaux_(ifaforsom, 1, 0), triangle_initiaux_(ifaforsom, 1, 1), triangle_initiaux_(ifaforsom, 1, 2)};
1350 Point3D p3 = {triangle_initiaux_(ifaforsom, 2, 0), triangle_initiaux_(ifaforsom, 2, 1), triangle_initiaux_(ifaforsom, 2, 2)};
1352 std::cout << Surfactant_facette_initiale_(ifaforsom)/S << std::endl;
1354 std::cout <<std::endl;
1356 std::cout <<
"Surfactant finaux / Sfa7: " <<std::endl;
1357 for (
int ifaforsom = 0; ifaforsom < nb_triangle_fin; ifaforsom++)
1359 Point3D p1 = {triangle_finaux_(ifaforsom, 0, 0), triangle_finaux_(ifaforsom, 0, 1), triangle_finaux_(ifaforsom, 0, 2)};
1360 Point3D p2 = {triangle_finaux_(ifaforsom, 1, 0), triangle_finaux_(ifaforsom, 1, 1), triangle_finaux_(ifaforsom, 1, 2)};
1361 Point3D p3 = {triangle_finaux_(ifaforsom, 2, 0), triangle_finaux_(ifaforsom, 2, 1), triangle_finaux_(ifaforsom, 2, 2)};
1363 std::cout << surfactant_final(ifaforsom)/S << std::endl;
1365 std::cout <<std::endl;
1367 std::cout <<
"indice facette finaux : " <<std::endl;
1368 for (
int ifaforsom = 0; ifaforsom < nb_triangle_fin; ifaforsom++)
1370 std::cout << indice_facette_finaux_(ifaforsom) << std::endl;
1372 std::cout <<std::endl;
1374 for (
const auto &point : Surface_fa7fin)
1376 cout <<
"Surface fa7 fin = " << point << endl;
1379 for (
const auto &point : Surface_fa7init)
1381 cout <<
"Surface fa7 init = " << point << endl;
1385 for (
int tf = 0; tf < Surface_fa7fin.size_array(); tf++)
1387 for (
int to = 0; to < Surface_fa7init.size_array(); to++)
1389 cout <<
"Intersection normalisee " << tf <<
" / " << to <<
" = " << Surface_intersection(tf,to)/Surface_fa7fin[tf] << std::endl;
1394 for (
int tf = 0; tf < Surface_fa7fin.size_array(); tf++)
1396 double conservation = 0. ;
1397 for (
int to = 0; to < Surface_fa7init.size_array(); to++)
1399 if(normale_triangle_finaux(tf) == orientation_principale)
1400 conservation += Surface_intersection(tf,to);
1402 conservation/=Surface_fa7fin[tf];
1403 Process::Journal() <<
"conservation de la surface apres calcul des intersections remaillage pour le triangle final " << tf <<
" vaut " << conservation << std::endl;
1404 std::cout <<
"conservation de la surface apres calcul des intersections remaillage pour le triangle final " << tf <<
" vaut " << conservation << std::endl;
1572 if (!((liste_sommets_apres_deplacement.
dimension(0) == liste_sommets_avant_deplacement.
dimension(0)) and (liste_sommets_avant_deplacement.
dimension(0) == compo_connexe_sommets_deplace.
size_array())))
1574 std::cout <<
"Erreur dans completer_compo_connexe_partielle : les tableaux en arguments ne font pas tous la meme taille" << std::endl;
1580 IntVect slice_3D(3) ;
1582 for (
int dir = 0; dir < 3; dir++)
1589 nb_compo_a_envoyer_max_=0;
1590 proc_deja_echange_.resize(0);
1591 proc_numero_.resize(0);
1592 compo_transmises_a_envoyer_.resize(0, 0);
1596 for (
int iproc = -1; iproc < 2; iproc++)
1598 for (
int jproc = -1; jproc < 2; jproc++)
1600 for (
int kproc = -1; kproc < 2; kproc++)
1602 int pe_send = splitting.
get_processor_by_ijk(((slice_3D(0)-iproc)%N_3D(0)+N_3D(0))%N_3D(0), ((slice_3D(1)-jproc)%N_3D(1)+N_3D(1))%N_3D(1), ((slice_3D(2)-kproc)%N_3D(2)+N_3D(2))%N_3D(2));
1603 int pe_rcdv = splitting.
get_processor_by_ijk(((slice_3D(0)+iproc)%N_3D(0)+N_3D(0))%N_3D(0), ((slice_3D(1)+jproc)%N_3D(1)+N_3D(1))%N_3D(1), ((slice_3D(2)+kproc)%N_3D(2)+N_3D(2))%N_3D(2));
1613 proc_deja_echange_.resize(0);
1614 facettes_sommets_full_compo_.resize(0, 0);
1615 liste_sommets_et_deplacements_.resize(0,0);
1617 exchange_data(moi, moi, mesh, liste_sommets_avant_deplacement, liste_sommets_apres_deplacement, compo_connexe_sommets_deplace);
1619 for (
int iproc = -1; iproc < 2; iproc++)
1621 for (
int jproc = -1; jproc < 2; jproc++)
1623 for (
int kproc = -1; kproc < 2; kproc++)
1625 int pe_send = splitting.
get_processor_by_ijk(((slice_3D(0)-iproc)%N_3D(0)+N_3D(0))%N_3D(0), ((slice_3D(1)-jproc)%N_3D(1)+N_3D(1))%N_3D(1), ((slice_3D(2)-kproc)%N_3D(2)+N_3D(2))%N_3D(2));
1626 int pe_rcdv = splitting.
get_processor_by_ijk(((slice_3D(0)+iproc)%N_3D(0)+N_3D(0))%N_3D(0), ((slice_3D(1)+jproc)%N_3D(1)+N_3D(1))%N_3D(1), ((slice_3D(2)+kproc)%N_3D(2)+N_3D(2))%N_3D(2));
1627 if (!(pe_send==moi and pe_rcdv==moi))
1628 exchange_data(pe_send, pe_rcdv, mesh, liste_sommets_avant_deplacement, liste_sommets_apres_deplacement, compo_connexe_sommets_deplace);
1702 int n = liste_sommets_et_deplacements_.dimension(0);
1703 std::vector<double> arr(n);
1704 sorted_index_.resize(n);
1705 for (
int item = 0; item < n; item++)
1707 arr[item]=
norme({liste_sommets_et_deplacements_(item,0),liste_sommets_et_deplacements_(item,1),liste_sommets_et_deplacements_(item,2)});
1710 std::vector<long unsigned int> indices(n);
1713 for (
int item = 0; item < n; item++)
1715 sorted_index_(item)=int(indices[item]);
1718 if (print_debug_surfactant_)
1727 int proc_index = z + y * nz + x * ny * nz ;
1728 int index_global = 0;
1729 for (
int proc = 0; proc < nb_proc; proc++)
1733 if (proc == proc_index)
1735 std::cout <<
"proc = " << proc_index <<
" total facette connues = " << facettes_sommets_full_compo_.dimension(0) << std::endl;
1736 std::cout <<
"proc = " << proc_index <<
" nb facette_local = " << mesh.
nb_facettes() << std::endl;
1737 std::cout <<
"proc = " << proc_index <<
" total sommets connus = " << liste_sommets_et_deplacements_.dimension(0) << std::endl;
1738 std::cout <<
"proc = " << proc_index <<
" nb liste_sommets local = " << liste_sommets_apres_deplacement.
dimension(0) << std::endl;
1739 std::cout <<
"proc = " << proc_index <<
" nb sommets local = " << mesh.
nb_sommets() << std::endl;
1751 Point3D AB = {facettes_sommets_full_compo_(fa, 3*1+0)-facettes_sommets_full_compo_(fa, 0),
1752 facettes_sommets_full_compo_(fa, 3*1+1)-facettes_sommets_full_compo_(fa, 1),
1753 facettes_sommets_full_compo_(fa, 3*1+2)-facettes_sommets_full_compo_(fa, 2)
1756 Point3D AC = {facettes_sommets_full_compo_(fa, 3*2+0)-facettes_sommets_full_compo_(fa, 0),
1757 facettes_sommets_full_compo_(fa, 3*2+1)-facettes_sommets_full_compo_(fa, 1),
1758 facettes_sommets_full_compo_(fa, 3*2+2)-facettes_sommets_full_compo_(fa, 2)
1761 Point3D nreel = {facettes_sommets_full_compo_(fa, 12),facettes_sommets_full_compo_(fa, 13),facettes_sommets_full_compo_(fa, 14)};
1784 AB = {facettes_sommets_full_compo_(fa, 3*B+0)-pos_apres_dep[0],
1785 facettes_sommets_full_compo_(fa, 3*B+1)-pos_apres_dep[1],
1786 facettes_sommets_full_compo_(fa, 3*B+2)-pos_apres_dep[2]
1788 AC = {facettes_sommets_full_compo_(fa, 3*C+0)-pos_apres_dep[0],
1789 facettes_sommets_full_compo_(fa, 3*C+1)-pos_apres_dep[1],
1790 facettes_sommets_full_compo_(fa, 3*C+2)-pos_apres_dep[2]
1795 AB = {pos_apres_dep[0]-facettes_sommets_full_compo_(fa, 3*A+0),
1796 pos_apres_dep[1]-facettes_sommets_full_compo_(fa, 3*A+1),
1797 pos_apres_dep[2]-facettes_sommets_full_compo_(fa, 3*A+2)
1799 AC = {facettes_sommets_full_compo_(fa, 3*C+0)-facettes_sommets_full_compo_(fa, 3*A+0),
1800 facettes_sommets_full_compo_(fa, 3*C+1)-facettes_sommets_full_compo_(fa, 3*A+1),
1801 facettes_sommets_full_compo_(fa, 3*C+2)-facettes_sommets_full_compo_(fa, 3*A+2)
1806 AB = {facettes_sommets_full_compo_(fa, 3*B+0)-facettes_sommets_full_compo_(fa, 3*A+0),
1807 facettes_sommets_full_compo_(fa, 3*B+1)-facettes_sommets_full_compo_(fa, 3*A+1),
1808 facettes_sommets_full_compo_(fa, 3*B+2)-facettes_sommets_full_compo_(fa, 3*A+2)
1810 AC = {pos_apres_dep[0]-facettes_sommets_full_compo_(fa, 3*A+0),
1811 pos_apres_dep[1]-facettes_sommets_full_compo_(fa, 3*A+1),
1812 pos_apres_dep[2]-facettes_sommets_full_compo_(fa, 3*A+2)
1932 const Maillage_FT_IJK& mesh,
const DoubleTab& liste_sommets_avant_deplacement,
const DoubleTab& liste_sommets_apres_deplacement,
const ArrOfInt& compo_connexe_sommets_deplace)
1935 const DoubleTab& sommets=mesh.
sommets();
1936 const IntTab& facettes=mesh.
facettes();
1940 if (echange_already_made)
1947 int dimensions_tab = 15;
1951 int size_avant_echange = facettes_sommets_full_compo_.dimension(0);
1952 int new_size = size_avant_echange + mesh.
nb_facettes() ;
1953 facettes_sommets_full_compo_.resize(new_size, dimensions_tab);
1954 int index = size_avant_echange-1;
1955 index_local_Ft_field_=index;
1962 facettes_sommets_full_compo_(index, 0) = sommets(facettes(fa, 0), 0) ;
1963 facettes_sommets_full_compo_(index, 1) = sommets(facettes(fa, 0), 1) ;
1964 facettes_sommets_full_compo_(index, 2) = sommets(facettes(fa, 0), 2) ;
1965 facettes_sommets_full_compo_(index, 3) = sommets(facettes(fa, 1), 0) ;
1966 facettes_sommets_full_compo_(index, 4) = sommets(facettes(fa, 1), 1) ;
1967 facettes_sommets_full_compo_(index, 5) = sommets(facettes(fa, 1), 2) ;
1968 facettes_sommets_full_compo_(index, 6) = sommets(facettes(fa, 2), 0) ;
1969 facettes_sommets_full_compo_(index, 7) = sommets(facettes(fa, 2), 1) ;
1970 facettes_sommets_full_compo_(index, 8) = sommets(facettes(fa, 2), 2) ;
1972 facettes_sommets_full_compo_(index, 10) = double(fa);
1975 facettes_sommets_full_compo_(index, 11) = 0.;
1979 facettes_sommets_full_compo_(index, 11) = 1.;
1981 facettes_sommets_full_compo_(index, 12) = normale_facette(fa, 0);
1982 facettes_sommets_full_compo_(index, 13) = normale_facette(fa, 1);
1983 facettes_sommets_full_compo_(index, 14) = normale_facette(fa, 2);
1988 size_avant_echange = liste_sommets_et_deplacements_.dimension(0);
1989 new_size = size_avant_echange + liste_sommets_avant_deplacement.
dimension(0) ;
1990 liste_sommets_et_deplacements_.resize(new_size, 6);
1991 index = size_avant_echange-1;
1992 for (
int som = 0; som < liste_sommets_avant_deplacement.
dimension(0); som++)
1995 liste_sommets_et_deplacements_(index, 0) = liste_sommets_avant_deplacement(som, 0);
1996 liste_sommets_et_deplacements_(index, 1) = liste_sommets_avant_deplacement(som, 1);
1997 liste_sommets_et_deplacements_(index, 2) = liste_sommets_avant_deplacement(som, 2);
1998 liste_sommets_et_deplacements_(index, 3) = liste_sommets_apres_deplacement(som, 0);
1999 liste_sommets_et_deplacements_(index, 4) = liste_sommets_apres_deplacement(som, 1);
2000 liste_sommets_et_deplacements_(index, 5) = liste_sommets_apres_deplacement(som, 2);
2012 const int double_size =
sizeof(double);
2013 const int int_size =
sizeof(int);
2014 int *send_buffer_volume_facette = 0;
2015 int *recv_buffer_volume_facette = 0;
2016 int *send_buffer_volume_sommet = 0;
2017 int *recv_buffer_volume_sommet = 0;
2018 double *send_buffer_data_facette = 0;
2019 double *recv_buffer_data_facette = 0;
2020 double *send_buffer_data_sommet = 0;
2021 double *recv_buffer_data_sommet = 0;
2022 int nb_fa7_a_envoyer = 0;
2023 int nb_som_a_envoyer = 0;
2026 DoubleTab item_to_send_facette;
2027 DoubleTab item_to_send_sommet;
2028 int volume_donnees_facette_envoyees = 0;
2029 int volume_donnees_sommet_envoyees = 0;
2030 int volume_donnees_facette_recue = 0;
2031 int volume_donnees_sommet_recue = 0;
2044 item_to_send_facette.
resize(nb_fa7_a_envoyer, dimensions_tab);
2045 item_to_send_facette(nb_fa7_a_envoyer-1, 0) = sommets(facettes(fa, 0), 0) ;
2046 item_to_send_facette(nb_fa7_a_envoyer-1, 1) = sommets(facettes(fa, 0), 1) ;
2047 item_to_send_facette(nb_fa7_a_envoyer-1, 2) = sommets(facettes(fa, 0), 2) ;
2048 item_to_send_facette(nb_fa7_a_envoyer-1, 3) = sommets(facettes(fa, 1), 0) ;
2049 item_to_send_facette(nb_fa7_a_envoyer-1, 4) = sommets(facettes(fa, 1), 1) ;
2050 item_to_send_facette(nb_fa7_a_envoyer-1, 5) = sommets(facettes(fa, 1), 2) ;
2051 item_to_send_facette(nb_fa7_a_envoyer-1, 6) = sommets(facettes(fa, 2), 0) ;
2052 item_to_send_facette(nb_fa7_a_envoyer-1, 7) = sommets(facettes(fa, 2), 1) ;
2053 item_to_send_facette(nb_fa7_a_envoyer-1, 8) = sommets(facettes(fa, 2), 2) ;
2055 item_to_send_facette(nb_fa7_a_envoyer-1, 10) = -1.;
2056 item_to_send_facette(nb_fa7_a_envoyer-1, 11) = 0.;
2057 item_to_send_facette(nb_fa7_a_envoyer-1, 12) = normale_facette(fa, 0);
2058 item_to_send_facette(nb_fa7_a_envoyer-1, 13) = normale_facette(fa, 1);
2059 item_to_send_facette(nb_fa7_a_envoyer-1, 14) = normale_facette(fa, 2);
2063 volume_donnees_facette_envoyees = nb_fa7_a_envoyer;
2065 for (
int som = 0; som < liste_sommets_avant_deplacement.
dimension(0); som++)
2070 item_to_send_sommet.
resize(nb_som_a_envoyer, 6);
2071 item_to_send_sommet(nb_som_a_envoyer-1, 0) = liste_sommets_avant_deplacement(som, 0);
2072 item_to_send_sommet(nb_som_a_envoyer-1, 1) = liste_sommets_avant_deplacement(som, 1);
2073 item_to_send_sommet(nb_som_a_envoyer-1, 2) = liste_sommets_avant_deplacement(som, 2);
2074 item_to_send_sommet(nb_som_a_envoyer-1, 3) = liste_sommets_apres_deplacement(som, 0);
2075 item_to_send_sommet(nb_som_a_envoyer-1, 4) = liste_sommets_apres_deplacement(som, 1);
2076 item_to_send_sommet(nb_som_a_envoyer-1, 5) = liste_sommets_apres_deplacement(som, 2);
2079 volume_donnees_sommet_envoyees = nb_som_a_envoyer;
2086 send_buffer_volume_facette =
new int[1];
2087 int *buf_volume_facette = send_buffer_volume_facette;
2088 *buf_volume_facette = volume_donnees_facette_envoyees ;
2091 send_buffer_data_facette =
new double[volume_donnees_facette_envoyees*dimensions_tab];
2092 double *buf_data_facette = send_buffer_data_facette;
2094 for (
int i = 0; i < nb_fa7_a_envoyer; i++)
2095 for (
int item = 0; item < dimensions_tab; item++, buf_data_facette++)
2096 *buf_data_facette = item_to_send_facette(i, item);
2099 send_buffer_volume_sommet =
new int[1];
2100 int *buf_volume_sommet = send_buffer_volume_sommet;
2101 *buf_volume_sommet = volume_donnees_sommet_envoyees ;
2104 send_buffer_data_sommet =
new double[volume_donnees_sommet_envoyees*6];
2105 double *buf_data_sommet = send_buffer_data_sommet;
2107 for (
int i = 0; i < nb_som_a_envoyer; i++)
2108 for (
int item = 0; item < 6; item++, buf_data_sommet++)
2109 *buf_data_sommet = item_to_send_sommet(i, item);
2115 recv_buffer_volume_facette =
new int[1];
2116 recv_buffer_volume_sommet =
new int[1];
2118 ::envoyer_recevoir(send_buffer_volume_facette, int_size, pe_send_, recv_buffer_volume_facette, int_size, pe_recv_);
2119 ::envoyer_recevoir(send_buffer_volume_sommet, int_size, pe_send_, recv_buffer_volume_sommet, int_size, pe_recv_);
2122 int *buf_volume_facette = recv_buffer_volume_facette;
2123 volume_donnees_facette_recue = *buf_volume_facette;
2125 int *buf_volume_sommet = recv_buffer_volume_sommet;
2126 volume_donnees_sommet_recue = *buf_volume_sommet;
2133 recv_buffer_data_facette =
new double[volume_donnees_facette_recue*dimensions_tab];
2134 recv_buffer_data_sommet =
new double[volume_donnees_sommet_recue*6];
2136 ::envoyer_recevoir(send_buffer_data_facette, volume_donnees_facette_envoyees*dimensions_tab * double_size, pe_send_, recv_buffer_data_facette, volume_donnees_facette_recue * dimensions_tab * double_size, pe_recv_);
2137 ::envoyer_recevoir(send_buffer_data_sommet, volume_donnees_sommet_envoyees*6 * double_size, pe_send_, recv_buffer_data_sommet, volume_donnees_sommet_recue * 6 * double_size, pe_recv_);
2141 int size_avant_echange = facettes_sommets_full_compo_.dimension(0);
2142 int new_size = size_avant_echange + volume_donnees_facette_recue ;
2143 facettes_sommets_full_compo_.resize(new_size, dimensions_tab);
2144 double *buf_data_facette = recv_buffer_data_facette;
2145 for (
int i = size_avant_echange; i < new_size; i++)
2146 for (
int item = 0; item < dimensions_tab; item++, buf_data_facette++)
2147 facettes_sommets_full_compo_(i, item) = *buf_data_facette;
2149 size_avant_echange = liste_sommets_et_deplacements_.dimension(0);
2150 new_size = size_avant_echange + volume_donnees_sommet_recue ;
2151 liste_sommets_et_deplacements_.resize(new_size, 6);
2152 double *buf_data_sommet = recv_buffer_data_sommet;
2153 for (
int i = size_avant_echange; i < new_size; i++)
2154 for (
int item = 0; item < 6; item++, buf_data_sommet++)
2155 liste_sommets_et_deplacements_(i, item) = *buf_data_sommet;
2158 delete[] send_buffer_volume_facette;
2159 delete[] recv_buffer_volume_facette;
2160 delete[] send_buffer_data_facette;
2161 delete[] recv_buffer_data_facette;
2162 delete[] send_buffer_volume_sommet;
2163 delete[] recv_buffer_volume_sommet;
2164 delete[] send_buffer_data_sommet;
2165 delete[] recv_buffer_data_sommet;