117void CartesianMeshAMRPatchMng::
129 cell_to_refine_internals.
add(cell);
130 if (cell.
level() > max_level)
131 max_level = cell.
level();
134 m_num_mng->prepareLevel(max_level + 1);
140 Integer total_nb_cells = 0;
141 Integer total_nb_nodes = 0;
142 Integer total_nb_faces = 0;
144 std::unordered_map<Int64, Int32> node_uid_to_owner;
145 std::unordered_map<Int64, Int32> face_uid_to_owner;
160 std::unordered_map<Int64, Integer> around_parent_cells_uid_to_owner;
161 std::unordered_map<Int64, Int32> around_parent_cells_uid_to_flags;
169 Int32 usefull_flags = ItemFlags::II_Refine + ItemFlags::II_Inactive;
174 around_parent_cells_uid_to_owner[cell.
uniqueId()] = my_rank;
175 around_parent_cells_uid_to_flags[cell.
uniqueId()] = ((cell.
itemBase().
flags() & usefull_flags) + ItemFlags::II_UserMark1);
180 around_parent_cells_uid_to_owner[cell.
uniqueId()] = cell.
owner();
181 around_parent_cells_uid_to_flags[cell.
uniqueId()] = ((cell.
itemBase().
flags() & usefull_flags) + ItemFlags::II_UserMark1);
188 for (
Cell parent_cell : cell_to_refine_internals) {
189 m_num_mng->cellUniqueIdsAroundCell(cell_uids_around, parent_cell);
190 for (Int64 cell_uid : cell_uids_around) {
197 if (around_parent_cells_uid_to_owner.find(cell_uid) != around_parent_cells_uid_to_owner.end())
200 uid_of_cells_needed.
add(cell_uid);
213 m_mesh->cellFamily()->itemsUniqueIdToLocalId(local_ids, uid_of_cells_needed_all_procs,
false);
217 if (!icell->null() && icell->isOwn()) {
218 owner_of_cells_needed_all_procs[compt] = my_rank;
219 flags_of_cells_needed_all_procs[compt] = (icell->itemBase().flags() & usefull_flags);
222 owner_of_cells_needed_all_procs[compt] = -1;
223 flags_of_cells_needed_all_procs[compt] = 0;
229 pm->
reduce(Parallel::eReduceType::ReduceMax, owner_of_cells_needed_all_procs);
230 pm->
reduce(Parallel::eReduceType::ReduceMax, flags_of_cells_needed_all_procs);
244 Integer size_uid_of_cells_needed = uid_of_cells_needed.
size();
245 Integer my_pos_in_all_procs_arrays = 0;
248 pm->
allGather(av, size_uid_of_cells_needed_per_proc);
250 for (Integer i = 0; i < my_rank; ++i) {
251 my_pos_in_all_procs_arrays += size_uid_of_cells_needed_per_proc[i];
254 ArrayView<Int32> owner_of_cells_needed = owner_of_cells_needed_all_procs.
subView(my_pos_in_all_procs_arrays, size_uid_of_cells_needed);
255 ArrayView<Int32> flags_of_cells_needed = flags_of_cells_needed_all_procs.
subView(my_pos_in_all_procs_arrays, size_uid_of_cells_needed);
256 for (Integer i = 0; i < size_uid_of_cells_needed; ++i) {
257 around_parent_cells_uid_to_owner[uid_of_cells_needed[i]] = owner_of_cells_needed[i];
258 around_parent_cells_uid_to_flags[uid_of_cells_needed[i]] = flags_of_cells_needed[i];
263 if (m_mesh->dimension() == 2) {
285 const bool mask_node_if_cell_left[] = {
false,
true,
true,
false };
286 const bool mask_node_if_cell_bottom[] = {
false,
false,
true,
true };
288 const bool mask_node_if_cell_right[] = {
true,
false,
false,
true };
289 const bool mask_node_if_cell_top[] = {
true,
true,
false,
false };
291 const bool mask_face_if_cell_left[] = {
true,
true,
true,
false };
292 const bool mask_face_if_cell_bottom[] = {
false,
true,
true,
true };
294 const bool mask_face_if_cell_right[] = {
true,
false,
true,
true };
295 const bool mask_face_if_cell_top[] = {
true,
true,
false,
true };
301 cells_infos.
reserve((cell_to_refine_internals.
size() * 4) * (2 + m_num_mng->nbNodeByCell()));
307 faces_infos.
reserve((cell_to_refine_internals.
size() * 12) * (2 + 2));
311 nodes_infos.
reserve(cell_to_refine_internals.
size() * 9);
313 for (
Cell parent_cell : cell_to_refine_internals) {
314 const Int64 parent_cell_uid = parent_cell.uniqueId();
315 const Int32 parent_cell_level = parent_cell.level();
316 const bool parent_cell_is_own = (parent_cell.owner() == my_rank);
318 const Int64 parent_coord_x = m_num_mng->cellUniqueIdToCoordX(parent_cell_uid, parent_cell_level);
319 const Int64 parent_coord_y = m_num_mng->cellUniqueIdToCoordY(parent_cell_uid, parent_cell_level);
321 const Int64 child_coord_x = m_num_mng->offsetLevelToLevel(parent_coord_x, parent_cell_level, parent_cell_level + 1);
322 const Int64 child_coord_y = m_num_mng->offsetLevelToLevel(parent_coord_y, parent_cell_level, parent_cell_level + 1);
324 const Integer pattern = m_num_mng->pattern();
330 m_num_mng->cellUniqueIdsAroundCell(uid_cells_around_parent_cell_1d, parent_cell);
332 for (Integer i = 0; i < 9; ++i) {
333 Int64 uid_cell = uid_cells_around_parent_cell_1d[i];
336 if (uid_cell != -1 && around_parent_cells_uid_to_owner[uid_cell] != -1) {
337 owner_cells_around_parent_cell_1d[i] = around_parent_cells_uid_to_owner[uid_cell];
338 flags_cells_around_parent_cell_1d[i] = around_parent_cells_uid_to_flags[uid_cell];
341 uid_cells_around_parent_cell_1d[i] = -1;
342 owner_cells_around_parent_cell_1d[i] = -1;
343 flags_cells_around_parent_cell_1d[i] = 0;
348 ConstArray2View uid_cells_around_parent_cell(uid_cells_around_parent_cell_1d.
data(), 3, 3);
349 ConstArray2View owner_cells_around_parent_cell(owner_cells_around_parent_cell_1d.
data(), 3, 3);
350 ConstArray2View flags_cells_around_parent_cell(flags_cells_around_parent_cell_1d.
data(), 3, 3);
381 bool is_cell_around_parent_cell_present_and_useful[3][3] = { {
false } };
388 is_cell_around_parent_cell_present_and_useful[0][0] = ((uid_cells_around_parent_cell(0, 0) != -1) && (flags_cells_around_parent_cell(0, 0) & (ItemFlags::II_Refine | ItemFlags::II_Inactive)));
389 is_cell_around_parent_cell_present_and_useful[0][1] = ((uid_cells_around_parent_cell(0, 1) != -1) && (flags_cells_around_parent_cell(0, 1) & (ItemFlags::II_Refine | ItemFlags::II_Inactive)));
390 is_cell_around_parent_cell_present_and_useful[0][2] = ((uid_cells_around_parent_cell(0, 2) != -1) && (flags_cells_around_parent_cell(0, 2) & (ItemFlags::II_Refine | ItemFlags::II_Inactive)));
392 is_cell_around_parent_cell_present_and_useful[1][0] = ((uid_cells_around_parent_cell(1, 0) != -1) && (flags_cells_around_parent_cell(1, 0) & (ItemFlags::II_Refine | ItemFlags::II_Inactive)));
401 is_cell_around_parent_cell_present_and_useful[1][2] = ((uid_cells_around_parent_cell(1, 2) != -1) && (flags_cells_around_parent_cell(1, 2) & ItemFlags::II_Inactive));
403 is_cell_around_parent_cell_present_and_useful[2][0] = ((uid_cells_around_parent_cell(2, 0) != -1) && (flags_cells_around_parent_cell(2, 0) & ItemFlags::II_Inactive));
404 is_cell_around_parent_cell_present_and_useful[2][1] = ((uid_cells_around_parent_cell(2, 1) != -1) && (flags_cells_around_parent_cell(2, 1) & ItemFlags::II_Inactive));
405 is_cell_around_parent_cell_present_and_useful[2][2] = ((uid_cells_around_parent_cell(2, 2) != -1) && (flags_cells_around_parent_cell(2, 2) & ItemFlags::II_Inactive));
409 auto is_cell_around_parent_cell_in_subdomain = [&](Integer y, Integer x) {
410 return is_cell_around_parent_cell_present_and_useful[y][x] && (flags_cells_around_parent_cell(y, x) & ItemFlags::II_UserMark1);
414 auto is_cell_around_parent_cell_same_owner = [&](Integer y, Integer x) {
415 return is_cell_around_parent_cell_present_and_useful[y][x] && (owner_cells_around_parent_cell(y, x) == owner_cells_around_parent_cell(1, 1));
419 auto is_cell_around_parent_cell_different_owner = [&](Integer y, Integer x) {
420 return is_cell_around_parent_cell_present_and_useful[y][x] && (owner_cells_around_parent_cell(y, x) != owner_cells_around_parent_cell(1, 1));
424 for (Int64 j = child_coord_y; j < child_coord_y + pattern; ++j) {
425 for (Int64 i = child_coord_x; i < child_coord_x + pattern; ++i) {
426 parent_cells.
add(parent_cell);
429 const Int64 child_cell_uid = m_num_mng->cellUniqueId(parent_cell_level + 1,
Int64x2(i, j));
430 debug() <<
"Child -- x : " << i <<
" -- y : " << j <<
" -- level : " << parent_cell_level + 1 <<
" -- uid : " << child_cell_uid;
432 m_num_mng->cellNodeUniqueIds(child_nodes_uids, parent_cell_level + 1,
Int64x2(i, j));
433 m_num_mng->cellFaceUniqueIds(child_faces_uids, parent_cell_level + 1,
Int64x2(i, j));
435 const Integer type_cell = IT_Quad4;
436 const Integer type_face = IT_Line2;
439 cells_infos.
add(type_cell);
440 cells_infos.
add(child_cell_uid);
441 for (Integer nc = 0; nc < m_num_mng->nbNodeByCell(); nc++) {
442 cells_infos.
add(child_nodes_uids[nc]);
446 for (Integer l = 0; l < m_num_mng->nbFaceByCell(); ++l) {
447 Integer child_face_owner = -1;
448 bool is_new_face =
false;
462 ((i == child_coord_x && !is_cell_around_parent_cell_in_subdomain(1, 0)) || (mask_face_if_cell_left[l])) &&
463 ((i != (child_coord_x + pattern - 1) || !is_cell_around_parent_cell_in_subdomain(1, 2)) || mask_face_if_cell_right[l]) &&
464 ((j == child_coord_y && !is_cell_around_parent_cell_in_subdomain(0, 1)) || (mask_face_if_cell_bottom[l])) &&
465 ((j != (child_coord_y + pattern - 1) || !is_cell_around_parent_cell_in_subdomain(2, 1)) || mask_face_if_cell_top[l])) {
467 faces_infos.
add(type_face);
468 faces_infos.
add(child_faces_uids[l]);
472 for (Integer nc = l; nc < l + 2; nc++) {
473 faces_infos.
add(child_nodes_uids[nc % m_num_mng->nbNodeByCell()]);
478 child_face_owner = owner_cells_around_parent_cell(1, 1);
489 ((i == child_coord_x && !is_cell_around_parent_cell_same_owner(1, 0)) || (mask_face_if_cell_left[l])) &&
490 ((i != (child_coord_x + pattern - 1) || !is_cell_around_parent_cell_same_owner(1, 2)) || mask_face_if_cell_right[l]) &&
491 ((j == child_coord_y && !is_cell_around_parent_cell_same_owner(0, 1)) || (mask_face_if_cell_bottom[l])) &&
492 ((j != (child_coord_y + pattern - 1) || !is_cell_around_parent_cell_same_owner(2, 1)) || mask_face_if_cell_top[l])) {
512 if (i == child_coord_x && (!mask_face_if_cell_left[l]) && is_cell_around_parent_cell_different_owner(1, 0)) {
513 child_face_owner = owner_cells_around_parent_cell(1, 0);
517 else if (j == child_coord_y && (!mask_face_if_cell_bottom[l]) && is_cell_around_parent_cell_different_owner(0, 1)) {
518 child_face_owner = owner_cells_around_parent_cell(0, 1);
525 child_face_owner = owner_cells_around_parent_cell(1, 1);
530 if (child_face_owner != -1) {
531 face_uid_to_owner[child_faces_uids[l]] = child_face_owner;
537 face_uid_change_owner_only.
add(child_faces_uids[l]);
538 debug() <<
"Child face (change owner) -- x : " << i
540 <<
" -- level : " << parent_cell_level + 1
541 <<
" -- face : " << l
542 <<
" -- uid_face : " << child_faces_uids[l]
543 <<
" -- owner : " << child_face_owner;
546 debug() <<
"Child face (create face) -- x : " << i
548 <<
" -- level : " << parent_cell_level + 1
549 <<
" -- face : " << l
550 <<
" -- uid_face : " << child_faces_uids[l]
551 <<
" -- owner : " << child_face_owner;
559 for (Integer l = 0; l < m_num_mng->nbNodeByCell(); ++l) {
560 Integer child_node_owner = -1;
561 bool is_new_node =
false;
575 ((i == child_coord_x && !is_cell_around_parent_cell_in_subdomain(1, 0)) || (mask_node_if_cell_left[l])) &&
576 ((i != (child_coord_x + pattern - 1) || !is_cell_around_parent_cell_in_subdomain(1, 2)) || mask_node_if_cell_right[l]) &&
577 ((j == child_coord_y && !is_cell_around_parent_cell_in_subdomain(0, 1)) || (mask_node_if_cell_bottom[l])) &&
578 ((j != (child_coord_y + pattern - 1) || !is_cell_around_parent_cell_in_subdomain(2, 1)) || mask_node_if_cell_top[l])) {
580 nodes_infos.
add(child_nodes_uids[l]);
584 child_node_owner = owner_cells_around_parent_cell(1, 1);
595 ((i == child_coord_x && !is_cell_around_parent_cell_same_owner(1, 0)) || (mask_node_if_cell_left[l])) &&
596 ((i != (child_coord_x + pattern - 1) || !is_cell_around_parent_cell_same_owner(1, 2)) || mask_node_if_cell_right[l]) &&
597 ((j == child_coord_y && !is_cell_around_parent_cell_same_owner(0, 1)) || (mask_node_if_cell_bottom[l])) &&
598 ((j != (child_coord_y + pattern - 1) || !is_cell_around_parent_cell_same_owner(2, 1)) || mask_node_if_cell_top[l])) {
604 if (i == child_coord_x && (!mask_node_if_cell_left[l])) {
608 if (j == child_coord_y && (!mask_node_if_cell_bottom[l])) {
611 if (is_cell_around_parent_cell_different_owner(0, 0)) {
612 child_node_owner = owner_cells_around_parent_cell(0, 0);
616 else if (is_cell_around_parent_cell_different_owner(0, 1)) {
617 child_node_owner = owner_cells_around_parent_cell(0, 1);
621 else if (is_cell_around_parent_cell_different_owner(1, 0)) {
622 child_node_owner = owner_cells_around_parent_cell(1, 0);
626 child_node_owner = owner_cells_around_parent_cell(1, 1);
632 else if (j == (child_coord_y + pattern - 1) && (!mask_node_if_cell_top[l])) {
635 if (is_cell_around_parent_cell_different_owner(1, 0)) {
636 child_node_owner = owner_cells_around_parent_cell(1, 0);
641 child_node_owner = owner_cells_around_parent_cell(1, 1);
648 if (is_cell_around_parent_cell_different_owner(1, 0)) {
649 child_node_owner = owner_cells_around_parent_cell(1, 0);
654 child_node_owner = owner_cells_around_parent_cell(1, 1);
660 else if (i == (child_coord_x + pattern - 1) && (!mask_node_if_cell_right[l])) {
664 if (j == child_coord_y && (!mask_node_if_cell_bottom[l])) {
667 if (is_cell_around_parent_cell_different_owner(0, 1)) {
668 child_node_owner = owner_cells_around_parent_cell(0, 1);
672 else if (is_cell_around_parent_cell_different_owner(0, 2)) {
673 child_node_owner = owner_cells_around_parent_cell(0, 2);
678 child_node_owner = owner_cells_around_parent_cell(1, 1);
684 else if (j == (child_coord_y + pattern - 1) && (!mask_node_if_cell_top[l])) {
685 child_node_owner = owner_cells_around_parent_cell(1, 1);
690 child_node_owner = owner_cells_around_parent_cell(1, 1);
699 if (j == child_coord_y && (!mask_node_if_cell_bottom[l]) && is_cell_around_parent_cell_different_owner(0, 1)) {
700 child_node_owner = owner_cells_around_parent_cell(0, 1);
705 else if (parent_cell_is_own && j == (child_coord_y + pattern - 1) && (!mask_node_if_cell_top[l]) && is_cell_around_parent_cell_different_owner(2, 1)) {
706 child_node_owner = owner_cells_around_parent_cell(1, 1);
711 child_node_owner = owner_cells_around_parent_cell(1, 1);
717 if (child_node_owner != -1) {
718 node_uid_to_owner[child_nodes_uids[l]] = child_node_owner;
724 node_uid_change_owner_only.
add(child_nodes_uids[l]);
725 debug() <<
"Child node (change owner) -- x : " << i
727 <<
" -- level : " << parent_cell_level + 1
728 <<
" -- node : " << l
729 <<
" -- uid_node : " << child_nodes_uids[l]
730 <<
" -- owner : " << child_node_owner;
733 debug() <<
"Child node (create node) -- x : " << i
735 <<
" -- level : " << parent_cell_level + 1
736 <<
" -- node : " << l
737 <<
" -- uid_node : " << child_nodes_uids[l]
738 <<
" -- owner : " << child_node_owner;
748 else if (m_mesh->dimension() == 3) {
770 const bool mask_node_if_cell_left[] = {
false,
true,
true,
false,
false,
true,
true,
false };
771 const bool mask_node_if_cell_bottom[] = {
false,
false,
true,
true,
false,
false,
true,
true };
772 const bool mask_node_if_cell_rear[] = {
false,
false,
false,
false,
true,
true,
true,
true };
774 const bool mask_node_if_cell_right[] = {
true,
false,
false,
true,
true,
false,
false,
true };
775 const bool mask_node_if_cell_top[] = {
true,
true,
false,
false,
true,
true,
false,
false };
776 const bool mask_node_if_cell_front[] = {
true,
true,
true,
true,
false,
false,
false,
false };
778 const bool mask_face_if_cell_left[] = {
true,
false,
true,
true,
true,
true };
779 const bool mask_face_if_cell_bottom[] = {
true,
true,
false,
true,
true,
true };
780 const bool mask_face_if_cell_rear[] = {
false,
true,
true,
true,
true,
true };
782 const bool mask_face_if_cell_right[] = {
true,
true,
true,
true,
false,
true };
783 const bool mask_face_if_cell_top[] = {
true,
true,
true,
true,
true,
false };
784 const bool mask_face_if_cell_front[] = {
true,
true,
true,
false,
true,
true };
793 const Integer nodes_in_face_0[] = { 0, 1, 2, 3 };
794 const Integer nodes_in_face_1[] = { 0, 3, 7, 4 };
795 const Integer nodes_in_face_2[] = { 0, 1, 5, 4 };
796 const Integer nodes_in_face_3[] = { 4, 5, 6, 7 };
797 const Integer nodes_in_face_4[] = { 1, 2, 6, 5 };
798 const Integer nodes_in_face_5[] = { 3, 2, 6, 7 };
800 const Integer nb_nodes_in_face = 4;
806 cells_infos.
reserve((cell_to_refine_internals.
size() * 8) * (2 + m_num_mng->nbNodeByCell()));
812 faces_infos.
reserve((cell_to_refine_internals.
size() * 36) * (2 + 4));
816 nodes_infos.
reserve(cell_to_refine_internals.
size() * 27);
818 for (
Cell parent_cell : cell_to_refine_internals) {
819 const Int64 parent_cell_uid = parent_cell.uniqueId();
820 const Int32 parent_cell_level = parent_cell.level();
822 const Int64 parent_coord_x = m_num_mng->cellUniqueIdToCoordX(parent_cell_uid, parent_cell_level);
823 const Int64 parent_coord_y = m_num_mng->cellUniqueIdToCoordY(parent_cell_uid, parent_cell_level);
824 const Int64 parent_coord_z = m_num_mng->cellUniqueIdToCoordZ(parent_cell_uid, parent_cell_level);
826 const Int64 child_coord_x = m_num_mng->offsetLevelToLevel(parent_coord_x, parent_cell_level, parent_cell_level + 1);
827 const Int64 child_coord_y = m_num_mng->offsetLevelToLevel(parent_coord_y, parent_cell_level, parent_cell_level + 1);
828 const Int64 child_coord_z = m_num_mng->offsetLevelToLevel(parent_coord_z, parent_cell_level, parent_cell_level + 1);
830 const Integer pattern = m_num_mng->pattern();
836 m_num_mng->cellUniqueIdsAroundCell(uid_cells_around_parent_cell_1d, parent_cell);
838 for (Integer i = 0; i < 27; ++i) {
839 Int64 uid_cell = uid_cells_around_parent_cell_1d[i];
842 if (uid_cell != -1 && around_parent_cells_uid_to_owner[uid_cell] != -1) {
843 owner_cells_around_parent_cell_1d[i] = around_parent_cells_uid_to_owner[uid_cell];
844 flags_cells_around_parent_cell_1d[i] = around_parent_cells_uid_to_flags[uid_cell];
847 uid_cells_around_parent_cell_1d[i] = -1;
848 owner_cells_around_parent_cell_1d[i] = -1;
849 flags_cells_around_parent_cell_1d[i] = 0;
854 ConstArray3View uid_cells_around_parent_cell(uid_cells_around_parent_cell_1d.
data(), 3, 3, 3);
855 ConstArray3View owner_cells_around_parent_cell(owner_cells_around_parent_cell_1d.
data(), 3, 3, 3);
856 ConstArray3View flags_cells_around_parent_cell(flags_cells_around_parent_cell_1d.
data(), 3, 3, 3);
890 bool is_cell_around_parent_cell_present_and_useful[3][3][3] = { { {
false } } };
897 is_cell_around_parent_cell_present_and_useful[0][0][0] = ((uid_cells_around_parent_cell(0, 0, 0) != -1) && (flags_cells_around_parent_cell(0, 0, 0) & (ItemFlags::II_Refine | ItemFlags::II_Inactive)));
898 is_cell_around_parent_cell_present_and_useful[0][0][1] = ((uid_cells_around_parent_cell(0, 0, 1) != -1) && (flags_cells_around_parent_cell(0, 0, 1) & (ItemFlags::II_Refine | ItemFlags::II_Inactive)));
899 is_cell_around_parent_cell_present_and_useful[0][0][2] = ((uid_cells_around_parent_cell(0, 0, 2) != -1) && (flags_cells_around_parent_cell(0, 0, 2) & (ItemFlags::II_Refine | ItemFlags::II_Inactive)));
900 is_cell_around_parent_cell_present_and_useful[0][1][0] = ((uid_cells_around_parent_cell(0, 1, 0) != -1) && (flags_cells_around_parent_cell(0, 1, 0) & (ItemFlags::II_Refine | ItemFlags::II_Inactive)));
901 is_cell_around_parent_cell_present_and_useful[0][1][1] = ((uid_cells_around_parent_cell(0, 1, 1) != -1) && (flags_cells_around_parent_cell(0, 1, 1) & (ItemFlags::II_Refine | ItemFlags::II_Inactive)));
902 is_cell_around_parent_cell_present_and_useful[0][1][2] = ((uid_cells_around_parent_cell(0, 1, 2) != -1) && (flags_cells_around_parent_cell(0, 1, 2) & (ItemFlags::II_Refine | ItemFlags::II_Inactive)));
903 is_cell_around_parent_cell_present_and_useful[0][2][0] = ((uid_cells_around_parent_cell(0, 2, 0) != -1) && (flags_cells_around_parent_cell(0, 2, 0) & (ItemFlags::II_Refine | ItemFlags::II_Inactive)));
904 is_cell_around_parent_cell_present_and_useful[0][2][1] = ((uid_cells_around_parent_cell(0, 2, 1) != -1) && (flags_cells_around_parent_cell(0, 2, 1) & (ItemFlags::II_Refine | ItemFlags::II_Inactive)));
905 is_cell_around_parent_cell_present_and_useful[0][2][2] = ((uid_cells_around_parent_cell(0, 2, 2) != -1) && (flags_cells_around_parent_cell(0, 2, 2) & (ItemFlags::II_Refine | ItemFlags::II_Inactive)));
907 is_cell_around_parent_cell_present_and_useful[1][0][0] = ((uid_cells_around_parent_cell(1, 0, 0) != -1) && (flags_cells_around_parent_cell(1, 0, 0) & (ItemFlags::II_Refine | ItemFlags::II_Inactive)));
908 is_cell_around_parent_cell_present_and_useful[1][0][1] = ((uid_cells_around_parent_cell(1, 0, 1) != -1) && (flags_cells_around_parent_cell(1, 0, 1) & (ItemFlags::II_Refine | ItemFlags::II_Inactive)));
909 is_cell_around_parent_cell_present_and_useful[1][0][2] = ((uid_cells_around_parent_cell(1, 0, 2) != -1) && (flags_cells_around_parent_cell(1, 0, 2) & (ItemFlags::II_Refine | ItemFlags::II_Inactive)));
911 is_cell_around_parent_cell_present_and_useful[1][1][0] = ((uid_cells_around_parent_cell(1, 1, 0) != -1) && (flags_cells_around_parent_cell(1, 1, 0) & (ItemFlags::II_Refine | ItemFlags::II_Inactive)));
920 is_cell_around_parent_cell_present_and_useful[1][1][2] = ((uid_cells_around_parent_cell(1, 1, 2) != -1) && (flags_cells_around_parent_cell(1, 1, 2) & ItemFlags::II_Inactive));
922 is_cell_around_parent_cell_present_and_useful[1][2][0] = ((uid_cells_around_parent_cell(1, 2, 0) != -1) && (flags_cells_around_parent_cell(1, 2, 0) & ItemFlags::II_Inactive));
923 is_cell_around_parent_cell_present_and_useful[1][2][1] = ((uid_cells_around_parent_cell(1, 2, 1) != -1) && (flags_cells_around_parent_cell(1, 2, 1) & ItemFlags::II_Inactive));
924 is_cell_around_parent_cell_present_and_useful[1][2][2] = ((uid_cells_around_parent_cell(1, 2, 2) != -1) && (flags_cells_around_parent_cell(1, 2, 2) & ItemFlags::II_Inactive));
926 is_cell_around_parent_cell_present_and_useful[2][0][0] = ((uid_cells_around_parent_cell(2, 0, 0) != -1) && (flags_cells_around_parent_cell(2, 0, 0) & ItemFlags::II_Inactive));
927 is_cell_around_parent_cell_present_and_useful[2][0][1] = ((uid_cells_around_parent_cell(2, 0, 1) != -1) && (flags_cells_around_parent_cell(2, 0, 1) & ItemFlags::II_Inactive));
928 is_cell_around_parent_cell_present_and_useful[2][0][2] = ((uid_cells_around_parent_cell(2, 0, 2) != -1) && (flags_cells_around_parent_cell(2, 0, 2) & ItemFlags::II_Inactive));
929 is_cell_around_parent_cell_present_and_useful[2][1][0] = ((uid_cells_around_parent_cell(2, 1, 0) != -1) && (flags_cells_around_parent_cell(2, 1, 0) & ItemFlags::II_Inactive));
930 is_cell_around_parent_cell_present_and_useful[2][1][1] = ((uid_cells_around_parent_cell(2, 1, 1) != -1) && (flags_cells_around_parent_cell(2, 1, 1) & ItemFlags::II_Inactive));
931 is_cell_around_parent_cell_present_and_useful[2][1][2] = ((uid_cells_around_parent_cell(2, 1, 2) != -1) && (flags_cells_around_parent_cell(2, 1, 2) & ItemFlags::II_Inactive));
932 is_cell_around_parent_cell_present_and_useful[2][2][0] = ((uid_cells_around_parent_cell(2, 2, 0) != -1) && (flags_cells_around_parent_cell(2, 2, 0) & ItemFlags::II_Inactive));
933 is_cell_around_parent_cell_present_and_useful[2][2][1] = ((uid_cells_around_parent_cell(2, 2, 1) != -1) && (flags_cells_around_parent_cell(2, 2, 1) & ItemFlags::II_Inactive));
934 is_cell_around_parent_cell_present_and_useful[2][2][2] = ((uid_cells_around_parent_cell(2, 2, 2) != -1) && (flags_cells_around_parent_cell(2, 2, 2) & ItemFlags::II_Inactive));
938 auto is_cell_around_parent_cell_in_subdomain = [&](Integer z, Integer y, Integer x) {
939 return is_cell_around_parent_cell_present_and_useful[z][y][x] && (flags_cells_around_parent_cell(z, y, x) & ItemFlags::II_UserMark1);
943 auto is_cell_around_parent_cell_same_owner = [&](Integer z, Integer y, Integer x) {
944 return is_cell_around_parent_cell_present_and_useful[z][y][x] && (owner_cells_around_parent_cell(z, y, x) == owner_cells_around_parent_cell(1, 1, 1));
948 auto is_cell_around_parent_cell_different_owner = [&](Integer z, Integer y, Integer x) {
949 return is_cell_around_parent_cell_present_and_useful[z][y][x] && (owner_cells_around_parent_cell(z, y, x) != owner_cells_around_parent_cell(1, 1, 1));
953 for (Int64 k = child_coord_z; k < child_coord_z + pattern; ++k) {
954 for (Int64 j = child_coord_y; j < child_coord_y + pattern; ++j) {
955 for (Int64 i = child_coord_x; i < child_coord_x + pattern; ++i) {
956 parent_cells.
add(parent_cell);
959 const Int64 child_cell_uid = m_num_mng->cellUniqueId(parent_cell_level + 1,
Int64x3(i, j, k));
960 debug() <<
"Child -- x : " << i <<
" -- y : " << j <<
" -- z : " << k <<
" -- level : " << parent_cell_level + 1 <<
" -- uid : " << child_cell_uid;
962 m_num_mng->cellNodeUniqueIds(child_nodes_uids, parent_cell_level + 1,
Int64x3(i, j, k));
963 m_num_mng->cellFaceUniqueIds(child_faces_uids, parent_cell_level + 1,
Int64x3(i, j, k));
965 const Integer type_cell = IT_Hexaedron8;
966 const Integer type_face = IT_Quad4;
969 cells_infos.
add(type_cell);
970 cells_infos.
add(child_cell_uid);
971 for (Integer nc = 0; nc < m_num_mng->nbNodeByCell(); nc++) {
972 cells_infos.
add(child_nodes_uids[nc]);
976 for (Integer l = 0; l < m_num_mng->nbFaceByCell(); ++l) {
977 Integer child_face_owner = -1;
978 bool is_new_face =
false;
992 ((i == child_coord_x && !is_cell_around_parent_cell_in_subdomain(1, 1, 0)) || mask_face_if_cell_left[l]) &&
993 ((i != (child_coord_x + pattern - 1) || !is_cell_around_parent_cell_in_subdomain(1, 1, 2)) || mask_face_if_cell_right[l]) &&
994 ((j == child_coord_y && !is_cell_around_parent_cell_in_subdomain(1, 0, 1)) || mask_face_if_cell_bottom[l]) &&
995 ((j != (child_coord_y + pattern - 1) || !is_cell_around_parent_cell_in_subdomain(1, 2, 1)) || mask_face_if_cell_top[l]) &&
996 ((k == child_coord_z && !is_cell_around_parent_cell_in_subdomain(0, 1, 1)) || mask_face_if_cell_rear[l]) &&
997 ((k != (child_coord_z + pattern - 1) || !is_cell_around_parent_cell_in_subdomain(2, 1, 1)) || mask_face_if_cell_front[l])) {
999 faces_infos.
add(type_face);
1000 faces_infos.
add(child_faces_uids[l]);
1026 for (Integer nc : nodes_in_face_l) {
1027 faces_infos.
add(child_nodes_uids[nc]);
1032 child_face_owner = owner_cells_around_parent_cell(1, 1, 1);
1043 ((i == child_coord_x && !is_cell_around_parent_cell_same_owner(1, 1, 0)) || mask_face_if_cell_left[l]) &&
1044 ((i != (child_coord_x + pattern - 1) || !is_cell_around_parent_cell_same_owner(1, 1, 2)) || mask_face_if_cell_right[l]) &&
1045 ((j == child_coord_y && !is_cell_around_parent_cell_same_owner(1, 0, 1)) || mask_face_if_cell_bottom[l]) &&
1046 ((j != (child_coord_y + pattern - 1) || !is_cell_around_parent_cell_same_owner(1, 2, 1)) || mask_face_if_cell_top[l]) &&
1047 ((k == child_coord_z && !is_cell_around_parent_cell_same_owner(0, 1, 1)) || mask_face_if_cell_rear[l]) &&
1048 ((k != (child_coord_z + pattern - 1) || !is_cell_around_parent_cell_same_owner(2, 1, 1)) || mask_face_if_cell_front[l])) {
1068 if (i == child_coord_x && (!mask_face_if_cell_left[l]) && is_cell_around_parent_cell_different_owner(1, 1, 0)) {
1069 child_face_owner = owner_cells_around_parent_cell(1, 1, 0);
1073 else if (j == child_coord_y && (!mask_face_if_cell_bottom[l]) && is_cell_around_parent_cell_different_owner(1, 0, 1)) {
1074 child_face_owner = owner_cells_around_parent_cell(1, 0, 1);
1078 else if (k == child_coord_z && (!mask_face_if_cell_rear[l]) && is_cell_around_parent_cell_different_owner(0, 1, 1)) {
1079 child_face_owner = owner_cells_around_parent_cell(0, 1, 1);
1086 child_face_owner = owner_cells_around_parent_cell(1, 1, 1);
1091 if (child_face_owner != -1) {
1092 face_uid_to_owner[child_faces_uids[l]] = child_face_owner;
1098 face_uid_change_owner_only.
add(child_faces_uids[l]);
1099 debug() <<
"Child face (change owner) -- x : " << i
1102 <<
" -- level : " << parent_cell_level + 1
1103 <<
" -- face : " << l
1104 <<
" -- uid_face : " << child_faces_uids[l]
1105 <<
" -- owner : " << child_face_owner;
1108 debug() <<
"Child face (create face) -- x : " << i
1111 <<
" -- level : " << parent_cell_level + 1
1112 <<
" -- face : " << l
1113 <<
" -- uid_face : " << child_faces_uids[l]
1114 <<
" -- owner : " << child_face_owner;
1122 for (Integer l = 0; l < m_num_mng->nbNodeByCell(); ++l) {
1123 Integer child_node_owner = -1;
1124 bool is_new_node =
false;
1139 ((i == child_coord_x && !is_cell_around_parent_cell_in_subdomain(1, 1, 0)) || mask_node_if_cell_left[l]) &&
1140 ((i != (child_coord_x + pattern - 1) || !is_cell_around_parent_cell_in_subdomain(1, 1, 2)) || mask_node_if_cell_right[l]) &&
1141 ((j == child_coord_y && !is_cell_around_parent_cell_in_subdomain(1, 0, 1)) || mask_node_if_cell_bottom[l]) &&
1142 ((j != (child_coord_y + pattern - 1) || !is_cell_around_parent_cell_in_subdomain(1, 2, 1)) || mask_node_if_cell_top[l]) &&
1143 ((k == child_coord_z && !is_cell_around_parent_cell_in_subdomain(0, 1, 1)) || mask_node_if_cell_rear[l]) &&
1144 ((k != (child_coord_z + pattern - 1) || !is_cell_around_parent_cell_in_subdomain(2, 1, 1)) || mask_node_if_cell_front[l])) {
1146 nodes_infos.
add(child_nodes_uids[l]);
1150 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1161 ((i == child_coord_x && !is_cell_around_parent_cell_same_owner(1, 1, 0)) || mask_node_if_cell_left[l]) &&
1162 ((i != (child_coord_x + pattern - 1) || !is_cell_around_parent_cell_same_owner(1, 1, 2)) || mask_node_if_cell_right[l]) &&
1163 ((j == child_coord_y && !is_cell_around_parent_cell_same_owner(1, 0, 1)) || mask_node_if_cell_bottom[l]) &&
1164 ((j != (child_coord_y + pattern - 1) || !is_cell_around_parent_cell_same_owner(1, 2, 1)) || mask_node_if_cell_top[l]) &&
1165 ((k == child_coord_z && !is_cell_around_parent_cell_same_owner(0, 1, 1)) || mask_node_if_cell_rear[l]) &&
1166 ((k != (child_coord_z + pattern - 1) || !is_cell_around_parent_cell_same_owner(2, 1, 1)) || mask_node_if_cell_front[l])) {
1172 if (i == child_coord_x && (!mask_node_if_cell_left[l])) {
1176 if (j == child_coord_y && (!mask_node_if_cell_bottom[l])) {
1180 if (k == child_coord_z && (!mask_node_if_cell_rear[l])) {
1183 if (is_cell_around_parent_cell_different_owner(0, 0, 0)) {
1184 child_node_owner = owner_cells_around_parent_cell(0, 0, 0);
1188 else if (is_cell_around_parent_cell_different_owner(0, 0, 1)) {
1189 child_node_owner = owner_cells_around_parent_cell(0, 0, 1);
1193 else if (is_cell_around_parent_cell_different_owner(0, 1, 0)) {
1194 child_node_owner = owner_cells_around_parent_cell(0, 1, 0);
1198 else if (is_cell_around_parent_cell_different_owner(0, 1, 1)) {
1199 child_node_owner = owner_cells_around_parent_cell(0, 1, 1);
1203 else if (is_cell_around_parent_cell_different_owner(1, 0, 0)) {
1204 child_node_owner = owner_cells_around_parent_cell(1, 0, 0);
1208 else if (is_cell_around_parent_cell_different_owner(1, 0, 1)) {
1209 child_node_owner = owner_cells_around_parent_cell(1, 0, 1);
1213 else if (is_cell_around_parent_cell_different_owner(1, 1, 0)) {
1214 child_node_owner = owner_cells_around_parent_cell(1, 1, 0);
1219 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1225 else if (k == (child_coord_z + pattern - 1) && (!mask_node_if_cell_front[l])) {
1228 if (is_cell_around_parent_cell_different_owner(1, 0, 0)) {
1229 child_node_owner = owner_cells_around_parent_cell(1, 0, 0);
1233 else if (is_cell_around_parent_cell_different_owner(1, 0, 1)) {
1234 child_node_owner = owner_cells_around_parent_cell(1, 0, 1);
1238 else if (is_cell_around_parent_cell_different_owner(1, 1, 0)) {
1239 child_node_owner = owner_cells_around_parent_cell(1, 1, 0);
1244 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1252 if (is_cell_around_parent_cell_different_owner(1, 0, 0)) {
1253 child_node_owner = owner_cells_around_parent_cell(1, 0, 0);
1257 else if (is_cell_around_parent_cell_different_owner(1, 0, 1)) {
1258 child_node_owner = owner_cells_around_parent_cell(1, 0, 1);
1262 else if (is_cell_around_parent_cell_different_owner(1, 1, 0)) {
1263 child_node_owner = owner_cells_around_parent_cell(1, 1, 0);
1268 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1275 else if (j == (child_coord_y + pattern - 1) && (!mask_node_if_cell_top[l])) {
1279 if (k == child_coord_z && (!mask_node_if_cell_rear[l])) {
1282 if (is_cell_around_parent_cell_different_owner(0, 1, 0)) {
1283 child_node_owner = owner_cells_around_parent_cell(0, 1, 0);
1287 else if (is_cell_around_parent_cell_different_owner(0, 1, 1)) {
1288 child_node_owner = owner_cells_around_parent_cell(0, 1, 1);
1292 else if (is_cell_around_parent_cell_different_owner(0, 2, 0)) {
1293 child_node_owner = owner_cells_around_parent_cell(0, 2, 0);
1297 else if (is_cell_around_parent_cell_different_owner(0, 2, 1)) {
1298 child_node_owner = owner_cells_around_parent_cell(0, 2, 1);
1302 else if (is_cell_around_parent_cell_different_owner(1, 1, 0)) {
1303 child_node_owner = owner_cells_around_parent_cell(1, 1, 0);
1308 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1314 else if (k == (child_coord_z + pattern - 1) && (!mask_node_if_cell_front[l])) {
1317 if (is_cell_around_parent_cell_different_owner(1, 1, 0)) {
1318 child_node_owner = owner_cells_around_parent_cell(1, 1, 0);
1323 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1331 if (is_cell_around_parent_cell_different_owner(1, 1, 0)) {
1332 child_node_owner = owner_cells_around_parent_cell(1, 1, 0);
1337 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1346 if (k == child_coord_z && (!mask_node_if_cell_rear[l])) {
1349 if (is_cell_around_parent_cell_different_owner(0, 1, 0)) {
1350 child_node_owner = owner_cells_around_parent_cell(0, 1, 0);
1354 else if (is_cell_around_parent_cell_different_owner(0, 1, 1)) {
1355 child_node_owner = owner_cells_around_parent_cell(0, 1, 1);
1359 else if (is_cell_around_parent_cell_different_owner(1, 1, 0)) {
1360 child_node_owner = owner_cells_around_parent_cell(1, 1, 0);
1365 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1370 else if (k == (child_coord_z + pattern - 1) && (!mask_node_if_cell_front[l])) {
1373 if (is_cell_around_parent_cell_different_owner(1, 1, 0)) {
1374 child_node_owner = owner_cells_around_parent_cell(1, 1, 0);
1379 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1387 if (is_cell_around_parent_cell_different_owner(1, 1, 0)) {
1388 child_node_owner = owner_cells_around_parent_cell(1, 1, 0);
1393 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1402 else if (i == (child_coord_x + pattern - 1) && (!mask_node_if_cell_right[l])) {
1406 if (j == child_coord_y && (!mask_node_if_cell_bottom[l])) {
1410 if (k == child_coord_z && (!mask_node_if_cell_rear[l])) {
1413 if (is_cell_around_parent_cell_different_owner(0, 0, 1)) {
1414 child_node_owner = owner_cells_around_parent_cell(0, 0, 1);
1418 else if (is_cell_around_parent_cell_different_owner(0, 0, 2)) {
1419 child_node_owner = owner_cells_around_parent_cell(0, 0, 2);
1423 else if (is_cell_around_parent_cell_different_owner(0, 1, 1)) {
1424 child_node_owner = owner_cells_around_parent_cell(0, 1, 1);
1428 else if (is_cell_around_parent_cell_different_owner(0, 1, 2)) {
1429 child_node_owner = owner_cells_around_parent_cell(0, 1, 2);
1433 else if (is_cell_around_parent_cell_different_owner(1, 0, 1)) {
1434 child_node_owner = owner_cells_around_parent_cell(1, 0, 1);
1438 else if (is_cell_around_parent_cell_different_owner(1, 0, 2)) {
1439 child_node_owner = owner_cells_around_parent_cell(1, 0, 2);
1444 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1450 else if (k == (child_coord_z + pattern - 1) && (!mask_node_if_cell_front[l])) {
1453 if (is_cell_around_parent_cell_different_owner(1, 0, 1)) {
1454 child_node_owner = owner_cells_around_parent_cell(1, 0, 1);
1458 else if (is_cell_around_parent_cell_different_owner(1, 0, 2)) {
1459 child_node_owner = owner_cells_around_parent_cell(1, 0, 2);
1464 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1472 if (is_cell_around_parent_cell_different_owner(1, 0, 1)) {
1473 child_node_owner = owner_cells_around_parent_cell(1, 0, 1);
1477 else if (is_cell_around_parent_cell_different_owner(1, 0, 2)) {
1478 child_node_owner = owner_cells_around_parent_cell(1, 0, 2);
1483 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1490 else if (j == (child_coord_y + pattern - 1) && (!mask_node_if_cell_top[l])) {
1494 if (k == child_coord_z && (!mask_node_if_cell_rear[l])) {
1497 if (is_cell_around_parent_cell_different_owner(0, 1, 1)) {
1498 child_node_owner = owner_cells_around_parent_cell(0, 1, 1);
1502 else if (is_cell_around_parent_cell_different_owner(0, 1, 2)) {
1503 child_node_owner = owner_cells_around_parent_cell(0, 1, 2);
1507 else if (is_cell_around_parent_cell_different_owner(0, 2, 1)) {
1508 child_node_owner = owner_cells_around_parent_cell(0, 2, 1);
1512 else if (is_cell_around_parent_cell_different_owner(0, 2, 2)) {
1513 child_node_owner = owner_cells_around_parent_cell(0, 2, 2);
1518 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1524 else if (k == (child_coord_z + pattern - 1) && (!mask_node_if_cell_front[l])) {
1525 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1530 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1537 if (k == child_coord_z && (!mask_node_if_cell_rear[l])) {
1540 if (is_cell_around_parent_cell_different_owner(0, 1, 1)) {
1541 child_node_owner = owner_cells_around_parent_cell(0, 1, 1);
1545 else if (is_cell_around_parent_cell_different_owner(0, 1, 2)) {
1546 child_node_owner = owner_cells_around_parent_cell(0, 1, 2);
1551 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1556 else if (k == (child_coord_z + pattern - 1) && (!mask_node_if_cell_front[l])) {
1557 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1562 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1575 if (j == child_coord_y && (!mask_node_if_cell_bottom[l])) {
1579 if (k == child_coord_z && (!mask_node_if_cell_rear[l])) {
1582 if (is_cell_around_parent_cell_different_owner(0, 0, 1)) {
1583 child_node_owner = owner_cells_around_parent_cell(0, 0, 1);
1587 else if (is_cell_around_parent_cell_different_owner(0, 1, 1)) {
1588 child_node_owner = owner_cells_around_parent_cell(0, 1, 1);
1592 else if (is_cell_around_parent_cell_different_owner(1, 0, 1)) {
1593 child_node_owner = owner_cells_around_parent_cell(1, 0, 1);
1598 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1604 else if (k == (child_coord_z + pattern - 1) && (!mask_node_if_cell_front[l])) {
1607 if (is_cell_around_parent_cell_different_owner(1, 0, 1)) {
1608 child_node_owner = owner_cells_around_parent_cell(1, 0, 1);
1613 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1621 if (is_cell_around_parent_cell_different_owner(1, 0, 1)) {
1622 child_node_owner = owner_cells_around_parent_cell(1, 0, 1);
1627 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1633 else if (j == (child_coord_y + pattern - 1) && (!mask_node_if_cell_top[l])) {
1637 if (k == child_coord_z && (!mask_node_if_cell_rear[l])) {
1640 if (is_cell_around_parent_cell_different_owner(0, 1, 1)) {
1641 child_node_owner = owner_cells_around_parent_cell(0, 1, 1);
1645 else if (is_cell_around_parent_cell_different_owner(0, 2, 1)) {
1646 child_node_owner = owner_cells_around_parent_cell(0, 2, 1);
1651 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1657 else if (k == (child_coord_z + pattern - 1) && (!mask_node_if_cell_front[l])) {
1658 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1663 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1671 if (k == child_coord_z && (!mask_node_if_cell_rear[l])) {
1674 if (is_cell_around_parent_cell_different_owner(0, 1, 1)) {
1675 child_node_owner = owner_cells_around_parent_cell(0, 1, 1);
1680 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1685 else if (k == (child_coord_z + pattern - 1) && (!mask_node_if_cell_front[l])) {
1686 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1691 child_node_owner = owner_cells_around_parent_cell(1, 1, 1);
1698 if (child_node_owner != -1) {
1699 node_uid_to_owner[child_nodes_uids[l]] = child_node_owner;
1705 node_uid_change_owner_only.
add(child_nodes_uids[l]);
1706 debug() <<
"Child node (change owner) -- x : " << i
1709 <<
" -- level : " << parent_cell_level + 1
1710 <<
" -- node : " << l
1711 <<
" -- uid_node : " << child_nodes_uids[l]
1712 <<
" -- owner : " << child_node_owner;
1715 debug() <<
"Child node (create node) -- x : " << i
1718 <<
" -- level : " << parent_cell_level + 1
1719 <<
" -- node : " << l
1720 <<
" -- uid_node : " << child_nodes_uids[l]
1721 <<
" -- owner : " << child_node_owner;
1736 debug() <<
"Nb new nodes in patch : " << total_nb_nodes;
1738 const Integer nb_node_owner_change = node_uid_change_owner_only.
size();
1745 m_mesh->modifier()->addNodes(nodes_infos, nodes_lid.
subView(0, total_nb_nodes));
1748 m_mesh->nodeFamily()->itemsUniqueIdToLocalId(nodes_lid.
subView(total_nb_nodes, nb_node_owner_change), node_uid_change_owner_only,
true);
1755 ENUMERATE_ (
Node, inode, m_mesh->nodeFamily()->view(nodes_lid)) {
1759 if (node_uid_to_owner[node.
uniqueId()] == my_rank) {
1767 uid_child_nodes[index++] = m_num_mng->parentNodeUniqueIdOfNode(node.
uniqueId(), max_level + 1,
false);
1770 m_mesh->nodeFamily()->itemsUniqueIdToLocalId(lid_child_nodes, uid_child_nodes,
false);
1774 ENUMERATE_ (
Node, inode, m_mesh->nodeFamily()->view(nodes_lid)) {
1775 const Int32 child_lid = lid_child_nodes[index++];
1776 if (child_lid == NULL_ITEM_ID) {
1780 Node parent = nodes[child_lid];
1781 Node child = *inode;
1783 m_mesh->modifier()->addParentNodeToNode(child, parent);
1784 m_mesh->modifier()->addChildNodeToNode(parent, child);
1787 m_mesh->nodeFamily()->notifyItemsOwnerChanged();
1792 debug() <<
"Nb new faces in patch : " << total_nb_faces;
1794 const Integer nb_face_owner_change = face_uid_change_owner_only.
size();
1801 m_mesh->modifier()->addFaces(total_nb_faces, faces_infos, faces_lid.
subView(0, total_nb_faces));
1804 m_mesh->faceFamily()->itemsUniqueIdToLocalId(faces_lid.
subView(total_nb_faces, nb_face_owner_change), face_uid_change_owner_only,
true);
1811 ENUMERATE_ (
Face, iface, m_mesh->faceFamily()->view(faces_lid)) {
1815 if (face_uid_to_owner[face.
uniqueId()] == my_rank) {
1823 uid_parent_faces[index++] = m_num_mng->parentFaceUniqueIdOfFace(face.
uniqueId(), max_level + 1,
false);
1827 m_mesh->faceFamily()->itemsUniqueIdToLocalId(lid_parent_faces, uid_parent_faces,
false);
1831 ENUMERATE_ (
Face, iface, m_mesh->faceFamily()->view(faces_lid)) {
1832 const Int32 child_lid = lid_parent_faces[index++];
1833 if (child_lid == NULL_ITEM_ID) {
1837 Face parent = faces[child_lid];
1838 Face child = *iface;
1840 m_mesh->modifier()->addParentFaceToFace(child, parent);
1841 m_mesh->modifier()->addChildFaceToFace(parent, child);
1844 m_mesh->faceFamily()->notifyItemsOwnerChanged();
1849 debug() <<
"Nb new cells in patch : " << total_nb_cells;
1852 m_mesh->modifier()->addCells(total_nb_cells, cells_infos, cells_lid);
1856 for (Integer i = 0; i < total_nb_cells; ++i) {
1857 Cell child = cells[cells_lid[i]];
1863 if (parent_cells[i].owner() == my_rank) {
1867 if (parent_cells[i].itemBase().flags() & ItemFlags::II_Shared) {
1871 m_mesh->modifier()->addParentCellToCell(child, parent_cells[i]);
1872 m_mesh->modifier()->addChildCellToCell(parent_cells[i], child);
1876 for (
Cell cell : cell_to_refine_internals) {
1877 cell.mutableItemBase().removeFlags(ItemFlags::II_Refine);
1878 cell.mutableItemBase().addFlags(ItemFlags::II_JustRefined | ItemFlags::II_Inactive);
1880 m_mesh->cellFamily()->notifyItemsOwnerChanged();
1883 m_mesh->modifier()->endUpdate();
1886 for (
Cell parent_cell : cell_to_refine_internals) {
1887 m_num_mng->setChildNodeCoordinates(parent_cell);
1889 if (parent_cell.mutableItemBase().flags() & ItemFlags::II_Shared) {
1890 for (Integer i = 0; i < parent_cell.nbHChildren(); ++i) {
1893 if (node.mutableItemBase().flags() & ItemFlags::II_Own) {
1899 if (face.mutableItemBase().flags() & ItemFlags::II_Own) {
1900 face.mutableItemBase().addFlags(ItemFlags::II_Shared);
1943void CartesianMeshAMRPatchMng::
1953 std::unordered_map<Int64, Int32> around_parent_cells_uid_to_owner;
1954 std::unordered_map<Int64, bool> around_parent_cells_uid_is_in_subdomain;
1955 std::unordered_map<Int64, UniqueArray<Cell>> parent_to_child_cells;
1957 std::unordered_map<Int64, Int32> node_uid_to_owner;
1958 std::unordered_map<Int64, Int32> face_uid_to_owner;
1963 m_num_mng->prepareLevel(-1);
1978 gm->
setNbGhostLayer(nb_ghost_layer + (nb_ghost_layer % m_num_mng->pattern()));
1990 Int64 parent_uid = m_num_mng->parentCellUniqueIdOfCell(cell);
1993 if (!cell_uid_to_create.
contains(parent_uid)) {
1994 cell_uid_to_create.
add(parent_uid);
1997 around_parent_cells_uid_to_owner[parent_uid] = cell.
owner();
1998 around_parent_cells_uid_is_in_subdomain[parent_uid] =
true;
2002 if (around_parent_cells_uid_to_owner[parent_uid] != cell.
owner()) {
2009 parent_to_child_cells[parent_uid].add(cell);
2021 Integer total_nb_cells = 0;
2022 Integer total_nb_nodes = 0;
2023 Integer total_nb_faces = 0;
2037 for (Int64 parent_cell : cell_uid_to_create) {
2038 m_num_mng->cellUniqueIdsAroundCell(cell_uids_around, parent_cell, -1);
2039 for (Int64 cell_uid : cell_uids_around) {
2046 if (around_parent_cells_uid_to_owner.find(cell_uid) != around_parent_cells_uid_to_owner.end())
2050 if (!uid_of_cells_needed.
contains(cell_uid)) {
2051 uid_of_cells_needed.
add(cell_uid);
2057 around_parent_cells_uid_is_in_subdomain[cell_uid] =
false;
2071 for (Integer i = 0; i < uid_of_cells_needed_all_procs.
size(); ++i) {
2072 if (around_parent_cells_uid_to_owner.find(uid_of_cells_needed_all_procs[i]) != around_parent_cells_uid_to_owner.end()) {
2073 owner_of_cells_needed_all_procs[i] = around_parent_cells_uid_to_owner[uid_of_cells_needed_all_procs[i]];
2077 owner_of_cells_needed_all_procs[i] = -1;
2083 pm->
reduce(Parallel::eReduceType::ReduceMax, owner_of_cells_needed_all_procs);
2087 Integer size_uid_of_cells_needed = uid_of_cells_needed.
size();
2088 Integer my_pos_in_all_procs_arrays = 0;
2091 pm->
allGather(av, size_uid_of_cells_needed_per_proc);
2094 for (Integer i = 0; i < my_rank; ++i) {
2095 my_pos_in_all_procs_arrays += size_uid_of_cells_needed_per_proc[i];
2099 ArrayView<Int32> owner_of_cells_needed = owner_of_cells_needed_all_procs.
subView(my_pos_in_all_procs_arrays, size_uid_of_cells_needed);
2100 for (Integer i = 0; i < size_uid_of_cells_needed; ++i) {
2101 around_parent_cells_uid_to_owner[uid_of_cells_needed[i]] = owner_of_cells_needed[i];
2105 if (owner_of_cells_needed[i] == -1) {
2106 ARCANE_FATAL(
"En déraffinement, c'est normalement impossible");
2112 if (m_mesh->dimension() == 2) {
2117 const bool mask_face_if_cell_left[] = {
true,
true,
true,
false };
2118 const bool mask_face_if_cell_bottom[] = {
false,
true,
true,
true };
2121 const bool mask_node_if_cell_left[] = {
false,
true,
true,
false };
2122 const bool mask_node_if_cell_bottom[] = {
false,
false,
true,
true };
2126 for (Int64 parent_cell_uid : cell_uid_to_create) {
2129 m_num_mng->cellUniqueIdsAroundCell(cells_uid_around, parent_cell_uid, -1);
2134 ConstArray2View owner_cells_around_parent_cell(owner_cells_around_parent_cell_1d.
data(), 3, 3);
2136 ConstArray2View is_not_in_subdomain_cells_around_parent_cell(is_not_in_subdomain_cells_around_parent_cell_1d.
data(), 3, 3);
2138 for (Integer i = 0; i < 9; ++i) {
2139 Int64 uid_cell = cells_uid_around[i];
2142 if (uid_cell != -1 && around_parent_cells_uid_to_owner[uid_cell] != -1) {
2143 owner_cells_around_parent_cell_1d[i] = around_parent_cells_uid_to_owner[uid_cell];
2144 is_not_in_subdomain_cells_around_parent_cell_1d[i] = !around_parent_cells_uid_is_in_subdomain[uid_cell];
2147 cells_uid_around[i] = -1;
2148 owner_cells_around_parent_cell_1d[i] = -1;
2149 is_not_in_subdomain_cells_around_parent_cell_1d[i] =
true;
2156 auto is_cell_around_parent_cell_different_owner = [&](Integer y, Integer x) {
2157 return (owner_cells_around_parent_cell(y, x) != owner_cells_around_parent_cell(1, 1));
2160 auto is_cell_around_parent_cell_exist_and_different_owner = [&](Integer y, Integer x) {
2161 return (owner_cells_around_parent_cell(y, x) != -1 && (owner_cells_around_parent_cell(y, x) != owner_cells_around_parent_cell(1, 1)));
2166 <<
" -- x : " << m_num_mng->cellUniqueIdToCoordX(parent_cell_uid, -1)
2167 <<
" -- y : " << m_num_mng->cellUniqueIdToCoordY(parent_cell_uid, -1)
2168 <<
" -- level : " << -1
2169 <<
" -- uid : " << parent_cell_uid;
2172 m_num_mng->cellNodeUniqueIds(parent_nodes_uids, -1, parent_cell_uid);
2173 m_num_mng->cellFaceUniqueIds(parent_faces_uids, -1, parent_cell_uid);
2175 const Integer type_cell = IT_Quad4;
2176 const Integer type_face = IT_Line2;
2179 cells_infos.
add(type_cell);
2180 cells_infos.
add(parent_cell_uid);
2181 for (Integer nc = 0; nc < m_num_mng->nbNodeByCell(); nc++) {
2182 cells_infos.
add(parent_nodes_uids[nc]);
2186 for (Integer l = 0; l < m_num_mng->nbFaceByCell(); ++l) {
2187 Integer parent_face_owner = -1;
2195 (mask_face_if_cell_left[l] || is_cell_around_parent_cell_different_owner(1, 0) || is_not_in_subdomain_cells_around_parent_cell(1, 0)) &&
2196 (mask_face_if_cell_bottom[l] || is_cell_around_parent_cell_different_owner(0, 1) || is_not_in_subdomain_cells_around_parent_cell(0, 1))) {
2197 faces_infos.
add(type_face);
2198 faces_infos.
add(parent_faces_uids[l]);
2202 for (Integer nc = l; nc < l + 2; nc++) {
2203 faces_infos.
add(parent_nodes_uids[nc % m_num_mng->nbNodeByCell()]);
2207 if ((!mask_face_if_cell_left[l]) && is_cell_around_parent_cell_exist_and_different_owner(1, 0)) {
2208 parent_face_owner = owner_cells_around_parent_cell(1, 0);
2210 else if ((!mask_face_if_cell_bottom[l]) && is_cell_around_parent_cell_exist_and_different_owner(0, 1)) {
2211 parent_face_owner = owner_cells_around_parent_cell(0, 1);
2214 parent_face_owner = owner_cells_around_parent_cell(1, 1);
2216 face_uid_to_owner[parent_faces_uids[l]] = parent_face_owner;
2217 debug() <<
"Parent face (create face) -- parent_cell_uid : " << parent_cell_uid
2218 <<
" -- level : " << -1
2219 <<
" -- face : " << l
2220 <<
" -- uid_face : " << parent_faces_uids[l]
2221 <<
" -- owner : " << parent_face_owner;
2228 for (Integer l = 0; l < m_num_mng->nbNodeByCell(); ++l) {
2229 Integer parent_node_owner = -1;
2231 (mask_node_if_cell_left[l] || is_cell_around_parent_cell_different_owner(1, 0) || is_not_in_subdomain_cells_around_parent_cell(1, 0)) &&
2232 (mask_node_if_cell_bottom[l] || is_cell_around_parent_cell_different_owner(0, 1) || is_not_in_subdomain_cells_around_parent_cell(0, 1))) {
2233 nodes_infos.
add(parent_nodes_uids[l]);
2236 if ((!mask_node_if_cell_left[l])) {
2237 if ((!mask_node_if_cell_bottom[l])) {
2238 if (is_cell_around_parent_cell_exist_and_different_owner(0, 0)) {
2239 parent_node_owner = owner_cells_around_parent_cell(0, 0);
2241 else if (is_cell_around_parent_cell_exist_and_different_owner(0, 1)) {
2242 parent_node_owner = owner_cells_around_parent_cell(0, 1);
2244 else if (is_cell_around_parent_cell_exist_and_different_owner(1, 0)) {
2245 parent_node_owner = owner_cells_around_parent_cell(1, 0);
2248 parent_node_owner = owner_cells_around_parent_cell(1, 1);
2252 if (is_cell_around_parent_cell_exist_and_different_owner(1, 0)) {
2253 parent_node_owner = owner_cells_around_parent_cell(1, 0);
2256 parent_node_owner = owner_cells_around_parent_cell(1, 1);
2261 if ((!mask_node_if_cell_bottom[l])) {
2262 if (is_cell_around_parent_cell_exist_and_different_owner(0, 1)) {
2263 parent_node_owner = owner_cells_around_parent_cell(0, 1);
2265 else if (is_cell_around_parent_cell_exist_and_different_owner(0, 2)) {
2266 parent_node_owner = owner_cells_around_parent_cell(0, 2);
2269 parent_node_owner = owner_cells_around_parent_cell(1, 1);
2273 parent_node_owner = owner_cells_around_parent_cell(1, 1);
2277 node_uid_to_owner[parent_nodes_uids[l]] = parent_node_owner;
2278 debug() <<
"Parent node (create node) -- parent_cell_uid : " << parent_cell_uid
2279 <<
" -- level : " << -1
2280 <<
" -- node : " << l
2281 <<
" -- uid_node : " << parent_nodes_uids[l]
2282 <<
" -- owner : " << parent_node_owner;
2287 else if (m_mesh->dimension() == 3) {
2291 const bool mask_node_if_cell_left[] = {
false,
true,
true,
false,
false,
true,
true,
false };
2292 const bool mask_node_if_cell_bottom[] = {
false,
false,
true,
true,
false,
false,
true,
true };
2293 const bool mask_node_if_cell_rear[] = {
false,
false,
false,
false,
true,
true,
true,
true };
2295 const bool mask_face_if_cell_left[] = {
true,
false,
true,
true,
true,
true };
2296 const bool mask_face_if_cell_bottom[] = {
true,
true,
false,
true,
true,
true };
2297 const bool mask_face_if_cell_rear[] = {
false,
true,
true,
true,
true,
true };
2306 const Integer nodes_in_face_0[] = { 0, 1, 2, 3 };
2307 const Integer nodes_in_face_1[] = { 0, 3, 7, 4 };
2308 const Integer nodes_in_face_2[] = { 0, 1, 5, 4 };
2309 const Integer nodes_in_face_3[] = { 4, 5, 6, 7 };
2310 const Integer nodes_in_face_4[] = { 1, 2, 6, 5 };
2311 const Integer nodes_in_face_5[] = { 3, 2, 6, 7 };
2313 const Integer nb_nodes_in_face = 4;
2317 for (Int64 parent_cell_uid : cell_uid_to_create) {
2320 m_num_mng->cellUniqueIdsAroundCell(cells_uid_around, parent_cell_uid, -1);
2325 ConstArray3View owner_cells_around_parent_cell(owner_cells_around_parent_cell_1d.
data(), 3, 3, 3);
2327 ConstArray3View is_not_in_subdomain_cells_around_parent_cell(is_not_in_subdomain_cells_around_parent_cell_1d.
data(), 3, 3, 3);
2329 for (Integer i = 0; i < 27; ++i) {
2330 Int64 uid_cell = cells_uid_around[i];
2333 if (uid_cell != -1 && around_parent_cells_uid_to_owner[uid_cell] != -1) {
2334 owner_cells_around_parent_cell_1d[i] = around_parent_cells_uid_to_owner[uid_cell];
2335 is_not_in_subdomain_cells_around_parent_cell_1d[i] = !around_parent_cells_uid_is_in_subdomain[uid_cell];
2338 cells_uid_around[i] = -1;
2339 owner_cells_around_parent_cell_1d[i] = -1;
2340 is_not_in_subdomain_cells_around_parent_cell_1d[i] =
true;
2347 auto is_cell_around_parent_cell_different_owner = [&](Integer z, Integer y, Integer x) {
2348 return (owner_cells_around_parent_cell(z, y, x) != owner_cells_around_parent_cell(1, 1, 1));
2351 auto is_cell_around_parent_cell_exist_and_different_owner = [&](Integer z, Integer y, Integer x) {
2352 return (owner_cells_around_parent_cell(z, y, x) != -1 && (owner_cells_around_parent_cell(z, y, x) != owner_cells_around_parent_cell(1, 1, 1)));
2357 <<
" -- x : " << m_num_mng->cellUniqueIdToCoordX(parent_cell_uid, -1)
2358 <<
" -- y : " << m_num_mng->cellUniqueIdToCoordY(parent_cell_uid, -1)
2359 <<
" -- z : " << m_num_mng->cellUniqueIdToCoordZ(parent_cell_uid, -1)
2360 <<
" -- level : " << -1
2361 <<
" -- uid : " << parent_cell_uid;
2364 m_num_mng->cellNodeUniqueIds(parent_nodes_uids, -1, parent_cell_uid);
2365 m_num_mng->cellFaceUniqueIds(parent_faces_uids, -1, parent_cell_uid);
2367 const Integer type_cell = IT_Hexaedron8;
2368 const Integer type_face = IT_Quad4;
2371 cells_infos.
add(type_cell);
2372 cells_infos.
add(parent_cell_uid);
2373 for (Integer nc = 0; nc < m_num_mng->nbNodeByCell(); nc++) {
2374 cells_infos.
add(parent_nodes_uids[nc]);
2378 for (Integer l = 0; l < m_num_mng->nbFaceByCell(); ++l) {
2379 Integer parent_face_owner = -1;
2387 (mask_face_if_cell_left[l] || is_cell_around_parent_cell_different_owner(1, 1, 0) || is_not_in_subdomain_cells_around_parent_cell(1, 1, 0)) &&
2388 (mask_face_if_cell_bottom[l] || is_cell_around_parent_cell_different_owner(1, 0, 1) || is_not_in_subdomain_cells_around_parent_cell(1, 0, 1)) &&
2389 (mask_face_if_cell_rear[l] || is_cell_around_parent_cell_different_owner(0, 1, 1) || is_not_in_subdomain_cells_around_parent_cell(0, 1, 1))) {
2390 faces_infos.
add(type_face);
2391 faces_infos.
add(parent_faces_uids[l]);
2417 for (Integer nc : nodes_in_face_l) {
2418 faces_infos.
add(parent_nodes_uids[nc]);
2422 if ((!mask_face_if_cell_left[l]) && is_cell_around_parent_cell_exist_and_different_owner(1, 1, 0)) {
2423 parent_face_owner = owner_cells_around_parent_cell(1, 1, 0);
2425 else if ((!mask_face_if_cell_bottom[l]) && is_cell_around_parent_cell_exist_and_different_owner(1, 0, 1)) {
2426 parent_face_owner = owner_cells_around_parent_cell(1, 0, 1);
2428 else if ((!mask_face_if_cell_rear[l]) && is_cell_around_parent_cell_exist_and_different_owner(0, 1, 1)) {
2429 parent_face_owner = owner_cells_around_parent_cell(0, 1, 1);
2432 parent_face_owner = owner_cells_around_parent_cell(1, 1, 1);
2434 face_uid_to_owner[parent_faces_uids[l]] = parent_face_owner;
2435 debug() <<
"Parent face (create face) -- parent_cell_uid : " << parent_cell_uid
2436 <<
" -- level : " << -1
2437 <<
" -- face : " << l
2438 <<
" -- uid_face : " << parent_faces_uids[l]
2439 <<
" -- owner : " << parent_face_owner;
2446 for (Integer l = 0; l < m_num_mng->nbNodeByCell(); ++l) {
2447 Integer parent_node_owner = -1;
2449 (mask_node_if_cell_left[l] || is_cell_around_parent_cell_different_owner(1, 1, 0) || is_not_in_subdomain_cells_around_parent_cell(1, 1, 0)) &&
2450 (mask_node_if_cell_bottom[l] || is_cell_around_parent_cell_different_owner(1, 0, 1) || is_not_in_subdomain_cells_around_parent_cell(1, 0, 1)) &&
2451 (mask_node_if_cell_rear[l] || is_cell_around_parent_cell_different_owner(0, 1, 1) || is_not_in_subdomain_cells_around_parent_cell(0, 1, 1))) {
2452 nodes_infos.
add(parent_nodes_uids[l]);
2455 if ((!mask_node_if_cell_left[l])) {
2456 if ((!mask_node_if_cell_bottom[l])) {
2457 if ((!mask_node_if_cell_rear[l])) {
2459 if (is_cell_around_parent_cell_exist_and_different_owner(0, 0, 0)) {
2460 parent_node_owner = owner_cells_around_parent_cell(0, 0, 0);
2462 else if (is_cell_around_parent_cell_exist_and_different_owner(0, 0, 1)) {
2463 parent_node_owner = owner_cells_around_parent_cell(0, 0, 1);
2465 else if (is_cell_around_parent_cell_exist_and_different_owner(0, 1, 0)) {
2466 parent_node_owner = owner_cells_around_parent_cell(0, 1, 0);
2468 else if (is_cell_around_parent_cell_exist_and_different_owner(0, 1, 1)) {
2469 parent_node_owner = owner_cells_around_parent_cell(0, 1, 1);
2471 else if (is_cell_around_parent_cell_exist_and_different_owner(1, 0, 0)) {
2472 parent_node_owner = owner_cells_around_parent_cell(1, 0, 0);
2474 else if (is_cell_around_parent_cell_exist_and_different_owner(1, 0, 1)) {
2475 parent_node_owner = owner_cells_around_parent_cell(1, 0, 1);
2477 else if (is_cell_around_parent_cell_exist_and_different_owner(1, 1, 0)) {
2478 parent_node_owner = owner_cells_around_parent_cell(1, 1, 0);
2481 parent_node_owner = owner_cells_around_parent_cell(1, 1, 1);
2485 if (is_cell_around_parent_cell_exist_and_different_owner(1, 0, 0)) {
2486 parent_node_owner = owner_cells_around_parent_cell(1, 0, 0);
2488 else if (is_cell_around_parent_cell_exist_and_different_owner(1, 0, 1)) {
2489 parent_node_owner = owner_cells_around_parent_cell(1, 0, 1);
2491 else if (is_cell_around_parent_cell_exist_and_different_owner(1, 1, 0)) {
2492 parent_node_owner = owner_cells_around_parent_cell(1, 1, 0);
2495 parent_node_owner = owner_cells_around_parent_cell(1, 1, 1);
2500 if ((!mask_node_if_cell_rear[l])) {
2501 if (is_cell_around_parent_cell_exist_and_different_owner(0, 1, 0)) {
2502 parent_node_owner = owner_cells_around_parent_cell(0, 1, 0);
2504 else if (is_cell_around_parent_cell_exist_and_different_owner(0, 1, 1)) {
2505 parent_node_owner = owner_cells_around_parent_cell(0, 1, 1);
2507 else if (is_cell_around_parent_cell_exist_and_different_owner(0, 2, 0)) {
2508 parent_node_owner = owner_cells_around_parent_cell(0, 2, 0);
2510 else if (is_cell_around_parent_cell_exist_and_different_owner(0, 2, 1)) {
2511 parent_node_owner = owner_cells_around_parent_cell(0, 2, 1);
2513 else if (is_cell_around_parent_cell_exist_and_different_owner(1, 1, 0)) {
2514 parent_node_owner = owner_cells_around_parent_cell(1, 1, 0);
2517 parent_node_owner = owner_cells_around_parent_cell(1, 1, 1);
2521 if (is_cell_around_parent_cell_exist_and_different_owner(1, 1, 0)) {
2522 parent_node_owner = owner_cells_around_parent_cell(1, 1, 0);
2525 parent_node_owner = owner_cells_around_parent_cell(1, 1, 1);
2531 if ((!mask_node_if_cell_bottom[l])) {
2532 if ((!mask_node_if_cell_rear[l])) {
2533 if (is_cell_around_parent_cell_exist_and_different_owner(0, 0, 1)) {
2534 parent_node_owner = owner_cells_around_parent_cell(0, 0, 1);
2536 else if (is_cell_around_parent_cell_exist_and_different_owner(0, 0, 2)) {
2537 parent_node_owner = owner_cells_around_parent_cell(0, 0, 2);
2539 else if (is_cell_around_parent_cell_exist_and_different_owner(0, 1, 1)) {
2540 parent_node_owner = owner_cells_around_parent_cell(0, 1, 1);
2542 else if (is_cell_around_parent_cell_exist_and_different_owner(0, 1, 2)) {
2543 parent_node_owner = owner_cells_around_parent_cell(0, 1, 2);
2545 else if (is_cell_around_parent_cell_exist_and_different_owner(1, 0, 1)) {
2546 parent_node_owner = owner_cells_around_parent_cell(1, 0, 1);
2548 else if (is_cell_around_parent_cell_exist_and_different_owner(1, 0, 2)) {
2549 parent_node_owner = owner_cells_around_parent_cell(1, 0, 2);
2552 parent_node_owner = owner_cells_around_parent_cell(1, 1, 1);
2556 if (is_cell_around_parent_cell_exist_and_different_owner(1, 0, 1)) {
2557 parent_node_owner = owner_cells_around_parent_cell(1, 0, 1);
2559 else if (is_cell_around_parent_cell_exist_and_different_owner(1, 0, 2)) {
2560 parent_node_owner = owner_cells_around_parent_cell(1, 0, 2);
2563 parent_node_owner = owner_cells_around_parent_cell(1, 1, 1);
2568 if ((!mask_node_if_cell_rear[l])) {
2569 if (is_cell_around_parent_cell_exist_and_different_owner(0, 1, 1)) {
2570 parent_node_owner = owner_cells_around_parent_cell(0, 1, 1);
2572 else if (is_cell_around_parent_cell_exist_and_different_owner(0, 1, 2)) {
2573 parent_node_owner = owner_cells_around_parent_cell(0, 1, 2);
2575 else if (is_cell_around_parent_cell_exist_and_different_owner(0, 2, 1)) {
2576 parent_node_owner = owner_cells_around_parent_cell(0, 2, 1);
2578 else if (is_cell_around_parent_cell_exist_and_different_owner(0, 2, 2)) {
2579 parent_node_owner = owner_cells_around_parent_cell(0, 2, 2);
2582 parent_node_owner = owner_cells_around_parent_cell(1, 1, 1);
2586 parent_node_owner = owner_cells_around_parent_cell(1, 1, 1);
2591 node_uid_to_owner[parent_nodes_uids[l]] = parent_node_owner;
2592 debug() <<
"Parent node (create node) -- parent_cell_uid : " << parent_cell_uid
2593 <<
" -- level : " << -1
2594 <<
" -- node : " << l
2595 <<
" -- uid_node : " << parent_nodes_uids[l]
2596 <<
" -- owner : " << parent_node_owner;
2607 debug() <<
"Nb new nodes in patch : " << total_nb_nodes;
2613 m_mesh->modifier()->addNodes(nodes_infos, nodes_lid);
2620 ENUMERATE_ (
Node, inode, m_mesh->nodeFamily()->view(nodes_lid)) {
2623 ARCANE_ASSERT((node_uid_to_owner.find(node.
uniqueId()) != node_uid_to_owner.end()), (
"No owner found for node"));
2624 ARCANE_ASSERT((node_uid_to_owner[node.
uniqueId()] < nb_rank && node_uid_to_owner[node.
uniqueId()] >= 0), (
"Bad owner found for node"));
2628 if (node_uid_to_owner[node.
uniqueId()] == my_rank) {
2632 uid_child_nodes[index++] = m_num_mng->childNodeUniqueIdOfNode(node.
uniqueId(), -1);
2634 m_mesh->nodeFamily()->itemsUniqueIdToLocalId(lid_child_nodes, uid_child_nodes,
false);
2638 ENUMERATE_ (
Node, inode, m_mesh->nodeFamily()->view(nodes_lid)) {
2639 const Int32 child_lid = lid_child_nodes[index++];
2640 if (child_lid == NULL_ITEM_ID) {
2644 Node child = nodes[child_lid];
2645 Node parent = *inode;
2647 m_mesh->modifier()->addParentNodeToNode(child, parent);
2648 m_mesh->modifier()->addChildNodeToNode(parent, child);
2652 m_mesh->nodeFamily()->notifyItemsOwnerChanged();
2657 debug() <<
"Nb new faces in patch : " << total_nb_faces;
2659 Integer nb_child = (m_mesh->dimension() == 2 ? 2 : 4);
2662 m_mesh->modifier()->addFaces(total_nb_faces, faces_infos, faces_lid);
2669 ENUMERATE_ (
Face, iface, m_mesh->faceFamily()->view(faces_lid)) {
2672 ARCANE_ASSERT((face_uid_to_owner.find(face.
uniqueId()) != face_uid_to_owner.end()), (
"No owner found for face"));
2673 ARCANE_ASSERT((face_uid_to_owner[face.
uniqueId()] < nb_rank && face_uid_to_owner[face.
uniqueId()] >= 0), (
"Bad owner found for face"));
2677 if (face_uid_to_owner[face.
uniqueId()] == my_rank) {
2681 for (Integer i = 0; i < nb_child; ++i) {
2682 uid_child_faces[index++] = m_num_mng->childFaceUniqueIdOfFace(face.
uniqueId(), -1, i);
2686 m_mesh->faceFamily()->itemsUniqueIdToLocalId(lid_child_faces, uid_child_faces,
false);
2690 ENUMERATE_ (
Face, iface, m_mesh->faceFamily()->view(faces_lid)) {
2691 for (Integer i = 0; i < nb_child; ++i) {
2692 const Int32 child_lid = lid_child_faces[index++];
2693 if (child_lid == NULL_ITEM_ID) {
2697 Face child = faces[child_lid];
2698 Face parent = *iface;
2700 m_mesh->modifier()->addParentFaceToFace(child, parent);
2701 m_mesh->modifier()->addChildFaceToFace(parent, child);
2706 m_mesh->faceFamily()->notifyItemsOwnerChanged();
2712 debug() <<
"Nb new cells in patch : " << total_nb_cells;
2714 m_mesh->modifier()->addCells(total_nb_cells, cells_infos, cells_lid);
2718 for (Integer i = 0; i < total_nb_cells; ++i) {
2719 Cell parent = cells[cells_lid[i]];
2727 if (around_parent_cells_uid_to_owner[parent.
uniqueId()] == my_rank) {
2730 if (parent_to_child_cells[parent.
uniqueId()][0].itemBase().flags() & ItemFlags::II_Shared) {
2733 for (
Cell child : parent_to_child_cells[parent.
uniqueId()]) {
2734 m_mesh->modifier()->addParentCellToCell(child, parent);
2735 m_mesh->modifier()->addChildCellToCell(parent, child);
2738 m_mesh->cellFamily()->notifyItemsOwnerChanged();
2741 m_mesh->modifier()->endUpdate();
2742 m_num_mng->updateFirstLevel();
2746 for (Integer i = 0; i < total_nb_cells; ++i) {
2747 Cell parent_cell = cells[cells_lid[i]];
2748 m_num_mng->setParentNodeCoordinates(parent_cell);
2753 if (node.mutableItemBase().flags() & ItemFlags::II_Own) {
2754 node.mutableItemBase().addFlags(ItemFlags::II_Shared);
2758 if (face.mutableItemBase().flags() & ItemFlags::II_Own) {
2759 face.mutableItemBase().addFlags(ItemFlags::II_Shared);
2767 CellGroup parent_cells = m_mesh->allLevelCells(0);
2775 m_mesh->computeSynchronizeInfos();
2779 m_cmesh->computeDirections();