16#include "arcane/utils/SmallArray.h"
17#include "arcane/utils/HashTableMap2.h"
18#include "arcane/utils/CheckedConvert.h"
20#include "arcane/core/IMesh.h"
21#include "arcane/core/IItemFamily.h"
22#include "arcane/core/Item.h"
24#include "arcane/core/ItemGroup.h"
25#include "arcane/core/IIndexedIncrementalItemConnectivityMng.h"
26#include "arcane/core/IIndexedIncrementalItemConnectivity.h"
27#include "arcane/core/IIncrementalItemConnectivity.h"
28#include "arcane/core/IParallelMng.h"
40 class NodeNodeConnectivityHelper
44 NodeNodeConnectivityHelper(IMesh* mesh,
const String& connectivity_name)
45 : node_family(mesh->nodeFamily())
47 auto connectivity_mng = mesh->indexedConnectivityMng();
48 connectivity_ref = connectivity_mng->findOrCreateConnectivity(node_family, node_family, connectivity_name);
49 item_connectivity = connectivity_ref->connectivity();
54 void addCurrentNodeSetToNode(NodeLocalId node_lid)
58 Int32 nb_node = CheckedConvert::toInt32(node_set.size());
61 connected_items_ids.resize(nb_node);
63 for (
auto x : node_set) {
64 connected_items_ids[index] = x;
67 item_connectivity->setConnectedItems(node_lid, connected_items_ids);
74 IItemFamily* node_family =
nullptr;
75 Ref<IIndexedIncrementalItemConnectivity> connectivity_ref;
80 std::set<Int32> node_set;
85 SmallArray<Int32> connected_items_ids;
87 IIncrementalItemConnectivity* item_connectivity =
nullptr;
95computeNodeNodeViaEdgeConnectivity(
IMesh*
mesh,
const String& connectivity_name)
98 NodeNodeConnectivityHelper helper(
mesh, connectivity_name);
106 NodeLocalId node_lid(node.
localId());
111 NodeLocalId node0_lid = cell.nodeId(e.
beginNode());
112 NodeLocalId node1_lid = cell.nodeId(e.
endNode());
113 if (node0_lid == node_lid)
114 helper.node_set.insert(node1_lid);
115 if (node1_lid == node_lid)
116 helper.node_set.insert(node0_lid);
120 helper.addCurrentNodeSetToNode(node_lid);
123 return helper.connectivity_ref;
130computeBoundaryNodeNodeViaEdgeConnectivity(
IMesh*
mesh,
const String& connectivity_name)
134 NodeNodeConnectivityHelper helper(
mesh, connectivity_name);
137 Int32 my_rank =
mesh->parallelMng()->commRank();
158 for (NodeLocalId node_id : face.
nodeIds())
159 boundary_node_map.add(node_id,
true);
166 for (
auto [node_lid, _] : boundary_node_map) {
167 Node node = nodes[node_lid];
172 NodeLocalId node0_lid = cell.nodeId(e.
beginNode());
173 NodeLocalId node1_lid = cell.nodeId(e.
endNode());
174 Int32 other_node_lid = NULL_ITEM_LOCAL_ID;
175 if (node0_lid == node_lid)
176 other_node_lid = node1_lid;
177 if (node1_lid == node_lid)
178 other_node_lid = node0_lid;
179 if (other_node_lid != NULL_ITEM_LOCAL_ID && boundary_node_map.contains(other_node_lid))
180 helper.node_set.insert(other_node_lid);
183 helper.addCurrentNodeSetToNode(NodeLocalId(node_lid));
185 return helper.connectivity_ref;
#define ARCANE_CHECK_POINTER(ptr)
Macro returning the pointer ptr if it is not null or throwing an exception if it is null.
Utility functions for the mesh.
Cell cell(Int32 i) const
i-th cell of the face
Int32 nbCell() const
Number of cells of the face (1 or 2).
Local information about a cell edge.
Integer endNode() const
Local index in the cell of the ending node of the edge.
Integer beginNode() const
Local index in the cell of the starting node of the edge.
Info on a mesh entity type.
LocalEdge localEdge(Integer id) const
Local connectivity of the i-th edge of the cell.
Integer nbLocalEdge() const
Number of edges of the entity.
NodeLocalIdView nodeIds() const
List of nodes of the entity.
constexpr Int32 localId() const
Local identifier of the entity in the processor subdomain.
Int32 owner() const
Owner subdomain number of the entity.
constexpr bool isOwn() const
true if the entity belongs to the subdomain
Class to convert a NodeLocalId to an edge.
CellConnectedListViewType cells() const
List of cells of the node.
Reference to an instance.
Unicode character string.
Implementation of std::unordered_map.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int32_t Int32
Signed integer type of 32 bits.