Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
Arcane::CartesianMeshAMRMng Class Reference

Class allowing access to the specific AMR methods of the Cartesian mesh. More...

#include <arcane/cartesianmesh/CartesianMeshAMRMng.h>

Collaboration diagram for Arcane::CartesianMeshAMRMng:

Public Member Functions

 CartesianMeshAMRMng (ICartesianMesh *cmesh)
 Constructor.
Int32 nbPatch () const
 Number of mesh patches.
CartesianPatch amrPatch (Int32 index) const
 Returns the index-th patch of the mesh.
CartesianMeshPatchListView patches () const
 View of the list of patches.
void refineZone (const AMRZonePosition &position) const
 Refines a block of the Cartesian mesh.
void coarseZone (const AMRZonePosition &position) const
 Coarsens a block of the Cartesian mesh.
void beginAdaptMesh (Int32 max_nb_levels, Int32 level_to_refine_first)
 Method to start mesh refinement.
void adaptLevel (Int32 level_to_adapt, bool do_fatal_if_useless=false) const
 Method to create a level of mesh refinement.
void endAdaptMesh ()
 Method to finish mesh refinement.
void clearRefineRelatedFlags () const
 Method to delete flags related to mesh refinement for all cells.
void setOverlapLayerSizeTopLevel (Int32 new_size) const
 Method to modify the number of overlap cell layers on the highest refinement level.
void disableOverlapLayer ()
 Method to disable overlap cell layers (and destroy them if present).
Integer reduceNbGhostLayers (Integer level, Integer target_nb_ghost_layers) const
 Method to delete one or more layers of ghost cells on a defined refinement level.
void mergePatches () const
 Method to merge patches that can be merged.
void createSubLevel () const
 Method to create a sub-level ("level -1").

Private Attributes

ICartesianMeshm_cmesh

Detailed Description

Class allowing access to the specific AMR methods of the Cartesian mesh.

An instance of this class is valid as long as the ICartesianMesh passed in the constructor is valid.

Definition at line 40 of file CartesianMeshAMRMng.h.

Constructor & Destructor Documentation

◆ CartesianMeshAMRMng()

Arcane::CartesianMeshAMRMng::CartesianMeshAMRMng ( ICartesianMesh * cmesh)
explicit

Constructor.

Definition at line 39 of file CartesianMeshAMRMng.cc.

Member Function Documentation

◆ adaptLevel()

void Arcane::CartesianMeshAMRMng::adaptLevel ( Int32 level_to_adapt,
bool do_fatal_if_useless = false ) const

Method to create a level of mesh refinement.

Warning
Experimental method.

This method can only be called if the mesh is an AMR mesh (IMesh::isAmrActivated()==true) and the AMR type is 3 (PatchCartesianMeshOnly).

This second method will allow the mesh to be refined level by level.

Note that the parameter level_to_adapt designates the level to refine, meaning the creation of level level_to_adapt +1 (if we want to refine level 0, then level 1 will be created).

Before calling this method, you must add the "II_Refine" flag to the cells that must be refined, only on level level_to_adapt. To ensure no flags are already present on the mesh, it is possible to call the method clearRefineRelatedFlags().

For the refinement of cells outside of level 0 (this "ground" level having a special status), the cells that can be refined must possess the "II_InPatch" flag. Cells without the "II_InPatch" flag cannot be refined.

Todo
Add the "II_InPatch" flag to all level 0 cells?

Cells on level level_to_adapt that are already refined, but do not have the "II_Refine" flag, may be deleted when calling the third method. This method redraws the patches and creates the new child cells if necessary, but does not delete any cells. The third method will handle the deletion of all cells that do not belong to any patch.

Once this method is called, level level_to_adapt +1 is ready to be used, notably to mark cells "II_Refine", and call this method again to create another level, etc.

This method is intended to be called iteratively, level by level (from the lowest level to the highest level). If patches of levels higher than level_to_adapt are detected, they will be deleted. It is therefore possible to call this method for level n, and then call it again for level n-1, for example (however, pay attention to the number of new cells created).

This operation is collective.

Parameters
level_to_adaptThe level to adapt.
do_fatal_if_uselessTriggers an exception if no cells are to refine or if level_to_adapt designates a level too high compared to the previous call.

Definition at line 102 of file CartesianMeshAMRMng.cc.

◆ amrPatch()

CartesianPatch Arcane::CartesianMeshAMRMng::amrPatch ( Int32 index) const

Returns the index-th patch of the mesh.

If the mesh is Cartesian, there is only one patch.

The returned instance remains valid as long as this instance is not destroyed.

Definition at line 56 of file CartesianMeshAMRMng.cc.

◆ beginAdaptMesh()

void Arcane::CartesianMeshAMRMng::beginAdaptMesh ( Int32 max_nb_levels,
Int32 level_to_refine_first )

Method to start mesh refinement.

Warning
Experimental method.

This method can only be called if the mesh is an AMR mesh (IMesh::isAmrActivated()==true) and the AMR type is 3 (PatchCartesianMeshOnly).

This method is the first of a trio of methods necessary to refine the mesh:

This first method will prepare the mesh for refinement.

It is necessary to pass the number of refinement levels that will occur during this refinement phase (max_nb_levels).

It is recommended to specify the exact number of levels to avoid adjustment of the number of overlap cell layers during the call to the third method, which is computationally expensive.

It is also necessary to pass the first level to be refined. If two levels are already present on the mesh (0 and 1) and you only want to create a third level (level 2) from the second level (level 1), you can set 1 for the parameter level_to_refine_first.

If two levels are already present on the mesh (0 and 1) and you want to start from scratch, you can set 0 for the parameter level_to_refine_first. In this case, the level 1 patches will be deleted, but not the cells/faces/nodes. Once the new level 1 patches are created using the second method, the third method will handle deleting the excess items. This allows the variable values for the cells/faces/nodes that were in a patch before and are preserved in a new patch.

Execution example:

amr_mng.beginAdaptMesh(2, 0); for (Integer level = 0; level < 2; ++level){ // Will perform its calculations and set II_Refine flags on the cells // of level level. computeInLevel(level); amr_mng.adaptLevel(level); } amr_mng.endAdaptMesh();

  • This operation is collective.
Parameters
max_nb_levelsThe desired number of refinement levels.
level_to_refine_firstThe level that will be refined first.

Definition at line 92 of file CartesianMeshAMRMng.cc.

◆ clearRefineRelatedFlags()

void Arcane::CartesianMeshAMRMng::clearRefineRelatedFlags ( ) const

Method to delete flags related to mesh refinement for all cells.

The flags concerned are:

Definition at line 121 of file CartesianMeshAMRMng.cc.

◆ coarseZone()

void Arcane::CartesianMeshAMRMng::coarseZone ( const AMRZonePosition & position) const

Coarsens a block of the Cartesian mesh.

This method can only be called if the mesh is an AMR mesh (IMesh::isAmrActivated()==true).

The cells whose center positions are between position and (position+length) are coarsened, and the corresponding connectivity information is updated.

All cells in the coarsening zone must be of the same level.

Patches that no longer contain cells after calling this method will be deleted.

This operation is collective.

Definition at line 83 of file CartesianMeshAMRMng.cc.

◆ createSubLevel()

void Arcane::CartesianMeshAMRMng::createSubLevel ( ) const

Method to create a sub-level ("level -1").

This method can only be called if the mesh is an AMR mesh (IMesh::isAmrActivated()==true).

In the case of using AMR type 3 (PatchCartesianMeshOnly), it is possible to call this method during calculation and as many times as necessary (as long as it is possible to divide the size of level 0 by 2). Once level -1 is created, all levels are "upgraded" (meaning level -1 becomes the level 0 "ground").

Definition at line 182 of file CartesianMeshAMRMng.cc.

References ARCANE_FATAL, Arcane::Cell, Arcane::CartesianMeshUtils::createCartesianMeshCoarsening2(), Arcane::Patch, and Arcane::PatchCartesianMeshOnly.

Here is the call graph for this function:

◆ disableOverlapLayer()

void Arcane::CartesianMeshAMRMng::disableOverlapLayer ( )

Method to disable overlap cell layers (and destroy them if present).

Warning
Without this layer, there may be more than one level of refinement between two cells. It is up to the user to manage this constraint.
Note
To reactivate these layers, a call to setOverlapLayerSizeTopLevel() is sufficient.

Definition at line 144 of file CartesianMeshAMRMng.cc.

References Arcane::Cell.

◆ endAdaptMesh()

void Arcane::CartesianMeshAMRMng::endAdaptMesh ( )

Method to finish mesh refinement.

Warning
Experimental method.

This method can only be called if the mesh is an AMR mesh (IMesh::isAmrActivated()==true) and the AMR type is 3 (PatchCartesianMeshOnly).

This third method will allow the mesh refinement to finish, specifically by deleting cells that no longer belong to any patch.

If the highest level refined with the second method does not correspond to the max_nb_levels parameter of the first method, there will be an adjustment of the number of overlap cell layers.

This operation is collective.

Definition at line 111 of file CartesianMeshAMRMng.cc.

◆ mergePatches()

void Arcane::CartesianMeshAMRMng::mergePatches ( ) const

Method to merge patches that can be merged.

This method can only be called if the mesh is an AMR mesh (IMesh::isAmrActivated()==true). If the AMR type is not 3 (PatchCartesianMeshOnly), the method does nothing.

This method can be useful after several calls to refineZone() and coarseZone(). However, calling this method is useless after a call to adaptLevel() because adaptLevel() handles it.

Definition at line 167 of file CartesianMeshAMRMng.cc.

References Arcane::Cell.

◆ nbPatch()

Int32 Arcane::CartesianMeshAMRMng::nbPatch ( ) const

Number of mesh patches.

There is always at least one patch representing the Cartesian mesh.

Definition at line 47 of file CartesianMeshAMRMng.cc.

◆ patches()

CartesianMeshPatchListView Arcane::CartesianMeshAMRMng::patches ( ) const

View of the list of patches.

Definition at line 65 of file CartesianMeshAMRMng.cc.

◆ reduceNbGhostLayers()

Integer Arcane::CartesianMeshAMRMng::reduceNbGhostLayers ( Integer level,
Integer target_nb_ghost_layers ) const

Method to delete one or more layers of ghost cells on a defined refinement level.

The desired number of ghost cell layers may be increased by the method. It is necessary to retrieve the returned value to get the final number of ghost cell layers.

Parameters
levelThe refinement level concerned by the deletion of ghost cells.
target_nb_ghost_layersThe desired number of layers after calling this method. ATTENTION: It may be adjusted by the method.
Returns
The final number of ghost cell layers.

Definition at line 158 of file CartesianMeshAMRMng.cc.

◆ refineZone()

void Arcane::CartesianMeshAMRMng::refineZone ( const AMRZonePosition & position) const

Refines a block of the Cartesian mesh.

This method can only be called if the mesh is an AMR mesh (IMesh::isAmrActivated()==true).

The cells whose center positions are between position and (position+length) are refined, and the corresponding connectivity information is updated.

This operation is collective.

Definition at line 74 of file CartesianMeshAMRMng.cc.

◆ setOverlapLayerSizeTopLevel()

void Arcane::CartesianMeshAMRMng::setOverlapLayerSizeTopLevel ( Int32 new_size) const

Method to modify the number of overlap cell layers on the highest refinement level.

A call to this method will trigger the adjustment of the number of layers for all existing patches.

The parameter new_size must be an even number (otherwise, it will be modified to the next highest even number).

Parameters
new_sizeThe new number of overlap cell layers.

Definition at line 130 of file CartesianMeshAMRMng.cc.

References Arcane::Cell.

Member Data Documentation

◆ m_cmesh

ICartesianMesh* Arcane::CartesianMeshAMRMng::m_cmesh
private

Definition at line 331 of file CartesianMeshAMRMng.h.


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