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