Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
GeomElement.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/* GeomElement.h (C) 2000-2026 */
9/* */
10/* Geometric Elements. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_GEOMETRIC_GEOMELEMENT_H
13#define ARCANE_GEOMETRIC_GEOMELEMENT_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/core/Item.h"
18#include "arcane/core/VariableTypes.h"
19
20#include "arcane/geometry/GeomElementView.h"
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane::geometric
26{
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29/*!
30 * \ingroup ArcaneGeometric
31 * \brief Base class for geometric elements.
32 *
33 * A geometric element contains the coordinates of the \a NbNode nodes that
34 * compose this element.
35 *
36 * For performance reasons, the default constructor
37 * does not initialize the coordinates.
38 *
39 * To retrieve the coordinates of the i-th node of the geometric element,
40 * simply use the [] operator. Modification is done via
41 * setItem().
42 */
43template <int NbNode>
45{
46 public:
47
48 //! Empty constructor.
50 //! Constructor from the coordinates \a coords of the nodes of the entity \a item
52 {
53 init(coords, item);
54 }
55 //! Constructor from the coordinates \a coords.
57 {
58 for (Integer i = 0; i < NbNode; ++i)
59 setItem(i, coords[i]);
60 }
61
62 //! Retrieves the value of the i-th node
63 inline const Real3 s(Integer i) const { return Real3(m_s[i].x, m_s[i].y, m_s[i].z); }
64 //! Retrieves the value of the i-th node
65 inline const Real3 operator[](Integer i) const { return Real3(m_s[i].x, m_s[i].y, m_s[i].z); }
66 //! Positions the value of the i-th node at \a v
67 inline void setItem(Integer i, const Real3& v) { m_s[i] = v; }
68 //! Positions the value of the i-th node at Real3(\a x,\a y,\a z)
69 inline void setItem(Integer i, Real x, Real y, Real z) { m_s[i] = Real3(x, y, z); }
70
71 /*!
72 * \brief Fills the view \a view with the coordinates of the instance.
73 */
74 void fillView(Real3ArrayView view) const
75 {
76 for (Integer i = 0; i < NbNode; ++i)
77 view[i] = s(i);
78 }
79
80 /*!
81 * \brief Initializes the coordinates with those of the nodes of the entity \a item
82 */
83 void init(const VariableNodeReal3& coords, ItemWithNodes item)
84 {
85 for (Integer i = 0; i < NbNode; ++i)
86 m_s[i] = coords[item.node(i)];
87 }
89 protected:
91 Real3POD m_s[NbNode];
92};
93
94/*---------------------------------------------------------------------------*/
95/*---------------------------------------------------------------------------*/
96
97#include "arcane/geometry/GeneratedGeomElement.h"
98
99/*---------------------------------------------------------------------------*/
100/*---------------------------------------------------------------------------*/
102} // namespace Arcane::geometric
103
104/*---------------------------------------------------------------------------*/
105/*---------------------------------------------------------------------------*/
106
107#endif
Mesh element based on nodes (Edge,Face,Cell).
Definition Item.h:773
Node node(Int32 i) const
i-th node of the entity
Definition Item.h:840
Class managing a 3-dimensional real vector.
Definition Real3.h:132
GeomElementBase()
Empty constructor.
Definition GeomElement.h:49
const Real3 operator[](Integer i) const
Retrieves the value of the i-th node.
Definition GeomElement.h:65
GeomElementBase(const VariableNodeReal3 &coords, ItemWithNodes item)
Constructor from the coordinates coords of the nodes of the entity item.
Definition GeomElement.h:51
const Real3 s(Integer i) const
Retrieves the value of the i-th node.
Definition GeomElement.h:63
void setItem(Integer i, Real x, Real y, Real z)
Positions the value of the i-th node at Real3(x,y,z).
Definition GeomElement.h:69
void fillView(Real3ArrayView view) const
Fills the view view with the coordinates of the instance.
Definition GeomElement.h:74
void init(const VariableNodeReal3 &coords, ItemWithNodes item)
Initializes the coordinates with those of the nodes of the entity item.
Definition GeomElement.h:83
GeomElementBase(Real3ConstArrayView coords)
Constructor from the coordinates coords.
Definition GeomElement.h:56
void setItem(Integer i, const Real3 &v)
Positions the value of the i-th node at v.
Definition GeomElement.h:67
ViewType view()
Mutable view of the element.
Definition GeomElement.h:90
MeshVariableScalarRefT< Node, Real3 > VariableNodeReal3
Coordinate type quantity at node.
ConstArrayView< Real3 > Real3ConstArrayView
C equivalent of a 1D array of Real3.
Definition UtilsTypes.h:496
ArrayView< Real3 > Real3ArrayView
C equivalent of a 1D array of Real3.
Definition UtilsTypes.h:467
Int32 Integer
Type representing an integer.
double Real
Type representing a real number.