Arcane  v4.1.4.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
CartesianMeshAMRMng.cc
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/* CartesianMeshAMRMng.cc (C) 2000-2026 */
9/* */
10/* Gestionnaire de l'AMR pour un maillage cartésien. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/cartesianmesh/CartesianMeshAMRMng.h"
15
16#include "arcane/utils/FatalErrorException.h"
17
18#include "arcane/core/IMesh.h"
19#include "arcane/core/MeshKind.h"
20
21#include "arcane/cartesianmesh/ICartesianMesh.h"
22#include "arcane/cartesianmesh/CartesianPatch.h"
23#include "arcane/cartesianmesh/CartesianMeshCoarsening2.h"
24#include "arcane/cartesianmesh/CartesianMeshPatchListView.h"
25#include "arcane/cartesianmesh/CartesianMeshUtils.h"
26
27#include "arcane/cartesianmesh/internal/ICartesianMeshInternal.h"
28#include "arcane/cartesianmesh/internal/CartesianPatchGroup.h"
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
33namespace Arcane
34{
35
36/*---------------------------------------------------------------------------*/
37/*---------------------------------------------------------------------------*/
38
43
44/*---------------------------------------------------------------------------*/
45/*---------------------------------------------------------------------------*/
46
48nbPatch() const
49{
50 return m_cmesh->nbPatch();
51}
52
53/*---------------------------------------------------------------------------*/
54/*---------------------------------------------------------------------------*/
55
57amrPatch(Int32 index) const
58{
59 return m_cmesh->amrPatch(index);
60}
61
62/*---------------------------------------------------------------------------*/
63/*---------------------------------------------------------------------------*/
64
66patches() const
67{
68 return m_cmesh->patches();
69}
70
71/*---------------------------------------------------------------------------*/
72/*---------------------------------------------------------------------------*/
73
75refineZone(const AMRZonePosition& position) const
76{
77 m_cmesh->refinePatch(position);
78}
79
80/*---------------------------------------------------------------------------*/
81/*---------------------------------------------------------------------------*/
82
84coarseZone(const AMRZonePosition& position) const
85{
86 m_cmesh->coarseZone(position);
87}
88
89/*---------------------------------------------------------------------------*/
90/*---------------------------------------------------------------------------*/
91
93beginAdaptMesh(Int32 max_nb_levels, Int32 level_to_refine_first)
94{
95 // On calcule le nombre de mailles de recouvrements pour chaque level.
96 m_cmesh->_internalApi()->cartesianPatchGroup().beginAdaptMesh(max_nb_levels, level_to_refine_first);
97}
98
99/*---------------------------------------------------------------------------*/
100/*---------------------------------------------------------------------------*/
101
103adaptLevel(Int32 level_to_adapt, bool do_fatal_if_useless) const
104{
105 m_cmesh->_internalApi()->cartesianPatchGroup().adaptLevel(level_to_adapt, do_fatal_if_useless);
106}
107
108/*---------------------------------------------------------------------------*/
109/*---------------------------------------------------------------------------*/
110
113{
114 m_cmesh->_internalApi()->cartesianPatchGroup().endAdaptMesh();
115}
116
117/*---------------------------------------------------------------------------*/
118/*---------------------------------------------------------------------------*/
119
122{
123 m_cmesh->_internalApi()->cartesianPatchGroup().clearRefineRelatedFlags();
124}
125
126/*---------------------------------------------------------------------------*/
127/*---------------------------------------------------------------------------*/
128
131{
132 auto amr_type = m_cmesh->mesh()->meshKind().meshAMRKind();
133 if (amr_type == eMeshAMRKind::Cell) {
134 return;
135 }
136 m_cmesh->_internalApi()->cartesianPatchGroup().setOverlapLayerSizeTopLevel(new_size);
137}
138
139/*---------------------------------------------------------------------------*/
140/*---------------------------------------------------------------------------*/
141
144{
145 auto amr_type = m_cmesh->mesh()->meshKind().meshAMRKind();
146 if (amr_type == eMeshAMRKind::Cell) {
147 return;
148 }
149 m_cmesh->_internalApi()->cartesianPatchGroup().setOverlapLayerSizeTopLevel(-1);
150}
151
152/*---------------------------------------------------------------------------*/
153/*---------------------------------------------------------------------------*/
154
156reduceNbGhostLayers(Integer level, Integer target_nb_ghost_layers) const
157{
158 return m_cmesh->reduceNbGhostLayers(level, target_nb_ghost_layers);
159}
160
161/*---------------------------------------------------------------------------*/
162/*---------------------------------------------------------------------------*/
163
165mergePatches() const
166{
167 auto amr_type = m_cmesh->mesh()->meshKind().meshAMRKind();
168 if (amr_type == eMeshAMRKind::Cell) {
169 return;
170 }
171
172 m_cmesh->_internalApi()->cartesianPatchGroup().mergePatches();
173}
174
175/*---------------------------------------------------------------------------*/
176/*---------------------------------------------------------------------------*/
177
179createSubLevel() const
180{
181 auto amr_type = m_cmesh->mesh()->meshKind().meshAMRKind();
182 if(amr_type == eMeshAMRKind::Cell) {
184 coarser->createCoarseCells();
185 }
186 else if(amr_type == eMeshAMRKind::PatchCartesianMeshOnly) {
187 m_cmesh->_internalApi()->cartesianPatchGroup().updateLevelsAndAddGroundPatch();
188 }
189 else if(amr_type == eMeshAMRKind::Patch) {
190 ARCANE_FATAL("General patch AMR is not implemented. Please use PatchCartesianMeshOnly (3)");
191 }
192 else{
193 ARCANE_FATAL("AMR is not enabled");
194 }
195}
196
197/*---------------------------------------------------------------------------*/
198/*---------------------------------------------------------------------------*/
199
200} // End namespace Arcane
201
202/*---------------------------------------------------------------------------*/
203/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Classe permettant de définir une zone d'un maillage.
void setOverlapLayerSizeTopLevel(Int32 new_size) const
Méthode permettant de modifier le nombre de couches de mailles de recouvrement sur le niveau de raffi...
void coarseZone(const AMRZonePosition &position) const
Dé-raffine un bloc du maillage cartésien.
CartesianMeshPatchListView patches() const
Vue sur la liste des patchs.
void mergePatches() const
Méthode permettant de fusionner les patchs qui peuvent l'être.
void clearRefineRelatedFlags() const
Méthode permettant de supprimer les flags liés au raffinement de toutes les mailles.
CartesianMeshAMRMng(ICartesianMesh *cmesh)
Constructeur.
Int32 nbPatch() const
Nombre de patchs du maillage.
void endAdaptMesh()
Méthode permettant de terminer le raffinement du maillage.
void disableOverlapLayer()
Méthode permettant de désactiver les couches de mailles de recouvrement (et de les détruire si présen...
Integer reduceNbGhostLayers(Integer level, Integer target_nb_ghost_layers) const
Méthode permettant de supprimer une ou plusieurs couches de mailles fantômes sur un niveau de raffine...
void adaptLevel(Int32 level_to_adapt, bool do_fatal_if_useless=false) const
Méthode permettant de créer un niveau de raffinement du maillage.
void beginAdaptMesh(Int32 max_nb_levels, Int32 level_to_refine_first)
Méthode permettant de commencer le raffinement du maillage.
CartesianPatch amrPatch(Int32 index) const
Retourne le index-ième patch du maillage.
void refineZone(const AMRZonePosition &position) const
Raffine un bloc du maillage cartésien.
void createSubLevel() const
Méthode permettant de créer un sous-niveau ("niveau -1").
Patch AMR d'un maillage cartésien.
Interface d'un maillage cartésien.
Référence à une instance.
ARCANE_CARTESIANMESH_EXPORT Ref< CartesianMeshCoarsening2 > createCartesianMeshCoarsening2(ICartesianMesh *cm)
Créé une instance pour gérer le déraffinement du maillage (V2).
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Int32 Integer
Type représentant un entier.
@ Patch
Le maillage est AMR par patch.
Definition MeshKind.h:54
@ Cell
Le maillage est AMR par maille.
Definition MeshKind.h:52
@ PatchCartesianMeshOnly
Le maillage est AMR par patch cartésien (rectangulaire)
Definition MeshKind.h:56
std::int32_t Int32
Type entier signé sur 32 bits.