Arcane  v4.1.4.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
CartesianMeshNumberingMngInternal.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/* CartesianMeshNumberingMngInternal.cc (C) 2000-2026 */
9/* */
10/* Gestionnaire de numérotation de maillage cartesian. La numérotation */
11/* des mailles et des noeuds est assez classique, la numérotation des faces */
12/* est expliquée (entre autres) dans les méthodes 'faceUniqueId()' et */
13/* 'cellFaceUniqueIds()'. */
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/cartesianmesh/internal/CartesianMeshNumberingMngInternal.h"
18
19#include "arcane/utils/Vector2.h"
20#include "arcane/utils/ITraceMng.h"
21
22#include "arcane/core/IMesh.h"
23#include "arcane/core/IParallelMng.h"
24#include "arcane/core/VariableTypes.h"
25#include "arcane/core/ICartesianMeshGenerationInfo.h"
26#include "arcane/core/IItemFamily.h"
27#include "arcane/core/IMeshModifier.h"
28#include "arcane/core/Properties.h"
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
33namespace Arcane
34{
35
36/*---------------------------------------------------------------------------*/
37/*---------------------------------------------------------------------------*/
38
39CartesianMeshNumberingMngInternal::
40CartesianMeshNumberingMngInternal(IMesh* mesh)
41: TraceAccessor(mesh->traceMng())
42, m_mesh(mesh)
43, m_dimension(mesh->dimension())
44, m_pattern(2)
45, m_max_level(0)
46, m_min_level(0)
47, m_converting_numbering_face(true)
48, m_ori_level(0)
49{
50 {
51 const auto* m_generation_info = ICartesianMeshGenerationInfo::getReference(m_mesh, true);
52 ConstArrayView<Int64> global_nb_cells_by_direction = m_generation_info->globalNbCells();
53
54 const Int64x3 nb_cell_ground = {
55 global_nb_cells_by_direction[MD_DirX],
56 global_nb_cells_by_direction[MD_DirY],
57 ((m_dimension == 2) ? 1 : global_nb_cells_by_direction[MD_DirZ])
58 };
59
60 m_nb_cell_ground.x = static_cast<CartCoord>(nb_cell_ground.x);
61 m_nb_cell_ground.y = static_cast<CartCoord>(nb_cell_ground.y);
62 m_nb_cell_ground.z = static_cast<CartCoord>(nb_cell_ground.z);
63
64 if (nb_cell_ground.x <= 0)
65 ARCANE_FATAL("Bad value '{0}' for globalNbCells()[MD_DirX] (should be >0)", nb_cell_ground.x);
66 if (nb_cell_ground.y <= 0)
67 ARCANE_FATAL("Bad value '{0}' for globalNbCells()[MD_DirY] (should be >0)", nb_cell_ground.y);
68 if (nb_cell_ground.z <= 0)
69 ARCANE_FATAL("Bad value '{0}' for globalNbCells()[MD_DirZ] (should be >0)", nb_cell_ground.z);
70
71 if (m_dimension == 2) {
72 m_latest_cell_uid = nb_cell_ground.x * nb_cell_ground.y;
73 m_latest_node_uid = (nb_cell_ground.x + 1) * (nb_cell_ground.y + 1);
74 m_latest_face_uid = (nb_cell_ground.x * nb_cell_ground.y) * 2 + nb_cell_ground.x * 2 + nb_cell_ground.y;
75 }
76 else {
77 m_latest_cell_uid = nb_cell_ground.x * nb_cell_ground.y * nb_cell_ground.z;
78 m_latest_node_uid = (nb_cell_ground.x + 1) * (nb_cell_ground.y + 1) * (nb_cell_ground.z + 1);
79 m_latest_face_uid = (nb_cell_ground.x + 1) * nb_cell_ground.y * nb_cell_ground.z + (nb_cell_ground.y + 1) * nb_cell_ground.z * nb_cell_ground.x + (nb_cell_ground.z + 1) * nb_cell_ground.x * nb_cell_ground.y;
80 }
81 }
82
83 m_first_cell_uid_level.add(0);
84 m_first_node_uid_level.add(0);
85 m_first_face_uid_level.add(0);
86
87 // Tant qu'on utilise la numérotation d'origine pour le niveau 0, on doit utiliser
88 // une conversion de la numérotation d'origine vers la nouvelle.
89 // TODO AH : Ça risque de pas très bien se passer en cas de repartitionnement...
90 if (m_converting_numbering_face) {
91 UniqueArray<Int64> face_uid(CartesianMeshNumberingMngInternal::nbFaceByCell());
92 ENUMERATE_ (Cell, icell, m_mesh->allLevelCells(0)) {
93 CartesianMeshNumberingMngInternal::cellFaceUniqueIds(icell->uniqueId(), 0, face_uid);
94 for (Integer i = 0; i < CartesianMeshNumberingMngInternal::nbFaceByCell(); ++i) {
95 m_face_ori_numbering_to_new[icell->face(i).uniqueId()] = face_uid[i];
96 m_face_new_numbering_to_ori[face_uid[i]] = icell->face(i).uniqueId();
97 // debug() << "Face Ori <-> New -- Ori : " << icell->face(i).uniqueId() << " -- New : " << face_uid[i];
98 }
99 }
100 }
101}
102
103/*---------------------------------------------------------------------------*/
104/*---------------------------------------------------------------------------*/
105
106void CartesianMeshNumberingMngInternal::
107build()
108{
109 m_properties = makeRef(new Properties(*(m_mesh->properties()), "CartesianMeshNumberingMngInternal"));
110}
111
112/*---------------------------------------------------------------------------*/
113/*---------------------------------------------------------------------------*/
114
115void CartesianMeshNumberingMngInternal::
116saveInfosInProperties()
117{
118 m_properties->set("Version", 1);
119 m_properties->set("FirstCellUIDByLevel", m_first_cell_uid_level);
120
121 // Voir pour le recalculer à la reprise.
122 m_properties->set("FirstNodeUIDByLevel", m_first_node_uid_level);
123 m_properties->set("FirstFaceUIDByLevel", m_first_face_uid_level);
124
125 m_properties->set("OriginalGroundLevelForConverting", m_ori_level);
126}
127
128/*---------------------------------------------------------------------------*/
129/*---------------------------------------------------------------------------*/
130
131void CartesianMeshNumberingMngInternal::
132recreateFromDump()
133{
134 Int32 v = m_properties->getInt32("Version");
135 if (v != 1)
136 ARCANE_FATAL("Bad numbering mng version: trying to read from incompatible checkpoint v={0} expected={1}", v, 1);
137
138 m_properties->get("FirstCellUIDByLevel", m_first_cell_uid_level);
139 m_properties->get("FirstNodeUIDByLevel", m_first_node_uid_level);
140 m_properties->get("FirstFaceUIDByLevel", m_first_face_uid_level);
141
142 m_properties->get("OriginalGroundLevelForConverting", m_ori_level);
143 if (m_ori_level == -1) {
144 m_converting_numbering_face = false;
145 m_face_ori_numbering_to_new.clear();
146 m_face_new_numbering_to_ori.clear();
147 }
148
149 m_nb_cell_ground = { globalNbCellsX(0), globalNbCellsY(0), globalNbCellsZ(0) };
150
151 m_max_level = m_first_cell_uid_level.size() - 1;
152
153 {
154 Integer pos = 0;
155 Int64 max = 0;
156 Integer iter = 0;
157 for (const Int64 elem : m_first_cell_uid_level) {
158 if (elem > max) {
159 max = elem;
160 pos = iter;
161 }
162 iter++;
163 }
164 m_latest_cell_uid = m_first_cell_uid_level[pos] + nbCellInLevel(pos);
165 m_latest_node_uid = m_first_node_uid_level[pos] + nbNodeInLevel(pos);
166 m_latest_face_uid = m_first_face_uid_level[pos] + nbFaceInLevel(pos);
167 }
168}
169
170/*---------------------------------------------------------------------------*/
171/*---------------------------------------------------------------------------*/
172
173void CartesianMeshNumberingMngInternal::
174renumberingFacesLevel0FromOriginalArcaneNumbering()
175{
176 if (!m_converting_numbering_face)
177 return;
178
179 info() << "Renumbering faces of level 0...";
180
182 ENUMERATE_ (Cell, icell, m_mesh->allLevelCells(m_ori_level)) {
183 cellFaceUniqueIds(icell->uniqueId(), m_ori_level, face_uid);
184 for (Integer i = 0; i < nbFaceByCell(); ++i) {
185 // debug() << "Face Ori <-> New -- Ori : " << icell->face(i).uniqueId() << " -- New : " << face_uid[i];
186 icell->face(i).mutableItemBase().setUniqueId(face_uid[i]);
187 }
188 }
189 m_mesh->faceFamily()->notifyItemsUniqueIdChanged();
190 m_mesh->modifier()->endUpdate();
191 m_mesh->checkValidMesh();
192
193 m_converting_numbering_face = false;
194 m_ori_level = -1;
195 m_face_ori_numbering_to_new.clear();
196 m_face_new_numbering_to_ori.clear();
197}
198
199/*---------------------------------------------------------------------------*/
200/*---------------------------------------------------------------------------*/
201
202void CartesianMeshNumberingMngInternal::
203printStatus()
204{
205 ITraceMng* tm = m_mesh->traceMng();
206 Trace::Setter _(tm, "CartesianMeshNumberingMngInternal");
207
208 tm->info() << "CartesianMeshNumberingMngInternal status :";
209
210 // tm->info() << "FirstCellUIDByLevel : " << m_first_cell_uid_level;
211 // tm->info() << "FirstNodeUIDByLevel : " << m_first_node_uid_level;
212 // tm->info() << "FirstFaceUIDByLevel : " << m_first_face_uid_level;
213
214 tm->info() << "LatestCellUID : " << m_latest_cell_uid;
215 tm->info() << "LatestNodeUID : " << m_latest_node_uid;
216 tm->info() << "LatestFaceUID : " << m_latest_face_uid;
217
218 tm->info() << "MinLevel : " << m_min_level;
219 tm->info() << "MaxLevel : " << m_max_level;
220
221 tm->info() << "GroundLevelNbCells : " << m_nb_cell_ground;
222
223 if (m_ori_level == -1) {
224 tm->info() << "Ground Level is renumbered";
225 }
226 else {
227 tm->info() << "Ground Level is not renumbered -- OriginalGroundLevel : " << m_ori_level;
228 }
229
230 for (Integer i = m_min_level; i <= m_max_level; ++i) {
231 tm->info() << "Level " << i << " : ";
232 tm->info() << "\tUID Cells : [" << firstCellUniqueId(i) << ", " << (firstCellUniqueId(i) + nbCellInLevel(i)) << "[";
233 tm->info() << "\tUID Nodes : [" << firstNodeUniqueId(i) << ", " << (firstNodeUniqueId(i) + nbNodeInLevel(i)) << "[";
234 tm->info() << "\tUID Faces : [" << firstFaceUniqueId(i) << ", " << (firstFaceUniqueId(i) + nbFaceInLevel(i)) << "[";
235 }
236
237 const auto* m_generation_info = ICartesianMeshGenerationInfo::getReference(m_mesh, true);
238
239 Int64ConstArrayView global_nb_cells_by_direction = m_generation_info->globalNbCells();
240 tm->info() << "global_nb_cells_by_direction.x : " << global_nb_cells_by_direction[MD_DirX];
241 tm->info() << "global_nb_cells_by_direction.y : " << global_nb_cells_by_direction[MD_DirY];
242 tm->info() << "global_nb_cells_by_direction.z : " << global_nb_cells_by_direction[MD_DirZ];
243}
244
245/*---------------------------------------------------------------------------*/
246/*---------------------------------------------------------------------------*/
247
248void CartesianMeshNumberingMngInternal::
249prepareLevel(Int32 level)
250{
251 if (level <= m_max_level && level >= m_min_level)
252 return;
253 if (level == m_max_level + 1) {
254 m_max_level++;
255 m_first_cell_uid_level.add(m_latest_cell_uid);
256 m_first_node_uid_level.add(m_latest_node_uid);
257 m_first_face_uid_level.add(m_latest_face_uid);
258 }
259 else if (level == m_min_level - 1) {
260 m_min_level--;
261 _pushFront(m_first_cell_uid_level, m_latest_cell_uid);
262 _pushFront(m_first_node_uid_level, m_latest_node_uid);
263 _pushFront(m_first_face_uid_level, m_latest_face_uid);
264 }
265 else {
266 ARCANE_FATAL("Level error : {0}", level);
267 }
268
269 m_latest_cell_uid += nbCellInLevel(level);
270 m_latest_node_uid += nbNodeInLevel(level);
271 m_latest_face_uid += nbFaceInLevel(level);
272}
273
274/*---------------------------------------------------------------------------*/
275/*---------------------------------------------------------------------------*/
276
277void CartesianMeshNumberingMngInternal::
278updateFirstLevel()
279{
280 const Int32 nb_levels_to_add = -m_min_level;
281 m_ori_level += nb_levels_to_add;
282
283 if (nb_levels_to_add == 0) {
284 return;
285 }
286
287 m_max_level += nb_levels_to_add;
288 m_min_level += nb_levels_to_add;
289
290 const Integer to_div = m_pattern * nb_levels_to_add;
291 if (m_dimension == 2) {
292 m_nb_cell_ground.x /= to_div;
293 m_nb_cell_ground.y /= to_div;
294 // z reste à 1.
295 }
296 else {
297 m_nb_cell_ground /= to_div;
298 }
299
300 // ----------
301 // CartesianMeshCoarsening2::_recomputeMeshGenerationInfo()
302 // Recalcule les informations sur le nombre de mailles par direction.
303 auto* cmgi = ICartesianMeshGenerationInfo::getReference(m_mesh, false);
304 if (!cmgi)
305 return;
306
307 {
308 ConstArrayView<Int64> v = cmgi->ownCellOffsets();
309 cmgi->setOwnCellOffsets(v[0] / to_div, v[1] / to_div, v[2] / to_div);
310 }
311 {
312 ConstArrayView<Int64> v = cmgi->globalNbCells();
313 cmgi->setGlobalNbCells(v[0] / to_div, v[1] / to_div, v[2] / to_div);
314 }
315 {
316 ConstArrayView<Int32> v = cmgi->ownNbCells();
317 cmgi->setOwnNbCells(v[0] / to_div, v[1] / to_div, v[2] / to_div);
318 }
319 cmgi->setFirstOwnCellUniqueId(firstCellUniqueId(0));
320 // CartesianMeshCoarsening2::_recomputeMeshGenerationInfo()
321 // ----------
322}
323
324/*---------------------------------------------------------------------------*/
325/*---------------------------------------------------------------------------*/
326
327Int64 CartesianMeshNumberingMngInternal::
328firstCellUniqueId(Int32 level) const
329{
330 return m_first_cell_uid_level[level - m_min_level];
331}
332
333/*---------------------------------------------------------------------------*/
334/*---------------------------------------------------------------------------*/
335
336Int64 CartesianMeshNumberingMngInternal::
337firstNodeUniqueId(Int32 level) const
338{
339 return m_first_node_uid_level[level - m_min_level];
340}
341
342/*---------------------------------------------------------------------------*/
343/*---------------------------------------------------------------------------*/
344
345Int64 CartesianMeshNumberingMngInternal::
346firstFaceUniqueId(Int32 level) const
347{
348 return m_first_face_uid_level[level - m_min_level];
349}
350
351/*---------------------------------------------------------------------------*/
352/*---------------------------------------------------------------------------*/
353
354CartCoord CartesianMeshNumberingMngInternal::
355globalNbCellsX(Int32 level) const
356{
357 return static_cast<CartCoord>(static_cast<Real>(m_nb_cell_ground.x) * std::pow(m_pattern, level));
358}
359
360/*---------------------------------------------------------------------------*/
361/*---------------------------------------------------------------------------*/
362
363CartCoord CartesianMeshNumberingMngInternal::
364globalNbCellsY(Int32 level) const
365{
366 return static_cast<CartCoord>(static_cast<Real>(m_nb_cell_ground.y) * std::pow(m_pattern, level));
367}
368
369/*---------------------------------------------------------------------------*/
370/*---------------------------------------------------------------------------*/
371
372CartCoord CartesianMeshNumberingMngInternal::
373globalNbCellsZ(Int32 level) const
374{
375 return static_cast<CartCoord>(static_cast<Real>(m_nb_cell_ground.z) * std::pow(m_pattern, level));
376}
377
378/*---------------------------------------------------------------------------*/
379/*---------------------------------------------------------------------------*/
380
381CartCoord CartesianMeshNumberingMngInternal::
382globalNbNodesX(Int32 level) const
383{
384 return globalNbCellsX(level) + 1;
385}
386
387/*---------------------------------------------------------------------------*/
388/*---------------------------------------------------------------------------*/
389
390CartCoord CartesianMeshNumberingMngInternal::
391globalNbNodesY(Int32 level) const
392{
393 return globalNbCellsY(level) + 1;
394}
395
396/*---------------------------------------------------------------------------*/
397/*---------------------------------------------------------------------------*/
398
399CartCoord CartesianMeshNumberingMngInternal::
400globalNbNodesZ(Int32 level) const
401{
402 return globalNbCellsZ(level) + 1;
403}
404
405/*---------------------------------------------------------------------------*/
406/*---------------------------------------------------------------------------*/
407
408CartCoord CartesianMeshNumberingMngInternal::
409globalNbFacesX(Int32 level) const
410{
411 return globalNbCellsX(level) + 1;
412}
413
414/*---------------------------------------------------------------------------*/
415/*---------------------------------------------------------------------------*/
416
417CartCoord CartesianMeshNumberingMngInternal::
418globalNbFacesY(Int32 level) const
419{
420 return globalNbCellsY(level) + 1;
421}
422
423/*---------------------------------------------------------------------------*/
424/*---------------------------------------------------------------------------*/
425
426CartCoord CartesianMeshNumberingMngInternal::
427globalNbFacesZ(Int32 level) const
428{
429 return globalNbCellsZ(level) + 1;
430}
431
432/*---------------------------------------------------------------------------*/
433/*---------------------------------------------------------------------------*/
434
435CartCoord CartesianMeshNumberingMngInternal::
436globalNbFacesXCartesianView(Int32 level) const
437{
438 return (globalNbCellsX(level) * 2) + 1;
439}
440
441/*---------------------------------------------------------------------------*/
442/*---------------------------------------------------------------------------*/
443
444CartCoord CartesianMeshNumberingMngInternal::
445globalNbFacesYCartesianView(Int32 level) const
446{
447 return (globalNbCellsY(level) * 2) + 1;
448}
449
450/*---------------------------------------------------------------------------*/
451/*---------------------------------------------------------------------------*/
452
453CartCoord CartesianMeshNumberingMngInternal::
454globalNbFacesZCartesianView(Int32 level) const
455{
456 return (globalNbCellsZ(level) * 2) + 1;
457}
458
459/*---------------------------------------------------------------------------*/
460/*---------------------------------------------------------------------------*/
461
462Int64 CartesianMeshNumberingMngInternal::
463nbCellInLevel(Int32 level) const
464{
465 if (m_dimension == 2) {
466 const Int64x2 nb_cell(globalNbCellsX(level), globalNbCellsY(level));
467 return nb_cell.x * nb_cell.y;
468 }
469
470 const Int64x3 nb_cell(globalNbCellsX(level), globalNbCellsY(level), globalNbCellsZ(level));
471 return nb_cell.x * nb_cell.y * nb_cell.z;
472}
473
474/*---------------------------------------------------------------------------*/
475/*---------------------------------------------------------------------------*/
476
477Int64 CartesianMeshNumberingMngInternal::
478nbNodeInLevel(Int32 level) const
479{
480 if (m_dimension == 2) {
481 const Int64x2 nb_cell(globalNbCellsX(level), globalNbCellsY(level));
482 return (nb_cell.x + 1) * (nb_cell.y + 1);
483 }
484
485 const Int64x3 nb_cell(globalNbCellsX(level), globalNbCellsY(level), globalNbCellsZ(level));
486 return (nb_cell.x + 1) * (nb_cell.y + 1) * (nb_cell.z + 1);
487}
488
489/*---------------------------------------------------------------------------*/
490/*---------------------------------------------------------------------------*/
491
492Int64 CartesianMeshNumberingMngInternal::
493nbFaceInLevel(Int32 level) const
494{
495 if (m_dimension == 2) {
496 const Int64x2 nb_cell(globalNbCellsX(level), globalNbCellsY(level));
497 return (nb_cell.x * nb_cell.y) * 2 + nb_cell.x * 2 + nb_cell.y;
498 }
499
500 const Int64x3 nb_cell(globalNbCellsX(level), globalNbCellsY(level), globalNbCellsZ(level));
501 return (nb_cell.x + 1) * nb_cell.y * nb_cell.z + (nb_cell.y + 1) * nb_cell.z * nb_cell.x + (nb_cell.z + 1) * nb_cell.x * nb_cell.y;
502}
503
504/*---------------------------------------------------------------------------*/
505/*---------------------------------------------------------------------------*/
506
507Int32 CartesianMeshNumberingMngInternal::
508pattern() const
509{
510 return m_pattern;
511}
512
513/*---------------------------------------------------------------------------*/
514/*---------------------------------------------------------------------------*/
515
516Int32 CartesianMeshNumberingMngInternal::
517cellLevel(Int64 uid) const
518{
519 Int32 pos = -1;
520 Int64 max = -1;
521
522 for (Int32 i = m_min_level; i <= m_max_level; ++i) {
523 const Int64 first_uid = firstCellUniqueId(i);
524 if (first_uid <= uid && first_uid > max) {
525 pos = i;
526 max = first_uid;
527 }
528 }
529#ifdef ARCANE_CHECK
530 if (max == -1) {
531 ARCANE_FATAL("CellUID is not in any patch (UID too low)");
532 }
533 if (uid >= firstCellUniqueId(pos) + nbCellInLevel(pos)) {
534 ARCANE_FATAL("CellUID is not in any patch (UID too high)");
535 }
536#endif
537 return pos;
538}
539
540/*---------------------------------------------------------------------------*/
541/*---------------------------------------------------------------------------*/
542
543Int32 CartesianMeshNumberingMngInternal::
544nodeLevel(Int64 uid) const
545{
546 Int32 pos = -1;
547 Int64 max = -1;
548
549 for (Int32 i = m_min_level; i <= m_max_level; ++i) {
550 const Int64 first_uid = firstNodeUniqueId(i);
551 if (first_uid <= uid && first_uid > max) {
552 pos = i;
553 max = first_uid;
554 }
555 }
556#ifdef ARCANE_CHECK
557 if (max == -1) {
558 ARCANE_FATAL("NodeUID is not in any patch (UID too low)");
559 }
560 if (uid >= firstNodeUniqueId(pos) + nbNodeInLevel(pos)) {
561 ARCANE_FATAL("NodeUID is not in any patch (UID too high)");
562 }
563#endif
564 return pos;
565}
566
567/*---------------------------------------------------------------------------*/
568/*---------------------------------------------------------------------------*/
569
570Int32 CartesianMeshNumberingMngInternal::
571faceLevel(Int64 uid) const
572{
573 Int32 pos = -1;
574 Int64 max = -1;
575
576 for (Int32 i = m_min_level; i <= m_max_level; ++i) {
577 const Int64 first_uid = firstFaceUniqueId(i);
578 if (first_uid <= uid && first_uid > max) {
579 pos = i;
580 max = first_uid;
581 }
582 }
583#ifdef ARCANE_CHECK
584 if (max == -1) {
585 ARCANE_FATAL("FaceUID is not in any patch (UID too low)");
586 }
587 if (uid >= firstFaceUniqueId(pos) + nbFaceInLevel(pos)) {
588 ARCANE_FATAL("FaceUID is not in any patch (UID too high)");
589 }
590#endif
591 return pos;
592}
593
594/*---------------------------------------------------------------------------*/
595/*---------------------------------------------------------------------------*/
596
597// Tant que l'on a un unique "pattern" pour x, y, z, pas besoin de trois méthodes.
598CartCoord CartesianMeshNumberingMngInternal::
599offsetLevelToLevel(CartCoord coord, Int32 level_from, Int32 level_to) const
600{
601 if (level_from == level_to) {
602 return coord;
603 }
604 if (level_from < level_to) {
605 return coord * static_cast<CartCoord>(std::pow(m_pattern, (level_to - level_from)));
606 }
607 return coord / static_cast<CartCoord>(std::pow(m_pattern, (level_from - level_to)));
608}
609
610/*---------------------------------------------------------------------------*/
611/*---------------------------------------------------------------------------*/
612
613CartCoord3 CartesianMeshNumberingMngInternal::
614offsetLevelToLevel(CartCoord3 coord, Int32 level_from, Int32 level_to) const
615{
616 if (level_from == level_to) {
617 return coord;
618 }
619 if (level_from < level_to) {
620 return coord * static_cast<CartCoord>(std::pow(m_pattern, (level_to - level_from)));
621 }
622 return coord / static_cast<CartCoord>(std::pow(m_pattern, (level_from - level_to)));
623}
624
625/*---------------------------------------------------------------------------*/
626/*---------------------------------------------------------------------------*/
627
628// Tant que l'on a un unique "pattern" pour x, y, z, pas besoin de trois méthodes.
629CartCoord CartesianMeshNumberingMngInternal::
630faceOffsetLevelToLevel(CartCoord coord, Int32 level_from, Int32 level_to) const
631{
632 // Admettons que l'on ai les faces suivantes :
633 // ┌─0──┬──2─┐
634 // 4│ 6│ 8│
635 // ├─5──┼─7──┤
636 // 9│ 11│ 13│
637 // └─10─┴─12─┘
638
639 // Pour la position d'une face, on considère cette disposition :
640 // ┌──┬──┬──┬──┬──┐
641 // │ │ 0│ │ 2│ │
642 // ├──┼──┼──┼──┼──┤
643 // │ 4│ │ 6│ │ 8│
644 // ├──┼──┼──┼──┼──┤
645 // │ │ 5│ │ 7│ │
646 // ├──┼──┼──┼──┼──┤
647 // │ 9│ │11│ │13│
648 // ├──┼──┼──┼──┼──┤
649 // │ │10│ │12│ │
650 // └──┴──┴──┴──┴──┘
651
652 if (level_from == level_to) {
653 return coord;
654 }
655
656 if (level_from < level_to) {
657 const Int32 pattern = m_pattern * (level_to - level_from);
658 if (coord % 2 == 0) {
659 return coord * pattern;
660 }
661 return ((coord - 1) * pattern) + 1;
662 }
663
664 const Int32 pattern = m_pattern * (level_from - level_to);
665 if (coord % 2 == 0) {
666 if (coord % (pattern * 2) == 0) {
667 return coord / pattern;
668 }
669 return -1;
670 }
671
672 // auto a = coord - 1;
673 // auto b = a % (pattern * 2);
674 // auto c = a / (pattern * 2);
675 // auto d = c * (2 * (pattern - 1));
676 // auto e = d + b;
677 // auto f = coord - e;
678 // return f;
679
680 return coord - (((coord - 1) / (pattern * 2) * (2 * (pattern - 1))) + ((coord - 1) % (pattern * 2)));
681}
682
683/*---------------------------------------------------------------------------*/
684/*---------------------------------------------------------------------------*/
685
686CartCoord3 CartesianMeshNumberingMngInternal::
687cellUniqueIdToCoord(Int64 uid, Int32 level)
688{
689 const Int64 nb_cell_x = globalNbCellsX(level);
690 const Int64 nb_cell_y = globalNbCellsY(level);
691 const Int64 first_cell_uid = firstCellUniqueId(level);
692
693 uid -= first_cell_uid;
694
695 const Int64 to2d = uid % (nb_cell_x * nb_cell_y);
696
697 return { static_cast<CartCoord>(to2d % nb_cell_x), static_cast<CartCoord>(to2d / nb_cell_x), static_cast<CartCoord>(uid / (nb_cell_x * nb_cell_y)) };
698}
699
700/*---------------------------------------------------------------------------*/
701/*---------------------------------------------------------------------------*/
702
703CartCoord3 CartesianMeshNumberingMngInternal::
704cellUniqueIdToCoord(Cell cell)
705{
706 return cellUniqueIdToCoord(cell.uniqueId().asInt64(), cell.level());
707}
708
709/*---------------------------------------------------------------------------*/
710/*---------------------------------------------------------------------------*/
711
712CartCoord CartesianMeshNumberingMngInternal::
713cellUniqueIdToCoordX(Int64 uid, Int32 level)
714{
715 const Int64 nb_cell_x = globalNbCellsX(level);
716 const Int64 nb_cell_y = globalNbCellsY(level);
717 const Int64 first_cell_uid = firstCellUniqueId(level);
718
719 uid -= first_cell_uid;
720
721 const Int64 to2d = uid % (nb_cell_x * nb_cell_y);
722 return static_cast<CartCoord>(to2d % nb_cell_x);
723}
724
725/*---------------------------------------------------------------------------*/
726/*---------------------------------------------------------------------------*/
727
728CartCoord CartesianMeshNumberingMngInternal::
729cellUniqueIdToCoordX(Cell cell)
730{
731 return cellUniqueIdToCoordX(cell.uniqueId(), cell.level());
732}
733
734/*---------------------------------------------------------------------------*/
735/*---------------------------------------------------------------------------*/
736
737CartCoord CartesianMeshNumberingMngInternal::
738cellUniqueIdToCoordY(Int64 uid, Int32 level)
739{
740 const Int64 nb_cell_x = globalNbCellsX(level);
741 const Int64 nb_cell_y = globalNbCellsY(level);
742 const Int64 first_cell_uid = firstCellUniqueId(level);
743
744 uid -= first_cell_uid;
745
746 const Int64 to2d = uid % (nb_cell_x * nb_cell_y);
747 return static_cast<CartCoord>(to2d / nb_cell_x);
748}
749
750/*---------------------------------------------------------------------------*/
751/*---------------------------------------------------------------------------*/
752
753CartCoord CartesianMeshNumberingMngInternal::
754cellUniqueIdToCoordY(Cell cell)
755{
756 return cellUniqueIdToCoordY(cell.uniqueId(), cell.level());
757}
758
759/*---------------------------------------------------------------------------*/
760/*---------------------------------------------------------------------------*/
761
762CartCoord CartesianMeshNumberingMngInternal::
763cellUniqueIdToCoordZ(Int64 uid, Int32 level)
764{
765 const Int64 nb_cell_x = globalNbCellsX(level);
766 const Int64 nb_cell_y = globalNbCellsY(level);
767 const Int64 first_cell_uid = firstCellUniqueId(level);
768
769 uid -= first_cell_uid;
770
771 return static_cast<CartCoord>(uid / (nb_cell_x * nb_cell_y));
772}
773
774/*---------------------------------------------------------------------------*/
775/*---------------------------------------------------------------------------*/
776
777CartCoord CartesianMeshNumberingMngInternal::
778cellUniqueIdToCoordZ(Cell cell)
779{
780 return cellUniqueIdToCoordZ(cell.uniqueId(), cell.level());
781}
782
783/*---------------------------------------------------------------------------*/
784/*---------------------------------------------------------------------------*/
785
786CartCoord CartesianMeshNumberingMngInternal::
787nodeUniqueIdToCoordX(Int64 uid, Int32 level)
788{
789 const Int64 nb_node_x = globalNbNodesX(level);
790 const Int64 nb_node_y = globalNbNodesY(level);
791 const Int64 first_node_uid = firstNodeUniqueId(level);
792
793 uid -= first_node_uid;
794
795 const Int64 to2d = uid % (nb_node_x * nb_node_y);
796 return static_cast<CartCoord>(to2d % nb_node_x);
797}
798
799/*---------------------------------------------------------------------------*/
800/*---------------------------------------------------------------------------*/
801
802CartCoord CartesianMeshNumberingMngInternal::
803nodeUniqueIdToCoordX(Node node)
804{
805 const Int64 uid = node.uniqueId().asInt64();
806 return nodeUniqueIdToCoordX(uid, nodeLevel(uid));
807}
808
809/*---------------------------------------------------------------------------*/
810/*---------------------------------------------------------------------------*/
811
812CartCoord CartesianMeshNumberingMngInternal::
813nodeUniqueIdToCoordY(Int64 uid, Int32 level)
814{
815 const Int64 nb_node_x = globalNbNodesX(level);
816 const Int64 nb_node_y = globalNbNodesY(level);
817 const Int64 first_node_uid = firstNodeUniqueId(level);
818
819 uid -= first_node_uid;
820
821 const Int64 to2d = uid % (nb_node_x * nb_node_y);
822 return static_cast<CartCoord>(to2d / nb_node_x);
823}
824
825/*---------------------------------------------------------------------------*/
826/*---------------------------------------------------------------------------*/
827
828CartCoord CartesianMeshNumberingMngInternal::
829nodeUniqueIdToCoordY(Node node)
830{
831 const Int64 uid = node.uniqueId().asInt64();
832 return nodeUniqueIdToCoordY(uid, nodeLevel(uid));
833}
834
835/*---------------------------------------------------------------------------*/
836/*---------------------------------------------------------------------------*/
837
838CartCoord CartesianMeshNumberingMngInternal::
839nodeUniqueIdToCoordZ(Int64 uid, Int32 level)
840{
841 const Int64 nb_node_x = globalNbNodesX(level);
842 const Int64 nb_node_y = globalNbNodesY(level);
843 const Int64 first_node_uid = firstNodeUniqueId(level);
844
845 uid -= first_node_uid;
846
847 return static_cast<CartCoord>(uid / (nb_node_x * nb_node_y));
848}
849
850/*---------------------------------------------------------------------------*/
851/*---------------------------------------------------------------------------*/
852
853CartCoord CartesianMeshNumberingMngInternal::
854nodeUniqueIdToCoordZ(Node node)
855{
856 const Int64 uid = node.uniqueId().asInt64();
857 return nodeUniqueIdToCoordZ(uid, nodeLevel(uid));
858}
859
860/*---------------------------------------------------------------------------*/
861/*---------------------------------------------------------------------------*/
862
863CartCoord CartesianMeshNumberingMngInternal::
864faceUniqueIdToCoordX(Int64 uid, Int32 level)
865{
866 if (m_dimension == 2) {
867
868 const Int64 nb_face_x = globalNbFacesXCartesianView(level);
869 const Int64 first_face_uid = firstFaceUniqueId(level);
870
871 uid -= first_face_uid;
872 uid += 1;
873
874 // Le +1 nous permet d'avoir le niveau (imaginaire) -1 commençant à 0 :
875 //
876 // x = 0 1 2 3 4
877 // ┌──┬──┬──┬──┬──┐
878 // y = -1 │ 0│ │ 2│ │ 4│
879 // ┌──┬──┬──┬──┬──┐
880 // y = 0 │ │ 1│ │ 3│ │
881 // ├──┼──┼──┼──┼──┤
882 // y = 1 │ 5│ │ 7│ │ 9│
883 // ├──┼──┼──┼──┼──┤
884 // y = 2 │ │ 6│ │ 8│ │
885 // ├──┼──┼──┼──┼──┤
886 // y = 3 │10│ │12│ │14│
887 // ├──┼──┼──┼──┼──┤
888 // y = 4 │ │11│ │13│ │
889 // └──┴──┴──┴──┴──┘
890 //
891 // Si on fait "tomber" les faces (tetris), on obtient une numérotation
892 // cartésienne classique.
893
894 return static_cast<CartCoord>(uid % nb_face_x);
895 }
896
897 const Int64 nb_face_x = globalNbFacesX(level);
898 const Int64 nb_cell_x = globalNbCellsX(level);
899 const Int64 first_face_uid = firstFaceUniqueId(level);
900
901 // Int64 initial_uid = uid;
902
903 uid -= first_face_uid;
904
905 Int64x3 three_parts_numbering = _face3DNumberingThreeParts(level);
906
907 // Prenons la vue des faces en grille cartésienne d'un maillage 2x2x2 :
908 // z = 0 │ z = 1 │ z = 2 │ z = 3 │ z = 4
909 // x = 0 1 2 3 4 │ 0 1 2 3 4 │ 0 1 2 3 4 │ 0 1 2 3 4 │ 0 1 2 3 4
910 // ┌──┬──┬──┬──┬──┐ │ ┌──┬──┬──┬──┬──┐ │ ┌──┬──┬──┬──┬──┐ │ ┌──┬──┬──┬──┬──┐ │ ┌──┬──┬──┬──┬──┐
911 // y = 0 │ │ │ │ │ │ │ │ │12│ │13│ │ │ │ │ │ │ │ │ │ │ │18│ │19│ │ │ │ │ │ │ │ │
912 // ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤
913 // y = 1 │ │24│ │25│ │ │ │ 0│ │ 1│ │ 2│ │ │ │28│ │29│ │ │ │ 6│ │ 7│ │ 8│ │ │ │32│ │33│ │
914 // ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤
915 // y = 2 │ │ │ │ │ │ │ │ │14│ │15│ │ │ │ │ │ │ │ │ │ │ │20│ │21│ │ │ │ │ │ │ │ │
916 // ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤
917 // y = 3 │ │26│ │27│ │ │ │ 3│ │ 4│ │ 5│ │ │ │30│ │31│ │ │ │ 9│ │10│ │11│ │ │ │34│ │35│ │
918 // ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤
919 // y = 4 │ │ │ │ │ │ │ │ │16│ │17│ │ │ │ │ │ │ │ │ │ │ │22│ │23│ │ │ │ │ │ │ │ │
920 // └──┴──┴──┴──┴──┘ │ └──┴──┴──┴──┴──┘ │ └──┴──┴──┴──┴──┘ │ └──┴──┴──┴──┴──┘ │ └──┴──┴──┴──┴──┘
921 // │ │ │ │
922 //
923 // On peut remarquer 3 "sortes de disposition" : les faces ayant les uid [0, 11],
924 // les faces ayant les uid [12, 23] et les faces ayant les uid [24, 35].
925 // On récupère ces intervalles avec la méthode face3DNumberingThreeParts().
926
927 // Pour l'intervalle [0, 11], on remarque que l'origine en X est toujours 0 et que les mailles
928 // contenant une face sont sur les X pairs.
929 // Enfin, on a "nb_face_x" faces en X.
930 if (uid < three_parts_numbering.x) {
931
932 // debug() << "faceUniqueIdToCoordX (2)"
933 // << " -- true uid : " << initial_uid
934 // << " -- uid : " << uid
935 // << " -- level : " << level
936 // << " -- three_parts_numbering : " << three_parts_numbering
937 // << " -- nb_face_x : " << nb_face_x
938 // << " -- return : " << ((uid % nb_face_x) * 2);
939
940 return static_cast<CartCoord>((uid % nb_face_x) * 2);
941 }
942
943 // Pour l'intervalle [12, 23], on remarque que l'origine en X est toujours 1 et que les mailles
944 // contenant une face sont sur les X impairs.
945 // Enfin, on a "nb_cell_x" faces en X.
946 if (uid < three_parts_numbering.x + three_parts_numbering.y) {
947 uid -= three_parts_numbering.x;
948 // debug() << "faceUniqueIdToCoordX (3)"
949 // << " -- true uid : " << initial_uid
950 // << " -- uid : " << uid
951 // << " -- level : " << level
952 // << " -- three_parts_numbering : " << three_parts_numbering
953 // << " -- nb_cell_x : " << nb_cell_x
954 // << " -- return : " << ((uid % nb_cell_x) * 2 + 1);
955
956 return static_cast<CartCoord>((uid % nb_cell_x) * 2 + 1);
957 }
958
959 // Pour l'intervalle [24, 35], on remarque que l'origine en X est toujours 1 et que les mailles
960 // contenant une face sont sur les X impairs.
961 // Enfin, on a "nb_cell_x" faces en X.
962 uid -= three_parts_numbering.x + three_parts_numbering.y;
963 // debug() << "faceUniqueIdToCoordX (1)"
964 // << " -- true uid : " << initial_uid
965 // << " -- uid : " << uid
966 // << " -- level : " << level
967 // << " -- three_parts_numbering : " << three_parts_numbering
968 // << " -- nb_cell_x : " << nb_cell_x
969 // << " -- return : " << ((uid % nb_cell_x) * 2 + 1);
970
971 return static_cast<CartCoord>((uid % nb_cell_x) * 2 + 1);
972}
973
974/*---------------------------------------------------------------------------*/
975/*---------------------------------------------------------------------------*/
976
977CartCoord CartesianMeshNumberingMngInternal::
978faceUniqueIdToCoordX(Face face)
979{
980 const Int64 uid = face.uniqueId().asInt64();
981 return faceUniqueIdToCoordX(uid, faceLevel(uid));
982}
983
984/*---------------------------------------------------------------------------*/
985/*---------------------------------------------------------------------------*/
986
987CartCoord CartesianMeshNumberingMngInternal::
988faceUniqueIdToCoordY(Int64 uid, Int32 level)
989{
990 if (m_dimension == 2) {
991 const Int64 nb_face_x = globalNbFacesXCartesianView(level);
992 const Int64 first_face_uid = firstFaceUniqueId(level);
993
994 uid -= first_face_uid;
995 uid += 1;
996
997 // Le +1 nous permet d'avoir le niveau (imaginaire) -1 commençant à 0 :
998 //
999 // x = 0 1 2 3 4
1000 // ┌──┬──┬──┬──┬──┐
1001 // y = -1 │ 0│ │ 2│ │ 4│
1002 // ┌──┬──┬──┬──┬──┐
1003 // y = 0 │ │ 1│ │ 3│ │
1004 // ├──┼──┼──┼──┼──┤
1005 // y = 1 │ 5│ │ 7│ │ 9│
1006 // ├──┼──┼──┼──┼──┤
1007 // y = 2 │ │ 6│ │ 8│ │
1008 // ├──┼──┼──┼──┼──┤
1009 // y = 3 │10│ │12│ │14│
1010 // ├──┼──┼──┼──┼──┤
1011 // y = 4 │ │11│ │13│ │
1012 // └──┴──┴──┴──┴──┘
1013 //
1014 // Si, en plus, on fait y+1, on simplifie le problème puisque si on fait
1015 // "tomber" les faces (tetris), on obtient une numérotation cartesienne classique.
1016
1017 const Int64 flat_pos = uid / nb_face_x;
1018 return static_cast<CartCoord>((flat_pos * 2) + (flat_pos % 2 == uid % 2 ? 0 : 1) - 1); // Le -1 pour "retirer" le niveau imaginaire.
1019 }
1020 const Int64 nb_face_x = globalNbFacesX(level);
1021 const Int64 nb_face_y = globalNbFacesY(level);
1022 const Int64 nb_cell_x = globalNbCellsX(level);
1023 const Int64 nb_cell_y = globalNbCellsY(level);
1024 const Int64 first_face_uid = firstFaceUniqueId(level);
1025
1026 // Int64 initial_uid = uid;
1027
1028 uid -= first_face_uid;
1029
1030 Int64x3 three_parts_numbering = _face3DNumberingThreeParts(level);
1031
1032 // Prenons la vue des faces en grille cartésienne d'un maillage 2x2x2 :
1033 // z = 0 │ z = 1 │ z = 2 │ z = 3 │ z = 4
1034 // x = 0 1 2 3 4 │ 0 1 2 3 4 │ 0 1 2 3 4 │ 0 1 2 3 4 │ 0 1 2 3 4
1035 // ┌──┬──┬──┬──┬──┐ │ ┌──┬──┬──┬──┬──┐ │ ┌──┬──┬──┬──┬──┐ │ ┌──┬──┬──┬──┬──┐ │ ┌──┬──┬──┬──┬──┐
1036 // y = 0 │ │ │ │ │ │ │ │ │12│ │13│ │ │ │ │ │ │ │ │ │ │ │18│ │19│ │ │ │ │ │ │ │ │
1037 // ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤
1038 // y = 1 │ │24│ │25│ │ │ │ 0│ │ 1│ │ 2│ │ │ │28│ │29│ │ │ │ 6│ │ 7│ │ 8│ │ │ │32│ │33│ │
1039 // ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤
1040 // y = 2 │ │ │ │ │ │ │ │ │14│ │15│ │ │ │ │ │ │ │ │ │ │ │20│ │21│ │ │ │ │ │ │ │ │
1041 // ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤
1042 // y = 3 │ │26│ │27│ │ │ │ 3│ │ 4│ │ 5│ │ │ │30│ │31│ │ │ │ 9│ │10│ │11│ │ │ │34│ │35│ │
1043 // ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤
1044 // y = 4 │ │ │ │ │ │ │ │ │16│ │17│ │ │ │ │ │ │ │ │ │ │ │22│ │23│ │ │ │ │ │ │ │ │
1045 // └──┴──┴──┴──┴──┘ │ └──┴──┴──┴──┴──┘ │ └──┴──┴──┴──┴──┘ │ └──┴──┴──┴──┴──┘ │ └──┴──┴──┴──┴──┘
1046 // │ │ │ │
1047 //
1048 // On peut remarquer 3 "sortes de disposition" : les faces ayant les uid [0, 11],
1049 // les faces ayant les uid [12, 23] et les faces ayant les uid [24, 35].
1050 // On récupère ces intervalles avec la méthode face3DNumberingThreeParts().
1051
1052 // Pour l'intervalle [0, 1], on remarque que l'origine en Y est toujours 1 et que les mailles
1053 // contenant une face sont sur les Y impairs.
1054 // Enfin, on a "nb_cell_y" faces en Y.
1055 if (uid < three_parts_numbering.x) {
1056 uid %= nb_face_x * nb_cell_y;
1057
1058 // debug() << "faceUniqueIdToCoordY (2)"
1059 // << " -- true uid : " << initial_uid
1060 // << " -- uid : " << uid
1061 // << " -- level : " << level
1062 // << " -- three_parts_numbering : " << three_parts_numbering
1063 // << " -- nb_face_x : " << nb_face_x
1064 // << " -- nb_cell_y : " << nb_cell_y
1065 // << " -- return : " << ((uid / nb_face_x) * 2 + 1);
1066
1067 return static_cast<CartCoord>((uid / nb_face_x) * 2 + 1);
1068 }
1069
1070 // Pour l'intervalle [12, 23], on remarque que l'origine en Y est toujours 0 et que les mailles
1071 // contenant une face sont sur les Y pairs.
1072 // Enfin, on a "nb_face_y" faces en Y.
1073 if (uid < three_parts_numbering.x + three_parts_numbering.y) {
1074 uid -= three_parts_numbering.x;
1075 uid %= nb_cell_x * nb_face_y;
1076
1077 // debug() << "faceUniqueIdToCoordY (3)"
1078 // << " -- true uid : " << initial_uid
1079 // << " -- uid : " << uid
1080 // << " -- level : " << level
1081 // << " -- three_parts_numbering : " << three_parts_numbering
1082 // << " -- nb_cell_x : " << nb_cell_x
1083 // << " -- nb_face_y : " << nb_face_y
1084 // << " -- return : " << ((uid / nb_cell_x) * 2);
1085
1086 return static_cast<CartCoord>((uid / nb_cell_x) * 2);
1087 }
1088
1089 // Pour l'intervalle [24, 35], on remarque que l'origine en Y est toujours 1 et que les mailles
1090 // contenant une face sont sur les Y impairs.
1091 // Enfin, on a "nb_cell_y" faces en Y.
1092 uid -= three_parts_numbering.x + three_parts_numbering.y;
1093 uid %= nb_cell_x * nb_cell_y;
1094
1095 // debug() << "faceUniqueIdToCoordY (1)"
1096 // << " -- true uid : " << initial_uid
1097 // << " -- uid : " << uid
1098 // << " -- level : " << level
1099 // << " -- three_parts_numbering : " << three_parts_numbering
1100 // << " -- nb_cell_x : " << nb_cell_x
1101 // << " -- nb_cell_y : " << nb_cell_y
1102 // << " -- return : " << ((uid / nb_cell_x) * 2 + 1);
1103
1104 return static_cast<CartCoord>((uid / nb_cell_x) * 2 + 1);
1105}
1106
1107/*---------------------------------------------------------------------------*/
1108/*---------------------------------------------------------------------------*/
1109
1110CartCoord CartesianMeshNumberingMngInternal::
1111faceUniqueIdToCoordY(Face face)
1112{
1113 const Int64 uid = face.uniqueId().asInt64();
1114 return faceUniqueIdToCoordY(uid, faceLevel(uid));
1115}
1116
1117/*---------------------------------------------------------------------------*/
1118/*---------------------------------------------------------------------------*/
1119
1120CartCoord CartesianMeshNumberingMngInternal::
1121faceUniqueIdToCoordZ(Int64 uid, Int32 level)
1122{
1123 const Int64 nb_face_x = globalNbFacesX(level);
1124 const Int64 nb_face_y = globalNbFacesY(level);
1125 const Int64 nb_cell_x = globalNbCellsX(level);
1126 const Int64 nb_cell_y = globalNbCellsY(level);
1127 const Int64 first_face_uid = firstFaceUniqueId(level);
1128
1129 // Int64 initial_uid = uid;
1130
1131 uid -= first_face_uid;
1132
1133 Int64x3 three_parts_numbering = _face3DNumberingThreeParts(level);
1134
1135 // Prenons la vue des faces en grille cartésienne d'un maillage 2x2x2 :
1136 // z = 0 │ z = 1 │ z = 2 │ z = 3 │ z = 4
1137 // x = 0 1 2 3 4 │ 0 1 2 3 4 │ 0 1 2 3 4 │ 0 1 2 3 4 │ 0 1 2 3 4
1138 // ┌──┬──┬──┬──┬──┐ │ ┌──┬──┬──┬──┬──┐ │ ┌──┬──┬──┬──┬──┐ │ ┌──┬──┬──┬──┬──┐ │ ┌──┬──┬──┬──┬──┐
1139 // y = 0 │ │ │ │ │ │ │ │ │12│ │13│ │ │ │ │ │ │ │ │ │ │ │18│ │19│ │ │ │ │ │ │ │ │
1140 // ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤
1141 // y = 1 │ │24│ │25│ │ │ │ 0│ │ 1│ │ 2│ │ │ │28│ │29│ │ │ │ 6│ │ 7│ │ 8│ │ │ │32│ │33│ │
1142 // ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤
1143 // y = 2 │ │ │ │ │ │ │ │ │14│ │15│ │ │ │ │ │ │ │ │ │ │ │20│ │21│ │ │ │ │ │ │ │ │
1144 // ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤
1145 // y = 3 │ │26│ │27│ │ │ │ 3│ │ 4│ │ 5│ │ │ │30│ │31│ │ │ │ 9│ │10│ │11│ │ │ │34│ │35│ │
1146 // ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤
1147 // y = 4 │ │ │ │ │ │ │ │ │16│ │17│ │ │ │ │ │ │ │ │ │ │ │22│ │23│ │ │ │ │ │ │ │ │
1148 // └──┴──┴──┴──┴──┘ │ └──┴──┴──┴──┴──┘ │ └──┴──┴──┴──┴──┘ │ └──┴──┴──┴──┴──┘ │ └──┴──┴──┴──┴──┘
1149 // │ │ │ │
1150 //
1151 // On peut remarquer 3 "sortes de disposition" : les faces ayant les uid [0, 11],
1152 // les faces ayant les uid [12, 23] et les faces ayant les uid [24, 35].
1153 // On récupère ces intervalles avec la méthode face3DNumberingThreeParts().
1154
1155 // Pour l'intervalle [0, 11], on remarque que l'origine en Z est toujours 1 et que les mailles
1156 // contenant une face sont sur les Z impairs.
1157 // Enfin, on a "nb_cell_z" faces en Z.
1158 if (uid < three_parts_numbering.x) {
1159
1160 // debug() << "faceUniqueIdToCoordZ (2)"
1161 // << " -- true uid : " << initial_uid
1162 // << " -- uid : " << uid
1163 // << " -- level : " << level
1164 // << " -- three_parts_numbering : " << three_parts_numbering
1165 // << " -- nb_face_x : " << nb_face_x
1166 // << " -- nb_cell_y : " << nb_cell_y
1167 // << " -- return : " << ((uid / (nb_face_x * nb_cell_y)) * 2 + 1);
1168
1169 return static_cast<CartCoord>((uid / (nb_face_x * nb_cell_y)) * 2 + 1);
1170 }
1171
1172 // Pour l'intervalle [12, 23], on remarque que l'origine en Z est toujours 1 et que les mailles
1173 // contenant une face sont sur les Z impairs.
1174 // Enfin, on a "nb_cell_z" faces en Z.
1175 if (uid < three_parts_numbering.x + three_parts_numbering.y) {
1176 uid -= three_parts_numbering.x;
1177
1178 // debug() << "faceUniqueIdToCoordZ (3)"
1179 // << " -- true uid : " << initial_uid
1180 // << " -- uid : " << uid
1181 // << " -- level : " << level
1182 // << " -- three_parts_numbering : " << three_parts_numbering
1183 // << " -- nb_cell_x : " << nb_cell_x
1184 // << " -- nb_face_y : " << nb_face_y
1185 // << " -- return : " << ((uid / (nb_cell_x * nb_face_y)) * 2 + 1);
1186
1187 return static_cast<CartCoord>((uid / (nb_cell_x * nb_face_y)) * 2 + 1);
1188 }
1189
1190 // Pour l'intervalle [24, 35], on remarque que l'origine en Z est toujours 0 et que les mailles
1191 // contenant une face sont sur les Z pairs.
1192 // Enfin, on a "nb_face_z" faces en Z.
1193 uid -= three_parts_numbering.x + three_parts_numbering.y;
1194
1195 // debug() << "faceUniqueIdToCoordZ (1)"
1196 // << " -- true uid : " << initial_uid
1197 // << " -- uid : " << uid
1198 // << " -- level : " << level
1199 // << " -- three_parts_numbering : " << three_parts_numbering
1200 // << " -- nb_cell_x : " << nb_cell_x
1201 // << " -- nb_cell_y : " << nb_cell_y
1202 // << " -- return : " << ((uid / (nb_cell_x * nb_cell_y)) * 2);
1203
1204 return static_cast<CartCoord>((uid / (nb_cell_x * nb_cell_y)) * 2);
1205}
1206
1207/*---------------------------------------------------------------------------*/
1208/*---------------------------------------------------------------------------*/
1209
1210CartCoord CartesianMeshNumberingMngInternal::
1211faceUniqueIdToCoordZ(Face face)
1212{
1213 const Int64 uid = face.uniqueId().asInt64();
1214 return faceUniqueIdToCoordZ(uid, faceLevel(uid));
1215}
1216
1217/*---------------------------------------------------------------------------*/
1218/*---------------------------------------------------------------------------*/
1219
1220Int64 CartesianMeshNumberingMngInternal::
1221cellUniqueId(CartCoord3 cell_coord, Int32 level)
1222{
1223 const Int64 nb_cell_x = globalNbCellsX(level);
1224 const Int64 nb_cell_y = globalNbCellsY(level);
1225 const Int64 first_cell_uid = firstCellUniqueId(level);
1226
1227 return (cell_coord.x + cell_coord.y * nb_cell_x + cell_coord.z * nb_cell_x * nb_cell_y) + first_cell_uid;
1228}
1229
1230/*---------------------------------------------------------------------------*/
1231/*---------------------------------------------------------------------------*/
1232
1233Int64 CartesianMeshNumberingMngInternal::
1234cellUniqueId(CartCoord2 cell_coord, Int32 level)
1235{
1236 const Int64 nb_cell_x = globalNbCellsX(level);
1237 const Int64 first_cell_uid = firstCellUniqueId(level);
1238
1239 return (cell_coord.x + cell_coord.y * nb_cell_x) + first_cell_uid;
1240}
1241
1242/*---------------------------------------------------------------------------*/
1243/*---------------------------------------------------------------------------*/
1244
1245Int64 CartesianMeshNumberingMngInternal::
1246nodeUniqueId(CartCoord3 node_coord, Int32 level)
1247{
1248 const Int64 nb_node_x = globalNbNodesX(level);
1249 const Int64 nb_node_y = globalNbNodesY(level);
1250 const Int64 first_node_uid = firstNodeUniqueId(level);
1251
1252 return (node_coord.x + node_coord.y * nb_node_x + node_coord.z * nb_node_x * nb_node_y) + first_node_uid;
1253}
1254
1255/*---------------------------------------------------------------------------*/
1256/*---------------------------------------------------------------------------*/
1257
1258Int64 CartesianMeshNumberingMngInternal::
1259nodeUniqueId(CartCoord2 node_coord, Int32 level)
1260{
1261 const Int64 nb_node_x = globalNbNodesX(level);
1262 const Int64 first_node_uid = firstNodeUniqueId(level);
1263
1264 return (node_coord.x + node_coord.y * nb_node_x) + first_node_uid;
1265}
1266
1267/*---------------------------------------------------------------------------*/
1268/*---------------------------------------------------------------------------*/
1269
1270Int64 CartesianMeshNumberingMngInternal::
1271faceUniqueId(CartCoord3 face_coord, Int32 level)
1272{
1273 const Int64 nb_face_x = globalNbFacesX(level);
1274 const Int64 nb_face_y = globalNbFacesY(level);
1275 const Int64 nb_cell_x = globalNbCellsX(level);
1276 const Int64 nb_cell_y = globalNbCellsY(level);
1277
1278 Int64x3 three_parts_numbering = _face3DNumberingThreeParts(level);
1279 Int64 uid = firstFaceUniqueId(level);
1280
1281 // Prenons la vue des faces en grille cartésienne d'un maillage 2x2x2 :
1282 // z = 0 │ z = 1 │ z = 2 │ z = 3 │ z = 4
1283 // x = 0 1 2 3 4 │ 0 1 2 3 4 │ 0 1 2 3 4 │ 0 1 2 3 4 │ 0 1 2 3 4
1284 // ┌──┬──┬──┬──┬──┐ │ ┌──┬──┬──┬──┬──┐ │ ┌──┬──┬──┬──┬──┐ │ ┌──┬──┬──┬──┬──┐ │ ┌──┬──┬──┬──┬──┐
1285 // y = 0 │ │ │ │ │ │ │ │ │12│ │13│ │ │ │ │ │ │ │ │ │ │ │18│ │19│ │ │ │ │ │ │ │ │
1286 // ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤
1287 // y = 1 │ │24│ │25│ │ │ │ 0│ │ 1│ │ 2│ │ │ │28│ │29│ │ │ │ 6│ │ 7│ │ 8│ │ │ │32│ │33│ │
1288 // ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤
1289 // y = 2 │ │ │ │ │ │ │ │ │14│ │15│ │ │ │ │ │ │ │ │ │ │ │20│ │21│ │ │ │ │ │ │ │ │
1290 // ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤
1291 // y = 3 │ │26│ │27│ │ │ │ 3│ │ 4│ │ 5│ │ │ │30│ │31│ │ │ │ 9│ │10│ │11│ │ │ │34│ │35│ │
1292 // ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤
1293 // y = 4 │ │ │ │ │ │ │ │ │16│ │17│ │ │ │ │ │ │ │ │ │ │ │22│ │23│ │ │ │ │ │ │ │ │
1294 // └──┴──┴──┴──┴──┘ │ └──┴──┴──┴──┴──┘ │ └──┴──┴──┴──┴──┘ │ └──┴──┴──┴──┴──┘ │ └──┴──┴──┴──┴──┘
1295 // │ │ │ │
1296 //
1297 // On peut remarquer 3 "sortes de disposition" : les faces ayant les uid [0, 11],
1298 // les faces ayant les uid [12, 23] et les faces ayant les uid [24, 35].
1299 // Ici, on veut faire l'inverse : passer des coordonnées x,y,z à un uid.
1300 // Pour identifier les trois intervalles, on regarde quelle coordonnée est pair.
1301 // En effet, pour l'intervalle [0, 11], on s'aperçoit que seule la coordonnée z est pair.
1302 // Pour l'intervalle [12, 23], seule la coordonnée x est pair et pour l'intervalle [24, 35],
1303 // seule la coordonnée y est pair.
1304
1305 // Intervalle [0, 11].
1306 if (face_coord.x % 2 == 0) {
1307
1308 // Ici, on place les mailles à l'origine 0*0*0 et on les met côte-à-côte.
1309 face_coord.y -= 1;
1310 face_coord.z -= 1;
1311
1312 face_coord /= 2;
1313
1314 // On est, à présent et pour cet intervalle, dans une vue cartésienne de
1315 // taille nb_face_x * nb_cell_y * nb_cell_z.
1316 uid += face_coord.x + (face_coord.y * nb_face_x) + (face_coord.z * nb_face_x * nb_cell_y);
1317 }
1318
1319 // Intervalle [12, 23].
1320 else if (face_coord.y % 2 == 0) {
1321 uid += three_parts_numbering.x;
1322
1323 // Ici, on place les mailles à l'origine 0*0*0 et on les met côte-à-côte.
1324 face_coord.x -= 1;
1325 face_coord.z -= 1;
1326
1327 face_coord /= 2;
1328
1329 // On est, à présent et pour cet intervalle, dans une vue cartésienne de
1330 // taille nb_cell_x * nb_face_y * nb_cell_z.
1331 uid += face_coord.x + (face_coord.y * nb_cell_x) + (face_coord.z * nb_cell_x * nb_face_y);
1332 }
1333
1334 // Intervalle [24, 35].
1335 else if (face_coord.z % 2 == 0) {
1336 uid += three_parts_numbering.x + three_parts_numbering.y;
1337
1338 // Ici, on place les mailles à l'origine 0*0*0 et on les met côte-à-côte.
1339 face_coord.x -= 1;
1340 face_coord.y -= 1;
1341
1342 face_coord /= 2;
1343
1344 // On est, à présent et pour cet intervalle, dans une vue cartésienne de
1345 // taille nb_cell_x * nb_cell_y * nb_face_z.
1346 uid += face_coord.x + (face_coord.y * nb_cell_x) + (face_coord.z * nb_cell_x * nb_cell_y);
1347 }
1348 else {
1349 ARCANE_FATAL("Bizarre -- x : {0} -- y : {1} -- z : {2}", face_coord.x, face_coord.y, face_coord.z);
1350 }
1351
1352 return uid;
1353}
1354
1355/*---------------------------------------------------------------------------*/
1356/*---------------------------------------------------------------------------*/
1357
1358Int64 CartesianMeshNumberingMngInternal::
1359faceUniqueId(CartCoord2 face_coord, Int32 level)
1360{
1361 const Int64 nb_face_x = globalNbFacesXCartesianView(level);
1362 const Int64 first_face_uid = firstFaceUniqueId(level);
1363
1364 // On considère que l'on a un niveau imaginaire -1 et que
1365 // l'on obtiendra uid+1 (dans la numérotation utilisée normalement,
1366 // la face à la position (1, 0) a un uid = 0).
1367 //
1368 // x = 0 1 2 3 4
1369 // ┌──┬──┬──┬──┬──┐
1370 // y = -1 │ 0│ │ 2│ │ 4│
1371 // ┌──┬──┬──┬──┬──┐
1372 // y = 0 │ │ 1│ │ 3│ │
1373 // ├──┼──┼──┼──┼──┤
1374 // y = 1 │ 5│ │ 7│ │ 9│
1375 // ├──┼──┼──┼──┼──┤
1376 // y = 2 │ │ 6│ │ 8│ │
1377 // ├──┼──┼──┼──┼──┤
1378 // y = 3 │10│ │12│ │14│
1379 // ├──┼──┼──┼──┼──┤
1380 // y = 4 │ │11│ │13│ │
1381 // └──┴──┴──┴──┴──┘
1382 //
1383
1384 face_coord.y += 1;
1385
1386 const Int64 a = (face_coord.y / 2) * nb_face_x;
1387
1388 return (face_coord.x + a - 1) + first_face_uid; // Le -1 est pour revenir à la numérotation normale.
1389}
1390
1391/*---------------------------------------------------------------------------*/
1392/*---------------------------------------------------------------------------*/
1393
1394Int32 CartesianMeshNumberingMngInternal::
1395nbNodeByCell()
1396{
1397 return (m_dimension == 2 ? 4 : 8);
1398}
1399
1400/*---------------------------------------------------------------------------*/
1401/*---------------------------------------------------------------------------*/
1402
1403void CartesianMeshNumberingMngInternal::
1404cellNodeUniqueIds(CartCoord3 cell_coord, Int32 level, ArrayView<Int64> uid)
1405{
1406 if (uid.size() != nbNodeByCell())
1407 ARCANE_FATAL("Bad size of arrayview");
1408
1409 const Int64 nb_node_x = globalNbNodesX(level);
1410 const Int64 nb_node_y = globalNbNodesY(level);
1411 const Int64 first_node_uid = firstNodeUniqueId(level);
1412
1413 const Int64 x0 = cell_coord.x + 0;
1414 const Int64 x1 = cell_coord.x + 1;
1415
1416 const Int64 y0 = (cell_coord.y + 0) * nb_node_x;
1417 const Int64 y1 = (cell_coord.y + 1) * nb_node_x;
1418
1419 const Int64 z0 = (cell_coord.z + 0) * nb_node_x * nb_node_y;
1420 const Int64 z1 = (cell_coord.z + 1) * nb_node_x * nb_node_y;
1421
1422 uid[0] = x0 + y0 + z0 + first_node_uid;
1423 uid[1] = x1 + y0 + z0 + first_node_uid;
1424 uid[2] = x1 + y1 + z0 + first_node_uid;
1425 uid[3] = x0 + y1 + z0 + first_node_uid;
1426
1427 uid[4] = x0 + y0 + z1 + first_node_uid;
1428 uid[5] = x1 + y0 + z1 + first_node_uid;
1429 uid[6] = x1 + y1 + z1 + first_node_uid;
1430 uid[7] = x0 + y1 + z1 + first_node_uid;
1431}
1432
1433/*---------------------------------------------------------------------------*/
1434/*---------------------------------------------------------------------------*/
1435
1436void CartesianMeshNumberingMngInternal::
1437cellNodeUniqueIds(CartCoord2 cell_coord, Int32 level, ArrayView<Int64> uid)
1438{
1439 if (uid.size() != nbNodeByCell())
1440 ARCANE_FATAL("Bad size of arrayview");
1441
1442 const Int64 nb_node_x = globalNbNodesX(level);
1443 const Int64 first_node_uid = firstNodeUniqueId(level);
1444
1445 const Int64 x0 = cell_coord.x + 0;
1446 const Int64 x1 = cell_coord.x + 1;
1447
1448 const Int64 y0 = (cell_coord.y + 0) * nb_node_x;
1449 const Int64 y1 = (cell_coord.y + 1) * nb_node_x;
1450
1451 uid[0] = x0 + y0 + first_node_uid;
1452 uid[1] = x1 + y0 + first_node_uid;
1453 uid[2] = x1 + y1 + first_node_uid;
1454 uid[3] = x0 + y1 + first_node_uid;
1455}
1456
1457/*---------------------------------------------------------------------------*/
1458/*---------------------------------------------------------------------------*/
1459
1460void CartesianMeshNumberingMngInternal::
1461cellNodeUniqueIds(Int64 cell_uid, Int32 level, ArrayView<Int64> uid)
1462{
1463 if (m_dimension == 2) {
1464 const CartCoord2 cell_coord(cellUniqueIdToCoordX(cell_uid, level), cellUniqueIdToCoordY(cell_uid, level));
1465 cellNodeUniqueIds(cell_coord, level, uid);
1466 }
1467 else {
1468 const CartCoord3 cell_coord(cellUniqueIdToCoordX(cell_uid, level), cellUniqueIdToCoordY(cell_uid, level), cellUniqueIdToCoordZ(cell_uid, level));
1469 cellNodeUniqueIds(cell_coord, level, uid);
1470 }
1471}
1472
1473/*---------------------------------------------------------------------------*/
1474/*---------------------------------------------------------------------------*/
1475
1476void CartesianMeshNumberingMngInternal::
1477cellNodeUniqueIds(Cell cell, ArrayView<Int64> uid)
1478{
1479 cellNodeUniqueIds(cell.uniqueId().asInt64(), cell.level(), uid);
1480}
1481
1482/*---------------------------------------------------------------------------*/
1483/*---------------------------------------------------------------------------*/
1484
1485Int32 CartesianMeshNumberingMngInternal::
1486nbFaceByCell()
1487{
1488 return (m_dimension == 2 ? 4 : 6);
1489}
1490
1491/*---------------------------------------------------------------------------*/
1492/*---------------------------------------------------------------------------*/
1493
1494void CartesianMeshNumberingMngInternal::
1495cellFaceUniqueIds(CartCoord3 cell_coord, Int32 level, ArrayView<Int64> uid)
1496{
1497 if (uid.size() != nbFaceByCell())
1498 ARCANE_FATAL("Bad size of arrayview");
1499
1500 const Int64x3 nb_cell(globalNbCellsX(level), globalNbCellsY(level), globalNbCellsZ(level));
1501 const Int64x3 nb_face(nb_cell + 1);
1502
1503 const Int64 first_face_uid = firstFaceUniqueId(level);
1504
1505 // Numérote les faces
1506 // Cet algo n'est pas basé sur l'algo 2D.
1507 // Les UniqueIDs générés sont contigües.
1508 // Il est aussi possible de retrouver les UniqueIDs des faces
1509 // à l'aide de la position de la cellule et la taille du maillage.
1510 // De plus, l'ordre des UniqueIDs des faces d'une cellule est toujours le
1511 // même (en notation localId Arcane (cell.face(i)) : 1, 4, 2, 5, 0, 3).
1512 // Les UniqueIDs générés sont donc les mêmes quelque soit le découpage.
1513 //
1514 // Prenons la vue des faces en grille cartésienne d'un maillage 2x2x2 :
1515 // z = 0 │ z = 1 │ z = 2 │ z = 3 │ z = 4
1516 // x = 0 1 2 3 4 │ 0 1 2 3 4 │ 0 1 2 3 4 │ 0 1 2 3 4 │ 0 1 2 3 4
1517 // ┌──┬──┬──┬──┬──┐ │ ┌──┬──┬──┬──┬──┐ │ ┌──┬──┬──┬──┬──┐ │ ┌──┬──┬──┬──┬──┐ │ ┌──┬──┬──┬──┬──┐
1518 // y = 0 │ │ │ │ │ │ │ │ │12│ │13│ │ │ │ │ │ │ │ │ │ │ │18│ │19│ │ │ │ │ │ │ │ │
1519 // ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤
1520 // y = 1 │ │24│ │25│ │ │ │ 0│ │ 1│ │ 2│ │ │ │28│ │29│ │ │ │ 6│ │ 7│ │ 8│ │ │ │32│ │33│ │
1521 // ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤
1522 // y = 2 │ │ │ │ │ │ │ │ │14│ │15│ │ │ │ │ │ │ │ │ │ │ │20│ │21│ │ │ │ │ │ │ │ │
1523 // ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤
1524 // y = 3 │ │26│ │27│ │ │ │ 3│ │ 4│ │ 5│ │ │ │30│ │31│ │ │ │ 9│ │10│ │11│ │ │ │34│ │35│ │
1525 // ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤ │ ├──┼──┼──┼──┼──┤
1526 // y = 4 │ │ │ │ │ │ │ │ │16│ │17│ │ │ │ │ │ │ │ │ │ │ │22│ │23│ │ │ │ │ │ │ │ │
1527 // └──┴──┴──┴──┴──┘ │ └──┴──┴──┴──┴──┘ │ └──┴──┴──┴──┴──┘ │ └──┴──┴──┴──┴──┘ │ └──┴──┴──┴──┴──┘
1528 // │ │ │ │
1529 //
1530 // (dans cette vue, les mailles se situent aux X, Y et Z impaires
1531 // (donc ici, [1, 1, 1], [3, 1, 1], [1, 3, 1], &c)).
1532 //
1533 // On a un cube décomposé en huit cellules (2x2x2).
1534 // Le schéma au-dessus représente les faces des cellules de ce cube avec
1535 // les uniqueIDs que l'algorithme génèrera (sans face_adder).
1536 // Pour cet algo, on commence par les faces "yz" (direction X).
1537 // On énumère d'abord en x, puis en y, puis en z.
1538 // Une fois les faces "yz" numérotées, on fait les faces "zx" (direction Y).
1539 // Toujours le même ordre de numérotation.
1540 // On termine avec les faces "xy" (direction Z), encore dans le même ordre.
1541 //
1542 // Dans l'implémentation ci-dessous, on fait la numérotation
1543 // maille par maille.
1544
1545 const Int64 total_face_yz = nb_face.x * nb_cell.y * nb_cell.z;
1546 const Int64 total_face_yz_zx = total_face_yz + nb_face.y * nb_cell.z * nb_cell.x;
1547
1548 const Int64 nb_cell_before_j = cell_coord.y * nb_cell.x;
1549
1550 uid[0] = (cell_coord.z * nb_cell.x * nb_cell.y) + nb_cell_before_j + cell_coord.x + total_face_yz_zx;
1551
1552 uid[3] = uid[0] + nb_cell.x * nb_cell.y;
1553
1554 uid[1] = (cell_coord.z * nb_face.x * nb_cell.y) + (cell_coord.y * nb_face.x) + cell_coord.x;
1555
1556 uid[4] = uid[1] + 1;
1557
1558 uid[2] = (cell_coord.z * nb_cell.x * nb_face.y) + nb_cell_before_j + cell_coord.x + total_face_yz;
1559
1560 uid[5] = uid[2] + nb_cell.x;
1561
1562 uid[0] += first_face_uid;
1563 uid[1] += first_face_uid;
1564 uid[2] += first_face_uid;
1565 uid[3] += first_face_uid;
1566 uid[4] += first_face_uid;
1567 uid[5] += first_face_uid;
1568
1569 // debug() << "Coord : " << cell_coord << " -- UIDs : " << uid;
1570}
1571
1572/*---------------------------------------------------------------------------*/
1573/*---------------------------------------------------------------------------*/
1574
1575void CartesianMeshNumberingMngInternal::
1576cellFaceUniqueIds(CartCoord2 cell_coord, Int32 level, ArrayView<Int64> uid)
1577{
1578 if (uid.size() != nbFaceByCell())
1579 ARCANE_FATAL("Bad size of arrayview");
1580
1581 const Int64 nb_cell_x = globalNbCellsX(level);
1582 const Int64 nb_face_x = nb_cell_x + 1;
1583 const Int64 first_face_uid = firstFaceUniqueId(level);
1584
1585 // Numérote les faces
1586 // ┌─0──┬──2─┐
1587 // 4│ 6│ 8│
1588 // ├─5──┼─7──┤
1589 // 9│ 11│ 13│
1590 // └─10─┴─12─┘
1591 //
1592 // Avec cette numérotation, HAUT < GAUCHE < BAS < DROITE
1593 // Mis à part les uniqueIds de la première ligne de face, tous
1594 // les uniqueIds sont contigües.
1595
1596 // HAUT
1597 // - "(current_level_nb_face_x + current_level_nb_cell_x)" :
1598 // le nombre de faces GAUCHE BAS DROITE au dessus.
1599 // - "cell_coord.y * (current_level_nb_face_x + current_level_nb_cell_x)" :
1600 // le nombre total de faces GAUCHE BAS DROITE au dessus.
1601 // - "cell_coord.x * 2"
1602 // on avance deux à deux sur les faces d'un même "coté".
1603 uid[0] = cell_coord.x * 2 + cell_coord.y * (nb_face_x + nb_cell_x);
1604
1605 // BAS
1606 // Pour BAS, c'est comme HAUT mais avec un "nombre de face du dessus" en plus.
1607 uid[2] = uid[0] + (nb_face_x + nb_cell_x);
1608 // GAUCHE
1609 // Pour GAUCHE, c'est l'UID de BAS -1.
1610 uid[3] = uid[2] - 1;
1611 // DROITE
1612 // Pour DROITE, c'est l'UID de BAS +1.
1613 uid[1] = uid[2] + 1;
1614
1615 uid[0] += first_face_uid;
1616 uid[1] += first_face_uid;
1617 uid[2] += first_face_uid;
1618 uid[3] += first_face_uid;
1619}
1620
1621/*---------------------------------------------------------------------------*/
1622/*---------------------------------------------------------------------------*/
1623
1624void CartesianMeshNumberingMngInternal::
1625cellFaceUniqueIds(Int64 cell_uid, Int32 level, ArrayView<Int64> uid)
1626{
1627 if (m_dimension == 2) {
1628 const CartCoord2 cell_coord(cellUniqueIdToCoordX(cell_uid, level), cellUniqueIdToCoordY(cell_uid, level));
1629 cellFaceUniqueIds(cell_coord, level, uid);
1630 }
1631 else {
1632 const CartCoord3 cell_coord(cellUniqueIdToCoordX(cell_uid, level), cellUniqueIdToCoordY(cell_uid, level), cellUniqueIdToCoordZ(cell_uid, level));
1633 cellFaceUniqueIds(cell_coord, level, uid);
1634 }
1635}
1636
1637/*---------------------------------------------------------------------------*/
1638/*---------------------------------------------------------------------------*/
1639
1640void CartesianMeshNumberingMngInternal::
1641cellFaceUniqueIds(Cell cell, ArrayView<Int64> uid)
1642{
1643 cellFaceUniqueIds(cell.uniqueId().asInt64(), cell.level(), uid);
1644}
1645
1646/*---------------------------------------------------------------------------*/
1647/*---------------------------------------------------------------------------*/
1648
1649void CartesianMeshNumberingMngInternal::
1650cellUniqueIdsAroundCell(CartCoord3 cell_coord, Int32 level, ArrayView<Int64> uid)
1651{
1652 ARCANE_ASSERT((uid.size() == 27), ("Size of uid array != 27"));
1653
1654 uid.fill(-1);
1655
1656 const CartCoord nb_cells_x = globalNbCellsX(level);
1657 const CartCoord nb_cells_y = globalNbCellsY(level);
1658 const CartCoord nb_cells_z = globalNbCellsZ(level);
1659
1660 for (CartCoord k = -1; k < 2; ++k) {
1661 const CartCoord coord_around_cell_z = cell_coord.z + k;
1662 if (coord_around_cell_z >= 0 && coord_around_cell_z < nb_cells_z) {
1663 for (CartCoord j = -1; j < 2; ++j) {
1664 const CartCoord coord_around_cell_y = cell_coord.y + j;
1665
1666 if (coord_around_cell_y >= 0 && coord_around_cell_y < nb_cells_y) {
1667 for (CartCoord i = -1; i < 2; ++i) {
1668 const CartCoord coord_around_cell_x = cell_coord.x + i;
1669
1670 if (coord_around_cell_x >= 0 && coord_around_cell_x < nb_cells_x) {
1671 uid[(i + 1) + ((j + 1) * 3) + ((k + 1) * 9)] = cellUniqueId(CartCoord3{ coord_around_cell_x, coord_around_cell_y, coord_around_cell_z }, level);
1672 }
1673 }
1674 }
1675 }
1676 }
1677 }
1678}
1679
1680/*---------------------------------------------------------------------------*/
1681/*---------------------------------------------------------------------------*/
1682
1683void CartesianMeshNumberingMngInternal::
1684cellUniqueIdsAroundCell(CartCoord2 cell_coord, Int32 level, ArrayView<Int64> uid)
1685{
1686 ARCANE_ASSERT((uid.size() == 9), ("Size of uid array != 9"));
1687
1688 uid.fill(-1);
1689
1690 const CartCoord nb_cells_x = globalNbCellsX(level);
1691 const CartCoord nb_cells_y = globalNbCellsY(level);
1692
1693 for (CartCoord j = -1; j < 2; ++j) {
1694 const CartCoord coord_around_cell_y = cell_coord.y + j;
1695 if (coord_around_cell_y >= 0 && coord_around_cell_y < nb_cells_y) {
1696
1697 for (CartCoord i = -1; i < 2; ++i) {
1698 const CartCoord coord_around_cell_x = cell_coord.x + i;
1699 if (coord_around_cell_x >= 0 && coord_around_cell_x < nb_cells_x) {
1700 uid[(i + 1) + ((j + 1) * 3)] = cellUniqueId(CartCoord2{ coord_around_cell_x, coord_around_cell_y }, level);
1701 }
1702 }
1703 }
1704 }
1705}
1706
1707/*---------------------------------------------------------------------------*/
1708/*---------------------------------------------------------------------------*/
1709
1710void CartesianMeshNumberingMngInternal::
1711cellUniqueIdsAroundCell(Int64 cell_uid, Int32 level, ArrayView<Int64> uid)
1712{
1713 if (m_dimension == 2) {
1714 const CartCoord2 cell_coord(cellUniqueIdToCoordX(cell_uid, level), cellUniqueIdToCoordY(cell_uid, level));
1715 cellUniqueIdsAroundCell(cell_coord, level, uid);
1716 }
1717 else {
1718 const CartCoord3 cell_coord(cellUniqueIdToCoordX(cell_uid, level), cellUniqueIdToCoordY(cell_uid, level), cellUniqueIdToCoordZ(cell_uid, level));
1719 cellUniqueIdsAroundCell(cell_coord, level, uid);
1720 }
1721}
1722
1723/*---------------------------------------------------------------------------*/
1724/*---------------------------------------------------------------------------*/
1725
1726void CartesianMeshNumberingMngInternal::
1727cellUniqueIdsAroundCell(Cell cell, ArrayView<Int64> uid)
1728{
1729 cellUniqueIdsAroundCell(cell.uniqueId().asInt64(), cell.level(), uid);
1730}
1731
1732/*---------------------------------------------------------------------------*/
1733/*---------------------------------------------------------------------------*/
1734
1735void CartesianMeshNumberingMngInternal::
1736cellUniqueIdsAroundNode(CartCoord3 node_coord, Int32 level, ArrayView<Int64> uid)
1737{
1738 ARCANE_ASSERT((uid.size() == 8), ("Size of uid array != 8"));
1739
1740 uid.fill(-1);
1741
1742 const CartCoord nb_cells_x = globalNbCellsX(level);
1743 const CartCoord nb_cells_y = globalNbCellsY(level);
1744 const CartCoord nb_cells_z = globalNbCellsZ(level);
1745
1746 for (CartCoord k = -1; k < 1; ++k) {
1747 const CartCoord coord_cell_z = node_coord.z + k;
1748 if (coord_cell_z >= 0 && coord_cell_z < nb_cells_z) {
1749
1750 for (CartCoord j = -1; j < 1; ++j) {
1751 const CartCoord coord_cell_y = node_coord.y + j;
1752 if (coord_cell_y >= 0 && coord_cell_y < nb_cells_y) {
1753
1754 for (CartCoord i = -1; i < 1; ++i) {
1755 const CartCoord coord_cell_x = node_coord.x + i;
1756 if (coord_cell_x >= 0 && coord_cell_x < nb_cells_x) {
1757 uid[(i + 1) + ((j + 1) * 2) + ((k + 1) * 4)] = cellUniqueId(CartCoord3{ coord_cell_x, coord_cell_y, coord_cell_z }, level);
1758 }
1759 }
1760 }
1761 }
1762 }
1763 }
1764}
1765
1766/*---------------------------------------------------------------------------*/
1767/*---------------------------------------------------------------------------*/
1768
1769void CartesianMeshNumberingMngInternal::
1770cellUniqueIdsAroundNode(CartCoord2 node_coord, Int32 level, ArrayView<Int64> uid)
1771{
1772 ARCANE_ASSERT((uid.size() == 4), ("Size of uid array != 4"));
1773
1774 uid.fill(-1);
1775
1776 const CartCoord nb_cells_x = globalNbCellsX(level);
1777 const CartCoord nb_cells_y = globalNbCellsY(level);
1778
1779 for (CartCoord j = -1; j < 1; ++j) {
1780 const CartCoord coord_cell_y = node_coord.y + j;
1781 if (coord_cell_y >= 0 && coord_cell_y < nb_cells_y) {
1782
1783 for (CartCoord i = -1; i < 1; ++i) {
1784 const CartCoord coord_cell_x = node_coord.x + i;
1785 if (coord_cell_x >= 0 && coord_cell_x < nb_cells_x) {
1786 uid[(i + 1) + ((j + 1) * 2)] = cellUniqueId(CartCoord2{ coord_cell_x, coord_cell_y }, level);
1787 }
1788 }
1789 }
1790 }
1791}
1792
1793/*---------------------------------------------------------------------------*/
1794/*---------------------------------------------------------------------------*/
1795
1796void CartesianMeshNumberingMngInternal::
1797cellUniqueIdsAroundNode(Int64 node_uid, Int32 level, ArrayView<Int64> uid)
1798{
1799 if (m_dimension == 2) {
1800 const CartCoord2 node_coord{ nodeUniqueIdToCoordX(node_uid, level), nodeUniqueIdToCoordY(node_uid, level) };
1801 cellUniqueIdsAroundNode(node_coord, level, uid);
1802 }
1803 else {
1804 const CartCoord3 node_coord{ nodeUniqueIdToCoordX(node_uid, level), nodeUniqueIdToCoordY(node_uid, level), nodeUniqueIdToCoordZ(node_uid, level) };
1805 cellUniqueIdsAroundNode(node_coord, level, uid);
1806 }
1807}
1808
1809/*---------------------------------------------------------------------------*/
1810/*---------------------------------------------------------------------------*/
1811
1812void CartesianMeshNumberingMngInternal::
1813cellUniqueIdsAroundNode(Node node, ArrayView<Int64> uid)
1814{
1815 cellUniqueIdsAroundNode(node.uniqueId().asInt64(), nodeLevel(node.uniqueId().asInt64()), uid);
1816}
1817
1818/*---------------------------------------------------------------------------*/
1819/*---------------------------------------------------------------------------*/
1820
1821void CartesianMeshNumberingMngInternal::
1822setChildNodeCoordinates(Cell parent_cell)
1823{
1824 if (!(parent_cell.itemBase().flags() & ItemFlags::II_JustRefined)) {
1825 ARCANE_FATAL("Cell not II_JustRefined");
1826 }
1827
1828 VariableNodeReal3& nodes_coords = m_mesh->nodesCoordinates();
1829
1830 const Real3& node0(nodes_coords[parent_cell.node(0)]);
1831 const Real3& node1(nodes_coords[parent_cell.node(1)]);
1832 const Real3& node2(nodes_coords[parent_cell.node(2)]);
1833 const Real3& node3(nodes_coords[parent_cell.node(3)]);
1834
1835 if (m_dimension == 2) {
1836
1837 /*
1838 =
1839 ┌─────────────────────►= y3
1840 │ = ▲ l
1841 ▼ = ▼
1842 X───────────────X◄────►= y2
1843 /▲ /▲ =
1844 / │ / │ =
1845 / │ / │ =
1846 / │ / │ =
1847 / │ / │ =
1848 / │ / │ =
1849 / │ / │ =
1850 / │ / │ =
1851 X───────────────X◄───────│─────►= y1
1852 ▲ │ ▲ │ = ▲ k
1853 │ │ │ │ = ▼
1854 ├──────────────────────────────►= y0
1855 │ │ │ │ =
1856 │ │ │ │ =
1857 ▼ ▼ ▼ ▼
1858 ==============================
1859 x0 ◄───► x3 x1 ◄───► x2
1860 i j
1861 */
1866 auto txty = [&](CartCoord pos_x, CartCoord pos_y) -> Real3 {
1867 const Real x = static_cast<Real>(pos_x) / static_cast<Real>(m_pattern);
1868 const Real y = static_cast<Real>(pos_y) / static_cast<Real>(m_pattern);
1869
1870 const Real i = (node3.x - node0.x) * y + node0.x;
1871 const Real j = (node2.x - node1.x) * y + node1.x;
1872
1873 const Real k = (node1.y - node0.y) * x + node0.y;
1874 const Real l = (node2.y - node3.y) * x + node3.y;
1875
1876 const Real tx = (j - i) * x + i;
1877 const Real ty = (l - k) * y + k;
1878
1879 /*
1880 info() << "[txty]"
1881 << " x : " << x
1882 << " -- y : " << y
1883 << " -- node0 : " << node0
1884 << " -- node1 : " << node1
1885 << " -- node2 : " << node2
1886 << " -- node3 : " << node3
1887 << " -- i : " << i
1888 << " -- j : " << j
1889 << " -- k : " << k
1890 << " -- l : " << l
1891 << " -- tx : " << tx
1892 << " -- ty : " << ty;
1893 */
1894 return { tx, ty, 0 };
1895 };
1896
1897 constexpr CartCoord node_1d_2d_x[] = { 0, 1, 1, 0 };
1898 constexpr CartCoord node_1d_2d_y[] = { 0, 0, 1, 1 };
1899
1900 for (CartCoord j = 0; j < m_pattern; ++j) {
1901 for (CartCoord i = 0; i < m_pattern; ++i) {
1902
1903 Int32 begin = (i == 0 && j == 0 ? 0 : j == 0 ? 1
1904 : 2);
1905 Int32 end = (i == 0 ? nbNodeByCell() : nbNodeByCell() - 1);
1906 Cell child = childCellOfCell(parent_cell, CartCoord2(i, j));
1907
1908 for (Int32 inode = begin; inode < end; ++inode) {
1909 nodes_coords[child.node(inode)] = txty(i + node_1d_2d_x[inode], j + node_1d_2d_y[inode]);
1910 // Real3 pos = txty(i + node_1d_2d_x[inode], j + node_1d_2d_y[inode]);
1911 // nodes_coords[child.node(inode)] = pos;
1912 // info() << "Node uid : " << child.node(inode).uniqueId()
1913 // << " -- nodeX : " << (i + node_1d_2d_x[inode])
1914 // << " -- nodeY : " << (j + node_1d_2d_y[inode])
1915 // << " -- Pos : " << pos;
1916 }
1917 }
1918 }
1919 }
1920
1921 else {
1922 const Real3& node4(nodes_coords[parent_cell.node(4)]);
1923 const Real3& node5(nodes_coords[parent_cell.node(5)]);
1924 const Real3& node6(nodes_coords[parent_cell.node(6)]);
1925 const Real3& node7(nodes_coords[parent_cell.node(7)]);
1926
1931 auto txtytz = [&](CartCoord pos_x, CartCoord pos_y, CartCoord pos_z) -> Real3 {
1932 const Real x = static_cast<Real>(pos_x) / static_cast<Real>(m_pattern);
1933 const Real y = static_cast<Real>(pos_y) / static_cast<Real>(m_pattern);
1934 const Real z = static_cast<Real>(pos_z) / static_cast<Real>(m_pattern);
1935
1936 // Face (m, n, o, p) entre les faces (node0, node1, node2, node3) et (node4, node5, node6, node7).
1937 const Real3 m = (node4 - node0) * z + node0;
1938 const Real3 n = (node5 - node1) * z + node1;
1939 const Real3 o = (node6 - node2) * z + node2;
1940 const Real3 p = (node7 - node3) * z + node3;
1941
1942 // On calcule tx et ty comme en 2D mais sur la face (m, n, o, p).
1943 const Real i = (p.x - m.x) * y + m.x;
1944 const Real j = (o.x - n.x) * y + n.x;
1945
1946 const Real tx = (j - i) * x + i;
1947
1948 const Real k = (n.y - m.y) * x + m.y;
1949 const Real l = (o.y - p.y) * x + p.y;
1950
1951 const Real ty = (l - k) * y + k;
1952
1953 const Real q = (p.z - m.z) * y + m.z;
1954 const Real r = (o.z - n.z) * y + n.z;
1955
1956 const Real s = (n.z - m.z) * x + m.z;
1957 const Real t = (o.z - p.z) * x + p.z;
1958
1959 const Real tz = (((r - q) * x + q) + ((t - s) * y + s)) * 0.5;
1960
1961 /*
1962 info() << "[txtytz]"
1963 << " x : " << x
1964 << " -- y : " << y
1965 << " -- z : " << z
1966 << " -- node0 : " << node0
1967 << " -- node1 : " << node1
1968 << " -- node2 : " << node2
1969 << " -- node3 : " << node3
1970 << " -- node4 : " << node4
1971 << " -- node5 : " << node5
1972 << " -- node6 : " << node6
1973 << " -- node7 : " << node7
1974 << " -- m : " << m
1975 << " -- n : " << n
1976 << " -- o : " << o
1977 << " -- p : " << p
1978 << " -- j : " << j
1979 << " -- k : " << k
1980 << " -- l : " << l
1981 << " -- q : " << q
1982 << " -- r : " << r
1983 << " -- s : " << s
1984 << " -- t : " << t
1985 << " -- tx : " << tx
1986 << " -- ty : " << ty
1987 << " -- tz : " << tz;
1988 */
1989 return { tx, ty, tz };
1990 };
1991
1992 constexpr CartCoord node_1d_3d_x[] = { 0, 1, 1, 0, 0, 1, 1, 0 };
1993 constexpr CartCoord node_1d_3d_y[] = { 0, 0, 1, 1, 0, 0, 1, 1 };
1994 constexpr CartCoord node_1d_3d_z[] = { 0, 0, 0, 0, 1, 1, 1, 1 };
1995
1996 for (CartCoord k = 0; k < m_pattern; ++k) {
1997 for (CartCoord j = 0; j < m_pattern; ++j) {
1998 for (CartCoord i = 0; i < m_pattern; ++i) {
1999
2000 // TODO : éviter les multiples appels pour un même noeud.
2001 Int32 begin = 0;
2002 Int32 end = nbNodeByCell();
2003 Cell child = childCellOfCell(parent_cell, CartCoord3(i, j, k));
2004
2005 for (Int32 inode = begin; inode < end; ++inode) {
2006 nodes_coords[child.node(inode)] = txtytz(i + node_1d_3d_x[inode], j + node_1d_3d_y[inode], k + node_1d_3d_z[inode]);
2007 // Real3 pos = txtytz(i + node_1d_3d_x[inode], j + node_1d_3d_y[inode], k + node_1d_3d_z[inode]);
2008 // nodes_coords[child.node(inode)] = pos;
2009 // info() << "Node uid : " << child.node(inode).uniqueId()
2010 // << " -- nodeX : " << (i + node_1d_3d_x[inode])
2011 // << " -- nodeY : " << (j + node_1d_3d_y[inode])
2012 // << " -- nodeZ : " << (k + node_1d_3d_z[inode])
2013 // << " -- Pos : " << pos;
2014 }
2015 }
2016 }
2017 }
2018 }
2019}
2020
2021/*---------------------------------------------------------------------------*/
2022/*---------------------------------------------------------------------------*/
2023
2024void CartesianMeshNumberingMngInternal::
2025setParentNodeCoordinates(Cell parent_cell)
2026{
2027 if (!(parent_cell.itemBase().flags() & ItemFlags::II_JustAdded)) {
2028 ARCANE_FATAL("Cell not II_JustAdded");
2029 }
2030
2031 VariableNodeReal3& nodes_coords = m_mesh->nodesCoordinates();
2032
2033 if (m_dimension == 2) {
2034 nodes_coords[parent_cell.node(0)] = nodes_coords[childCellOfCell(parent_cell, CartCoord2(0, 0)).node(0)];
2035 nodes_coords[parent_cell.node(1)] = nodes_coords[childCellOfCell(parent_cell, CartCoord2(m_pattern - 1, 0)).node(1)];
2036 nodes_coords[parent_cell.node(2)] = nodes_coords[childCellOfCell(parent_cell, CartCoord2(m_pattern - 1, m_pattern - 1)).node(2)];
2037 nodes_coords[parent_cell.node(3)] = nodes_coords[childCellOfCell(parent_cell, CartCoord2(0, m_pattern - 1)).node(3)];
2038 }
2039
2040 else {
2041 nodes_coords[parent_cell.node(0)] = nodes_coords[childCellOfCell(parent_cell, CartCoord3(0, 0, 0)).node(0)];
2042 nodes_coords[parent_cell.node(1)] = nodes_coords[childCellOfCell(parent_cell, CartCoord3(m_pattern - 1, 0, 0)).node(1)];
2043 nodes_coords[parent_cell.node(2)] = nodes_coords[childCellOfCell(parent_cell, CartCoord3(m_pattern - 1, m_pattern - 1, 0)).node(2)];
2044 nodes_coords[parent_cell.node(3)] = nodes_coords[childCellOfCell(parent_cell, CartCoord3(0, m_pattern - 1, 0)).node(3)];
2045
2046 nodes_coords[parent_cell.node(4)] = nodes_coords[childCellOfCell(parent_cell, CartCoord3(0, 0, m_pattern - 1)).node(4)];
2047 nodes_coords[parent_cell.node(5)] = nodes_coords[childCellOfCell(parent_cell, CartCoord3(m_pattern - 1, 0, m_pattern - 1)).node(5)];
2048 nodes_coords[parent_cell.node(6)] = nodes_coords[childCellOfCell(parent_cell, CartCoord3(m_pattern - 1, m_pattern - 1, m_pattern - 1)).node(6)];
2049 nodes_coords[parent_cell.node(7)] = nodes_coords[childCellOfCell(parent_cell, CartCoord3(0, m_pattern - 1, m_pattern - 1)).node(7)];
2050 }
2051}
2052
2053/*---------------------------------------------------------------------------*/
2054/*---------------------------------------------------------------------------*/
2055
2056Int64 CartesianMeshNumberingMngInternal::
2057parentCellUniqueIdOfCell(Int64 uid, Int32 level, bool do_fatal)
2058{
2059 // Pour avoir la face parent d'une maille, on passe d'abord de l'uid vers les
2060 // coordonnées de la maille,
2061 // puis on détermine les coordonnées du parent grâce au m_pattern,
2062 // et enfin, on repasse des coordonnées du parent vers son uid.
2063
2064 if (globalNbCellsX(level - 1) == 0) {
2065 if (do_fatal) {
2066 ARCANE_FATAL("Level {0} do not exist", (level - 1));
2067 }
2068 return NULL_ITEM_UNIQUE_ID;
2069 }
2070
2071 if (m_dimension == 2) {
2072 return cellUniqueId(CartCoord2(offsetLevelToLevel(cellUniqueIdToCoordX(uid, level), level, level - 1),
2073 offsetLevelToLevel(cellUniqueIdToCoordY(uid, level), level, level - 1)),
2074 level - 1);
2075 }
2076
2077 return cellUniqueId(CartCoord3(offsetLevelToLevel(cellUniqueIdToCoordX(uid, level), level, level - 1),
2078 offsetLevelToLevel(cellUniqueIdToCoordY(uid, level), level, level - 1),
2079 offsetLevelToLevel(cellUniqueIdToCoordZ(uid, level), level, level - 1)),
2080 level - 1);
2081}
2082
2083/*---------------------------------------------------------------------------*/
2084/*---------------------------------------------------------------------------*/
2085
2086Int64 CartesianMeshNumberingMngInternal::
2087parentCellUniqueIdOfCell(Cell cell, bool do_fatal)
2088{
2089 return parentCellUniqueIdOfCell(cell.uniqueId(), cell.level(), do_fatal);
2090}
2091
2092/*---------------------------------------------------------------------------*/
2093/*---------------------------------------------------------------------------*/
2094
2095Int64 CartesianMeshNumberingMngInternal::
2096childCellUniqueIdOfCell(Cell cell, CartCoord3 child_coord_in_parent)
2097{
2098 ARCANE_ASSERT((child_coord_in_parent.x < m_pattern && child_coord_in_parent.x >= 0), ("Bad child_coord_in_parent.x"))
2099 ARCANE_ASSERT((child_coord_in_parent.y < m_pattern && child_coord_in_parent.y >= 0), ("Bad child_coord_in_parent.y"))
2100 ARCANE_ASSERT((child_coord_in_parent.z < m_pattern && child_coord_in_parent.z >= 0), ("Bad child_coord_in_parent.z"))
2101
2102 const Int64 uid = cell.uniqueId();
2103 const Int32 level = cell.level();
2104
2105 return cellUniqueId(CartCoord3(offsetLevelToLevel(cellUniqueIdToCoordX(uid, level), level, level + 1) + child_coord_in_parent.x,
2106 offsetLevelToLevel(cellUniqueIdToCoordY(uid, level), level, level + 1) + child_coord_in_parent.y,
2107 offsetLevelToLevel(cellUniqueIdToCoordZ(uid, level), level, level + 1) + child_coord_in_parent.z),
2108 level + 1);
2109}
2110
2111/*---------------------------------------------------------------------------*/
2112/*---------------------------------------------------------------------------*/
2113
2114Int64 CartesianMeshNumberingMngInternal::
2115childCellUniqueIdOfCell(Cell cell, CartCoord2 child_coord_in_parent)
2116{
2117 ARCANE_ASSERT((child_coord_in_parent.x < m_pattern && child_coord_in_parent.x >= 0), ("Bad child_coord_in_parent.x"))
2118 ARCANE_ASSERT((child_coord_in_parent.y < m_pattern && child_coord_in_parent.y >= 0), ("Bad child_coord_in_parent.y"))
2119
2120 const Int64 uid = cell.uniqueId();
2121 const Int32 level = cell.level();
2122
2123 return cellUniqueId(CartCoord2(offsetLevelToLevel(cellUniqueIdToCoordX(uid, level), level, level + 1) + child_coord_in_parent.x,
2124 offsetLevelToLevel(cellUniqueIdToCoordY(uid, level), level, level + 1) + child_coord_in_parent.y),
2125 level + 1);
2126}
2127
2128/*---------------------------------------------------------------------------*/
2129/*---------------------------------------------------------------------------*/
2130
2131Int64 CartesianMeshNumberingMngInternal::
2132childCellUniqueIdOfCell(Cell cell, Int32 child_index_in_parent)
2133{
2134 if (m_dimension == 2) {
2135 ARCANE_ASSERT((child_index_in_parent < m_pattern * m_pattern && child_index_in_parent >= 0), ("Bad child_index_in_parent"))
2136
2137 return childCellUniqueIdOfCell(cell,
2138 CartCoord2(
2139 child_index_in_parent % m_pattern,
2140 child_index_in_parent / m_pattern));
2141 }
2142
2143 ARCANE_ASSERT((child_index_in_parent < m_pattern * m_pattern * m_pattern && child_index_in_parent >= 0), ("Bad child_index_in_parent"))
2144
2145 const CartCoord to_2d = child_index_in_parent % (m_pattern * m_pattern);
2146 return childCellUniqueIdOfCell(cell,
2147 CartCoord3(
2148 to_2d % m_pattern,
2149 to_2d / m_pattern,
2150 child_index_in_parent / (m_pattern * m_pattern)));
2151}
2152
2153/*---------------------------------------------------------------------------*/
2154/*---------------------------------------------------------------------------*/
2155
2156Cell CartesianMeshNumberingMngInternal::
2157childCellOfCell(Cell cell, CartCoord3 child_coord_in_parent)
2158{
2159 ARCANE_ASSERT((child_coord_in_parent.x < m_pattern && child_coord_in_parent.x >= 0), ("Bad child_coord_in_parent.x"))
2160 ARCANE_ASSERT((child_coord_in_parent.y < m_pattern && child_coord_in_parent.y >= 0), ("Bad child_coord_in_parent.y"))
2161
2162 Cell child = cell.hChild(child_coord_in_parent.x + (child_coord_in_parent.y * m_pattern) + (child_coord_in_parent.z * m_pattern * m_pattern));
2163 const Int64 uid = childCellUniqueIdOfCell(cell, child_coord_in_parent);
2164
2165 // Si jamais la maille à l'index calculé ne correspond pas à l'uniqueId
2166 // recherché, on recherche parmi les autres mailles enfants.
2167 if (child.uniqueId() != uid) {
2168 const Int32 nb_children = cell.nbHChildren();
2169 for (Integer i = 0; i < nb_children; ++i) {
2170 if (cell.hChild(i).uniqueId() == uid) {
2171 return cell.hChild(i);
2172 }
2173 }
2174 ARCANE_FATAL("Unknown cell uid -- uid : {0} -- parent_uid : {1}", uid, cell.uniqueId());
2175 }
2176 return child;
2177}
2178
2179/*---------------------------------------------------------------------------*/
2180/*---------------------------------------------------------------------------*/
2181
2182Cell CartesianMeshNumberingMngInternal::
2183childCellOfCell(Cell cell, CartCoord2 child_coord_in_parent)
2184{
2185 ARCANE_ASSERT((child_coord_in_parent.x < m_pattern && child_coord_in_parent.x >= 0), ("Bad child_coord_in_parent.x"))
2186 ARCANE_ASSERT((child_coord_in_parent.y < m_pattern && child_coord_in_parent.y >= 0), ("Bad child_coord_in_parent.y"))
2187
2188 Cell child = cell.hChild(child_coord_in_parent.x + (child_coord_in_parent.y * m_pattern));
2189 const Int64 uid = childCellUniqueIdOfCell(cell, child_coord_in_parent);
2190
2191 // Si jamais la maille à l'index calculé ne correspond pas à l'uniqueId
2192 // recherché, on recherche parmi les autres mailles enfants.
2193 if (child.uniqueId() != uid) {
2194 const Int32 nb_children = cell.nbHChildren();
2195 for (Integer i = 0; i < nb_children; ++i) {
2196 if (cell.hChild(i).uniqueId() == uid) {
2197 return cell.hChild(i);
2198 }
2199 }
2200 ARCANE_FATAL("Unknown cell uid -- uid : {0} -- parent_uid : {1}", uid, cell.uniqueId());
2201 }
2202 return child;
2203}
2204
2205/*---------------------------------------------------------------------------*/
2206/*---------------------------------------------------------------------------*/
2207
2208Int64 CartesianMeshNumberingMngInternal::
2209parentNodeUniqueIdOfNode(Int64 uid, Int32 level, bool do_fatal)
2210{
2211 // Pour avoir le noeud parent d'un noeud, on passe d'abord de l'uid vers les
2212 // coordonnées du noeud, puis on détermine les coordonnées du parent grâce au m_pattern,
2213 // et enfin, on repasse des coordonnées du parent vers son uid.
2214
2215 const CartCoord coord_x = nodeUniqueIdToCoordX(uid, level);
2216 const CartCoord coord_y = nodeUniqueIdToCoordY(uid, level);
2217
2218 if (coord_x % m_pattern != 0 || coord_y % m_pattern != 0) {
2219 if (do_fatal) {
2220 ARCANE_FATAL("Node uid={0} do not have parent", uid);
2221 }
2222 return NULL_ITEM_UNIQUE_ID;
2223 }
2224
2225 if (m_dimension == 2) {
2226 return nodeUniqueId(CartCoord2(offsetLevelToLevel(coord_x, level, level - 1),
2227 offsetLevelToLevel(coord_y, level, level - 1)),
2228 level - 1);
2229 }
2230
2231 const CartCoord coord_z = nodeUniqueIdToCoordZ(uid, level);
2232
2233 if (coord_z % m_pattern != 0) {
2234 if (do_fatal) {
2235 ARCANE_FATAL("Node uid={0} do not have parent", uid);
2236 }
2237 return NULL_ITEM_UNIQUE_ID;
2238 }
2239 return nodeUniqueId(CartCoord3(offsetLevelToLevel(coord_x, level, level - 1),
2240 offsetLevelToLevel(coord_y, level, level - 1),
2241 offsetLevelToLevel(coord_z, level, level - 1)),
2242 level - 1);
2243}
2244
2245/*---------------------------------------------------------------------------*/
2246/*---------------------------------------------------------------------------*/
2247
2248Int64 CartesianMeshNumberingMngInternal::
2249parentNodeUniqueIdOfNode(Node node, bool do_fatal)
2250{
2251 const Int64 uid = node.uniqueId().asInt64();
2252 return parentNodeUniqueIdOfNode(uid, nodeLevel(uid), do_fatal);
2253}
2254
2255/*---------------------------------------------------------------------------*/
2256/*---------------------------------------------------------------------------*/
2257
2258Int64 CartesianMeshNumberingMngInternal::
2259childNodeUniqueIdOfNode(Int64 uid, Int32 level)
2260{
2261 if (m_dimension == 2) {
2262 return nodeUniqueId(CartCoord2(offsetLevelToLevel(nodeUniqueIdToCoordX(uid, level), level, level + 1),
2263 offsetLevelToLevel(nodeUniqueIdToCoordY(uid, level), level, level + 1)),
2264 level + 1);
2265 }
2266
2267 return nodeUniqueId(CartCoord3(offsetLevelToLevel(nodeUniqueIdToCoordX(uid, level), level, level + 1),
2268 offsetLevelToLevel(nodeUniqueIdToCoordY(uid, level), level, level + 1),
2269 offsetLevelToLevel(nodeUniqueIdToCoordZ(uid, level), level, level + 1)),
2270 level + 1);
2271}
2272
2273/*---------------------------------------------------------------------------*/
2274/*---------------------------------------------------------------------------*/
2275
2276Int64 CartesianMeshNumberingMngInternal::
2277childNodeUniqueIdOfNode(Node node)
2278{
2279 const Int64 uid = node.uniqueId().asInt64();
2280 return childNodeUniqueIdOfNode(uid, nodeLevel(uid));
2281}
2282
2283/*---------------------------------------------------------------------------*/
2284/*---------------------------------------------------------------------------*/
2285
2286Int64 CartesianMeshNumberingMngInternal::
2287parentFaceUniqueIdOfFace(Int64 uid, Int32 level, bool do_fatal)
2288{
2289 if (m_converting_numbering_face && level == m_ori_level) {
2290 uid = m_face_ori_numbering_to_new[uid];
2291 }
2292
2293 // Pour avoir la face parent d'une face, on passe d'abord de l'uid vers les
2294 // coordonnées de la face en "vue cartésienne",
2295 // puis on détermine les coordonnées du parent grâce au m_pattern,
2296 // et enfin, on repasse des coordonnées du parent vers son uid.
2297
2298 const CartCoord coord_x = faceUniqueIdToCoordX(uid, level);
2299 const CartCoord coord_y = faceUniqueIdToCoordY(uid, level);
2300
2301 ARCANE_ASSERT((coord_x < globalNbFacesXCartesianView(level) && coord_x >= 0), ("Bad coord_x"))
2302 ARCANE_ASSERT((coord_y < globalNbFacesYCartesianView(level) && coord_y >= 0), ("Bad coord_y"))
2303
2304 const CartCoord parent_coord_x = faceOffsetLevelToLevel(coord_x, level, level - 1);
2305 const CartCoord parent_coord_y = faceOffsetLevelToLevel(coord_y, level, level - 1);
2306
2307 if (parent_coord_x == -1 || parent_coord_y == -1) {
2308 if (do_fatal) {
2309 ARCANE_FATAL("Face uid={0} do not have parent", uid);
2310 }
2311 return NULL_ITEM_UNIQUE_ID;
2312 }
2313
2314 ARCANE_ASSERT((parent_coord_x < globalNbFacesXCartesianView(level - 1) && parent_coord_x >= 0), ("Bad parent_coord_x"))
2315 ARCANE_ASSERT((parent_coord_y < globalNbFacesYCartesianView(level - 1) && parent_coord_y >= 0), ("Bad parent_coord_y"))
2316
2317 if (m_dimension == 2) {
2318 if (m_converting_numbering_face && level - 1 == m_ori_level) {
2319 return m_face_new_numbering_to_ori[faceUniqueId(CartCoord2(parent_coord_x, parent_coord_y), level - 1)];
2320 }
2321 return faceUniqueId(CartCoord2(parent_coord_x, parent_coord_y), level - 1);
2322 }
2323
2324 const CartCoord coord_z = faceUniqueIdToCoordZ(uid, level);
2325 ARCANE_ASSERT((coord_z < globalNbFacesZCartesianView(level) && coord_z >= 0), ("Bad coord_z"))
2326
2327 const CartCoord parent_coord_z = faceOffsetLevelToLevel(coord_z, level, level - 1);
2328
2329 if (parent_coord_z == -1) {
2330 if (do_fatal) {
2331 ARCANE_FATAL("Face uid={0} do not have parent", uid);
2332 }
2333 return NULL_ITEM_UNIQUE_ID;
2334 }
2335
2336 ARCANE_ASSERT((parent_coord_z < globalNbFacesZCartesianView(level - 1) && parent_coord_z >= 0), ("Bad parent_coord_z"))
2337
2338 // debug() << "Uid : " << uid << " -- CoordX : " << coord_x << " -- CoordY : " << coord_y << " -- CoordZ : " << coord_z;
2339
2340 if (m_converting_numbering_face && level - 1 == m_ori_level) {
2341 return m_face_new_numbering_to_ori[faceUniqueId(CartCoord3(parent_coord_x, parent_coord_y, parent_coord_z), level - 1)];
2342 }
2343
2344 return faceUniqueId(CartCoord3(parent_coord_x, parent_coord_y, parent_coord_z), level - 1);
2345}
2346
2347/*---------------------------------------------------------------------------*/
2348/*---------------------------------------------------------------------------*/
2349
2350Int64 CartesianMeshNumberingMngInternal::
2351parentFaceUniqueIdOfFace(Face face, bool do_fatal)
2352{
2353 const Int64 uid = face.uniqueId().asInt64();
2354 return parentFaceUniqueIdOfFace(uid, faceLevel(uid), do_fatal);
2355}
2356
2357/*---------------------------------------------------------------------------*/
2358/*---------------------------------------------------------------------------*/
2359
2360Int64 CartesianMeshNumberingMngInternal::
2361childFaceUniqueIdOfFace(Int64 uid, Int32 level, Int32 child_index_in_parent)
2362{
2363 if (m_converting_numbering_face && level == m_ori_level) {
2364 uid = m_face_ori_numbering_to_new[uid];
2365 }
2366
2367 const CartCoord coord_x = faceUniqueIdToCoordX(uid, level);
2368 const CartCoord coord_y = faceUniqueIdToCoordY(uid, level);
2369
2370 ARCANE_ASSERT((coord_x < globalNbFacesXCartesianView(level) && coord_x >= 0), ("Bad coord_x"))
2371 ARCANE_ASSERT((coord_y < globalNbFacesYCartesianView(level) && coord_y >= 0), ("Bad coord_y"))
2372
2373 CartCoord first_child_coord_x = faceOffsetLevelToLevel(coord_x, level, level + 1);
2374 CartCoord first_child_coord_y = faceOffsetLevelToLevel(coord_y, level, level + 1);
2375
2376 ARCANE_ASSERT((first_child_coord_x < globalNbFacesXCartesianView(level + 1) && first_child_coord_x >= 0), ("Bad first_child_coord_x"))
2377 ARCANE_ASSERT((first_child_coord_y < globalNbFacesYCartesianView(level + 1) && first_child_coord_y >= 0), ("Bad first_child_coord_y"))
2378
2379 if (m_dimension == 2) {
2380 ARCANE_ASSERT((child_index_in_parent < m_pattern && child_index_in_parent >= 0), ("Invalid child_index_in_parent"))
2381
2382 if (coord_y % 2 == 0) {
2383 first_child_coord_x += child_index_in_parent * 2;
2384 }
2385 else if (coord_x % 2 == 0) {
2386 first_child_coord_y += child_index_in_parent * globalNbFacesY(level + 1);
2387 }
2388 else {
2389 ARCANE_FATAL("Impossible normalement");
2390 }
2391
2392 if (m_converting_numbering_face && level + 1 == m_ori_level) {
2393 return m_face_new_numbering_to_ori[faceUniqueId(CartCoord2(first_child_coord_x, first_child_coord_y), level + 1)];
2394 }
2395
2396 return faceUniqueId(CartCoord2(first_child_coord_x, first_child_coord_y), level + 1);
2397 }
2398
2399 ARCANE_ASSERT((child_index_in_parent < m_pattern * m_pattern && child_index_in_parent >= 0), ("Invalid child_index_in_parent"))
2400
2401 const CartCoord coord_z = faceUniqueIdToCoordZ(uid, level);
2402 ARCANE_ASSERT((coord_z < globalNbFacesZCartesianView(level) && coord_z >= 0), ("Bad coord_z"))
2403
2404 CartCoord first_child_coord_z = faceOffsetLevelToLevel(coord_z, level, level + 1);
2405 ARCANE_ASSERT((first_child_coord_z < globalNbFacesZCartesianView(level + 1) && first_child_coord_z >= 0), ("Bad first_child_coord_z"))
2406
2407 const CartCoord child_x = child_index_in_parent % m_pattern;
2408 const CartCoord child_y = child_index_in_parent / m_pattern;
2409
2410 Int64x3 three_parts_numbering = _face3DNumberingThreeParts(level);
2411
2412 if (uid < three_parts_numbering.x) {
2413 first_child_coord_y += child_x * 2;
2414 first_child_coord_z += child_y * 2;
2415 }
2416 else if (uid < three_parts_numbering.x + three_parts_numbering.y) {
2417 first_child_coord_x += child_x * 2;
2418 first_child_coord_z += child_y * 2;
2419 }
2420 else {
2421 first_child_coord_x += child_x * 2;
2422 first_child_coord_y += child_y * 2;
2423 }
2424
2425 if (m_converting_numbering_face && level + 1 == m_ori_level) {
2426 return m_face_new_numbering_to_ori[faceUniqueId(CartCoord3(first_child_coord_x, first_child_coord_y, first_child_coord_z), level + 1)];
2427 }
2428
2429 return faceUniqueId(CartCoord3(first_child_coord_x, first_child_coord_y, first_child_coord_z), level + 1);
2430}
2431
2432/*---------------------------------------------------------------------------*/
2433/*---------------------------------------------------------------------------*/
2434
2435Int64 CartesianMeshNumberingMngInternal::
2436childFaceUniqueIdOfFace(Face face, Int32 child_index_in_parent)
2437{
2438 const Int64 uid = face.uniqueId().asInt64();
2439 return childFaceUniqueIdOfFace(uid, faceLevel(uid), child_index_in_parent);
2440}
2441
2442/*---------------------------------------------------------------------------*/
2443/*---------------------------------------------------------------------------*/
2444
2445Int64x3 CartesianMeshNumberingMngInternal::
2446_face3DNumberingThreeParts(Int32 level) const
2447{
2448 const Int64x3 nb_cell(globalNbCellsX(level), globalNbCellsY(level), globalNbCellsZ(level));
2449 return { (nb_cell.x + 1) * nb_cell.y * nb_cell.z, (nb_cell.y + 1) * nb_cell.z * nb_cell.x, (nb_cell.z + 1) * nb_cell.x * nb_cell.y };
2450}
2451
2452/*---------------------------------------------------------------------------*/
2453/*---------------------------------------------------------------------------*/
2454
2455void CartesianMeshNumberingMngInternal::
2456_pushFront(UniqueArray<Int64>& array, const Int64 elem)
2457{
2458 array.resize(array.size() + 1);
2459 array.back() = elem;
2460 for (Integer i = array.size() - 2; i >= 0; --i) {
2461 std::swap(array[i], array[i + 1]);
2462 }
2463}
2464
2465/*---------------------------------------------------------------------------*/
2466/*---------------------------------------------------------------------------*/
2467
2468} // End namespace Arcane
2469
2470/*---------------------------------------------------------------------------*/
2471/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
#define ENUMERATE_(type, name, group)
Enumérateur générique d'un groupe d'entité
Integer size() const
Nombre d'éléments du vecteur.
Vue modifiable d'un tableau d'un type T.
void fill(const T &o) noexcept
Remplit le tableau avec la valeur o.
constexpr Integer size() const noexcept
Retourne la taille du tableau.
void resize(Int64 s)
Change le nombre d'éléments du tableau à s.
T & back()
Dernier élément du tableau.
CartCoord globalNbFacesXCartesianView(Int32 level) const override
Méthode permettant de récupérer la taille de la vue "grille cartésienne" contenant les faces.
Int32 pattern() const override
Méthode permettant de récupérer le pattern de raffinement utilisé dans chaque maille....
Int64 childNodeUniqueIdOfNode(Int64 uid, Int32 level) override
Méthode permettant de récupérer l'uniqueId d'un noeud enfant d'un noeud parent.
Int64x3 _face3DNumberingThreeParts(Int32 level) const
Méthode permettant de récupérer le nombre de faces des trois parties de la numérotation.
Int64 nbNodeInLevel(Int32 level) const override
Méthode permettant de récupérer le nombre de noeuds total dans un niveau.
Cell childCellOfCell(Cell cell, CartCoord3 child_coord_in_parent) override
Méthode permettant de récupérer une maille enfant d'une maille parent à partir de la position de la m...
Int64 nbCellInLevel(Int32 level) const override
Méthode permettant de récupérer le nombre de mailles total dans un niveau.
CartCoord faceUniqueIdToCoordX(Int64 uid, Int32 level) override
Méthode permettant de récupérer la coordonnée en X d'une face grâce à son uniqueId.
void cellFaceUniqueIds(CartCoord3 cell_coord, Int32 level, ArrayView< Int64 > uid) override
Méthode permettant de récupérer les uniqueIds des faces d'une maille à partir de ses coordonnées.
CartCoord cellUniqueIdToCoordX(Int64 uid, Int32 level) override
Méthode permettant de récupérer la coordonnée en X d'une maille grâce à son uniqueId.
Int64 childFaceUniqueIdOfFace(Int64 uid, Int32 level, Int32 child_index_in_parent) override
Méthode permettant de récupérer l'uniqueId d'une face enfant d'une face parent à partir de l'index de...
void cellUniqueIdsAroundCell(CartCoord3 cell_coord, Int32 level, ArrayView< Int64 > uid) override
Méthode permettant de récupérer les uniqueIds des mailles autour d'une maille.
CartCoord3 cellUniqueIdToCoord(Int64 uid, Int32 level) override
Méthode permettant de récupérer les coordonnées d'une maille grâce à son uniqueId.
CartCoord offsetLevelToLevel(CartCoord coord, Int32 level_from, Int32 level_to) const override
Méthode permettant d'obtenir la position du premier noeud/maille fille à partir de la position du noe...
void cellUniqueIdsAroundNode(CartCoord3 node_coord, Int32 level, ArrayView< Int64 > uid) override
Méthode permettant de récupérer les uniqueIds des mailles autour d'un noeud.
CartCoord nodeUniqueIdToCoordX(Int64 uid, Int32 level) override
Méthode permettant de récupérer la coordonnée en X d'un noeud grâce à son uniqueId.
CartCoord globalNbFacesYCartesianView(Int32 level) const override
Méthode permettant de récupérer la taille de la vue "grille cartésienne" contenant les faces.
Int64 parentFaceUniqueIdOfFace(Int64 uid, Int32 level, bool do_fatal) override
Méthode permettant de récupérer l'uniqueId du parent d'une face.
Int64 firstFaceUniqueId(Int32 level) const override
Méthode permettant de récupérer le premier unique id utilisé par les faces d'un niveau....
Int64 nbFaceInLevel(Int32 level) const override
Méthode permettant de récupérer le nombre de faces total dans un niveau.
CartCoord nodeUniqueIdToCoordY(Int64 uid, Int32 level) override
Méthode permettant de récupérer la coordonnée en Y d'un noeud grâce à son uniqueId.
Int32 faceLevel(Int64 uid) const override
Méthode permettant de récupérer le niveau d'une face avec son uid.
CartCoord faceOffsetLevelToLevel(CartCoord coord, Int32 level_from, Int32 level_to) const override
Méthode permettant d'obtenir la position de la première face enfant à partir de la position de la fac...
CartCoord globalNbCellsZ(Int32 level) const override
Méthode permettant de récupérer le nombre de mailles global en Z d'un niveau.
CartCoord nodeUniqueIdToCoordZ(Int64 uid, Int32 level) override
Méthode permettant de récupérer la coordonnée en Z d'un noeud grâce à son uniqueId.
Int64 firstCellUniqueId(Int32 level) const override
Méthode permettant de récupérer le premier unique id utilisé par les mailles d'un niveau....
Int64 parentNodeUniqueIdOfNode(Int64 uid, Int32 level, bool do_fatal) override
Méthode permettant de récupérer l'uniqueId du parent d'un noeud.
CartCoord globalNbFacesZCartesianView(Int32 level) const override
Méthode permettant de récupérer la taille de la vue "grille cartésienne" contenant les faces.
Int32 nbNodeByCell() override
Méthode permettant de récupérer le nombre de noeuds dans une maille.
CartCoord globalNbNodesX(Int32 level) const override
Méthode permettant de récupérer le nombre de noeuds global en X d'un niveau.
CartCoord cellUniqueIdToCoordZ(Int64 uid, Int32 level) override
Méthode permettant de récupérer la coordonnée en Z d'une maille grâce à son uniqueId.
Int32 nbFaceByCell() override
Méthode permettant de récupérer le nombre de faces dans une maille.
void cellNodeUniqueIds(CartCoord3 cell_coord, Int32 level, ArrayView< Int64 > uid) override
Méthode permettant de récupérer les uniqueIds des noeuds d'une maille à partir de ses coordonnées.
CartCoord faceUniqueIdToCoordZ(Int64 uid, Int32 level) override
Méthode permettant de récupérer la coordonnée en Z d'une face grâce à son uniqueId.
CartCoord faceUniqueIdToCoordY(Int64 uid, Int32 level) override
Méthode permettant de récupérer la coordonnée en Y d'une face grâce à son uniqueId.
Int64 cellUniqueId(CartCoord3 cell_coord, Int32 level) override
Méthode permettant de récupérer l'uniqueId d'une maille à partir de sa position et de son niveau.
CartCoord globalNbCellsX(Int32 level) const override
Méthode permettant de récupérer le nombre de mailles global en X d'un niveau.
Int64 nodeUniqueId(CartCoord3 node_coord, Int32 level) override
Méthode permettant de récupérer l'uniqueId d'un noeud à partir de sa position et de son niveau.
CartCoord globalNbCellsY(Int32 level) const override
Méthode permettant de récupérer le nombre de mailles global en Y d'un niveau.
Int64 firstNodeUniqueId(Int32 level) const override
Méthode permettant de récupérer le premier unique id utilisé par les noeuds d'un niveau....
CartCoord globalNbNodesY(Int32 level) const override
Méthode permettant de récupérer le nombre de noeuds global en Y d'un niveau.
Int64 faceUniqueId(CartCoord3 face_coord, Int32 level) override
Méthode permettant de récupérer l'uniqueId d'une face à partir de sa position et de son niveau.
CartCoord globalNbFacesY(Int32 level) const override
Méthode permettant de récupérer le nombre de faces global en Y d'un niveau.
Int32 nodeLevel(Int64 uid) const override
Méthode permettant de récupérer le niveau d'un noeud avec son uid.
Int64 childCellUniqueIdOfCell(Cell cell, CartCoord3 child_coord_in_parent) override
Méthode permettant de récupérer l'uniqueId d'une maille enfant d'une maille parent à partir de la pos...
CartCoord globalNbFacesX(Int32 level) const override
Méthode permettant de récupérer le nombre de faces global en X d'un niveau.
CartCoord cellUniqueIdToCoordY(Int64 uid, Int32 level) override
Méthode permettant de récupérer la coordonnée en Y d'une maille grâce à son uniqueId.
Int64 parentCellUniqueIdOfCell(Int64 uid, Int32 level, bool do_fatal) override
Méthode permettant de récupérer l'uniqueId du parent d'une maille.
Maille d'un maillage.
Definition Item.h:1214
Int32 nbHChildren() const
Nombre d'enfants pour l'AMR.
Definition Item.h:1333
Cell hChild(Int32 i) const
i-ème enfant AMR
Definition Item.h:1336
Int32 level() const
Definition Item.h:1368
Vue constante d'un tableau de type T.
Face d'une maille.
Definition Item.h:964
Interface du gestionnaire de traces.
virtual TraceMessage info()=0
Flot pour un message d'information.
Int32 flags() const
Flags de l'entité
@ II_JustAdded
L'entité vient d'être ajoutée.
Definition ItemFlags.h:61
@ II_JustRefined
L'entité vient d'être raffinée.
Definition ItemFlags.h:78
Node node(Int32 i) const
i-ème noeud de l'entité
Definition Item.h:791
ItemUniqueId uniqueId() const
Identifiant unique sur tous les domaines.
Definition Item.h:225
impl::ItemBase itemBase() const
Partie interne de l'entité.
Definition Item.h:369
Noeud d'un maillage.
Definition Item.h:582
Classe gérant un vecteur de réel de dimension 3.
Definition Real3.h:132
TraceMessage info() const
Flot pour un message d'information.
Positionne une classe de message.
Vecteur 1D de données avec sémantique par valeur (style STL).
T max(const T &a, const T &b, const T &c)
Retourne le maximum de trois éléments.
Definition MathUtils.h:392
MeshVariableScalarRefT< Node, Real3 > VariableNodeReal3
Grandeur au noeud de type coordonnées.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Int32 CartCoord
Représente une coordonnée d'un élément dans la grille cartésienne (en X ou en Y ou en Z).
std::int64_t Int64
Type entier signé sur 64 bits.
Int32 Integer
Type représentant un entier.
ConstArrayView< Int64 > Int64ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 64 bits.
Definition UtilsTypes.h:480
@ MD_DirZ
Direction Z.
@ MD_DirY
Direction Y.
@ MD_DirX
Direction X.
double Real
Type représentant un réel.
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Créé une référence sur un pointeur.
Int32x2 CartCoord2
Représente les coordonnées 2D d'un élément dans la grille cartésienne {x, y}.
std::int32_t Int32
Type entier signé sur 32 bits.
Int32x3 CartCoord3
Représente les coordonnées 3D d'un élément dans la grille cartésienne {x, y, z}.
Real y
deuxième composante du triplet
Definition Real3.h:36
Real z
troisième composante du triplet
Definition Real3.h:37
Real x
première composante du triplet
Definition Real3.h:35