14#include "arcane/mesh/NodeFamily.h"
16#include "arcane/utils/FatalErrorException.h"
17#include "arcane/utils/PlatformUtils.h"
18#include "arcane/utils/ITraceMng.h"
19#include "arcane/utils/ValueConvert.h"
21#include "arcane/core/ISubDomain.h"
22#include "arcane/core/ItemPrinter.h"
23#include "arcane/core/VariableTypes.h"
24#include "arcane/core/IMesh.h"
26#include "arcane/core/Connectivity.h"
27#include "arcane/core/ConnectivityItemVector.h"
28#include "arcane/core/Properties.h"
30#include "arcane/mesh/IncrementalItemConnectivity.h"
31#include "arcane/mesh/CompactIncrementalItemConnectivity.h"
32#include "arcane/mesh/ItemConnectivitySelector.h"
33#include "arcane/mesh/AbstractItemFamilyTopologyModifier.h"
34#include "arcane/mesh/NewWithLegacyConnectivity.h"
35#include "arcane/mesh/FaceFamily.h"
36#include "arcane/mesh/EdgeFamily.h"
48:
public AbstractItemFamilyTopologyModifier
52 TopologyModifier(NodeFamily* f)
53 : AbstractItemFamilyTopologyModifier(f)
61 m_true_family->replaceEdge(item_lid, index, new_lid);
65 m_true_family->replaceFace(item_lid, index, new_lid);
69 m_true_family->replaceCell(item_lid, index, new_lid);
74 NodeFamily* m_true_family;
88 _setTopologyModifier(
new TopologyModifier(
this));
97 delete m_nodes_coords;
108 ItemTypeMng* itm = m_mesh->itemTypeMng();
111 m_nodes_coords =
nullptr;
118 if (m_mesh->useMeshItemFamilyDependencies())
120 m_edge_connectivity =
dynamic_cast<NewWithLegacyConnectivityType<NodeFamily, EdgeFamily>::type*
>(m_mesh->itemFamilyNetwork()->getConnectivity(
this,
mesh()->edgeFamily(), connectivityName(
this,
mesh()->edgeFamily())));
121 m_face_connectivity =
dynamic_cast<NewWithLegacyConnectivityType<NodeFamily, FaceFamily>::type*
>(m_mesh->itemFamilyNetwork()->getConnectivity(
this, m_face_family, connectivityName(
this,
mesh()->faceFamily())));
122 m_cell_connectivity =
dynamic_cast<NewWithLegacyConnectivityType<NodeFamily, CellFamily>::type*
>(m_mesh->itemFamilyNetwork()->getConnectivity(
this,
mesh()->cellFamily(), connectivityName(
this,
mesh()->cellFamily())));
125 m_edge_connectivity =
new EdgeConnectivity(
this,
mesh()->edgeFamily(),
"NodeEdge");
126 m_face_connectivity =
new FaceConnectivity(
this, m_face_family,
"NodeFace");
127 m_cell_connectivity =
new CellConnectivity(
this,
mesh()->cellFamily(),
"NodeCell");
129 m_hparent_connectivity =
new HParentConnectivity(
this,
this,
"HParentNode");
130 m_hchild_connectivity =
new HChildConnectivity(
this,
this,
"HChildNode");
132 _addConnectivitySelector(m_edge_connectivity);
133 _addConnectivitySelector(m_face_connectivity);
134 _addConnectivitySelector(m_cell_connectivity);
135 _addConnectivitySelector(m_hparent_connectivity);
136 _addConnectivitySelector(m_hchild_connectivity);
138 _buildConnectivitySelectors();
147 this->_preAllocate(nb_item,
true);
156 return m_edge_connectivity->trueCustomConnectivity();
163cellConnectivity()
const
165 return m_cell_connectivity->trueCustomConnectivity();
171IncrementalItemConnectivity* NodeFamily::
172faceConnectivity()
const
174 return m_face_connectivity->trueCustomConnectivity();
183 m_item_internal_list->nodes = _itemsInternal();
185 m_item_internal_list->nodes = _itemsInternal();
195 m_nodes_coords->setUsed(
true);
196 ItemFamily::_endAllocate();
203addCellToNode(
Node node,
Cell new_cell)
205 _checkValidSourceTargetItems(node, new_cell);
214addFaceToNode(Node node, Face new_face)
216 if (m_no_face_connectivity)
219 _checkValidSourceTargetItems(node, new_face);
220 m_face_connectivity->addConnectedItem(ItemLocalId(node), ItemLocalId(new_face));
227addEdgeToNode(Node node, Edge new_edge)
229 if (!Connectivity::hasConnectivity(m_mesh_connectivity, Connectivity::CT_NodeToEdge))
232 _checkValidSourceTargetItems(node, new_edge);
233 m_edge_connectivity->addConnectedItem(ItemLocalId(node), ItemLocalId(new_edge));
240removeEdgeFromNode(ItemLocalId node, ItemLocalId edge_to_remove)
242 if (!Connectivity::hasConnectivity(m_mesh_connectivity, Connectivity::CT_NodeToEdge))
244 m_edge_connectivity->removeConnectedItem(node, edge_to_remove);
251removeFaceFromNode(ItemLocalId node, ItemLocalId face_to_remove)
253 if (m_no_face_connectivity)
256 m_face_connectivity->removeConnectedItem(node, face_to_remove);
263removeCellFromNode(Node node, ItemLocalId cell_to_remove_lid)
265 _checkValidItem(node);
266 m_cell_connectivity->removeConnectedItem(ItemLocalId(node), cell_to_remove_lid);
275 _checkValidItem(node);
289 debug() <<
"Creating the ghosts nodes list";
296inline void NodeFamily::
297_removeNode(
Node node)
316 m_cell_connectivity->replaceItem(node, index, cell);
328 m_edge_connectivity->replaceItem(node, index, edge);
340 m_face_connectivity->replaceItem(node, index, face);
349 m_mesh_connectivity = c;
350 if (Connectivity::hasConnectivity(m_mesh_connectivity, Connectivity::CT_HasEdge))
351 m_edge_prealloc = Connectivity::getPrealloc(m_mesh_connectivity,
IK_Node,
IK_Edge);
352 m_face_prealloc = Connectivity::getPrealloc(m_mesh_connectivity,
IK_Node,
IK_Face);
353 m_cell_prealloc = Connectivity::getPrealloc(m_mesh_connectivity,
IK_Node,
IK_Cell);
354 m_face_connectivity->setPreAllocatedSize(m_face_prealloc);
355 m_cell_connectivity->setPreAllocatedSize(m_cell_prealloc);
356 debug() <<
"Family " <<
name() <<
" prealloc "
357 << m_edge_prealloc <<
" by edge, "
358 << m_face_prealloc <<
" by face, "
359 << m_cell_prealloc <<
" by cell.";
360 m_no_face_connectivity = !Connectivity::hasConnectivity(m_mesh_connectivity, Connectivity::CT_NodeToFace);
377 bool operator()(
Int32 item1,
Int32 item2)
const
379 return m_items.uniqueId(item1) < m_items.uniqueId(item2);
401 ItemInternalArrayView m_items;
407 m_msg->
info() <<
"** Compare ptr=" << m_items.data()
408 <<
" i1=" << item1 <<
" i2=" << item2
409 <<
" i1=" << m_items[item1] <<
" i2=" << m_items[item2]
410 <<
" uid1=" << m_items[item1]->uniqueId()
411 <<
" uid2=" << m_items[item2]->uniqueId();
412 return m_items[item1]->uniqueId() < m_items[item2]->uniqueId();
433 Int32ArrayView conn_lids = connectivity->_connectedItemsLocalId(lid);
434 std::sort(std::begin(conn_lids), std::end(conn_lids), ic_items);
442sortInternalReferences()
445 _sortConnectedItems(
mesh()->cellFamily(), m_cell_connectivity->trueCustomConnectivity());
451 info(4) <<
"Sorting connected faces and edges family=" <<
fullName();
452 _sortConnectedItems(m_face_family, m_face_connectivity->trueCustomConnectivity());
453 if (Connectivity::hasConnectivity(m_mesh_connectivity, Connectivity::CT_NodeToEdge))
454 _sortConnectedItems(
mesh()->edgeFamily(), m_edge_connectivity->trueCustomConnectivity());
467 m_face_family->reorientFacesIfNeeded();
468 m_edge_family->reorientEdgesIfNeeded();
475_addParentNodeToNode(
Node parent_node,
Node child_node)
484_addChildNodeToNode(
Node parent_node,
Node child_node)
#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.
Template class for converting a type.
Interface of an entity family.
virtual TraceMessage info()=0
Stream for an information message.
bool isSuppressed() const
True if the entity is suppressed.
View of a list to obtain information about entities.
Index of an Item in a variable.
constexpr Int32 localId() const
Local identifier of the entity in the processor subdomain.
impl::ItemBase itemBase() const
Internal part of the entity.
Int32 nbCell() const
Number of cells connected to the node.
bool getBoolWithDefault(const String &name, bool default_value) const
Value of the property named name.
Unicode character string.
TraceMessageDbg debug(Trace::eDebugLevel=Trace::Medium) const
Flow for a debug message.
TraceMessage info() const
Flow for an information message.
Incremental item->item[] connectivity.
IMesh * mesh() const override
Associated mesh.
String fullName() const override
Full family name (with the mesh's name).
ItemGroup allItems() const override
Group of all entities.
void notifyItemsUniqueIdChanged() override
Notifies that the unique IDs of the entities have been modified.
void computeSynchronizeInfos() override
Constructs the structures necessary for synchronization.
void _allocateInfosBulk(Int64ConstArrayView uids, ItemTypeInfo *type, Int32 owner, Int32ArrayView lids)
Allocates every item of uids at once.
Properties * properties() override
Properties associated with this family.
String name() const override
Family name.
void replaceCell(ItemLocalId item_lid, Integer index, ItemLocalId new_lid) override
Replaces a cell of an entity.
void replaceFace(ItemLocalId item_lid, Integer index, ItemLocalId new_lid) override
Replaces a face of an entity.
void replaceEdge(ItemLocalId item_lid, Integer index, ItemLocalId new_lid) override
Replaces an edge of an entity.
void computeSynchronizeInfos() override
Constructs the structures necessary for synchronization.
void replaceCell(ItemLocalId node, Integer index, ItemLocalId cell)
Replaces the cell index index of the node node with that of localId() node_lid.
void removeNodeIfNotConnected(Node node)
Removes the node if it is no longer connected.
void replaceFace(ItemLocalId node, Integer index, ItemLocalId face)
Replaces the face index index of the node node with that of localId() face_lid.
void notifyItemsUniqueIdChanged() override
Notifies that the unique IDs of the entities have been modified.
void setConnectivity(const Integer c)
Sets the active connectivity for the associated mesh.
void replaceEdge(ItemLocalId node, Integer index, ItemLocalId edge)
Replaces the edge index index of the node node with that of localId() face_lid.
void allocateItemsBulk(Int64ConstArrayView uids, Int32 owner, Int32ArrayView lids)
Allocates every node of uids at once, in one pass per family array.
ItemTypeInfo * m_node_type
Instance containing the node type.
bool m_is_sort_connected_faces_and_edges
Indicates if connected faces and edges are sorted by nodes.
IncrementalItemConnectivity * edgeConnectivity() const
The true connectivity behind the selector, for a bulk fill.
MeshVariableScalarRefT< Node, Real3 > VariableNodeReal3
Coordinate type quantity at node.
Int32 Integer
Type representing an integer.
ConstArrayView< Int64 > Int64ConstArrayView
C equivalent of a 1D array of 64-bit integers.
ArrayView< Int32 > Int32ArrayView
C equivalent of a 1D array of 32-bit integers.
@ IK_Node
Node mesh entity.
@ IK_Cell
Cell mesh entity.
@ IK_Face
Face mesh entity.
@ IK_Edge
Edge mesh entity.
std::int32_t Int32
Signed integer type of 32 bits.