14#include "arcane/cartesianmesh/AMRPatchPosition.h"
17#include "arcane/utils/FatalErrorException.h"
18#include "arcane/utils/Math.h"
34, m_overlap_layer_size(0)
43, m_min_point(min_point)
44, m_max_point(max_point)
45, m_overlap_layer_size(overlap_layer_size)
64~AMRPatchPosition() =
default;
99 m_min_point = min_point;
117 m_max_point = max_point;
126 return m_overlap_layer_size;
135 m_overlap_layer_size = layer_size;
144 return m_min_point - m_overlap_layer_size;
153 return m_max_point + m_overlap_layer_size;
162 return static_cast<Int64>(m_max_point.x - m_min_point.x) * (m_max_point.y - m_min_point.y) * (m_max_point.z - m_min_point.z);
175 patch_max_cut.x = cut_point;
176 patch_min_cut.x = cut_point;
179 patch_max_cut.y = cut_point;
180 patch_min_cut.y = cut_point;
183 patch_max_cut.z = cut_point;
184 patch_min_cut.z = cut_point;
204 return m_level == other_patch.
level() &&
205 (((m_min_point.x == max_point.x || m_max_point.x == min_point.x) &&
206 (m_min_point.y == min_point.y && m_max_point.y == max_point.y) &&
207 (m_min_point.z == min_point.z && m_max_point.z == max_point.z)) ||
209 ((m_min_point.x == min_point.x && m_max_point.x == max_point.x) &&
210 (m_min_point.y == max_point.y || m_max_point.y == min_point.y) &&
211 (m_min_point.z == min_point.z && m_max_point.z == max_point.z)) ||
213 ((m_min_point.x == min_point.x && m_max_point.x == max_point.x) &&
214 (m_min_point.y == min_point.y && m_max_point.y == max_point.y) &&
215 (m_min_point.z == max_point.z || m_max_point.z == min_point.z)));
231 if (m_min_point.x > min_point.x) {
232 m_min_point.x = min_point.x;
234 else if (m_max_point.x < max_point.x) {
235 m_max_point.x = max_point.x;
238 else if (m_min_point.y > min_point.y) {
239 m_min_point.y = min_point.y;
241 else if (m_max_point.y < max_point.y) {
242 m_max_point.y = max_point.y;
245 else if (m_min_point.z > min_point.z) {
246 m_min_point.z = min_point.z;
248 else if (m_max_point.z < max_point.z) {
249 m_max_point.z = max_point.z;
263 return m_level == -2;
276 p.
setMaxPoint({ m_max_point.x * 2, m_max_point.y * 2, 1 });
310 return m_max_point - m_min_point;
319 return x >= m_min_point.x && x < m_max_point.x && y >= m_min_point.y && y < m_max_point.y && z >= m_min_point.z && z < m_max_point.z;
328 return coord.x >= m_min_point.x && coord.x < m_max_point.x && coord.y >= m_min_point.y && coord.y < m_max_point.y && coord.z >= m_min_point.z && coord.z < m_max_point.z;
339 return x >= min_point.x && x < max_point.x && y >= min_point.y && y < max_point.y && z >= min_point.z && z < max_point.z;
350 return coord.x >= min_point.x && coord.x < max_point.x && coord.y >= min_point.y && coord.y < max_point.y && coord.z >= min_point.z && coord.z < max_point.z;
359 const CartCoord3 min_point = m_min_point - overlap;
360 const CartCoord3 max_point = m_max_point + overlap;
361 return x >= min_point.x && x < max_point.x && y >= min_point.y && y < max_point.y && z >= min_point.z && z < max_point.z;
370 const CartCoord3 min_point = m_min_point - overlap;
371 const CartCoord3 max_point = m_max_point + overlap;
372 return coord.x >= min_point.x && coord.x < max_point.x && coord.y >= min_point.y && coord.y < max_point.y && coord.z >= min_point.z && coord.z < max_point.z;
402 if (overlap_layer_size_top_level == -1) {
409 if (
level == higher_level) {
410 return overlap_layer_size_top_level;
416 Int32 nb_overlap_cells = overlap_layer_size_top_level;
419 if (nb_overlap_cells == 0) {
422 if (nb_overlap_cells == 2) {
426 if (nb_overlap_cells == 4) {
429 nb_overlap_cells = ((nb_overlap_cells / 4) + 1) * 2;
432 return nb_overlap_cells;
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
Declarations of Arcane's general types.
AMRPatchPosition patchUp(Integer dim, Int32 higher_level, Int32 overlap_layer_size_top_level) const
Method to create an AMRPatchPosition for the higher level.
bool isInWithOverlap(CartCoord x, CartCoord y, CartCoord z) const
Method to know if a cell at position x,y,z is included in this patch with overlap layer.
CartCoord3 minPointWithOverlap() const
Method to retrieve the min position of the enclosing box including the overlap cell layer.
AMRPatchPosition patchDown(Integer dim, Int32 higher_level, Int32 overlap_layer_size_top_level) const
Method to create an AMRPatchPosition for the lower level.
bool isIn(CartCoord x, CartCoord y, CartCoord z) const
Method to know if a cell at position x,y,z is included in this patch.
bool canBeFusion(const AMRPatchPosition &other_patch) const
Method to know if our patch can be merged with other_patch.
static Int32 computeOverlapLayerSize(Int32 level, Int32 higher_level, Int32 overlap_layer_size_top_level)
Method to calculate the number of overlap cell layers for a given level.
bool fusion(AMRPatchPosition &other_patch)
Method to merge other_patch with ours.
CartCoord3 minPoint() const
Method to retrieve the min position of the enclosing box.
void setMinPoint(CartCoord3 min_point)
Method to set the min position of the enclosing box.
CartCoord3 length() const
Method to know the size of the patch (in number of cells per direction).
AMRPatchPosition()
Constructor for a null position. A null position is defined by a level = -2.
void setLevel(Int32 level)
Method to set the patch level.
bool isNull() const
Method to know if the patch is null.
CartCoord3 maxPointWithOverlap() const
Method to retrieve the max position of the enclosing box including the overlap cell layer.
CartCoord3 maxPoint() const
Method to retrieve the max position of the enclosing box.
bool haveIntersection(const AMRPatchPosition &other) const
Method to know if our patch is in contact with other.
Int64 nbCells() const
Method to know the number of cells in the patch according to its position.
Int32 overlapLayerSize() const
Method to retrieve the number of overlap cell layers of the patch.
void setOverlapLayerSize(Int32 layer_size)
Method to set the number of overlap cell layers of the patch.
Int32 level() const
Method to retrieve the patch level.
std::pair< AMRPatchPosition, AMRPatchPosition > cut(CartCoord cut_point, Integer dim) const
Method to cut the patch into two patches according to a cut point.
void setMaxPoint(CartCoord3 max_point)
Method to set the max position of the enclosing box.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 CartCoord
Represents a coordinate of an element in the Cartesian grid (in X or Y or Z).
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
std::int32_t Int32
Signed integer type of 32 bits.
Int32x3 CartCoord3
Represents the 3D coordinates of an element in the Cartesian grid {x, y, z}.