Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
AllCellToAllEnvCellConverter.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/* AllCellToAllEnvCellConverter.h (C) 2000-2024 */
9/* */
10/* Conversion of 'Cell' to 'AllEnvCell'. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_MATERIALS_ALLCELLTOALLENVCELLCONVERTER_H
13#define ARCANE_MATERIALS_ALLCELLTOALLENVCELLCONVERTER_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18
19#include "arcane/core/materials/MatItem.h"
21#include "arcane/core/materials/CellToAllEnvCellConverter.h"
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26namespace Arcane::Materials
27{
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
54{
55 friend class CellToAllEnvCellAccessor;
56 friend class CellToAllComponentCellEnumerator;
57 friend AllCellToAllEnvCellContainer;
58
59 private:
60
62 ARCCORE_HOST_DEVICE Span<ComponentItemLocalId> operator[](Int32 cell_id) const
63 {
64 return m_allcell_allenvcell_ptr[cell_id];
65 }
66
67 private:
68
69 Span<Span<ComponentItemLocalId>> m_allcell_allenvcell_ptr;
70};
71
72/*---------------------------------------------------------------------------*/
73/*---------------------------------------------------------------------------*/
74
85class ARCANE_MATERIALS_EXPORT CellToAllEnvCellAccessor
86{
87 friend class CellToAllComponentCellEnumerator;
88
89 public:
90
91 using size_type = Span<ComponentItemLocalId>::size_type;
92
93 public:
94
95 CellToAllEnvCellAccessor() = default;
96 explicit CellToAllEnvCellAccessor(const IMeshMaterialMng* mm);
97
98 ARCCORE_HOST_DEVICE size_type nbEnvironment(Int32 cid) const
99 {
100 return m_cell_allenvcell[cid].size();
101 }
102
103 private:
104
105 ARCCORE_HOST_DEVICE AllCellToAllEnvCell _getAllCellToAllEnvCell() const
106 {
107 return m_cell_allenvcell;
108 }
109
110 private:
111
112 AllCellToAllEnvCell m_cell_allenvcell;
113};
114
115/*---------------------------------------------------------------------------*/
116/*---------------------------------------------------------------------------*/
117
118class ARCANE_MATERIALS_EXPORT CellToAllComponentCellEnumerator
119{
120 friend class EnumeratorTracer;
121
122 public:
123
124 using index_type = Span<ComponentItemLocalId>::index_type;
125 using size_type = Span<ComponentItemLocalId>::size_type;
126
127 public:
128
129 // The CPU version allows verification that initialization was done before ENUMERATE
130 ARCCORE_HOST_DEVICE explicit CellToAllComponentCellEnumerator(Int32 cell_id, const CellToAllEnvCellAccessor& acc)
131 {
132 AllCellToAllEnvCell all_env_view = acc._getAllCellToAllEnvCell();
133 m_ptr = all_env_view[cell_id];
134 }
135 ARCCORE_HOST_DEVICE void operator++()
136 {
137 ++m_index;
138 }
139
140 ARCCORE_HOST_DEVICE bool hasNext() const
141 {
142 return m_index < m_ptr.size();
143 }
144
145 ARCCORE_HOST_DEVICE ComponentItemLocalId operator*() const
146 {
147 return m_ptr[m_index];
148 }
149
150 private:
151
152 index_type m_index = 0;
154};
155
156/*---------------------------------------------------------------------------*/
157/*---------------------------------------------------------------------------*/
158
169#define RUNCOMMAND_ENUMERATE_CELL_ALLENVCELL(cell_to_allenvcellaccessor, iter_name, cell_group) \
170 A_FUNCINFO << cell_group << [=] ARCCORE_HOST_DEVICE(CellLocalId iter_name)
171
172/*---------------------------------------------------------------------------*/
173/*---------------------------------------------------------------------------*/
174
175// TODO Very likely to be moved elsewhere if this prototype is kept
176#define A_ENUMERATE_CELL_ALLCOMPONENTCELL(_EnumeratorClassName, iname, cid, cell_to_allenvcellaccessor) \
177 for (A_TRACE_COMPONENT(_EnumeratorClassName) iname(::Arcane::Materials::_EnumeratorClassName(cid, cell_to_allenvcellaccessor) A_TRACE_ENUMERATOR_WHERE); iname.hasNext(); ++iname)
178
179/*---------------------------------------------------------------------------*/
180/*---------------------------------------------------------------------------*/
181
192// TODO Very likely to be moved elsewhere if this prototype is kept
193#define ENUMERATE_CELL_ALLENVCELL(iname, cid, cell_to_allenvcellaccessor) \
194 A_ENUMERATE_CELL_ALLCOMPONENTCELL(CellToAllComponentCellEnumerator, iname, cid, cell_to_allenvcellaccessor)
195
196/*---------------------------------------------------------------------------*/
197/*---------------------------------------------------------------------------*/
198
199} // End namespace Arcane::Materials
200
201/*---------------------------------------------------------------------------*/
202/*---------------------------------------------------------------------------*/
203
204#endif
Connectivity table from 'Cell' to its 'AllEnvCell' intended for use on accelerator.
__host__ __device__ Span< ComponentItemLocalId > operator[](Int32 cell_id) const
Access method for the "connectivity" table cell -> all env cells.
Encapsulation class to access the equivalent connectivity cell -> allenvcell. Intended to be used wit...
Interface for the material and environment manager of a mesh.
View of an array of elements of type T.
Definition Span.h:635
Always enables tracing in Arcane parts concerning materials.
class ARCANE_MATERIALS_EXPORT(64) SimdMatVarIndex
SIMD indexer on a component.
std::int32_t Int32
Signed integer type of 32 bits.