12#ifndef ARCANE_CORE_CARTESIANGRIDDIMENSION_H
13#define ARCANE_CORE_CARTESIANGRIDDIMENSION_H
17#include "arcane/utils/Vector3.h"
18#include "arcane/utils/Vector2.h"
48class ARCANE_CORE_EXPORT CartesianGridDimension
53 friend class CartesianMeshUniqueIdRenumbering;
54 friend class CartesianMeshCoarsening;
55 friend class CartesianMeshCoarsening2;
63 class NodeUniqueIdComputer2D
67 NodeUniqueIdComputer2D(
Int64 base_offset,
Int64 nb_node_x)
68 : m_base_offset(base_offset)
69 , m_nb_node_x(nb_node_x)
76 return m_base_offset + x + y * m_nb_node_x;
79 std::array<Int64, 4> computeForCell(
Int64 x,
Int64 y)
81 std::array<Int64, 4> node_uids;
82 node_uids[0] = compute(x + 0, y + 0);
83 node_uids[1] = compute(x + 1, y + 0);
84 node_uids[2] = compute(x + 1, y + 1);
85 node_uids[3] = compute(x + 0, y + 1);
99 class CellUniqueIdComputer2D
103 CellUniqueIdComputer2D(
Int64 base_offset,
Int64 all_nb_cell_x)
104 : m_base_offset(base_offset)
105 , m_all_nb_cell_x(all_nb_cell_x)
112 return m_base_offset + x + y * m_all_nb_cell_x;
114 Int64x3 compute(
Int64 unique_id)
116 Int64 uid = unique_id - m_base_offset;
117 const Int64 y = uid / m_all_nb_cell_x;
118 const Int64 x = uid % m_all_nb_cell_x;
119 return Int64x3(x, y, 0);
125 Int64 m_all_nb_cell_x;
132 class FaceUniqueIdComputer2D
136 FaceUniqueIdComputer2D(
Int64 base_offset,
Int64 nb_cell_x,
Int64 nb_face_x,
Int64 nb_face_dir_x)
137 : m_base_offset(base_offset)
138 , m_nb_cell_x(nb_cell_x)
139 , m_nb_face_x(nb_face_x)
140 , m_nb_face_dir_x(nb_face_dir_x)
148 std::array<Int64, 4> face_uids;
151 face_uids[0] = m_base_offset + (x + 0) + ((y + 0) * m_nb_cell_x) + m_nb_face_dir_x;
152 face_uids[2] = m_base_offset + (x + 0) + ((y + 1) * m_nb_cell_x) + m_nb_face_dir_x;
155 face_uids[1] = m_base_offset + (x + 1) + (y + 0) * m_nb_face_x;
156 face_uids[3] = m_base_offset + (x + 0) + (y + 0) * m_nb_face_x;
166 Int64 m_nb_face_dir_x;
173 class NodeUniqueIdComputer3D
177 NodeUniqueIdComputer3D(
Int64 base_offset,
Int64 nb_node_x,
Int64 nb_node_xy)
178 : m_base_offset(base_offset)
179 , m_nb_node_x(nb_node_x)
180 , m_nb_node_xy(nb_node_xy)
187 return m_base_offset + x + y * m_nb_node_x + z * m_nb_node_xy;
192 std::array<Int64, 8> node_uids;
193 node_uids[0] = compute(x + 0, y + 0, z + 0);
194 node_uids[1] = compute(x + 1, y + 0, z + 0);
195 node_uids[2] = compute(x + 1, y + 1, z + 0);
196 node_uids[3] = compute(x + 0, y + 1, z + 0);
197 node_uids[4] = compute(x + 0, y + 0, z + 1);
198 node_uids[5] = compute(x + 1, y + 0, z + 1);
199 node_uids[6] = compute(x + 1, y + 1, z + 1);
200 node_uids[7] = compute(x + 0, y + 1, z + 1);
215 class CellUniqueIdComputer3D
219 CellUniqueIdComputer3D(
Int64 base_offset,
Int64 all_nb_cell_x,
Int64 all_nb_cell_xy)
220 : m_base_offset(base_offset)
221 , m_all_nb_cell_x(all_nb_cell_x)
222 , m_all_nb_cell_xy(all_nb_cell_xy)
230 return m_base_offset + x + y * m_all_nb_cell_x + z * m_all_nb_cell_xy;
235 Int64 uid = unique_id - m_base_offset;
236 Int64 z = uid / m_all_nb_cell_xy;
237 Int64 v = uid - (z * m_all_nb_cell_xy);
238 Int64 y = v / m_all_nb_cell_x;
239 Int64 x = v % m_all_nb_cell_x;
240 return Int64x3(x, y, z);
246 Int64 m_all_nb_cell_x;
247 Int64 m_all_nb_cell_xy;
254 class FaceUniqueIdComputer3D
258 FaceUniqueIdComputer3D(
Int64 base_offset,
Int64 nb_cell_x,
Int64 nb_face_x, Int64x3 nb_face_dir,
259 Int64 total_nb_face_xy,
Int64 total_nb_face_x)
260 : m_base_offset(base_offset)
261 , m_nb_cell_x(nb_cell_x)
262 , m_nb_face_x(nb_face_x)
263 , m_nb_face_dir(nb_face_dir)
264 , m_total_nb_face_xy(total_nb_face_xy)
265 , m_total_nb_face_x(total_nb_face_x)
273 std::array<Int64, 6> face_uids;
276 face_uids[0] = (x + 0) + ((y + 0) * m_nb_cell_x) + ((z + 0) * m_nb_face_dir.z) + m_total_nb_face_xy;
277 face_uids[3] = (x + 0) + ((y + 0) * m_nb_cell_x) + ((z + 1) * m_nb_face_dir.z) + m_total_nb_face_xy;
280 face_uids[1] = (x + 0) + ((y + 0) * m_nb_face_x) + ((z + 0) * m_nb_face_dir.x);
281 face_uids[4] = (x + 1) + ((y + 0) * m_nb_face_x) + ((z + 0) * m_nb_face_dir.x);
284 face_uids[2] = (x + 0) + ((y + 0) * m_nb_cell_x) + ((z + 0) * m_nb_face_dir.y) + m_total_nb_face_x;
285 face_uids[5] = (x + 0) + ((y + 1) * m_nb_cell_x) + ((z + 0) * m_nb_face_dir.y) + m_total_nb_face_x;
287 for (
Int32 i = 0; i < 6; ++i)
288 face_uids[i] += m_base_offset;
298 Int64x3 m_nb_face_dir;
299 Int64 m_total_nb_face_xy;
300 Int64 m_total_nb_face_x;
368 Int64 total_nb_face_xy = (nb_face_dir.x + nb_face_dir.y) *
m_nb_cell.z;
370 return { offset,
m_nb_cell.x,
m_nb_face.x, nb_face_dir, total_nb_face_xy, total_nb_face_x };
384 Int64 m_nb_cell_xy = 0;
385 Int64 m_total_nb_cell = 0;
Declarations of Arcane's general types.
Class for calculating the uniqueId() of a cell in 2D based on its position in the grid.
Class for calculating the uniqueId() of a cell in 3D based on its position in the grid.
Int64 compute(Int64 x, Int64 y, Int64 z)
Calculates the uniqueId() based on coordinates.
Int64x3 compute(Int64 unique_id)
Calculates the coordinates based on the uniqueId().
Class for calculating the uniqueId() of a face in 2D based on its position in the grid.
std::array< Int64, 4 > computeForCell(Int64 x, Int64 y)
Calculates the uniqueIds() of the 4 faces of the topological coordinate cell (x,y).
Class for calculating the uniqueId() of a face in 2D based on its position in the grid.
std::array< Int64, 6 > computeForCell(Int64 x, Int64 y, Int64 z)
Calculates the uniqueIds() of the 6 faces of the topological coordinate cell (x,y,...
Class for calculating the uniqueId() of a node in 2D based on its position in the grid.
Class for calculating the uniqueId() of a node in 3D based on its position in the grid.
Information about the dimensions of a Cartesian grid.
constexpr Int64x3 nbCell() const
Number of cells in each direction.
Int64x3 m_nb_node
Number of nodes in each direction.
CellUniqueIdComputer2D getCellComputer2D(Int64 offset) const
Instance to calculate the uniqueIds() of cells for this grid.
Int64x3 m_nb_cell
Number of cells in each direction.
constexpr Int64 totalNbCell() const
Total number of cells.
CellUniqueIdComputer3D getCellComputer3D(Int64 offset) const
Instance to calculate the uniqueIds() of cells for this grid.
FaceUniqueIdComputer3D getFaceComputer3D(Int64 offset) const
Instance to calculate the uniqueIds() of faces for this grid.
Int64x3 m_nb_face_oriented
Total number of faces in a given orientation.
NodeUniqueIdComputer3D getNodeComputer3D(Int64 offset) const
Instance to calculate the uniqueIds() of nodes for this grid.
NodeUniqueIdComputer2D getNodeComputer2D(Int64 offset) const
Instance to calculate the uniqueIds() of nodes for this grid.
constexpr Int64x3 nbFace() const
Number of faces in each direction.
Int64x3 m_nb_face
Number of faces in each direction.
constexpr Int64x3 nbFaceParallelToDirection() const
Total number of faces parallel to a given direction.
FaceUniqueIdComputer2D getFaceComputer2D(Int64 offset) const
Instance to calculate the uniqueIds() of faces for this grid.
constexpr Int64x3 nbNode() const
Number of nodes in each direction.
Construction of uniqueId() for faces in a cartesian mesh.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int64_t Int64
Signed integer type of 64 bits.
std::int32_t Int32
Signed integer type of 32 bits.