Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
CartesianMeshCoarsening.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/* CartesianMeshCoarsening.h (C) 2000-2024 */
9/* */
10/* Coarsening of a Cartesian mesh. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CARTESIANMESH_CARTESIANMESHCOARSENING_H
13#define ARCANE_CARTESIANMESH_CARTESIANMESHCOARSENING_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 * \deprecated This class is obsolete. The version 2 implementation (CartesianMeshCoarsening2) must be used.
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 well as the number of local cells in each subdomain.
49 *
50 * The coarsening is done in two phases:
51 *
52 * - createCoarseCells(), which creates the coarse cells. After calling
53 * this method, it is possible to use coarseCells() to get
54 * the list of coarse cells and refinedCells() to get for
55 * each coarse cell the list of corresponding refined cells.
56 * - removeRefinedCells(), which removes cells other than the coarse cells. After this call, there is only a Cartesian mesh
57 * with half the number of cells in each direction. It will then
58 * be possible to call the refinement methods to create additional levels.
59 *
60 * \code
61 * ICartesianMesh* cartesian_mesh = ...;
62 * Ref<CartesianMeshCoarsening> coarser = m_cartesian_mesh->createCartesianMeshCoarsening();
63 * IMesh* mesh = cartesian_mesh->mesh();
64 * CellInfoListView cells(mesh->cellFamily());
65 * coarser->createCoarseCells();
66 * Int32 index = 0;
67 * for( Int32 cell_lid : coarser->coarseCells()){
68 * Cell cell = cells[cell_lid];
69 * info() << "Test: CoarseCell= " << ItemPrinter(cell);
70 * ConstArrayView<Int32> sub_cells(coarser->refinedCells(index));
71 * ++index;
72 * for( Int32 sub_lid : sub_cells )
73 * info() << "SubCell=" << ItemPrinter(cells[sub_lid]);
74 * }
75 * coarser->removeRefinedCells();
76 * \endcode
77 */
78class ARCANE_CARTESIANMESH_EXPORT CartesianMeshCoarsening
79: public TraceAccessor
80{
81 friend CartesianMeshImpl;
82
83 private:
84
85 ARCANE_DEPRECATED_REASON("Y2024: Use Arcane::CartesianMeshUtils::createCartesianMeshCoarsening2() instead")
86 explicit CartesianMeshCoarsening(ICartesianMesh* m);
87
88 public:
89
90 /*!
91 * \brief Coarsens the initial mesh by 2.
92 *
93 * This method is collective.
94 */
95 void createCoarseCells();
96
97 /*!
98 * \brief List of localIds() of refined cells for the parent cell at index \a index.
99 *
100 * This method is only valid after calling createCoarseCells().
101 *
102 * In 2D, there are 4 refined cells per coarse cell. In 3D, there are 8.
103 */
105 {
106 return m_refined_cells[index];
107 }
108 /*!
109 * \brief List of localIds() of coarse cells.
110 *
111 * This method is only valid after calling createCoarseCells().
112 */
113 ConstArrayView<Int32> coarseCells() const { return m_coarse_cells; }
114
115 /*!
116 * \brief Removes refined cells.
117 *
118 * createCoarseCells() must be called beforehand.
119 */
120 void removeRefinedCells();
121
122 private:
123
124 ICartesianMesh* m_cartesian_mesh = nullptr;
125 Int32 m_verbosity_level = false;
126 UniqueArray2<Int32> m_refined_cells;
127 UniqueArray<Int32> m_coarse_cells;
128 bool m_is_create_coarse_called = false;
129 bool m_is_remove_refined_called = false;
130 Int64 m_first_own_cell_unique_id_offset = NULL_ITEM_UNIQUE_ID;
131
132 private:
133
134 Int64 _getMaxUniqueId(const ItemGroup& group);
135 void _recomputeMeshGenerationInfo();
136};
137
138/*---------------------------------------------------------------------------*/
139/*---------------------------------------------------------------------------*/
140
141} // End namespace Arcane
142
143/*---------------------------------------------------------------------------*/
144/*---------------------------------------------------------------------------*/
145
146#endif
Declarations of types on entities.
void createCoarseCells()
Coarsens the initial mesh by 2.
ConstArrayView< Int32 > refinedCells(Int32 index) const
List of localIds() of refined cells for the parent cell at index index.
ConstArrayView< Int32 > coarseCells() const
List of localIds() of coarse cells.
Constant view of an array of type T.
Mesh entity group.
Definition ItemGroup.h:51
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
2D data vector with value semantics (STL style).
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.