Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
GeomShapeOperation.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/* GeomShapeOperation.h (C) 2000-2026 */
9/* */
10/* Operation on a geometric shape. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_GEOMETRIC_GEOMETRICOPERATION_H
13#define ARCANE_GEOMETRIC_GEOMETRICOPERATION_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/TraceAccessor.h"
18
19#include "arcane/core/AbstractItemOperationByBasicType.h"
20
21#include "arcane/geometry/GeomShapeView.h"
22#include "arcane/geometry/GeomShapeMng.h"
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27namespace Arcane::geometric
28{
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32/*!
33 * \ingroup ArcaneGeometric
34 * \brief Template class to apply specific operations to a geometric shape view.
35 *
36 * This class allows providing an operator implementing IItemOperationByBasicType
37 * from an instance of OperationFunction that uses views
38 * specific to geometric shapes (the derived classes of GeomShapeView).
39 *
40 * The class \a OperationFunction must provide an apply() method for each shape
41 * geometric type (Hexaedron8ShapeView, Quad4ShapeView, ...)
42 *
43 * The call is then made with a group of cells (CellGroup) by calling
44 * the ItemGroup::applyOperation() method with this instance as an argument:
45 *
46 \code
47 * // Definition of the operation
48 * class MyFunc
49 * {
50 * public:
51 * void apply(Hexaedron8ShapeView view)
52 * {
53 * // Applies the operation for a hexahedron.
54 * }
55 * };
56 *
57 * GeomShapeOperation<MyFunc> op;
58 * CellGroup cells;
59 * // Applies \a op on the group \a cells
60 * cells.applyOperation(&op);
61 \endcode
62 */
63template <typename OperationFunction>
66{
67 public:
68
69 /*!
70 * \brief Constructs the operator.
71 *
72 * The first argument is of type \a GeomShapeMng and is used to initialize
73 * the operator. Subsequent optional arguments are passed directly to the
74 * OperationFunction constructor.
75 *
76 * \a shape_mng must have been initialized before operations can be applied.
77 */
78 template <typename... BuildArgs>
79 GeomShapeOperation(GeomShapeMng& shape_mng, BuildArgs... compute_function_args)
80 : m_shape_mng(shape_mng)
81 , m_operation_function(compute_function_args...)
82 {
83 }
84
85 template <typename ShapeType>
86 void apply(ItemVectorView cells)
87 {
88 ShapeType generic;
89 ENUMERATE_CELL (i_cell, cells) {
90 Cell cell = *i_cell;
91 m_shape_mng.initShape(generic, cell);
92 m_operation_function.apply(generic);
93 }
94 }
95
96 void applyTriangle3(ItemVectorView cells)
97 {
98 apply<TriangleShapeView>(cells);
99 }
100 void applyQuad4(ItemVectorView cells)
101 {
102 apply<QuadShapeView>(cells);
103 }
104 void applyPentagon5(ItemVectorView cells)
105 {
106 apply<PentagonShapeView>(cells);
107 }
108 void applyHexagon6(ItemVectorView cells)
109 {
110 apply<HexagonShapeView>(cells);
111 }
112
113 void applyTetraedron4(ItemVectorView cells)
114 {
115 apply<TetraShapeView>(cells);
116 }
117 void applyPyramid5(ItemVectorView cells)
118 {
119 apply<PyramidShapeView>(cells);
120 }
121 void applyPentaedron6(ItemVectorView cells)
122 {
123 apply<PentaShapeView>(cells);
124 }
125 void applyHexaedron8(ItemVectorView cells)
126 {
127 apply<HexaShapeView>(cells);
128 }
129 void applyHeptaedron10(ItemVectorView cells)
130 {
131 apply<Wedge7ShapeView>(cells);
132 }
133 void applyOctaedron12(ItemVectorView cells)
134 {
135 apply<Wedge8ShapeView>(cells);
136 }
137
138 public:
139
140 //! Operator instance
141 OperationFunction& operation() { return m_operation_function; }
142 //! Associated manager
143 GeomShapeMng& cellShapeMng() { return m_shape_mng; }
144
145 private:
146
147 GeomShapeMng m_shape_mng;
148 OperationFunction m_operation_function;
149};
150
151/*---------------------------------------------------------------------------*/
152/*---------------------------------------------------------------------------*/
153
154} // namespace Arcane::geometric
155
156/*---------------------------------------------------------------------------*/
157/*---------------------------------------------------------------------------*/
158
159#endif
#define ENUMERATE_CELL(name, group)
Generic enumerator for a cell group.
Abstract operator on entities sorted by type.
Cell of a mesh.
Definition Item.h:1300
View on a vector of entities.
Class managing the GeomShapes of a mesh.
void initShape(GeomShapeView &ge, Cell cell) const
Initializes the view ge with the information of the cell cell.
OperationFunction & operation()
Operator instance.
GeomShapeMng & cellShapeMng()
Associated manager.
GeomShapeOperation(GeomShapeMng &shape_mng, BuildArgs... compute_function_args)
Constructs the operator.