Arcane  v4.1.10.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
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/* Opération sur une forme géométrique. */
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 * \ingroup ArcaneGeometric
33 * \brief Classe template pour appliquer spécifique à une vue sur une forme géométrique.
34 *
35 * Cette classe permet de fournir un opérateur implémentant IItemOperationByBasicType
36 * à partir d'une instance de OperationFunction qui utilise des vues
37 * spécifiques sur des formes géométriques (les classes dérivées de GeomShapeView).
38 *
39 * La classe \a OperationFunction doit fournir une méthode apply() pour chaque type de forme
40 * géométrique (Hexaedron8ShapeView, Quad4ShapeView, ...)
41 *
42 * L'appel se fait ensuite avec un groupe de mailles (CellGroup) en appelant
43 * la méthode ItemGroup::applyOperation() avec cette instance en argument:
44 *
45 \code
46 * // Définition de l'opération
47 * class MyFunc
48 * {
49 * public:
50 * void apply(Hexaedron8ShapeView view)
51 * {
52 * // Applique l'opération pour un hexaèdre.
53 * }
54 * };
55 *
56 * GeomShapeOperation<MyFunc> op;
57 * CellGroup cells;
58 * // Applique \a op sur le groupe \a cells
59 * cells.applyOperation(&op);
60 \endcode
61 */
62template<typename OperationFunction>
65{
66 public:
67 /*!
68 * \brief Construit l'opérateur.
69 *
70 * Le premier argument est de type \a GeomShapeMng et sert à initialiser
71 * l'opérateur. Les arguments suivants éventuels sont directement passés au
72 * constructeur de OperationFunction.
73 *
74 * \a shape_mng doit avoir été initialisé avant de pouvoir appliquer les opérations.
75 */
76 template<typename ... BuildArgs>
77 GeomShapeOperation(GeomShapeMng& shape_mng,BuildArgs ... compute_function_args)
78 : m_shape_mng(shape_mng),
79 m_operation_function(compute_function_args ...)
80 {
81 }
82
83 template<typename ShapeType>
84 void apply(ItemVectorView cells)
85 {
86 ShapeType generic;
87 ENUMERATE_CELL(i_cell,cells){
88 Cell cell = *i_cell;
89 m_shape_mng.initShape(generic,cell);
90 m_operation_function.apply(generic);
91 }
92 }
93
94 void applyTriangle3(ItemVectorView cells)
95 {
96 apply<TriangleShapeView>(cells);
97 }
98 void applyQuad4(ItemVectorView cells)
99 {
100 apply<QuadShapeView>(cells);
101 }
102 void applyPentagon5(ItemVectorView cells)
103 {
104 apply<PentagonShapeView>(cells);
105 }
106 void applyHexagon6(ItemVectorView cells)
107 {
108 apply<HexagonShapeView>(cells);
109 }
110
111 void applyTetraedron4(ItemVectorView cells)
112 {
113 apply<TetraShapeView>(cells);
114 }
115 void applyPyramid5(ItemVectorView cells)
116 {
117 apply<PyramidShapeView>(cells);
118 }
119 void applyPentaedron6(ItemVectorView cells)
120 {
121 apply<PentaShapeView>(cells);
122 }
123 void applyHexaedron8(ItemVectorView cells)
124 {
125 apply<HexaShapeView>(cells);
126 }
127 void applyHeptaedron10(ItemVectorView cells)
128 {
129 apply<Wedge7ShapeView>(cells);
130 }
131 void applyOctaedron12(ItemVectorView cells)
132 {
133 apply<Wedge8ShapeView>(cells);
134 }
135
136 public:
137 //! Instance de l'opérateur
138 OperationFunction& operation() { return m_operation_function; }
139 //! Gestionnaire associé
140 GeomShapeMng& cellShapeMng() { return m_shape_mng; }
141 private:
142
143 GeomShapeMng m_shape_mng;
144 OperationFunction m_operation_function;
145};
146
147/*---------------------------------------------------------------------------*/
148/*---------------------------------------------------------------------------*/
149
150} // namespace Arcane::geometric
151
152/*---------------------------------------------------------------------------*/
153/*---------------------------------------------------------------------------*/
154
155#endif
#define ENUMERATE_CELL(name, group)
Enumérateur générique d'un groupe de mailles.
Opérateur abstrait sur des entités rangées par type.
Maille d'un maillage.
Definition Item.h:1214
Vue sur un vecteur d'entités.
Classe gérant les GeomShape des mailles d'un maillage.
void initShape(GeomShapeView &ge, Cell cell) const
Initialise la vue ge avec les informations de la maille cell.
OperationFunction & operation()
Instance de l'opérateur.
GeomShapeMng & cellShapeMng()
Gestionnaire associé
GeomShapeOperation(GeomShapeMng &shape_mng, BuildArgs ... compute_function_args)
Construit l'opérateur.