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;
176 "return array 'cells' has to have same size as number of cells");
233void DynamicMeshIncrementalBuilder::
279void DynamicMeshIncrementalBuilder::
280_fillFaceInfo(Integer& nb_face, Integer nb_cell,
Int64Array& faces_infos,
Int64ConstArrayView cells_infos, std::map<Int64,Int64SharedArray>& cell_to_face_connectivity_info)
282 faces_infos.reserve(2*cells_infos.size());
285 ItemTypeMng* itm = m_item_type_mng;
286 Integer cells_infos_index = 0;
288 NodeInFaceSet face_nodes_set;
289 for (Integer i_cell = 0; i_cell < nb_cell; ++i_cell) {
290 Integer item_type_id = (Integer)cells_infos[cells_infos_index++];
291 Int64 current_cell_unique_id = cells_infos[cells_infos_index++];
292 ItemTypeInfo* it = itm->typeFromId(item_type_id);
293 Integer current_cell_nb_node = it->nbLocalNode();
294 Int64ConstArrayView current_cell_node_uids(current_cell_nb_node,&cells_infos[cells_infos_index]);
295 Integer current_cell_nb_face = it->nbLocalFace();
296 for (Integer face_in_cell_index = 0; face_in_cell_index < current_cell_nb_face; ++face_in_cell_index)
298 const ItemTypeInfo::LocalFace& current_face = it->localFace(face_in_cell_index);
299 Integer current_face_nb_node = current_face.nbNode();
300 work_face_orig_nodes.resize(current_face_nb_node);
301 work_face_sorted_nodes.resize(current_face_nb_node);
303 for (Integer node_in_face_index = 0; node_in_face_index < current_face_nb_node; ++node_in_face_index)
305 work_face_orig_nodes[i++] = current_cell_node_uids[current_face.node(node_in_face_index)];
307 mesh_utils::reorderNodesOfFace(work_face_orig_nodes,work_face_sorted_nodes);
309 Int64 current_face_uid = _findFaceUniqueId(work_face_sorted_nodes,face_nodes_set);
310 if (current_face_uid == NULL_ITEM_ID)
313 faces_infos.add(current_face.typeId());
314 faces_infos.add(current_face_uid);
315 faces_infos.addRange(work_face_sorted_nodes);
316 _addFaceNodes(face_nodes_set,work_face_sorted_nodes,current_face_uid);
319 cell_to_face_connectivity_info[current_cell_unique_id].add(current_face_uid);
321 cells_infos_index += current_cell_nb_node;
327void DynamicMeshIncrementalBuilder::
328_fillEdgeInfo(Integer& nb_edge, Integer nb_face,
Int64Array& edges_infos,
331 edges_infos.reserve(2*faces_infos.size());
332 ItemTypeMng* itm = m_item_type_mng;
335 for (Integer i_face = 0; i_face < nb_face; ++i_face) {
338 ItemTypeInfo* it = itm->typeFromId(item_type_id);
339 Integer current_face_nb_node = it->nbLocalNode();
340 Int64ConstArrayView current_face_node_uids(current_face_nb_node,&faces_infos[faces_infos_index]);
341 Integer current_face_nb_edge = it->nbLocalEdge();
342 for (Integer edge_in_face_index = 0; edge_in_face_index < current_face_nb_edge; ++edge_in_face_index)
344 const ItemTypeInfo::LocalEdge& current_edge = it->localEdge(edge_in_face_index);
345 Int64 first_node = current_face_node_uids[current_edge.beginNode()];
346 Int64 second_node = current_face_node_uids[current_edge.endNode()];
347 if (first_node > second_node) std::swap(first_node,second_node);
348 auto edge_it = edge_uid_map.insert(std::make_pair(std::make_pair(first_node,second_node),
m_edge_uid_pool));
352 edges_infos.add(first_node);
353 edges_infos.add(second_node);
358 faces_infos_index += current_face_nb_node;
364void DynamicMeshIncrementalBuilder::
367 nodes_infos.reserve(faces_infos.size());
369 std::set<Int64> nodes_set;
370 ItemTypeMng* itm = m_item_type_mng;
371 for (Integer i_face = 0; i_face < nb_face; ++i_face) {
373 Integer current_face_nb_node = itm->typeFromId(type_id)->nbLocalNode();
375 for (
auto node_uid : faces_infos.subConstView(faces_infos_index,current_face_nb_node)) {
376 nodes_set.insert(node_uid);
378 faces_infos_index+=current_face_nb_node;
381 for (
auto node_uid : nodes_set) {
382 nodes_infos.add(node_uid);
388void DynamicMeshIncrementalBuilder::
391 nodes_infos.reserve(2*edges_infos.size());
393 std::set<Int64> nodes_set;
394 for (Integer i_edge = 0; i_edge < nb_edge; ++i_edge) {
396 nodes_set.insert(edges_infos[edges_infos_index++]);
397 nodes_set.insert(edges_infos[edges_infos_index++]);
400 for (
auto node_uid : nodes_set) {
401 nodes_infos.add(node_uid);
406void DynamicMeshIncrementalBuilder::
408 const std::map<Int64,Int64SharedArray>& cell_to_face_connectivity_info,
const std::map<std::pair<Int64,Int64>,
Int64>& edge_uid_map)
410 Integer cell_infos2_size_approx = 1 + 3 * (cells_infos.size()+ 2*nb_cell);
411 cell_infos2.reserve(cell_infos2_size_approx);
412 ItemTypeMng* itm = m_item_type_mng;
414 Integer nb_connected_families = hasEdge() ? 3 : 2;
415 cell_infos2.add(nb_connected_families);
416 for (Integer i_cell = 0; i_cell < nb_cell; ++i_cell) {
418 cell_infos2.add(cells_infos[cells_infos_index++]);
419 Int64 current_cell_uid = cells_infos[cells_infos_index];
420 cell_infos2.add(cells_infos[cells_infos_index++]);
421 ItemTypeInfo* it = itm->typeFromId(item_type_id);
424 Integer current_cell_nb_node = it->nbLocalNode();
425 cell_infos2.add(current_cell_nb_node);
426 Int64ConstArrayView current_cell_node_uids(current_cell_nb_node,&cells_infos[cells_infos_index]);
427 cell_infos2.addRange(current_cell_node_uids);
429 cell_infos2.add(mesh()->faceFamily()->itemKind());
430 Integer current_cell_nb_face = it->nbLocalFace();
431 cell_infos2.add(current_cell_nb_face);
432 Int64ArrayView current_cell_faces = cell_to_face_connectivity_info.find(current_cell_uid)->second.view();
433 if (current_cell_nb_face != current_cell_faces.size())
434 ARCANE_FATAL(
"Incoherent number of faces for cell {0}. Expected {1} found {2}",
435 current_cell_uid,current_cell_nb_face,current_cell_faces.size());
436 cell_infos2.addRange(current_cell_faces);
440 cell_infos2.add(mesh()->edgeFamily()->itemKind());
441 Integer current_cell_nb_edge = it->nbLocalEdge();
442 cell_infos2.add(current_cell_nb_edge);
443 for (
int edge_index = 0; edge_index < current_cell_nb_edge; ++edge_index) {
444 Int64 first_node = current_cell_node_uids[it->localEdge(edge_index).beginNode()];
445 Int64 second_node = current_cell_node_uids[it->localEdge(edge_index).endNode()];
446 if (first_node > second_node) std::swap(first_node,second_node);
447 auto edge_it = edge_uid_map.find(std::make_pair(first_node,second_node));
448 if (edge_it == edge_uid_map.end())
449 ARCANE_FATAL(
"Do not find edge with nodes {0}-{1} in edge uid map. Exiting",
450 current_cell_node_uids[it->localEdge(edge_index).beginNode()],
451 current_cell_node_uids[it->localEdge(edge_index).endNode()]);
452 cell_infos2.add(edge_it->second);
455 cells_infos_index += current_cell_nb_node;
463void DynamicMeshIncrementalBuilder::
467 Integer cell_infos2_size_approx = 1 + 2 * (cells_infos.size()+ 2*nb_cell);
468 cell_infos2.reserve(cell_infos2_size_approx);
470 ItemTypeMng* itm = m_item_type_mng;
475 faces_infos.reserve(2*cells_infos.size());
478 NodeInFaceSet face_nodes_set;
479 std::set<Int64> node_uid_set;
481 for (Integer i_cell = 0; i_cell < nb_cell; ++i_cell) {
484 cell_infos2.add(cells_infos[cells_infos_index++]);
485 cell_infos2.add(cells_infos[cells_infos_index++]);
488 ItemTypeInfo* it = itm->typeFromId(item_type_id);
490 Integer current_cell_nb_node = it->nbLocalNode();
491 cell_infos2.add(current_cell_nb_node);
492 Int64ConstArrayView current_cell_node_uids(current_cell_nb_node,&cells_infos[cells_infos_index]);
493 cell_infos2.addRange(current_cell_node_uids);
494 if (!allow_build_face) node_uid_set.insert(current_cell_node_uids.begin(),current_cell_node_uids.end());
496 cell_infos2.add(mesh()->faceFamily()->itemKind());
497 Integer current_cell_nb_face = it->nbLocalFace();
498 cell_infos2.add(current_cell_nb_face);
499 for (Integer face_in_cell_index = 0; face_in_cell_index < current_cell_nb_face; ++face_in_cell_index)
501 ItemTypeInfo::LocalFace current_face = it->localFace(face_in_cell_index);
502 Integer current_face_nb_node = current_face.nbNode();
503 work_face_orig_nodes.resize(current_face_nb_node);
504 work_face_sorted_nodes.resize(current_face_nb_node);
506 for (Integer node_in_face_index = 0; node_in_face_index < current_face_nb_node; ++node_in_face_index)
508 work_face_orig_nodes[i++] = current_cell_node_uids[current_face.node(node_in_face_index)];
510 mesh_utils::reorderNodesOfFace(work_face_orig_nodes,work_face_sorted_nodes);
512 Int64 current_face_uid = _findFaceUniqueId(work_face_sorted_nodes,face_nodes_set);
513 if (current_face_uid == NULL_ITEM_ID)
516 faces_infos.add(current_face.typeId());
517 faces_infos.add(current_face_uid);
518 faces_infos.addRange(work_face_sorted_nodes);
519 _addFaceNodes(face_nodes_set,work_face_sorted_nodes,current_face_uid);
522 cell_infos2.add(current_face_uid);
524 cells_infos_index += current_cell_nb_node;
526 if (! allow_build_face)
528 node_uids.resize(node_uid_set.size());
530 for (
Int64 node_uid : node_uid_set) node_uids[index++] = node_uid;
536void DynamicMeshIncrementalBuilder::
537_initFaceRelationInfo(ItemData& source_item_relation_data,
const ItemData& target_item_dependencies_data,
Int64ConstArrayView faces_info)
539 _fillFaceRelationInfo(source_item_relation_data,target_item_dependencies_data,faces_info,
true);
545void DynamicMeshIncrementalBuilder::
546_appendFaceRelationInfo(ItemData& source_item_relation_data,
const ItemData& target_item_dependencies_data,
Int64ConstArrayView faces_info)
548 _fillFaceRelationInfo(source_item_relation_data,target_item_dependencies_data,faces_info,
false);
553void DynamicMeshIncrementalBuilder::
554_fillFaceRelationInfo(ItemData& source_item_relation_data,
const ItemData& target_item_dependencies_data,
559 face_uids_and_types.
reserve(2*source_item_relation_data.nbItems());
560 ItemTypeMng* itm = m_item_type_mng;
561 for (Integer face_info_index = 0; face_info_index < faces_info.size();) {
562 face_uids_and_types.add(faces_info[face_info_index+1]);
563 face_uids_and_types.add(faces_info[face_info_index]);
565 face_info_index += (2+itm->typeFromId(type_id)->nbLocalNode());
567 _fillItemRelationInfo(source_item_relation_data,target_item_dependencies_data,face_uids_and_types, is_source_relation_data_empty);
572void DynamicMeshIncrementalBuilder::
573_initEdgeRelationInfo(ItemData& source_item_relation_data,
const ItemData& target_item_dependencies_data,
Int64ConstArrayView edges_info)
575 _fillEdgeRelationInfo(source_item_relation_data,target_item_dependencies_data,edges_info,
true);
581void DynamicMeshIncrementalBuilder::
582_appendEdgeRelationInfo(ItemData& source_item_relation_data,
const ItemData& target_item_dependencies_data,
Int64ConstArrayView edges_info)
584 _fillEdgeRelationInfo(source_item_relation_data,target_item_dependencies_data,edges_info,
false);
590void DynamicMeshIncrementalBuilder::
591_fillEdgeRelationInfo(ItemData& source_item_relation_data,
const ItemData& target_item_dependencies_data,
595 ARCANE_ASSERT((source_item_relation_data.nbItems()*3 == edges_info.size()),(
"source_item_relation_data and edges_info size incoherent. Exiting."));
597 edge_uids_and_types.
reserve(2*source_item_relation_data.nbItems());
598 for (Integer edge_info_index = 0; edge_info_index < edges_info.size();) {
599 edge_uids_and_types.add(edges_info[edge_info_index++]);
600 edge_uids_and_types.add(IT_Line2);
603 _fillItemRelationInfo(source_item_relation_data,target_item_dependencies_data,edge_uids_and_types, is_source_relation_data_empty);
608void DynamicMeshIncrementalBuilder::
609_initNodeRelationInfo(ItemData& source_item_relation_data,
const ItemData& target_item_dependencies_data,
Int64ConstArrayView nodes_info)
611 _fillNodeRelationInfo(source_item_relation_data,target_item_dependencies_data,nodes_info,
true);
617void DynamicMeshIncrementalBuilder::
618_appendNodeRelationInfo(ItemData& source_item_relation_data,
const ItemData& target_item_dependencies_data,
Int64ConstArrayView nodes_info)
620 _fillNodeRelationInfo(source_item_relation_data,target_item_dependencies_data,nodes_info,
false);
625void DynamicMeshIncrementalBuilder::
626_fillNodeRelationInfo(ItemData& source_item_relation_data,
const ItemData& target_item_dependencies_data,
Int64ConstArrayView nodes_info,
bool is_source_relation_data_empty){
628 ARCANE_ASSERT((source_item_relation_data.nbItems() == nodes_info.size()),(
"source_item_relation_data and nodes_info size incoherent. Exiting."));
630 for (Integer node_index = 0; node_index < nodes_info.size(); ++node_index) {
631 node_uids_and_types[2*node_index] = nodes_info[node_index];
632 node_uids_and_types[2*node_index+1] = IT_Vertex;
634 _fillItemRelationInfo(source_item_relation_data,target_item_dependencies_data,node_uids_and_types, is_source_relation_data_empty);
640void DynamicMeshIncrementalBuilder::
641_fillItemRelationInfo(ItemData& source_item_relation_data,
const ItemData& target_item_dependencies_data,
643 bool is_source_item_relation_data_empty)
645 ARCANE_ASSERT((source_item_relation_data.nbItems()*2 == source_item_uids_and_types.size()),
646 (
"source item number incoherent between source_item_relation_data and source_item_uids_and_types. Exiting."));
648 auto & source_relation_info = source_item_relation_data.itemInfos();
649 const auto & target_dependencies_info = target_item_dependencies_data.itemInfos();
650 auto source_family = source_item_relation_data.itemFamily();
651 auto target_family = target_item_dependencies_data.itemFamily();
652 if (! source_family || !target_family)
return;
653 std::map<Int64, Int64SharedArray> source_to_target_uids;
658 for (; target_info_index < target_dependencies_info.size();) {
660 Int64 target_item_uid = target_dependencies_info[target_info_index++];
661 for (Integer family_connected_to_target = 0; family_connected_to_target < nb_families_connected_to_target; ++family_connected_to_target) {
662 Int64 family_connected_to_target_kind = target_dependencies_info[target_info_index++];
663 if (family_connected_to_target_kind != source_family->itemKind()) {
665 target_info_index+= nb_non_read_values;
670 for (Integer source_item_index = 0; source_item_index < nb_source_item_connected_to_target_item; ++source_item_index) {
671 source_to_target_uids[target_dependencies_info[source_item_index+target_info_index]].add(target_item_uid);
673 target_info_index += nb_source_item_connected_to_target_item;
678 if (is_source_item_relation_data_empty) _initEmptyRelationInfo(source_relation_info, source_to_target_uids, source_item_uids_and_types,
679 target_dependencies_info.size(), target_family);
680 else _appendInitializedRelationInfo(source_relation_info, source_to_target_uids, source_item_uids_and_types,
681 target_dependencies_info.size(), target_family);
687void DynamicMeshIncrementalBuilder::
688_initEmptyRelationInfo(
Int64Array& source_relation_info, std::map<Int64, Int64SharedArray>& source_to_target_uids,
Int64ConstArrayView source_item_uids_and_types,
689 Integer approx_relation_size,
690 IItemFamily
const * target_family)
692 if (! source_relation_info.empty()) source_relation_info.clear();
693 source_relation_info.reserve(approx_relation_size);
694 source_relation_info.add(1);
696 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) {
697 Int64 source_item_uid = source_item_uids_and_types[source_item_uids_and_types_index];
698 source_relation_info.add(source_item_uids_and_types[source_item_uids_and_types_index+1]);
699 source_relation_info.add(source_item_uid);
700 source_relation_info.add(target_family->itemKind());
701 auto & connected_items = source_to_target_uids[source_item_uid];
702 source_relation_info.add(connected_items.size());
703 source_relation_info.addRange(connected_items.view());
709void DynamicMeshIncrementalBuilder::
710_appendInitializedRelationInfo(
Int64Array& source_relation_info, std::map<Int64, Int64SharedArray>& source_to_target_uids,
Int64ConstArrayView source_item_uids_and_types,
711 Integer approx_relation_size,
712 IItemFamily
const * target_family)
716 source_relation_info_wrk_copy.
reserve(source_relation_info.size()+approx_relation_size);
717 std::set<Int64> treated_items;
718 Integer source_relation_info_index = 0;
720 source_relation_info_wrk_copy.add(nb_connected_family+1);
721 for(; source_relation_info_index < source_relation_info.size() ;){
722 source_relation_info_wrk_copy.add(source_relation_info[source_relation_info_index++]);
723 Int64 source_item_uid = source_relation_info[source_relation_info_index++];
724 source_relation_info_wrk_copy.add(source_item_uid);
725 treated_items.insert(source_item_uid);
726 for (Integer connected_family_index = 0; connected_family_index < nb_connected_family; ++connected_family_index) {
727 source_relation_info_wrk_copy.add(source_relation_info[source_relation_info_index++]);
729 source_relation_info_wrk_copy.add(nb_connected_elements);
730 source_relation_info_wrk_copy.addRange(source_relation_info.subConstView(source_relation_info_index,nb_connected_elements));
731 source_relation_info_index += nb_connected_elements;
734 source_relation_info_wrk_copy.add(target_family->itemKind());
735 const auto& connected_items = source_to_target_uids[source_item_uid];
736 source_relation_info_wrk_copy.add(connected_items.size());
737 source_relation_info_wrk_copy.addRange(connected_items);
740 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) {
741 Int64 source_item_uid = source_item_uids_and_types[source_item_uids_and_types_index];
742 if (treated_items.find(source_item_uid) == treated_items.end()){
743 source_relation_info_wrk_copy.add(source_item_uids_and_types[source_item_uids_and_types_index+1]);
744 source_relation_info_wrk_copy.add(source_item_uid);
745 source_relation_info_wrk_copy.add(target_family->itemKind());
746 const auto& connected_items = source_to_target_uids[source_item_uid];
747 source_relation_info_wrk_copy.add(connected_items.size());
748 source_relation_info_wrk_copy.addRange(connected_items);
750 for (Integer connected_family_index = 0; connected_family_index < nb_connected_family; ++connected_family_index) {
751 source_relation_info_wrk_copy.add(0);
752 source_relation_info_wrk_copy.add(0);
757 source_relation_info.resize(source_relation_info_wrk_copy.size());
758 std::copy(source_relation_info_wrk_copy.begin(), source_relation_info_wrk_copy.end(), source_relation_info.begin());
764Int64 DynamicMeshIncrementalBuilder::
765_findFaceUniqueId(
Int64ConstArrayView work_face_sorted_nodes, NodeInFaceSet& face_nodes_set)
770 return _findFaceInFaceNodesSet(face_nodes_set,index,work_face_sorted_nodes,NodeInFacePtr(NULL_ITEM_ID));
775Int64 DynamicMeshIncrementalBuilder::
776_findFaceInFaceNodesSet(
const NodeInFaceSet& face_nodes_set,Integer index,
Int64ConstArrayView face_nodes, NodeInFacePtr node)
778 if (index < face_nodes.size())
780 auto found_node = std::find(face_nodes_set.begin(),face_nodes_set.end(),NodeInFacePtr(face_nodes[index]));
781 if (found_node == face_nodes_set.end())
return node->faceUid();
782 else return _findFaceInFaceNodesSet((*found_node)->nextNodeSet(),++index,face_nodes,*found_node);
784 else return node->faceUid();
789void DynamicMeshIncrementalBuilder::
794 _addFaceInFaceNodesSet(face_nodes_set, index,face_nodes, NodeInFacePtr(NULL_ITEM_ID), face_uid);
799void DynamicMeshIncrementalBuilder::
800_addFaceInFaceNodesSet(NodeInFaceSet& face_nodes_set,Integer index,
Int64ConstArrayView face_nodes, NodeInFacePtr node,
Int64 face_uid)
802 if (index < face_nodes.size())
805 auto next_node = _insertNode(face_nodes_set,face_nodes[index]);
808 _addFaceInFaceNodesSet(next_node->nextNodeSet(),++index,face_nodes,next_node,face_uid);
814 node->setFaceUid(face_uid);
819DynamicMeshIncrementalBuilder::NodeInFacePtr&
820DynamicMeshIncrementalBuilder::_insertNode(NodeInFaceSet& face_nodes_set,
Int64 inserted_node_uid)
822 NodeInFacePtr new_node(inserted_node_uid);
823 auto found_node = std::find(face_nodes_set.begin(),face_nodes_set.end(),new_node);
824 if (found_node == face_nodes_set.end()) {
825 face_nodes_set.push_back(std::move(new_node));
826 return face_nodes_set.back();
828 else return *found_node;
868 debug() <<
"[DynamicMeshIncrementalBuilder::addHChildrenCells] ADD CELLS mesh=" <<
m_mesh->
name() <<
" nb_cell=" <<
nb_cell;
873 "return array 'cells' has to have same size as number of cells");
906 debug() <<
"[DynamicMeshIncrementalBuilder::addHChildrenCells] done";
943 "return array 'nodes' has to have same size as number of nodes");
967 "return array 'nodes' has to have same size as number of nodes");
981void DynamicMeshIncrementalBuilder::
1019 _addItemsOrRelations(
item_info_list,IItemFamilyNetwork::InverseTopologicalOrder);
1034void DynamicMeshIncrementalBuilder::
1043void DynamicMeshIncrementalBuilder::
1044_addItemsOrRelations(ItemDataList& info_list, IItemFamilyNetwork::eSchedulingOrder family_graph_traversal_order)
1047 if (info_list.size() == 0)
return;
1049 ItemData i_infos = info_list[family->itemKind()];
1052 family_graph_traversal_order);
1069 "return array containing item lids has to have be of size number of items");
1136 "return array 'faces' has to have same size as number of faces");
1176 "return array 'faces' has to have same size as number of faces");
1213void DynamicMeshIncrementalBuilder::
1220 "return array 'faces' has to have same size as number of faces");
1267void DynamicMeshIncrementalBuilder::
1270 ItemTypeMng* itm = m_item_type_mng;
1271 Integer nb_connected_family = hasEdge() ? 2 : 1;
1272 Integer face_infos2_size_approx = 1 + 2 * (faces_infos.size()+ 2*nb_face);
1273 face_infos2.reserve(face_infos2_size_approx);
1276 Integer faces_infos_index = 0;
1278 std::set<Int64> node_uids_set;
1279 face_infos2.add(nb_connected_family);
1281 for(Integer i_face=0; i_face<nb_face; ++i_face ){
1282 Integer current_face_type = (Integer)faces_infos[faces_infos_index++];
1283 Integer current_face_uid = (Integer)faces_infos[faces_infos_index++];
1284 face_infos2.add(current_face_type);
1285 face_infos2.add(current_face_uid);
1288 ItemTypeInfo* it = itm->typeFromId(current_face_type);
1289 Integer current_face_nb_node = it->nbLocalNode();
1290 face_infos2.add(current_face_nb_node);
1292 Int64ConstArrayView current_face_node_uids(current_face_nb_node,&faces_infos[faces_infos_index]);
1293 work_face_orig_nodes.resize(current_face_nb_node);
1294 work_face_sorted_nodes.resize(current_face_nb_node);
1295 work_face_orig_nodes.copy(current_face_node_uids);
1296 mesh_utils::reorderNodesOfFace(work_face_orig_nodes,work_face_sorted_nodes);
1297 face_infos2.addRange(work_face_sorted_nodes);
1298 faces_infos_index += current_face_nb_node;
1301 face_infos2.add(mesh()->edgeFamily()->itemKind());
1302 face_infos2.add(it->nbLocalEdge());
1303 for (
int edge_index = 0; edge_index < it->nbLocalEdge(); ++edge_index) {
1304 Int64 first_node = work_face_sorted_nodes[it->localEdge(edge_index).beginNode()];
1305 Int64 second_node = work_face_sorted_nodes[it->localEdge(edge_index).endNode()];
1306 if (first_node > second_node) std::swap(first_node,second_node);
1307 auto edge_it = edge_uid_map.find(std::make_pair(first_node,second_node));
1308 if (edge_it == edge_uid_map.end())
1309 ARCANE_FATAL(
"Do not find edge with nodes {0}-{1} in edge uid map. Exiting",
1310 work_face_sorted_nodes[it->localEdge(edge_index).beginNode()],
1311 work_face_sorted_nodes[it->localEdge(edge_index).endNode()]);
1312 face_infos2.add(edge_it->second);
1320void DynamicMeshIncrementalBuilder::
1323 ItemTypeMng* itm = m_item_type_mng;
1324 Integer faces_infos_index = 0;
1325 Integer face_infos2_index = 0;
1326 face_infos2[face_infos2_index++] = 1;
1329 std::set<Int64> node_uids_set;
1331 for(Integer i_face=0; i_face<nb_face; ++i_face ){
1334 face_infos2[face_infos2_index++] = faces_infos[faces_infos_index++];
1335 face_infos2[face_infos2_index++] = faces_infos[faces_infos_index++];
1338 ItemTypeInfo* it = itm->typeFromId(item_type_id);
1339 Integer current_face_nb_node = it->nbLocalNode();
1340 face_infos2[face_infos2_index++] = current_face_nb_node;
1341 Int64ConstArrayView current_face_node_uids(current_face_nb_node,&faces_infos[faces_infos_index]);
1342 work_face_orig_nodes.resize(current_face_nb_node);
1343 work_face_sorted_nodes.resize(current_face_nb_node);
1344 work_face_orig_nodes.copy(current_face_node_uids);
1345 mesh_utils::reorderNodesOfFace(work_face_orig_nodes,work_face_sorted_nodes);
1346 face_infos2.subView(face_infos2_index,current_face_nb_node).copy(work_face_sorted_nodes);
1347 faces_infos_index += current_face_nb_node;
1348 face_infos2_index += current_face_nb_node;
1349 node_uids_set.insert(current_face_node_uids.begin(),current_face_node_uids.end());
1351 node_uids.resize(node_uids_set.size());
1353 for (
Int64 node_uid : node_uids_set) node_uids[index++] = node_uid;
1373 "return array 'edges' has to have same size as number of edges");
1408 "return array 'edges' has to have same size as number of edges");
1433void DynamicMeshIncrementalBuilder::
1440 "return array 'edges' has to have same size as number of edges");
1472void DynamicMeshIncrementalBuilder::
1492 node_uids.resize(node_uids_set.size());
1494 for (
Int64 node_uid : node_uids_set) node_uids[index++] = node_uid;
1497void DynamicMeshIncrementalBuilder::
1500 Integer edges_infos_index = 0;
1501 Integer edges_new_infos_index = 0;
1504 edges_new_infos[edges_new_infos_index++] = 1;
1506 for(Integer i_edge=0; i_edge<nb_edge; ++i_edge ){
1507 edges_new_infos[edges_new_infos_index++] = IT_Line2;
1508 edges_new_infos[edges_new_infos_index++] = edges_infos[edges_infos_index++];
1510 edges_new_infos[edges_new_infos_index++] = 2;
1511 Int64 first_node = edges_infos[edges_infos_index++];
1512 Int64 second_node = edges_infos[edges_infos_index++];
1513 if (first_node > second_node) std::swap(first_node,second_node);
1514 edges_new_infos[edges_new_infos_index++] = first_node;
1515 edges_new_infos[edges_new_infos_index++] = second_node;
1522void DynamicMeshIncrementalBuilder::
1527 ItemInternalMap& faces_map =
m_mesh->facesMap();
1529 faces_map.eachItem([&](Item face) {
1530 if (face.uniqueId() > max_uid)
1531 max_uid = face.uniqueId();
1536 ItemInternalMap& edges_map =
m_mesh->edgesMap();
1538 edges_map.eachItem([&](Item edge) {
1539 if (edge.uniqueId() > max_uid)
1540 max_uid = edge.uniqueId();
1552void DynamicMeshIncrementalBuilder::
1555 info() <<
"-- Mesh information (Arcane2):";
1560 info() <<
"-- Graph information (Arcane2):";
1566void DynamicMeshIncrementalBuilder::
1567printStats(
Int32 level)
1569 info(level) <<
"-- -- Statistics";
1578 info(level) <<
"--";
1607 if (!m_face_unique_id_builder)
1609 m_face_unique_id_builder->computeFacesUniqueIds();
1612 if (!m_edge_unique_id_builder)
1614 m_edge_unique_id_builder->computeEdgesUniqueIds();
1621void DynamicMeshIncrementalBuilder::
1624 debug() <<
"Add one ghost layer";
1637 debug() <<
"Add one ghost layer";
1646void DynamicMeshIncrementalBuilder::
1690 if (family->itemKind()!=
IK_DoF || family->name()==GraphDoFs::linkFamilyName())
1692 info() <<
"Remove Items for family : "<<family->name() ;
1693 family->removeNeedRemoveMarkedItems() ;
1732#ifdef ARCANE_DEBUG_DYNAMIC_MESH
1748 }, IItemFamilyNetwork::InverseTopologicalOrder);
1749 for (
auto family :
m_mesh->itemFamilies()) {
1763 if (connectivity == 0)
1766 ARCANE_FATAL(
"Connectivity already set: cannot redefine it");
1768 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).
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.
ItemInternal * addFace(Int64 a_face_uid, Int64ConstArrayView a_node_list, Integer a_type)
Ajoute une face.
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(Int64 a_face_uid, Int64ConstArrayView a_node_list, Integer a_type)
Ajoute une face.
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.
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.