Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
GeometryTemplatesT.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#ifndef ARCGEOSIM_GEOMETRY_IMPL_GEOMETRYTEMPLATES_H
8#define ARCGEOSIM_GEOMETRY_IMPL_GEOMETRYTEMPLATES_H
9
10#include "arcane/core/IMesh.h"
11using namespace Arcane;
12
13#include "arcane/utils/ITraceMng.h"
14
15#include "arcane/core/IItemOperationByBasicType.h"
16#include "arcane/core/IItemFamily.h"
17#include "arcane/core/ArcaneVersion.h"
19#include "arcane/core/ItemVectorView.h"
20
21#include "arcane/geometry/impl/ItemGroupGeometryProperty.h"
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26namespace Arcane::Numerics
27{
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32template <typename GeometryT>
33class GenericGSInternalUpdater : public IItemOperationByBasicType
34{
35 private:
36
37 GeometryT& m_geom;
38 ItemGroupGeometryProperty* m_group_property = nullptr;
39 ITraceMng* m_trace_mng;
40
41 public:
42
43 GenericGSInternalUpdater(GeometryT& geom, ITraceMng* traceMng)
44 : m_geom(geom)
45 , m_trace_mng(traceMng)
46 {}
47
48 void setGroupProperty(ItemGroupGeometryProperty* group_property)
49 {
50 m_group_property = group_property;
51 }
52
53#define SAVE_PROPERTY(property, type, item, group, expr) \
54 if (m_group_property->hasProperty((property))) { \
55 ItemGroupGeometryProperty::StorageInfo& storage = m_group_property->storages[property]; \
56 if (ContainerAccessorT<type>::getVarContainer(storage)) { \
57 IGeometryMng::type##Variable& mMap = *ContainerAccessorT<type>::getVarContainer(storage); \
58 ENUMERATE_ITEMWITHNODES((item), (group)) \
59 { \
60 mMap[*(item)] = (expr); \
61 } \
62 } \
63 }
64
65 template <typename ComputeLineFunctor>
66 void applyLineTemplate(ItemVectorView group)
67 {
68 // Uses local arrays instead of specialization by property type (less code, more flexibility)
69 UniqueArray<Real3> centers(group.size());
70 UniqueArray<Real3> orientations(group.size());
71
72 ComputeLineFunctor functor(&m_geom);
73 ENUMERATE_ITEMWITHNODES(item, group)
74 {
75 functor.computeOrientedMeasureAndCenter(*item, orientations[item.index()], centers[item.index()]);
76 }
77
78 SAVE_PROPERTY(IGeometryProperty::PMeasure, Real, item, group, math::normeR3(orientations[item.index()]));
79 SAVE_PROPERTY(IGeometryProperty::PLength, Real, item, group, math::normeR3(orientations[item.index()]));
80 SAVE_PROPERTY(IGeometryProperty::PArea, Real, item, group, 0);
81 SAVE_PROPERTY(IGeometryProperty::PVolume, Real, item, group, 0);
82 SAVE_PROPERTY(IGeometryProperty::PCenter, Real3, item, group, centers[item.index()]);
83 SAVE_PROPERTY(IGeometryProperty::PNormal, Real3, item, group, orientations[item.index()]);
84 SAVE_PROPERTY(IGeometryProperty::PVolumeSurfaceRatio, Real, item, group, 0);
85 }
86
87 template <typename ComputeSurfaceFunctor>
88 void applySurfaceTemplate(ItemVectorView group)
89 {
90 // Uses local arrays instead of specialization by property type (less code, more flexibility)
91 UniqueArray<Real3> centers(group.size());
92 UniqueArray<Real3> normals(group.size());
93
94 ComputeSurfaceFunctor functor(&m_geom);
95 ENUMERATE_ITEMWITHNODES(item, group)
96 {
97 functor.computeOrientedMeasureAndCenter(*item, normals[item.index()], centers[item.index()]);
98 }
99
100 SAVE_PROPERTY(IGeometryProperty::PMeasure, Real, item, group, math::normeR3(normals[item.index()]));
101 SAVE_PROPERTY(IGeometryProperty::PLength, Real, item, group, 0);
102 SAVE_PROPERTY(IGeometryProperty::PArea, Real, item, group, math::normeR3(normals[item.index()]));
103 SAVE_PROPERTY(IGeometryProperty::PVolume, Real, item, group, 0);
104 SAVE_PROPERTY(IGeometryProperty::PCenter, Real3, item, group, centers[item.index()]);
105 SAVE_PROPERTY(IGeometryProperty::PNormal, Real3, item, group, normals[item.index()]);
106 SAVE_PROPERTY(IGeometryProperty::PVolumeSurfaceRatio, Real, item, group, 0);
107 }
108
109 template <typename ComputeVolumeFunctor>
110 void applyVolumeTemplate(ItemVectorView group)
111 {
112 // Uses local arrays instead of specialization by property type (less code, more flexibility)
113 UniqueArray<Real3> centers(group.size());
114 UniqueArray<Real> volumes(group.size());
115
116 ComputeVolumeFunctor functor(&m_geom);
117 ENUMERATE_ITEMWITHNODES(item, group)
118 {
119 functor.computeOrientedMeasureAndCenter(*item, volumes[item.index()], centers[item.index()]);
120 }
121
122 SAVE_PROPERTY(IGeometryProperty::PMeasure, Real, item, group, volumes[item.index()]);
123 SAVE_PROPERTY(IGeometryProperty::PLength, Real, item, group, 0);
124 SAVE_PROPERTY(IGeometryProperty::PArea, Real, item, group, 0);
125 SAVE_PROPERTY(IGeometryProperty::PVolume, Real, item, group, volumes[item.index()]);
126 SAVE_PROPERTY(IGeometryProperty::PCenter, Real3, item, group, centers[item.index()]);
127 SAVE_PROPERTY(IGeometryProperty::PNormal, Real3, item, group, 0);
128
129 if (m_group_property->hasProperty((IGeometryProperty::PVolumeSurfaceRatio))) {
130 UniqueArray<Real> areas(group.size());
131 ENUMERATE_ITEMWITHNODES(item, group)
132 {
133 functor.computeVolumeArea(*item, areas[item.index()]);
134 }
135 SAVE_PROPERTY(IGeometryProperty::PVolumeSurfaceRatio, Real, item, group, volumes[item.index()] / areas[item.index()]);
136 }
137 }
138
139 void applyVertex(ItemVectorView group) { ARCANE_UNUSED(group); }
140
141 void applyLine2(ItemVectorView group)
142 {
143 applyLineTemplate<typename GeometryT::ComputeLine2>(group);
144 }
145
146 void applyTriangle3(ItemVectorView group)
147 {
148 applySurfaceTemplate<typename GeometryT::ComputeTriangle3>(group);
149 }
150
151 void applyQuad4(ItemVectorView group)
152 {
153 applySurfaceTemplate<typename GeometryT::ComputeQuad4>(group);
154 }
155
156 void applyPentagon5(ItemVectorView group)
157 {
158 applySurfaceTemplate<typename GeometryT::ComputePentagon5>(group);
159 }
160
161 void applyHexagon6(ItemVectorView group)
162 {
163 applySurfaceTemplate<typename GeometryT::ComputeHexagon6>(group);
164 }
165
166 void applyTetraedron4(ItemVectorView group)
167 {
168 applyVolumeTemplate<typename GeometryT::ComputeTetraedron4>(group);
169 }
170
171 void applyPyramid5(ItemVectorView group)
172 {
173 applyVolumeTemplate<typename GeometryT::ComputePyramid5>(group);
174 }
175
176 void applyPentaedron6(ItemVectorView group)
177 {
178 applyVolumeTemplate<typename GeometryT::ComputePentaedron6>(group);
179 }
180
181 void applyHexaedron8(ItemVectorView group)
182 {
183 applyVolumeTemplate<typename GeometryT::ComputeHexaedron8>(group);
184 }
185
186 void applyHeptaedron10(ItemVectorView group)
187 {
188 applyVolumeTemplate<typename GeometryT::ComputeHeptaedron10>(group);
189 }
190
191 void applyOctaedron12(ItemVectorView group)
192 {
193 applyVolumeTemplate<typename GeometryT::ComputeOctaedron12>(group);
194 }
195
196 void applyHemiHexa7(ItemVectorView group)
197 {
198 applyVolumeTemplate<typename GeometryT::ComputeHemiHexa7>(group);
199 }
200
201 void applyHemiHexa6(ItemVectorView group)
202 {
203 applyVolumeTemplate<typename GeometryT::ComputeHemiHexa6>(group);
204 }
205
206 void applyHemiHexa5(ItemVectorView group)
207 {
208 applyVolumeTemplate<typename GeometryT::ComputeHemiHexa5>(group);
209 }
210
211 void applyAntiWedgeLeft6(ItemVectorView group)
212 {
213 applyVolumeTemplate<typename GeometryT::ComputeAntiWedgeLeft6>(group);
214 }
215
216 void applyAntiWedgeRight6(ItemVectorView group)
217 {
218 applyVolumeTemplate<typename GeometryT::ComputeAntiWedgeRight6>(group);
219 }
220
221 void applyDiTetra5(ItemVectorView group)
222 {
223 applyVolumeTemplate<typename GeometryT::ComputeDiTetra5>(group);
224 }
225
226 void applyDualNode(ItemVectorView group) { ARCANE_UNUSED(group); }
227 void applyDualEdge(ItemVectorView group) { ARCANE_UNUSED(group); }
228 void applyDualFace(ItemVectorView group) { ARCANE_UNUSED(group); }
229 void applyDualCell(ItemVectorView group) { ARCANE_UNUSED(group); }
230 void applyLine3(ItemVectorView group) { ARCANE_UNUSED(group); }
231 void applyLine4(ItemVectorView group) { ARCANE_UNUSED(group); }
232 void applyLine5(ItemVectorView group) { ARCANE_UNUSED(group); }
233 void applyLine9(ItemVectorView group) { ARCANE_UNUSED(group); }
234 void applyLink(ItemVectorView group) { ARCANE_UNUSED(group); }
235};
236
237/*---------------------------------------------------------------------------*/
238/*---------------------------------------------------------------------------*/
239
240} // namespace Arcane::Numerics
241
242/*---------------------------------------------------------------------------*/
243/*---------------------------------------------------------------------------*/
244
245#endif
Various mathematical functions.
Interface of an operator on entities sorted by type.
View on a vector of entities.
Int32 size() const
Number of elements in the vector.
Internal class implementation for TemisGeometryService and Euclidian3GeometryService.
Class managing a 3-dimensional real vector.
Definition Real3.h:132
1D data vector with value semantics (STL style).
Real normeR3(Real3 v1)
Norm of a vector.
Definition MathUtils.h:684
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
double Real
Type representing a real number.