14#include "arcane/utils/Iterator.h"
15#include "arcane/utils/ArgumentException.h"
16#include "arcane/utils/NotImplementedException.h"
17#include "arcane/utils/NotSupportedException.h"
18#include "arcane/utils/ITraceMng.h"
19#include "arcane/utils/ValueConvert.h"
21#include "arcane/core/ItemTypeMng.h"
23#include "arcane/core/IParallelMng.h"
24#include "arcane/core/SerializeBuffer.h"
25#include "arcane/core/ItemPrinter.h"
26#include "arcane/core/Connectivity.h"
27#include "arcane/core/MeshToMeshTransposer.h"
28#include "arcane/core/IItemFamilyModifier.h"
30#include "arcane/mesh/DynamicMesh.h"
31#include "arcane/mesh/DynamicMeshIncrementalBuilder.h"
32#include "arcane/mesh/OneMeshItemAdder.h"
33#include "arcane/mesh/GhostLayerBuilder.h"
34#include "arcane/mesh/FaceUniqueIdBuilder.h"
35#include "arcane/mesh/EdgeUniqueIdBuilder.h"
36#include "arcane/mesh/CellFamily.h"
37#include "arcane/mesh/GraphDoFs.h"
38#include "arcane/mesh/ParticleFamily.h"
63, m_item_type_mng(mesh->itemTypeMng())
64, m_has_amr(mesh->isAmrActivated())
74DynamicMeshIncrementalBuilder::
75~DynamicMeshIncrementalBuilder()
78 delete m_face_unique_id_builder;
79 delete m_edge_unique_id_builder;
86void DynamicMeshIncrementalBuilder::
93 for(
Face face : cell.faces() ){
95 if (face.backCell()==cell){
101 add_msg =
"is a front face";
103 info() << str <<
": celluid=" << cell.uniqueId()
104 <<
" faceuid=" << face.uniqueId()
105 <<
" faceindex=" << index
109 info() << str <<
": celluid=" << cell.uniqueId()
110 <<
" nbback=" << nb_num_back_face
111 <<
" nbfront=" << nb_num_front_face;
175 "return array 'cells' has to have same size as number of cells");
232void DynamicMeshIncrementalBuilder::
278void DynamicMeshIncrementalBuilder::
279_fillFaceInfo(Integer& nb_face, Integer nb_cell,
Int64Array& faces_infos,
Int64ConstArrayView cells_infos, std::map<Int64,Int64SharedArray>& cell_to_face_connectivity_info)
281 faces_infos.reserve(2*cells_infos.size());
284 ItemTypeMng* itm = m_item_type_mng;
285 Integer cells_infos_index = 0;
287 NodeInFaceSet face_nodes_set;
288 for (Integer i_cell = 0; i_cell < nb_cell; ++i_cell) {
289 Integer item_type_id = (Integer)cells_infos[cells_infos_index++];
290 Int64 current_cell_unique_id = cells_infos[cells_infos_index++];
291 ItemTypeInfo* it = itm->typeFromId(item_type_id);
292 Integer current_cell_nb_node = it->nbLocalNode();
293 Int64ConstArrayView current_cell_node_uids(current_cell_nb_node,&cells_infos[cells_infos_index]);
294 Integer current_cell_nb_face = it->nbLocalFace();
295 for (Integer face_in_cell_index = 0; face_in_cell_index < current_cell_nb_face; ++face_in_cell_index)
297 const ItemTypeInfo::LocalFace& current_face = it->localFace(face_in_cell_index);
298 Integer current_face_nb_node = current_face.nbNode();
299 work_face_orig_nodes.resize(current_face_nb_node);
300 work_face_sorted_nodes.resize(current_face_nb_node);
302 for (Integer node_in_face_index = 0; node_in_face_index < current_face_nb_node; ++node_in_face_index)
304 work_face_orig_nodes[i++] = current_cell_node_uids[current_face.node(node_in_face_index)];
306 mesh_utils::reorderNodesOfFace(work_face_orig_nodes,work_face_sorted_nodes);
308 Int64 current_face_uid = _findFaceUniqueId(work_face_sorted_nodes,face_nodes_set);
309 if (current_face_uid == NULL_ITEM_ID)
312 faces_infos.add(current_face.typeId());
313 faces_infos.add(current_face_uid);
314 faces_infos.addRange(work_face_sorted_nodes);
315 _addFaceNodes(face_nodes_set,work_face_sorted_nodes,current_face_uid);
318 cell_to_face_connectivity_info[current_cell_unique_id].add(current_face_uid);
320 cells_infos_index += current_cell_nb_node;
326void DynamicMeshIncrementalBuilder::
327_fillEdgeInfo(Integer& nb_edge, Integer nb_face,
Int64Array& edges_infos,
330 edges_infos.reserve(2*faces_infos.size());
331 ItemTypeMng* itm = m_item_type_mng;
334 for (Integer i_face = 0; i_face < nb_face; ++i_face) {
337 ItemTypeInfo* it = itm->typeFromId(item_type_id);
338 Integer current_face_nb_node = it->nbLocalNode();
339 Int64ConstArrayView current_face_node_uids(current_face_nb_node,&faces_infos[faces_infos_index]);
340 Integer current_face_nb_edge = it->nbLocalEdge();
341 for (Integer edge_in_face_index = 0; edge_in_face_index < current_face_nb_edge; ++edge_in_face_index)
343 const ItemTypeInfo::LocalEdge& current_edge = it->localEdge(edge_in_face_index);
344 Int64 first_node = current_face_node_uids[current_edge.beginNode()];
345 Int64 second_node = current_face_node_uids[current_edge.endNode()];
346 if (first_node > second_node) std::swap(first_node,second_node);
347 auto edge_it = edge_uid_map.insert(std::make_pair(std::make_pair(first_node,second_node),
m_edge_uid_pool));
351 edges_infos.add(first_node);
352 edges_infos.add(second_node);
357 faces_infos_index += current_face_nb_node;
363void DynamicMeshIncrementalBuilder::
366 nodes_infos.reserve(faces_infos.size());
368 std::set<Int64> nodes_set;
369 ItemTypeMng* itm = m_item_type_mng;
370 for (Integer i_face = 0; i_face < nb_face; ++i_face) {
372 Integer current_face_nb_node = itm->typeFromId(type_id)->nbLocalNode();
374 for (
auto node_uid : faces_infos.subConstView(faces_infos_index,current_face_nb_node)) {
375 nodes_set.insert(node_uid);
377 faces_infos_index+=current_face_nb_node;
380 for (
auto node_uid : nodes_set) {
381 nodes_infos.add(node_uid);
387void DynamicMeshIncrementalBuilder::
390 nodes_infos.reserve(2*edges_infos.size());
392 std::set<Int64> nodes_set;
393 for (Integer i_edge = 0; i_edge < nb_edge; ++i_edge) {
395 nodes_set.insert(edges_infos[edges_infos_index++]);
396 nodes_set.insert(edges_infos[edges_infos_index++]);
399 for (
auto node_uid : nodes_set) {
400 nodes_infos.add(node_uid);
405void DynamicMeshIncrementalBuilder::
407 const std::map<Int64,Int64SharedArray>& cell_to_face_connectivity_info,
const std::map<std::pair<Int64,Int64>,
Int64>& edge_uid_map)
409 Integer cell_infos2_size_approx = 1 + 3 * (cells_infos.size()+ 2*nb_cell);
410 cell_infos2.reserve(cell_infos2_size_approx);
411 ItemTypeMng* itm = m_item_type_mng;
413 Integer nb_connected_families = hasEdge() ? 3 : 2;
414 cell_infos2.add(nb_connected_families);
415 for (Integer i_cell = 0; i_cell < nb_cell; ++i_cell) {
417 cell_infos2.add(cells_infos[cells_infos_index++]);
418 Int64 current_cell_uid = cells_infos[cells_infos_index];
419 cell_infos2.add(cells_infos[cells_infos_index++]);
420 ItemTypeInfo* it = itm->typeFromId(item_type_id);
423 Integer current_cell_nb_node = it->nbLocalNode();
424 cell_infos2.add(current_cell_nb_node);
425 Int64ConstArrayView current_cell_node_uids(current_cell_nb_node,&cells_infos[cells_infos_index]);
426 cell_infos2.addRange(current_cell_node_uids);
428 cell_infos2.add(mesh()->faceFamily()->itemKind());
429 Integer current_cell_nb_face = it->nbLocalFace();
430 cell_infos2.add(current_cell_nb_face);
431 Int64ArrayView current_cell_faces = cell_to_face_connectivity_info.find(current_cell_uid)->second.view();
432 if (current_cell_nb_face != current_cell_faces.size())
433 ARCANE_FATAL(
"Incoherent number of faces for cell {0}. Expected {1} found {2}",
434 current_cell_uid,current_cell_nb_face,current_cell_faces.size());
435 cell_infos2.addRange(current_cell_faces);
439 cell_infos2.add(mesh()->edgeFamily()->itemKind());
440 Integer current_cell_nb_edge = it->nbLocalEdge();
441 cell_infos2.add(current_cell_nb_edge);
442 for (
int edge_index = 0; edge_index < current_cell_nb_edge; ++edge_index) {
443 Int64 first_node = current_cell_node_uids[it->localEdge(edge_index).beginNode()];
444 Int64 second_node = current_cell_node_uids[it->localEdge(edge_index).endNode()];
445 if (first_node > second_node) std::swap(first_node,second_node);
446 auto edge_it = edge_uid_map.find(std::make_pair(first_node,second_node));
447 if (edge_it == edge_uid_map.end())
448 ARCANE_FATAL(
"Do not find edge with nodes {0}-{1} in edge uid map. Exiting",
449 current_cell_node_uids[it->localEdge(edge_index).beginNode()],
450 current_cell_node_uids[it->localEdge(edge_index).endNode()]);
451 cell_infos2.add(edge_it->second);
454 cells_infos_index += current_cell_nb_node;
462void DynamicMeshIncrementalBuilder::
466 Integer cell_infos2_size_approx = 1 + 2 * (cells_infos.size()+ 2*nb_cell);
467 cell_infos2.reserve(cell_infos2_size_approx);
469 ItemTypeMng* itm = m_item_type_mng;
474 faces_infos.reserve(2*cells_infos.size());
477 NodeInFaceSet face_nodes_set;
478 std::set<Int64> node_uid_set;
480 for (Integer i_cell = 0; i_cell < nb_cell; ++i_cell) {
483 cell_infos2.add(cells_infos[cells_infos_index++]);
484 cell_infos2.add(cells_infos[cells_infos_index++]);
487 ItemTypeInfo* it = itm->typeFromId(item_type_id);
489 Integer current_cell_nb_node = it->nbLocalNode();
490 cell_infos2.add(current_cell_nb_node);
491 Int64ConstArrayView current_cell_node_uids(current_cell_nb_node,&cells_infos[cells_infos_index]);
492 cell_infos2.addRange(current_cell_node_uids);
493 if (!allow_build_face) node_uid_set.insert(current_cell_node_uids.begin(),current_cell_node_uids.end());
495 cell_infos2.add(mesh()->faceFamily()->itemKind());
496 Integer current_cell_nb_face = it->nbLocalFace();
497 cell_infos2.add(current_cell_nb_face);
498 for (Integer face_in_cell_index = 0; face_in_cell_index < current_cell_nb_face; ++face_in_cell_index)
500 ItemTypeInfo::LocalFace current_face = it->localFace(face_in_cell_index);
501 Integer current_face_nb_node = current_face.nbNode();
502 work_face_orig_nodes.resize(current_face_nb_node);
503 work_face_sorted_nodes.resize(current_face_nb_node);
505 for (Integer node_in_face_index = 0; node_in_face_index < current_face_nb_node; ++node_in_face_index)
507 work_face_orig_nodes[i++] = current_cell_node_uids[current_face.node(node_in_face_index)];
509 mesh_utils::reorderNodesOfFace(work_face_orig_nodes,work_face_sorted_nodes);
511 Int64 current_face_uid = _findFaceUniqueId(work_face_sorted_nodes,face_nodes_set);
512 if (current_face_uid == NULL_ITEM_ID)
515 faces_infos.add(current_face.typeId());
516 faces_infos.add(current_face_uid);
517 faces_infos.addRange(work_face_sorted_nodes);
518 _addFaceNodes(face_nodes_set,work_face_sorted_nodes,current_face_uid);
521 cell_infos2.add(current_face_uid);
523 cells_infos_index += current_cell_nb_node;
525 if (! allow_build_face)
527 node_uids.resize(node_uid_set.size());
529 for (
Int64 node_uid : node_uid_set) node_uids[index++] = node_uid;
535void DynamicMeshIncrementalBuilder::
536_initFaceRelationInfo(ItemData& source_item_relation_data,
const ItemData& target_item_dependencies_data,
Int64ConstArrayView faces_info)
538 _fillFaceRelationInfo(source_item_relation_data,target_item_dependencies_data,faces_info,
true);
544void DynamicMeshIncrementalBuilder::
545_appendFaceRelationInfo(ItemData& source_item_relation_data,
const ItemData& target_item_dependencies_data,
Int64ConstArrayView faces_info)
547 _fillFaceRelationInfo(source_item_relation_data,target_item_dependencies_data,faces_info,
false);
552void DynamicMeshIncrementalBuilder::
553_fillFaceRelationInfo(ItemData& source_item_relation_data,
const ItemData& target_item_dependencies_data,
558 face_uids_and_types.
reserve(2*source_item_relation_data.nbItems());
559 ItemTypeMng* itm = m_item_type_mng;
560 for (Integer face_info_index = 0; face_info_index < faces_info.size();) {
561 face_uids_and_types.add(faces_info[face_info_index+1]);
562 face_uids_and_types.add(faces_info[face_info_index]);
564 face_info_index += (2+itm->typeFromId(type_id)->nbLocalNode());
566 _fillItemRelationInfo(source_item_relation_data,target_item_dependencies_data,face_uids_and_types, is_source_relation_data_empty);
571void DynamicMeshIncrementalBuilder::
572_initEdgeRelationInfo(ItemData& source_item_relation_data,
const ItemData& target_item_dependencies_data,
Int64ConstArrayView edges_info)
574 _fillEdgeRelationInfo(source_item_relation_data,target_item_dependencies_data,edges_info,
true);
580void DynamicMeshIncrementalBuilder::
581_appendEdgeRelationInfo(ItemData& source_item_relation_data,
const ItemData& target_item_dependencies_data,
Int64ConstArrayView edges_info)
583 _fillEdgeRelationInfo(source_item_relation_data,target_item_dependencies_data,edges_info,
false);
589void DynamicMeshIncrementalBuilder::
590_fillEdgeRelationInfo(ItemData& source_item_relation_data,
const ItemData& target_item_dependencies_data,
594 ARCANE_ASSERT((source_item_relation_data.nbItems()*3 == edges_info.size()),(
"source_item_relation_data and edges_info size incoherent. Exiting."));
596 edge_uids_and_types.
reserve(2*source_item_relation_data.nbItems());
597 for (Integer edge_info_index = 0; edge_info_index < edges_info.size();) {
598 edge_uids_and_types.add(edges_info[edge_info_index++]);
599 edge_uids_and_types.add(IT_Line2);
602 _fillItemRelationInfo(source_item_relation_data,target_item_dependencies_data,edge_uids_and_types, is_source_relation_data_empty);
607void DynamicMeshIncrementalBuilder::
608_initNodeRelationInfo(ItemData& source_item_relation_data,
const ItemData& target_item_dependencies_data,
Int64ConstArrayView nodes_info)
610 _fillNodeRelationInfo(source_item_relation_data,target_item_dependencies_data,nodes_info,
true);
616void DynamicMeshIncrementalBuilder::
617_appendNodeRelationInfo(ItemData& source_item_relation_data,
const ItemData& target_item_dependencies_data,
Int64ConstArrayView nodes_info)
619 _fillNodeRelationInfo(source_item_relation_data,target_item_dependencies_data,nodes_info,
false);
624void DynamicMeshIncrementalBuilder::
625_fillNodeRelationInfo(ItemData& source_item_relation_data,
const ItemData& target_item_dependencies_data,
Int64ConstArrayView nodes_info,
bool is_source_relation_data_empty){
627 ARCANE_ASSERT((source_item_relation_data.nbItems() == nodes_info.size()),(
"source_item_relation_data and nodes_info size incoherent. Exiting."));
629 for (Integer node_index = 0; node_index < nodes_info.size(); ++node_index) {
630 node_uids_and_types[2*node_index] = nodes_info[node_index];
631 node_uids_and_types[2*node_index+1] = IT_Vertex;
633 _fillItemRelationInfo(source_item_relation_data,target_item_dependencies_data,node_uids_and_types, is_source_relation_data_empty);
639void DynamicMeshIncrementalBuilder::
640_fillItemRelationInfo(ItemData& source_item_relation_data,
const ItemData& target_item_dependencies_data,
642 bool is_source_item_relation_data_empty)
644 ARCANE_ASSERT((source_item_relation_data.nbItems()*2 == source_item_uids_and_types.size()),
645 (
"source item number incoherent between source_item_relation_data and source_item_uids_and_types. Exiting."));
647 auto & source_relation_info = source_item_relation_data.itemInfos();
648 const auto & target_dependencies_info = target_item_dependencies_data.itemInfos();
649 auto source_family = source_item_relation_data.itemFamily();
650 auto target_family = target_item_dependencies_data.itemFamily();
651 if (! source_family || !target_family)
return;
652 std::map<Int64, Int64SharedArray> source_to_target_uids;
657 for (; target_info_index < target_dependencies_info.size();) {
659 Int64 target_item_uid = target_dependencies_info[target_info_index++];
660 for (Integer family_connected_to_target = 0; family_connected_to_target < nb_families_connected_to_target; ++family_connected_to_target) {
661 Int64 family_connected_to_target_kind = target_dependencies_info[target_info_index++];
662 if (family_connected_to_target_kind != source_family->itemKind()) {
664 target_info_index+= nb_non_read_values;
669 for (Integer source_item_index = 0; source_item_index < nb_source_item_connected_to_target_item; ++source_item_index) {
670 source_to_target_uids[target_dependencies_info[source_item_index+target_info_index]].add(target_item_uid);
672 target_info_index += nb_source_item_connected_to_target_item;
677 if (is_source_item_relation_data_empty) _initEmptyRelationInfo(source_relation_info, source_to_target_uids, source_item_uids_and_types,
678 target_dependencies_info.size(), target_family);
679 else _appendInitializedRelationInfo(source_relation_info, source_to_target_uids, source_item_uids_and_types,
680 target_dependencies_info.size(), target_family);
686void DynamicMeshIncrementalBuilder::
687_initEmptyRelationInfo(
Int64Array& source_relation_info, std::map<Int64, Int64SharedArray>& source_to_target_uids,
Int64ConstArrayView source_item_uids_and_types,
688 Integer approx_relation_size,
689 IItemFamily
const * target_family)
691 if (! source_relation_info.empty()) source_relation_info.clear();
692 source_relation_info.reserve(approx_relation_size);
693 source_relation_info.add(1);
695 for (Integer source_item_uids_and_types_index = 0; source_item_uids_and_types_index < source_item_uids_and_types.size(); source_item_uids_and_types_index+=2) {
696 Int64 source_item_uid = source_item_uids_and_types[source_item_uids_and_types_index];
697 source_relation_info.add(source_item_uids_and_types[source_item_uids_and_types_index+1]);
698 source_relation_info.add(source_item_uid);
699 source_relation_info.add(target_family->itemKind());
700 auto & connected_items = source_to_target_uids[source_item_uid];
701 source_relation_info.add(connected_items.size());
702 source_relation_info.addRange(connected_items.view());
708void DynamicMeshIncrementalBuilder::
709_appendInitializedRelationInfo(
Int64Array& source_relation_info, std::map<Int64, Int64SharedArray>& source_to_target_uids,
Int64ConstArrayView source_item_uids_and_types,
710 Integer approx_relation_size,
711 IItemFamily
const * target_family)
715 source_relation_info_wrk_copy.
reserve(source_relation_info.size()+approx_relation_size);
716 std::set<Int64> treated_items;
717 Integer source_relation_info_index = 0;
719 source_relation_info_wrk_copy.add(nb_connected_family+1);
720 for(; source_relation_info_index < source_relation_info.size() ;){
721 source_relation_info_wrk_copy.add(source_relation_info[source_relation_info_index++]);
722 Int64 source_item_uid = source_relation_info[source_relation_info_index++];
723 source_relation_info_wrk_copy.add(source_item_uid);
724 treated_items.insert(source_item_uid);
725 for (Integer connected_family_index = 0; connected_family_index < nb_connected_family; ++connected_family_index) {
726 source_relation_info_wrk_copy.add(source_relation_info[source_relation_info_index++]);
728 source_relation_info_wrk_copy.add(nb_connected_elements);
729 source_relation_info_wrk_copy.addRange(source_relation_info.subConstView(source_relation_info_index,nb_connected_elements));
730 source_relation_info_index += nb_connected_elements;
733 source_relation_info_wrk_copy.add(target_family->itemKind());
734 const auto& connected_items = source_to_target_uids[source_item_uid];
735 source_relation_info_wrk_copy.add(connected_items.size());
736 source_relation_info_wrk_copy.addRange(connected_items);
739 for (Integer source_item_uids_and_types_index = 0; source_item_uids_and_types_index < source_item_uids_and_types.size(); source_item_uids_and_types_index+=2) {
740 Int64 source_item_uid = source_item_uids_and_types[source_item_uids_and_types_index];
741 if (treated_items.find(source_item_uid) == treated_items.end()){
742 source_relation_info_wrk_copy.add(source_item_uids_and_types[source_item_uids_and_types_index+1]);
743 source_relation_info_wrk_copy.add(source_item_uid);
744 source_relation_info_wrk_copy.add(target_family->itemKind());
745 const auto& connected_items = source_to_target_uids[source_item_uid];
746 source_relation_info_wrk_copy.add(connected_items.size());
747 source_relation_info_wrk_copy.addRange(connected_items);
749 for (Integer connected_family_index = 0; connected_family_index < nb_connected_family; ++connected_family_index) {
750 source_relation_info_wrk_copy.add(0);
751 source_relation_info_wrk_copy.add(0);
756 source_relation_info.resize(source_relation_info_wrk_copy.size());
757 std::copy(source_relation_info_wrk_copy.begin(), source_relation_info_wrk_copy.end(), source_relation_info.begin());
763Int64 DynamicMeshIncrementalBuilder::
764_findFaceUniqueId(
Int64ConstArrayView work_face_sorted_nodes, NodeInFaceSet& face_nodes_set)
769 return _findFaceInFaceNodesSet(face_nodes_set,index,work_face_sorted_nodes,NodeInFacePtr(NULL_ITEM_ID));
774Int64 DynamicMeshIncrementalBuilder::
775_findFaceInFaceNodesSet(
const NodeInFaceSet& face_nodes_set,Integer index,
Int64ConstArrayView face_nodes, NodeInFacePtr node)
777 if (index < face_nodes.size())
779 auto found_node = std::find(face_nodes_set.begin(),face_nodes_set.end(),NodeInFacePtr(face_nodes[index]));
780 if (found_node == face_nodes_set.end())
return node->faceUid();
781 else return _findFaceInFaceNodesSet((*found_node)->nextNodeSet(),++index,face_nodes,*found_node);
783 else return node->faceUid();
788void DynamicMeshIncrementalBuilder::
793 _addFaceInFaceNodesSet(face_nodes_set, index,face_nodes, NodeInFacePtr(NULL_ITEM_ID), face_uid);
798void DynamicMeshIncrementalBuilder::
799_addFaceInFaceNodesSet(NodeInFaceSet& face_nodes_set,Integer index,
Int64ConstArrayView face_nodes, NodeInFacePtr node,
Int64 face_uid)
801 if (index < face_nodes.size())
804 auto next_node = _insertNode(face_nodes_set,face_nodes[index]);
807 _addFaceInFaceNodesSet(next_node->nextNodeSet(),++index,face_nodes,next_node,face_uid);
813 node->setFaceUid(face_uid);
818DynamicMeshIncrementalBuilder::NodeInFacePtr&
819DynamicMeshIncrementalBuilder::_insertNode(NodeInFaceSet& face_nodes_set,
Int64 inserted_node_uid)
821 NodeInFacePtr new_node(inserted_node_uid);
822 auto found_node = std::find(face_nodes_set.begin(),face_nodes_set.end(),new_node);
823 if (found_node == face_nodes_set.end()) {
824 face_nodes_set.push_back(std::move(new_node));
825 return face_nodes_set.back();
827 else return *found_node;
867 debug() <<
"[DynamicMeshIncrementalBuilder::addHChildrenCells] ADD CELLS mesh=" <<
m_mesh->
name() <<
" nb_cell=" <<
nb_cell;
872 "return array 'cells' has to have same size as number of cells");
905 debug() <<
"[DynamicMeshIncrementalBuilder::addHChildrenCells] done";
919 const Integer nb_item = items.
size();
942 "return array 'nodes' has to have same size as number of nodes");
966 "return array 'nodes' has to have same size as number of nodes");
980void DynamicMeshIncrementalBuilder::
1018 _addItemsOrRelations(
item_info_list,IItemFamilyNetwork::InverseTopologicalOrder);
1033void DynamicMeshIncrementalBuilder::
1042void DynamicMeshIncrementalBuilder::
1043_addItemsOrRelations(ItemDataList& info_list, IItemFamilyNetwork::eSchedulingOrder family_graph_traversal_order)
1046 if (info_list.size() == 0)
return;
1048 ItemData i_infos = info_list[family->itemKind()];
1051 family_graph_traversal_order);
1068 "return array containing item lids has to have be of size number of items");
1121 "return array 'faces' has to have same size as number of faces");
1161 "return array 'faces' has to have same size as number of faces");
1198void DynamicMeshIncrementalBuilder::
1205 "return array 'faces' has to have same size as number of faces");
1252void DynamicMeshIncrementalBuilder::
1255 ItemTypeMng* itm = m_item_type_mng;
1256 Integer nb_connected_family = hasEdge() ? 2 : 1;
1257 Integer face_infos2_size_approx = 1 + 2 * (faces_infos.size()+ 2*nb_face);
1258 face_infos2.reserve(face_infos2_size_approx);
1261 Integer faces_infos_index = 0;
1263 std::set<Int64> node_uids_set;
1264 face_infos2.add(nb_connected_family);
1266 for(Integer i_face=0; i_face<nb_face; ++i_face ){
1267 Integer current_face_type = (Integer)faces_infos[faces_infos_index++];
1268 Integer current_face_uid = (Integer)faces_infos[faces_infos_index++];
1269 face_infos2.add(current_face_type);
1270 face_infos2.add(current_face_uid);
1273 ItemTypeInfo* it = itm->typeFromId(current_face_type);
1274 Integer current_face_nb_node = it->nbLocalNode();
1275 face_infos2.add(current_face_nb_node);
1277 Int64ConstArrayView current_face_node_uids(current_face_nb_node,&faces_infos[faces_infos_index]);
1278 work_face_orig_nodes.resize(current_face_nb_node);
1279 work_face_sorted_nodes.resize(current_face_nb_node);
1280 work_face_orig_nodes.copy(current_face_node_uids);
1281 mesh_utils::reorderNodesOfFace(work_face_orig_nodes,work_face_sorted_nodes);
1282 face_infos2.addRange(work_face_sorted_nodes);
1283 faces_infos_index += current_face_nb_node;
1286 face_infos2.add(mesh()->edgeFamily()->itemKind());
1287 face_infos2.add(it->nbLocalEdge());
1288 for (
int edge_index = 0; edge_index < it->nbLocalEdge(); ++edge_index) {
1289 Int64 first_node = work_face_sorted_nodes[it->localEdge(edge_index).beginNode()];
1290 Int64 second_node = work_face_sorted_nodes[it->localEdge(edge_index).endNode()];
1291 if (first_node > second_node) std::swap(first_node,second_node);
1292 auto edge_it = edge_uid_map.find(std::make_pair(first_node,second_node));
1293 if (edge_it == edge_uid_map.end())
1294 ARCANE_FATAL(
"Do not find edge with nodes {0}-{1} in edge uid map. Exiting",
1295 work_face_sorted_nodes[it->localEdge(edge_index).beginNode()],
1296 work_face_sorted_nodes[it->localEdge(edge_index).endNode()]);
1297 face_infos2.add(edge_it->second);
1305void DynamicMeshIncrementalBuilder::
1308 ItemTypeMng* itm = m_item_type_mng;
1309 Integer faces_infos_index = 0;
1310 Integer face_infos2_index = 0;
1311 face_infos2[face_infos2_index++] = 1;
1314 std::set<Int64> node_uids_set;
1316 for(Integer i_face=0; i_face<nb_face; ++i_face ){
1319 face_infos2[face_infos2_index++] = faces_infos[faces_infos_index++];
1320 face_infos2[face_infos2_index++] = faces_infos[faces_infos_index++];
1323 ItemTypeInfo* it = itm->typeFromId(item_type_id);
1324 Integer current_face_nb_node = it->nbLocalNode();
1325 face_infos2[face_infos2_index++] = current_face_nb_node;
1326 Int64ConstArrayView current_face_node_uids(current_face_nb_node,&faces_infos[faces_infos_index]);
1327 work_face_orig_nodes.resize(current_face_nb_node);
1328 work_face_sorted_nodes.resize(current_face_nb_node);
1329 work_face_orig_nodes.copy(current_face_node_uids);
1330 mesh_utils::reorderNodesOfFace(work_face_orig_nodes,work_face_sorted_nodes);
1331 face_infos2.subView(face_infos2_index,current_face_nb_node).copy(work_face_sorted_nodes);
1332 faces_infos_index += current_face_nb_node;
1333 face_infos2_index += current_face_nb_node;
1334 node_uids_set.insert(current_face_node_uids.begin(),current_face_node_uids.end());
1336 node_uids.resize(node_uids_set.size());
1338 for (
Int64 node_uid : node_uids_set) node_uids[index++] = node_uid;
1358 "return array 'edges' has to have same size as number of edges");
1393 "return array 'edges' has to have same size as number of edges");
1418void DynamicMeshIncrementalBuilder::
1425 "return array 'edges' has to have same size as number of edges");
1457void DynamicMeshIncrementalBuilder::
1477 node_uids.resize(node_uids_set.size());
1479 for (
Int64 node_uid : node_uids_set) node_uids[index++] = node_uid;
1482void DynamicMeshIncrementalBuilder::
1485 Integer edges_infos_index = 0;
1486 Integer edges_new_infos_index = 0;
1489 edges_new_infos[edges_new_infos_index++] = 1;
1491 for(Integer i_edge=0; i_edge<nb_edge; ++i_edge ){
1492 edges_new_infos[edges_new_infos_index++] = IT_Line2;
1493 edges_new_infos[edges_new_infos_index++] = edges_infos[edges_infos_index++];
1495 edges_new_infos[edges_new_infos_index++] = 2;
1496 Int64 first_node = edges_infos[edges_infos_index++];
1497 Int64 second_node = edges_infos[edges_infos_index++];
1498 if (first_node > second_node) std::swap(first_node,second_node);
1499 edges_new_infos[edges_new_infos_index++] = first_node;
1500 edges_new_infos[edges_new_infos_index++] = second_node;
1507void DynamicMeshIncrementalBuilder::
1512 ItemInternalMap& faces_map =
m_mesh->facesMap();
1514 faces_map.eachItem([&](Item face) {
1515 if (face.uniqueId() > max_uid)
1516 max_uid = face.uniqueId();
1521 ItemInternalMap& edges_map =
m_mesh->edgesMap();
1523 edges_map.eachItem([&](Item edge) {
1524 if (edge.uniqueId() > max_uid)
1525 max_uid = edge.uniqueId();
1537void DynamicMeshIncrementalBuilder::
1540 info() <<
"-- Mesh information (Arcane2):";
1545 info() <<
"-- Graph information (Arcane2):";
1551void DynamicMeshIncrementalBuilder::
1552printStats(
Int32 level)
1554 info(level) <<
"-- -- Statistics";
1563 info(level) <<
"--";
1592 if (!m_face_unique_id_builder)
1594 m_face_unique_id_builder->computeFacesUniqueIds();
1597 if (!m_edge_unique_id_builder)
1599 m_edge_unique_id_builder->computeEdgesUniqueIds();
1606void DynamicMeshIncrementalBuilder::
1609 debug() <<
"Add one ghost layer";
1622 debug() <<
"Add one ghost layer";
1631void DynamicMeshIncrementalBuilder::
1675 if (family->itemKind()!=
IK_DoF || family->name()==GraphDoFs::linkFamilyName())
1677 info() <<
"Remove Items for family : "<<family->name() ;
1678 family->removeNeedRemoveMarkedItems() ;
1717#ifdef ARCANE_DEBUG_DYNAMIC_MESH
1733 }, IItemFamilyNetwork::InverseTopologicalOrder);
1734 for (
auto family :
m_mesh->itemFamilies()) {
1748 if (connectivity == 0)
1751 ARCANE_FATAL(
"Connectivity already set: cannot redefine it");
1753 m_has_edge = Connectivity::hasConnectivity(connectivity,Connectivity::CT_HasEdge);
#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_THROW(exception_class,...)
Macro pour envoyer une exception avec formattage.
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Fonctions utilitaires sur le maillage.
Tableau d'items de types quelconques.
virtual void schedule(IItemFamilyNetworkTask task, eSchedulingOrder order=TopologicalOrder)=0
Ordonnance l'exécution d'une tâche, dans l'ordre topologique ou topologique inverse du graphe de dépe...
Interface d'une famille d'entités.
virtual void removeNeedRemoveMarkedItems()=0
Supprime des entités et met a jour les connectivites.
virtual String name() const =0
Nom de la famille.
virtual eItemKind itemKind() const =0
Genre des entités.
Int32 localId() const
Numéro local (au sous-domaine) de l'entité
Flags pour les caractéristiques des entités.
@ II_NeedRemove
L'entité doit être supprimé
Structure interne d'une entité de maillage.
Type d'une entité (Item).
static ItemTypeId fromInteger(Int64 v)
Créé une instance à partir d'un entier.
Infos sur un type d'entité du maillage.
Gestionnaire des types d'entités de maillage.
Vue sur un vecteur d'entités.
Int32 size() const
Nombre d'éléments du vecteur.
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.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Méthodes permettant de modifier ItemBase.
void addNodes2(Int64ConstArrayView nodes_uid, Integer sub_domain_id, Int32ArrayView nodes)
Ajoute des noeuds au maillage actuel. Utilise l'ajout d'item générique basé sur dépendances entre fam...
void computeFacesUniqueIds()
Calcul les numéros uniques de chaque face.
bool m_verbose
Vrai si affiche messages.
void setConnectivity(Integer c)
Définit la connectivité active pour le maillage associé
void addParentCells(const ItemVectorView &items)
Ajout au maillage courant d'item venant d'un maillage parent.
void addCells(Integer nb_cell, Int64ConstArrayView cell_infos, Integer sub_domain_id, Int32ArrayView cells, bool allow_build_face=true)
Ajoute des mailles au maillage actuel.
void addParentItems(const ItemVectorView &items, const eItemKind submesh_kind)
Ajout au maillage courant d'item venant d'un maillage parent.
OneMeshItemAdder * m_one_mesh_item_adder
Outils de construction du maillage.
Int64 m_face_uid_pool
Numéro du uniqueId() utilisé pour générer les faces.
void resetAfterDeallocate()
Remise à zéro des structures pour pouvoir faire à nouveau une allocation.
void addGhostChildFromParent(Array< Int64 > &ghost_cell_to_refine)
AMR.
void addEdges2(Integer nb_edge, Int64ConstArrayView edge_infos, Integer sub_domain_id, Int32ArrayView edges)
Ajoute des arêtes au maillage actuel. Utilise l'ajout d'item générique basé sur dépendances entre fam...
Int64 m_edge_uid_pool
Numéro du uniqueId() utilisé pour générer les edges.
void addItems(ItemDataList &item_info_list)
Ajout générique d'items d'un ensemble de famille pour lesquelles on fournit un ItemData.
void addNodes(Int64ConstArrayView nodes_uid, Integer sub_domain_id, Int32ArrayView nodes)
Ajoute des noeuds au maillage actuel.
void addFaces(Integer nb_face, Int64ConstArrayView face_infos, Integer sub_domain_id, Int32ArrayView faces)
Ajoute des faces au maillage actuel.
void addEdges(Integer nb_edge, Int64ConstArrayView edge_infos, Integer sub_domain_id, Int32ArrayView edges)
Ajoute des arêtes au maillage actuel.
GhostLayerBuilder * m_ghost_layer_builder
Outil pour construire les éléments fantômes.
void addHChildrenCells(Cell hParent_cell, Integer nb_cell, Int64ConstArrayView cells_infos, Int32 sub_domain_id, Int32ArrayView cells, bool allow_build_face)
Ajoute des mailles au maillage actuel.
bool m_has_edge
Info sur la présence d'arête (accèlere l'accès à la connectivité générale)
void addFamilyItems(ItemData &item_info)
Ajout générique d'items d'une famille, décrite par son ItemInfo.
DynamicMeshIncrementalBuilder(DynamicMesh *mesh)
Construit une instance pour le maillage mesh.
void removeNeedRemoveMarkedItems()
Supprime les items fantômes.
void addCells3(Integer nb_cell, Int64ConstArrayView cell_infos, Integer sub_domain_id, Int32ArrayView cells, bool allow_build_face=true)
Ajoute des mailles au maillage actuel. Utilise l'ajout d'item générique basé sur dépendances entre fa...
void addFaces2(Integer nb_face, Int64ConstArrayView face_infos, Integer sub_domain_id, Int32ArrayView faces)
Ajoute des faces au maillage actuel. Utilise l'ajout d'item générique basé sur dépendances entre fami...
Integer m_connectivity
Info de connectivité du maillage courant.
DynamicMesh * m_mesh
Maillage associé
Implémentation d'un maillage.
bool useMeshItemFamilyDependencies() const override
check if the network itemFamily dependencies is activated
IItemFamily * nodeFamily() override
Retourne la famille des noeuds.
IItemFamily * cellFamily() override
Retourne la famille des mailles.
String name() const override
Nom du maillage.
IItemFamily * faceFamily() override
Retourne la famille des faces.
IItemFamily * findItemFamily(eItemKind ik, const String &name, bool create_if_needed, bool register_modifier_if_created) override
Retourne la famille de nom name.
IItemFamilyNetwork * itemFamilyNetwork() override
Interface du réseau de familles (familles connectées)
IItemFamily * edgeFamily() override
Retourne la famille des arêtes.
Construction des couches fantômes.
Construction des couches fantômes.
Construction des couches fantômes.
Tableau associatif de ItemInternal.
Int32 count() const
Nombre d'éléments de la table.
ItemInternal * addOneCell(ItemTypeId type_id, Int64 cell_uid, Int32 sub_domain_id, Int64ConstArrayView nodes_uid, bool allow_build_face)
Ajoute une maille.
void resetAfterDeallocate()
Remise à zéro des structures pour pouvoir faire à nouveau une allocation.
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.
Integer size() const
Nombre d'éléments du vecteur.
Exception lorsqu'un argument est invalide.
Vue modifiable d'un tableau d'un type T.
constexpr Integer size() const noexcept
Retourne la taille du tableau.
void reserve(Int64 new_capacity)
Réserve le mémoire pour new_capacity éléments.
Vue constante d'un tableau de type T.
constexpr Integer size() const noexcept
Nombre d'éléments du tableau.
Chaîne de caractères unicode.
Classe d'accès aux traces.
TraceMessageDbg debug(Trace::eDebugLevel=Trace::Medium) const
Flot pour un message de debug.
TraceMessage info() const
Flot pour un message d'information.
Vecteur 1D de données avec sémantique par valeur (style STL).
Integer toInteger(Real r)
Converti un Int64 en un Integer.
Int32 toInt32(Int64 v)
Converti un Int64 en un Int32.
Array< Int64 > Int64Array
Tableau dynamique à une dimension d'entiers 64 bits.
UniqueArray< Int64 > Int64UniqueArray
Tableau dynamique à une dimension d'entiers 64 bits.
ArrayView< Int64 > Int64ArrayView
Equivalent C d'un tableau à une dimension d'entiers 64 bits.
eItemKind
Genre d'entité de maillage.
@ IK_Particle
Entité de maillage de genre particule.
@ 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.
ConstArrayView< Int64 > Int64ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 64 bits.
@ Highest
Niveau le plus élevé
Int32 Integer
Type représentant un entier.