15#include "CartesianMeshNumberingMng.h" 
   17#include "arcane/utils/Vector2.h" 
   19#include "arcane/core/IMesh.h" 
   20#include "arcane/core/IParallelMng.h" 
   21#include "arcane/core/VariableTypes.h" 
   22#include "arcane/core/ICartesianMeshGenerationInfo.h" 
   33CartesianMeshNumberingMng::
 
   34CartesianMeshNumberingMng(
IMesh* mesh)
 
   37, m_dimension(mesh->dimension())
 
   41, m_converting_numbering_face(true)
 
   44  const auto* m_generation_info = ICartesianMeshGenerationInfo::getReference(m_mesh, 
true);
 
   47  m_nb_cell.x = global_nb_cells_by_direction[
MD_DirX];
 
   48  m_nb_cell.y = global_nb_cells_by_direction[
MD_DirY];
 
   49  m_nb_cell.z = ((m_dimension == 2) ? 1 : global_nb_cells_by_direction[
MD_DirZ]);
 
   52    ARCANE_FATAL(
"Bad value '{0}' for globalNbCells()[MD_DirX] (should be >0)", m_nb_cell.x);
 
   54    ARCANE_FATAL(
"Bad value '{0}' for globalNbCells()[MD_DirY] (should be >0)", m_nb_cell.y);
 
   56    ARCANE_FATAL(
"Bad value '{0}' for globalNbCells()[MD_DirZ] (should be >0)", m_nb_cell.z);
 
   58  m_p_to_l_level.add(0);
 
   60  if (m_dimension == 2) {
 
   61    m_latest_cell_uid = m_nb_cell.x * m_nb_cell.y;
 
   62    m_latest_node_uid = (m_nb_cell.x + 1) * (m_nb_cell.y + 1);
 
   63    m_latest_face_uid = (m_nb_cell.x * m_nb_cell.y) * 2 + m_nb_cell.x * 2 + m_nb_cell.y;
 
   66    m_latest_cell_uid = m_nb_cell.x * m_nb_cell.y * m_nb_cell.z;
 
   67    m_latest_node_uid = (m_nb_cell.x + 1) * (m_nb_cell.y + 1) * (m_nb_cell.z + 1);
 
   68    m_latest_face_uid = (m_nb_cell.z + 1) * m_nb_cell.x * m_nb_cell.y + (m_nb_cell.x + 1) * m_nb_cell.y * m_nb_cell.z + (m_nb_cell.y + 1) * m_nb_cell.z * m_nb_cell.x;
 
   71  m_first_cell_uid_level.add(0);
 
   72  m_first_node_uid_level.add(0);
 
   73  m_first_face_uid_level.add(0);
 
   78  if (m_converting_numbering_face) {
 
   79    UniqueArray<Int64> face_uid(CartesianMeshNumberingMng::nbFaceByCell());
 
   80    ENUMERATE_ (Cell, icell, m_mesh->allLevelCells(0)) {
 
   81      CartesianMeshNumberingMng::cellFaceUniqueIds(face_uid, 0, icell->uniqueId());
 
   82      for (Integer i = 0; i < CartesianMeshNumberingMng::nbFaceByCell(); ++i) {
 
   83        m_face_ori_numbering_to_new[icell->face(i).uniqueId()] = face_uid[i];
 
   84        m_face_new_numbering_to_ori[face_uid[i]] = icell->face(i).uniqueId();
 
   94void CartesianMeshNumberingMng::
 
   95prepareLevel(
Int32 level)
 
   97  if (level <= m_max_level && level >= m_min_level)
 
   99  if (level == m_max_level + 1) {
 
  102  else if (level == m_min_level - 1) {
 
  108  m_p_to_l_level.add(level);
 
  110  m_first_cell_uid_level.add(m_latest_cell_uid);
 
  111  m_first_node_uid_level.add(m_latest_node_uid);
 
  112  m_first_face_uid_level.add(m_latest_face_uid);
 
 
  122void CartesianMeshNumberingMng::
 
  125  Int32 nb_levels_to_add = -m_min_level;
 
  126  m_ori_level += nb_levels_to_add;
 
  128  if (nb_levels_to_add == 0) {
 
  132  m_max_level += nb_levels_to_add;
 
  133  m_min_level += nb_levels_to_add;
 
  135  for (
Int32& i : m_p_to_l_level) {
 
  136    i += nb_levels_to_add;
 
  139  m_nb_cell /= (m_pattern * nb_levels_to_add);
 
  144  auto* cmgi = ICartesianMeshGenerationInfo::getReference(m_mesh, 
false);
 
  150    cmgi->setOwnCellOffsets(v[0] / m_pattern, v[1] / m_pattern, v[2] / m_pattern);
 
  154    cmgi->setGlobalNbCells(v[0] / m_pattern, v[1] / m_pattern, v[2] / m_pattern);
 
  158    cmgi->setOwnNbCells(v[0] / m_pattern, v[1] / m_pattern, v[2] / m_pattern);
 
 
  169firstCellUniqueId(
Integer level)
 
  171  auto pos = m_p_to_l_level.span().findFirst(level);
 
  172  if (pos.has_value()) {
 
  173    return m_first_cell_uid_level[pos.value()];
 
 
  184firstNodeUniqueId(
Integer level)
 
  186  auto pos = m_p_to_l_level.span().findFirst(level);
 
  187  if (pos.has_value()) {
 
  188    return m_first_node_uid_level[pos.value()];
 
 
  199firstFaceUniqueId(
Integer level)
 
  201  auto pos = m_p_to_l_level.span().findFirst(level);
 
  202  if (pos.has_value()) {
 
  203    return m_first_face_uid_level[pos.value()];
 
 
  214globalNbCellsX(
Integer level)
 const 
  216  return static_cast<Int64>(
static_cast<Real>(m_nb_cell.x) * std::pow(m_pattern, level));
 
 
  223globalNbCellsY(
Integer level)
 const 
  225  return static_cast<Int64>(
static_cast<Real>(m_nb_cell.y) * std::pow(m_pattern, level));
 
 
  232globalNbCellsZ(
Integer level)
 const 
  234  return static_cast<Int64>(
static_cast<Real>(m_nb_cell.z) * std::pow(m_pattern, level));
 
 
  241globalNbNodesX(
Integer level)
 const 
 
  250globalNbNodesY(
Integer level)
 const 
 
  259globalNbNodesZ(
Integer level)
 const 
 
  268globalNbFacesX(
Integer level)
 const 
 
  277globalNbFacesY(
Integer level)
 const 
 
  286globalNbFacesZ(
Integer level)
 const 
 
  295globalNbFacesXCartesianView(
Integer level)
 const 
 
  304globalNbFacesYCartesianView(
Integer level)
 const 
 
  313globalNbFacesZCartesianView(
Integer level)
 const 
 
  322nbCellInLevel(
Integer level)
 const 
  324  if (m_dimension == 2) {
 
  326    return nb_cell.x * nb_cell.y;
 
  330  return nb_cell.x * nb_cell.y * nb_cell.z;
 
 
  337nbNodeInLevel(
Integer level)
 const 
  339  if (m_dimension == 2) {
 
  341    return (nb_cell.x + 1) * (nb_cell.y + 1);
 
  345  return (nb_cell.x + 1) * (nb_cell.y + 1) * (nb_cell.z + 1);
 
 
  352nbFaceInLevel(
Integer level)
 const 
  354  if (m_dimension == 2) {
 
  356    return (nb_cell.x * nb_cell.y) * 2 + nb_cell.x * 2 + nb_cell.y;
 
  360  return (nb_cell.z + 1) * nb_cell.x * nb_cell.y + (nb_cell.x + 1) * nb_cell.y * nb_cell.z + (nb_cell.y + 1) * nb_cell.z * nb_cell.x;
 
 
  376cellLevel(
Int64 uid)
 const 
  380  while (pos < m_first_cell_uid_level.size() && m_first_cell_uid_level[pos] <= uid) {
 
  385  return m_p_to_l_level[pos];
 
 
  392nodeLevel(
Int64 uid)
 const 
  396  while (pos < m_first_node_uid_level.size() && m_first_node_uid_level[pos] <= uid) {
 
  401  return m_p_to_l_level[pos];
 
 
  408faceLevel(
Int64 uid)
 const 
  412  while (pos < m_first_face_uid_level.size() && m_first_face_uid_level[pos] <= uid) {
 
  417  return m_p_to_l_level[pos];
 
 
  427  if (level_from == level_to) {
 
  430  else if (level_from < level_to) {
 
  431    return coord * m_pattern * (level_to - level_from);
 
  434    return coord / (m_pattern * (level_from - level_to));
 
 
  465  if (level_from == level_to) {
 
  468  else if (level_from < level_to) {
 
  470    if (coord % 2 == 0) {
 
  474      return ((coord - 1) * 
pattern) + 1;
 
  479    if (coord % 2 == 0) {
 
  480      if (coord % (
pattern * 2) == 0) {
 
 
  511  uid -= first_cell_uid;
 
  513  const Int64 to2d = uid % (nb_cell_x * nb_cell_y);
 
  514  return to2d % nb_cell_x;
 
 
  521cellUniqueIdToCoordX(
Cell cell)
 
 
  536  uid -= first_cell_uid;
 
  538  const Int64 to2d = uid % (nb_cell_x * nb_cell_y);
 
  539  return to2d / nb_cell_x;
 
 
  546cellUniqueIdToCoordY(
Cell cell)
 
 
  561  uid -= first_cell_uid;
 
  563  return uid / (nb_cell_x * nb_cell_y);
 
 
  570cellUniqueIdToCoordZ(
Cell cell)
 
 
  585  uid -= first_node_uid;
 
  587  const Int64 to2d = uid % (nb_node_x * nb_node_y);
 
  588  return to2d % nb_node_x;
 
 
  595nodeUniqueIdToCoordX(
Node node)
 
 
  611  uid -= first_node_uid;
 
  613  const Int64 to2d = uid % (nb_node_x * nb_node_y);
 
  614  return to2d / nb_node_x;
 
 
  621nodeUniqueIdToCoordY(
Node node)
 
 
  637  uid -= first_node_uid;
 
  639  return uid / (nb_node_x * nb_node_y);
 
 
  646nodeUniqueIdToCoordZ(
Node node)
 
 
  658  if (m_dimension == 2) {
 
  663    uid -= first_face_uid;
 
  686    return uid % nb_face_x;
 
  695    uid -= first_face_uid;
 
  697    Int64x3 three_parts_numbering = face3DNumberingThreeParts(level);
 
  722    if (uid < three_parts_numbering.x) {
 
  731      return (uid % nb_cell_x) * 2 + 1;
 
  737    else if (uid < three_parts_numbering.x + three_parts_numbering.y) {
 
  738      uid -= three_parts_numbering.x;
 
  748      return (uid % nb_face_x) * 2;
 
  755      uid -= three_parts_numbering.x + three_parts_numbering.y;
 
  765      return (uid % nb_cell_x) * 2 + 1;
 
 
  774faceUniqueIdToCoordX(
Face face)
 
 
  786  if (m_dimension == 2) {
 
  790    uid -= first_face_uid;
 
  813    const Int64 flat_pos = uid / nb_face_x;
 
  814    return (flat_pos * 2) + (flat_pos % 2 == uid % 2 ? 0 : 1) - 1; 
 
  825    uid -= first_face_uid;
 
  827    Int64x3 three_parts_numbering = face3DNumberingThreeParts(level);
 
  852    if (uid < three_parts_numbering.x) {
 
  853      uid %= nb_cell_x * nb_cell_y;
 
  864      return (uid / nb_cell_x) * 2 + 1;
 
  870    else if (uid < three_parts_numbering.x + three_parts_numbering.y) {
 
  871      uid -= three_parts_numbering.x;
 
  872      uid %= nb_face_x * nb_cell_y;
 
  883      return (uid / nb_face_x) * 2 + 1;
 
  890      uid -= three_parts_numbering.x + three_parts_numbering.y;
 
  891      uid %= nb_cell_x * nb_face_y;
 
  902      return (uid / nb_cell_x) * 2;
 
 
  911faceUniqueIdToCoordY(
Face face)
 
 
  931  uid -= first_face_uid;
 
  933  Int64x3 three_parts_numbering = face3DNumberingThreeParts(level);
 
  958  if (uid < three_parts_numbering.x) {
 
  969    return (uid / (nb_cell_x * nb_cell_y)) * 2;
 
  975  else if (uid < three_parts_numbering.x + three_parts_numbering.y) {
 
  976    uid -= three_parts_numbering.x;
 
  987    return (uid / (nb_face_x * nb_cell_y)) * 2 + 1;
 
  994    uid -= three_parts_numbering.x + three_parts_numbering.y;
 
 1005    return (uid / (nb_cell_x * nb_face_y)) * 2 + 1;
 
 
 1013faceUniqueIdToCoordZ(
Face face)
 
 
 1023cellUniqueId(
Integer level, Int64x3 cell_coord)
 
 1029  return (cell_coord.x + cell_coord.y * nb_cell_x + cell_coord.z * nb_cell_x * nb_cell_y) + first_cell_uid;
 
 
 1036cellUniqueId(
Integer level, Int64x2 cell_coord)
 
 1041  return (cell_coord.x + cell_coord.y * nb_cell_x) + first_cell_uid;
 
 
 1048nodeUniqueId(
Integer level, Int64x3 node_coord)
 
 1054  return (node_coord.x + node_coord.y * nb_node_x + node_coord.z * nb_node_x * nb_node_y) + first_node_uid;
 
 
 1061nodeUniqueId(
Integer level, Int64x2 node_coord)
 
 1066  return (node_coord.x + node_coord.y * nb_node_x) + first_node_uid;
 
 
 1073faceUniqueId(
Integer level, Int64x3 face_coord)
 
 1080  Int64x3 three_parts_numbering = face3DNumberingThreeParts(level);
 
 1108  if (face_coord.z % 2 == 0) {
 
 1117    uid += face_coord.x + (face_coord.y * nb_cell_x) + (face_coord.z * nb_cell_x * nb_cell_y);
 
 1121  else if (face_coord.x % 2 == 0) {
 
 1122    uid += three_parts_numbering.x;
 
 1132    uid += face_coord.x + (face_coord.y * nb_face_x) + (face_coord.z * nb_face_x * nb_cell_y);
 
 1136  else if (face_coord.y % 2 == 0) {
 
 1137    uid += three_parts_numbering.x + three_parts_numbering.y;
 
 1147    uid += face_coord.x + (face_coord.y * nb_cell_x) + (face_coord.z * nb_cell_x * nb_face_y);
 
 1150    ARCANE_FATAL(
"Bizarre -- x : {0} -- y : {1} -- z : {2}", face_coord.x, face_coord.y, face_coord.z);
 
 
 1160faceUniqueId(
Integer level, Int64x2 face_coord)
 
 1187  const Int64 a = (face_coord.y / 2) * nb_face_x;
 
 1189  return (face_coord.x + a - 1) + first_face_uid; 
 
 
 1198  return static_cast<Integer>(std::pow(m_pattern, m_mesh->dimension()));
 
 
 1204void CartesianMeshNumberingMng::
 
 1214  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;
 
 1215  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;
 
 1216  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;
 
 1217  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;
 
 1219  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;
 
 1220  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;
 
 1221  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;
 
 1222  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;
 
 
 1228void CartesianMeshNumberingMng::
 
 1237  uid[0] = (cell_coord.x + 0) + ((cell_coord.y + 0) * nb_node_x) + first_node_uid;
 
 1238  uid[1] = (cell_coord.x + 1) + ((cell_coord.y + 0) * nb_node_x) + first_node_uid;
 
 1239  uid[2] = (cell_coord.x + 1) + ((cell_coord.y + 1) * nb_node_x) + first_node_uid;
 
 1240  uid[3] = (cell_coord.x + 0) + ((cell_coord.y + 1) * nb_node_x) + first_node_uid;
 
 
 1246void CartesianMeshNumberingMng::
 
 1249  if (m_dimension == 2) {
 
 
 1265  return m_pattern * m_dimension;
 
 
 1271void CartesianMeshNumberingMng::
 
 1278  const Int64x3 nb_face(nb_cell + 1);
 
 1323  const Int64 total_face_xy = nb_face.z * nb_cell.x * nb_cell.y;
 
 1324  const Int64 total_face_xy_yz = total_face_xy + nb_face.x * nb_cell.y * nb_cell.z;
 
 1326  const Int64 nb_cell_before_j = cell_coord.y * nb_cell.x;
 
 1328  uid[0] = (cell_coord.z * nb_cell.x * nb_cell.y) + nb_cell_before_j + (cell_coord.x);
 
 1330  uid[3] = uid[0] + nb_cell.x * nb_cell.y;
 
 1332  uid[1] = (cell_coord.z * nb_face.x * nb_cell.y) + (cell_coord.y * nb_face.x) + (cell_coord.x) + total_face_xy;
 
 1334  uid[4] = uid[1] + 1;
 
 1336  uid[2] = (cell_coord.z * nb_cell.x * nb_face.y) + nb_cell_before_j + (cell_coord.x) + total_face_xy_yz;
 
 1338  uid[5] = uid[2] + nb_cell.x;
 
 1340  uid[0] += first_face_uid;
 
 1341  uid[1] += first_face_uid;
 
 1342  uid[2] += first_face_uid;
 
 1343  uid[3] += first_face_uid;
 
 1344  uid[4] += first_face_uid;
 
 1345  uid[5] += first_face_uid;
 
 
 1351void CartesianMeshNumberingMng::
 
 1358  const Int64 nb_face_x = nb_cell_x + 1;
 
 1379  uid[0] = cell_coord.x * 2 + cell_coord.y * (nb_face_x + nb_cell_x);
 
 1383  uid[2] = uid[0] + (nb_face_x + nb_cell_x);
 
 1386  uid[3] = uid[2] - 1;
 
 1389  uid[1] = uid[2] + 1;
 
 1391  uid[0] += first_face_uid;
 
 1392  uid[1] += first_face_uid;
 
 1393  uid[2] += first_face_uid;
 
 1394  uid[3] += first_face_uid;
 
 
 1400void CartesianMeshNumberingMng::
 
 1403  if (m_dimension == 2) {
 
 
 1416void CartesianMeshNumberingMng::
 
 
 1425void CartesianMeshNumberingMng::
 
 1436  if (m_dimension == 2) {
 
 1437    ARCANE_ASSERT((uid.
size() == 9), (
"Size of uid array != 9"));
 
 1439    for (
Integer j = -1; j < 2; ++j) {
 
 1440      const Int64 coord_around_cell_y = coord_cell_y + j;
 
 1441      if (coord_around_cell_y >= 0 && coord_around_cell_y < nb_cells_y) {
 
 1443        for (
Integer i = -1; i < 2; ++i) {
 
 1444          const Int64 coord_around_cell_x = coord_cell_x + i;
 
 1445          if (coord_around_cell_x >= 0 && coord_around_cell_x < nb_cells_x) {
 
 1446            uid[(i + 1) + ((j + 1) * 3)] = 
cellUniqueId(level, Int64x2(coord_around_cell_x, coord_around_cell_y));
 
 1454    ARCANE_ASSERT((uid.
size() == 27), (
"Size of uid array != 27"));
 
 1459    for (
Integer k = -1; k < 2; ++k) {
 
 1460      const Int64 coord_around_cell_z = coord_cell_z + k;
 
 1461      if (coord_around_cell_z >= 0 && coord_around_cell_z < nb_cells_z) {
 
 1463        for (
Integer j = -1; j < 2; ++j) {
 
 1464          const Int64 coord_around_cell_y = coord_cell_y + j;
 
 1465          if (coord_around_cell_y >= 0 && coord_around_cell_y < nb_cells_y) {
 
 1467            for (
Integer i = -1; i < 2; ++i) {
 
 1468              const Int64 coord_around_cell_x = coord_cell_x + i;
 
 1469              if (coord_around_cell_x >= 0 && coord_around_cell_x < nb_cells_x) {
 
 1470                uid[(i + 1) + ((j + 1) * 3) + ((k + 1) * 9)] = 
cellUniqueId(level, Int64x3(coord_around_cell_x, coord_around_cell_y, coord_around_cell_z));
 
 
 1483void CartesianMeshNumberingMng::
 
 1484setChildNodeCoordinates(
Cell parent_cell)
 
 1492  const Real3& node0(nodes_coords[parent_cell.
node(0)]);
 
 1493  const Real3& node1(nodes_coords[parent_cell.
node(1)]);
 
 1494  const Real3& node2(nodes_coords[parent_cell.
node(2)]);
 
 1495  const Real3& node3(nodes_coords[parent_cell.
node(3)]);
 
 1497  if (m_dimension == 2) {
 
 1532      const Real i = (node3.
x - node0.
x) * y + node0.
x;
 
 1533      const Real j = (node2.
x - node1.
x) * y + node1.
x;
 
 1535      const Real k = (node1.
y - node0.
y) * x + node0.
y;
 
 1536      const Real l = (node2.
y - node3.
y) * x + node3.
y;
 
 1538      const Real tx = (j - i) * x + i;
 
 1539      const Real ty = (l - k) * y + k;
 
 1556      return { tx, ty, 0 };
 
 1559    const Integer node_1d_2d_x[] = { 0, 1, 1, 0 };
 
 1560    const Integer node_1d_2d_y[] = { 0, 0, 1, 1 };
 
 1562    for (
Integer j = 0; j < m_pattern; ++j) {
 
 1563      for (
Integer i = 0; i < m_pattern; ++i) {
 
 1565        Integer begin = (i == 0 && j == 0 ? 0 : j == 0 ? 1
 
 1570        for (
Integer inode = begin; inode < end; ++inode) {
 
 1571          nodes_coords[child.
node(inode)] = txty(i + node_1d_2d_x[inode], j + node_1d_2d_y[inode]);
 
 1584    const Real3& node4(nodes_coords[parent_cell.
node(4)]);
 
 1585    const Real3& node5(nodes_coords[parent_cell.
node(5)]);
 
 1586    const Real3& node6(nodes_coords[parent_cell.
node(6)]);
 
 1587    const Real3& node7(nodes_coords[parent_cell.
node(7)]);
 
 1599      const Real3 m = (node4 - node0) * z + node0;
 
 1600      const Real3 n = (node5 - node1) * z + node1;
 
 1601      const Real3 o = (node6 - node2) * z + node2;
 
 1602      const Real3 p = (node7 - node3) * z + node3;
 
 1605      const Real i = (p.
x - m.
x) * y + m.
x;
 
 1606      const Real j = (o.
x - n.
x) * y + n.
x;
 
 1608      const Real tx = (j - i) * x + i;
 
 1610      const Real k = (n.
y - m.
y) * x + m.
y;
 
 1611      const Real l = (o.
y - p.
y) * x + p.
y;
 
 1613      const Real ty = (l - k) * y + k;
 
 1615      const Real q = (p.
z - m.
z) * y + m.
z;
 
 1616      const Real r = (o.
z - n.
z) * y + n.
z;
 
 1618      const Real s = (n.
z - m.
z) * x + m.
z;
 
 1619      const Real t = (o.
z - p.
z) * x + p.
z;
 
 1621      const Real tz = (((r - q) * x + q) + ((t - s) * y + s)) * 0.5;
 
 1651      return { tx, ty, tz };
 
 1654    const Integer node_1d_3d_x[] = { 0, 1, 1, 0, 0, 1, 1, 0 };
 
 1655    const Integer node_1d_3d_y[] = { 0, 0, 1, 1, 0, 0, 1, 1 };
 
 1656    const Integer node_1d_3d_z[] = { 0, 0, 0, 0, 1, 1, 1, 1 };
 
 1658    for (
Integer k = 0; k < m_pattern; ++k) {
 
 1659      for (
Integer j = 0; j < m_pattern; ++j) {
 
 1660        for (
Integer i = 0; i < m_pattern; ++i) {
 
 1667          for (
Integer inode = begin; inode < end; ++inode) {
 
 1668            nodes_coords[child.
node(inode)] = txtytz(i + node_1d_3d_x[inode], j + node_1d_3d_y[inode], k + node_1d_3d_z[inode]);
 
 
 1686void CartesianMeshNumberingMng::
 
 1687setParentNodeCoordinates(
Cell parent_cell)
 
 1695  if (m_dimension == 2) {
 
 1696    nodes_coords[parent_cell.
node(0)] = nodes_coords[
childCellOfCell(parent_cell, Int64x2(0, 0)).node(0)];
 
 1697    nodes_coords[parent_cell.
node(1)] = nodes_coords[
childCellOfCell(parent_cell, Int64x2(m_pattern - 1, 0)).node(1)];
 
 1698    nodes_coords[parent_cell.
node(2)] = nodes_coords[
childCellOfCell(parent_cell, Int64x2(m_pattern - 1, m_pattern - 1)).node(2)];
 
 1699    nodes_coords[parent_cell.
node(3)] = nodes_coords[
childCellOfCell(parent_cell, Int64x2(0, m_pattern - 1)).node(3)];
 
 1703    nodes_coords[parent_cell.
node(0)] = nodes_coords[
childCellOfCell(parent_cell, Int64x3(0, 0, 0)).node(0)];
 
 1704    nodes_coords[parent_cell.
node(1)] = nodes_coords[
childCellOfCell(parent_cell, Int64x3(m_pattern - 1, 0, 0)).node(1)];
 
 1705    nodes_coords[parent_cell.
node(2)] = nodes_coords[
childCellOfCell(parent_cell, Int64x3(m_pattern - 1, m_pattern - 1, 0)).node(2)];
 
 1706    nodes_coords[parent_cell.
node(3)] = nodes_coords[
childCellOfCell(parent_cell, Int64x3(0, m_pattern - 1, 0)).node(3)];
 
 1708    nodes_coords[parent_cell.
node(4)] = nodes_coords[
childCellOfCell(parent_cell, Int64x3(0, 0, m_pattern - 1)).node(4)];
 
 1709    nodes_coords[parent_cell.
node(5)] = nodes_coords[
childCellOfCell(parent_cell, Int64x3(m_pattern - 1, 0, m_pattern - 1)).node(5)];
 
 1710    nodes_coords[parent_cell.
node(6)] = nodes_coords[
childCellOfCell(parent_cell, Int64x3(m_pattern - 1, m_pattern - 1, m_pattern - 1)).node(6)];
 
 1711    nodes_coords[parent_cell.
node(7)] = nodes_coords[
childCellOfCell(parent_cell, Int64x3(0, m_pattern - 1, m_pattern - 1)).node(7)];
 
 
 1719parentCellUniqueIdOfCell(
Int64 uid, 
Integer level, 
bool do_fatal)
 
 1730    return NULL_ITEM_UNIQUE_ID;
 
 1733  if (m_dimension == 2) {
 
 
 1750parentCellUniqueIdOfCell(
Cell cell, 
bool do_fatal)
 
 
 1759childCellUniqueIdOfCell(
Cell cell, Int64x3 child_coord_in_parent)
 
 1761  ARCANE_ASSERT((child_coord_in_parent.x < m_pattern && child_coord_in_parent.x >= 0), (
"Bad child_coord_in_parent.x"))
 
 1762  ARCANE_ASSERT((child_coord_in_parent.y < m_pattern && child_coord_in_parent.y >= 0), (
"Bad child_coord_in_parent.y"))
 
 1763  ARCANE_ASSERT((child_coord_in_parent.z < m_pattern && child_coord_in_parent.z >= 0), (
"Bad child_coord_in_parent.z"))
 
 
 1778childCellUniqueIdOfCell(
Cell cell, Int64x2 child_coord_in_parent)
 
 1780  ARCANE_ASSERT((child_coord_in_parent.x < m_pattern && child_coord_in_parent.x >= 0), (
"Bad child_coord_in_parent.x"))
 
 1781  ARCANE_ASSERT((child_coord_in_parent.y < m_pattern && child_coord_in_parent.y >= 0), (
"Bad child_coord_in_parent.y"))
 
 
 1795childCellUniqueIdOfCell(
Cell cell, 
Int64 child_index_in_parent)
 
 1797  if (m_dimension == 2) {
 
 1798    ARCANE_ASSERT((child_index_in_parent < m_pattern * m_pattern && child_index_in_parent >= 0), (
"Bad child_index_in_parent"))
 
 1802                                   child_index_in_parent % m_pattern,
 
 1803                                   child_index_in_parent / m_pattern));
 
 1807    ARCANE_ASSERT((child_index_in_parent < m_pattern * m_pattern * m_pattern && child_index_in_parent >= 0), (
"Bad child_index_in_parent"))
 
 1809    const Int64 to_2d = child_index_in_parent % (m_pattern * m_pattern);
 
 1814                                   child_index_in_parent / (m_pattern * m_pattern)));
 
 
 1822childCellOfCell(
Cell cell, Int64x3 child_coord_in_parent)
 
 1824  ARCANE_ASSERT((child_coord_in_parent.x < m_pattern && child_coord_in_parent.x >= 0), (
"Bad child_coord_in_parent.x"))
 
 1825  ARCANE_ASSERT((child_coord_in_parent.y < m_pattern && child_coord_in_parent.y >= 0), (
"Bad child_coord_in_parent.y"))
 
 1827  Cell child = cell.
hChild((
Int32)child_coord_in_parent.x + ((
Int32)child_coord_in_parent.y * m_pattern) + ((
Int32)child_coord_in_parent.z * m_pattern * m_pattern));
 
 1834    for (
Integer i = 0; i < nb_children; ++i) {
 
 
 1848childCellOfCell(
Cell cell, Int64x2 child_coord_in_parent)
 
 1850  ARCANE_ASSERT((child_coord_in_parent.x < m_pattern && child_coord_in_parent.x >= 0), (
"Bad child_coord_in_parent.x"))
 
 1851  ARCANE_ASSERT((child_coord_in_parent.y < m_pattern && child_coord_in_parent.y >= 0), (
"Bad child_coord_in_parent.y"))
 
 1853  Cell child = cell.
hChild((
Int32)child_coord_in_parent.x + ((
Int32)child_coord_in_parent.y * m_pattern));
 
 1860    for (
Integer i = 0; i < nb_children; ++i) {
 
 
 1874parentNodeUniqueIdOfNode(
Int64 uid, 
Integer level, 
bool do_fatal)
 
 1883  if (coord_x % m_pattern != 0 || coord_y % m_pattern != 0) {
 
 1887    return NULL_ITEM_UNIQUE_ID;
 
 1890  if (m_dimension == 2) {
 
 1898    if (coord_z % m_pattern != 0) {
 
 1902      return NULL_ITEM_UNIQUE_ID;
 
 
 1915parentNodeUniqueIdOfNode(
Node node, 
bool do_fatal)
 
 
 1927  if (m_dimension == 2) {
 
 
 1945childNodeUniqueIdOfNode(
Node node)
 
 
 1955parentFaceUniqueIdOfFace(
Int64 uid, 
Integer level, 
bool do_fatal)
 
 1957  if (m_converting_numbering_face && level == m_ori_level) {
 
 1958    uid = m_face_ori_numbering_to_new[uid];
 
 1975  if (parent_coord_x == -1 || parent_coord_y == -1) {
 
 1979    return NULL_ITEM_UNIQUE_ID;
 
 1985  if (m_dimension == 2) {
 
 1986    if (m_converting_numbering_face && level - 1 == m_ori_level) {
 
 1987      return m_face_new_numbering_to_ori[
faceUniqueId(level - 1, Int64x2(parent_coord_x, parent_coord_y))];
 
 1989    return faceUniqueId(level - 1, Int64x2(parent_coord_x, parent_coord_y));
 
 1997    if (parent_coord_z == -1) {
 
 2001      return NULL_ITEM_UNIQUE_ID;
 
 2008    if (m_converting_numbering_face && level - 1 == m_ori_level) {
 
 2009      return m_face_new_numbering_to_ori[
faceUniqueId(level - 1, Int64x3(parent_coord_x, parent_coord_y, parent_coord_z))];
 
 2012    return faceUniqueId(level - 1, Int64x3(parent_coord_x, parent_coord_y, parent_coord_z));
 
 
 2020parentFaceUniqueIdOfFace(
Face face, 
bool do_fatal)
 
 
 2032  if (m_converting_numbering_face && level == m_ori_level) {
 
 2033    uid = m_face_ori_numbering_to_new[uid];
 
 2045  ARCANE_ASSERT((first_child_coord_x < 
globalNbFacesXCartesianView(level + 1) && first_child_coord_x >= 0), (
"Bad first_child_coord_x"))
 
 2046  ARCANE_ASSERT((first_child_coord_y < 
globalNbFacesYCartesianView(level + 1) && first_child_coord_y >= 0), (
"Bad first_child_coord_y"))
 
 2048  if (m_dimension == 2) {
 
 2049    ARCANE_ASSERT((child_index_in_parent < m_pattern && child_index_in_parent >= 0), (
"Invalid child_index_in_parent"))
 
 2051    if (coord_y % 2 == 0) {
 
 2052      first_child_coord_x += child_index_in_parent * 2;
 
 2054    else if (coord_x % 2 == 0) {
 
 2055      first_child_coord_y += child_index_in_parent * 
globalNbFacesY(level + 1);
 
 2061    if (m_converting_numbering_face && level + 1 == m_ori_level) {
 
 2062      return m_face_new_numbering_to_ori[
faceUniqueId(level + 1, Int64x2(first_child_coord_x, first_child_coord_y))];
 
 2065    return faceUniqueId(level + 1, Int64x2(first_child_coord_x, first_child_coord_y));
 
 2069    ARCANE_ASSERT((child_index_in_parent < m_pattern * m_pattern && child_index_in_parent >= 0), (
"Invalid child_index_in_parent"))
 
 2075    ARCANE_ASSERT((first_child_coord_z < 
globalNbFacesZCartesianView(level + 1) && first_child_coord_z >= 0), (
"Bad first_child_coord_z"))
 
 2077    Int64 child_x = child_index_in_parent % m_pattern;
 
 2078    Int64 child_y = child_index_in_parent / m_pattern;
 
 2080    Int64x3 three_parts_numbering = face3DNumberingThreeParts(level);
 
 2082    if (uid < three_parts_numbering.x) {
 
 2083      first_child_coord_x += child_x * 2;
 
 2084      first_child_coord_y += child_y * 2;
 
 2086    else if (uid < three_parts_numbering.x + three_parts_numbering.y) {
 
 2087      first_child_coord_y += child_x * 2;
 
 2088      first_child_coord_z += child_y * 2;
 
 2091      first_child_coord_x += child_x * 2;
 
 2092      first_child_coord_z += child_y * 2;
 
 2095    if (m_converting_numbering_face && level + 1 == m_ori_level) {
 
 2096      return m_face_new_numbering_to_ori[
faceUniqueId(level + 1, Int64x3(first_child_coord_x, first_child_coord_y, first_child_coord_z))];
 
 2099    return faceUniqueId(level + 1, Int64x3(first_child_coord_x, first_child_coord_y, first_child_coord_z));
 
 
 2107childFaceUniqueIdOfFace(
Face face, 
Int64 child_index_in_parent)
 
 
 2116Int64x3 CartesianMeshNumberingMng::
 
 2117face3DNumberingThreeParts(
Integer level)
 const 
 2119  const Int64x3 nb_cell(globalNbCellsX(level), globalNbCellsY(level), globalNbCellsZ(level));
 
 2120  return { (nb_cell.z + 1) * nb_cell.x * nb_cell.y, (nb_cell.x + 1) * nb_cell.y * nb_cell.z, (nb_cell.y + 1) * nb_cell.z * nb_cell.x };
 
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Vue modifiable d'un tableau d'un type T.
void fill(const T &o) noexcept
Remplit le tableau avec la valeur o.
constexpr Integer size() const noexcept
Retourne la taille du tableau.
Int64 parentCellUniqueIdOfCell(Int64 uid, Integer level, bool do_fatal) override
Méthode permettant de récupérer l'uniqueId du parent d'une maille.
Int32 nodeLevel(Int64 uid) const override
Méthode permettant de récupérer le niveau d'un noeud avec son uid.
Int64 parentNodeUniqueIdOfNode(Int64 uid, Integer level, bool do_fatal) override
Méthode permettant de récupérer l'uniqueId du parent d'un noeud.
Int64 globalNbNodesX(Integer level) const override
Méthode permettant de récupérer le nombre de noeuds global en X d'un niveau.
Int64 nbFaceInLevel(Integer level) const override
Méthode permettant de récupérer le nombre de faces total dans un niveau.
Int64 faceUniqueId(Integer level, Int64x3 face_coord) override
Méthode permettant de récupérer l'uniqueId d'une face à partir de sa position et de son niveau.
Int64 faceUniqueIdToCoordY(Int64 uid, Integer level) override
Méthode permettant de récupérer la coordonnée en Y d'une face grâce à son uniqueId.
void cellFaceUniqueIds(ArrayView< Int64 > uid, Integer level, Int64x3 cell_coord) override
Méthode permettant de récupérer les uniqueIds des faces d'une maille à partir de ses coordonnées.
Int64 cellUniqueIdToCoordY(Int64 uid, Integer level) override
Méthode permettant de récupérer la coordonnée en Y d'une maille grâce à son uniqueId.
Int64 firstFaceUniqueId(Integer level) override
Méthode permettant de récupérer le premier unique id utilisé par les faces d'un niveau....
Int64 nbNodeInLevel(Integer level) const override
Méthode permettant de récupérer le nombre de noeuds total dans un niveau.
Integer nbNodeByCell() override
Méthode permettant de récupérer le nombre de noeuds dans une maille.
Int64 nodeUniqueId(Integer level, Int64x3 node_coord) override
Méthode permettant de récupérer l'uniqueId d'un noeud à partir de sa position et de son niveau.
Int64 globalNbCellsX(Integer level) const override
Méthode permettant de récupérer le nombre de mailles global en X d'un niveau.
void cellUniqueIdsAroundCell(ArrayView< Int64 > uid, Int64 cell_uid, Int32 level) override
Méthode permettant de récupérer les uniqueIds des mailles autour de la maille passée en paramètre.
Integer pattern() const override
Méthode permettant de récupérer le pattern de raffinement utilisé dans chaque maille....
Int64 faceUniqueIdToCoordX(Int64 uid, Integer level) override
Méthode permettant de récupérer la coordonnée en X d'une face grâce à son uniqueId.
Int64 nodeUniqueIdToCoordX(Int64 uid, Integer level) override
Méthode permettant de récupérer la coordonnée en X d'un noeud grâce à son uniqueId.
Int64 globalNbFacesX(Integer level) const override
Méthode permettant de récupérer le nombre de faces global en X d'un niveau.
Int64 faceOffsetLevelToLevel(Int64 coord, Integer level_from, Integer level_to) const override
Méthode permettant d'obtenir la position de la première face enfant à partir de la position de la fac...
Int64 globalNbNodesY(Integer level) const override
Méthode permettant de récupérer le nombre de noeuds global en Y d'un niveau.
Int64 cellUniqueIdToCoordX(Int64 uid, Integer level) override
Méthode permettant de récupérer la coordonnée en X d'une maille grâce à son uniqueId.
Int64 nodeUniqueIdToCoordZ(Int64 uid, Integer level) override
Méthode permettant de récupérer la coordonnée en Z d'un noeud grâce à son uniqueId.
Int64 cellUniqueId(Integer level, Int64x3 cell_coord) override
Méthode permettant de récupérer l'uniqueId d'une maille à partir de sa position et de son niveau.
Int64 offsetLevelToLevel(Int64 coord, Integer level_from, Integer level_to) const override
Méthode permettant d'obtenir la position du premier noeud/maille fille à partir de la position du noe...
Integer nbFaceByCell() override
Méthode permettant de récupérer le nombre de faces dans une maille.
Int64 globalNbCellsZ(Integer level) const override
Méthode permettant de récupérer le nombre de mailles global en Z d'un niveau.
Int64 childNodeUniqueIdOfNode(Int64 uid, Integer level) override
Méthode permettant de récupérer l'uniqueId d'un noeud enfant d'un noeud parent.
Int64 cellUniqueIdToCoordZ(Int64 uid, Integer level) override
Méthode permettant de récupérer la coordonnée en Z d'une maille grâce à son uniqueId.
Int64 nodeUniqueIdToCoordY(Int64 uid, Integer level) override
Méthode permettant de récupérer la coordonnée en Y d'un noeud grâce à son uniqueId.
void cellNodeUniqueIds(ArrayView< Int64 > uid, Integer level, Int64x3 cell_coord) override
Méthode permettant de récupérer les uniqueIds des noeuds d'une maille à partir de ses coordonnées.
Int64 firstNodeUniqueId(Integer level) override
Méthode permettant de récupérer le premier unique id utilisé par les noeuds d'un niveau....
Cell childCellOfCell(Cell cell, Int64x3 child_coord_in_parent) override
Méthode permettant de récupérer une maille enfant d'une maille parent à partir de la position de la m...
Int64 childCellUniqueIdOfCell(Cell cell, Int64x3 child_coord_in_parent) override
Méthode permettant de récupérer l'uniqueId d'une maille enfant d'une maille parent à partir de la pos...
Int64 nbCellInLevel(Integer level) const override
Méthode permettant de récupérer le nombre de mailles total dans un niveau.
Int64 globalNbFacesY(Integer level) const override
Méthode permettant de récupérer le nombre de faces global en Y d'un niveau.
Int64 childFaceUniqueIdOfFace(Int64 uid, Integer level, Int64 child_index_in_parent) override
Méthode permettant de récupérer l'uniqueId d'une face enfant d'une face parent à partir de l'index de...
Int64 faceUniqueIdToCoordZ(Int64 uid, Integer level) override
Méthode permettant de récupérer la coordonnée en Z d'une face grâce à son uniqueId.
Int32 faceLevel(Int64 uid) const override
Méthode permettant de récupérer le niveau d'une face avec son uid.
Int64 globalNbCellsY(Integer level) const override
Méthode permettant de récupérer le nombre de mailles global en Y d'un niveau.
Int64 parentFaceUniqueIdOfFace(Int64 uid, Integer level, bool do_fatal) override
Méthode permettant de récupérer l'uniqueId du parent d'une face.
Int64 globalNbFacesYCartesianView(Integer level) const override
Méthode permettant de récupérer la taille de la vue "grille cartésienne" contenant les noeuds.
Int64 globalNbFacesXCartesianView(Integer level) const override
Méthode permettant de récupérer la taille de la vue "grille cartésienne" contenant les noeuds.
Int64 firstCellUniqueId(Integer level) override
Méthode permettant de récupérer le premier unique id utilisé par les mailles d'un niveau....
Int64 globalNbFacesZCartesianView(Integer level) const override
Méthode permettant de récupérer la taille de la vue "grille cartésienne" contenant les noeuds.
Int32 nbHChildren() const
Nombre d'enfants pour l'AMR.
Cell hChild(Int32 i) const
i-ème enfant AMR
Vue constante d'un tableau de type T.
Int32 flags() const
Flags de l'entité
@ II_JustAdded
L'entité vient d'être ajoutée.
@ II_JustRefined
L'entité vient d'être raffinée.
Node node(Int32 i) const
i-ème noeud de l'entité
ItemUniqueId uniqueId() const
Identifiant unique sur tous les domaines.
impl::ItemBase itemBase() const
Partie interne de l'entité.
Classe gérant un vecteur de réel de dimension 3.
Classe d'accès aux traces.
MeshVariableScalarRefT< Node, Real3 > VariableNodeReal3
Grandeur au noeud de type coordonnées.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
std::int64_t Int64
Type entier signé sur 64 bits.
Int32 Integer
Type représentant un entier.
ConstArrayView< Int64 > Int64ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 64 bits.
double Real
Type représentant un réel.
std::int32_t Int32
Type entier signé sur 32 bits.
Real y
deuxième composante du triplet
Real z
troisième composante du triplet
Real x
première composante du triplet