Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
Arcane::AMRPatchPosition Class Reference

Class allowing the definition of a patch position in the Cartesian mesh. More...

#include <arcane/cartesianmesh/AMRPatchPosition.h>

Public Member Functions

 AMRPatchPosition ()
 Constructor for a null position. A null position is defined by a level = -2.
 AMRPatchPosition (Int32 level, CartCoord3 min_point, CartCoord3 max_point, Int32 overlap_layer_size)
 AMRPatchPosition (const AMRPatchPosition &src)
 Copy constructor.
AMRPatchPositionoperator= (const AMRPatchPosition &)=default
bool operator== (const AMRPatchPosition &other) const =default
Int32 level () const
 Method to retrieve the patch level.
void setLevel (Int32 level)
 Method to set the patch level.
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 maxPoint () const
 Method to retrieve the max position of the enclosing box.
void setMaxPoint (CartCoord3 max_point)
 Method to set the max position of the enclosing box.
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.
CartCoord3 minPointWithOverlap () const
 Method to retrieve the min position of the enclosing box including the overlap cell layer.
CartCoord3 maxPointWithOverlap () const
 Method to retrieve the max position of the enclosing box including the overlap cell layer.
Int64 nbCells () const
 Method to know the number of cells in the patch according to its position.
std::pair< AMRPatchPosition, AMRPatchPositioncut (CartCoord cut_point, Integer dim) const
 Method to cut the patch into two patches according to a cut point.
bool canBeFusion (const AMRPatchPosition &other_patch) const
 Method to know if our patch can be merged with other_patch.
bool fusion (AMRPatchPosition &other_patch)
 Method to merge other_patch with ours.
bool isNull () const
 Method to know if the patch is null.
AMRPatchPosition patchUp (Integer dim, Int32 higher_level, Int32 overlap_layer_size_top_level) const
 Method to create an AMRPatchPosition for the higher level.
AMRPatchPosition patchDown (Integer dim, Int32 higher_level, Int32 overlap_layer_size_top_level) const
 Method to create an AMRPatchPosition for the lower level.
CartCoord3 length () const
 Method to know the size of the patch (in number of cells per direction).
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 isIn (CartCoord3 coord) const
 Method to know if a cell is included in this patch.
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.
bool isInWithOverlap (CartCoord3 coord) const
 Method to know if a cell is included in this patch with overlap layer.
bool isInWithOverlap (CartCoord x, CartCoord y, CartCoord z, Integer overlap) const
 Method to know if a cell at position x,y,z is included in this patch with a specified overlap layer.
bool isInWithOverlap (CartCoord3 coord, Integer overlap) const
 Method to know if a cell is included in this patch with a specified overlap layer.
bool haveIntersection (const AMRPatchPosition &other) const
 Method to know if our patch is in contact with other.
void computeOverlapLayerSize (Int32 higher_level, Int32 overlap_layer_size_top_level)
 Method to calculate the number of overlap cell layers for our patch.

Static Public Member Functions

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.

Detailed Description

Class allowing the definition of a patch position in the Cartesian mesh.

The position of a patch is designated by the position of two cells in the grid. The "min" position and the "max" position form an enclosing box.

Warning
The cell at the "min" position is included in the box, but the cell at the "max" position is excluded.
Note
The patch position is global for the Cartesian mesh. The decomposition into subdomains is not taken into account (example with the nbCells() method of this class, which gives the number of cells in the patch without considering subdomains).

Cell positions can be obtained via the CartesianMeshNumberingMng.

Warning
This class is only valid for a refinement pattern of 2 (modifying this should not be complex, if needed).

Definition at line 50 of file AMRPatchPosition.h.

Constructor & Destructor Documentation

◆ AMRPatchPosition() [1/3]

Arcane::AMRPatchPosition::AMRPatchPosition ( )

Constructor for a null position. A null position is defined by a level = -2.

Definition at line 31 of file AMRPatchPosition.cc.

Referenced by AMRPatchPosition(), canBeFusion(), cut(), fusion(), haveIntersection(), patchDown(), and patchUp().

◆ AMRPatchPosition() [2/3]

Arcane::AMRPatchPosition::AMRPatchPosition ( Int32 level,
CartCoord3 min_point,
CartCoord3 max_point,
Int32 overlap_layer_size )

Definition at line 40 of file AMRPatchPosition.cc.

◆ AMRPatchPosition() [3/3]

Arcane::AMRPatchPosition::AMRPatchPosition ( const AMRPatchPosition & src)

Copy constructor.

Parameters
srcThe position to copy.

Definition at line 51 of file AMRPatchPosition.cc.

References AMRPatchPosition(), level(), maxPoint(), minPoint(), and overlapLayerSize().

Member Function Documentation

◆ canBeFusion()

bool Arcane::AMRPatchPosition::canBeFusion ( const AMRPatchPosition & other_patch) const

Method to know if our patch can be merged with other_patch.

Parameters
other_patchThe patch to check.
Returns
True if merging is possible.

Definition at line 199 of file AMRPatchPosition.cc.

References AMRPatchPosition(), level(), maxPoint(), and minPoint().

Referenced by fusion().

◆ computeOverlapLayerSize() [1/2]

void Arcane::AMRPatchPosition::computeOverlapLayerSize ( Int32 higher_level,
Int32 overlap_layer_size_top_level )

Method to calculate the number of overlap cell layers for our patch.

Parameters
higher_levelThe highest refinement level.
overlap_layer_size_top_levelThe number of layers for the highest refinement level.

Definition at line 438 of file AMRPatchPosition.cc.

References computeOverlapLayerSize().

◆ computeOverlapLayerSize() [2/2]

Int32 Arcane::AMRPatchPosition::computeOverlapLayerSize ( Int32 level,
Int32 higher_level,
Int32 overlap_layer_size_top_level )
static

Method to calculate the number of overlap cell layers for a given level.

Parameters
levelThe requested level.
higher_levelThe highest refinement level.
overlap_layer_size_top_levelThe number of layers for the highest refinement level.
Returns
The number of overlap cell layers for the requested level.

Formula: Let m be the highest refinement level (higher_level), Let C(m) be the number of layers at level m (overlap_layer_size_top_level), For any positive even integer C(m): C(m-1) = (int(C(m)/4)+1)*2

Definition at line 398 of file AMRPatchPosition.cc.

References ARCANE_FATAL, and level().

Referenced by computeOverlapLayerSize(), patchDown(), and patchUp().

◆ cut()

std::pair< AMRPatchPosition, AMRPatchPosition > Arcane::AMRPatchPosition::cut ( CartCoord cut_point,
Integer dim ) const

Method to cut the patch into two patches according to a cut point.

Parameters
cut_pointThe cut point.
dimThe dimension that must be cut.
Returns
The two patch positions resulting from the cut.

Definition at line 168 of file AMRPatchPosition.cc.

References AMRPatchPosition(), Arcane::MD_DirX, Arcane::MD_DirY, setMaxPoint(), and setMinPoint().

◆ fusion()

bool Arcane::AMRPatchPosition::fusion ( AMRPatchPosition & other_patch)

Method to merge other_patch with ours.

A check for possible merging (via canBeFusion()) is performed before merging. If merging is impossible, false is returned. Otherwise, we merge and return true. If merged, other_patch becomes null.

Parameters
other_patchThe patch to merge with.
Returns
true if the merge was successful, false if the merge is impossible.

Definition at line 221 of file AMRPatchPosition.cc.

References AMRPatchPosition(), canBeFusion(), maxPoint(), minPoint(), and setLevel().

◆ haveIntersection()

bool Arcane::AMRPatchPosition::haveIntersection ( const AMRPatchPosition & other) const

Method to know if our patch is in contact with other.

Parameters
otherThe patch to check.
Returns
True if the patches are in contact.

Definition at line 378 of file AMRPatchPosition.cc.

References AMRPatchPosition(), level(), maxPoint(), and minPoint().

◆ isIn() [1/2]

bool Arcane::AMRPatchPosition::isIn ( CartCoord x,
CartCoord y,
CartCoord z ) const

Method to know if a cell at position x,y,z is included in this patch.

To include the overlap layer, use the isInWithOverlap() method.

Parameters
xX position of the cell.
yY position of the cell.
zZ position of the cell.
Returns
True if the cell is in the patch.

Definition at line 316 of file AMRPatchPosition.cc.

◆ isIn() [2/2]

bool Arcane::AMRPatchPosition::isIn ( CartCoord3 coord) const

Method to know if a cell is included in this patch.

To include the overlap layer, use the isInWithOverlap() method.

Parameters
coordPosition of the cell.
Returns
True if the cell is in the patch.

Definition at line 325 of file AMRPatchPosition.cc.

◆ isInWithOverlap() [1/4]

bool Arcane::AMRPatchPosition::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.

Parameters
xX position of the cell.
yY position of the cell.
zZ position of the cell.
Returns
True if the cell is in the patch.

Definition at line 334 of file AMRPatchPosition.cc.

References maxPointWithOverlap(), and minPointWithOverlap().

◆ isInWithOverlap() [2/4]

bool Arcane::AMRPatchPosition::isInWithOverlap ( CartCoord x,
CartCoord y,
CartCoord z,
Integer overlap ) const

Method to know if a cell at position x,y,z is included in this patch with a specified overlap layer.

Parameters
xX position of the cell.
yY position of the cell.
zZ position of the cell.
overlapThe number of overlap cells in the layer.
Returns
True if the cell is in the patch.

Definition at line 356 of file AMRPatchPosition.cc.

◆ isInWithOverlap() [3/4]

bool Arcane::AMRPatchPosition::isInWithOverlap ( CartCoord3 coord) const

Method to know if a cell is included in this patch with overlap layer.

Parameters
coordPosition of the cell.
Returns
True if the cell is in the patch.

Definition at line 345 of file AMRPatchPosition.cc.

References maxPointWithOverlap(), and minPointWithOverlap().

◆ isInWithOverlap() [4/4]

bool Arcane::AMRPatchPosition::isInWithOverlap ( CartCoord3 coord,
Integer overlap ) const

Method to know if a cell is included in this patch with a specified overlap layer.

Parameters
coordPosition of the cell.
overlapThe number of overlap cells in the layer.
Returns
True if the cell is in the patch.

Definition at line 367 of file AMRPatchPosition.cc.

◆ isNull()

bool Arcane::AMRPatchPosition::isNull ( ) const

Method to know if the patch is null.

Warning
The validity of the position is not checked.
Returns
True if the patch is null.

Definition at line 260 of file AMRPatchPosition.cc.

◆ length()

CartCoord3 Arcane::AMRPatchPosition::length ( ) const

Method to know the size of the patch (in number of cells per direction).

Returns
The size of the patch.

Definition at line 307 of file AMRPatchPosition.cc.

◆ level()

Int32 Arcane::AMRPatchPosition::level ( ) const

Method to retrieve the patch level.

Returns
The patch level.

Definition at line 69 of file AMRPatchPosition.cc.

Referenced by AMRPatchPosition(), canBeFusion(), computeOverlapLayerSize(), haveIntersection(), and setLevel().

◆ maxPoint()

CartCoord3 Arcane::AMRPatchPosition::maxPoint ( ) const

Method to retrieve the max position of the enclosing box.

Returns
The max position.

Definition at line 105 of file AMRPatchPosition.cc.

Referenced by AMRPatchPosition(), canBeFusion(), fusion(), and haveIntersection().

◆ maxPointWithOverlap()

CartCoord3 Arcane::AMRPatchPosition::maxPointWithOverlap ( ) const

Method to retrieve the max position of the enclosing box including the overlap cell layer.

Returns
The max position with the overlap cell layer.

Definition at line 150 of file AMRPatchPosition.cc.

Referenced by isInWithOverlap(), and isInWithOverlap().

◆ minPoint()

CartCoord3 Arcane::AMRPatchPosition::minPoint ( ) const

Method to retrieve the min position of the enclosing box.

Returns
The min position.

Definition at line 87 of file AMRPatchPosition.cc.

Referenced by AMRPatchPosition(), canBeFusion(), fusion(), and haveIntersection().

◆ minPointWithOverlap()

CartCoord3 Arcane::AMRPatchPosition::minPointWithOverlap ( ) const

Method to retrieve the min position of the enclosing box including the overlap cell layer.

Returns
The min position with the overlap cell layer.

Definition at line 141 of file AMRPatchPosition.cc.

Referenced by isInWithOverlap(), and isInWithOverlap().

◆ nbCells()

Int64 Arcane::AMRPatchPosition::nbCells ( ) const

Method to know the number of cells in the patch according to its position.

Warning
The number of cells is calculated using the min and max positions (without the overlap layer). This number is therefore the same for all subdomains. Be careful not to compare this number with the number of cells in the cell group that may be associated with this class, which may be different for each subdomain.
Returns
The number of cells in the patch.

Definition at line 159 of file AMRPatchPosition.cc.

◆ overlapLayerSize()

Int32 Arcane::AMRPatchPosition::overlapLayerSize ( ) const

Method to retrieve the number of overlap cell layers of the patch.

Returns
the number of overlap cell layers

Definition at line 123 of file AMRPatchPosition.cc.

Referenced by AMRPatchPosition().

◆ patchDown()

AMRPatchPosition Arcane::AMRPatchPosition::patchDown ( Integer dim,
Int32 higher_level,
Int32 overlap_layer_size_top_level ) const

Method to create an AMRPatchPosition for the lower level.

If the min position is not divisible by two, it is rounded down to the lower integer. If the max position is not divisible by two, it is rounded up to the higher integer.

For the overlap layer, this method ensures that there will never be more than one level difference between two cells of different levels.

Warning
patch.patchDown(patch.patchUp(X)) != patch and patch.patchUp(patch.patchDown(X)) != patch.
Parameters
dimThe dimension of the mesh.
higher_levelThe highest refinement level of the mesh.
overlap_layer_size_top_levelThe number of overlap cell layers for patches at the highest refinement level.
Returns
A lower-level AMRPatchPosition.

Definition at line 288 of file AMRPatchPosition.cc.

References AMRPatchPosition(), computeOverlapLayerSize(), setLevel(), setMaxPoint(), and setMinPoint().

◆ patchUp()

AMRPatchPosition Arcane::AMRPatchPosition::patchUp ( Integer dim,
Int32 higher_level,
Int32 overlap_layer_size_top_level ) const

Method to create an AMRPatchPosition for the higher level.

Parameters
dimThe dimension of the mesh.
higher_levelThe highest refinement level of the mesh.
overlap_layer_size_top_levelThe number of overlap cell layers for patches at the highest refinement level.
Returns
A higher-level AMRPatchPosition.

Definition at line 269 of file AMRPatchPosition.cc.

References AMRPatchPosition(), computeOverlapLayerSize(), setLevel(), setMaxPoint(), and setMinPoint().

◆ setLevel()

void Arcane::AMRPatchPosition::setLevel ( Int32 level)

Method to set the patch level.

Parameters
levelThe patch level.

Definition at line 78 of file AMRPatchPosition.cc.

References level().

Referenced by fusion(), patchDown(), and patchUp().

◆ setMaxPoint()

void Arcane::AMRPatchPosition::setMaxPoint ( CartCoord3 max_point)

Method to set the max position of the enclosing box.

Parameters
max_pointthe max position.

Definition at line 114 of file AMRPatchPosition.cc.

Referenced by cut(), patchDown(), and patchUp().

◆ setMinPoint()

void Arcane::AMRPatchPosition::setMinPoint ( CartCoord3 min_point)

Method to set the min position of the enclosing box.

Parameters
min_pointthe min position.

Definition at line 96 of file AMRPatchPosition.cc.

Referenced by cut(), patchDown(), and patchUp().

◆ setOverlapLayerSize()

void Arcane::AMRPatchPosition::setOverlapLayerSize ( Int32 layer_size)

Method to set the number of overlap cell layers of the patch.

Parameters
layer_sizethe number of overlap cell layers

Definition at line 132 of file AMRPatchPosition.cc.


The documentation for this class was generated from the following files: