Arcane  v4.1.5.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 m_cmesh->_internalApi()->saveInfosInProperties();
116}
117
118/*---------------------------------------------------------------------------*/
119/*---------------------------------------------------------------------------*/
120
123{
124 m_cmesh->_internalApi()->cartesianPatchGroup().clearRefineRelatedFlags();
125}
126
127/*---------------------------------------------------------------------------*/
128/*---------------------------------------------------------------------------*/
129
132{
133 auto amr_type = m_cmesh->mesh()->meshKind().meshAMRKind();
134 if (amr_type == eMeshAMRKind::Cell) {
135 return;
136 }
137 m_cmesh->_internalApi()->cartesianPatchGroup().setOverlapLayerSizeTopLevel(new_size);
138 m_cmesh->_internalApi()->saveInfosInProperties();
139}
140
141/*---------------------------------------------------------------------------*/
142/*---------------------------------------------------------------------------*/
143
146{
147 auto amr_type = m_cmesh->mesh()->meshKind().meshAMRKind();
148 if (amr_type == eMeshAMRKind::Cell) {
149 return;
150 }
151 m_cmesh->_internalApi()->cartesianPatchGroup().setOverlapLayerSizeTopLevel(-1);
152 m_cmesh->_internalApi()->saveInfosInProperties();
153}
154
155/*---------------------------------------------------------------------------*/
156/*---------------------------------------------------------------------------*/
157
159reduceNbGhostLayers(Integer level, Integer target_nb_ghost_layers) const
160{
161 return m_cmesh->reduceNbGhostLayers(level, target_nb_ghost_layers);
162}
163
164/*---------------------------------------------------------------------------*/
165/*---------------------------------------------------------------------------*/
166
168mergePatches() const
169{
170 auto amr_type = m_cmesh->mesh()->meshKind().meshAMRKind();
171 if (amr_type == eMeshAMRKind::Cell) {
172 return;
173 }
174
175 m_cmesh->_internalApi()->cartesianPatchGroup().mergePatches();
176 m_cmesh->_internalApi()->saveInfosInProperties();
177}
178
179/*---------------------------------------------------------------------------*/
180/*---------------------------------------------------------------------------*/
181
183createSubLevel() const
184{
185 auto amr_type = m_cmesh->mesh()->meshKind().meshAMRKind();
186 if(amr_type == eMeshAMRKind::Cell) {
188 coarser->createCoarseCells();
189 }
190 else if(amr_type == eMeshAMRKind::PatchCartesianMeshOnly) {
191 m_cmesh->_internalApi()->cartesianPatchGroup().updateLevelsAndAddGroundPatch();
192 }
193 else if(amr_type == eMeshAMRKind::Patch) {
194 ARCANE_FATAL("General patch AMR is not implemented. Please use PatchCartesianMeshOnly (3)");
195 }
196 else{
197 ARCANE_FATAL("AMR is not enabled");
198 }
199 m_cmesh->_internalApi()->saveInfosInProperties();
200}
201
202/*---------------------------------------------------------------------------*/
203/*---------------------------------------------------------------------------*/
204
205} // End namespace Arcane
206
207/*---------------------------------------------------------------------------*/
208/*---------------------------------------------------------------------------*/
#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.