91void CartesianMeshNumberingMng::
92prepareLevel(Int32 level)
94 if (level <= m_max_level && level >= m_min_level)
96 if (level == m_max_level + 1) {
99 else if (level == m_min_level - 1) {
105 m_p_to_l_level.add(level);
107 m_first_cell_uid_level.add(m_latest_cell_uid);
108 m_first_node_uid_level.add(m_latest_node_uid);
109 m_first_face_uid_level.add(m_latest_face_uid);
111 m_latest_cell_uid += nbCellInLevel(level);
112 m_latest_node_uid += nbNodeInLevel(level);
113 m_latest_face_uid += nbFaceInLevel(level);
119void CartesianMeshNumberingMng::
122 Int32 nb_levels_to_add = -m_min_level;
123 m_ori_level += nb_levels_to_add;
125 if (nb_levels_to_add == 0) {
129 m_max_level += nb_levels_to_add;
130 m_min_level += nb_levels_to_add;
132 for (Int32& i : m_p_to_l_level) {
133 i += nb_levels_to_add;
136 m_nb_cell /= (m_pattern * nb_levels_to_add);
141 auto* cmgi = ICartesianMeshGenerationInfo::getReference(m_mesh,
false);
147 cmgi->setOwnCellOffsets(v[0] / m_pattern, v[1] / m_pattern, v[2] / m_pattern);
151 cmgi->setGlobalNbCells(v[0] / m_pattern, v[1] / m_pattern, v[2] / m_pattern);
155 cmgi->setOwnNbCells(v[0] / m_pattern, v[1] / m_pattern, v[2] / m_pattern);
157 cmgi->setFirstOwnCellUniqueId(firstCellUniqueId(0));
439Int64 CartesianMeshNumberingMng::
440faceOffsetLevelToLevel(Int64 coord, Integer level_from, Integer level_to)
const
462 if (level_from == level_to) {
465 else if (level_from < level_to) {
466 const Integer pattern = m_pattern * (level_to - level_from);
467 if (coord % 2 == 0) {
468 return coord * pattern;
471 return ((coord - 1) * pattern) + 1;
475 const Integer pattern = m_pattern * (level_from - level_to);
476 if (coord % 2 == 0) {
477 if (coord % (pattern * 2) == 0) {
478 return coord / pattern;
493 return coord - ((Int64((coord - 1) / (pattern * 2)) * (2 * (pattern - 1))) + ((coord - 1) % (pattern * 2)));
652Int64 CartesianMeshNumberingMng::
653faceUniqueIdToCoordX(Int64 uid, Integer level)
655 if (m_dimension == 2) {
657 const Int64 nb_face_x = globalNbFacesXCartesianView(level);
658 const Int64 first_face_uid = firstFaceUniqueId(level);
660 uid -= first_face_uid;
683 return uid % nb_face_x;
686 const Int64 nb_face_x = globalNbFacesX(level);
687 const Int64 nb_cell_x = globalNbCellsX(level);
688 const Int64 first_face_uid = firstFaceUniqueId(level);
692 uid -= first_face_uid;
694 Int64x3 three_parts_numbering = face3DNumberingThreeParts(level);
719 if (uid < three_parts_numbering.x) {
728 return (uid % nb_cell_x) * 2 + 1;
734 else if (uid < three_parts_numbering.x + three_parts_numbering.y) {
735 uid -= three_parts_numbering.x;
745 return (uid % nb_face_x) * 2;
752 uid -= three_parts_numbering.x + three_parts_numbering.y;
762 return (uid % nb_cell_x) * 2 + 1;
780Int64 CartesianMeshNumberingMng::
781faceUniqueIdToCoordY(Int64 uid, Integer level)
783 if (m_dimension == 2) {
784 const Int64 nb_face_x = globalNbFacesXCartesianView(level);
785 const Int64 first_face_uid = firstFaceUniqueId(level);
787 uid -= first_face_uid;
810 const Int64 flat_pos = uid / nb_face_x;
811 return (flat_pos * 2) + (flat_pos % 2 == uid % 2 ? 0 : 1) - 1;
814 const Int64 nb_face_x = globalNbFacesX(level);
815 const Int64 nb_face_y = globalNbFacesY(level);
816 const Int64 nb_cell_x = globalNbCellsX(level);
817 const Int64 nb_cell_y = globalNbCellsY(level);
818 const Int64 first_face_uid = firstFaceUniqueId(level);
822 uid -= first_face_uid;
824 Int64x3 three_parts_numbering = face3DNumberingThreeParts(level);
849 if (uid < three_parts_numbering.x) {
850 uid %= nb_cell_x * nb_cell_y;
861 return (uid / nb_cell_x) * 2 + 1;
867 else if (uid < three_parts_numbering.x + three_parts_numbering.y) {
868 uid -= three_parts_numbering.x;
869 uid %= nb_face_x * nb_cell_y;
880 return (uid / nb_face_x) * 2 + 1;
887 uid -= three_parts_numbering.x + three_parts_numbering.y;
888 uid %= nb_cell_x * nb_face_y;
899 return (uid / nb_cell_x) * 2;
917Int64 CartesianMeshNumberingMng::
918faceUniqueIdToCoordZ(Int64 uid, Integer level)
920 const Int64 nb_face_x = globalNbFacesX(level);
921 const Int64 nb_face_y = globalNbFacesY(level);
922 const Int64 nb_cell_x = globalNbCellsX(level);
923 const Int64 nb_cell_y = globalNbCellsY(level);
924 const Int64 first_face_uid = firstFaceUniqueId(level);
928 uid -= first_face_uid;
930 Int64x3 three_parts_numbering = face3DNumberingThreeParts(level);
955 if (uid < three_parts_numbering.x) {
966 return (uid / (nb_cell_x * nb_cell_y)) * 2;
972 else if (uid < three_parts_numbering.x + three_parts_numbering.y) {
973 uid -= three_parts_numbering.x;
984 return (uid / (nb_face_x * nb_cell_y)) * 2 + 1;
991 uid -= three_parts_numbering.x + three_parts_numbering.y;
1002 return (uid / (nb_cell_x * nb_face_y)) * 2 + 1;
1069Int64 CartesianMeshNumberingMng::
1070faceUniqueId(Integer level,
Int64x3 face_coord)
1072 const Int64 nb_face_x = globalNbFacesX(level);
1073 const Int64 nb_face_y = globalNbFacesY(level);
1074 const Int64 nb_cell_x = globalNbCellsX(level);
1075 const Int64 nb_cell_y = globalNbCellsY(level);
1077 Int64x3 three_parts_numbering = face3DNumberingThreeParts(level);
1078 Int64 uid = firstFaceUniqueId(level);
1105 if (face_coord.z % 2 == 0) {
1114 uid += face_coord.x + (face_coord.y * nb_cell_x) + (face_coord.z * nb_cell_x * nb_cell_y);
1118 else if (face_coord.x % 2 == 0) {
1119 uid += three_parts_numbering.x;
1129 uid += face_coord.x + (face_coord.y * nb_face_x) + (face_coord.z * nb_face_x * nb_cell_y);
1133 else if (face_coord.y % 2 == 0) {
1134 uid += three_parts_numbering.x + three_parts_numbering.y;
1144 uid += face_coord.x + (face_coord.y * nb_cell_x) + (face_coord.z * nb_cell_x * nb_face_y);
1147 ARCANE_FATAL(
"Bizarre -- x : {0} -- y : {1} -- z : {2}", face_coord.x, face_coord.y, face_coord.z);
1201void CartesianMeshNumberingMng::
1204 if (uid.
size() != nbNodeByCell())
1207 const Int64 nb_node_x = globalNbNodesX(level);
1208 const Int64 nb_node_y = globalNbNodesY(level);
1209 const Int64 first_node_uid = firstNodeUniqueId(level);
1211 uid[0] = (cell_coord.x + 0) + ((cell_coord.y + 0) * nb_node_x) + ((cell_coord.z + 0) * nb_node_x * nb_node_y) + first_node_uid;
1212 uid[1] = (cell_coord.x + 1) + ((cell_coord.y + 0) * nb_node_x) + ((cell_coord.z + 0) * nb_node_x * nb_node_y) + first_node_uid;
1213 uid[2] = (cell_coord.x + 1) + ((cell_coord.y + 1) * nb_node_x) + ((cell_coord.z + 0) * nb_node_x * nb_node_y) + first_node_uid;
1214 uid[3] = (cell_coord.x + 0) + ((cell_coord.y + 1) * nb_node_x) + ((cell_coord.z + 0) * nb_node_x * nb_node_y) + first_node_uid;
1216 uid[4] = (cell_coord.x + 0) + ((cell_coord.y + 0) * nb_node_x) + ((cell_coord.z + 1) * nb_node_x * nb_node_y) + first_node_uid;
1217 uid[5] = (cell_coord.x + 1) + ((cell_coord.y + 0) * nb_node_x) + ((cell_coord.z + 1) * nb_node_x * nb_node_y) + first_node_uid;
1218 uid[6] = (cell_coord.x + 1) + ((cell_coord.y + 1) * nb_node_x) + ((cell_coord.z + 1) * nb_node_x * nb_node_y) + first_node_uid;
1219 uid[7] = (cell_coord.x + 0) + ((cell_coord.y + 1) * nb_node_x) + ((cell_coord.z + 1) * nb_node_x * nb_node_y) + first_node_uid;
1243void CartesianMeshNumberingMng::
1246 if (m_dimension == 2) {
1247 const Int64x2 cell_coord(cellUniqueIdToCoordX(cell_uid, level), cellUniqueIdToCoordY(cell_uid, level));
1248 cellNodeUniqueIds(uid, level, cell_coord);
1251 const Int64x3 cell_coord(cellUniqueIdToCoordX(cell_uid, level), cellUniqueIdToCoordY(cell_uid, level), cellUniqueIdToCoordZ(cell_uid, level));
1252 cellNodeUniqueIds(uid, level, cell_coord);
1268void CartesianMeshNumberingMng::
1271 if (uid.
size() != nbFaceByCell())
1274 const Int64x3 nb_cell(globalNbCellsX(level), globalNbCellsY(level), globalNbCellsZ(level));
1275 const Int64x3 nb_face(nb_cell + 1);
1277 const Int64 first_face_uid = firstFaceUniqueId(level);
1320 const Int64 total_face_xy = nb_face.z * nb_cell.x * nb_cell.y;
1321 const Int64 total_face_xy_yz = total_face_xy + nb_face.x * nb_cell.y * nb_cell.z;
1323 const Int64 nb_cell_before_j = cell_coord.y * nb_cell.x;
1325 uid[0] = (cell_coord.z * nb_cell.x * nb_cell.y) + nb_cell_before_j + (cell_coord.x);
1327 uid[3] = uid[0] + nb_cell.x * nb_cell.y;
1329 uid[1] = (cell_coord.z * nb_face.x * nb_cell.y) + (cell_coord.y * nb_face.x) + (cell_coord.x) + total_face_xy;
1331 uid[4] = uid[1] + 1;
1333 uid[2] = (cell_coord.z * nb_cell.x * nb_face.y) + nb_cell_before_j + (cell_coord.x) + total_face_xy_yz;
1335 uid[5] = uid[2] + nb_cell.x;
1337 uid[0] += first_face_uid;
1338 uid[1] += first_face_uid;
1339 uid[2] += first_face_uid;
1340 uid[3] += first_face_uid;
1341 uid[4] += first_face_uid;
1342 uid[5] += first_face_uid;
1348void CartesianMeshNumberingMng::
1351 if (uid.
size() != nbFaceByCell())
1354 const Int64 nb_cell_x = globalNbCellsX(level);
1355 const Int64 nb_face_x = nb_cell_x + 1;
1356 const Int64 first_face_uid = firstFaceUniqueId(level);
1376 uid[0] = cell_coord.x * 2 + cell_coord.y * (nb_face_x + nb_cell_x);
1380 uid[2] = uid[0] + (nb_face_x + nb_cell_x);
1383 uid[3] = uid[2] - 1;
1386 uid[1] = uid[2] + 1;
1388 uid[0] += first_face_uid;
1389 uid[1] += first_face_uid;
1390 uid[2] += first_face_uid;
1391 uid[3] += first_face_uid;
1397void CartesianMeshNumberingMng::
1400 if (m_dimension == 2) {
1401 const Int64x2 cell_coord(cellUniqueIdToCoordX(cell_uid, level), cellUniqueIdToCoordY(cell_uid, level));
1402 cellFaceUniqueIds(uid, level, cell_coord);
1405 const Int64x3 cell_coord(cellUniqueIdToCoordX(cell_uid, level), cellUniqueIdToCoordY(cell_uid, level), cellUniqueIdToCoordZ(cell_uid, level));
1406 cellFaceUniqueIds(uid, level, cell_coord);
1422void CartesianMeshNumberingMng::
1427 const Int64 coord_cell_x = cellUniqueIdToCoordX(cell_uid, level);
1428 const Int64 coord_cell_y = cellUniqueIdToCoordY(cell_uid, level);
1430 const Int64 nb_cells_x = globalNbCellsX(level);
1431 const Int64 nb_cells_y = globalNbCellsY(level);
1433 if (m_dimension == 2) {
1434 ARCANE_ASSERT((uid.
size() == 9), (
"Size of uid array != 9"));
1436 for (Integer j = -1; j < 2; ++j) {
1437 const Int64 coord_around_cell_y = coord_cell_y + j;
1438 if (coord_around_cell_y >= 0 && coord_around_cell_y < nb_cells_y) {
1440 for (Integer i = -1; i < 2; ++i) {
1441 const Int64 coord_around_cell_x = coord_cell_x + i;
1442 if (coord_around_cell_x >= 0 && coord_around_cell_x < nb_cells_x) {
1443 uid[(i + 1) + ((j + 1) * 3)] = cellUniqueId(level,
Int64x2(coord_around_cell_x, coord_around_cell_y));
1451 ARCANE_ASSERT((uid.
size() == 27), (
"Size of uid array != 27"));
1453 const Int64 coord_cell_z = cellUniqueIdToCoordZ(cell_uid, level);
1454 const Int64 nb_cells_z = globalNbCellsZ(level);
1456 for (Integer k = -1; k < 2; ++k) {
1457 const Int64 coord_around_cell_z = coord_cell_z + k;
1458 if (coord_around_cell_z >= 0 && coord_around_cell_z < nb_cells_z) {
1460 for (Integer j = -1; j < 2; ++j) {
1461 const Int64 coord_around_cell_y = coord_cell_y + j;
1462 if (coord_around_cell_y >= 0 && coord_around_cell_y < nb_cells_y) {
1464 for (Integer i = -1; i < 2; ++i) {
1465 const Int64 coord_around_cell_x = coord_cell_x + i;
1466 if (coord_around_cell_x >= 0 && coord_around_cell_x < nb_cells_x) {
1467 uid[(i + 1) + ((j + 1) * 3) + ((k + 1) * 9)] = cellUniqueId(level,
Int64x3(coord_around_cell_x, coord_around_cell_y, coord_around_cell_z));
1480void CartesianMeshNumberingMng::
1481setChildNodeCoordinates(
Cell parent_cell)
1483 if (!(parent_cell.
itemBase().
flags() & ItemFlags::II_JustRefined)) {
1489 const Real3& node0(nodes_coords[parent_cell.
node(0)]);
1490 const Real3& node1(nodes_coords[parent_cell.
node(1)]);
1491 const Real3& node2(nodes_coords[parent_cell.
node(2)]);
1492 const Real3& node3(nodes_coords[parent_cell.
node(3)]);
1494 if (m_dimension == 2) {
1525 auto txty = [&](Integer pos_x, Integer pos_y) ->
Real3 {
1526 const Real x = (Real)pos_x / (Real)m_pattern;
1527 const Real y = (Real)pos_y / (Real)m_pattern;
1529 const Real i = (node3.
x - node0.
x) * y + node0.
x;
1530 const Real j = (node2.
x - node1.
x) * y + node1.
x;
1532 const Real k = (node1.
y - node0.
y) * x + node0.
y;
1533 const Real l = (node2.
y - node3.
y) * x + node3.
y;
1535 const Real tx = (j - i) * x + i;
1536 const Real ty = (l - k) * y + k;
1553 return { tx, ty, 0 };
1556 const Integer node_1d_2d_x[] = { 0, 1, 1, 0 };
1557 const Integer node_1d_2d_y[] = { 0, 0, 1, 1 };
1559 for (Integer j = 0; j < m_pattern; ++j) {
1560 for (Integer i = 0; i < m_pattern; ++i) {
1562 Integer begin = (i == 0 && j == 0 ? 0 : j == 0 ? 1
1564 Integer end = (i == 0 ? nbNodeByCell() : nbNodeByCell() - 1);
1565 Cell child = childCellOfCell(parent_cell,
Int64x2(i, j));
1567 for (Integer inode = begin; inode < end; ++inode) {
1568 nodes_coords[child.
node(inode)] = txty(i + node_1d_2d_x[inode], j + node_1d_2d_y[inode]);
1581 const Real3& node4(nodes_coords[parent_cell.
node(4)]);
1582 const Real3& node5(nodes_coords[parent_cell.
node(5)]);
1583 const Real3& node6(nodes_coords[parent_cell.
node(6)]);
1584 const Real3& node7(nodes_coords[parent_cell.
node(7)]);
1590 auto txtytz = [&](Integer pos_x, Integer pos_y, Integer pos_z) ->
Real3 {
1591 const Real x = (Real)pos_x / (Real)m_pattern;
1592 const Real y = (Real)pos_y / (Real)m_pattern;
1593 const Real z = (Real)pos_z / (Real)m_pattern;
1596 const Real3 m = (node4 - node0) * z + node0;
1597 const Real3 n = (node5 - node1) * z + node1;
1598 const Real3 o = (node6 - node2) * z + node2;
1599 const Real3 p = (node7 - node3) * z + node3;
1602 const Real i = (p.
x - m.
x) * y + m.
x;
1603 const Real j = (o.
x - n.
x) * y + n.
x;
1605 const Real tx = (j - i) * x + i;
1607 const Real k = (n.
y - m.
y) * x + m.
y;
1608 const Real l = (o.
y - p.
y) * x + p.
y;
1610 const Real ty = (l - k) * y + k;
1612 const Real q = (p.
z - m.
z) * y + m.
z;
1613 const Real r = (o.
z - n.
z) * y + n.
z;
1615 const Real s = (n.
z - m.
z) * x + m.
z;
1616 const Real t = (o.
z - p.
z) * x + p.
z;
1618 const Real tz = (((r - q) * x + q) + ((t - s) * y + s)) * 0.5;
1648 return { tx, ty, tz };
1651 const Integer node_1d_3d_x[] = { 0, 1, 1, 0, 0, 1, 1, 0 };
1652 const Integer node_1d_3d_y[] = { 0, 0, 1, 1, 0, 0, 1, 1 };
1653 const Integer node_1d_3d_z[] = { 0, 0, 0, 0, 1, 1, 1, 1 };
1655 for (Integer k = 0; k < m_pattern; ++k) {
1656 for (Integer j = 0; j < m_pattern; ++j) {
1657 for (Integer i = 0; i < m_pattern; ++i) {
1661 Integer end = nbNodeByCell();
1662 Cell child = childCellOfCell(parent_cell,
Int64x3(i, j, k));
1664 for (Integer inode = begin; inode < end; ++inode) {
1665 nodes_coords[child.
node(inode)] = txtytz(i + node_1d_3d_x[inode], j + node_1d_3d_y[inode], k + node_1d_3d_z[inode]);
1683void CartesianMeshNumberingMng::
1684setParentNodeCoordinates(
Cell parent_cell)
1686 if (!(parent_cell.
itemBase().
flags() & ItemFlags::II_JustAdded)) {
1692 if (m_dimension == 2) {
1693 nodes_coords[parent_cell.
node(0)] = nodes_coords[childCellOfCell(parent_cell,
Int64x2(0, 0)).node(0)];
1694 nodes_coords[parent_cell.
node(1)] = nodes_coords[childCellOfCell(parent_cell,
Int64x2(m_pattern - 1, 0)).node(1)];
1695 nodes_coords[parent_cell.
node(2)] = nodes_coords[childCellOfCell(parent_cell,
Int64x2(m_pattern - 1, m_pattern - 1)).node(2)];
1696 nodes_coords[parent_cell.
node(3)] = nodes_coords[childCellOfCell(parent_cell,
Int64x2(0, m_pattern - 1)).node(3)];
1700 nodes_coords[parent_cell.
node(0)] = nodes_coords[childCellOfCell(parent_cell,
Int64x3(0, 0, 0)).node(0)];
1701 nodes_coords[parent_cell.
node(1)] = nodes_coords[childCellOfCell(parent_cell,
Int64x3(m_pattern - 1, 0, 0)).node(1)];
1702 nodes_coords[parent_cell.
node(2)] = nodes_coords[childCellOfCell(parent_cell,
Int64x3(m_pattern - 1, m_pattern - 1, 0)).node(2)];
1703 nodes_coords[parent_cell.
node(3)] = nodes_coords[childCellOfCell(parent_cell,
Int64x3(0, m_pattern - 1, 0)).node(3)];
1705 nodes_coords[parent_cell.
node(4)] = nodes_coords[childCellOfCell(parent_cell,
Int64x3(0, 0, m_pattern - 1)).node(4)];
1706 nodes_coords[parent_cell.
node(5)] = nodes_coords[childCellOfCell(parent_cell,
Int64x3(m_pattern - 1, 0, m_pattern - 1)).node(5)];
1707 nodes_coords[parent_cell.
node(6)] = nodes_coords[childCellOfCell(parent_cell,
Int64x3(m_pattern - 1, m_pattern - 1, m_pattern - 1)).node(6)];
1708 nodes_coords[parent_cell.
node(7)] = nodes_coords[childCellOfCell(parent_cell,
Int64x3(0, m_pattern - 1, m_pattern - 1)).node(7)];
1715Int64 CartesianMeshNumberingMng::
1716parentCellUniqueIdOfCell(Int64 uid, Integer level,
bool do_fatal)
1723 if (globalNbCellsX(level - 1) == 0) {
1727 return NULL_ITEM_UNIQUE_ID;
1730 if (m_dimension == 2) {
1731 return cellUniqueId(level - 1,
1732 Int64x2(offsetLevelToLevel(cellUniqueIdToCoordX(uid, level), level, level - 1),
1733 offsetLevelToLevel(cellUniqueIdToCoordY(uid, level), level, level - 1)));
1736 return cellUniqueId(level - 1,
1737 Int64x3(offsetLevelToLevel(cellUniqueIdToCoordX(uid, level), level, level - 1),
1738 offsetLevelToLevel(cellUniqueIdToCoordY(uid, level), level, level - 1),
1739 offsetLevelToLevel(cellUniqueIdToCoordZ(uid, level), level, level - 1)));
1755Int64 CartesianMeshNumberingMng::
1756childCellUniqueIdOfCell(
Cell cell,
Int64x3 child_coord_in_parent)
1758 ARCANE_ASSERT((child_coord_in_parent.x < m_pattern && child_coord_in_parent.x >= 0), (
"Bad child_coord_in_parent.x"))
1759 ARCANE_ASSERT((child_coord_in_parent.y < m_pattern && child_coord_in_parent.y >= 0), (
"Bad child_coord_in_parent.y"))
1760 ARCANE_ASSERT((child_coord_in_parent.z < m_pattern && child_coord_in_parent.z >= 0), (
"Bad child_coord_in_parent.z"))
1763 const Int32 level = cell.
level();
1765 return cellUniqueId(level + 1,
1766 Int64x3(offsetLevelToLevel(cellUniqueIdToCoordX(uid, level), level, level + 1) + child_coord_in_parent.x,
1767 offsetLevelToLevel(cellUniqueIdToCoordY(uid, level), level, level + 1) + child_coord_in_parent.y,
1768 offsetLevelToLevel(cellUniqueIdToCoordZ(uid, level), level, level + 1) + child_coord_in_parent.z));
1774Int64 CartesianMeshNumberingMng::
1775childCellUniqueIdOfCell(
Cell cell,
Int64x2 child_coord_in_parent)
1777 ARCANE_ASSERT((child_coord_in_parent.x < m_pattern && child_coord_in_parent.x >= 0), (
"Bad child_coord_in_parent.x"))
1778 ARCANE_ASSERT((child_coord_in_parent.y < m_pattern && child_coord_in_parent.y >= 0), (
"Bad child_coord_in_parent.y"))
1781 const Int32 level = cell.
level();
1783 return cellUniqueId(level + 1,
1784 Int64x2(offsetLevelToLevel(cellUniqueIdToCoordX(uid, level), level, level + 1) + child_coord_in_parent.x,
1785 offsetLevelToLevel(cellUniqueIdToCoordY(uid, level), level, level + 1) + child_coord_in_parent.y));
1791Int64 CartesianMeshNumberingMng::
1792childCellUniqueIdOfCell(
Cell cell, Int64 child_index_in_parent)
1794 if (m_dimension == 2) {
1795 ARCANE_ASSERT((child_index_in_parent < m_pattern * m_pattern && child_index_in_parent >= 0), (
"Bad child_index_in_parent"))
1797 return childCellUniqueIdOfCell(cell,
1799 child_index_in_parent % m_pattern,
1800 child_index_in_parent / m_pattern));
1804 ARCANE_ASSERT((child_index_in_parent < m_pattern * m_pattern * m_pattern && child_index_in_parent >= 0), (
"Bad child_index_in_parent"))
1806 const Int64 to_2d = child_index_in_parent % (m_pattern * m_pattern);
1807 return childCellUniqueIdOfCell(cell,
1811 child_index_in_parent / (m_pattern * m_pattern)));
1870Int64 CartesianMeshNumberingMng::
1871parentNodeUniqueIdOfNode(Int64 uid, Integer level,
bool do_fatal)
1877 const Int64 coord_x = nodeUniqueIdToCoordX(uid, level);
1878 const Int64 coord_y = nodeUniqueIdToCoordY(uid, level);
1880 if (coord_x % m_pattern != 0 || coord_y % m_pattern != 0) {
1884 return NULL_ITEM_UNIQUE_ID;
1887 if (m_dimension == 2) {
1888 return nodeUniqueId(level - 1,
1889 Int64x2(offsetLevelToLevel(coord_x, level, level - 1),
1890 offsetLevelToLevel(coord_y, level, level - 1)));
1893 const Int64 coord_z = nodeUniqueIdToCoordZ(uid, level);
1895 if (coord_z % m_pattern != 0) {
1899 return NULL_ITEM_UNIQUE_ID;
1901 return nodeUniqueId(level - 1,
1902 Int64x3(offsetLevelToLevel(coord_x, level, level - 1),
1903 offsetLevelToLevel(coord_y, level, level - 1),
1904 offsetLevelToLevel(coord_z, level, level - 1)));
1921Int64 CartesianMeshNumberingMng::
1922childNodeUniqueIdOfNode(Int64 uid, Integer level)
1924 if (m_dimension == 2) {
1925 return nodeUniqueId(level + 1,
1926 Int64x2(offsetLevelToLevel(nodeUniqueIdToCoordX(uid, level), level, level + 1),
1927 offsetLevelToLevel(nodeUniqueIdToCoordY(uid, level), level, level + 1)));
1931 return nodeUniqueId(level + 1,
1932 Int64x3(offsetLevelToLevel(nodeUniqueIdToCoordX(uid, level), level, level + 1),
1933 offsetLevelToLevel(nodeUniqueIdToCoordY(uid, level), level, level + 1),
1934 offsetLevelToLevel(nodeUniqueIdToCoordZ(uid, level), level, level + 1)));
1951Int64 CartesianMeshNumberingMng::
1952parentFaceUniqueIdOfFace(Int64 uid, Integer level,
bool do_fatal)
1954 if (m_converting_numbering_face && level == m_ori_level) {
1955 uid = m_face_ori_numbering_to_new[uid];
1963 const Int64 coord_x = faceUniqueIdToCoordX(uid, level);
1964 const Int64 coord_y = faceUniqueIdToCoordY(uid, level);
1966 ARCANE_ASSERT((coord_x < globalNbFacesXCartesianView(level) && coord_x >= 0), (
"Bad coord_x"))
1967 ARCANE_ASSERT((coord_y < globalNbFacesYCartesianView(level) && coord_y >= 0), (
"Bad coord_y"))
1969 const Int64 parent_coord_x = faceOffsetLevelToLevel(coord_x, level, level - 1);
1970 const Int64 parent_coord_y = faceOffsetLevelToLevel(coord_y, level, level - 1);
1972 if (parent_coord_x == -1 || parent_coord_y == -1) {
1976 return NULL_ITEM_UNIQUE_ID;
1979 ARCANE_ASSERT((parent_coord_x < globalNbFacesXCartesianView(level - 1) && parent_coord_x >= 0), (
"Bad parent_coord_x"))
1980 ARCANE_ASSERT((parent_coord_y < globalNbFacesYCartesianView(level - 1) && parent_coord_y >= 0), (
"Bad parent_coord_y"))
1982 if (m_dimension == 2) {
1983 if (m_converting_numbering_face && level - 1 == m_ori_level) {
1984 return m_face_new_numbering_to_ori[faceUniqueId(level - 1,
Int64x2(parent_coord_x, parent_coord_y))];
1986 return faceUniqueId(level - 1,
Int64x2(parent_coord_x, parent_coord_y));
1989 const Int64 coord_z = faceUniqueIdToCoordZ(uid, level);
1990 ARCANE_ASSERT((coord_z < globalNbFacesZCartesianView(level) && coord_z >= 0), (
"Bad coord_z"))
1992 const Int64 parent_coord_z = faceOffsetLevelToLevel(coord_z, level, level - 1);
1994 if (parent_coord_z == -1) {
1998 return NULL_ITEM_UNIQUE_ID;
2001 ARCANE_ASSERT((parent_coord_z < globalNbFacesZCartesianView(level - 1) && parent_coord_z >= 0), (
"Bad parent_coord_z"))
2005 if (m_converting_numbering_face && level - 1 == m_ori_level) {
2006 return m_face_new_numbering_to_ori[faceUniqueId(level - 1,
Int64x3(parent_coord_x, parent_coord_y, parent_coord_z))];
2009 return faceUniqueId(level - 1,
Int64x3(parent_coord_x, parent_coord_y, parent_coord_z));
2026Int64 CartesianMeshNumberingMng::
2027childFaceUniqueIdOfFace(Int64 uid, Integer level, Int64 child_index_in_parent)
2029 if (m_converting_numbering_face && level == m_ori_level) {
2030 uid = m_face_ori_numbering_to_new[uid];
2033 const Int64 coord_x = faceUniqueIdToCoordX(uid, level);
2034 const Int64 coord_y = faceUniqueIdToCoordY(uid, level);
2036 ARCANE_ASSERT((coord_x < globalNbFacesXCartesianView(level) && coord_x >= 0), (
"Bad coord_x"))
2037 ARCANE_ASSERT((coord_y < globalNbFacesYCartesianView(level) && coord_y >= 0), (
"Bad coord_y"))
2039 Int64 first_child_coord_x = faceOffsetLevelToLevel(coord_x, level, level + 1);
2040 Int64 first_child_coord_y = faceOffsetLevelToLevel(coord_y, level, level + 1);
2042 ARCANE_ASSERT((first_child_coord_x < globalNbFacesXCartesianView(level + 1) && first_child_coord_x >= 0), (
"Bad first_child_coord_x"))
2043 ARCANE_ASSERT((first_child_coord_y < globalNbFacesYCartesianView(level + 1) && first_child_coord_y >= 0), (
"Bad first_child_coord_y"))
2045 if (m_dimension == 2) {
2046 ARCANE_ASSERT((child_index_in_parent < m_pattern && child_index_in_parent >= 0), (
"Invalid child_index_in_parent"))
2048 if (coord_y % 2 == 0) {
2049 first_child_coord_x += child_index_in_parent * 2;
2051 else if (coord_x % 2 == 0) {
2052 first_child_coord_y += child_index_in_parent * globalNbFacesY(level + 1);
2058 if (m_converting_numbering_face && level + 1 == m_ori_level) {
2059 return m_face_new_numbering_to_ori[faceUniqueId(level + 1,
Int64x2(first_child_coord_x, first_child_coord_y))];
2062 return faceUniqueId(level + 1,
Int64x2(first_child_coord_x, first_child_coord_y));
2066 ARCANE_ASSERT((child_index_in_parent < m_pattern * m_pattern && child_index_in_parent >= 0), (
"Invalid child_index_in_parent"))
2068 const Int64 coord_z = faceUniqueIdToCoordZ(uid, level);
2069 ARCANE_ASSERT((coord_z < globalNbFacesZCartesianView(level) && coord_z >= 0), (
"Bad coord_z"))
2071 Int64 first_child_coord_z = faceOffsetLevelToLevel(coord_z, level, level + 1);
2072 ARCANE_ASSERT((first_child_coord_z < globalNbFacesZCartesianView(level + 1) && first_child_coord_z >= 0), (
"Bad first_child_coord_z"))
2074 Int64 child_x = child_index_in_parent % m_pattern;
2075 Int64 child_y = child_index_in_parent / m_pattern;
2077 Int64x3 three_parts_numbering = face3DNumberingThreeParts(level);
2079 if (uid < three_parts_numbering.x) {
2080 first_child_coord_x += child_x * 2;
2081 first_child_coord_y += child_y * 2;
2083 else if (uid < three_parts_numbering.x + three_parts_numbering.y) {
2084 first_child_coord_y += child_x * 2;
2085 first_child_coord_z += child_y * 2;
2088 first_child_coord_x += child_x * 2;
2089 first_child_coord_z += child_y * 2;
2092 if (m_converting_numbering_face && level + 1 == m_ori_level) {
2093 return m_face_new_numbering_to_ori[faceUniqueId(level + 1,
Int64x3(first_child_coord_x, first_child_coord_y, first_child_coord_z))];
2096 return faceUniqueId(level + 1,
Int64x3(first_child_coord_x, first_child_coord_y, first_child_coord_z));