14#include "arcane/mesh/OneMeshItemAdder.h"
16#include "arcane/utils/NotSupportedException.h"
17#include "arcane/utils/ValueConvert.h"
18#include "arcane/utils/FixedArray.h"
19#include "arcane/utils/HashTableMap2.h"
22#include "arcane/core/MeshToMeshTransposer.h"
23#include "arcane/core/IParallelMng.h"
24#include "arcane/core/ItemPrinter.h"
25#include "arcane/core/ItemTypeInfoBuilder.h"
26#include "arcane/core/internal/ItemTypeMngInternal.h"
28#include "arcane/mesh/DynamicMesh.h"
29#include "arcane/mesh/DynamicMeshIncrementalBuilder.h"
30#include "arcane/mesh/ItemTools.h"
31#include "arcane/mesh/ConnectivityNewWithDependenciesTypes.h"
32#include "arcane/mesh/GraphDoFs.h"
50 bool allow_build_face =
false)
51 : m_type_info(type_info)
52 , m_cell_uid(cell_uid)
56 , m_allow_build_face(allow_build_face)
59 Int64 uniqueId()
const {
return m_cell_uid; }
60 ItemTypeId itemTypeId()
const {
return m_type_id; }
62 Int32 owner()
const {
return m_owner; }
63 Integer nbNode()
const {
return m_info.size(); }
64 Integer nbFace()
const {
return m_type_info->nbLocalFace(); }
65 Integer nbEdge()
const {
return m_type_info->nbLocalEdge(); }
66 Int64 nodeUniqueId(
Integer i_node)
const {
return m_info[i_node]; }
70 bool allowBuildFace()
const {
return m_allow_build_face; }
71 bool allowBuildEdge()
const {
return m_allow_build_face; }
78 Int64 m_cell_uid = NULL_ITEM_UNIQUE_ID;
80 Int32 m_owner = A_NULL_RANK;
82 bool m_allow_build_face =
false;
91, m_mesh(mesh_builder->
mesh())
92, m_mesh_builder(mesh_builder)
93, m_cell_family(m_mesh->trueCellFamily())
94, m_node_family(m_mesh->trueNodeFamily())
95, m_face_family(m_mesh->trueFaceFamily())
96, m_edge_family(m_mesh->trueEdgeFamily())
97, m_item_type_mng(m_mesh->itemTypeMng())
102 m_work_face_orig_nodes_uid.reserve(100);
112 ItemInternal* node = m_node_family.findOrAllocOne(node_uid,is_add);
134 if (item.
nbNode()!=nb_node)
135 ARCANE_FATAL(
"Trying to add existing item (kind='{0}', uid={1}) with different number of node (existing={2} new={3})",
139 for(
Int32 i=0; i<nb_node; ++i ){
140 Int64 new_uid = nodes_uid[i];
142 if (new_uid != current_uid){
143 std::ostringstream ostr;
144 for(
Int32 k=0; k<nb_node; ++k )
146 ARCANE_FATAL(
"Trying to add existing item (kind='{0}', uid={1}) with different nodes (index={2} existing='{3}' new='{4}')",
147 item.
kind(), item.
uniqueId(), i, ostr.str(), nodes_uid);
162 if (uid!=NULL_ITEM_UNIQUE_ID)
201 bool is_add_face =
false;
202 Face face = m_face_family.findOrAllocOne(face_uid,type_id,is_add_face);
207 for(
Integer i_node=0; i_node<face_nb_node; ++i_node ){
209 m_face_family.replaceNode(face,i_node,node);
210 m_node_family.addFaceToNode(node, face);
218 return ItemCompatibility::_itemInternal(face);
227 m_work_edge_sorted_nodes.
resize(2);
228 m_work_edge_orig_nodes_uid.
resize(2);
231 m_work_edge_orig_nodes_uid[z] = nodes_uid[z];
235 bool is_add_edge =
false;
242 for(
Integer i_node=0; i_node<2; ++i_node ){
245 m_node_family.addEdgeToNode(current_node_internal, edge);
255Face OneMeshItemAdder::
256_findInternalFace(
Integer i_face,
const FullCellInfo& cell_info,
bool& is_add)
258 const Int64 face_unique_id = cell_info.faceUniqueId(i_face);
259 ItemTypeInfo* cell_type_info = cell_info.
typeInfo();
260 const ItemTypeInfo::LocalFace& lf = cell_type_info->
localFace(i_face);
261 ItemTypeInfo* face_type_info = m_item_type_mng->typeFromId(lf.typeId());
262 return m_face_family.findOrAllocOne(face_unique_id,face_type_info,is_add);
269Face OneMeshItemAdder::
272 const ItemInternalMap& nodes_map = m_mesh->nodesMap();
273 ItemTypeInfo* cell_type_info = cell_info.typeInfo();
274 const ItemTypeInfo::LocalFace& lf = cell_type_info->localFace(i_face);
276 Int64 face_unique_id = NULL_ITEM_UNIQUE_ID;
286 face_internal = m_face_family.itemsMap().tryFind(face_unique_id);
291 Node nbi = nodes_map.findItem(face_sorted_nodes[0]);
294 if (face_internal.null()) {
298 info() <<
"BadCell uid=" << cell_info.uniqueId();
299 for(
Int32 i=0; i<cell_info.nbNode(); ++i )
300 info() <<
"Cell node I=" << i <<
" uid=" << cell_info.nodeUniqueId(i);
301 ARCANE_FATAL(
"On the fly face allocation is not allowed here.\n"
302 " You need to add faces with IMeshModifier::addFaces().\n"
303 " CellUid={0} LocalFace={1} FaceNodes={2}",
304 cell_info.uniqueId(),i_face,face_sorted_nodes);
310 ItemTypeInfo* face_type = m_item_type_mng->typeFromId(lf.typeId());
311 return m_face_family.allocOne(face_unique_id,face_type);
315 return face_internal;
323Edge OneMeshItemAdder::
324_findInternalEdge(
Integer i_edge,
const FullCellInfo& cell_info,
325 Int64 first_node,
Int64 second_node,
bool& is_add)
327 ARCANE_UNUSED(first_node);
328 ARCANE_UNUSED(second_node);
330 const Int64 edge_unique_id = cell_info.edgeUniqueId(i_edge);
331 return m_edge_family.findOrAllocOne(edge_unique_id,is_add);
338Edge OneMeshItemAdder::
341 ARCANE_UNUSED(i_edge);
344 FixedArray<Int64,2> nodes;
345 Int64 edge_unique_id = NULL_ITEM_UNIQUE_ID;
348 nodes[0] = first_node;
349 nodes[1] = second_node;
350 edge_unique_id = MeshUtils::generateHashUniqueId(nodes.view());
351 edge_internal = m_edge_family.itemsMap().tryFind(edge_unique_id);
354 const ItemInternalMap& nodes_map = m_mesh->nodesMap();
355 Node nbi = nodes_map.findItem(first_node);
358 if (edge_internal.null()){
359 if (!cell_info.allowBuildEdge() && !use_hash)
360 ARCANE_FATAL(
"On the fly edge allocation is not allowed here."
361 " You need to add edges before with IMeshModifier::addEdges()");
365 return m_edge_family.allocOne(edge_unique_id);
369 return edge_internal;
391ItemInternal* OneMeshItemAdder::
392addOneCell(ItemTypeId type_id,
Int64 cell_uid,
Int32 owner,
393 ConstArrayView<Int64> nodes_uid,
bool allow_build_face)
395 if (type_id == ITI_GenericPolyhedron)
396 return _addOnePolyhedron(cell_uid, nodes_uid, owner, allow_build_face);
397 CellInfoProxy cell_info_proxy(type_id, m_item_type_mng->typeFromId(type_id), cell_uid, owner, nodes_uid, allow_build_face);
427 ARCANE_ASSERT(m_mesh->
itemFamilyNetwork(),(
"ItemFamilyNetwork is required to call OneMeshItemAdder::addOneItem"));
428 bool is_alloc =
true;
429 Item item = family_modifier->findOrAllocOne(item_uid,type_id,
m_mesh_info,is_alloc);
433 for (
Integer family_index = 0; family_index < nb_connected_family; ++family_index){
436 Int32 nb_connected_item = CheckedConvert::toInt32(connectivity_info[info_index++]);
439 String connectivity_name = mesh::connectivityName(family,connected_family);
440 String reverse_connectivity_name = mesh::connectivityName(connected_family,family);
441 bool is_dependency =
false;
446 if(!is_dependency) _clearConnectivity(
ItemLocalId(item), family_to_connected_family);
447 if (connected_family_to_family) _clearReverseConnectivity(
ItemLocalId(item),family_to_connected_family,connected_family_to_family);
452 for (
Integer connected_item_index = 0; connected_item_index < nb_connected_item; ++connected_item_index){
453 if (family_to_connected_family) {
458 if (connected_family_to_family)
459 connected_family_to_family->
addConnectedItem(ItemLocalId(connected_item_lids[connected_item_index]),ItemLocalId(item));
461 info_index+= nb_connected_item;
465 return ItemCompatibility::_itemInternal(item);
470ItemInternal* OneMeshItemAdder::
471addOneItem2(IItemFamily* family,
472 IItemFamilyModifier* family_modifier,
480 ARCANE_ASSERT(m_mesh->itemFamilyNetwork(),(
"ItemFamilyNetwork is required to call OneMeshItemAdder::addOneItem"));
481 bool is_alloc =
true;
482 Item item = family_modifier->findOrAllocOne(item_uid,type_id,
m_mesh_info,is_alloc);
486 for (
Integer family_index = 0; family_index < nb_connected_family; ++family_index) {
490 Int32 nb_connected_item = CheckedConvert::toInt32(connectivity_info[info_index++]);
491 if (nb_connected_item == 0)
continue;
492 IItemFamily* connected_family = nullptr ;
495 connected_family = m_mesh->findItemFamily(family_kind, ParticleFamily::defaultFamilyName(),
false,
false);
498 if(family->name()==GraphDoFs::dualNodeFamilyName())
499 connected_family = m_mesh->findItemFamily(family_kind, GraphDoFs::linkFamilyName(),
false,
false);
501 connected_family = m_mesh->findItemFamily(family_kind, GraphDoFs::dualNodeFamilyName(),
false,
false);
504 connected_family = m_mesh->itemFamily(family_kind);
508 String connectivity_name = mesh::connectivityName(family,connected_family);
509 bool is_dependency =
false;
510 IIncrementalItemConnectivity* family_to_connected_family = m_mesh->itemFamilyNetwork()->getConnectivity(family,connected_family,connectivity_name,is_dependency);
511 if (!family_to_connected_family)
512 ARCANE_FATAL(
"Cannot find connectivity name={0}",connectivity_name);
513 bool is_deep_connectivity = m_mesh->itemFamilyNetwork()->isDeep(family_to_connected_family) ;
514 bool is_relation = !(is_dependency && is_deep_connectivity);
518 bool do_fatal = is_relation ? false :
true;
519 connected_family->itemsUniqueIdToLocalId(connected_item_lids,connectivity_info.subView(info_index,nb_connected_item),do_fatal);
521 Integer nb_connected_item_found = nb_connected_item;
524 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;
533 for (
Integer connected_item_index = 0; connected_item_index < nb_connected_item_found; ++connected_item_index)
535 if (family_to_connected_family)
538 auto connected_item_lid = ItemLocalId{connected_item_lids[connected_item_index]};
541 if (!family_to_connected_family->hasConnectedItem(ItemLocalId(item),connected_item_lid))
543 family_to_connected_family->addConnectedItem(ItemLocalId(item),connected_item_lid);
548 family_to_connected_family->replaceConnectedItem(ItemLocalId(item),connected_item_index,connected_item_lid);
552 info_index+= nb_connected_item;
555 debug(
Trace::Highest) <<
"[addItems] ADD_ITEM " << ItemPrinter(item) <<
" in " << family->name();
558 return ItemCompatibility::_itemInternal(item);
563void OneMeshItemAdder::
564_printRelations(ItemInternal* item)
566 debug(
Trace::Highest) <<
"[addItems] RELATIONS for " << ItemPrinter(item) <<
" in " << item->family()->name();
567 for (
const auto& relation : m_mesh->itemFamilyNetwork()->getChildRelations(item->family())) {
570 ConnectivityItemVector connected_items(relation);
571 for (
const auto& connected_item : connected_items.connectedItems(ItemLocalId(item))) {
580void OneMeshItemAdder::
581_clearConnectivity(ItemLocalId item, IIncrementalItemConnectivity* connectivity)
584 ConnectivityItemVector accessor(connectivity);
586 connectivity->removeConnectedItem(item,connected_item);
593void OneMeshItemAdder::
594_clearReverseConnectivity(ItemLocalId item, IIncrementalItemConnectivity* connectivity, IIncrementalItemConnectivity* reverse_connectivity)
596 ConnectivityItemVector accessor(connectivity);
598 reverse_connectivity->removeConnectedItem(connected_item,item);
605template<>
void OneMeshItemAdder::
609 if(m_mesh->isAmrActivated()){
612 if(cell_info.
level() != 0){
613 Integer child_rank = cell_info.whichChildAmI();
614 Int64 hParent_uid = cell_info.hParentCellUniqueId();
617 Cell hParent_cell= m_cell_family.findOrAllocOne(hParent_uid,cell_type,is_add);
618 m_cell_family._addParentCellToCell(new_cell,hParent_cell);
619 m_cell_family._addChildCellToCell(hParent_cell,child_rank,new_cell);
624template<>
void OneMeshItemAdder::
625_AMR_Patch(
Cell cell,
const CellInfoProxy& cell_info)
628 ARCANE_UNUSED(cell_info);
638template<
typename CellInfo>
646 const bool is_verbose =
false;
648 info() <<
"AddNewCell type_id=" << cell_type_id <<
" nb_node=" << cell_info.nbNode()
649 <<
" type=" << cell_type_info->
typeName();
654 inew_cell = m_cell_family.findOrAllocOne(cell_info.uniqueId(), cell_type_info, is_add);
657 Cell cell2(inew_cell);
659 for(
Integer i=0, is=cell_info.nbNode(); i<is; ++i )
660 if (cell_info.nodeUniqueId(i)!=cell2.
node(i).
uniqueId())
661 ARCANE_FATAL(
"trying to add existing cell (uid={0}) with different nodes",
662 cell_info.uniqueId());
664 return ItemCompatibility::_itemInternal(inew_cell);
668 Cell new_cell(inew_cell);
672 const MeshKind& mesh_kind = m_mesh->meshKind();
674 const Int32 cell_nb_face = cell_info.nbFace();
677 mut_cell.
addFlags(ItemFlags::II_HasEdgeFor1DItems);
681 if (cell_info.nbNode()!=inew_cell.
nbNode())
682 ARCANE_FATAL(
"Incoherent number of nodes v={0} expected={1}",inew_cell.
nbNode(),cell_info.nbNode());
683 if (cell_nb_face!=inew_cell.
nbFace())
684 ARCANE_FATAL(
"Incoherent number of faces v={0} expected={1}",inew_cell.
nbFace(),cell_nb_face);
686 ARCANE_FATAL(
"Type '{0}' is not allowed for 'Cell' (cell_uid={1})",
687 cell_type_info->
typeName(),cell_info.uniqueId());
688 if (!allow_multi_dim_cell){
690 Int32 mesh_dimension = m_mesh->dimension();
691 if (cell_dimension>=0 && cell_dimension!=mesh_dimension)
692 ARCANE_FATAL(
"Incoherent dimension for cell uid={0} cell_dim={1} mesh_dim={2} type={3}",
693 cell_info.uniqueId(),cell_dimension,mesh_dimension,cell_type_info->
typeName());
702 if (m_mesh_builder->hasEdge()) {
703 const Int32 cell_nb_edge = cell_info.nbEdge();
705 for(
Integer i_edge=0; i_edge<cell_nb_edge; ++i_edge ){
708 Int64 second_node = cell_info.nodeUniqueId( le.
endNode() );
709 if (first_node > second_node)
710 std::swap(first_node,second_node);
713 Edge edge_internal = _findInternalEdge(i_edge, cell_info, first_node, second_node, is_add);
721 m_edge_family.replaceNode(
ItemLocalId(edge_internal), 0, current_node);
722 m_node_family.addEdgeToNode(current_node, edge_internal);
726 m_edge_family.replaceNode(
ItemLocalId(edge_internal), 1, current_node);
727 m_node_family.addEdgeToNode(current_node, edge_internal);
733 m_edge_family.addCellToEdge(edge_internal,inew_cell);
738 for(
Integer i_face=0; i_face<cell_nb_face; ++i_face ){
742 const bool is_reorder = _isReorder(i_face, lf, cell_info);
745 Face face = _findInternalFace(i_face, cell_info, is_add);
752 info() <<
"AddFaceToCell (cell_uid=" << new_cell.
uniqueId() <<
": Create face (index=" << i_face
755 <<
" type=" << face_type_info->
typeName()
756 <<
" face_nb_linear_node=" << face_nb_linear_node
757 <<
" sorted_nodes=" << face_sorted_nodes;
761 for (
Integer i_node = 0; i_node < face_nb_node; ++i_node) {
763 info() <<
"AddNodeToFace i_node=" << i_node <<
" uid=" << face_sorted_nodes[i_node];
764 Node current_node = nodes_map.
findItem(face_sorted_nodes[i_node]);
765 m_face_family.replaceNode(face, i_node, current_node);
766 if (i_node<face_nb_linear_node){
767 m_node_family.addFaceToNode(current_node, face);
771 if (m_mesh_builder->hasEdge()) {
773 for(
Integer i_edge=0; i_edge<face_nb_edge; ++i_edge ){
775 m_face_family.addEdgeToFace(face,current_edge);
776 m_edge_family.addFaceToEdge(current_edge,face);
781 m_cell_family.replaceFace(new_cell,i_face,face);
784 if(m_mesh->isAmrActivated()){
787 m_face_family.replaceFrontCellToFace(face,new_cell);
789 m_face_family.addFrontCellToFace(face,inew_cell);
792 m_face_family.replaceBackCellToFace(face,new_cell);
794 m_face_family.addBackCellToFace(face,inew_cell);
798 m_face_family.addFrontCellToFace(face,inew_cell);
800 m_face_family.addBackCellToFace(face,inew_cell);
805 _AMR_Patch(inew_cell, cell_info);
806 return ItemCompatibility::_itemInternal(inew_cell);
815 const bool is_verbose =
false;
817 info() <<
"AddNewPolyhedronCell nb_connectivity=" << connectivity_infos.
size()
818 <<
" c=" << connectivity_infos;
836 Int16 nb_local_node = 0;
837 nodes_of_cell.
clear();
838 connectivity_to_local_index.clear();
839 local_nodes_of_cell.
clear();
840 arcane_faces_nb_node.
clear();
841 arcane_faces_nodes.
clear();
849 Int32 array_size =
static_cast<Int32>(connectivity_infos[0]);
850 if (array_size != connectivity_infos.
size())
851 ARCANE_FATAL(
"Incoherent size array_size={0} connectivity_info={1}", array_size, connectivity_infos.
size());
852 Int32 scheme_version =
static_cast<Int32>(connectivity_infos[1]);
853 if (scheme_version != 1)
854 ARCANE_FATAL(
"Insupported scheme version '{0}'. Only supported value is 1", scheme_version);
855 const Int32 cell_nb_face =
static_cast<Int32>(connectivity_infos[2]);
857 info() <<
"NB_FACE=" << cell_nb_face;
858 Int32 index_in_connectivity = 3;
859 for (
Int32 z = 0; z < cell_nb_face; ++z) {
860 const Int16 face_nb_node =
static_cast<Int16>(connectivity_infos[index_in_connectivity]);
861 ++index_in_connectivity;
863 info() <<
"NB_FACE_NODE=" << face_nb_node;
864 nodes_of_face.
resize(face_nb_node);
865 arcane_faces_nb_node.
add(face_nb_node);
866 for (
Int16 k = 0; k < face_nb_node; ++k) {
867 Int64 node_id = connectivity_infos[index_in_connectivity];
868 ++index_in_connectivity;
869 auto x = connectivity_to_local_index.find(node_id);
870 Int16 local_node_index = -1;
872 if (x == connectivity_to_local_index.end()) {
873 local_node_index = nb_local_node;
874 connectivity_to_local_index[node_id] = nb_local_node;
876 local_nodes_of_cell.
add(local_node_index);
877 nodes_of_cell.
add(node_id);
878 cell_nodes_uid.
add(node_id);
881 local_node_index = x->second;
882 nodes_of_face[k] = local_node_index;
883 arcane_faces_nodes.
add(local_node_index);
887 info() <<
" Polyhedral face=" << z <<
" nb_node=" << face_nb_node
888 <<
" nodes=" << nodes_of_face.
view() <<
" index=" << index_in_connectivity;
892 info() <<
"EndCreateTypeForPolyhedron nb_node=" << nodes_of_cell.
size();
893 ItemTypeMngInternal* api = m_item_type_mng->_internalApi();
894 SmallArray<Int32> type_ids_buffer;
895 ItemTypeInfoBuilder cell_type_info;
896 api->fillTemporaryTypeForPolyhedron(&cell_type_info, &type_ids_buffer, nodes_of_cell.
size(),
897 arcane_faces_nb_node, arcane_faces_nodes);
898 CellInfoProxy cell_info_proxy(ITI_GenericPolyhedron, &cell_type_info, cell_uid, owner, nodes_of_cell, allow_build_face);
928 if (item.
type() == IT_Line2 && submesh_kind ==
IK_Cell)
930 if (item.
type() == IT_Vertex && submesh_kind ==
IK_Face)
941 switch (submesh_kind) {
943 new_item = m_node_family.findOrAllocOne(item.
uniqueId(),is_add);
947 new_item = m_edge_family.findOrAllocOne(item.
uniqueId(),is_add);
951 new_item = m_face_family.findOrAllocOne(item.
uniqueId(),
type,is_add);
957 new_item = m_cell_family.findOrAllocOne(item.
uniqueId(),type_id,is_add);
965 if (fatal_on_existing_item)
966 ARCANE_FATAL(
"Cannot add already existing parent item in submesh");
968 return ItemCompatibility::_itemInternal(new_item);
980 switch (submesh_kind) {
982 item_nb_face =
type->nbLocalFace();
983 item_nb_edge =
type->nbLocalEdge();
984 item_nb_node =
type->nbLocalNode();
987 item_nb_edge =
type->nbLocalEdge();
988 item_nb_node =
type->nbLocalNode();
991 item_nb_node =
type->nbLocalNode();
997 if (!m_mesh_builder->hasEdge())
1003 for(
Integer z=0; z<item_nb_face; ++z )
1004 new_item->_setFace(z,NULL_ITEM_ID);
1005 for(
Integer z=0; z<item_nb_edge; ++z )
1006 new_item->_setEdge(z,NULL_ITEM_ID);
1007 for(
Integer z=0; z<item_nb_node; ++z )
1008 new_item->_setNode(z,NULL_ITEM_ID);
1013 DynamicMeshKindInfos::ItemInternalMap& nodes_map = m_mesh->nodesMap();
1015 DynamicMeshKindInfos::ItemInternalMap& parent_nodes_map = parent_mesh->nodesMap();
1020 const bool direct_node_order =
1023 && !(item.
toFace().isSubDomainBoundaryOutside()));
1026 for(
Integer i_node=0; i_node<item_nb_node; ++i_node ){
1028 if (
type->typeId() == IT_FaceVertex)
1031 Int32 idx = ((direct_node_order) ? i_node : (item_nb_node-1-i_node));
1034 Int64 new_node_uid = nodes_uid[i_node] = parent_item.
uniqueId();
1035 ItemInternal* node_internal = m_node_family.findOrAllocOne(new_node_uid,is_add);
1037#ifdef ARCANE_DEBUG_DYNAMIC_MESH
1038 info() <<
"Création node " << new_node_uid <<
' '
1049 switch (submesh_kind) {
1051 m_cell_family.replaceNode(new_item_lid,i_node, node_lid);
1052 m_node_family.addCellToNode(node_internal, new_item.
toCell());
1055 m_face_family.replaceNode(new_item_lid,i_node, node_lid);
1056 m_node_family.addFaceToNode(node_internal, new_item.
toFace());
1059 m_edge_family.replaceNode(new_item_lid,i_node, node_lid);
1060 m_node_family.addEdgeToNode(node_internal, new_item.
toEdge());
1068 for(
Integer i_edge=0; i_edge<item_nb_edge; ++i_edge ) {
1073 if (first_node > second_node)
1074 std::swap(first_node,second_node);
1077 if (parent_item.
null())
1082 ItemInternal* edge_internal = m_edge_family.findOrAllocOne(new_edge_uid,is_add);
1084#ifdef ARCANE_DEBUG_DYNAMIC_MESH
1085 info() <<
"Création edge " << new_edge_uid <<
' '
1093 m_edge_family.replaceNode(
ItemLocalId(edge_internal), 0, current_node);
1094 m_node_family.addEdgeToNode(current_node, edge_internal);
1098 m_edge_family.replaceNode(
ItemLocalId(edge_internal), 1, current_node);
1099 m_node_family.addEdgeToNode(current_node, edge_internal);
1106 switch (submesh_kind) {
1109 m_edge_family.addCellToEdge(edge_internal, new_item.
toCell());
1113 m_edge_family.addFaceToEdge(edge_internal, new_item.
toFace());
1122 for(
Integer i_face=0; i_face<item_nb_face; ++i_face ) {
1126 m_work_face_orig_nodes_uid.resize(face_nb_node);
1127 for(
Integer z=0; z<face_nb_node; ++z )
1128 m_work_face_orig_nodes_uid[z] = nodes_uid[ lf.
node(z) ];
1129 bool is_reorder =
false;
1130 if (m_mesh->dimension() == 1) {
1131 is_reorder =
m_face_reorderer.reorder1D(i_face, m_work_face_orig_nodes_uid[0]);
1143 if (m_mesh->dimension() == 1) {
1144 parent_item = parent_nodes_map.
findItem(face_sorted_nodes[0]);
1147 Int64 first_node = face_sorted_nodes[0];
1148 Int64 second_node = face_sorted_nodes[1];
1149 if (first_node > second_node)
1150 std::swap(first_node,second_node);
1156 if (parent_item.
null())
1161 ItemInternal* face_internal = m_face_family.findOrAllocOne(new_face_uid,face_type,is_add);
1163#ifdef ARCANE_DEBUG_DYNAMIC_MESH
1164 info() <<
"Création face " << new_face_uid <<
' '
1170 for(
Integer i_node=0; i_node<face_nb_node; ++i_node ){
1171 Node current_node = nodes_map.
findItem(face_sorted_nodes[i_node]);
1172 m_face_family.replaceNode(
ItemLocalId(face_internal), i_node, current_node);
1173 m_node_family.addFaceToNode(current_node, face_internal);
1176 if (m_mesh_builder->hasEdge()) {
1178 for(
Integer i_edge=0; i_edge<face_nb_edge; ++i_edge ){
1180 Edge current_edge = new_item.
itemBase().edgeBase(edge_idx);
1181 m_face_family.addEdgeToFace(face_internal,current_edge);
1182 m_edge_family.addFaceToEdge(current_edge,face_internal);
1189 m_face_family.addFrontCellToFace(face_internal,new_item.
toCell());
1191 m_face_family.addBackCellToFace(face_internal,new_item.
toCell());
1195 return ItemCompatibility::_itemInternal(new_item);
1203template<
typename CellInfo>
1207 Integer cell_nb_node = cell_info.nbNode();
1210 for(
Integer i_node=0; i_node<cell_nb_node; ++i_node ){
1211 Int64 node_unique_id = cell_info.nodeUniqueId(i_node);
1212 bool is_add =
false;
1213 ItemInternal* node_internal = m_node_family.findOrAllocOne(node_unique_id,is_add);
1218 m_node_family.addCellToNode(node_internal,cell);
1219 m_cell_family.replaceNode(cell,i_node,
ItemLocalId(node_internal));
1226template<
typename CellInfo>
1227bool OneMeshItemAdder::
1231 m_work_face_orig_nodes_uid.
resize(face_nb_node);
1232 for(
Integer i_node=0; i_node < face_nb_node; ++i_node)
1233 m_work_face_orig_nodes_uid[i_node] = cell_info.nodeUniqueId(lf.
node(i_node));
1234 bool is_reorder =
false;
1236 is_reorder =
m_face_reorderer.reorder1D(i_face, m_work_face_orig_nodes_uid[0]);
1264 ARCANE_FATAL(
"Can not call this method when edge or face are already created");
#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.
Fonctions utilitaires sur le maillage.
bool reorderNodesOfFace(Int64ConstArrayView before_ids, Int64ArrayView after_ids)
Réordonne les noeuds d'une face.
Int64 generateHashUniqueId(SmallSpan< const Int64 > nodes_unique_id)
Génère un identifiant unique à partir d'une liste d'identifiants de noeuds.
Integer size() const
Nombre d'éléments du vecteur.
void clear()
Supprime les éléments du tableau.
void resize(Int64 s)
Change le nombre d'éléments du tableau à s.
ArrayView< T > view() const
Vue mutable sur ce tableau.
void add(ConstReferenceType val)
Ajoute l'élément val à la fin du tableau.
Face face(Int32 i) const
i-ème face de la maille
Int32 nbFace() const
Nombre de faces de la maille.
Edge edge(Int32 i) const
i-ème arête de la maille
Vue constante d'un tableau de type T.
constexpr ConstArrayView< T > subView(Integer abegin, Integer asize) const noexcept
Sous-vue (constante) à partir de l'élément abegin et contenant asize éléments.
constexpr Integer size() const noexcept
Nombre d'éléments du tableau.
Int32 nbCell() const
Nombre de mailles de la face (1 ou 2).
bool isSubDomainBoundary() const
Indique si la face est au bord du sous-domaine (i.e nbCell()==1).
Interface pour gérer une connectivité incrémentale.
virtual void replaceConnectedItem(ItemLocalId source_item, Integer index, ItemLocalId target_local_id)=0
Remplace l'entité d'index index de source_item par l'entité de localId() target_local_id.
virtual void addConnectedItem(ItemLocalId source_item, ItemLocalId target_local_id)=0
Ajoute l'entité de localId() target_local_id à la connectivité de source_item.
Interface de modification d'une famille.
virtual IIncrementalItemConnectivity * getStoredConnectivity(IItemFamily *source_family, IItemFamily *target_family, const String &name)=0
Retourne, si elle est associée à un stockage, la connectivité entre les familles source_family et tar...
Interface d'une famille d'entités.
virtual String name() const =0
Nom de la famille.
virtual void itemsUniqueIdToLocalId(Int32ArrayView local_ids, Int64ConstArrayView unique_ids, bool do_fatal=true) const =0
Converti un tableau de numéros uniques en numéros locaux.
ItemUniqueId uniqueId() const
Numéro unique de l'entité
ItemTypeInfo * typeInfo() const
Type de l'entité.
Int32 localId() const
Numéro local (au sous-domaine) de l'entité
Structure interne d'une entité de maillage.
Index d'un Item dans une variable.
Type d'une entité (Item).
static ItemTypeId fromInteger(Int64 v)
Créé une instance à partir d'un entier.
Informations locales sur une arête d'une maille.
Integer endNode() const
Indice local à la maille du sommet extrémité de l'arête.
Integer beginNode() const
Indice local à la maille du sommet origine de l'arête.
Informations locales sur une face d'une maille.
Integer node(Integer i) const
Indice locale dans la maille du i-ème noeud de la face.
Integer nbEdge() const
Nombre d'arête de la face.
Integer typeId() const
Type de l'entité face.
Integer edge(Integer i) const
Arête de la face.
Integer nbNode() const
Nombre de noeuds de la face.
Infos sur un type d'entité du maillage.
LocalEdge localEdge(Integer id) const
Connectivité locale de la i-ème arête de la maille.
LocalFace localFace(Integer id) const
Connectivité locale de la i-ème face de la maille.
const ItemTypeInfo * linearTypeInfo() const
Type de l'élément linéaire correspondant.
Int16 dimension() const
Dimension de l'élément (<0 si inconnu).
Integer nbLocalNode() const
Nombre de noeuds de l'entité
String typeName() const
Nom du type.
Integer nbLocalFace() const
Nombre de faces de l'entité
bool isValidForCell() const
Indique si le type est valide pour créér une maille (Cell).
ItemTypeId itemTypeId() const
Numéro du type.
Gestionnaire des types d'entités d'un maillage.
ItemTypeInfo * typeFromId(Integer id) const
Type correspondant au numéro id.
Elément de maillage s'appuyant sur des noeuds (Edge,Face,Cell).
Node node(Int32 i) const
i-ème noeud de l'entité
Int32 nbNode() const
Nombre de noeuds de l'entité
Classe de base d'un élément de maillage.
impl::MutableItemBase mutableItemBase() const
Partie interne modifiable de l'entité.
constexpr Int32 localId() const
Identifiant local de l'entité dans le sous-domaine du processeur.
Edge toEdge() const
Converti l'entité en le genre Edge.
Int32 owner() const
Numéro du sous-domaine propriétaire de l'entité
ItemWithNodes toItemWithNodes() const
Converti l'entité en le genre ItemWithNodes.
Cell toCell() const
Converti l'entité en le genre Cell.
ItemUniqueId uniqueId() const
Identifiant unique sur tous les domaines.
constexpr bool null() const
true si l'entité est nul (i.e. non connecté au maillage)
Face toFace() const
Converti l'entité en le genre Edge.
impl::ItemBase itemBase() const
Partie interne de l'entité.
constexpr eItemKind kind() const
Genre de l'entité
Int16 type() const
Type de l'entité
Caractéristiques d'un maillage.
bool isMonoDimension() const
Vrai si la structure du maillage est eMeshCellDimensionKind::MonoDimension.
static eItemKind kindTranspose(eItemKind kindA, IMesh *meshA, IMesh *meshB)
Transpose le genre kindA du maillage meshA en le genre associé dans meshB.
Méthodes permettant de modifier ItemBase.
void setOwner(Integer suid, Int32 current_sub_domain)
Positionne le numéro du sous-domaine propriétaire de l'entité.
void setParent(Int32 aindex, Int32 parent_local_id)
Positionne le i-ème parent (actuellement aindex doit valoir 0).
void addFlags(Int32 added_flags)
Ajoute les flags added_flags à ceux de l'entité
Exception lorsqu'une opération n'est pas supportée.
Tableau 1D de données avec buffer pré-alloué sur la pile.
Chaîne de caractères unicode.
TraceAccessor(ITraceMng *m)
Construit un accesseur via le gestionnaire de trace m.
TraceMessageDbg debug(Trace::eDebugLevel=Trace::Medium) const
Flot pour un message de debug.
TraceMessage info() const
Flot pour un message d'information.
ITraceMng * traceMng() const
Gestionnaire de trace.
Vecteur 1D de données avec sémantique par valeur (style STL).
Implementation of std::unordered_map.
Construction d'un maillage de manière incrémentale.
Implémentation d'un maillage.
IItemFamily * itemFamily(eItemKind ik) override
Retourne la famille d'entité de type ik.
Integer dimension() override
Dimension du maillage (1D, 2D ou 3D).
IItemFamilyNetwork * itemFamilyNetwork() override
Interface du réseau de familles (familles connectées).
Item findOrAllocOne(Int64 uid, ItemTypeId type_id, MeshInfos &mesh_info, bool &is_alloc) override
Récupère ou alloue une arête de numéro unique uid et de type type.Ajout générique d'item.
void replaceNode(ItemLocalId edge, Integer index, ItemLocalId node)
Remplace le noeud d'index index de l'arête edge avec celui de localId() node_lid.
Infos pour créer/sérialiser une maille connaissant les uniqueId() et owner() de toutes ces sous-entit...
Integer level() const
AMR.
Tableau associatif de ItemInternal.
impl::ItemBase findItem(Int64 uid) const
Retourne l'entité de numéro unique uid.
Int32 rank() const
Numéro de ce sous-domaine.
Integer & nbEdge()
Nombre d'arêtes dans le maillage.
Integer & nbNode()
Nombre de noeuds dans le maillage.
void _checkSameItemCoherency(ItemWithNodes item, ConstArrayView< Int64 > nodes_uid)
Vérifie la cohérence des noeuds d'une entité ajouté déjà présente.
void _addNodesToCell(Cell cell, const CellInfo &cell_info)
Ajoute les noeuds nodes_uid à la maille cell.
NodesOfItemReorderer m_face_reorderer
Tableaux de travail.
ItemInternal * _addOneCell(const CellInfo &cell_info)
Ajoute une maille.
MeshInfos m_mesh_info
Info générale sur le maillage (numéro de sous-domaine, nombre d'items...).
Int64 _checkGenerateFaceUniqueId(Int64 uid, ConstArrayView< Int64 > nodes_uid)
Génère un uniqueId() pour la face si uid est nul.
Int64 m_next_edge_uid
Numéro du uniqueId() suivant utilisé pour générer les arêtes.
void setUseNodeUniqueIdToGenerateEdgeAndFaceUniqueId(bool v)
Positionne le mécanisme de numérotation des uniqueId().
void resetAfterDeallocate()
Remise à zéro des structures pour pouvoir faire à nouveau une allocation.
bool m_use_hash_for_edge_and_face_unique_id
Si vrai, génère les uniqueId() des faces à partir de ceux des noeuds.
Int64 m_next_face_uid
Numéro du uniqueId() suivant utilisé pour générer les faces.
ItemInternal * addOneParentItem(const Item &item, const eItemKind submesh_kind, const bool fatal_on_existing_item=true)
Ajoute d'un item parent.
ItemInternal * addOneFace(ItemTypeId type_id, Int64 face_uid, Int32 owner_rank, Int64ConstArrayView nodes_uid)
Ajoute une face.
@ Highest
Niveau le plus élevé
bool arcaneIsCheck()
Vrai si on est en mode vérification.
UniqueArray< Int64 > Int64UniqueArray
Tableau dynamique à une dimension d'entiers 64 bits.
std::int64_t Int64
Type entier signé sur 64 bits.
Int32 Integer
Type représentant un entier.
ConstArrayView< Int64 > Int64ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 64 bits.
UniqueArray< Int32 > Int32UniqueArray
Tableau dynamique à une dimension d'entiers 32 bits.
eItemKind
Genre d'entité de maillage.
@ IK_Particle
Entité de maillage de genre particule.
@ 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_DoF
Entité de maillage de genre degre de liberte.
@ IK_Edge
Entité de maillage de genre arête.
std::int16_t Int16
Type entier signé sur 16 bits.
std::int32_t Int32
Type entier signé sur 32 bits.