Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
CartesianMeshCoarsening2.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/* CartesianMeshCoarsening2.h (C) 2000-2024 */
9/* */
10/* Coarsening of a Cartesian mesh. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CARTESIANMESH_CARTESIANMESHCOARSENING2_H
13#define ARCANE_CARTESIANMESH_CARTESIANMESHCOARSENING2_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/TraceAccessor.h"
18#include "arcane/utils/Array2.h"
19
21#include "arcane/core/ICartesianMeshGenerationInfo.h"
22
23#include "arcane/cartesianmesh/CartesianMeshGlobal.h"
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28namespace Arcane
29{
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33/*!
34 * \ingroup ArcaneCartesianMesh
35 *
36 * \brief Coarsens a Cartesian mesh by 2.
37 *
38 * \warning This method is experimental.
39 *
40 * This class allows coarsening a Cartesian mesh. Instances
41 * of this class are created via ICartesianMesh::createCartesianMeshCoarsening().
42 *
43 * The initial mesh must be Cartesian and must not have patches.
44 *
45 * The mesh must be an AMR mesh (IMesh::isAmrActivated()==true).
46 *
47 * The number of cells in each dimension must be a multiple of 2
48 * as must the number of local cells in each subdomain.
49 *
50 * The coarsening occurs upon calling createCoarseCell(). After this
51 * call, the mesh has the following structure:
52 * - coarse cells are created for every quadruplet of existing cells
53 * which thus become refined cells.
54 * - each coarse cell is at level 0 (Cell::level()) and each initial cell
55 * is at level 1.
56 * - these child cells can be accessed via the Cell::nbHChildren() and
57 * Cell::hChild() methods.
58 * - there will be two patches in the mesh. The first will contain the level zero cells
59 * and the second will contain the level 1 cells, which are the
60 * original cells before coarsening.
61 *
62 * It is then possible to keep only the coarse cells and
63 * remove the refined cells by calling the method.
64 *
65 * - removeRefinedCells() which deletes cells other than the coarse cells. After this call, there is only a Cartesian mesh
66 * with half the number of cells in each direction. It will then
67 * be possible to call the refinement methods to create additional levels.
68 * Here is an example of user code:
69 *
70 * \code
71 * ICartesianMesh* cartesian_mesh = ...;
72 * Ref<CartesianMeshCoarsening> coarser = CartesianMeshUtils::createCartesianMeshCoarsening(cartesian_mesh);
73 * coarser->createCoarseCells();
74 * \endcode
75 */
76class ARCANE_CARTESIANMESH_EXPORT CartesianMeshCoarsening2
77: public TraceAccessor
78{
79 friend CartesianMeshImpl;
80
81 private:
82
83 explicit CartesianMeshCoarsening2(ICartesianMesh* m);
84
85 public:
86
87 /*!
88 * \brief Coarsens the initial mesh by 2.
89 *
90 * This method is collective.
91 */
92 void createCoarseCells();
93
94 void removeRefinedCells();
95
96 private:
97
98 ICartesianMesh* m_cartesian_mesh = nullptr;
99 Int32 m_verbosity_level = false;
100 //! uniqueId() of the coarse cells
101 UniqueArray<Int64> m_coarse_cells_uid;
102 bool m_is_create_coarse_called = false;
103 bool m_is_remove_refined_called = false;
104 Int64 m_first_own_cell_unique_id_offset = NULL_ITEM_UNIQUE_ID;
105
106 private:
107
108 Int64 _getMaxUniqueId(const ItemGroup& group);
109 void _recomputeMeshGenerationInfo();
110 void _writeMeshSVG(const String& name);
111 void _doDoubleGhostLayers();
112 void _createCoarseCells2D();
113 void _createCoarseCells3D();
114};
115
116/*---------------------------------------------------------------------------*/
117/*---------------------------------------------------------------------------*/
118
119} // End namespace Arcane
120
121/*---------------------------------------------------------------------------*/
122/*---------------------------------------------------------------------------*/
123
124#endif
Declarations of types on entities.
void createCoarseCells()
Coarsens the initial mesh by 2.
Mesh entity group.
Definition ItemGroup.h:51
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
1D data vector with value semantics (STL style).
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int64_t Int64
Signed integer type of 64 bits.
std::int32_t Int32
Signed integer type of 32 bits.