Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
ExternalPartitionConstraint.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* ExternalPartitionConstraint.cc (C) 2000-2024 */
9/* */
10/* Information on constraints for partitioning. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/core/ExternalPartitionConstraint.h"
15
16#include "arcane/utils/ITraceMng.h"
17#include "arcane/utils/NotImplementedException.h"
18
19#include "arcane/core/IMesh.h"
20#include "arcane/core/IMeshPartitionConstraint.h"
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
32addLinkedCells(Int64Array& linked_cells, Int32Array& linked_owners)
33{
34 m_mesh->traceMng()->info() << "ExternalPartitionConstraint::addLinkedCells(...)";
35
36 // Setting up a filter on the cells to prevent them from being included
37 // multiple times in the cells array
38 UniqueArray<Integer> filtre_cell;
39 filtre_cell.resize(m_mesh->allCells().size());
40 Integer marque = 0;
41 filtre_cell.fill(marque);
42
43 for (ItemGroup& group : m_constraints) {
44 // Array containing the list of cells to keep together
45 // This list is distributed across the processors
46 // and includes ghost cells as common elements
48 if (group.itemKind() == IK_Cell) {
49 ENUMERATE_CELL (icell, group.cellGroup()) {
50 cells.add(*icell);
51 }
52 }
53 // This method allows retrieving the cells in the case of semi-conformity
54 // We filter the cells to select them only once
55 else if (group.itemKind() == IK_Face) {
56 marque++;
57 ENUMERATE_FACE (iface, group.faceGroup()) {
58 for (Node node : iface->nodes()) {
59 for (Cell cell : node.cells()) {
60 if (filtre_cell[cell.localId()] != marque) {
61 cells.add(cell);
62 filtre_cell[cell.localId()] = marque;
63 }
64 }
65 }
66 }
67 }
68 else if (group.itemKind() == IK_Node) {
69 ENUMERATE_NODE (inode, group.nodeGroup()) {
70 for (Cell cell : inode->cells()) {
71 cells.add(cell);
72 }
73 }
74 }
75
76 if (cells.size() == 0)
77 continue;
78
79 // We populate the constraints in the form of pairs of cells
80 Cell cell0 = cells[0];
81 Int32 owner0 = cell0.owner();
82 ItemUniqueId uid0 = cell0.uniqueId();
83
84 for (Integer i = 1; i < cells.size(); ++i) {
85 ItemUniqueId uidi = cells[i].uniqueId();
86 if (uid0 < uidi) {
87 linked_cells.add(uid0);
88 linked_cells.add(uidi);
89 }
90 else {
91 linked_cells.add(uidi);
92 linked_cells.add(uid0);
93 }
94 linked_owners.add(owner0);
95 } // end for i=1; i<cells.size()
96
97 m_mesh->traceMng()->info() << "cells.size() = " << cells.size();
98
99 } // end for iter=m_constraints.begin()
100}
101
102/*---------------------------------------------------------------------------*/
103/*---------------------------------------------------------------------------*/
104
105} // namespace Arcane
106
107/*---------------------------------------------------------------------------*/
108/*---------------------------------------------------------------------------*/
#define ENUMERATE_FACE(name, group)
Generic enumerator for a face group.
#define ENUMERATE_CELL(name, group)
Generic enumerator for a cell group.
#define ENUMERATE_NODE(name, group)
Generic enumerator for a node group.
Integer size() const
Number of elements in the vector.
void fill(ConstReferenceType value)
Fills the array with the value value.
void resize(Int64 s)
Changes the number of elements in the array to s.
void add(ConstReferenceType val)
Adds element val to the end of the array.
Cell of a mesh.
Definition Item.h:1300
virtual void addLinkedCells(Int64Array &linked_cells, Int32Array &linked_owners)
Adds a set of constraints on the cells.
Mesh entity group.
Definition ItemGroup.h:51
Unique identifier of an entity.
Int32 owner() const
Owner subdomain number of the entity.
Definition Item.h:252
ItemUniqueId uniqueId() const
Unique identifier across all domains.
Definition Item.h:239
Node of a mesh.
Definition Item.h:598
1D data vector with value semantics (STL style).
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Array< Int64 > Int64Array
Dynamic one-dimensional array of 64-bit integers.
Definition UtilsTypes.h:125
Int32 Integer
Type representing an integer.
@ IK_Node
Node mesh entity.
@ IK_Cell
Cell mesh entity.
@ IK_Face
Face mesh entity.
Array< Int32 > Int32Array
Dynamic one-dimensional array of 32-bit integers.
Definition UtilsTypes.h:127
std::int32_t Int32
Signed integer type of 32 bits.