Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
AMRPatchPosition.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* AMRPatchPosition.h (C) 2000-2026 */
9/* */
10/* Position of an AMR patch in a Cartesian mesh. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CARTESIANMESH_AMRPATCHPOSITION_H
13#define ARCANE_CARTESIANMESH_AMRPATCHPOSITION_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/cartesianmesh/CartesianMeshGlobal.h"
18#include "arcane/utils/Vector3.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
50class ARCANE_CARTESIANMESH_EXPORT AMRPatchPosition
51{
52 public:
53
59 AMRPatchPosition(Int32 level, CartCoord3 min_point, CartCoord3 max_point, Int32 overlap_layer_size);
60
66 AMRPatchPosition& operator=(const AMRPatchPosition&) = default;
67
69
70 public:
71
72 bool operator==(const AMRPatchPosition& other) const = default;
73
74 public:
75
80 Int32 level() const;
81
86 void setLevel(Int32 level);
87
93 CartCoord3 minPoint() const;
94
99 void setMinPoint(CartCoord3 min_point);
100
106 CartCoord3 maxPoint() const;
107
112 void setMaxPoint(CartCoord3 max_point);
113
119 Int32 overlapLayerSize() const;
120
125 void setOverlapLayerSize(Int32 layer_size);
126
132
138
150 Int64 nbCells() const;
151
159 std::pair<AMRPatchPosition, AMRPatchPosition> cut(CartCoord cut_point, Integer dim) const;
160
167 bool canBeFusion(const AMRPatchPosition& other_patch) const;
168
179 bool fusion(AMRPatchPosition& other_patch);
180
188 bool isNull() const;
189
198 AMRPatchPosition patchUp(Integer dim, Int32 higher_level, Int32 overlap_layer_size_top_level) const;
199
215 AMRPatchPosition patchDown(Integer dim, Int32 higher_level, Int32 overlap_layer_size_top_level) const;
216
222 CartCoord3 length() const;
223
235 bool isIn(CartCoord x, CartCoord y, CartCoord z) const;
236
246 bool isIn(CartCoord3 coord) const;
247
257 bool isInWithOverlap(CartCoord x, CartCoord y, CartCoord z) const;
258
266 bool isInWithOverlap(CartCoord3 coord) const;
267
278 bool isInWithOverlap(CartCoord x, CartCoord y, CartCoord z, Integer overlap) const;
279
288 bool isInWithOverlap(CartCoord3 coord, Integer overlap) const;
289
296 bool haveIntersection(const AMRPatchPosition& other) const;
297
306 static Int32 computeOverlapLayerSize(Int32 level, Int32 higher_level, Int32 overlap_layer_size_top_level);
307
314 void computeOverlapLayerSize(Int32 higher_level, Int32 overlap_layer_size_top_level);
315
316 private:
317
318 Int32 m_level;
319 CartCoord3 m_min_point;
320 CartCoord3 m_max_point;
321 Int32 m_overlap_layer_size;
322};
323
324/*---------------------------------------------------------------------------*/
325/*---------------------------------------------------------------------------*/
326
327} // End namespace Arcane
328
329/*---------------------------------------------------------------------------*/
330/*---------------------------------------------------------------------------*/
331
332#endif
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}.