14#include "arcane/mesh/CellFamily.h"
16#include "arcane/utils/FatalErrorException.h"
18#include "arcane/core/IMesh.h"
19#include "arcane/core/ISubDomain.h"
20#include "arcane/core/ItemInternalEnumerator.h"
21#include "arcane/core/Connectivity.h"
23#include "arcane/mesh/NodeFamily.h"
24#include "arcane/mesh/EdgeFamily.h"
25#include "arcane/mesh/FaceFamily.h"
26#include "arcane/mesh/CellMerger.h"
27#include "arcane/mesh/IncrementalItemConnectivity.h"
28#include "arcane/mesh/CompactIncrementalItemConnectivity.h"
29#include "arcane/mesh/ItemConnectivitySelector.h"
30#include "arcane/mesh/AbstractItemFamilyTopologyModifier.h"
31#include "arcane/mesh/NewWithLegacyConnectivity.h"
43:
public AbstractItemFamilyTopologyModifier
47 TopologyModifier(CellFamily* f)
48 : AbstractItemFamilyTopologyModifier(f)
56 m_true_family->replaceNode(item_lid, index, new_lid);
60 m_true_family->replaceEdge(item_lid, index, new_lid);
64 m_true_family->replaceFace(item_lid, index, new_lid);
68 m_true_family->replaceHParent(item_lid, index, new_lid);
72 m_true_family->replaceHChild(item_lid, index, new_lid);
77 CellFamily* m_true_family;
89, m_mesh_connectivity(0)
90, m_node_family(nullptr)
91, m_edge_family(nullptr)
92, m_face_family(nullptr)
93, m_node_connectivity(nullptr)
94, m_edge_connectivity(nullptr)
95, m_face_connectivity(nullptr)
96, m_hparent_connectivity(nullptr)
98 _setTopologyModifier(
new TopologyModifier(
this));
123 auto* nc = network->getConnectivity(
this, m_node_family, connectivityName(
this, m_node_family));
124 using NodeNetwork = NewWithLegacyConnectivityType<CellFamily, NodeFamily>::type;
126 using EdgeNetwork = NewWithLegacyConnectivityType<CellFamily, EdgeFamily>::type;
127 auto* ec = network->getConnectivity(
this, m_edge_family, connectivityName(
this, m_edge_family));
129 using FaceNetwork = NewWithLegacyConnectivityType<CellFamily, FaceFamily>::type;
130 auto* fc = network->getConnectivity(
this, m_face_family, connectivityName(
this, m_face_family));
134 m_node_connectivity =
new NodeConnectivity(
this, m_node_family,
"CellNode");
135 m_edge_connectivity =
new EdgeConnectivity(
this, m_edge_family,
"CellEdge");
136 m_face_connectivity =
new FaceConnectivity(
this, m_face_family,
"CellFace");
138 m_hparent_connectivity =
new HParentConnectivity(
this,
this,
"HParentCell");
139 m_hchild_connectivity =
new HChildConnectivity(
this,
this,
"HChildCell");
141 _addConnectivitySelector(m_node_connectivity);
142 _addConnectivitySelector(m_edge_connectivity);
143 _addConnectivitySelector(m_face_connectivity);
144 _addConnectivitySelector(m_hparent_connectivity);
145 _addConnectivitySelector(m_hchild_connectivity);
147 _buildConnectivitySelectors();
153inline void CellFamily::
154_createOne(ItemInternal* item,
Int64 uid, ItemTypeInfo* type)
156 ItemLocalId item_lid(item);
157 m_item_internal_list->cells = _itemsInternal();
158 _allocateInfos(item, uid, type);
159 auto nc = m_node_connectivity->trueCustomConnectivity();
160 nc->addConnectedItems(item_lid, type->nbLocalNode());
161 if (m_edge_prealloc != 0) {
162 auto ec = m_edge_connectivity->trueCustomConnectivity();
163 ec->addConnectedItems(item_lid, type->nbLocalEdge());
165 auto fc = m_face_connectivity->trueCustomConnectivity();
166 fc->addConnectedItems(item_lid, type->nbLocalFace());
172inline void CellFamily::
173_createOne(ItemInternal* item,
Int64 uid, ItemTypeId type_id)
175 _createOne(item, uid, _itemTypeMng()->typeFromId(type_id));
194 auto cell = findOrAllocOne(uid, type_id, is_alloc);
207 _createOne(item, uid, type_id);
215findOrAllocOne(Int64 uid, ItemTypeId type_id,
bool& is_alloc)
217 return findOrAllocOne(uid, _itemTypeMng()->typeFromId(type_id), is_alloc);
226 ItemInternal* item = _allocOne(uid);
227 _createOne(item, uid, type);
234ItemInternal* CellFamily::
235findOrAllocOne(
Int64 uid, ItemTypeInfo* type,
bool& is_alloc)
238 ItemInternal* item = _findOrAllocOne(uid, is_alloc);
240 _createOne(item, uid, type);
250 this->_preAllocate(nb_item,
true);
259 debug() <<
"Creating the list of ghost cells";
277 m_face_family->removeCellFromFace(face, cell_lid);
279 m_edge_family->removeCellFromEdge(edge, cell_lid);
281 m_node_family->removeCellFromNode(node, cell_lid);
291 _checkValidItem(icell);
299 if (icell.
level() > 0) {
300 _removeParentCellToCell(icell);
302 _removeChildCellToCell(parent_cell, icell);
314 for (
Int32 lid : cells_local_id)
325 _checkValidItem(icell);
332 if (icell.
level() > 0) {
333 _removeParentCellToCell(icell);
335 _removeChildCellToCell(parent_cell, icell);
348 _detachCells2(cells_local_id);
366 m_face_family->removeFaceIfNotConnected(face);
370 m_edge_family->removeEdgeIfNotConnected(edge);
374 m_node_family->removeNodeIfNotConnected(node);
386 _removeDetachedOne(cell);
395 ARCANE_UNUSED(keep_ghost);
396 for (
Integer i = 0, is = local_ids.
size(); i < is; ++i) {
397 removeCell(m_item_internal_list->cells[local_ids[i]]);
411 m_node_connectivity->replaceItem(cell, index, node);
424 m_edge_connectivity->replaceItem(cell, index, edge);
437 m_face_connectivity->replaceItem(cell, index, face);
446 m_hchild_connectivity->replaceItem(cell, index, child_cell);
455 m_hparent_connectivity->replaceItem(cell, index, parent_cell);
464 m_mesh_connectivity = c;
465 m_node_prealloc = Connectivity::getPrealloc(m_mesh_connectivity,
IK_Cell,
IK_Node);
466 m_node_connectivity->setPreAllocatedSize(m_node_prealloc);
468 if (
mesh()->dimension() == 3) {
470 m_edge_connectivity->setPreAllocatedSize(edge_prealloc);
471 if (Connectivity::hasConnectivity(m_mesh_connectivity, Connectivity::CT_HasEdge))
472 m_edge_prealloc = edge_prealloc;
474 m_face_prealloc = Connectivity::getPrealloc(m_mesh_connectivity,
IK_Cell,
IK_Face);
475 m_face_connectivity->setPreAllocatedSize(m_face_prealloc);
476 debug() <<
"Family " <<
name() <<
" prealloc "
477 << m_node_prealloc <<
" by node, "
478 << m_edge_prealloc <<
" by edge, "
479 << m_face_prealloc <<
" by face.";
495_addChildCellToCell2(
Cell iparent_cell,
Cell child_cell)
504_addChildCellToCell(
Cell iparent_cell,
Integer position,
Cell child_cell)
506 Cell parent_cell(iparent_cell);
511 Int32 nb_connected = m_hchild_connectivity->trueCustomConnectivity()->
nbConnectedItem(parent_cell);
512 for (
Int32 i = nb_connected; i < (position + 1); ++i)
513 m_hchild_connectivity->addConnectedItem(parent_cell,
ItemLocalId(NULL_ITEM_LOCAL_ID));
515 x->replaceHChild(
ItemLocalId(iparent_cell), position, child_cell);
525 Integer nb_children = children_cells_lid.size();
526 auto c = m_hchild_connectivity->trueCustomConnectivity();
528 ItemLocalId item_lid(parent_cell);
529 c->addConnectedItems(item_lid, nb_children);
534 for (
Integer i = 0; i < nb_children; ++i)
535 x->replaceHChild(ItemLocalId(parent_cell), i, ItemLocalId(children_cells_lid[i]));
544_removeParentCellToCell(
Cell cell)
546 m_hparent_connectivity->removeConnectedItems(ItemLocalId(cell));
553_removeChildCellToCell(
Cell parent_cell,
Cell cell)
555 m_hchild_connectivity->removeConnectedItem(ItemLocalId(parent_cell), ItemLocalId(cell));
563_removeChildrenCellsToCell(
Cell parent_cell)
565 m_hchild_connectivity->removeConnectedItems(ItemLocalId(parent_cell));
#define ARCANE_CHECK_POINTER(ptr)
Macro returning the pointer ptr if it is not null or throwing an exception if it is null.
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
Class to convert a CellLocalId to a cell.
FaceConnectedListViewType faces() const
List of faces of the cell.
EdgeConnectedListViewType edges() const
List of edges of the cell.
Constant view of an array of type T.
constexpr Integer size() const noexcept
Number of elements in the array.
virtual IItemFamily * nodeFamily()=0
Returns the node family.
virtual IItemFamily * edgeFamily()=0
Returns the edge family.
virtual IItemFamily * faceFamily()=0
Returns the face family.
virtual bool useMeshItemFamilyDependencies() const =0
check if the network itemFamily dependencies is activated
virtual IItemFamilyNetwork * itemFamilyNetwork()=0
Family network interface (connected families).
bool isSuppressed() const
True if the entity is suppressed.
@ II_Inactive
The entity is inactive //COARSEN_INACTIVE,.
Internal structure of a mesh entity.
Index of an Item in a variable.
Type of an entity (Item).
NodeConnectedListViewType nodes() const
List of nodes of the entity.
Base class for a mesh element.
constexpr Int32 localId() const
Local identifier of the entity in the processor subdomain.
ItemUniqueId uniqueId() const
Unique identifier across all domains.
impl::ItemBase itemBase() const
Internal part of the entity.
Unicode character string.
TraceMessageDbg debug(Trace::eDebugLevel=Trace::Medium) const
Flow for a debug message.
void replaceFace(ItemLocalId item_lid, Integer index, ItemLocalId new_lid) override
Replaces a face of an entity.
void replaceNode(ItemLocalId item_lid, Integer index, ItemLocalId new_lid) override
Replaces a node of an entity.
void replaceHParent(ItemLocalId item_lid, Integer index, ItemLocalId new_lid) override
Replaces a parent entity of an entity.
void replaceEdge(ItemLocalId item_lid, Integer index, ItemLocalId new_lid) override
Replaces an edge of an entity.
void replaceHChild(ItemLocalId item_lid, Integer index, ItemLocalId new_lid) override
Replaces a child entity of an entity.
void _removeSubItems(Cell cell)
Item allocOne(Int64 uid, ItemTypeId type_id, MeshInfos &mesh_info) override
Allocates an element in the family and updates the corresponding mesh_info.
void detachCells2(Int32ConstArrayView cell_local_ids)
virtual void internalRemoveItems(Int32ConstArrayView local_ids, bool keep_ghost=false) override
void replaceNode(ItemLocalId cell, Integer index, ItemLocalId node)
Replaces the node at index index of the cell cell with that of localId() node.
void removeCell(Cell cell)
void removeCells(ConstArrayView< Int32 > cells_local_id)
Removes the cells whose local numbers are cells_local_id.
void removeDetachedCell(Cell cell)
virtual void computeSynchronizeInfos() override
Constructs the structures necessary for synchronization.
void _removeNotConnectedSubItems(Cell cell)
Removes cell sub-entities that are not connected to any cell.
void _addParentCellToCell(Cell cell, Cell parent_cell)
AMR.
void replaceFace(ItemLocalId cell, Integer index, ItemLocalId face)
Replaces the face at index index of the cell cell with that of localId() face.
void detachCell(Cell cell)
void replaceEdge(ItemLocalId cell, Integer index, ItemLocalId edge)
Replaces the edge at index index of the cell cell with that of localId() edge.
void setConnectivity(const Integer c)
Defines the active connectivity for the associated mesh.
Integer nbConnectedItem(ItemLocalId lid) const final
Number of entities connected to the source entity with local ID lid.
IMesh * mesh() const override
Associated mesh.
IItemFamilyTopologyModifier * _topologyModifier() override
Topology modifier interface.
void computeSynchronizeInfos() override
Constructs the structures necessary for synchronization.
String name() const override
Family name.
Class containing mesh information.
Integer & nbCell()
Number of cells in the mesh.
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
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.