Arcane  4.1.12.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
39/*---------------------------------------------------------------------------*/
40/*---------------------------------------------------------------------------*/
41
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;
70 public:
72 static void initializeConnectivity();
74 public:
75
77 : m_node_ptr(0)
78 , m_face_ptr(0)
79 , m_center_ptr(0)
80 , m_cell_connectivity(global_cell_connectivity[IT_NullType])
81 , m_item_internal(ItemInternal::nullItem())
82 {
83 }
84
85 public:
87#include "arcane/geometry/GeneratedGeomShapeViewDeclarations.h"
88
89 public:
90
91 //! Fills \a hexa with the information of the \a i-th sub-control volume
92 void fillSubZoneElement(HexaElementView hexa, Integer i);
93 //! Fills \a quad with the information of the \a i-th sub-control volume
94 void fillSubZoneElement(QuadElementView quad, Integer i);
95
96 /*!
97 * \deprecated Use GeomShape::initFromHexaedron8() instead.
98 */
99 ARCANE_DEPRECATED_122 void initFromHexa(HexaElementConstView hexa, GeomShape& geom_cell);
100 /*!
101 * \deprecated Use GeomShape::initFromQuad4() instead.
102 */
103 ARCANE_DEPRECATED_122 void initFromQuad(QuadElementConstView hexa, GeomShape& geom_cell);
104
105 public:
106
107 /*!
108 * \name Coordinate Retrieval.
109 */
110 //@{
111 //! Position of the \a i-th node of the shape
112 const Real3 node(Integer i) const
113 {
114 return m_node_ptr[i];
117 //! Position of the center of the \a i-th face of the shape
118 const Real3 face(Integer i) const
119 {
120 return m_face_ptr[i];
121 }
123 //! Position of the center of the shape
124 const Real3 center() const
125 {
126 return *m_center_ptr;
127 }
128
129 //! Position of the center of the \a i-th edge of the shape
130 inline const Real3 edge(Integer i) const
131 {
132 return 0.5 * (node(m_cell_connectivity->m_edge_direct_connectic[(i * 2)]) + node(m_cell_connectivity->m_edge_direct_connectic[(i * 2) + 1]));
133 }
134 //@}
135
136 //! Associated entity (null if none)
137 Item item() const { return Item(m_item_internal); }
138 //! Associated cell (null if none)
139 Cell cell() const { return Cell(m_item_internal); }
140 //! Associated face (null if none)
141 Face face() const { return Face(m_item_internal); }
142
143 protected:
144
145 void _setArray(const Real3* node_ptr, const Real3* face_ptr, const Real3* center_ptr)
146 {
147 m_node_ptr = node_ptr;
148 m_face_ptr = face_ptr;
149 m_center_ptr = center_ptr;
150 }
151
152 private:
153
154 ARCANE_RESTRICT const Real3* m_node_ptr;
155 ARCANE_RESTRICT const Real3* m_face_ptr;
156 ARCANE_RESTRICT const Real3* m_center_ptr;
157 //! Connectivity information
158 CellConnectivity* m_cell_connectivity;
159 //! Information about the original entity (ItemInternal::nullItem() if none)
160 ItemInternal* m_item_internal;
161
162 protected:
163
164 //TODO: TO BE REMOVED
165 const Real3POD* _nodeView() const { return (Real3POD*)m_node_ptr; }
166
167 public:
168
169 /*!
170 * \name Connectivity Information.
171 */
172 //@{
173 //! Node connectivity information.
175 {
176 return m_cell_connectivity->nodeConnectic()[i];
177 }
178
179 //! Edge connectivity information.
181 {
182 return m_cell_connectivity->edgeConnectic()[i];
184
185 //! Face connectivity information
188 return m_cell_connectivity->faceConnectic()[i];
189 }
191 //! Number of sub-control volumes
193 {
194 return m_cell_connectivity->nbSubZone();
195 }
196
197 //! Number of internal SVC faces
199 {
200 return m_cell_connectivity->nbSubZoneFace();
201 }
202
203 //! Local number of the vertex associated with the sub-control volume
205 {
206 return m_cell_connectivity->nodeAssociation()[i];
207 }
208
209 const SVCFaceConnectic& svcFaceConnectic(Integer i) const
210 {
211 return m_cell_connectivity->SCVFaceConnectic()[i];
212 }
213
214 //! Local numbers within the sub-control volumes
216 {
217 return m_cell_connectivity->m_edge_node_sub_zone_id[i];
218 }
219
220 Integer faceNodeSubZoneId(Integer i) const
222 return m_cell_connectivity->m_face_node_sub_zone_id[i];
224 //@}
226 /*!
227 * \brief Geometric type of the shape.
229 * If the shape is associated with an entity (retrievable via item()),
230 * it is also the type of the entity.
231 *
232 * Returns \a GeomType::NullType if the instance is not initialized.
233 */
235 {
236 return m_cell_connectivity->cellType();
237 }
239 protected:
240
241 void _setItem(Item item)
242 {
243 m_cell_connectivity = global_cell_connectivity[item.type()];
244 m_item_internal = ItemCompatibility::_itemInternal(item);
245 }
246
247 void _setNullItem(int item_type)
248 {
249 m_item_internal = ItemInternal::nullItem();
250 m_cell_connectivity = global_cell_connectivity[item_type];
251 }
252};
253
254/*---------------------------------------------------------------------------*/
255/*---------------------------------------------------------------------------*/
256//TODO: Use Traits for the number of nodes and the SVC name.
257/*---------------------------------------------------------------------------*/
258/*---------------------------------------------------------------------------*/
259/*!
260 * \ingroup ArcaneGeometric
261 * \brief View on 2D geometric shape.
262 */
263class GeomShape2DView
264: public GeomShapeView
266 public:
268 GeomShape2DView() {}
269 explicit GeomShape2DView(const GeomShapeView& rhs)
270 : GeomShapeView(rhs)
271 {}
272};
273
274/*!
275 * \ingroup ArcaneGeometric
276 * \brief View on 3D geometric shape.
277 */
278class GeomShape3DView
279: public GeomShapeView
280{
281 public:
282
283 GeomShape3DView() {}
284 explicit GeomShape3DView(const GeomShapeView& rhs)
285 : GeomShapeView(rhs)
286 {}
287};
288
289/*---------------------------------------------------------------------------*/
290/*---------------------------------------------------------------------------*/
291
292/*---------------------------------------------------------------------------*/
293/*---------------------------------------------------------------------------*/
294
295#include "arcane/geometry/GeneratedGeomShapeView.h"
297/*---------------------------------------------------------------------------*/
298/*---------------------------------------------------------------------------*/
299
300} // namespace Arcane::geometric
301
302/*---------------------------------------------------------------------------*/
303/*---------------------------------------------------------------------------*/
304
305//! To be removed eventually
306#include "arcane/geometry/GeomShape.h"
307
308/*---------------------------------------------------------------------------*/
309/*---------------------------------------------------------------------------*/
310
311#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.
Definition Real3.h:132
Information on the connectivity of a cell.
View on 2D geometric shape.
Constant view on a geometric shape GeomShape.
const EdgeConnectic & edgeConnectic(Integer i) const
Edge connectivity information.
const Real3 node(Integer i) const
Position of the i-th node of the shape.
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).
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.