14#include "arcane/cartesianmesh/CartesianMeshCoarsening2.h"
16#include "arcane/utils/FatalErrorException.h"
17#include "arcane/utils/ValueConvert.h"
18#include "arcane/utils/SmallArray.h"
20#include "arcane/core/IMesh.h"
21#include "arcane/core/ItemGroup.h"
22#include "arcane/core/IParallelMng.h"
23#include "arcane/core/CartesianGridDimension.h"
24#include "arcane/core/IMeshModifier.h"
25#include "arcane/core/SimpleSVGMeshExporter.h"
26#include "arcane/core/ItemPrinter.h"
27#include "arcane/core/MeshStats.h"
28#include "arcane/core/IGhostLayerMng.h"
30#include "arcane/mesh/CellFamily.h"
32#include "arcane/cartesianmesh/ICartesianMesh.h"
33#include "arcane/cartesianmesh/CellDirectionMng.h"
34#include "arcane/cartesianmesh/internal/ICartesianMeshInternal.h"
36#include <unordered_set>
47CartesianMeshCoarsening2::
48CartesianMeshCoarsening2(ICartesianMesh* m)
49: TraceAccessor(m->traceMng())
52 if (
auto v = Convert::Type<Int32>::tryParseFromEnvironment(
"ARCANE_CARTESIANMESH_COARSENING_VERBOSITY_LEVEL",
true))
53 m_verbosity_level = v.value();
60Int64 CartesianMeshCoarsening2::
61_getMaxUniqueId(
const ItemGroup& group)
66 if (max_offset < item.uniqueId())
67 max_offset = item.uniqueId();
75void CartesianMeshCoarsening2::
76_writeMeshSVG(
const String& name)
78 if (m_verbosity_level <= 0)
80 IMesh* mesh = m_cartesian_mesh->mesh();
81 if (mesh->dimension() != 2)
83 IParallelMng* pm = mesh->parallelMng();
84 const Int32 mesh_rank = pm->commRank();
85 String filename = String::format(
"mesh_{0}_{1}.svg", name, mesh_rank);
86 info() <<
"WriteMesh name=" << filename;
87 std::ofstream ofile(filename.localstr());
88 SimpleSVGMeshExporter writer(ofile);
89 writer.write(mesh->allCells());
100void CartesianMeshCoarsening2::
101_doDoubleGhostLayers()
103 IMesh* mesh = m_cartesian_mesh->mesh();
104 IMeshModifier* mesh_modifier = mesh->modifier();
105 IGhostLayerMng* gm = mesh->ghostLayerMng();
108 Int32 version = gm->builderVersion();
110 gm->setBuilderVersion(3);
111 Int32 nb_ghost_layer = gm->nbGhostLayer();
112 gm->setNbGhostLayer(nb_ghost_layer * 2);
113 mesh_modifier->setDynamic(
true);
114 mesh_modifier->updateGhostLayers();
116 gm->setNbGhostLayer(nb_ghost_layer);
119 m_cartesian_mesh->computeDirections();
122 _writeMeshSVG(
"double_ghost");
128void CartesianMeshCoarsening2::
131 if (m_is_create_coarse_called)
133 m_is_create_coarse_called =
true;
135 const bool is_verbose = m_verbosity_level > 0;
136 IMesh* mesh = m_cartesian_mesh->mesh();
138 Integer nb_patch = m_cartesian_mesh->nbPatch();
140 ARCANE_FATAL(
"This method is only valid for 1 patch (nb_patch={0})", nb_patch);
142 if (!mesh->isAmrActivated())
146 if (nb_dir != 2 && nb_dir != 3)
147 ARCANE_FATAL(
"This method is only valid for 2D or 3D mesh (dim={0})", nb_dir);
149 info() <<
"CoarseCartesianMesh nb_direction=" << nb_dir;
151 for (Integer idir = 0; idir < nb_dir; ++idir) {
154 info() <<
"NB_OWN_CELL dir=" << idir <<
" n=" << nb_own_cell;
155 if ((nb_own_cell % 2) != 0)
156 ARCANE_FATAL(
"Invalid number of cells ({0}) for direction {1}. Should be a multiple of 2",
160 _writeMeshSVG(
"orig");
163 _doDoubleGhostLayers();
166 SmallArray<Int64, 8> uids;
171 Int32 nb_node = cell.
nbNode();
172 uids.resize(nb_node);
173 for (Int32 i = 0; i < nb_node; ++i)
175 info() <<
"Orig cell_uid=" << cell.
uniqueId() <<
" Nodes=" << uids;
176 Int32 nb_face = cell.
nbFace();
177 uids.resize(nb_face);
178 for (Int32 i = 0; i < nb_face; ++i)
180 info() <<
"Orig cell_uid=" << cell.
uniqueId() <<
" Faces=" << uids;
188 Int64 max_cell_uid = _getMaxUniqueId(mesh->
allCells());
189 Int64 max_face_uid = _getMaxUniqueId(mesh->
allFaces());
190 const Int64 coarse_grid_cell_offset = 1 + pm->
reduce(Parallel::ReduceMax, math::max(max_cell_uid, max_face_uid));
191 m_first_own_cell_unique_id_offset = coarse_grid_cell_offset;
192 info() <<
"FirstCellUniqueIdOffset=" << m_first_own_cell_unique_id_offset;
194 _createCoarseCells3D();
195 else if (nb_dir == 2)
196 _createCoarseCells2D();
210 _recomputeMeshGenerationInfo();
232 m_cartesian_mesh->computeDirections();
234 _writeMeshSVG(
"coarse");
240void CartesianMeshCoarsening2::
241_createCoarseCells2D()
243 const bool is_verbose = m_verbosity_level > 0;
244 IMesh* mesh = m_cartesian_mesh->mesh();
246 const Int32 my_rank = pm->
commRank();
251 const Int64 global_nb_cell_x = cdm_x.globalNbCell();
252 const Int64 global_nb_cell_y = cdm_y.globalNbCell();
255 CartesianGridDimension::CellUniqueIdComputer2D refined_cell_uid_computer(refined_grid_dim.getCellComputer2D(0));
256 CartesianGridDimension::NodeUniqueIdComputer2D refined_node_uid_computer(refined_grid_dim.getNodeComputer2D(0));
257 CartesianGridDimension::CellUniqueIdComputer2D coarse_cell_uid_computer(coarse_grid_dim.getCellComputer2D(m_first_own_cell_unique_id_offset));
258 CartesianGridDimension::FaceUniqueIdComputer2D coarse_face_uid_computer(coarse_grid_dim.getFaceComputer2D(m_first_own_cell_unique_id_offset));
268 Int32 nb_coarse_face = 0;
269 Int32 nb_coarse_cell = 0;
280 Int64x3 cell_xy = refined_cell_uid_computer.compute(cell_uid);
281 const Int64 cell_x = cell_xy.x;
282 const Int64 cell_y = cell_xy.y;
288 if ((cell_x % 2) != 0 || (cell_y % 2) != 0)
291 info() <<
"CellToCoarse refined_uid=" << cell_uid <<
" x=" << cell_x <<
" y=" << cell_y;
292 coarse_cells_owner.
add(cell.
owner());
293 const Int64 coarse_cell_x = cell_x / 2;
294 const Int64 coarse_cell_y = cell_y / 2;
295 std::array<Int64, 4> node_uids_container;
297 node_uids[0] = refined_node_uid_computer.compute(cell_x + 0, cell_y + 0);
298 node_uids[1] = refined_node_uid_computer.compute(cell_x + 2, cell_y + 0);
299 node_uids[2] = refined_node_uid_computer.compute(cell_x + 2, cell_y + 2);
300 node_uids[3] = refined_node_uid_computer.compute(cell_x + 0, cell_y + 2);
302 info() <<
"CELLNodes uid=" << node_uids;
303 std::array<Int64, 4> coarse_face_uids = coarse_face_uid_computer.computeForCell(coarse_cell_x, coarse_cell_y);
306 for (Int32 z = 0; z < 4; ++z) {
308 faces_infos.
add(IT_Line2);
309 faces_infos.
add(coarse_face_uids[z]);
310 Int64 node_uid0 = node_uids[lface.
node(0)];
311 Int64 node_uid1 = node_uids[lface.
node(1)];
313 if (node_uid0 > node_uid1)
314 std::swap(node_uid0, node_uid1);
316 info() <<
"ADD_FACE coarse_uid=" << coarse_face_uids[z] <<
" n0=" << node_uid0 <<
" n1=" << node_uid1;
317 faces_infos.
add(node_uid0);
318 faces_infos.
add(node_uid1);
323 cells_infos.
add(IT_Quad4);
324 Int64 coarse_cell_uid = coarse_cell_uid_computer.compute(coarse_cell_x, coarse_cell_y);
325 cells_infos.
add(coarse_cell_uid);
327 info() <<
"CoarseCellUid=" << coarse_cell_uid;
328 m_coarse_cells_uid.add(coarse_cell_uid);
329 for (Int32 z = 0; z < 4; ++z)
330 cells_infos.
add(node_uids[z]);
332 first_child_cells.
add(cell);
337 std::array<Int32, 4> sub_cell_lids_container;
338 ArrayView<Int32> sub_lids(sub_cell_lids_container);
339 Cell cell1 = cdm_x[cell].next();
345 ARCANE_FATAL(
"Bad right cell for cell {0}", ItemPrinter(cell));
346 Cell cell2 = cdm_y[cell1].next();
348 ARCANE_FATAL(
"Bad upper right cell for cell {0}", ItemPrinter(cell));
349 Cell cell3 = cdm_y[cell].next();
351 ARCANE_FATAL(
"Bad upper cell for cell {0}", ItemPrinter(cell));
353 sub_lids[1] = cell1.localId();
354 sub_lids[2] = cell2.localId();
355 sub_lids[3] = cell3.localId();
361 coarse_faces_owner.
add(cell1.face(1).owner());
362 coarse_faces_owner.
add(cell2.face(2).owner());
363 coarse_faces_owner.
add(cell3.face(3).owner());
364 for (Int32 i = 0; i < 4; ++i)
365 refined_cells_lids.
add(sub_lids[i]);
370 UniqueArray<Int32> faces_local_ids(nb_coarse_face);
376 UniqueArray<Int32> cells_local_ids(nb_coarse_cell);
377 MeshModifierAddCellsArgs add_cells_args(nb_coarse_cell, cells_infos, cells_local_ids);
378 add_cells_args.setAllowBuildFaces(
false);
381 IItemFamily* cell_family = mesh->
cellFamily();
385 using mesh::CellFamily;
388 std::array<Int32, 4> sub_cell_lids_container;
389 ArrayView<Int32> sub_cell_lids(sub_cell_lids_container);
390 for (Int32 i = 0; i < nb_coarse_cell; ++i) {
391 Int32 coarse_cell_lid = cells_local_ids[i];
392 Cell coarse_cell = cells[coarse_cell_lid];
393 Cell first_child_cell = first_child_cells[i];
396 sub_cell_lids[0] = first_child_cell.localId();
397 sub_cell_lids[1] = cdm_x[first_child_cell].next().localId();
398 sub_cell_lids[2] = cdm_y[CellLocalId(sub_cell_lids[1])].next().localId();
399 sub_cell_lids[3] = cdm_y[first_child_cell].next().localId();
401 info() <<
"AddChildForCoarseCell i=" << i <<
" coarse=" << ItemPrinter(coarse_cell)
402 <<
" children_lid=" << sub_cell_lids;
403 for (Int32 z = 0; z < 4; ++z) {
404 Cell child_cell = cells[sub_cell_lids[z]];
406 info() <<
" AddParentCellToCell: z=" << z <<
" child=" << ItemPrinter(child_cell);
407 true_cell_family->_addParentCellToCell(child_cell, coarse_cell);
409 true_cell_family->_addChildrenCellsToCell(coarse_cell, sub_cell_lids);
414 IItemFamily* face_family = mesh->
faceFamily();
416 ENUMERATE_ (Cell, icell, cell_family->view(cells_local_ids)) {
418 Int32 owner = coarse_cells_owner[index];
419 cell.mutableItemBase().setOwner(owner, my_rank);
420 const Int64 sub_cell_index = index * 4;
421 for (Int32 z = 0; z < 4; ++z) {
422 cell.face(z).mutableItemBase().setOwner(coarse_faces_owner[sub_cell_index + z], my_rank);
426 cell_family->notifyItemsOwnerChanged();
427 face_family->notifyItemsOwnerChanged();
434void CartesianMeshCoarsening2::
435_createCoarseCells3D()
437 const bool is_verbose = m_verbosity_level > 0;
438 IMesh* mesh = m_cartesian_mesh->mesh();
439 IParallelMng* pm = mesh->parallelMng();
440 const Int32 my_rank = pm->
commRank();
442 CellDirectionMng cdm_x(m_cartesian_mesh->cellDirection(0));
443 CellDirectionMng cdm_y(m_cartesian_mesh->cellDirection(1));
444 CellDirectionMng cdm_z(m_cartesian_mesh->cellDirection(2));
446 const Int64 global_nb_cell_x = cdm_x.globalNbCell();
447 const Int64 global_nb_cell_y = cdm_y.globalNbCell();
448 const Int64 global_nb_cell_z = cdm_z.globalNbCell();
449 CartesianGridDimension refined_grid_dim(global_nb_cell_x, global_nb_cell_y, global_nb_cell_z);
450 CartesianGridDimension coarse_grid_dim(global_nb_cell_x / 2, global_nb_cell_y / 2, global_nb_cell_z / 2);
451 CartesianGridDimension::CellUniqueIdComputer3D refined_cell_uid_computer(refined_grid_dim.getCellComputer3D(0));
452 CartesianGridDimension::NodeUniqueIdComputer3D refined_node_uid_computer(refined_grid_dim.getNodeComputer3D(0));
453 CartesianGridDimension::CellUniqueIdComputer3D coarse_cell_uid_computer(coarse_grid_dim.getCellComputer3D(m_first_own_cell_unique_id_offset));
454 CartesianGridDimension::FaceUniqueIdComputer3D coarse_face_uid_computer(coarse_grid_dim.getFaceComputer3D(m_first_own_cell_unique_id_offset));
462 UniqueArray<Int64> faces_infos;
463 UniqueArray<Int64> cells_infos;
464 Int32 nb_coarse_face = 0;
465 Int32 nb_coarse_cell = 0;
467 UniqueArray<Cell> first_child_cells;
469 UniqueArray<Int64> refined_cells_lids;
470 UniqueArray<Int32> coarse_cells_owner;
471 UniqueArray<Int32> coarse_faces_owner;
473 static constexpr Int32 const_cell_nb_node = 8;
474 static constexpr Int32 const_cell_nb_face = 6;
475 static constexpr Int32 const_cell_nb_sub_cell = 8;
476 static constexpr Int32 const_face_nb_node = 4;
479 SmallArray<Int64, const_face_nb_node> face_node_uids(const_face_nb_node);
481 SmallArray<Int64, const_face_nb_node> face_sorted_node_uids(const_face_nb_node);
484 Int64 cell_uid = cell.uniqueId();
485 Int64x3 cell_xyz = refined_cell_uid_computer.compute(cell_uid);
486 const Int64 cell_x = cell_xyz.x;
487 const Int64 cell_y = cell_xyz.y;
488 const Int64 cell_z = cell_xyz.z;
491 cell.mutableItemBase().addFlags(ItemFlags::II_JustRefined);
494 if ((cell_x % 2) != 0 || (cell_y % 2) != 0 || (cell_z % 2) != 0)
497 info() <<
"CellToCoarse refined_uid=" << cell_uid <<
" x=" << cell_x <<
" y=" << cell_y <<
" z=" << cell_z;
498 coarse_cells_owner.add(cell.owner());
499 const Int64 coarse_cell_x = cell_x / 2;
500 const Int64 coarse_cell_y = cell_y / 2;
501 const Int64 coarse_cell_z = cell_z / 2;
502 std::array<Int64, const_cell_nb_node> node_uids_container;
503 ArrayView<Int64> node_uids(node_uids_container);
504 node_uids[0] = refined_node_uid_computer.compute(cell_x + 0, cell_y + 0, cell_z + 0);
505 node_uids[1] = refined_node_uid_computer.compute(cell_x + 2, cell_y + 0, cell_z + 0);
506 node_uids[2] = refined_node_uid_computer.compute(cell_x + 2, cell_y + 2, cell_z + 0);
507 node_uids[3] = refined_node_uid_computer.compute(cell_x + 0, cell_y + 2, cell_z + 0);
508 node_uids[4] = refined_node_uid_computer.compute(cell_x + 0, cell_y + 0, cell_z + 2);
509 node_uids[5] = refined_node_uid_computer.compute(cell_x + 2, cell_y + 0, cell_z + 2);
510 node_uids[6] = refined_node_uid_computer.compute(cell_x + 2, cell_y + 2, cell_z + 2);
511 node_uids[7] = refined_node_uid_computer.compute(cell_x + 0, cell_y + 2, cell_z + 2);
513 info() <<
"CELLNodes uid=" << node_uids;
514 std::array<Int64, const_cell_nb_face> coarse_face_uids = coarse_face_uid_computer.computeForCell(coarse_cell_x, coarse_cell_y, coarse_cell_z);
515 const ItemTypeInfo* cell_type = cell.typeInfo();
518 for (Int32 z = 0; z < const_cell_nb_face; ++z) {
519 ItemTypeInfo::LocalFace lface = cell_type->localFace(z);
520 faces_infos.add(IT_Quad4);
521 faces_infos.add(coarse_face_uids[z]);
522 for (Int32 knode = 0; knode < const_face_nb_node; ++knode)
523 face_node_uids[knode] = node_uids[lface.node(knode)];
524 MeshUtils::reorderNodesOfFace(face_node_uids, face_sorted_node_uids);
526 info() <<
"ADD_FACE coarse_uid=" << coarse_face_uids[z] <<
" n=" << face_sorted_node_uids;
527 faces_infos.addRange(face_sorted_node_uids);
533 cells_infos.add(IT_Hexaedron8);
534 Int64 coarse_cell_uid = coarse_cell_uid_computer.compute(coarse_cell_x, coarse_cell_y, coarse_cell_z);
535 cells_infos.add(coarse_cell_uid);
537 info() <<
"CoarseCellUid=" << coarse_cell_uid;
538 m_coarse_cells_uid.add(coarse_cell_uid);
539 for (Int32 z = 0; z < const_cell_nb_node; ++z)
540 cells_infos.add(node_uids[z]);
542 first_child_cells.add(cell);
549 std::array<Int32, const_cell_nb_sub_cell> sub_cell_lids_container;
550 ArrayView<Int32> sub_lids(sub_cell_lids_container);
551 Cell cell1 = cdm_x[cell].next();
557 ARCANE_FATAL(
"Bad right cell for cell {0}", ItemPrinter(cell));
558 Cell cell2 = cdm_y[cell1].next();
560 ARCANE_FATAL(
"Bad upper right cell for cell {0}", ItemPrinter(cell));
561 Cell cell3 = cdm_y[cell].next();
563 ARCANE_FATAL(
"Bad upper cell for cell {0}", ItemPrinter(cell));
565 Cell cell4 = cdm_z[cell].next();
567 ARCANE_FATAL(
"Bad top cell for cell {0}", ItemPrinter(cell));
569 Cell cell5 = cdm_x[cell4].next();
571 ARCANE_FATAL(
"Bad top right cell for cell {0}", ItemPrinter(cell));
572 Cell cell6 = cdm_y[cell5].next();
574 ARCANE_FATAL(
"Bad top upper right cell for cell {0}", ItemPrinter(cell));
575 Cell cell7 = cdm_y[cell4].next();
577 ARCANE_FATAL(
"Bad top upper cell for cell {0}", ItemPrinter(cell));
579 sub_lids[0] = cell.localId();
580 sub_lids[1] = cell1.localId();
581 sub_lids[2] = cell2.localId();
582 sub_lids[3] = cell3.localId();
583 sub_lids[4] = cell4.localId();
584 sub_lids[5] = cell5.localId();
585 sub_lids[6] = cell6.localId();
586 sub_lids[7] = cell7.localId();
591 coarse_faces_owner.add(cell.face(0).owner());
592 coarse_faces_owner.add(cell1.face(1).owner());
593 coarse_faces_owner.add(cell2.face(2).owner());
594 coarse_faces_owner.add(cell3.face(3).owner());
596 coarse_faces_owner.add(cell4.face(4).owner());
597 coarse_faces_owner.add(cell5.face(5).owner());
599 for (Int32 i = 0; i < const_cell_nb_sub_cell; ++i)
600 refined_cells_lids.add(sub_lids[i]);
605 UniqueArray<Int32> faces_local_ids(nb_coarse_face);
606 mesh->modifier()->addFaces(nb_coarse_face, faces_infos, faces_local_ids);
611 UniqueArray<Int32> cells_local_ids(nb_coarse_cell);
612 MeshModifierAddCellsArgs add_cells_args(nb_coarse_cell, cells_infos, cells_local_ids);
613 add_cells_args.setAllowBuildFaces(
false);
614 mesh->modifier()->addCells(add_cells_args);
616 IItemFamily* cell_family = mesh->cellFamily();
620 using mesh::CellFamily;
621 CellInfoListView cells(mesh->cellFamily());
623 std::array<Int32, const_cell_nb_sub_cell> sub_cell_lids_container;
624 ArrayView<Int32> sub_cell_lids(sub_cell_lids_container);
625 for (Int32 i = 0; i < nb_coarse_cell; ++i) {
626 Int32 coarse_cell_lid = cells_local_ids[i];
627 Cell coarse_cell = cells[coarse_cell_lid];
628 Cell first_child_cell = first_child_cells[i];
631 sub_cell_lids[0] = first_child_cell.localId();
632 sub_cell_lids[1] = cdm_x[first_child_cell].next().localId();
633 sub_cell_lids[2] = cdm_y[CellLocalId(sub_cell_lids[1])].next().localId();
634 sub_cell_lids[3] = cdm_y[first_child_cell].next().localId();
636 Cell top_first_child_cell = cdm_z[first_child_cell].next();
637 sub_cell_lids[4] = top_first_child_cell.localId();
638 sub_cell_lids[5] = cdm_x[top_first_child_cell].next().localId();
639 sub_cell_lids[6] = cdm_y[CellLocalId(sub_cell_lids[5])].next().localId();
640 sub_cell_lids[7] = cdm_y[top_first_child_cell].next().localId();
643 info() <<
"AddChildForCoarseCell i=" << i <<
" coarse=" << ItemPrinter(coarse_cell)
644 <<
" children_lid=" << sub_cell_lids;
645 for (Int32 z = 0; z < const_cell_nb_sub_cell; ++z) {
646 Cell child_cell = cells[sub_cell_lids[z]];
648 info() <<
" AddParentCellToCell: z=" << z <<
" child=" << ItemPrinter(child_cell);
649 true_cell_family->_addParentCellToCell(child_cell, coarse_cell);
651 true_cell_family->_addChildrenCellsToCell(coarse_cell, sub_cell_lids);
656 IItemFamily* face_family = mesh->faceFamily();
658 ENUMERATE_ (Cell, icell, cell_family->view(cells_local_ids)) {
660 Int32 owner = coarse_cells_owner[index];
661 cell.mutableItemBase().setOwner(owner, my_rank);
662 const Int64 sub_cell_index = index * const_cell_nb_face;
663 for (Int32 z = 0; z < const_cell_nb_face; ++z) {
664 cell.face(z).mutableItemBase().setOwner(coarse_faces_owner[sub_cell_index + z], my_rank);
668 cell_family->notifyItemsOwnerChanged();
669 face_family->notifyItemsOwnerChanged();
678void CartesianMeshCoarsening2::
679_recomputeMeshGenerationInfo()
681 IMesh* mesh = m_cartesian_mesh->mesh();
682 auto* cmgi = ICartesianMeshGenerationInfo::getReference(mesh,
false);
690 ConstArrayView<Int64> v = cmgi->ownCellOffsets();
691 cmgi->setOwnCellOffsets(v[0] / cf, v[1] / cf, v[2] / cf);
694 ConstArrayView<Int64> v = cmgi->globalNbCells();
695 cmgi->setGlobalNbCells(v[0] / cf, v[1] / cf, v[2] / cf);
698 ConstArrayView<Int32> v = cmgi->ownNbCells();
699 cmgi->setOwnNbCells(v[0] / cf, v[1] / cf, v[2] / cf);
701 cmgi->setFirstOwnCellUniqueId(m_first_own_cell_unique_id_offset);
707void CartesianMeshCoarsening2::
710 if (!m_is_create_coarse_called)
711 ARCANE_FATAL(
"You need to call createCoarseCells() before");
712 if (m_is_remove_refined_called)
714 m_is_remove_refined_called =
true;
716 const bool is_verbose = m_verbosity_level > 0;
718 IMesh* mesh = m_cartesian_mesh->mesh();
719 IMeshModifier* mesh_modifier = mesh->modifier();
721 info() <<
"RemoveRefinedCells nb_coarse_cell=" << m_coarse_cells_uid.size();
723 info() <<
"CoarseCells=" << m_coarse_cells_uid;
727 std::unordered_set<Int64> coarse_cells_set;
728 for (Int64 cell_uid : m_coarse_cells_uid)
729 coarse_cells_set.insert(cell_uid);
730 UniqueArray<Int32> cells_to_remove;
732 Int32 local_id = icell.itemLocalId();
734 if (coarse_cells_set.find(cell.uniqueId()) == coarse_cells_set.end())
735 cells_to_remove.add(local_id);
738 info() <<
"CellsToRemove n=" << cells_to_remove.size() <<
" list=" << cells_to_remove;
739 mesh_modifier->removeCells(cells_to_remove);
740 mesh_modifier->endUpdate();
744 mesh_modifier->setDynamic(
true);
745 mesh_modifier->updateGhostLayers();
749 MeshStats ms(traceMng(), mesh, mesh->parallelMng());
754 m_cartesian_mesh->computeDirections();
#define ARCANE_CHECK_POINTER(ptr)
Macro retournant le pointeur ptr s'il est non nul ou lancant une exception s'il est nul.
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Informations sur les dimensions d'une grille cartésienne.
Infos sur les mailles d'une direction spécifique X,Y ou Z d'un maillage structuré.
Int32 ownNbCell() const
Nombre de mailles propres dans cette direction.
Face face(Int32 i) const
i-ème face de la maille
Int32 nbFace() const
Nombre de faces de la maille.
virtual FaceGroup allFaces()=0
Groupe de toutes les faces.
virtual Integer dimension()=0
Dimension du maillage (1D, 2D ou 3D).
virtual IItemFamily * faceFamily()=0
Retourne la famille des faces.
virtual CellGroup allCells()=0
Groupe de toutes les mailles.
virtual IItemFamily * cellFamily()=0
Retourne la famille des mailles.
virtual void addFaces(Integer nb_face, Int64ConstArrayView face_infos, Int32ArrayView face_lids=Int32ArrayView())=0
Ajoute des faces.
virtual void addCells(Integer nb_cell, Int64ConstArrayView cell_infos, Int32ArrayView cells_lid=Int32ArrayView())=0
Ajoute des mailles.
virtual void endUpdate()=0
Notifie l'instance de la fin de la modification du maillage.
virtual IParallelMng * parallelMng()=0
Gestionnaire de parallèlisme.
virtual IMeshModifier * modifier()=0
Interface de modification associée.
virtual CellGroup allLevelCells(const Integer &level)=0
Groupe de toutes les mailles de niveau level.
virtual void computeSynchronizeInfos()=0
Recalcule les informations de synchronisation.
Interface du gestionnaire de parallélisme pour un sous-domaine.
virtual Int32 commRank() const =0
Rang de cette instance dans le communicateur.
virtual char reduce(eReduceType rt, char v)=0
Effectue la réduction de type rt sur le réel v et retourne la valeur.
ItemVectorView view() const
Vue sur les entités du groupe.
ItemGroupImplInternal * _internalApi() const
API interne à Arcane.
Classe utilitaire pour imprimer les infos sur une entité.
Informations locales sur une face d'une maille.
Integer node(Integer i) const
Indice locale dans la maille du i-ème noeud de la face.
Infos sur un type d'entité du maillage.
LocalFace localFace(Integer id) const
Connectivité locale de la i-ème face de la maille.
Int32ConstArrayView localIds() const
Tableau des numéros locaux des entités.
Node node(Int32 i) const
i-ème noeud de l'entité
Int32 nbNode() const
Nombre de noeuds de l'entité
const ItemTypeInfo * typeInfo() const
Infos sur le type de l'entité.
impl::MutableItemBase mutableItemBase() const
Partie interne modifiable de l'entité.
constexpr Int32 localId() const
Identifiant local de l'entité dans le sous-domaine du processeur.
Int32 owner() const
Numéro du sous-domaine propriétaire de l'entité
ItemUniqueId uniqueId() const
Identifiant unique sur tous les domaines.
void dumpStats() override
Imprime des infos sur le maillage.
void addFlags(Int32 added_flags)
Ajoute les flags \added_flags à ceux de l'entité
Vue modifiable d'un tableau d'un type T.
void add(ConstReferenceType val)
Ajoute l'élément val à la fin du tableau.
Vecteur 1D de données avec sémantique par valeur (style STL).
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-