Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
GeomShapeView.cc
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.cc (C) 2000-2026 */
9/* */
10/* Management of 2D and 3D geometric shapes. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/TraceAccessor.h"
15
16#include "arcane/geometry/GeomElement.h"
17#include "arcane/geometry/GeomShapeView.h"
18#include "arcane/geometry/CellConnectivity.h"
19//#include "arcane/geometric/CellGeomList.h"
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane::geometric
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29/*
30 * TODO: Verify that the IT_* correspond to the GeomType enumerations.
31 */
32/*---------------------------------------------------------------------------*/
33/*---------------------------------------------------------------------------*/
34
35class GeomShapeConnectivity
36{
37 public:
38
39 GeomShapeConnectivity()
40 {
41 for (int i = 0; i < NB_BASIC_ITEM_TYPE; ++i)
42 GeomShapeView::global_cell_connectivity[i] = 0;
43
44 GeomShapeView::global_cell_connectivity[IT_NullType] = &m_null_connectivity;
45 GeomShapeView::global_cell_connectivity[IT_Vertex] = &m_vertex_connectivity;
46 GeomShapeView::global_cell_connectivity[IT_Line2] = &m_line2_connectivity;
47 GeomShapeView::global_cell_connectivity[IT_Triangle3] = &m_triangle3_connectivity;
48 GeomShapeView::global_cell_connectivity[IT_Quad4] = &m_quad4_connectivity;
49 GeomShapeView::global_cell_connectivity[IT_Pentagon5] = &m_pentagon5_connectivity;
50 GeomShapeView::global_cell_connectivity[IT_Hexagon6] = &m_hexagon6_connectivity;
51 GeomShapeView::global_cell_connectivity[IT_Tetraedron4] = &m_tetraedron4_connectivity;
52 GeomShapeView::global_cell_connectivity[IT_Pyramid5] = &m_pyramid5_connectivity;
53 GeomShapeView::global_cell_connectivity[IT_Pentaedron6] = &m_pentaedron6_connectivity;
54 GeomShapeView::global_cell_connectivity[IT_Hexaedron8] = &m_hexaedron8_connectivity;
55 GeomShapeView::global_cell_connectivity[IT_Heptaedron10] = &m_heptaedron10_connectivity;
56 GeomShapeView::global_cell_connectivity[IT_Octaedron12] = &m_octaedron12_connectivity;
57 }
58
59 public:
60
61 NullConnectivity m_null_connectivity;
62 VertexConnectivity m_vertex_connectivity;
63 Line2Connectivity m_line2_connectivity;
64 Triangle3Connectivity m_triangle3_connectivity;
65 Quad4Connectivity m_quad4_connectivity;
66 Pentagon5Connectivity m_pentagon5_connectivity;
67 Hexagon6Connectivity m_hexagon6_connectivity;
68 Tetraedron4Connectivity m_tetraedron4_connectivity;
69 Pyramid5Connectivity m_pyramid5_connectivity;
70 Pentaedron6Connectivity m_pentaedron6_connectivity;
71 Hexaedron8Connectivity m_hexaedron8_connectivity;
72 Heptaedron10Connectivity m_heptaedron10_connectivity;
73 Octaedron12Connectivity m_octaedron12_connectivity;
74};
75
76/*---------------------------------------------------------------------------*/
77/*---------------------------------------------------------------------------*/
78
79void GeomShapeView::
80initializeConnectivity()
81{
82 if (global_connectivity)
83 return;
84
85 global_connectivity = new GeomShapeConnectivity();
86}
87
88/*---------------------------------------------------------------------------*/
89/*---------------------------------------------------------------------------*/
90
91CellConnectivity* GeomShapeView::global_cell_connectivity[NB_BASIC_ITEM_TYPE];
92GeomShapeConnectivity* GeomShapeView::global_connectivity = 0;
93
94/*---------------------------------------------------------------------------*/
95/*---------------------------------------------------------------------------*/
96
97/*---------------------------------------------------------------------------*/
98/*---------------------------------------------------------------------------*/
99
100class GeomShapeStdBuilder
101: public GeomShapeMutableView
102{
103 public:
104
105 GeomShapeStdBuilder(const GeomShapeMutableView& gsv)
106 : GeomShapeMutableView(gsv)
107 {
108 }
109
110 public:
111
112 void computeNodePositionFromHexa(HexaElementConstView hexa);
113 void computeNodePositionFromQuad(QuadElementConstView quad);
114
115 private:
116
117 inline void
118 _addFaceD(Integer fid, Integer id1, Integer id2, Integer id3, Integer id4)
119 {
120 setFace(fid,
121 Real3(0.25 * (node(id1).x + node(id2).x + node(id3).x + node(id4).x),
122 0.25 * (node(id1).y + node(id2).y + node(id3).y + node(id4).y),
123 0.25 * (node(id1).z + node(id2).z + node(id3).z + node(id4).z)));
124 }
125
126 inline void
127 _addFace2D(Integer fid, Integer id1, Integer id2)
128 {
129 setFace(fid,
130 Real3(0.5 * (node(id1).x + node(id2).x),
131 0.5 * (node(id1).y + node(id2).y),
132 0.0));
133 }
134};
135
136/*---------------------------------------------------------------------------*/
137/*---------------------------------------------------------------------------*/
138
140initFromHexa(HexaElementConstView hexa, GeomShape& geom_cell)
141{
142 _setNullItem(IT_Hexaedron8);
143
144 GeomShapeStdBuilder s(geom_cell.toMutableView());
146
147 geom_cell._setArray(*this);
148}
149
150/*---------------------------------------------------------------------------*/
151/*---------------------------------------------------------------------------*/
152
154initFromQuad(QuadElementConstView quad, GeomShape& geom_cell)
155{
156 _setNullItem(IT_Quad4);
157
158 GeomShapeStdBuilder s(geom_cell.toMutableView());
160
161 geom_cell._setArray(*this);
162}
163
164/*---------------------------------------------------------------------------*/
165/*----- Definition of control sub-volumes -----------------------------------*/
166/*---------------------------------------------------------------------------*/
167/*---------------------------------------------------------------------------*/
168/*--------------- In 2D -----------------------------------------------------*/
169
172{
173 const NodeConnectic& nc = nodeConnectic(id);
174
175 sub_zone.init(node(nodeAssociation(id)), face(nc.face(0)), center(), face(nc.face(1)));
176}
177
178/*---------------------------------------------------------------------------*/
179/*---------------------------------------------------------------------------*/
180
183{
184 switch (i) {
185 case 0:
186 sub_zone.init(node(0), face(0), center(), face(3));
187 break;
188 case 1:
189 sub_zone.init(node(1), face(1), center(), face(0));
190 break;
191 case 2:
192 sub_zone.init(node(2), face(2), center(), face(1));
193 break;
194 case 3:
195 sub_zone.init(node(3), face(3), center(), face(2));
196 break;
197 }
198}
199
200/*---------------------------------------------------------------------------*/
201/*---------------------------------------------------------------------------*/
202
205{
206 switch (i) {
207 case 0:
208 sub_zone.init(node(0), face(0), center(), node(0));
209 break;
210 case 1:
211 sub_zone.init(node(1), face(1), center(), face(0));
212 break;
213 case 2:
214 sub_zone.init(node(2), face(2), center(), face(1));
215 break;
216 case 3:
217 sub_zone.init(node(0), node(0), center(), face(2));
218 break;
219 }
220}
221
222/*---------------------------------------------------------------------------*/
223/*---------------------------------------------------------------------------*/
224
226fillSubZonePentagon5(QuadElementView, Integer)
227{
228 throw NotImplementedException(A_FUNCINFO);
229}
230
231/*---------------------------------------------------------------------------*/
232/*---------------------------------------------------------------------------*/
233
235fillSubZoneHexagon6(QuadElementView, Integer)
236{
237 throw NotImplementedException(A_FUNCINFO);
238}
239
240/*---------------------------------------------------------------------------*/
241/*---------------------------------------------------------------------------*/
242
244fillSubZoneElement(HexaElementView sub_zone, Integer i)
245{
246 const NodeConnectic& nc = nodeConnectic(i);
247
248 sub_zone.init(node(nodeAssociation(i)),
249 edge(nc.edge(0)), face(nc.face(0)), edge(nc.edge(1)),
250 edge(nc.edge(2)), face(nc.face(2)), center(), face(nc.face(1)));
251}
252
253/*---------------------------------------------------------------------------*/
254/*---------------------------------------------------------------------------*/
255
257fillSubZoneHexaedron8(HexaElementView sub_zone, Integer i)
258{
259 switch (i) {
260 case 0:
261 sub_zone.init(node(0), edge(0), face(0), edge(3), edge(4), face(2), center(), face(1));
262 break;
263 case 1:
264 sub_zone.init(node(1), edge(1), face(0), edge(0), edge(5), face(4), center(), face(2));
265 break;
266 case 2:
267 sub_zone.init(node(2), edge(2), face(0), edge(1), edge(6), face(5), center(), face(4));
268 break;
269 case 3:
270 sub_zone.init(node(3), edge(3), face(0), edge(2), edge(7), face(1), center(), face(5));
271 break;
272 case 4:
273 sub_zone.init(node(4), edge(11), face(3), edge(8), edge(4), face(1), center(), face(2));
274 break;
275 case 5:
276 sub_zone.init(node(5), edge(8), face(3), edge(9), edge(5), face(2), center(), face(4));
277 break;
278 case 6:
279 sub_zone.init(node(6), edge(9), face(3), edge(10), edge(6), face(4), center(), face(5));
280 break;
281 case 7:
282 sub_zone.init(node(7), edge(10), face(3), edge(11), edge(7), face(5), center(), face(1));
283 break;
284 }
285}
286
287/*---------------------------------------------------------------------------*/
288/*---------------------------------------------------------------------------*/
289
291fillSubZonePyramid5(HexaElementView sub_zone, Integer i)
292{
293 switch (i) {
294 case 0:
295 sub_zone.init(node(0), edge(0), face(0), edge(3), edge(4), face(2), center(), face(1));
296 break;
297 case 1:
298 sub_zone.init(node(1), edge(1), face(0), edge(0), edge(5), face(3), center(), face(2));
299 break;
300 case 2:
301 sub_zone.init(node(2), edge(2), face(0), edge(1), edge(6), face(4), center(), face(3));
302 break;
303 case 3:
304 sub_zone.init(node(3), edge(3), face(0), edge(2), edge(7), face(1), center(), face(4));
305 break;
306 case 4:
307 sub_zone.init(node(4), node(4), node(4), node(4), edge(4), face(1), center(), face(2));
308 break;
309 case 5:
310 sub_zone.init(node(4), node(4), node(4), node(4), edge(5), face(2), center(), face(3));
311 break;
312 case 6:
313 sub_zone.init(node(4), node(4), node(4), node(4), edge(6), face(3), center(), face(4));
314 break;
315 case 7:
316 sub_zone.init(node(4), node(4), node(4), node(4), edge(7), face(4), center(), face(1));
317 break;
318 }
319}
320
321/*---------------------------------------------------------------------------*/
322/*---------------------------------------------------------------------------*/
323
325fillSubZonePentaedron6(HexaElementView sub_zone, Integer i)
326{
327 switch (i) {
328 case 0:
329 sub_zone.init(node(0), edge(0), face(0), edge(2), edge(3), face(2), center(), face(1));
330 break;
331 case 1:
332 sub_zone.init(node(1), edge(1), face(0), edge(0), edge(4), face(4), center(), face(2));
333 break;
334 case 2:
335 sub_zone.init(node(2), edge(2), face(0), edge(1), edge(5), face(1), center(), face(4));
336 break;
337 case 3:
338 sub_zone.init(node(3), edge(8), face(3), edge(6), edge(3), face(1), center(), face(2));
339 break;
340 case 4:
341 sub_zone.init(node(4), edge(6), face(3), edge(7), edge(4), face(2), center(), face(4));
342 break;
343 case 5:
344 sub_zone.init(node(5), edge(7), face(3), edge(8), edge(5), face(4), center(), face(1));
345 break;
346 }
347}
348
349/*---------------------------------------------------------------------------*/
350/*---------------------------------------------------------------------------*/
351
353fillSubZoneTetraedron4(HexaElementView sub_zone, Integer i)
354{
355 switch (i) {
356 case 0:
357 sub_zone.init(node(0), edge(0), face(0), edge(2), edge(3), face(2), center(), face(1));
358 break;
359 case 1:
360 sub_zone.init(node(1), edge(1), face(0), edge(0), edge(4), face(3), center(), face(2));
361 break;
362 case 2:
363 sub_zone.init(node(2), edge(2), face(0), edge(1), edge(5), face(1), center(), face(3));
364 break;
365 case 3:
366 sub_zone.init(node(3), edge(3), face(1), edge(5), edge(4), face(2), center(), face(3));
367 break;
368 }
369}
370
371/*---------------------------------------------------------------------------*/
372/*---------------------------------------------------------------------------*/
373
375fillSubZoneHeptaedron10(HexaElementView sub_zone, Integer i)
376{
377 switch (i) {
378 case 0:
379 sub_zone.init(node(0), edge(0), face(0), edge(4), edge(10), face(2), center(), face(6));
380 break;
381 case 1:
382 sub_zone.init(node(1), edge(1), face(0), edge(0), edge(11), face(3), center(), face(2));
383 break;
384 case 2:
385 sub_zone.init(node(2), edge(2), face(0), edge(1), edge(12), face(4), center(), face(3));
386 break;
387 case 3:
388 sub_zone.init(node(3), edge(3), face(0), edge(2), edge(13), face(5), center(), face(4));
389 break;
390 case 4:
391 sub_zone.init(node(4), edge(4), face(0), edge(3), edge(14), face(6), center(), face(5));
392 break;
393 case 5:
394 sub_zone.init(node(5), edge(9), face(1), edge(5), edge(10), face(6), center(), face(2));
395 break;
396 case 6:
397 sub_zone.init(node(6), edge(5), face(1), edge(6), edge(11), face(2), center(), face(3));
398 break;
399 case 7:
400 sub_zone.init(node(7), edge(6), face(1), edge(7), edge(12), face(3), center(), face(4));
401 break;
402 case 8:
403 sub_zone.init(node(8), edge(7), face(1), edge(8), edge(13), face(4), center(), face(5));
404 break;
405 case 9:
406 sub_zone.init(node(9), edge(8), face(1), edge(9), edge(14), face(5), center(), face(6));
407 break;
408 }
409}
410
411/*---------------------------------------------------------------------------*/
412/*---------------------------------------------------------------------------*/
413
415fillSubZoneOctaedron12(HexaElementView sub_zone, Integer i)
416{
417 switch (i) {
418 case 0:
419 sub_zone.init(node(0), edge(0), face(0), edge(5), edge(12), face(2), center(), face(7));
420 break;
421 case 1:
422 sub_zone.init(node(1), edge(1), face(0), edge(0), edge(13), face(3), center(), face(2));
423 break;
424 case 2:
425 sub_zone.init(node(2), edge(2), face(0), edge(1), edge(14), face(4), center(), face(3));
426 break;
427 case 3:
428 sub_zone.init(node(3), edge(3), face(0), edge(2), edge(15), face(5), center(), face(4));
429 break;
430 case 4:
431 sub_zone.init(node(4), edge(4), face(0), edge(3), edge(16), face(6), center(), face(5));
432 break;
433 case 5:
434 sub_zone.init(node(5), edge(5), face(0), edge(4), edge(17), face(7), center(), face(6));
435 break;
436 case 6:
437 sub_zone.init(node(6), edge(11), face(1), edge(6), edge(12), face(7), center(), face(2));
438 break;
439 case 7:
440 sub_zone.init(node(7), edge(6), face(1), edge(7), edge(13), face(2), center(), face(3));
441 break;
442 case 8:
443 sub_zone.init(node(8), edge(7), face(1), edge(8), edge(14), face(3), center(), face(4));
444 break;
445 case 9:
446 sub_zone.init(node(9), edge(8), face(1), edge(9), edge(15), face(4), center(), face(5));
447 break;
448 case 10:
449 sub_zone.init(node(10), edge(9), face(1), edge(10), edge(16), face(5), center(), face(6));
450 break;
451 case 11:
452 sub_zone.init(node(11), edge(10), face(1), edge(11), edge(17), face(6), center(), face(7));
453 break;
454 }
455}
456
457/*---------------------------------------------------------------------------*/
458/*---------------------------------------------------------------------------*/
459
460/*---------------------------------------------------------------------------*/
461/*---------------------------------------------------------------------------*/
462/*!
463 * \brief In 3D, calculates the positions from the hexahedron \a hexa.
464 */
466computeNodePositionFromHexa(HexaElementConstView hexa)
467{
468 const Real3 nul_vector = Real3(0., 0., 0.);
469
470 // Calculates the center position.
471 Real3 c = nul_vector;
472
473 for (Integer i = 0; i < 8; ++i) {
474 setNode(i, hexa[i]);
475 c += node(i);
476 }
477
478 setCenter(0.125 * c);
479
480 // Calculates the face center positions.
481 _addFaceD(0, 0, 3, 2, 1);
482 _addFaceD(1, 0, 4, 7, 3);
483 _addFaceD(2, 0, 1, 5, 4);
484 _addFaceD(3, 4, 5, 6, 7);
485 _addFaceD(4, 1, 2, 6, 5);
486 _addFaceD(5, 2, 3, 7, 6);
487}
488
489/*---------------------------------------------------------------------------*/
490/*---------------------------------------------------------------------------*/
491/*!
492 * \brief In 2D, calculates the positions from the quad \a quad.
493 */
495computeNodePositionFromQuad(QuadElementConstView quad)
496{
497 const Real3 nul_vector = Real3(0., 0., 0.);
498
499 // Calculates the center position.
500 Real3 c = nul_vector;
501
502 for (Integer i = 0; i < 4; ++i) {
503 setNode(i, quad[i]);
504 c += node(i);
505 }
506
507 setCenter(0.25 * c);
508
509 // Calculates the face center positions.
510 _addFace2D(0, 0, 1);
511 _addFace2D(1, 1, 2);
512 _addFace2D(2, 2, 3);
513 _addFace2D(3, 3, 0);
514}
515
516/*---------------------------------------------------------------------------*/
517/*---------------------------------------------------------------------------*/
518
521{
523
524 view._setNullItem(IT_Hexaedron8);
525
528
529 _setArray(view);
530
531 //view.initFromHexa(hexa,*this);
532 return view;
533}
534
535/*---------------------------------------------------------------------------*/
536/*---------------------------------------------------------------------------*/
537
540{
541 Quad4ShapeView view;
542
543 view._setNullItem(IT_Quad4);
544
547
548 _setArray(view);
549
550 return view;
551}
552
553/*---------------------------------------------------------------------------*/
554/*---------------------------------------------------------------------------*/
555
556} // namespace Arcane::geometric
557
558/*---------------------------------------------------------------------------*/
559/*---------------------------------------------------------------------------*/
Class managing a 3-dimensional real vector.
Definition Real3.h:132
void computeNodePositionFromQuad(QuadElementConstView quad)
In 2D, calculates the positions from the quad quad.
void computeNodePositionFromHexa(HexaElementConstView hexa)
In 3D, calculates the positions from the hexahedron hexa.
const Real3 node(Integer i) const
Position of the i-th node of the shape.
void fillSubZoneHexaedron8(Hexaedron8ElementView svc, Integer i)
Fills svc with the information of the i-th control sub-volume.
void fillSubZoneOctaedron12(Hexaedron8ElementView svc, Integer i)
Fills svc with the information of the i-th control sub-volume.
const Real3 face(Integer i) const
Position of the center of the i-th face of the shape.
void fillSubZoneQuad4(Quad4ElementView svc, Integer i)
Fills svc with the information of the i-th control sub-volume.
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)
void fillSubZoneHeptaedron10(Hexaedron8ElementView svc, Integer i)
Fills svc with the information of the i-th control sub-volume.
void fillSubZoneHexagon6(Quad4ElementView svc, Integer i)
Fills svc with the information of the i-th control sub-volume.
void fillSubZonePentaedron6(Hexaedron8ElementView svc, Integer i)
Fills svc with the information of the i-th control sub-volume.
void fillSubZoneTriangle3(Quad4ElementView svc, Integer i)
Fills svc with the information of the i-th control sub-volume.
void fillSubZoneTetraedron4(Hexaedron8ElementView svc, Integer i)
Fills svc with the information of the i-th control sub-volume.
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.
void fillSubZonePyramid5(Hexaedron8ElementView svc, Integer i)
Fills svc with the information of the i-th control sub-volume.
void fillSubZonePentagon5(Quad4ElementView svc, Integer i)
Fills svc with the information of the i-th control sub-volume.
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.
Hexaedron8ShapeView initFromHexaedron8(Hexaedron8ElementConstView hexa)
Initializes the shape with a hexahedron hexa and returns a view of it.
Quad4ShapeView initFromQuad4(Quad4ElementConstView quad)
Initializes the shape with a quadrangle quad and returns a view of it.
GeomShapeMutableView toMutableView()
Modifiable view of this instance.
Definition GeomShape.h:61
Connectivity information for geometric elements of type GeomType::Heptaedron10.
Connectivity information for geometric elements of type GeomType::Hexaedron8.
Constant view on geometric elements of type GeomType::Hexaedron8.
void init(const Real3 &a0, const Real3 &a1, const Real3 &a2, const Real3 &a3, const Real3 &a4, const Real3 &a5, const Real3 &a6, const Real3 &a7)
Initializes the view with the coordinates passed as arguments.
Specific view on geometric shapes of type GeomType::Hexaedron8.
Connectivity information for geometric elements of type GeomType::Hexagon6.
Connectivity information for geometric elements of type GeomType::Line2.
Connectivity information for geometric elements of type IT_NullType.
Connectivity information for geometric elements of type GeomType::Octaedron12.
Connectivity information for geometric elements of type GeomType::Pentaedron6.
Connectivity information for geometric elements of type GeomType::Pentagon5.
Connectivity information for geometric elements of type GeomType::Pyramid5.
Connectivity information for geometric elements of type GeomType::Quad4.
Constant view on geometric elements of type GeomType::Quad4.
Modifiable view on geometric elements of type GeomType::Quad4.
void init(const Real3 &a0, const Real3 &a1, const Real3 &a2, const Real3 &a3)
Initializes the view with the coordinates passed as arguments.
Specific view on geometric shapes of type GeomType::Quad4.
Connectivity information for geometric elements of type GeomType::Tetraedron4.
Connectivity information for geometric elements of type GeomType::Triangle3.
Connectivity information for geometric elements of type GeomType::Vertex.
Int32 Integer
Type representing an integer.
Local cell connectivity structures.