Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
ItemTools.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/* ItemTools.cc (C) 2000-2020 */
9/* */
10/* Utilities for finding items based on others */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/ArcanePrecomp.h"
15
16#include "arcane/core/Item.h"
17#include "arcane/mesh/ItemTools.h"
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane::mesh
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
29isSameFace(Face face, Int64ConstArrayView face_nodes_uid)
30{
31 Integer index = 0;
32 for (Node node : face.nodes()) {
33 if (node.uniqueId() != face_nodes_uid[index])
34 return false;
35 ++index;
36 }
37 return true;
38}
39
40/*---------------------------------------------------------------------------*/
41/*---------------------------------------------------------------------------*/
42
44findFaceInNode2(Node node, Integer face_type_id,
45 Int64ConstArrayView face_nodes_uid)
46{
47 for (Face current_face : node.faces()) {
48 if (current_face.type() != face_type_id)
49 continue;
50 if (isSameFace(current_face, face_nodes_uid))
51 return current_face;
52 }
53 return Face();
54}
55
56/*---------------------------------------------------------------------------*/
57/*---------------------------------------------------------------------------*/
58
60findFaceInNode(Node node, Integer face_type_id,
61 Int64ConstArrayView face_nodes_uid)
62{
63 Face face = findFaceInNode2(node, face_type_id, face_nodes_uid);
64 if (face.null())
65 return nullptr;
66 return ItemCompatibility::_itemInternal(face);
67}
68
69/*---------------------------------------------------------------------------*/
70/*---------------------------------------------------------------------------*/
71
73findEdgeInNode2(Node node, Int64 begin_node, Int64 end_node)
74{
75 for (Edge edge : node.edges())
76 if (edge.node(0).uniqueId() == begin_node && edge.node(1).uniqueId() == end_node)
77 return edge;
78 return Edge();
79}
80
81/*---------------------------------------------------------------------------*/
82/*---------------------------------------------------------------------------*/
83
85findEdgeInNode(Node node, Int64 begin_node, Int64 end_node)
86{
87 Edge edge = findEdgeInNode2(node, begin_node, end_node);
88 if (edge.null())
89 return nullptr;
90 return ItemCompatibility::_itemInternal(edge);
91}
92
93/*---------------------------------------------------------------------------*/
94/*---------------------------------------------------------------------------*/
95
96} // End namespace Arcane::mesh
97
98/*---------------------------------------------------------------------------*/
99/*---------------------------------------------------------------------------*/
Edge of a cell.
Definition Item.h:875
Face of a cell.
Definition Item.h:1032
Internal structure of a mesh entity.
NodeConnectedListViewType nodes() const
List of nodes of the entity.
Definition Item.h:843
constexpr bool null() const
true if the entity is null (i.e. not connected to the mesh)
Definition Item.h:230
Node of a mesh.
Definition Item.h:598
FaceConnectedListViewType faces() const
List of faces of the node.
Definition Item.h:725
EdgeConnectedListViewType edges() const
List of edges of the node.
Definition Item.h:722
static ItemInternal * findFaceInNode(Node node, Integer face_type_id, Int64ConstArrayView face_nodes_uid)
Definition ItemTools.cc:60
static ItemInternal * findEdgeInNode(Node node, Int64 begin_node, Int64 end_node)
Definition ItemTools.cc:85
static Edge findEdgeInNode2(Node node, Int64 begin_node, Int64 end_node)
Definition ItemTools.cc:73
static Face findFaceInNode2(Node node, Integer face_type_id, Int64ConstArrayView face_nodes_uid)
Definition ItemTools.cc:44
static bool isSameFace(Face face, Int64ConstArrayView face_nodes_uid)
Definition ItemTools.cc:29
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
ConstArrayView< Int64 > Int64ConstArrayView
C equivalent of a 1D array of 64-bit integers.
Definition UtilsTypes.h:480