14#include "arcane/mesh/OneMeshItemAdder.h"
16#include "arcane/utils/NotSupportedException.h"
17#include "arcane/utils/ValueConvert.h"
18#include "arcane/utils/FixedArray.h"
21#include "arcane/core/MeshToMeshTransposer.h"
22#include "arcane/core/IParallelMng.h"
23#include "arcane/core/ItemPrinter.h"
25#include "arcane/mesh/DynamicMesh.h"
26#include "arcane/mesh/DynamicMeshIncrementalBuilder.h"
27#include "arcane/mesh/ItemTools.h"
28#include "arcane/mesh/ConnectivityNewWithDependenciesTypes.h"
29#include "arcane/mesh/GraphDoFs.h"
48 bool allow_build_face =
false)
49 : m_type_info(type_info)
50 , m_cell_uid(cell_uid)
52 , m_owner(sub_domain_id)
53 , m_allow_build_face(allow_build_face)
56 Int64 uniqueId()
const {
return m_cell_uid; }
58 Int32 owner()
const {
return m_owner; }
59 Integer nbNode()
const {
return m_info.size(); }
60 Integer nbFace()
const {
return m_type_info->nbLocalFace(); }
61 Integer nbEdge()
const {
return m_type_info->nbLocalEdge(); }
62 Int64 nodeUniqueId(
Integer i_node)
const {
return m_info[i_node]; }
67 bool allowBuildFace()
const {
return m_allow_build_face; }
68 bool allowBuildEdge()
const {
return m_allow_build_face; }
73 Int64 m_cell_uid = NULL_ITEM_UNIQUE_ID;
75 Int32 m_owner = A_NULL_RANK;
76 bool m_allow_build_face =
false;
85, m_mesh(mesh_builder->
mesh())
86, m_mesh_builder(mesh_builder)
87, m_cell_family(m_mesh->trueCellFamily())
88, m_node_family(m_mesh->trueNodeFamily())
89, m_face_family(m_mesh->trueFaceFamily())
90, m_edge_family(m_mesh->trueEdgeFamily())
91, m_item_type_mng(m_mesh->itemTypeMng())
96 m_work_face_orig_nodes_uid.reserve(100);
106 ItemInternal* node = m_node_family.findOrAllocOne(node_uid, is_add);
128 if (item.
nbNode() != nb_node)
129 ARCANE_FATAL(
"Trying to add existing item (kind='{0}', uid={1}) with different number of node (existing={2} new={3})",
133 for (
Int32 i = 0; i < nb_node; ++i) {
134 Int64 new_uid = nodes_uid[i];
136 if (new_uid != current_uid) {
137 std::ostringstream ostr;
138 for (
Int32 k = 0; k < nb_node; ++k)
140 ARCANE_FATAL(
"Trying to add existing item (kind='{0}', uid={1}) with different nodes (index={2} existing='{3}' new='{4}')",
141 item.
kind(), item.
uniqueId(), i, ostr.str(), nodes_uid);
156 if (uid != NULL_ITEM_UNIQUE_ID)
195 bool is_add_face =
false;
196 Face face = m_face_family.findOrAllocOne(face_uid, type_id, is_add_face);
201 for (
Integer i_node = 0; i_node < face_nb_node; ++i_node) {
203 m_face_family.replaceNode(face, i_node, node);
204 m_node_family.addFaceToNode(node, face);
212 return ItemCompatibility::_itemInternal(face);
221 m_work_edge_sorted_nodes.
resize(2);
222 m_work_edge_orig_nodes_uid.
resize(2);
224 for (
Integer z = 0; z < 2; ++z)
225 m_work_edge_orig_nodes_uid[z] = nodes_uid[z];
229 bool is_add_edge =
false;
236 for (
Integer i_node = 0; i_node < 2; ++i_node) {
239 m_node_family.addEdgeToNode(current_node_internal, edge);
249Face OneMeshItemAdder::
250_findInternalFace(
Integer i_face,
const FullCellInfo& cell_info,
bool& is_add)
252 const Int64 face_unique_id = cell_info.faceUniqueId(i_face);
253 ItemTypeInfo* cell_type_info = cell_info.
typeInfo();
254 const ItemTypeInfo::LocalFace& lf = cell_type_info->
localFace(i_face);
255 ItemTypeInfo* face_type_info = m_item_type_mng->typeFromId(lf.typeId());
256 return m_face_family.findOrAllocOne(face_unique_id, face_type_info, is_add);
263Face OneMeshItemAdder::
266 const ItemInternalMap& nodes_map = m_mesh->nodesMap();
267 ItemTypeInfo* cell_type_info = cell_info.typeInfo();
268 const ItemTypeInfo::LocalFace& lf = cell_type_info->localFace(i_face);
270 Int64 face_unique_id = NULL_ITEM_UNIQUE_ID;
280 face_internal = m_face_family.itemsMap().tryFind(face_unique_id);
285 Node nbi = nodes_map.findItem(face_sorted_nodes[0]);
288 if (face_internal.null()) {
292 info() <<
"BadCell uid=" << cell_info.uniqueId();
293 for (
Int32 i = 0; i < cell_info.nbNode(); ++i)
294 info() <<
"Cell node I=" << i <<
" uid=" << cell_info.nodeUniqueId(i);
295 ARCANE_FATAL(
"On the fly face allocation is not allowed here.\n"
296 " You need to add faces with IMeshModifier::addFaces().\n"
297 " CellUid={0} LocalFace={1} FaceNodes={2}",
298 cell_info.uniqueId(), i_face, face_sorted_nodes);
304 ItemTypeInfo* face_type = m_item_type_mng->typeFromId(lf.typeId());
305 return m_face_family.allocOne(face_unique_id, face_type);
309 return face_internal;
317Edge OneMeshItemAdder::
318_findInternalEdge(
Integer i_edge,
const FullCellInfo& cell_info,
319 Int64 first_node,
Int64 second_node,
bool& is_add)
321 ARCANE_UNUSED(first_node);
322 ARCANE_UNUSED(second_node);
324 const Int64 edge_unique_id = cell_info.edgeUniqueId(i_edge);
325 return m_edge_family.findOrAllocOne(edge_unique_id, is_add);
332Edge OneMeshItemAdder::
335 ARCANE_UNUSED(i_edge);
338 FixedArray<Int64, 2> nodes;
339 Int64 edge_unique_id = NULL_ITEM_UNIQUE_ID;
342 nodes[0] = first_node;
343 nodes[1] = second_node;
344 edge_unique_id = MeshUtils::generateHashUniqueId(nodes.view());
345 edge_internal = m_edge_family.itemsMap().tryFind(edge_unique_id);
348 const ItemInternalMap& nodes_map = m_mesh->nodesMap();
349 Node nbi = nodes_map.findItem(first_node);
352 if (edge_internal.null()) {
353 if (!cell_info.allowBuildEdge() && !use_hash)
354 ARCANE_FATAL(
"On the fly edge allocation is not allowed here."
355 " You need to add edges before with IMeshModifier::addEdges()");
359 return m_edge_family.allocOne(edge_unique_id);
363 return edge_internal;
391 bool allow_build_face)
393 CellInfoProxy cell_info_proxy(m_item_type_mng->typeFromId(type_id), cell_uid, sub_domain_id, nodes_uid, allow_build_face);
424 ARCANE_ASSERT(m_mesh->
itemFamilyNetwork(), (
"ItemFamilyNetwork is required to call OneMeshItemAdder::addOneItem"));
425 bool is_alloc =
true;
426 Item item = family_modifier->findOrAllocOne(item_uid, type_id,
m_mesh_info, is_alloc);
430 for (
Integer family_index = 0; family_index < nb_connected_family; ++family_index) {
433 Int32 nb_connected_item = CheckedConvert::toInt32(connectivity_info[info_index++]);
436 String connectivity_name = mesh::connectivityName(family, connected_family);
437 String reverse_connectivity_name = mesh::connectivityName(connected_family, family);
438 bool is_dependency =
false;
444 _clearConnectivity(
ItemLocalId(item), family_to_connected_family);
445 if (connected_family_to_family)
446 _clearReverseConnectivity(
ItemLocalId(item), family_to_connected_family, connected_family_to_family);
451 for (
Integer connected_item_index = 0; connected_item_index < nb_connected_item; ++connected_item_index) {
452 if (family_to_connected_family) {
459 if (connected_family_to_family)
460 connected_family_to_family->
addConnectedItem(ItemLocalId(connected_item_lids[connected_item_index]), ItemLocalId(item));
462 info_index += nb_connected_item;
466 return ItemCompatibility::_itemInternal(item);
471ItemInternal* OneMeshItemAdder::
472addOneItem2(IItemFamily* family,
473 IItemFamilyModifier* family_modifier,
481 ARCANE_ASSERT(m_mesh->itemFamilyNetwork(), (
"ItemFamilyNetwork is required to call OneMeshItemAdder::addOneItem"));
482 bool is_alloc =
true;
483 Item item = family_modifier->findOrAllocOne(item_uid, type_id,
m_mesh_info, is_alloc);
487 for (
Integer family_index = 0; family_index < nb_connected_family; ++family_index) {
491 Int32 nb_connected_item = CheckedConvert::toInt32(connectivity_info[info_index++]);
492 if (nb_connected_item == 0)
494 IItemFamily* connected_family =
nullptr;
495 switch (family_kind) {
497 connected_family = m_mesh->findItemFamily(family_kind, ParticleFamily::defaultFamilyName(),
false,
false);
500 if (family->name() == GraphDoFs::dualNodeFamilyName())
501 connected_family = m_mesh->findItemFamily(family_kind, GraphDoFs::linkFamilyName(),
false,
false);
503 connected_family = m_mesh->findItemFamily(family_kind, GraphDoFs::dualNodeFamilyName(),
false,
false);
506 connected_family = m_mesh->itemFamily(family_kind);
510 String connectivity_name = mesh::connectivityName(family, connected_family);
511 bool is_dependency =
false;
512 IIncrementalItemConnectivity* family_to_connected_family = m_mesh->itemFamilyNetwork()->getConnectivity(family, connected_family, connectivity_name, is_dependency);
513 if (!family_to_connected_family)
514 ARCANE_FATAL(
"Cannot find connectivity name={0}", connectivity_name);
515 bool is_deep_connectivity = m_mesh->itemFamilyNetwork()->isDeep(family_to_connected_family);
516 bool is_relation = !(is_dependency && is_deep_connectivity);
520 bool do_fatal = is_relation ? false :
true;
521 connected_family->itemsUniqueIdToLocalId(connected_item_lids, connectivity_info.subView(info_index, nb_connected_item), do_fatal);
523 Integer nb_connected_item_found = nb_connected_item;
525 for (
Integer index = 0; index < connected_item_lids.size();) {
526 if (connected_item_lids[index] == NULL_ITEM_LOCAL_ID) {
527 connected_item_lids.remove(index);
528 --nb_connected_item_found;
534 for (
Integer connected_item_index = 0; connected_item_index < nb_connected_item_found; ++connected_item_index) {
535 if (family_to_connected_family) {
537 auto connected_item_lid = ItemLocalId{ connected_item_lids[connected_item_index] };
539 if (!family_to_connected_family->hasConnectedItem(ItemLocalId(item), connected_item_lid)) {
540 family_to_connected_family->addConnectedItem(ItemLocalId(item), connected_item_lid);
544 family_to_connected_family->replaceConnectedItem(ItemLocalId(item), connected_item_index, connected_item_lid);
548 info_index += nb_connected_item;
551 debug(
Trace::Highest) <<
"[addItems] ADD_ITEM " << ItemPrinter(item) <<
" in " << family->name();
554 return ItemCompatibility::_itemInternal(item);
559void OneMeshItemAdder::
560_printRelations(ItemInternal* item)
562 debug(
Trace::Highest) <<
"[addItems] RELATIONS for " << ItemPrinter(item) <<
" in " << item->family()->name();
563 for (
const auto& relation : m_mesh->itemFamilyNetwork()->getChildRelations(item->family())) {
566 ConnectivityItemVector connected_items(relation);
567 for (
const auto& connected_item : connected_items.connectedItems(ItemLocalId(item))) {
576void OneMeshItemAdder::
577_clearConnectivity(ItemLocalId item, IIncrementalItemConnectivity* connectivity)
580 ConnectivityItemVector accessor(connectivity);
582 connectivity->removeConnectedItem(item, connected_item);
589void OneMeshItemAdder::
590_clearReverseConnectivity(ItemLocalId item, IIncrementalItemConnectivity* connectivity, IIncrementalItemConnectivity* reverse_connectivity)
592 ConnectivityItemVector accessor(connectivity);
594 reverse_connectivity->removeConnectedItem(connected_item, item);
601template <>
void OneMeshItemAdder::
605 if (m_mesh->isAmrActivated()) {
608 if (cell_info.
level() != 0) {
609 Integer child_rank = cell_info.whichChildAmI();
610 Int64 hParent_uid = cell_info.hParentCellUniqueId();
613 Cell hParent_cell = m_cell_family.findOrAllocOne(hParent_uid, cell_type, is_add);
614 m_cell_family._addParentCellToCell(new_cell, hParent_cell);
615 m_cell_family._addChildCellToCell(hParent_cell, child_rank, new_cell);
620template <>
void OneMeshItemAdder::
621_AMR_Patch(
Cell cell,
const CellInfoProxy& cell_info)
624 ARCANE_UNUSED(cell_info);
634template <
typename CellInfo>
642 const bool is_verbose =
false;
644 info() <<
"AddNewCell type_id=" << cell_type_id <<
" nb_node=" << cell_info.nbNode()
645 <<
" type=" << cell_type_info->
typeName();
650 inew_cell = m_cell_family.findOrAllocOne(cell_info.uniqueId(), cell_type_id, is_add);
653 Cell cell2(inew_cell);
655 for (
Integer i = 0, is = cell_info.nbNode(); i < is; ++i)
656 if (cell_info.nodeUniqueId(i) != cell2.
node(i).
uniqueId())
657 ARCANE_FATAL(
"trying to add existing cell (uid={0}) with different nodes",
658 cell_info.uniqueId());
660 return ItemCompatibility::_itemInternal(inew_cell);
664 Cell new_cell(inew_cell);
668 const MeshKind& mesh_kind = m_mesh->meshKind();
670 const Int32 cell_nb_face = cell_info.nbFace();
673 mut_cell.
addFlags(ItemFlags::II_HasEdgeFor1DItems);
677 if (cell_info.nbNode() != inew_cell.
nbNode())
678 ARCANE_FATAL(
"Incoherent number of nodes v={0} expected={1}", inew_cell.
nbNode(), cell_info.nbNode());
679 if (cell_nb_face != inew_cell.
nbFace())
680 ARCANE_FATAL(
"Incoherent number of faces v={0} expected={1}", inew_cell.
nbFace(), cell_nb_face);
682 ARCANE_FATAL(
"Type '{0}' is not allowed for 'Cell' (cell_uid={1})",
683 cell_type_info->
typeName(), cell_info.uniqueId());
684 if (!allow_multi_dim_cell) {
686 Int32 mesh_dimension = m_mesh->dimension();
687 if (cell_dimension >= 0 && cell_dimension != mesh_dimension)
688 ARCANE_FATAL(
"Incoherent dimension for cell uid={0} cell_dim={1} mesh_dim={2} type={3}",
689 cell_info.uniqueId(), cell_dimension, mesh_dimension, cell_type_info->
typeName());
698 if (m_mesh_builder->hasEdge()) {
699 const Int32 cell_nb_edge = cell_info.nbEdge();
701 for (
Integer i_edge = 0; i_edge < cell_nb_edge; ++i_edge) {
704 Int64 second_node = cell_info.nodeUniqueId(le.
endNode());
705 if (first_node > second_node)
706 std::swap(first_node, second_node);
709 Edge edge_internal = _findInternalEdge(i_edge, cell_info, first_node, second_node, is_add);
717 m_edge_family.replaceNode(
ItemLocalId(edge_internal), 0, current_node);
718 m_node_family.addEdgeToNode(current_node, edge_internal);
722 m_edge_family.replaceNode(
ItemLocalId(edge_internal), 1, current_node);
723 m_node_family.addEdgeToNode(current_node, edge_internal);
729 m_edge_family.addCellToEdge(edge_internal, inew_cell);
734 for (
Integer i_face = 0; i_face < cell_nb_face; ++i_face) {
738 const bool is_reorder = _isReorder(i_face, lf, cell_info);
741 Face face = _findInternalFace(i_face, cell_info, is_add);
748 info() <<
"AddFaceToCell (cell_uid=" << new_cell.
uniqueId() <<
": Create face (index=" << i_face
751 <<
" type=" << face_type_info->
typeName()
752 <<
" face_nb_linear_node=" << face_nb_linear_node
753 <<
" sorted_nodes=" << face_sorted_nodes;
757 for (
Integer i_node = 0; i_node < face_nb_node; ++i_node) {
759 info() <<
"AddNodeToFace i_node=" << i_node <<
" uid=" << face_sorted_nodes[i_node];
760 Node current_node = nodes_map.
findItem(face_sorted_nodes[i_node]);
761 m_face_family.replaceNode(face, i_node, current_node);
762 if (i_node < face_nb_linear_node) {
763 m_node_family.addFaceToNode(current_node, face);
767 if (m_mesh_builder->hasEdge()) {
769 for (
Integer i_edge = 0; i_edge < face_nb_edge; ++i_edge) {
771 m_face_family.addEdgeToFace(face, current_edge);
772 m_edge_family.addFaceToEdge(current_edge, face);
777 m_cell_family.replaceFace(new_cell, i_face, face);
780 if (m_mesh->isAmrActivated()) {
783 m_face_family.replaceFrontCellToFace(face, new_cell);
785 m_face_family.addFrontCellToFace(face, inew_cell);
789 m_face_family.replaceBackCellToFace(face, new_cell);
791 m_face_family.addBackCellToFace(face, inew_cell);
796 m_face_family.addFrontCellToFace(face, inew_cell);
799 m_face_family.addBackCellToFace(face, inew_cell);
804 _AMR_Patch(inew_cell, cell_info);
805 return ItemCompatibility::_itemInternal(inew_cell);
833 if (item.
type() == IT_Line2 && submesh_kind ==
IK_Cell)
835 if (item.
type() == IT_Vertex && submesh_kind ==
IK_Face)
846 switch (submesh_kind) {
848 new_item = m_node_family.findOrAllocOne(item.
uniqueId(), is_add);
852 new_item = m_edge_family.findOrAllocOne(item.
uniqueId(), is_add);
856 new_item = m_face_family.findOrAllocOne(item.
uniqueId(),
type, is_add);
862 new_item = m_cell_family.findOrAllocOne(item.
uniqueId(), type_id, is_add);
870 if (fatal_on_existing_item)
871 ARCANE_FATAL(
"Cannot add already existing parent item in submesh");
873 return ItemCompatibility::_itemInternal(new_item);
885 switch (submesh_kind) {
887 item_nb_face =
type->nbLocalFace();
888 item_nb_edge =
type->nbLocalEdge();
889 item_nb_node =
type->nbLocalNode();
892 item_nb_edge =
type->nbLocalEdge();
893 item_nb_node =
type->nbLocalNode();
896 item_nb_node =
type->nbLocalNode();
902 if (!m_mesh_builder->hasEdge())
908 for (
Integer z = 0; z < item_nb_face; ++z)
909 new_item->_setFace(z, NULL_ITEM_ID);
910 for (
Integer z = 0; z < item_nb_edge; ++z)
911 new_item->_setEdge(z, NULL_ITEM_ID);
912 for (
Integer z = 0; z < item_nb_node; ++z)
913 new_item->_setNode(z, NULL_ITEM_ID);
918 DynamicMeshKindInfos::ItemInternalMap& nodes_map = m_mesh->nodesMap();
920 DynamicMeshKindInfos::ItemInternalMap& parent_nodes_map = parent_mesh->nodesMap();
925 const bool direct_node_order =
929 for (
Integer i_node = 0; i_node < item_nb_node; ++i_node) {
931 if (
type->typeId() == IT_FaceVertex)
934 Int32 idx = ((direct_node_order) ? i_node : (item_nb_node - 1 - i_node));
937 Int64 new_node_uid = nodes_uid[i_node] = parent_item.
uniqueId();
938 ItemInternal* node_internal = m_node_family.findOrAllocOne(new_node_uid, is_add);
940#ifdef ARCANE_DEBUG_DYNAMIC_MESH
941 info() <<
"Création node " << new_node_uid <<
' '
952 switch (submesh_kind) {
954 m_cell_family.replaceNode(new_item_lid, i_node, node_lid);
955 m_node_family.addCellToNode(node_internal, new_item.
toCell());
958 m_face_family.replaceNode(new_item_lid, i_node, node_lid);
959 m_node_family.addFaceToNode(node_internal, new_item.
toFace());
962 m_edge_family.replaceNode(new_item_lid, i_node, node_lid);
963 m_node_family.addEdgeToNode(node_internal, new_item.
toEdge());
971 for (
Integer i_edge = 0; i_edge < item_nb_edge; ++i_edge) {
976 if (first_node > second_node)
977 std::swap(first_node, second_node);
980 if (parent_item.
null())
985 ItemInternal* edge_internal = m_edge_family.findOrAllocOne(new_edge_uid, is_add);
987#ifdef ARCANE_DEBUG_DYNAMIC_MESH
988 info() <<
"Création edge " << new_edge_uid <<
' '
996 m_edge_family.replaceNode(
ItemLocalId(edge_internal), 0, current_node);
997 m_node_family.addEdgeToNode(current_node, edge_internal);
1001 m_edge_family.replaceNode(
ItemLocalId(edge_internal), 1, current_node);
1002 m_node_family.addEdgeToNode(current_node, edge_internal);
1008 switch (submesh_kind) {
1011 m_edge_family.addCellToEdge(edge_internal, new_item.
toCell());
1015 m_edge_family.addFaceToEdge(edge_internal, new_item.
toFace());
1024 for (
Integer i_face = 0; i_face < item_nb_face; ++i_face) {
1028 m_work_face_orig_nodes_uid.resize(face_nb_node);
1029 for (
Integer z = 0; z < face_nb_node; ++z)
1030 m_work_face_orig_nodes_uid[z] = nodes_uid[lf.
node(z)];
1031 bool is_reorder =
false;
1032 if (m_mesh->dimension() == 1) {
1033 is_reorder =
m_face_reorderer.reorder1D(i_face, m_work_face_orig_nodes_uid[0]);
1045 if (m_mesh->dimension() == 1) {
1046 parent_item = parent_nodes_map.
findItem(face_sorted_nodes[0]);
1050 Int64 first_node = face_sorted_nodes[0];
1051 Int64 second_node = face_sorted_nodes[1];
1052 if (first_node > second_node)
1053 std::swap(first_node, second_node);
1059 if (parent_item.
null())
1064 ItemInternal* face_internal = m_face_family.findOrAllocOne(new_face_uid, face_type, is_add);
1066#ifdef ARCANE_DEBUG_DYNAMIC_MESH
1067 info() <<
"Création face " << new_face_uid <<
' '
1073 for (
Integer i_node = 0; i_node < face_nb_node; ++i_node) {
1074 Node current_node = nodes_map.
findItem(face_sorted_nodes[i_node]);
1075 m_face_family.replaceNode(
ItemLocalId(face_internal), i_node, current_node);
1076 m_node_family.addFaceToNode(current_node, face_internal);
1079 if (m_mesh_builder->hasEdge()) {
1081 for (
Integer i_edge = 0; i_edge < face_nb_edge; ++i_edge) {
1083 Edge current_edge = new_item.
itemBase().edgeBase(edge_idx);
1084 m_face_family.addEdgeToFace(face_internal, current_edge);
1085 m_edge_family.addFaceToEdge(current_edge, face_internal);
1092 m_face_family.addFrontCellToFace(face_internal, new_item.
toCell());
1095 m_face_family.addBackCellToFace(face_internal, new_item.
toCell());
1099 return ItemCompatibility::_itemInternal(new_item);
1108template <
typename CellInfo>
1112 Integer cell_nb_node = cell_info.nbNode();
1115 for (
Integer i_node = 0; i_node < cell_nb_node; ++i_node) {
1116 Int64 node_unique_id = cell_info.nodeUniqueId(i_node);
1117 bool is_add =
false;
1118 ItemInternal* node_internal = m_node_family.findOrAllocOne(node_unique_id, is_add);
1123 m_node_family.addCellToNode(node_internal, cell);
1124 m_cell_family.replaceNode(cell, i_node,
ItemLocalId(node_internal));
1131template <
typename CellInfo>
1132bool OneMeshItemAdder::
1136 m_work_face_orig_nodes_uid.
resize(face_nb_node);
1137 for (
Integer i_node = 0; i_node < face_nb_node; ++i_node)
1138 m_work_face_orig_nodes_uid[i_node] = cell_info.nodeUniqueId(lf.
node(i_node));
1139 bool is_reorder =
false;
1141 is_reorder =
m_face_reorderer.reorder1D(i_face, m_work_face_orig_nodes_uid[0]);
1169 ARCANE_FATAL(
"Can not call this method when edge or face are already created");
#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.
Utility functions for the mesh.
bool reorderNodesOfFace(Int64ConstArrayView before_ids, Int64ArrayView after_ids)
Reorders the nodes of a face.
Int64 generateHashUniqueId(SmallSpan< const Int64 > nodes_unique_id)
Generates a unique identifier from a list of node identifiers.
void resize(Int64 s)
Changes the number of elements in the array to s.
Face face(Int32 i) const
i-th face of the cell
Int32 nbFace() const
Number of faces of the cell.
Edge edge(Int32 i) const
i-th edge of the cell
Constant view of an array of type T.
constexpr ConstArrayView< T > subView(Integer abegin, Integer asize) const noexcept
Sub-view (constant) starting from element abegin and containing asize elements.
constexpr Integer size() const noexcept
Number of elements in the array.
Int32 nbCell() const
Number of cells of the face (1 or 2).
bool isSubDomainBoundary() const
Indicates if the face is on the subdomain boundary (i.e nbCell()==1).
Interface for managing an incremental connectivity.
virtual void replaceConnectedItem(ItemLocalId source_item, Integer index, ItemLocalId target_local_id)=0
Replaces the entity at index index of source_item with the entity with localId() target_local_id.
virtual void addConnectedItem(ItemLocalId source_item, ItemLocalId target_local_id)=0
Adds the entity with localId() target_local_id to the connectivity of source_item.
Interface for modifying a family.
virtual IIncrementalItemConnectivity * getStoredConnectivity(IItemFamily *source_family, IItemFamily *target_family, const String &name)=0
Returns, if associated with storage, the connectivity between the families source_family and target_f...
Interface of an entity family.
virtual String name() const =0
Family name.
virtual void itemsUniqueIdToLocalId(Int32ArrayView local_ids, Int64ConstArrayView unique_ids, bool do_fatal=true) const =0
Converts an array of unique numbers to local numbers.
ItemUniqueId uniqueId() const
Unique number of the entity.
ItemTypeInfo * typeInfo() const
Type of the entity.
Int32 localId() const
Local number (in the subdomain) of the entity.
Internal structure of a mesh entity.
Index of an Item in a variable.
Type of an entity (Item).
static ItemTypeId fromInteger(Int64 v)
Creates an instance from an integer.
Local information about a cell edge.
Integer endNode() const
Local index in the cell of the ending node of the edge.
Integer beginNode() const
Local index in the cell of the starting node of the edge.
Local information about a cell face.
Integer node(Integer i) const
Local index in the cell of the i-th node of the face.
Integer nbEdge() const
Number of edges of the face.
Integer typeId() const
Type of the face entity.
Integer edge(Integer i) const
Edge of the face.
Integer nbNode() const
Number of nodes of the face.
Info on a mesh entity type.
LocalEdge localEdge(Integer id) const
Local connectivity of the i-th edge of the cell.
LocalFace localFace(Integer id) const
Local connectivity of the i-th face of the cell.
const ItemTypeInfo * linearTypeInfo() const
Type of the corresponding linear element.
Int16 dimension() const
Dimension of the element (<0 if unknown).
Integer nbLocalNode() const
Number of nodes of the entity.
String typeName() const
Type name.
Integer nbLocalFace() const
Number of faces of the entity.
bool isValidForCell() const
Indicates if the type is valid for creating a cell.
ItemTypeId itemTypeId() const
Type number.
Mesh entity type manager.
ItemTypeInfo * typeFromId(Integer id) const
Type corresponding to the number id.
Mesh element based on nodes (Edge,Face,Cell).
Node node(Int32 i) const
i-th node of the entity
Int32 nbNode() const
Number of nodes of the entity.
Base class for a mesh element.
impl::MutableItemBase mutableItemBase() const
Mutable internal part of the entity.
constexpr Int32 localId() const
Local identifier of the entity in the processor subdomain.
Edge toEdge() const
Converts the entity to the Edge kind.
Int32 owner() const
Owner subdomain number of the entity.
ItemWithNodes toItemWithNodes() const
Converts the entity to the ItemWithNodes kind.
Cell toCell() const
Converts the entity to the Cell kind.
ItemUniqueId uniqueId() const
Unique identifier across all domains.
constexpr bool null() const
true if the entity is null (i.e. not connected to the mesh)
Face toFace() const
Converts the entity to the Face kind.
impl::ItemBase itemBase() const
Internal part of the entity.
constexpr eItemKind kind() const
Entity kind.
Int16 type() const
Entity type.
Characteristics of a mesh.
bool isMonoDimension() const
True if the mesh structure is eMeshCellDimensionKind::MonoDimension.
static eItemKind kindTranspose(eItemKind kindA, IMesh *meshA, IMesh *meshB)
Transpose the kind kindA of mesh meshA to the associated kind in meshB.
Methods allowing modification of ItemBase.
void setOwner(Integer suid, Int32 current_sub_domain)
Sets the sub-domain number of the entity owner.
void setParent(Int32 aindex, Int32 parent_local_id)
Sets the i-th parent (currently aindex must be 0).
void addFlags(Int32 added_flags)
Adds the flags added_flags to those of the entity.
Exception when an operation is not supported.
Unicode character string.
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
TraceMessageDbg debug(Trace::eDebugLevel=Trace::Medium) const
Flow for a debug message.
TraceMessage info() const
Flow for an information message.
ITraceMng * traceMng() const
Trace manager.
Construction of a mesh incrementally.
Implementation of a mesh.
IItemFamily * itemFamily(eItemKind ik) override
Returns the entity family of type ik.
Integer dimension() override
Mesh dimension (1D, 2D, or 3D).
IItemFamilyNetwork * itemFamilyNetwork() override
Family network interface (connected families).
Item findOrAllocOne(Int64 uid, ItemTypeId type_id, MeshInfos &mesh_info, bool &is_alloc) override
Retrieves or allocates a unique numbered edge uid and of type type.Generic item addition.
void replaceNode(ItemLocalId edge, Integer index, ItemLocalId node)
Replaces the node at index index of the edge edge with * that of localId() node_lid.
Info to create/serialize a cell knowing the uniqueId() and owner() of all these sub-entities (cells,...
Integer level() const
AMR.
Associative array of ItemInternal.
impl::ItemBase findItem(Int64 uid) const
Returns the unique ID entity uid.
Int32 rank() const
Number of this subdomain.
Integer & nbEdge()
Number of edges in the mesh.
Integer & nbNode()
Number of nodes in the mesh.
void _checkSameItemCoherency(ItemWithNodes item, ConstArrayView< Int64 > nodes_uid)
Checks the coherence of nodes for an already added item.
void _addNodesToCell(Cell cell, const CellInfo &cell_info)
Adds the nodes nodes_uid to the cell cell.
NodesOfItemReorderer m_face_reorderer
Work arrays.
ItemInternal * _addOneCell(const CellInfo &cell_info)
Adds a cell.
ItemInternal * addOneCell(ItemTypeId type_id, Int64 cell_uid, Int32 sub_domain_id, Int64ConstArrayView nodes_uid, bool allow_build_face)
Adds a cell.
MeshInfos m_mesh_info
General information about the mesh (sub-domain number, number of items...).
Int64 _checkGenerateFaceUniqueId(Int64 uid, ConstArrayView< Int64 > nodes_uid)
Generates a uniqueId() for the face if uid is null.
Int64 m_next_edge_uid
Next uniqueId() number used for generating edges.
void setUseNodeUniqueIdToGenerateEdgeAndFaceUniqueId(bool v)
Positions the uniqueId() numbering mechanism.
void resetAfterDeallocate()
Resets the structures to allow for re-allocation.
bool m_use_hash_for_edge_and_face_unique_id
If true, generates face uniqueIds from node uniqueIds.
Int64 m_next_face_uid
Next uniqueId() number used for generating faces.
ItemInternal * addOneParentItem(const Item &item, const eItemKind submesh_kind, const bool fatal_on_existing_item=true)
Adds a parent item.
ItemInternal * addOneFace(ItemTypeId type_id, Int64 face_uid, Int32 owner_rank, Int64ConstArrayView nodes_uid)
Adds a face.
bool arcaneIsCheck()
True if running in check mode.
UniqueArray< Int64 > Int64UniqueArray
Dynamic 1D array of 64-bit integers.
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.
UniqueArray< Int32 > Int32UniqueArray
Dynamic 1D array of 32-bit integers.
eItemKind
Mesh entity type.
@ IK_Particle
Particle mesh entity.
@ IK_Node
Node mesh entity.
@ IK_Cell
Cell mesh entity.
@ IK_Face
Face mesh entity.
@ IK_DoF
Degree of Freedom mesh entity.
@ IK_Edge
Edge mesh entity.
std::int32_t Int32
Signed integer type of 32 bits.