Arcane  v3.16.0.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
CartesianMesh.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/* CartesianMesh.cc (C) 2000-2025 */
9/* */
10/* Maillage cartésien. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/TraceAccessor.h"
15#include "arcane/utils/NotImplementedException.h"
16#include "arcane/utils/AutoDestroyUserData.h"
17#include "arcane/utils/IUserDataList.h"
18#include "arcane/utils/Ref.h"
19#include "arcane/utils/ScopedPtr.h"
20#include "arcane/utils/PlatformUtils.h"
21#include "arcane/utils/Event.h"
22
23#include "arcane/core/IMesh.h"
24#include "arcane/core/ItemPrinter.h"
25#include "arcane/core/IItemFamily.h"
26#include "arcane/core/IParallelMng.h"
27#include "arcane/core/VariableTypes.h"
28#include "arcane/core/Properties.h"
29#include "arcane/core/IMeshModifier.h"
30#include "arcane/core/MeshStats.h"
31#include "arcane/core/ICartesianMeshGenerationInfo.h"
32#include "arcane/core/MeshEvents.h"
33#include "arcane/core/MeshKind.h"
34#include "arcane/core/internal/IMeshInternal.h"
35
36#include "arcane/cartesianmesh/CartesianPatchGroup.h"
37#include "arcane/cartesianmesh/ICartesianMesh.h"
38#include "arcane/cartesianmesh/CartesianConnectivity.h"
39#include "arcane/cartesianmesh/CartesianMeshRenumberingInfo.h"
40#include "arcane/cartesianmesh/CartesianMeshCoarsening.h"
41#include "arcane/cartesianmesh/CartesianMeshCoarsening2.h"
42#include "arcane/cartesianmesh/CartesianMeshPatchListView.h"
43#include "arcane/cartesianmesh/internal/CartesianMeshPatch.h"
44#include "arcane/cartesianmesh/internal/ICartesianMeshInternal.h"
45
46#include "arcane/cartesianmesh/internal/CartesianMeshUniqueIdRenumbering.h"
47#include "arcane/cartesianmesh/v2/CartesianMeshUniqueIdRenumberingV2.h"
48#include "arcane/cartesianmesh/CartesianMeshNumberingMng.h"
49
50#include "arcane/cartesianmesh/CartesianMeshAMRPatchMng.h"
51#include "arcane/core/IGhostLayerMng.h"
52
53#include <set>
54
55/*---------------------------------------------------------------------------*/
56/*---------------------------------------------------------------------------*/
57/*!
58 * \defgroup ArcaneCartesianMesh Maillages cartésiens.
59 *
60 * Ensemble des classes assurant la gestion des maillage cartésiens.
61 *
62 * Pour plus de renseignements, se reporter à la page \ref arcanedoc_entities_cartesianmesh.
63 */
64/*---------------------------------------------------------------------------*/
65/*---------------------------------------------------------------------------*/
66
67namespace Arcane
68{
69
70/*---------------------------------------------------------------------------*/
71/*---------------------------------------------------------------------------*/
72/*!
73 * \brief Infos spécifiques à un maillage cartésien.
74 */
75class CartesianMeshImpl
76: public TraceAccessor
77, public ICartesianMesh
78{
79 class InternalApi
80 : public ICartesianMeshInternal
81 {
82 public:
83
84 explicit InternalApi(CartesianMeshImpl* cartesian_mesh)
85 : m_cartesian_mesh(cartesian_mesh)
86 {
87 }
88
89 public:
90
91 Ref<CartesianMeshCoarsening2> createCartesianMeshCoarsening2() override
92 {
93 return m_cartesian_mesh->_createCartesianMeshCoarsening2();
94 }
95 void addPatchFromExistingChildren(ConstArrayView<Int32> parent_cells_local_id) override
96 {
97 m_cartesian_mesh->_addPatchFromExistingChildren(parent_cells_local_id);
98 }
99 void initCartesianMeshAMRPatchMng() override
100 {
101 if (m_numbering_mng.isNull()) {
102 initCartesianMeshNumberingMng();
103 }
104 if (m_amr_mng.isNull()) {
105 m_amr_mng = makeRef(new CartesianMeshAMRPatchMng(m_cartesian_mesh, m_numbering_mng.get()));
106 }
107 }
108 Ref<ICartesianMeshAMRPatchMng> cartesianMeshAMRPatchMng() override
109 {
110 return m_amr_mng;
111 }
112 void initCartesianMeshNumberingMng() override
113 {
114 if (m_numbering_mng.isNull()) {
115 m_numbering_mng = makeRef(new CartesianMeshNumberingMng(m_cartesian_mesh->mesh()));
116 }
117 }
118 Ref<ICartesianMeshNumberingMng> cartesianMeshNumberingMng() override
119 {
120 return m_numbering_mng;
121 }
122
123 private:
124
125 CartesianMeshImpl* m_cartesian_mesh = nullptr;
127 Ref<ICartesianMeshNumberingMng> m_numbering_mng;
128 };
129
130 public:
131
132 explicit CartesianMeshImpl(IMesh* mesh);
133
134 public:
135
136 void build() override;
137
138 //! Maillage associé à ce maillage cartésien
139 IMesh* mesh() const override { return m_mesh; }
140
141 //! Gestionnaire de trace associé.
142 ITraceMng* traceMng() const override { return TraceAccessor::traceMng(); }
143
145 {
146 return m_all_items_direction_info->cellDirection(dir);
147 }
148
150 {
151 return m_all_items_direction_info->cellDirection(idir);
152 }
153
155 {
156 return m_all_items_direction_info->faceDirection(dir);
157 }
158
160 {
161 return m_all_items_direction_info->faceDirection(idir);
162 }
163
165 {
166 return m_all_items_direction_info->nodeDirection(dir);
167 }
168
170 {
171 return m_all_items_direction_info->nodeDirection(idir);
172 }
173
174 void computeDirections() override;
175
176 void recreateFromDump() override;
177
179 {
180 return m_connectivity;
181 }
182
183 Int32 nbPatch() const override { return m_patch_group.nbPatch(); }
184 ICartesianMeshPatch* patch(Int32 index) const override { return m_patch_group.patch(index).get(); }
185 CartesianPatch amrPatch(Int32 index) const override { return CartesianPatch(m_patch_group.patch(index).get()); }
186 CartesianMeshPatchListView patches() const override { return m_patch_group.patchListView(); }
187
188 void refinePatch2D(Real2 position,Real2 length) override;
189 void refinePatch3D(Real3 position,Real3 length) override;
190 void refinePatch(const AMRZonePosition& position) override;
191
192 void coarseZone2D(Real2 position, Real2 length) override;
193 void coarseZone3D(Real3 position, Real3 length) override;
194 void coarseZone(const AMRZonePosition& position) override;
195
196 Integer reduceNbGhostLayers(Integer level, Integer target_nb_ghost_layers) override;
197
199
200 void checkValid() const override;
201
203
204 //! API interne à Arcane
205 ICartesianMeshInternal* _internalApi() override { return &m_internal_api; }
206
207 private:
208
209 // Implémentation de 'ICartesianMeshInternal'
210 Ref<CartesianMeshCoarsening2> _createCartesianMeshCoarsening2();
211 void _addPatchFromExistingChildren(ConstArrayView<Int32> parent_cells_local_id);
212
213 private:
214
215 InternalApi m_internal_api;
216 //! Indice dans la numérotation locale de la maille, de la face dans
217 // la direction X, Y ou Z
218 Int32 m_local_face_direction[3] = { -1, -1, -1 };
219 IMesh* m_mesh = nullptr;
220 Ref<CartesianMeshPatch> m_all_items_direction_info;
221 CartesianConnectivity m_connectivity;
222 UniqueArray<CartesianConnectivity::Index> m_nodes_to_cell_storage;
223 UniqueArray<CartesianConnectivity::Index> m_cells_to_node_storage;
224 UniqueArray<CartesianConnectivity::Permutation> m_permutation_storage;
225 bool m_is_amr = false;
226 //! Groupe de mailles pour chaque patch AMR.
227 CartesianPatchGroup m_patch_group;
228 ScopedPtrT<Properties> m_properties;
229
230 EventObserverPool m_event_pool;
231 bool m_is_mesh_event_added = false;
232 Int64 m_mesh_timestamp = 0;
233 eMeshAMRKind m_amr_type;
234
235 private:
236
237 void _computeMeshDirection(CartesianMeshPatch& cdi,eMeshDirection dir,
238 VariableCellReal3& cells_center,
239 VariableFaceReal3& faces_center,CellGroup all_cells,
240 NodeGroup all_nodes);
241 void _applyRefine(const AMRZonePosition &position);
242 void _removeCellsInPatches(ConstArrayView<Int32> const_array_view);
243 void _applyCoarse(const AMRZonePosition &position);
244 void _addPatch(const CellGroup& parent_cells);
245 void _saveInfosInProperties();
246
247 std::tuple<CellGroup, NodeGroup>
248 _buildPatchGroups(const CellGroup& cells, Integer patch_level);
249 void _checkNeedComputeDirections();
250 void _checkAddObservableMeshChanged();
251};
252
253/*---------------------------------------------------------------------------*/
254/*---------------------------------------------------------------------------*/
255
256extern "C++" ICartesianMesh*
257arcaneCreateCartesianMesh(IMesh* mesh)
258{
259 auto* cm = new CartesianMeshImpl(mesh);
260 cm->build();
261 return cm;
262}
263
264/*---------------------------------------------------------------------------*/
265/*---------------------------------------------------------------------------*/
266
267CartesianMeshImpl::
268CartesianMeshImpl(IMesh* mesh)
269: TraceAccessor(mesh->traceMng())
270, m_internal_api(this)
271, m_mesh(mesh)
272, m_nodes_to_cell_storage(platform::getDefaultDataAllocator())
273, m_cells_to_node_storage(platform::getDefaultDataAllocator())
274, m_permutation_storage(platform::getDefaultDataAllocator())
275, m_patch_group(this)
276, m_amr_type(mesh->meshKind().meshAMRKind())
277{
278 if (m_amr_type == eMeshAMRKind::PatchCartesianMeshOnly) {
279 m_internal_api.initCartesianMeshNumberingMng();
280 m_internal_api.initCartesianMeshAMRPatchMng();
281 }
282 m_all_items_direction_info = m_patch_group.groundPatch();
283}
284
285/*---------------------------------------------------------------------------*/
286/*---------------------------------------------------------------------------*/
287
288void CartesianMeshImpl::
289build()
290{
291 m_properties = new Properties(*(mesh()->properties()),"CartesianMesh");
292}
293
294namespace
295{
296const Int32 SERIALIZE_VERSION = 1;
297}
298
299/*---------------------------------------------------------------------------*/
300/*---------------------------------------------------------------------------*/
301
302void CartesianMeshImpl::
303_checkNeedComputeDirections()
304{
305 Int64 new_timestamp = mesh()->timestamp();
306 if (m_mesh_timestamp!=new_timestamp){
307 info() << "Mesh timestamp has changed (old=" << m_mesh_timestamp << " new=" << new_timestamp << ")";
309 }
310}
311
312/*---------------------------------------------------------------------------*/
313/*---------------------------------------------------------------------------*/
314
315void CartesianMeshImpl::
316_saveInfosInProperties()
317{
318 // Sauve le numéro de version pour être sur que c'est OK en reprise
319 m_properties->set("Version",SERIALIZE_VERSION);
320
321 // Sauve les informations des patches
322 UniqueArray<String> patch_group_names;
323 for (Integer i = 1; i < m_patch_group.nbPatch(); ++i) {
324 patch_group_names.add(m_patch_group.cells(i).name());
325 }
326 m_properties->set("PatchGroupNames",patch_group_names);
327}
328
329/*---------------------------------------------------------------------------*/
330/*---------------------------------------------------------------------------*/
331
334{
335 info() << "Creating 'CartesianMesh' infos from dump";
336
337 // Sauve le numéro de version pour être sur que c'est OK en reprise
338 Int32 v = m_properties->getInt32("Version");
339 if (v!=SERIALIZE_VERSION)
340 ARCANE_FATAL("Bad serializer version: trying to read from incompatible checkpoint v={0} expected={1}",
341 v,SERIALIZE_VERSION);
342
343 // Récupère les noms des groupes des patchs
344 UniqueArray<String> patch_group_names;
345 m_properties->get("PatchGroupNames",patch_group_names);
346 info(4) << "Found n=" << patch_group_names.size() << " patchs";
347 m_patch_group.clear();
348 m_all_items_direction_info = m_patch_group.groundPatch();
349 IItemFamily* cell_family = m_mesh->cellFamily();
350 for( const String& x : patch_group_names ){
351 CellGroup group = cell_family->findGroup(x);
352 if (group.null())
353 ARCANE_FATAL("Can not find cell group '{0}'",x);
354 m_patch_group.addPatch(group);
355 }
356
358}
359
360/*---------------------------------------------------------------------------*/
361/*---------------------------------------------------------------------------*/
362
363void CartesianMeshImpl::
364_checkAddObservableMeshChanged()
365{
366 if (m_is_mesh_event_added)
367 return;
368 m_is_mesh_event_added = true;
369 // Pour appeler automatiquement 'computeDirections()' après un appel à
370 // IMesh::prepareForDump().
371 auto f1 = [&](const MeshEventArgs&){ this->_checkNeedComputeDirections(); };
372 mesh()->eventObservable(eMeshEventType::EndPrepareDump).attach(m_event_pool,f1);
373}
374
375/*---------------------------------------------------------------------------*/
376/*---------------------------------------------------------------------------*/
377
380{
381 info() << "CartesianMesh: computeDirections()";
382
383 m_mesh_timestamp = mesh()->timestamp();
384 _checkAddObservableMeshChanged();
385
386 m_is_amr = m_mesh->isAmrActivated();
387
388 VariableCellReal3 cells_center(VariableBuildInfo(m_mesh,"TemporaryCartesianMeshCellCenter"));
389 VariableFaceReal3 faces_center(VariableBuildInfo(m_mesh,"TemporaryCartesianMeshFaceCenter"));
390
391 // Calcule les coordonnées du centre des mailles.
392 VariableNodeReal3& nodes_coord = m_mesh->nodesCoordinates();
393 ENUMERATE_CELL(icell,m_mesh->allCells()){
394 Cell cell = *icell;
395 Real3 center;
396 for( NodeLocalId inode : cell.nodeIds() )
397 center += nodes_coord[inode];
398 center /= cell.nbNode();
399 cells_center[icell] = center;
400 }
401 ENUMERATE_FACE(iface,m_mesh->allFaces()){
402 Face face = *iface;
403 Real3 center;
404 for( NodeLocalId inode : face.nodeIds() )
405 center += nodes_coord[inode];
406 center /= face.nbNode();
407 faces_center[iface] = center;
408 }
409
410 IItemFamily* cell_family = m_mesh->cellFamily();
411 IItemFamily* node_family = m_mesh->nodeFamily();
412 Int32 next_face_x = -1;
413 Int32 next_face_y = -1;
414 Int32 next_face_z = -1;
415
416 CellVectorView cell_view = cell_family->allItems().view();
417 Cell cell0 = cell_view[0];
418 Integer nb_face = cell0.nbFace();
419 Integer nb_node = cell0.nbNode();
420 Real3 cell_center = cells_center[cell0];
421
422 info(4) << "sizeof(CellDirectionMng)=" << sizeof(CellDirectionMng)
423 << " sizeof(FaceDirectionMng)=" << sizeof(FaceDirectionMng)
424 << " sizeof(NodelDirectionMng)=" << sizeof(NodeDirectionMng);
425 info(4) << "sizeof(IndexedItemConnectivityViewBase)=" << sizeof(IndexedItemConnectivityViewBase)
426 << " sizeof(CellInfoListView)=" << sizeof(CellInfoListView);
427 info(4) << "Cartesian mesh compute directions is_amr=" << m_is_amr;
428
429 for( Integer i=0; i<nb_node; ++i ){
430 Node node = cell0.node(i);
431 info(4) << "Node I=" << i << " node=" << ItemPrinter(node) << " pos=" << nodes_coord[node];
432 }
433
434 bool is_3d = m_mesh->dimension() == 3;
435
436 // On suppose que toutes les mailles ont le même sens de numérotation dans le maillage.
437 // Par exemple, pour toutes les mailles, la face d'indice 0 est celle du haut, celle
438 // d'indice 1 celle de droite.
439 if (is_3d) {
440 Real max_x = -1;
441 Real max_y = -1;
442 Real max_z = -1;
443
444 for (Integer i = 0; i < nb_face; ++i) {
445 Face f = cell0.face(i);
446
447 Real3 next_center = faces_center[f];
448
449 Real diff_x = next_center.x - cell_center.x;
450 Real diff_y = next_center.y - cell_center.y;
451 Real diff_z = next_center.z - cell_center.z;
452
453 info(4) << "NEXT_FACE=" << ItemPrinter(f) << " center=" << next_center << " diff=" << Real3(diff_x, diff_y, diff_z);
454
455 if (diff_x > max_x) {
456 max_x = diff_x;
457 next_face_x = i;
458 }
459
460 if (diff_y > max_y) {
461 max_y = diff_y;
462 next_face_y = i;
463 }
464
465 if (diff_z > max_z) {
466 max_z = diff_z;
467 next_face_z = i;
468 }
469 }
470 info(4) << "Advance in direction X -> " << next_face_x;
471 info(4) << "Advance in direction Y -> " << next_face_y;
472 info(4) << "Advance in direction Z -> " << next_face_z;
473 }
474 else {
475 Real max_x = -1;
476 Real max_y = -1;
477
478 for (Integer i = 0; i < nb_face; ++i) {
479 Face f = cell0.face(i);
480
481 Real3 next_center = faces_center[f];
482
483 Real diff_x = next_center.x - cell_center.x;
484 Real diff_y = next_center.y - cell_center.y;
485
486 info(4) << "NEXT_FACE=" << ItemPrinter(f) << " center=" << next_center << " diff=" << Real2(diff_x, diff_y);
487
488 if (diff_x > max_x) {
489 max_x = diff_x;
490 next_face_x = i;
491 }
492
493 if (diff_y > max_y) {
494 max_y = diff_y;
495 next_face_y = i;
496 }
497 }
498 info(4) << "Advance in direction X -> " << next_face_x;
499 info(4) << "Advance in direction Y -> " << next_face_y;
500 }
501 m_all_items_direction_info->_internalComputeNodeCellInformations(cell0,cells_center[cell0],nodes_coord);
502
503 info() << "Informations from IMesh properties:";
504
505 auto* cmgi = ICartesianMeshGenerationInfo::getReference(m_mesh,true);
506
507 info() << "GlobalNbCell = " << cmgi->globalNbCells();
508 info() << "OwnNbCell: " << cmgi->ownNbCells();
509 info() << "SubDomainOffset: " << cmgi->subDomainOffsets();
510 info() << "OwnCellOffset: " << cmgi->ownCellOffsets();
511
512 CellGroup all_cells = cell_family->allItems();
513 NodeGroup all_nodes = node_family->allItems();
514 if (m_is_amr){
515 auto x = _buildPatchGroups(mesh()->allLevelCells(0),0);
516 all_cells = std::get<0>(x);
517 all_nodes = std::get<1>(x);
518 }
519
520 if (next_face_x!=(-1)){
521 m_local_face_direction[MD_DirX] = next_face_x;
522 _computeMeshDirection(*m_all_items_direction_info.get(),MD_DirX,cells_center,faces_center,all_cells,all_nodes);
523 }
524 if (next_face_y!=(-1)){
525 m_local_face_direction[MD_DirY] = next_face_y;
526 _computeMeshDirection(*m_all_items_direction_info.get(),MD_DirY,cells_center,faces_center,all_cells,all_nodes);
527 }
528 if (next_face_z != (-1)) {
529 m_local_face_direction[MD_DirZ] = next_face_z;
530 _computeMeshDirection(*m_all_items_direction_info.get(),MD_DirZ,cells_center,faces_center,all_cells,all_nodes);
531 }
532
533 // Positionne les informations par direction
534 for( Integer idir=0, nb_dir=mesh()->dimension(); idir<nb_dir; ++idir ){
535 CellDirectionMng& cdm = m_all_items_direction_info->cellDirection(idir);
536 cdm._internalSetOffsetAndNbCellInfos(cmgi->globalNbCells()[idir], cmgi->ownNbCells()[idir],
537 cmgi->subDomainOffsets()[idir], cmgi->ownCellOffsets()[idir]);
538 }
539
540 info() << "Compute cartesian connectivity";
541
542 m_permutation_storage.resize(1);
543 m_permutation_storage[0].compute();
544 m_nodes_to_cell_storage.resize(mesh()->nodeFamily()->maxLocalId());
545 m_cells_to_node_storage.resize(mesh()->cellFamily()->maxLocalId());
546 m_connectivity._setStorage(m_nodes_to_cell_storage,m_cells_to_node_storage,&m_permutation_storage[0]);
547 m_connectivity._computeInfos(mesh(),nodes_coord,cells_center);
548
549 // Ajoute informations de connectivités pour les patchs AMR
550 // TODO: supporter plusieurs appels à cette méthode ?
551 for (Integer patch_index = 1; patch_index < m_patch_group.nbPatch(); ++patch_index) {
552 CellGroup cells = m_patch_group.cells(patch_index);
553 Ref<CartesianMeshPatch> patch = m_patch_group.patch(patch_index);
554 info() << "AMR Patch name=" << cells.name() << " size=" << cells.size() << " index=" << patch_index << " nbPatch=" << m_patch_group.nbPatch();
555 patch->_internalComputeNodeCellInformations(cell0, cells_center[cell0], nodes_coord);
556 auto [patch_cells, patch_nodes] = _buildPatchGroups(cells, patch_index);
557 _computeMeshDirection(*patch.get(), MD_DirX, cells_center, faces_center, patch_cells, patch_nodes);
558 _computeMeshDirection(*patch.get(), MD_DirY, cells_center, faces_center, patch_cells, patch_nodes);
559 if (is_3d)
560 _computeMeshDirection(*patch.get(), MD_DirZ, cells_center, faces_center, patch_cells, patch_nodes);
561 }
562
563 if (arcaneIsCheck())
564 checkValid();
565
566 _saveInfosInProperties();
567}
568
569/*---------------------------------------------------------------------------*/
570/*---------------------------------------------------------------------------*/
571
572std::tuple<CellGroup,NodeGroup> CartesianMeshImpl::
573_buildPatchGroups(const CellGroup& cells,Integer patch_level)
574{
575 // On créé un groupe pour chaque patch en garantissant que l'ordre de parcours
576 // est celui des uniqueId() des entités
577 // TODO: à terme, il faudrait que l'ordre de parcours soit le même que
578 // celui du maillage cartésien. Pour cela, il faut soit que les uniqueId()
579 // des mailles/noeuds créés soient dans le même ordre que le maillage cartésien,
580 // soit que la fonction de tri soit spécifique à ce type de maillage.
581 NodeGroup nodes = cells.nodeGroup();
582 IItemFamily* cell_family = cells.itemFamily();
583 IItemFamily* node_family = nodes.itemFamily();
584
585 String cell_group_name = String("AMRPatchCells") + patch_level;
586 CellGroup patch_cells = cell_family->createGroup(cell_group_name,Int32ConstArrayView(),true);
587 // Met les mêmes mailles que \a cells mais force le tri
588 patch_cells.setItems(cells.view().localIds(),true);
589
590 String node_group_name = String("AMRPatchNodes") + patch_level;
591 NodeGroup patch_nodes = node_family->createGroup(node_group_name,Int32ConstArrayView(),true);
592 // Met les mêmes noeuds que \a nodes mais force le tri
593 patch_nodes.setItems(nodes.view().localIds(),true);
594 info(4) << "PATCH_CELLS name=" << patch_cells.name() << " size=" << patch_cells.size();
595 info(4) << "PATCH_NODES name=" << patch_nodes.name() << " size=" << patch_nodes.size();
596 return { patch_cells, patch_nodes };
597}
598
599/*---------------------------------------------------------------------------*/
600/*---------------------------------------------------------------------------*/
601
602void CartesianMeshImpl::
603_computeMeshDirection(CartesianMeshPatch& cdi,eMeshDirection dir,VariableCellReal3& cells_center,
604 VariableFaceReal3& faces_center,CellGroup all_cells,NodeGroup all_nodes)
605{
606 IItemFamily* cell_family = m_mesh->cellFamily();
607 IItemFamily* face_family = m_mesh->faceFamily();
608 IItemFamily* node_family = m_mesh->nodeFamily();
609
610 Int32 max_cell_id = cell_family->maxLocalId();
611 Int32 max_face_id = face_family->maxLocalId();
612 Int32 max_node_id = node_family->maxLocalId();
613
614 CellDirectionMng& cell_dm = cdi.cellDirection(dir);
615 cell_dm._internalResizeInfos(max_cell_id);
616
617 FaceDirectionMng& face_dm = cdi.faceDirection(dir);
618 face_dm._internalResizeInfos(max_face_id);
619
620 NodeDirectionMng& node_dm = cdi.nodeDirection(dir);
621 node_dm._internalResizeInfos(max_node_id);
622
623 //TODO: attention à remettre à jour après changement de maillage.
624 info(4) << "COMPUTE DIRECTION dir=" << dir;
625
626 Int32 prev_local_face = -1;
627 Int32 next_local_face = m_local_face_direction[dir];
628 Integer mesh_dim = m_mesh->dimension();
629 // Calcul le numero local de face oppose à la face suivante.
630 if (mesh_dim==2)
631 prev_local_face = (next_local_face + 2) % 4;
632 else if (mesh_dim==3)
633 prev_local_face = (next_local_face + 3) % 6;
634
635 cell_dm._internalSetLocalFaceIndex(next_local_face,prev_local_face);
636
637 // Positionne pour chaque maille les faces avant et après dans la direction.
638 // On s'assure que ces entités sont dans le groupe des entités de la direction correspondante
639 std::set<Int32> cells_set;
640 ENUMERATE_CELL(icell,all_cells){
641 cells_set.insert(icell.itemLocalId());
642 }
643
644 // Calcule les mailles devant/derrière. En cas de patch AMR, il faut que ces deux mailles
645 // soient de même niveau
646 ENUMERATE_CELL(icell,all_cells){
647 Cell cell = *icell;
648 Int32 my_level = cell.level();
649 Face next_face = cell.face(next_local_face);
650 Cell next_cell = next_face.backCell()==cell ? next_face.frontCell() : next_face.backCell();
651 if (cells_set.find(next_cell.localId())==cells_set.end())
652 next_cell = Cell();
653 else if (next_cell.level()!=my_level)
654 next_cell = Cell();
655
656 Face prev_face = cell.face(prev_local_face);
657 Cell prev_cell = prev_face.backCell()==cell ? prev_face.frontCell() : prev_face.backCell();
658 if (cells_set.find(prev_cell.localId())==cells_set.end())
659 prev_cell = Cell();
660 else if (prev_cell.level()!=my_level)
661 prev_cell = Cell();
662 cell_dm.m_infos_view[icell.itemLocalId()] = CellDirectionMng::ItemDirectionInfo(next_cell,prev_cell);
663 }
664 cell_dm._internalComputeInnerAndOuterItems(all_cells);
665 face_dm._internalComputeInfos(cell_dm,cells_center,faces_center);
666 node_dm._internalComputeInfos(cell_dm,all_nodes,cells_center);
667}
668
669/*---------------------------------------------------------------------------*/
670/*---------------------------------------------------------------------------*/
671
673refinePatch2D(Real2 position,Real2 length)
674{
675 info() << "REFINEMENT 2D position=" << position << " length=" << length;
676 refinePatch({ position, length });
677}
678
679/*---------------------------------------------------------------------------*/
680/*---------------------------------------------------------------------------*/
681
683refinePatch3D(Real3 position, Real3 length)
684{
685 info() << "REFINEMENT 3D position=" << position << " length=" << length;
686 refinePatch({ position, length });
687}
688
689/*---------------------------------------------------------------------------*/
690/*---------------------------------------------------------------------------*/
691
693refinePatch(const AMRZonePosition& position)
694{
695 _applyRefine(position);
696 _saveInfosInProperties();
697}
698
699/*---------------------------------------------------------------------------*/
700/*---------------------------------------------------------------------------*/
701
703coarseZone2D(Real2 position, Real2 length)
704{
705 info() << "COARSEN 2D position=" << position << " length=" << length;
706 coarseZone({ position, length });
707}
708
709/*---------------------------------------------------------------------------*/
710/*---------------------------------------------------------------------------*/
711
713coarseZone3D(Real3 position, Real3 length)
714{
715 info() << "COARSEN 3D position=" << position << " length=" << length;
716 coarseZone({ position, length });
717}
718
719/*---------------------------------------------------------------------------*/
720/*---------------------------------------------------------------------------*/
721
723coarseZone(const AMRZonePosition& position)
724{
725 _applyCoarse(position);
726 _saveInfosInProperties();
727}
728
729/*---------------------------------------------------------------------------*/
730/*---------------------------------------------------------------------------*/
731
733reduceNbGhostLayers(Integer level, Integer target_nb_ghost_layers)
734{
735 if (level < 1) {
736 ARCANE_FATAL("You cannot reduce number of ghost layer of level 0 with this method");
737 }
738
739 // Nombre de couche de maille fantôme max. Bof; à modifier.
740 const Int32 max_nb_layer = 128;
741 Int32 level_max = 0;
742
743 ENUMERATE_ (Cell, icell, m_mesh->allCells()) {
744 level_max = std::max(level_max, icell->level());
745 }
746
747 level_max = m_mesh->parallelMng()->reduce(Parallel::ReduceMax, level_max);
748 //debug() << "Level max : " << level_max;
749
751
752 Integer level_0_nb_ghost_layer = m_mesh->ghostLayerMng()->nbGhostLayer();
753 //debug() << "NbGhostLayers level 0 : " << level_0_nb_ghost_layer;
754
755 if (level_0_nb_ghost_layer == 0) {
756 return 0;
757 }
758
759 Integer nb_ghost_layer = Convert::toInt32(level_0_nb_ghost_layer * pow(2, level));
760
761 //debug() << "NbGhostLayers level " << level << " : " << nb_ghost_layer;
762
763 // On considère qu'on a toujours 2*2 mailles filles (2*2*2 en 3D).
764 if (target_nb_ghost_layers % 2 != 0) {
765 target_nb_ghost_layers++;
766 }
767
768 if (target_nb_ghost_layers == nb_ghost_layer) {
769 return nb_ghost_layer;
770 }
771
772 //debug() << "TargetNbGhostLayers level " << level << " : " << target_nb_ghost_layers;
773
774 Integer parent_level = level - 1;
775 Integer parent_target_nb_ghost_layer = target_nb_ghost_layers / 2;
776
777 // TODO AH : On est forcé de dé-raffiner niveau par niveau. À changer.
778 UniqueArray<UniqueArray<Int32>> cell_lid2(level_max);
779
780 //UniqueArray<Int32> cell_lid;
781 std::function<void(Cell)> children_list;
782
783 children_list = [&cell_lid2, &children_list](Cell cell) -> void {
784 for (Integer i = 0; i < cell.nbHChildren(); ++i) {
785 //debug() << "child of lid=" << cell.localId() << " : lid=" << cell.hChild(i).localId() << " -- level : " << cell.level();
786 cell_lid2[cell.level()].add(cell.hChild(i).localId());
787 children_list(cell.hChild(i));
788 }
789 };
790
791 // Algorithme de numérotation des couches de mailles fantômes.
792 {
793 VariableNodeInt32 level_node{ VariableBuildInfo{ m_mesh, "LevelNode" } };
794 level_node.fill(-1);
795
796 VariableCellInt32 level_cell{ VariableBuildInfo{ m_mesh, "LevelCell" } };
797 level_cell.fill(-1);
798
799 ENUMERATE_ (Face, iface, m_mesh->allFaces()) {
800 Cell front_cell = iface->frontCell();
801 Cell back_cell = iface->backCell();
802 if (
803 ((front_cell.null() || (!front_cell.isOwn() && front_cell.level() == parent_level)) && ((!back_cell.null()) && (back_cell.isOwn() && back_cell.level() == parent_level))) ||
804 ((back_cell.null() || (!back_cell.isOwn() && back_cell.level() == parent_level)) && ((!front_cell.null()) && (front_cell.isOwn() && front_cell.level() == parent_level)))) {
805 for (Node node : iface->nodes()) {
806 level_node[node] = 0;
807 //debug() << "Node layer 0 : " << node.uniqueId();
808 }
809 }
810 }
811
812 bool is_modif = true;
813 Int32 current_layer = 0;
814 while (is_modif) {
815 is_modif = false;
816
817 ENUMERATE_ (Cell, icell, m_mesh->allCells()) {
818 if (icell->isOwn() || icell->level() != parent_level || level_cell[icell] != -1) {
819 continue;
820 }
821
822 Int32 min = max_nb_layer;
823 Int32 max = -1;
824
825 for (Node node : icell->nodes()) {
826 Int32 nlevel = level_node[node];
827 if (nlevel != -1) {
828 min = std::min(min, nlevel);
829 max = std::max(max, nlevel);
830 }
831 }
832
833 // On fait couche par couche (voir pour enlever cette limitation).
834 if (min != current_layer) {
835 continue;
836 }
837
838 // Maille n'ayant pas de nodes déjà traités.
839 if (min == max_nb_layer && max == -1) {
840 continue;
841 }
842
843 Integer new_level = ((min == max) ? min + 1 : max);
844
845 for (Node node : icell->nodes()) {
846 Int32 nlevel = level_node[node];
847 if (nlevel == -1) {
848 level_node[node] = new_level;
849 //debug() << "Node layer " << new_level << " : " << node.uniqueId();
850 is_modif = true;
851 }
852 }
853
854 level_cell[icell] = min;
855
856 //debug() << "Cell uid : " << icell->uniqueId()
857 // << " -- Layer : " << min;
858
859 if (min >= parent_target_nb_ghost_layer) {
860 children_list(*icell);
861 }
862 }
863 current_layer++;
864 if (current_layer >= max_nb_layer) {
865 ARCANE_FATAL("Error in ghost layer counter algo. Report it plz.");
866 }
867 }
868 }
869
870 for (Integer i = level_max - 1; i >= 0; --i) {
871 // Une comm pour en éviter plein d'autres.
872 if (m_mesh->parallelMng()->reduce(Parallel::ReduceMax, cell_lid2[i].size()) == 0) {
873 continue;
874 }
875 //debug() << "Removing children of ghost cell (parent level=" << i << ") (children localIds) : " << cell_lid2[i];
876
877 m_mesh->modifier()->flagCellToCoarsen(cell_lid2[i]);
878 m_mesh->modifier()->coarsenItemsV2(false);
879 }
880
881 info() << "Nb ghost layer for level " << level << " : " << target_nb_ghost_layers;
882
883 return target_nb_ghost_layers;
884}
885
886/*---------------------------------------------------------------------------*/
887/*---------------------------------------------------------------------------*/
888
889void CartesianMeshImpl::
890_addPatchFromExistingChildren(ConstArrayView<Int32> parent_cells_local_id)
891{
892 IItemFamily* cell_family = m_mesh->cellFamily();
893 Integer index = m_patch_group.nextIndexForNewPatch();
894 String parent_group_name = String("CartesianMeshPatchParentCells")+index;
895 CellGroup parent_cells = cell_family->createGroup(parent_group_name,parent_cells_local_id,true);
896 _addPatch(parent_cells);
897}
898
899/*---------------------------------------------------------------------------*/
900/*---------------------------------------------------------------------------*/
901/*!
902 * \brief Créé un patch avec tous les enfants du groupe \a parent_cells.
903 */
904void CartesianMeshImpl::
905_addPatch(const CellGroup& parent_cells)
906{
907 Integer index = m_patch_group.nextIndexForNewPatch();
908 info() << "Add patch index : " << index;
909 // Créé le groupe contenant les mailles AMR
910 // Il s'agit des mailles filles de \a parent_cells
911 String children_group_name = String("CartesianMeshPatchCells")+index;
912 UniqueArray<Int32> children_local_id;
913 ENUMERATE_(Cell,icell,parent_cells){
914 Cell c = *icell;
915 for(Integer k=0; k<c.nbHChildren(); ++k ){
916 Cell child = c.hChild(k);
917 children_local_id.add(child.localId());
918 }
919 }
920 IItemFamily* cell_family = m_mesh->cellFamily();
921 CellGroup children_cells = cell_family->createGroup(children_group_name, children_local_id, true);
922 m_patch_group.addPatch(children_cells);
923}
924
925/*---------------------------------------------------------------------------*/
926/*---------------------------------------------------------------------------*/
927
928void CartesianMeshImpl::
929_removeCellsInPatches(ConstArrayView<Int32> const_array_view)
930{
931 if (m_amr_type == eMeshAMRKind::Cell) {
932 m_patch_group.removeCellsInAllPatches(const_array_view);
933 m_patch_group.applyPatchEdit(true);
934 }
935 else if (m_amr_type == eMeshAMRKind::PatchCartesianMeshOnly) {
936 m_patch_group.removeCellsInAllPatches(const_array_view);
937 // SharedArray<Integer> altered_patches;
938 // m_patch_group.removeCellsInAllPatches(const_array_view, altered_patches);
939 // info() << "altered_patches : " << altered_patches;
940 // for (Integer index : altered_patches) {
941 // m_patch_group.repairPatch(index, _internalApi()->cartesianMeshNumberingMng().get());
942 // }
943 m_patch_group.applyPatchEdit(true);
944 }
945 else if (m_amr_type == eMeshAMRKind::Patch) {
946 ARCANE_FATAL("General patch AMR is not implemented. Please use PatchCartesianMeshOnly (3)");
947 }
948 else {
949 ARCANE_FATAL("AMR is not enabled");
950 }
951}
952
953/*---------------------------------------------------------------------------*/
954/*---------------------------------------------------------------------------*/
955
956void CartesianMeshImpl::
957_applyRefine(const AMRZonePosition& position)
958{
959 SharedArray<Int32> cells_local_id;
960 position.cellsInPatch(mesh(), cells_local_id);
961
962 IItemFamily* cell_family = m_mesh->cellFamily();
963 Integer nb_cell = cells_local_id.size();
964 info(4) << "Local_NbCellToRefine = " << nb_cell;
965 Integer index = m_patch_group.nextIndexForNewPatch();
966 String parent_group_name = String("CartesianMeshPatchParentCells")+index;
967 CellGroup parent_cells = cell_family->createGroup(parent_group_name,cells_local_id,true);
968
969 IParallelMng* pm = m_mesh->parallelMng();
970 Int64 total_nb_cell = pm->reduce(Parallel::ReduceSum,nb_cell);
971 info(4) << "Global_NbCellToRefine = " << total_nb_cell;
972 if (total_nb_cell==0)
973 return;
974
975 if(m_amr_type == eMeshAMRKind::Cell) {
976 debug() << "Refine with modifier() (for all mesh types)";
977 m_mesh->modifier()->flagCellToRefine(cells_local_id);
978 m_mesh->modifier()->adapt();
979 }
980 else if(m_amr_type == eMeshAMRKind::PatchCartesianMeshOnly) {
981 debug() << "Refine with specific refiner (for cartesian mesh only)";
983 m_internal_api.cartesianMeshAMRPatchMng()->flagCellToRefine(cells_local_id, true);
984 m_internal_api.cartesianMeshAMRPatchMng()->refine();
985 }
986 else if(m_amr_type == eMeshAMRKind::Patch) {
987 ARCANE_FATAL("General patch AMR is not implemented. Please use PatchCartesianMeshOnly (3)");
988 }
989 else{
990 ARCANE_FATAL("AMR is not enabled");
991 }
992
993 {
994 MeshStats ms(traceMng(),m_mesh,m_mesh->parallelMng());
995 ms.dumpStats();
996 }
997 _addPatch(parent_cells);
998}
999
1000/*---------------------------------------------------------------------------*/
1001/*---------------------------------------------------------------------------*/
1002
1003void CartesianMeshImpl::
1004_applyCoarse(const AMRZonePosition& position)
1005{
1006 SharedArray<Int32> cells_local_id;
1007 position.cellsInPatch(mesh(), cells_local_id);
1008
1009 Integer nb_cell = cells_local_id.size();
1010 info(4) << "Local_NbCellToCoarsen = " << nb_cell;
1011
1012 IParallelMng* pm = m_mesh->parallelMng();
1013 Int64 total_nb_cell = pm->reduce(Parallel::ReduceSum, nb_cell);
1014 info(4) << "Global_NbCellToCoarsen = " << total_nb_cell;
1015 if (total_nb_cell == 0)
1016 return;
1017
1018 _removeCellsInPatches(cells_local_id);
1019
1020 if (m_amr_type == eMeshAMRKind::Cell) {
1021 debug() << "Coarse with modifier() (for all mesh types)";
1022 m_mesh->modifier()->flagCellToCoarsen(cells_local_id);
1023 m_mesh->modifier()->coarsenItemsV2(true);
1024 }
1025 else if (m_amr_type == eMeshAMRKind::PatchCartesianMeshOnly) {
1026 debug() << "Coarsen with specific coarser (for cartesian mesh only)";
1028 m_internal_api.cartesianMeshAMRPatchMng()->flagCellToCoarsen(cells_local_id, true);
1029 m_internal_api.cartesianMeshAMRPatchMng()->coarsen(true);
1030 }
1031 else if (m_amr_type == eMeshAMRKind::Patch) {
1032 ARCANE_FATAL("General patch AMR is not implemented. Please use PatchCartesianMeshOnly (3)");
1033 }
1034 else {
1035 ARCANE_FATAL("AMR is not enabled");
1036 }
1037
1038 {
1039 MeshStats ms(traceMng(), m_mesh, m_mesh->parallelMng());
1040 ms.dumpStats();
1041 }
1042}
1043
1044/*---------------------------------------------------------------------------*/
1045/*---------------------------------------------------------------------------*/
1046
1048checkValid() const
1049{
1050 info(4) << "Check valid CartesianMesh";
1051 Integer nb_patch = nbPatch();
1052 for( Integer i=0; i<nb_patch; ++i ){
1053 ICartesianMeshPatch* p = patch(i);
1054 p->checkValid();
1055 }
1056}
1057
1058/*---------------------------------------------------------------------------*/
1059/*---------------------------------------------------------------------------*/
1060
1063{
1064 auto* cmgi = ICartesianMeshGenerationInfo::getReference(m_mesh,true);
1065
1066 // Regarde d'abord si on renumérote les faces
1067 Int32 face_method = v.renumberFaceMethod();
1068 if (face_method!=0 && face_method!=1)
1069 ARCANE_FATAL("Invalid value '{0}' for renumberFaceMethod(). Valid values are 0 or 1",
1070 face_method);
1071 if (face_method==1)
1072 ARCANE_THROW(NotImplementedException,"Method 1 for face renumbering");
1073
1074 // Regarde ensuite les patchs si demandé.
1075 Int32 patch_method = v.renumberPatchMethod();
1076 if (patch_method < 0 || patch_method > 4)
1077 ARCANE_FATAL("Invalid value '{0}' for renumberPatchMethod(). Valid values are 0, 1, 2, 3 or 4",
1078 patch_method);
1079
1080 else if (patch_method == 1 || patch_method == 3 || patch_method == 4){
1081 CartesianMeshUniqueIdRenumbering renumberer(this,cmgi,v.parentPatch(),patch_method);
1082 renumberer.renumber();
1083 }
1084 else if (patch_method == 2){
1085 warning() << "The patch method 2 is experimental!";
1086 CartesianMeshUniqueIdRenumberingV2 renumberer(this,cmgi);
1087 renumberer.renumber();
1088 }
1089
1090 // Termine par un tri éventuel.
1091 if (v.isSortAfterRenumbering()){
1092 info() << "Compacting and Sorting after renumbering";
1093 m_mesh->nodeFamily()->compactItems(true);
1094 m_mesh->faceFamily()->compactItems(true);
1095 m_mesh->cellFamily()->compactItems(true);
1097 }
1098}
1099
1100/*---------------------------------------------------------------------------*/
1101/*---------------------------------------------------------------------------*/
1102
1108
1109/*---------------------------------------------------------------------------*/
1110/*---------------------------------------------------------------------------*/
1111
1112Ref<CartesianMeshCoarsening2> CartesianMeshImpl::
1113_createCartesianMeshCoarsening2()
1114{
1115 return makeRef(new CartesianMeshCoarsening2(this));
1116}
1117
1118/*---------------------------------------------------------------------------*/
1119/*---------------------------------------------------------------------------*/
1120
1121/*---------------------------------------------------------------------------*/
1122/*---------------------------------------------------------------------------*/
1123
1125getReference(const MeshHandleOrMesh& mesh_handle_or_mesh,bool create)
1126{
1127 MeshHandle h = mesh_handle_or_mesh.handle();
1128 //TODO: faire lock pour multi-thread
1129 const char* name = "CartesianMesh";
1130 IUserDataList* udlist = h.meshUserDataList();
1131
1132 IUserData* ud = udlist->data(name,true);
1133 if (!ud){
1134 if (!create)
1135 return nullptr;
1136 IMesh* mesh = h.meshOrNull();
1137 if (!mesh)
1138 ARCANE_FATAL("The mesh {0} is not yet created",h.meshName());
1139 ICartesianMesh* cm = arcaneCreateCartesianMesh(mesh);
1140 udlist->setData(name,new AutoDestroyUserData<ICartesianMesh>(cm));
1141
1142 // Indique que le maillage est cartésien
1143 MeshKind mk = mesh->meshKind();
1144 mk.setMeshStructure(eMeshStructure::Cartesian);
1145 mesh->_internalApi()->setMeshKind(mk);
1146
1147 return cm;
1148 }
1150 if (!adud)
1151 ARCANE_FATAL("Can not cast to ICartesianMesh*");
1152 return adud->data();
1153}
1154
1155/*---------------------------------------------------------------------------*/
1156/*---------------------------------------------------------------------------*/
1157
1158} // End namespace Arcane
1159
1160/*---------------------------------------------------------------------------*/
1161/*---------------------------------------------------------------------------*/
#define ARCANE_THROW(exception_class,...)
Macro pour envoyer une exception avec formattage.
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Fichier contenant les mécanismes de gestion des évènements.
#define ENUMERATE_FACE(name, group)
Enumérateur générique d'un groupe de faces.
#define ENUMERATE_(type, name, group)
Enumérateur générique d'un groupe d'entité
#define ENUMERATE_CELL(name, group)
Enumérateur générique d'un groupe de mailles.
Classe permettant de définir une zone d'un maillage.
Integer size() const
Nombre d'éléments du vecteur.
void add(ConstReferenceType val)
Ajoute l'élément val à la fin du tableau.
UserData s'auto-détruisant une fois détaché.
Informations de connectivité d'un maillage cartésien.
Déraffine un maillage cartésien par 2.
Déraffine un maillage cartésien par 2.
Infos spécifiques à un maillage cartésien.
void refinePatch3D(Real3 position, Real3 length) override
Raffine en 3D un bloc du maillage cartésien.
Int32 nbPatch() const override
Nombre de patchs du maillage.
Integer reduceNbGhostLayers(Integer level, Integer target_nb_ghost_layers) override
Méthode permettant de supprimer une ou plusieurs couches de mailles fantômes sur un niveau de raffine...
void refinePatch(const AMRZonePosition &position) override
Raffine un bloc du maillage cartésien.
ITraceMng * traceMng() const override
Gestionnaire de trace associé.
CellDirectionMng cellDirection(Integer idir) override
Liste des mailles dans la direction dir (0, 1 ou 2)
void recreateFromDump() override
Recalcule les informations de cartésiennes après une reprise.
void computeDirections() override
Calcule les infos pour les accès par direction.
FaceDirectionMng faceDirection(Integer idir) override
Liste des faces dans la direction dir (0, 1 ou 2)
void coarseZone(const AMRZonePosition &position) override
Dé-raffine un bloc du maillage cartésien.
NodeDirectionMng nodeDirection(Integer idir) override
Liste des noeuds dans la direction dir (0, 1 ou 2)
void checkValid() const override
Effectue des vérifications sur la validité de l'instance.
IMesh * mesh() const override
Maillage associé à ce maillage cartésien.
FaceDirectionMng faceDirection(eMeshDirection dir) override
Liste des faces dans la direction dir.
NodeDirectionMng nodeDirection(eMeshDirection dir) override
Liste des noeuds dans la direction dir.
void refinePatch2D(Real2 position, Real2 length) override
Raffine en 2D un bloc du maillage cartésien.
ICartesianMeshPatch * patch(Int32 index) const override
Retourne le index-ième patch du maillage.
void coarseZone2D(Real2 position, Real2 length) override
Dé-raffine en 2D un bloc du maillage cartésien.
void renumberItemsUniqueId(const CartesianMeshRenumberingInfo &v) override
Renumérote les uniqueId() des entités.
ICartesianMeshInternal * _internalApi() override
API interne à Arcane.
void coarseZone3D(Real3 position, Real3 length) override
Dé-raffine en 3D un bloc du maillage cartésien.
Ref< CartesianMeshCoarsening > createCartesianMeshCoarsening() override
Créé une instance pour gérer le déraffinement du maillage.
CartesianPatch amrPatch(Int32 index) const override
Retourne le index-ième patch du maillage.
CellDirectionMng cellDirection(eMeshDirection dir) override
Liste des mailles dans la direction dir.
CartesianMeshPatchListView patches() const override
Vue sur la liste des patchs.
CartesianConnectivity connectivity() override
Informations sur la connectivité
Patch AMR d'un maillage cartésien.
Infos sur les mailles d'une direction spécifique X,Y ou Z d'un maillage structuré.
Vue sur les informations des mailles.
Maille d'un maillage.
Definition Item.h:1191
Face face(Int32 i) const
i-ème face de la maille
Definition Item.h:1269
Int32 nbFace() const
Nombre de faces de la maille.
Definition Item.h:1266
Int32 level() const
Definition Item.h:1342
Vue constante d'un tableau de type T.
Infos sur les face d'une direction spécifique X,Y ou Z d'un maillage structuré.
Face d'une maille.
Definition Item.h:944
Interface d'un patch AMR d'un maillage cartésien.
virtual void checkValid() const =0
Effectue des vérifications sur la validité de l'instance.
Interface d'un maillage cartésien.
static ICartesianMesh * getReference(const MeshHandleOrMesh &mesh, bool create=true)
Récupère ou créé la référence associée à mesh.
virtual IMesh * mesh() const =0
Maillage associé à ce maillage cartésien.
Interface d'une famille d'entités.
Definition IItemFamily.h:84
virtual ItemGroup findGroup(const String &name) const =0
Recherche un groupe.
virtual ItemGroup allItems() const =0
Groupe de toutes les entités.
virtual ItemGroup createGroup(const String &name, Int32ConstArrayView local_ids, bool do_override=false)=0
Créé un groupe d'entités de nom name contenant les entités local_ids.
virtual Int32 maxLocalId() const =0
virtual IItemFamily * cellFamily()=0
Retourne la famille des mailles.
virtual Int64 timestamp()=0
Compteur indiquant le temps de dernière modification du maillage.
virtual EventObservable< const MeshEventArgs & > & eventObservable(eMeshEventType type)=0
Observable pour un évènement.
Interface du gestionnaire de traces.
Interface d'une liste qui gère des données utilisateurs.
virtual void setData(const String &name, IUserData *ud)=0
Positionne le user-data associé au nom name.
virtual IUserData * data(const String &name, bool allow_null=false) const =0
Donnée associée à name.
Interface pour une donnée utilisateur attachée à un autre objet.
Definition IUserData.h:31
Classe de base d'une vue sur une connectivité non structurée.
NodeGroup nodeGroup() const
Groupe des noeuds des éléments de ce groupe.
Definition ItemGroup.cc:229
const String & name() const
Nom du groupe.
Definition ItemGroup.h:76
ItemVectorView view() const
Vue sur les entités du groupe.
Definition ItemGroup.cc:582
Integer size() const
Nombre d'éléments du groupe.
Definition ItemGroup.h:88
IItemFamily * itemFamily() const
Famille d'entité à laquelle appartient ce groupe (0 pour le group nul)
Definition ItemGroup.h:123
void setItems(Int32ConstArrayView items_local_id)
Positionne les entités du groupe.
Definition ItemGroup.cc:488
bool null() const
true is le groupe est le groupe nul
Definition ItemGroup.h:70
Classe utilitaire pour imprimer les infos sur une entité.
Definition ItemPrinter.h:35
Int32ConstArrayView localIds() const
Tableau des numéros locaux des entités.
Node node(Int32 i) const
i-ème noeud de l'entité
Definition Item.h:779
Int32 nbNode() const
Nombre de noeuds de l'entité
Definition Item.h:776
NodeLocalIdView nodeIds() const
Liste des noeuds de l'entité
Definition Item.h:785
bool isOwn() const
true si l'entité est appartient au sous-domaine
Definition Item.h:253
constexpr bool null() const
true si l'entité est nul (i.e. non connecté au maillage)
Definition Item.h:216
Arguments des évènements sur le maillage.
Definition MeshEvents.h:43
Classe de compatibilité pour contenir un MeshHandle ou un IMesh*.
Definition MeshHandle.h:194
const MeshHandle & handle() const
handle associé.
Definition MeshHandle.h:217
Handle sur un maillage.
Definition MeshHandle.h:47
IMesh * meshOrNull() const
Retourne le maillage associé à cette instance.
IUserDataList * meshUserDataList() const
Données utilisateurs associées.
Definition MeshHandle.h:157
Caractéristiques d'un maillage.
Definition MeshKind.h:64
Infos sur les noeuds d'une direction spécifique X,Y ou Z d'un maillage structuré.
Noeud d'un maillage.
Definition Item.h:573
Classe gérant un vecteur de réel de dimension 2.
Definition Real2.h:121
Classe gérant un vecteur de réel de dimension 3.
Definition Real3.h:132
Référence à une instance.
Chaîne de caractères unicode.
TraceAccessor(ITraceMng *m)
Construit un accesseur via le gestionnaire de trace m.
TraceMessageDbg debug(Trace::eDebugLevel=Trace::Medium) const
Flot pour un message de debug.
TraceMessage info() const
Flot pour un message d'information.
TraceMessage warning() const
Flot pour un message d'avertissement.
ITraceMng * traceMng() const
Gestionnaire de trace.
Vecteur 1D de données avec sémantique par valeur (style STL).
Paramètres nécessaires à la construction d'une variable.
ItemGroupT< Cell > CellGroup
Groupe de mailles.
Definition ItemTypes.h:183
ItemVectorViewT< Cell > CellVectorView
Vue sur un vecteur de mailles.
Definition ItemTypes.h:304
ItemGroupT< Node > NodeGroup
Groupe de noeuds.
Definition ItemTypes.h:167
MeshVariableScalarRefT< Cell, Real3 > VariableCellReal3
Grandeur au centre des mailles de type coordonnées.
MeshVariableScalarRefT< Node, Int32 > VariableNodeInt32
Grandeur au noeud de type entier 32 bits.
MeshVariableScalarRefT< Node, Real3 > VariableNodeReal3
Grandeur au noeud de type coordonnées.
MeshVariableScalarRefT< Cell, Int32 > VariableCellInt32
Grandeur au centre des mailles de type entier 32 bits.
MeshVariableScalarRefT< Face, Real3 > VariableFaceReal3
Grandeur aux faces de type coordonnées.
Int32 toInt32(Real r)
Converti un Real en Int32.
Definition Convert.h:63
IMemoryAllocator * getDefaultDataAllocator()
Allocateur par défaut pour les données.
@ ReduceSum
Somme des valeurs.
@ ReduceMax
Maximum des valeurs.
Espace de nom pour les fonctions dépendant de la plateforme.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
bool arcaneIsCheck()
Vrai si on est en mode vérification.
Definition Misc.cc:68
std::int64_t Int64
Type entier signé sur 64 bits.
Int32 Integer
Type représentant un entier.
ConstArrayView< Int32 > Int32ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.
Definition UtilsTypes.h:569
eMeshDirection
Type de la direction pour un maillage structuré
@ MD_DirZ
Direction Z.
@ MD_DirY
Direction Y.
@ MD_DirX
Direction X.
@ EndPrepareDump
Evènement envoyé à la fin de prepareForDump()
Definition MeshEvents.h:34
double Real
Type représentant un réel.
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Créé une référence sur un pointeur.
eMeshAMRKind
Type de maillage AMR.
Definition MeshKind.h:41
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