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);
365 m_face_family->removeFaceIfNotConnected(face);
369 m_edge_family->removeEdgeIfNotConnected(edge);
373 m_node_family->removeNodeIfNotConnected(node);
385 _removeDetachedOne(cell);
394 ARCANE_UNUSED(keep_ghost);
395 for (
Integer i = 0, is = local_ids.
size(); i < is; ++i) {
396 removeCell(m_item_internal_list->cells[local_ids[i]]);
409 m_node_connectivity->replaceItem(cell, index, node);
421 m_edge_connectivity->replaceItem(cell, index, edge);
433 m_face_connectivity->replaceItem(cell, index, face);
442 m_hchild_connectivity->replaceItem(cell, index, child_cell);
451 m_hparent_connectivity->replaceItem(cell, index, parent_cell);
460 m_mesh_connectivity = c;
461 m_node_prealloc = Connectivity::getPrealloc(m_mesh_connectivity,
IK_Cell,
IK_Node);
462 m_node_connectivity->setPreAllocatedSize(m_node_prealloc);
464 if (
mesh()->dimension() == 3) {
466 m_edge_connectivity->setPreAllocatedSize(edge_prealloc);
467 if (Connectivity::hasConnectivity(m_mesh_connectivity, Connectivity::CT_HasEdge))
468 m_edge_prealloc = edge_prealloc;
470 m_face_prealloc = Connectivity::getPrealloc(m_mesh_connectivity,
IK_Cell,
IK_Face);
471 m_face_connectivity->setPreAllocatedSize(m_face_prealloc);
472 debug() <<
"Family " <<
name() <<
" prealloc "
473 << m_node_prealloc <<
" by node, "
474 << m_edge_prealloc <<
" by edge, "
475 << m_face_prealloc <<
" by face.";
491_addChildCellToCell2(
Cell iparent_cell,
Cell child_cell)
500_addChildCellToCell(
Cell iparent_cell,
Integer position,
Cell child_cell)
502 Cell parent_cell(iparent_cell);
507 Int32 nb_connected = m_hchild_connectivity->trueCustomConnectivity()->
nbConnectedItem(parent_cell);
508 for (
Int32 i = nb_connected; i < (position + 1); ++i)
509 m_hchild_connectivity->addConnectedItem(parent_cell,
ItemLocalId(NULL_ITEM_LOCAL_ID));
511 x->replaceHChild(
ItemLocalId(iparent_cell), position, child_cell);
521 Integer nb_children = children_cells_lid.size();
522 auto c = m_hchild_connectivity->trueCustomConnectivity();
524 ItemLocalId item_lid(parent_cell);
525 c->addConnectedItems(item_lid, nb_children);
530 for (
Integer i = 0; i < nb_children; ++i)
531 x->replaceHChild(ItemLocalId(parent_cell), i, ItemLocalId(children_cells_lid[i]));
540_removeParentCellToCell(
Cell cell)
542 m_hparent_connectivity->removeConnectedItems(ItemLocalId(cell));
549_removeChildCellToCell(
Cell parent_cell,
Cell cell)
551 m_hchild_connectivity->removeConnectedItem(ItemLocalId(parent_cell), ItemLocalId(cell));
559_removeChildrenCellsToCell(
Cell parent_cell)
561 m_hchild_connectivity->removeConnectedItems(ItemLocalId(parent_cell));
#define ARCANE_CHECK_POINTER(ptr)
Macro retournant le pointeur ptr s'il est non nul ou lancant une exception s'il est nul.
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Classe pour convertir un CellLocalId vers une maille.
FaceConnectedListViewType faces() const
Liste des faces de la maille.
EdgeConnectedListViewType edges() const
Liste des arêtes de la maille.
Vue constante d'un tableau de type T.
constexpr Integer size() const noexcept
Nombre d'éléments du tableau.
virtual IItemFamily * nodeFamily()=0
Retourne la famille des noeuds.
virtual IItemFamily * edgeFamily()=0
Retourne la famille des arêtes.
virtual IItemFamily * faceFamily()=0
Retourne la famille des faces.
virtual bool useMeshItemFamilyDependencies() const =0
check if the network itemFamily dependencies is activated
virtual IItemFamilyNetwork * itemFamilyNetwork()=0
Interface du réseau de familles (familles connectées).
bool isSuppressed() const
Vrai si l'entité est supprimée.
@ II_Inactive
L'entité est inactive //COARSEN_INACTIVE,.
Structure interne d'une entité de maillage.
Index d'un Item dans une variable.
Type d'une entité (Item).
NodeConnectedListViewType nodes() const
Liste des noeuds de l'entité
Classe de base d'un élément de maillage.
constexpr Int32 localId() const
Identifiant local de l'entité dans le sous-domaine du processeur.
ItemUniqueId uniqueId() const
Identifiant unique sur tous les domaines.
impl::ItemBase itemBase() const
Partie interne de l'entité.
Chaîne de caractères unicode.
TraceMessageDbg debug(Trace::eDebugLevel=Trace::Medium) const
Flot pour un message de debug.
void replaceFace(ItemLocalId item_lid, Integer index, ItemLocalId new_lid) override
Remplace une face d'une entité.
void replaceNode(ItemLocalId item_lid, Integer index, ItemLocalId new_lid) override
Remplace un noeud d'une entité.
void replaceHParent(ItemLocalId item_lid, Integer index, ItemLocalId new_lid) override
Remplace une entité parente d'une entité.
void replaceEdge(ItemLocalId item_lid, Integer index, ItemLocalId new_lid) override
Remplace une arête d'une entité.
void replaceHChild(ItemLocalId item_lid, Integer index, ItemLocalId new_lid) override
Remplace une entité enfant d'une entité.
void _removeSubItems(Cell cell)
Item allocOne(Int64 uid, ItemTypeId type_id, MeshInfos &mesh_info) override
Alloue un élément dans la famille et met à jour le mesh_info correspondant.
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 mesh cell with that of localId() node.
void removeCell(Cell cell)
void removeCells(ConstArrayView< Int32 > cells_local_id)
Removes the meshes whose local numbers are cells_local_id.
void removeDetachedCell(Cell cell)
virtual void computeSynchronizeInfos() override
Construit les structures nécessaires à la synchronisation.
void _removeNotConnectedSubItems(Cell cell)
Removes mesh sub-entities that are not connected to any mesh.
void _addParentCellToCell(Cell cell, Cell parent_cell)
AMR.
void replaceFace(ItemLocalId cell, Integer index, ItemLocalId face)
Replaces the face at index index of the mesh 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 mesh 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
Nombre d'entité connectées à l'entité source de numéro local lid.
IMesh * mesh() const override
Maillage associé
IItemFamilyTopologyModifier * _topologyModifier() override
Interface du modificateur de topologie.
void computeSynchronizeInfos() override
Construit les structures nécessaires à la synchronisation.
String name() const override
Nom de la famille.
Class containing mesh information.
Integer & nbCell()
Number of cells in the mesh.
std::int64_t Int64
Type entier signé sur 64 bits.
Int32 Integer
Type représentant un entier.
ConstArrayView< Int32 > Int32ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.
@ IK_Node
Entité de maillage de genre noeud.
@ IK_Cell
Entité de maillage de genre maille.
@ IK_Face
Entité de maillage de genre face.
@ IK_Edge
Entité de maillage de genre arête.
@ Cell
Le maillage est AMR par maille.
std::int32_t Int32
Type entier signé sur 32 bits.