Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
BarycentricGeomShapeComputer.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 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/* BarycentricGeomShapeComputer.cc (C) 2000-2014 */
9/* */
10/* Calcul des GeomShape en utilisant les barycentres. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/IMesh.h"
15
16#include "arcane/AbstractItemOperationByBasicType.h"
17
18#include "arcane/geometric/BarycentricGeomShapeComputer.h"
19#include "arcane/geometric/GeomShapeMng.h"
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24ARCANE_BEGIN_NAMESPACE
25GEOMETRIC_BEGIN_NAMESPACE
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
32template <> void BarycentricGeomShapeComputer::
33compute<GeomType::Quad4>(GeomShapeMutableView elem)
34{
35 const Real3 nul_vector = Real3(0.,0.,0.);
36
37 // Calcule la position du centre.
39
40 for( Integer i = 0; i<4; ++i ){
41 c += elem.node(i);
42 }
43 elem.setCenter(0.25 * c);
44
45 // Calcul la position des centres des faces.
46 _setFace2D(0, elem, 0 , 1);
47 _setFace2D(1, elem, 1 , 2);
48 _setFace2D(2, elem, 2 , 3);
49 _setFace2D(3, elem, 3 , 0);
50}
51
55void BarycentricGeomShapeComputer::
56computeQuad4(GeomShapeMutableView elem)
57{
59}
60
61/*---------------------------------------------------------------------------*/
62/*---------------------------------------------------------------------------*/
68template <> void BarycentricGeomShapeComputer::
69compute<GeomType::Triangle3>(GeomShapeMutableView elem)
70{
71 const Real3 nul_vector = Real3(0.,0.,0.);
72
74
75 // Calcule la position du centre.
76 for( Integer i = 0; i<3; ++i )
77 c += elem.node(i);
78
79 elem.setCenter(c / 3.0);
80
81 // Calcul la position des barycentres des faces.
82 _setFace2D(0, elem, 0 , 1);
83 _setFace2D(1, elem, 1 , 2);
84 _setFace2D(2, elem, 2 , 0);
85
86 elem.setFace(3, elem.node(0));
87}
88
94void BarycentricGeomShapeComputer::
95computeTriangle3(GeomShapeMutableView elem)
96{
98}
99
100/*---------------------------------------------------------------------------*/
101/*---------------------------------------------------------------------------*/
105template <> void BarycentricGeomShapeComputer::
106compute<GeomType::Hexaedron8>(GeomShapeMutableView elem)
107{
108 const Real3 nul_vector = Real3(0.,0.,0.);
109
110 // Calcule la position du centre.
112
113 for( Integer i = 0; i<8; ++i )
114 c += elem.node(i);
115
116 elem.setCenter(0.125 * c);
117
118 // Calcul la position des centres des faces.
119 _setFace3D(0, elem, 0 , 3 , 2 , 1);
120 _setFace3D(1, elem, 0 , 4 , 7 , 3);
121 _setFace3D(2, elem, 0 , 1 , 5 , 4);
122 _setFace3D(3, elem, 4 , 5 , 6 , 7);
123 _setFace3D(4, elem, 1 , 2 , 6 , 5);
124 _setFace3D(5, elem, 2 , 3 , 7 , 6);
125}
126
130void BarycentricGeomShapeComputer::
131computeHexaedron8(GeomShapeMutableView elem)
132{
134}
135
136/*---------------------------------------------------------------------------*/
137/*---------------------------------------------------------------------------*/
141template<> void BarycentricGeomShapeComputer::
142compute<GeomType::Pyramid5>(GeomShapeMutableView elem)
143{
144 const Real3 nul_vector = Real3(0.,0.,0.);
145
146 // Calcule la position du centre.
148
149 for( Integer i = 0; i<5; ++i )
150 c += elem.node(i);
151 elem.setCenter(0.2 * c);
152
153 // Calcul la position des barycentres des faces.
154 _setFace3D(0, elem, 0, 3, 2, 1);
155 _setFace3D(1, elem, 0, 4, 3);
156 _setFace3D(2, elem, 0, 1, 4);
157 _setFace3D(3, elem, 1, 2, 4);
158 _setFace3D(4, elem, 2, 3, 4);
159
160 // Pour compatibilite avec pyra_face_connectic
161 elem.setFace(5, elem.node(4));
162}
163
167void BarycentricGeomShapeComputer::
168computePyramid5(GeomShapeMutableView elem)
169{
171}
172
173/*---------------------------------------------------------------------------*/
174/*---------------------------------------------------------------------------*/
178template<> void BarycentricGeomShapeComputer::
179compute<GeomType::Pentaedron6>(GeomShapeMutableView elem)
180{
181 const Real3 nul_vector = Real3(0.,0.,0.);
182
183 // Calcule la position du centre.
185
186 for( Integer i = 0; i<6; ++i )
187 c += elem.node(i);
188
189 elem.setCenter( (1./6.) * c );
190
191 _setFace3D(0, elem, 0, 2, 1);
192 _setFace3D(1, elem, 0, 3, 5, 2);
193 _setFace3D(2, elem, 0, 1, 4, 3);
194 _setFace3D(3, elem, 3, 4, 5);
195 _setFace3D(4, elem, 1, 2, 5, 4);
196}
197
201void BarycentricGeomShapeComputer::
202computePentaedron6(GeomShapeMutableView elem)
203{
205}
206
207/*---------------------------------------------------------------------------*/
208/*---------------------------------------------------------------------------*/
212template<> void BarycentricGeomShapeComputer::
213compute<GeomType::Tetraedron4>(GeomShapeMutableView elem)
214{
215 const Real3 nul_vector = Real3(0.,0.,0.);
216
217 // Calcule la position du centre.
219
220 for( Integer i = 0; i<4; ++i ){
221 c += elem.node(i);
222 }
223
224 elem.setCenter(0.25 * c);
225
226 _setFace3D(0, elem, 0, 2, 1);
227 _setFace3D(1, elem, 0, 3, 2);
228 _setFace3D(2, elem, 0, 1, 3);
229 _setFace3D(3, elem, 3, 1, 2);
230}
231
235void BarycentricGeomShapeComputer::
236computeTetraedron4(GeomShapeMutableView elem)
237{
239}
240
241/*---------------------------------------------------------------------------*/
242/*---------------------------------------------------------------------------*/
246template<> void BarycentricGeomShapeComputer::
247compute<GeomType::Heptaedron10>(GeomShapeMutableView elem)
248{
249 const Real3 nul_vector = Real3(0.,0.,0.);
250
251 // Calcule la position du centre.
253
254 for( Integer i = 0; i<10; ++i )
255 {
256 c += elem.node(i);
257 }
258 elem.setCenter( 0.1 * c );
259
260 elem.setFace(0, 0.2 * ( elem.node(0) + elem.node(4) + elem.node(3) + elem.node(2) + elem.node(1) ));
261 elem.setFace(1, 0.2 * ( elem.node(5) + elem.node(6) + elem.node(7) + elem.node(8) + elem.node(9) ));
262
263 _setFace3D(2, elem, 0, 1, 6, 5);
264 _setFace3D(3, elem, 1, 2, 7, 6);
265 _setFace3D(4, elem, 2, 3, 8, 7);
266 _setFace3D(5, elem, 3, 4, 9, 8);
267 _setFace3D(6, elem, 4, 0, 5, 9);
268}
269
273void BarycentricGeomShapeComputer::
274computeHeptaedron10(GeomShapeMutableView elem)
275{
277}
278
279/*---------------------------------------------------------------------------*/
280/*---------------------------------------------------------------------------*/
284template<> void BarycentricGeomShapeComputer::
285compute<GeomType::Octaedron12>(GeomShapeMutableView elem)
286{
287 const Real3 nul_vector = Real3(0.,0.,0.);
288
289 // Calcule la position du centre.
291
292 for( Integer i = 0; i<12; ++i ){
293 c += elem.node(i);
294 }
295
296 elem.setCenter( (1./12.) * c );
297
298 elem.setFace(0, (1./6.) * ( elem.node(0) + elem.node(5) + elem.node( 4) + elem.node( 3) + elem.node( 2) + elem.node( 1) ));
299 elem.setFace(1, (1./6.) * ( elem.node(6) + elem.node(7) + elem.node( 8) + elem.node( 9) + elem.node(10) + elem.node(11) ));
300 _setFace3D(2, elem, 0, 1, 7, 6);
301 _setFace3D(3, elem, 1, 2, 8, 7);
302 _setFace3D(4, elem, 2, 3, 9, 8);
303 _setFace3D(5, elem, 3, 4, 10, 9);
304 _setFace3D(6, elem, 4, 5, 11, 10);
305 _setFace3D(7, elem, 5, 0, 6, 11);
306}
307
311void BarycentricGeomShapeComputer::
312computeOctaedron12(GeomShapeMutableView elem)
313{
315}
316
317/*---------------------------------------------------------------------------*/
318/*---------------------------------------------------------------------------*/
319
320void BarycentricGeomShapeComputer::
321computeAll(GeomShapeMutableView elem,const VariableNodeReal3& coords,Cell cell)
322{
323 setNodes(elem,coords,cell);
324
325 switch((GeomType)cell.type()){
326 case GeomType::Hexaedron8: computeHexaedron8(elem); return;
327 case GeomType::Pyramid5: computePyramid5(elem); return;
328 case GeomType::Pentaedron6: computePentaedron6(elem); return;
329 case GeomType::Tetraedron4: computeTetraedron4(elem); return;
330 case GeomType::Heptaedron10: computeHeptaedron10(elem); return;
331 case GeomType::Octaedron12: computeOctaedron12(elem); return;
332 case GeomType::Quad4: computeQuad4(elem); return;
333 case GeomType::Triangle3: computeTriangle3(elem); return;
334 default :
335 throw FatalErrorException(A_FUNCINFO,"Invalid cell type for compute");
336 }
337}
338
339/*---------------------------------------------------------------------------*/
340/*---------------------------------------------------------------------------*/
341
344{
345 GeomShapeMng m_shape_mng;
346 VariableNodeReal3 m_node_coords;
347 public:
349 : m_shape_mng(shape_mng), m_node_coords(node_coords)
350 {
351 }
352
353 template<GeomType ItemType> void
354 _applyGeneric(ItemVectorView cells)
355 {
356 ENUMERATE_CELL(i_cell,cells){
357 Cell cell = *i_cell;
359 BarycentricGeomShapeComputer::setNodes(shape_view,m_node_coords,cell);
360 BarycentricGeomShapeComputer::compute<ItemType>(shape_view);
361 }
362 }
363
364 void applyVertex(ItemVectorView cells) override
365 {
366 ARCANE_UNUSED(cells);
367 throw NotImplementedException(A_FUNCINFO);
368 }
369 void applyLine2(ItemVectorView cells) override
370 {
371 ARCANE_UNUSED(cells);
372 throw NotImplementedException(A_FUNCINFO);
373 }
374 void applyPentagon5(ItemVectorView cells) override
375 {
376 ARCANE_UNUSED(cells);
377 throw NotImplementedException(A_FUNCINFO);
378 }
379 void applyHexagon6(ItemVectorView cells) override
380 {
381 ARCANE_UNUSED(cells);
382 throw NotImplementedException(A_FUNCINFO);
383 }
384
385 void applyQuad4(ItemVectorView cells) override
386 {
388 }
389 void applyTriangle3(ItemVectorView cells) override
390 {
392 }
393
394 void applyHexaedron8(ItemVectorView cells) override
395 {
397 }
398
399 void applyPyramid5(ItemVectorView cells) override
400 {
402 }
403
404 void applyPentaedron6(ItemVectorView cells) override
405 {
407 }
408
409 void applyTetraedron4(ItemVectorView cells) override
410 {
412 }
413
414 void applyHeptaedron10(ItemVectorView cells) override
415 {
417 }
418
419 void applyOctaedron12(ItemVectorView cells) override
420 {
422 }
423};
424
425
426/*---------------------------------------------------------------------------*/
427/*---------------------------------------------------------------------------*/
428
429void BarycentricGeomShapeComputer::
430computeAll(GeomShapeMng& shape_mng,VariableNodeReal3& coords,const CellGroup& cells)
431{
433 cells.applyOperation(&s);
434}
435
436/*---------------------------------------------------------------------------*/
437/*---------------------------------------------------------------------------*/
438
439GEOMETRIC_END_NAMESPACE
440ARCANE_END_NAMESPACE
441
442/*---------------------------------------------------------------------------*/
443/*---------------------------------------------------------------------------*/
444
#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:1178
Classe gérant les GeomShape des mailles d'un maillage.
GeomShapeMutableView mutableShapeView(Cell cell)
Retourne une vue modifiable sur la GeomShape de la maille cell.
Vue modifiable sur un GeomShape.
Enumération spécifiant le type de polygone ou polyèdre associé à un élément ou une forme géométrique.
Definition GeomType.h:45
void applyOperation(IItemOperationByBasicType *operation) const
Applique l'opération operation sur les entités du groupe.
Definition ItemGroup.cc:530
Vue sur un vecteur d'entités.
Int16 type() const
Type de l'entité
Definition Item.h:232
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Classe gérant un vecteur de réel de dimension 3.
Definition Real3.h:132
Exception lorsqu'une erreur fatale est survenue.
Exception lorsqu'une fonction n'est pas implémentée.