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);
157 m_nodes_coords->setUsed(
true);
158 ItemFamily::_endAllocate();
165addCellToNode(Node node,
Cell new_cell)
167 _checkValidSourceTargetItems(node, new_cell);
168 Int32 cell_lid = new_cell.localId();
169 m_cell_connectivity->addConnectedItem(ItemLocalId(node), ItemLocalId(cell_lid));
176addFaceToNode(Node node, Face new_face)
178 if (m_no_face_connectivity)
181 _checkValidSourceTargetItems(node, new_face);
182 m_face_connectivity->addConnectedItem(ItemLocalId(node), ItemLocalId(new_face));
189addEdgeToNode(Node node, Edge new_edge)
191 if (!Connectivity::hasConnectivity(m_mesh_connectivity, Connectivity::CT_NodeToEdge))
194 _checkValidSourceTargetItems(node, new_edge);
195 m_edge_connectivity->addConnectedItem(ItemLocalId(node), ItemLocalId(new_edge));
202removeEdgeFromNode(ItemLocalId node, ItemLocalId edge_to_remove)
204 if (!Connectivity::hasConnectivity(m_mesh_connectivity, Connectivity::CT_NodeToEdge))
206 m_edge_connectivity->removeConnectedItem(node, edge_to_remove);
213removeFaceFromNode(ItemLocalId node, ItemLocalId face_to_remove)
215 if (m_no_face_connectivity)
218 m_face_connectivity->removeConnectedItem(node, face_to_remove);
225removeCellFromNode(Node node, ItemLocalId cell_to_remove_lid)
227 _checkValidItem(node);
228 m_cell_connectivity->removeConnectedItem(ItemLocalId(node), cell_to_remove_lid);
237 _checkValidItem(node);
251 debug() <<
"Creating the ghosts nodes list";
258inline void NodeFamily::
259_removeNode(
Node node)
278 m_cell_connectivity->replaceItem(node, index, cell);
290 m_edge_connectivity->replaceItem(node, index, edge);
302 m_face_connectivity->replaceItem(node, index, face);
311 m_mesh_connectivity = c;
312 if (Connectivity::hasConnectivity(m_mesh_connectivity, Connectivity::CT_HasEdge))
313 m_edge_prealloc = Connectivity::getPrealloc(m_mesh_connectivity,
IK_Node,
IK_Edge);
314 m_face_prealloc = Connectivity::getPrealloc(m_mesh_connectivity,
IK_Node,
IK_Face);
315 m_cell_prealloc = Connectivity::getPrealloc(m_mesh_connectivity,
IK_Node,
IK_Cell);
316 m_face_connectivity->setPreAllocatedSize(m_face_prealloc);
317 m_cell_connectivity->setPreAllocatedSize(m_cell_prealloc);
318 debug() <<
"Family " <<
name() <<
" prealloc "
319 << m_edge_prealloc <<
" by edge, "
320 << m_face_prealloc <<
" by face, "
321 << m_cell_prealloc <<
" by cell.";
322 m_no_face_connectivity = !Connectivity::hasConnectivity(m_mesh_connectivity, Connectivity::CT_NodeToFace);
339 bool operator()(
Int32 item1,
Int32 item2)
const
341 return m_items.uniqueId(item1) < m_items.uniqueId(item2);
363 ItemInternalArrayView m_items;
369 m_msg->
info() <<
"** Compare ptr=" << m_items.data()
370 <<
" i1=" << item1 <<
" i2=" << item2
371 <<
" i1=" << m_items[item1] <<
" i2=" << m_items[item2]
372 <<
" uid1=" << m_items[item1]->uniqueId()
373 <<
" uid2=" << m_items[item2]->uniqueId();
374 return m_items[item1]->uniqueId() < m_items[item2]->uniqueId();
395 Int32ArrayView conn_lids = connectivity->_connectedItemsLocalId(lid);
396 std::sort(std::begin(conn_lids), std::end(conn_lids), ic_items);
404sortInternalReferences()
407 _sortConnectedItems(
mesh()->cellFamily(), m_cell_connectivity->trueCustomConnectivity());
413 info(4) <<
"Sorting connected faces and edges family=" <<
fullName();
414 _sortConnectedItems(m_face_family, m_face_connectivity->trueCustomConnectivity());
415 if (Connectivity::hasConnectivity(m_mesh_connectivity, Connectivity::CT_NodeToEdge))
416 _sortConnectedItems(
mesh()->edgeFamily(), m_edge_connectivity->trueCustomConnectivity());
429 m_face_family->reorientFacesIfNeeded();
430 m_edge_family->reorientEdgesIfNeeded();
437_addParentNodeToNode(
Node parent_node,
Node child_node)
446_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.
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.
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.
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.
MeshVariableScalarRefT< Node, Real3 > VariableNodeReal3
Coordinate type quantity at node.
Int32 Integer
Type representing an integer.
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.
@ Cell
The mesh is AMR by cell.
std::int32_t Int32
Signed integer type of 32 bits.