Arcane  4.2.3.0
User documentation
Loading...
Searching...
No Matches
GeomShapeView.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/* GeomShapeView.h (C) 2000-2026 */
9/* */
10/* Handling of 2D and 3D geometric shapes. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_GEOMETRIC_GEOMSHAPEVIEW_H
13#define ARCANE_GEOMETRIC_GEOMSHAPEVIEW_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/ITraceMng.h"
18#include "arcane/utils/ArrayView.h"
19#include "arcane/utils/Real3.h"
20
21#include "arcane/core/Item.h"
22
23#include "arcane/geometry/GeometricConnectic.h"
24#include "arcane/geometry/GeomElement.h"
25#include "arcane/geometry/CellConnectivity.h"
26#include "arcane/geometry/GeomShapeMutableView.h"
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31namespace Arcane::geometric
32{
34/*---------------------------------------------------------------------------*/
35/*---------------------------------------------------------------------------*/
36
38
39/*---------------------------------------------------------------------------*/
40/*---------------------------------------------------------------------------*/
42/*!
43 * \ingroup ArcaneGeometric
44 * \brief Constant view on a geometric shape GeomShape.
45 *
46 * A view on a geometric shape allows for the optimized retrieval of
47 * the position of nodes, faces, and edges (in 3D)
48 * of a geometric object.
49 *
50 * This class manages a view on a geometric shape. There are two
51 * ways to initialize a view:
52 * - by retrieving the view associated with a mesh cell via the call
53 * to GeomShapeMng::initShape(). In this case, it is possible to
54 * retrieve the associated cell via the cell() method.
55 * - from a temporary instance of GeomShape
56 * via one of the two methods initFromHexa() or initFromQuad().
57 *
58 */
59class ARCANE_GEOMETRY_EXPORT GeomShapeView
60{
61 friend class GeomShapeMng;
62 friend class GeomShape;
63 friend class GeomShapeConnectivity;
64
65 private:
66
67 static CellConnectivity* global_cell_connectivity[NB_BASIC_ITEM_TYPE];
68 static GeomShapeConnectivity* global_connectivity;
69
70 public:
71
72 static void initializeConnectivity();
73
74 public:
75
76 GeomShapeView()
77 : m_cell_connectivity(global_cell_connectivity[IT_NullType])
78 , m_item_internal(ItemInternal::nullItem())
79 {
80 }
81
82 public:
83
84#include "arcane/geometry/GeneratedGeomShapeViewDeclarations.h"
85
86 public:
87
88 //! Fills \a hexa with the information of the \a i-th sub-control volume
89 void fillSubZoneElement(HexaElementView hexa, Integer i);
90 //! Fills \a quad with the information of the \a i-th sub-control volume
91 void fillSubZoneElement(QuadElementView quad, Integer i);
92
93 /*!
94 * \deprecated Use GeomShape::initFromHexaedron8() instead.
95 */
96 ARCANE_DEPRECATED_122 void initFromHexa(HexaElementConstView hexa, GeomShape& geom_cell);
97 /*!
98 * \deprecated Use GeomShape::initFromQuad4() instead.
99 */
100 ARCANE_DEPRECATED_122 void initFromQuad(QuadElementConstView hexa, GeomShape& geom_cell);
101
102 public:
103
104 /*!
105 * \name Coordinate Retrieval.
106 */
107 //@{
108 //! Position of the \a i-th node of the shape
109 constexpr const Real3 node(Integer i) const { return m_node_ptr[i]; }
110
111 //! Position of the center of the \a i-th face of the shape
112 const Real3 face(Integer i) const
113 {
114 return m_face_ptr[i];
116
117 //! Position of the center of the shape
118 const Real3 center() const
119 {
120 return *m_center_ptr;
121 }
122
123 //! Position of the center of the \a i-th edge of the shape
124 inline const Real3 edge(Integer i) const
126 return 0.5 * (node(m_cell_connectivity->m_edge_direct_connectic[(i * 2)]) + node(m_cell_connectivity->m_edge_direct_connectic[(i * 2) + 1]));
128 //@}
130 //! Associated entity (null if none)
131 Item item() const { return Item(m_item_internal); }
132 //! Associated cell (null if none)
133 Cell cell() const { return Cell(m_item_internal); }
134 //! Associated face (null if none)
135 Face face() const { return Face(m_item_internal); }
136
137 protected:
138
139 void _setArray(const Real3* node_ptr, const Real3* face_ptr, const Real3* center_ptr)
141 m_node_ptr = node_ptr;
142 m_face_ptr = face_ptr;
143 m_center_ptr = center_ptr;
144 }
145
146 private:
147
148 ARCANE_RESTRICT const Real3* m_node_ptr = nullptr;
149 ARCANE_RESTRICT const Real3* m_face_ptr = nullptr;
150 ARCANE_RESTRICT const Real3* m_center_ptr = nullptr;
151 //! Connectivity information
152 CellConnectivity* m_cell_connectivity;
153 //! Information about the original entity (ItemInternal::nullItem() if none)
154 ItemInternal* m_item_internal;
155
156 protected:
157
158 //TODO: TO BE REMOVED
159 constexpr const Real3POD* _nodeView() const { return (Real3POD*)(m_node_ptr); }
161 public:
162
163 /*!
164 * \name Connectivity Information.
165 */
166 //@{
167 //! Node connectivity information.
169 {
170 return m_cell_connectivity->nodeConnectic()[i];
171 }
173 //! Edge connectivity information.
175 {
176 return m_cell_connectivity->edgeConnectic()[i];
177 }
178
179 //! Face connectivity information
181 {
182 return m_cell_connectivity->faceConnectic()[i];
183 }
184
185 //! Number of sub-control volumes
188 return m_cell_connectivity->nbSubZone();
189 }
190
191 //! Number of internal SVC faces
193 {
194 return m_cell_connectivity->nbSubZoneFace();
195 }
196
197 //! Local number of the vertex associated with the sub-control volume
199 {
200 return m_cell_connectivity->nodeAssociation()[i];
201 }
202
203 const SVCFaceConnectic& svcFaceConnectic(Integer i) const
204 {
205 return m_cell_connectivity->SCVFaceConnectic()[i];
206 }
207
208 //! Local numbers within the sub-control volumes
210 {
211 return m_cell_connectivity->m_edge_node_sub_zone_id[i];
212 }
213
214 Integer faceNodeSubZoneId(Integer i) const
215 {
216 return m_cell_connectivity->m_face_node_sub_zone_id[i];
217 }
218 //@}
220 /*!
221 * \brief Geometric type of the shape.
222 *
223 * If the shape is associated with an entity (retrievable via item()),
224 * it is also the type of the entity.
225 *
226 * Returns \a GeomType::NullType if the instance is not initialized.
227 */
230 return m_cell_connectivity->cellType();
231 }
232
233 protected:
235 void _setItem(Item item)
236 {
237 m_cell_connectivity = global_cell_connectivity[item.type()];
238 m_item_internal = ItemCompatibility::_itemInternal(item);
239 }
240
241 void _setNullItem(int item_type)
242 {
243 m_item_internal = ItemInternal::nullItem();
244 m_cell_connectivity = global_cell_connectivity[item_type];
246};
247
248/*---------------------------------------------------------------------------*/
249/*---------------------------------------------------------------------------*/
250//TODO: Use Traits for the number of nodes and the SVC name.
251/*---------------------------------------------------------------------------*/
252/*---------------------------------------------------------------------------*/
253/*!
254 * \ingroup ArcaneGeometric
255 * \brief View on 2D geometric shape.
256 */
257class GeomShape2DView
258: public GeomShapeView
259{
260 public:
261
262 GeomShape2DView() {}
263 explicit GeomShape2DView(const GeomShapeView& rhs)
264 : GeomShapeView(rhs)
265 {}
267
268/*!
269 * \ingroup ArcaneGeometric
270 * \brief View on 3D geometric shape.
271 */
272class GeomShape3DView
273: public GeomShapeView
274{
275 public:
277 GeomShape3DView() {}
278 explicit GeomShape3DView(const GeomShapeView& rhs)
279 : GeomShapeView(rhs)
280 {}
282
283/*---------------------------------------------------------------------------*/
284/*---------------------------------------------------------------------------*/
285
286/*---------------------------------------------------------------------------*/
287/*---------------------------------------------------------------------------*/
288
289#include "arcane/geometry/GeneratedGeomShapeView.h"
290
291/*---------------------------------------------------------------------------*/
292/*---------------------------------------------------------------------------*/
293
294} // namespace Arcane::geometric
295
296/*---------------------------------------------------------------------------*/
297/*---------------------------------------------------------------------------*/
298
299//! To be removed eventually
300#include "arcane/geometry/GeomShape.h"
301
302/*---------------------------------------------------------------------------*/
303/*---------------------------------------------------------------------------*/
304
305#endif
Cell of a mesh.
Definition Item.h:1300
Face of a cell.
Definition Item.h:1032
Base class for a mesh element.
Definition Item.h:84
Class managing a 3-dimensional real vector.
Information on the connectivity of a cell.
View on 3D geometric shape.
Constant view on a geometric shape GeomShape.
const EdgeConnectic & edgeConnectic(Integer i) const
Edge connectivity information.
Integer edgeNodeSubZoneId(Integer i) const
Local numbers within the sub-control volumes.
const Real3 face(Integer i) const
Position of the center of the i-th face of the shape.
GeomType geomType() const
Geometric type of the shape.
Cell cell() const
Associated cell (null if none).
Integer nbSvcFace() const
Number of internal SVC faces.
ARCANE_DEPRECATED_122 void initFromHexa(HexaElementConstView hexa, GeomShape &geom_cell)
const Real3 edge(Integer i) const
Position of the center of the i-th edge of the shape.
ARCANE_DEPRECATED_122 void initFromQuad(QuadElementConstView hexa, GeomShape &geom_cell)
Integer nbSubZone() const
Number of sub-control volumes.
Face face() const
Associated face (null if none).
const Real3 center() const
Position of the center of the shape.
const NodeConnectic & nodeConnectic(Integer i) const
Node connectivity information.
const FaceConnectic & faceConnectic(Integer i) const
Face connectivity information.
void fillSubZoneElement(HexaElementView hexa, Integer i)
Fills hexa with the information of the i-th sub-control volume.
Integer nodeAssociation(Integer i) const
Local number of the vertex associated with the sub-control volume.
Item item() const
Associated entity (null if none).
constexpr const Real3 node(Integer i) const
Position of the i-th node of the shape.
Enumeration specifying the type of polygon or polyhedron associated with a geometric element or shape...
Definition GeomType.h:42
Int32 Integer
Type representing an integer.
Local cell connectivity structures.
Local connectivity structure.
Local cell connectivity structures.
Local cell and svc connectivity structures.