Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
GraphDoFs.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* GraphDoFs.cc (C) 2000-2024 */
9/* */
10/*---------------------------------------------------------------------------*/
11
12#include "arcane/mesh/DualUniqueIdMng.h"
13#include "arcane/mesh/GraphDoFs.h"
14
15#include "arcane/utils/ArgumentException.h"
16
17#include "arcane/IMesh.h"
18#include "arcane/IItemConnectivity.h"
19#include "arcane/IIncrementalItemConnectivity.h"
20#include "arcane/MathUtils.h"
21
22#include "arcane/mesh/ConnectivityNewWithDependenciesTypes.h"
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26namespace Arcane::mesh
27{
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32GraphIncrementalConnectivity::
33GraphIncrementalConnectivity(GraphDoFs* graph)
34: m_dualnode_family(graph->dualNodeFamily())
35, m_link_family(graph->linkFamily())
36, m_dualnode_connectivity(graph->m_dualnodes_incremental_connectivity)
37, m_link_connectivity(graph->m_links_incremental_connectivity)
38, m_dualitem_connectivities(graph->m_incremental_connectivities)
39, m_dualnode_to_connectivity_index(graph->m_dual_node_to_connectivity_index)
40{
41}
42
43/*---------------------------------------------------------------------------*/
44/*---------------------------------------------------------------------------*/
45
46GraphDoFs::
47GraphDoFs(IMesh* mesh, String particle_family_name)
48: TraceAccessor(mesh->traceMng())
49, m_mesh(mesh)
50, m_dof_mng(mesh)
51, m_connectivity_mng(m_dof_mng.connectivityMng())
52, m_dual_node_family(m_dof_mng.family(GraphDoFs::dualNodeFamilyName(), true))
53, m_link_family(m_dof_mng.family(GraphDoFs::linkFamilyName(), true))
54, m_update_sync_info(false)
55, m_particle_family_name(particle_family_name)
56{
57}
58
59void GraphDoFs::
60_allocateGraph()
61{
62 if (m_graph_allocated)
63 return;
64
65 auto connectivity_index = 0;
66 m_connectivity_indexes_per_type.resize(NB_BASIC_ITEM_TYPE, -1);
67 m_connectivity_indexes_per_type[IT_DualNode] = connectivity_index++;
68 m_connectivity_indexes_per_type[IT_DualEdge] = connectivity_index++;
69 m_connectivity_indexes_per_type[IT_DualFace] = connectivity_index++;
70 m_connectivity_indexes_per_type[IT_DualCell] = connectivity_index++;
71 m_connectivity_indexes_per_type[IT_DualParticle] = connectivity_index++;
72
73 m_item_family_network = m_mesh->itemFamilyNetwork();
74 if (m_item_family_network == nullptr)
75 ARCANE_FATAL("ARCANE_GRAPH_CONNECTIVITY_POLICY need to be activated");
76
77 m_graph_id = m_item_family_network->registerConnectedGraph(this);
78
79 m_dualnodes_incremental_connectivity =
80 new IncrementalItemConnectivity(dualNodeFamily(),
81 linkFamily(),
82 mesh::connectivityName(dualNodeFamily(), linkFamily()));
83
84 m_connectivity_mng->registerConnectivity(m_dualnodes_incremental_connectivity);
85
86 if (m_item_family_network)
87 m_item_family_network->addRelation(dualNodeFamily(), linkFamily(), m_dualnodes_incremental_connectivity);
88
89 m_links_incremental_connectivity =
90 new IncrementalItemConnectivity(linkFamily(),
91 dualNodeFamily(),
92 mesh::connectivityName(linkFamily(), dualNodeFamily()));
93 m_connectivity_mng->registerConnectivity(m_links_incremental_connectivity);
94
95 if (m_item_family_network)
96 //m_item_family_network->addRelation(linkFamily(),dualNodeFamily(),m_links_incremental_connectivity);
97 m_item_family_network->addDependency(linkFamily(), dualNodeFamily(), m_links_incremental_connectivity, false);
98
99 m_incremental_connectivities.resize(NB_DUAL_ITEM_TYPE, nullptr);
100 std::array<int, NB_DUAL_ITEM_TYPE> dual_node_kinds = { IT_DualCell, IT_DualFace, IT_DualEdge, IT_DualNode, IT_DualParticle };
101 for (auto dual_node_kind : dual_node_kinds) {
102 IItemFamily* dual_item_family = _dualItemFamily(dualItemKind(dual_node_kind));
103 if (dual_item_family) {
104 auto dof2dual_incremental_connectivity =
105 new IncrementalItemConnectivity(dualNodeFamily(),
106 dual_item_family,
107 mesh::connectivityName(dualNodeFamily(), dual_item_family));
108
109 m_connectivity_mng->registerConnectivity(dof2dual_incremental_connectivity);
110 m_incremental_connectivities[_connectivityIndex(dual_node_kind)] = dof2dual_incremental_connectivity;
111 if (m_item_family_network)
112 m_item_family_network->addDependency(dualNodeFamily(), dual_item_family, dof2dual_incremental_connectivity, false);
113 }
114 }
115 m_graph_connectivity.reset(new GraphIncrementalConnectivity(dualNodeFamily(),
116 linkFamily(),
117 m_dualnodes_incremental_connectivity,
118 m_links_incremental_connectivity,
119 m_incremental_connectivities,
120 m_dual_node_to_connectivity_index));
121
122 for (auto& obs : m_connectivity_observer)
123 if (obs.get())
124 obs->notifyUpdateConnectivity();
125
126 m_update_sync_info = false;
127 m_graph_allocated = true;
128}
129
130/*---------------------------------------------------------------------------*/
131/*---------------------------------------------------------------------------*/
132
133void GraphDoFs::
134addLinks(Integer nb_link,
137{
138 //info() << "GRAPHDOF : ADD LINKS";
139 Trace::Setter mci(traceMng(), _className());
140 if (!m_graph_allocated)
141 _allocateGraph();
142
143 mesh::DoFFamily& link_family = m_dof_mng.family(GraphDoFs::linkFamilyName());
144 mesh::DoFFamily& dual_node_family = m_dof_mng.family(GraphDoFs::dualNodeFamilyName());
145
146 // Extract link infos
148 link_uids.reserve(nb_link);
150 for (auto links_infos_index = 0; links_infos_index < links_infos.size();) {
152 link_uids.add(link_uid);
156 }
157
160 link_family.endUpdate();
161
162 // resize connectivity
163 // fill connectivity
165 dual_node_family.itemsUniqueIdToLocalId(
166 connected_dual_nodes_lids.view(), connected_dual_node_uids.constView(), true);
167
168 auto link_index = 0;
170 m_links_incremental_connectivity->notifySourceItemAdded(ItemLocalId(*inewlink));
172 m_links_incremental_connectivity->addConnectedItem(ItemLocalId(*inewlink), ItemLocalId(lid));
173 m_dualnodes_incremental_connectivity->addConnectedItem(ItemLocalId(lid), ItemLocalId(*inewlink));
174 }
176 }
177 m_connectivity_mng->setUpToDate(m_links_incremental_connectivity);
178 m_connectivity_mng->setUpToDate(m_dualnodes_incremental_connectivity);
179
180 m_update_sync_info = false;
181}
182
183/*---------------------------------------------------------------------------*/
184/*---------------------------------------------------------------------------*/
185
186void GraphDoFs::
187addDualNodes(Integer graph_nb_dual_node,
188 Integer dual_node_kind,
190{
191
192 Trace::Setter mci(traceMng(), _className());
193 if (!m_graph_allocated)
194 _allocateGraph();
195
196 // Size m_connecitivities if not yet done
197
201 for (auto infos_index = 0; infos_index < dual_nodes_infos.size();) {
204 }
205
207 auto& dual_node_family = m_dof_mng.family(GraphDoFs::dualNodeFamilyName());
209 dual_node_family.endUpdate();
210
211 IItemFamily* dual_item_family = _dualItemFamily(dualItemKind(dual_node_kind));
212
213 auto incremental_dual_item_connectivity = m_incremental_connectivities[_connectivityIndex(dual_node_kind)];
214 if (incremental_dual_item_connectivity == nullptr) {
216 new IncrementalItemConnectivity(dualNodeFamily(),
218 mesh::connectivityName(dualNodeFamily(), dual_item_family));
219
220 m_connectivity_mng->registerConnectivity(incremental_dual_item_connectivity);
221 m_incremental_connectivities[_connectivityIndex(dual_node_kind)] = incremental_dual_item_connectivity;
222 if (m_item_family_network)
223 m_item_family_network->addDependency(dualNodeFamily(), dual_item_family, incremental_dual_item_connectivity, false);
224 }
226 dual_item_family->itemsUniqueIdToLocalId(dual_item_lids, dual_item_uids);
227
231 }
232 m_connectivity_mng->setUpToDate(incremental_dual_item_connectivity);
233
234 m_update_sync_info = false;
235 //m_dual_node_to_connectivity_index.resize(&dual_node_family, _connectivityIndex(dual_node_kind));
236}
237
238void GraphDoFs::
239addDualNodes(Integer graph_nb_dual_node,
241{
242
243 Trace::Setter mci(traceMng(), _className());
244 if (!m_graph_allocated)
245 _allocateGraph();
246
247 // Size m_connecitivities if not yet done
248 bool is_parallel = m_mesh->parallelMng()->isParallel();
249 Integer domain_rank = m_mesh->parallelMng()->commRank();
250
251 std::map<Int64, std::pair<Int64UniqueArray, Int64UniqueArray>> dual_info_per_kind;
252 for (auto infos_index = 0; infos_index < dual_nodes_infos.size();) {
255 auto& dual_node_uids = info.first;
256 auto& dual_item_uids = info.second;
257 if (dual_node_uids.size() == 0) {
260 }
263 }
264
265 for (Integer index = 0; index < NB_DUAL_ITEM_TYPE; ++index) {
266 Integer dual_node_kind = m_dualnode_kinds[index];
268 auto& dual_node_uids = info.first;
269 auto& dual_item_uids = info.second;
270
271 auto& dual_node_family = m_dof_mng.family(GraphDoFs::dualNodeFamilyName());
273 if (is_parallel) {
274 IItemFamily* dual_item_family = _dualItemFamily(dualItemKind(dual_node_kind));
275 if (dual_item_family) {
277 dual_item_family->itemsUniqueIdToLocalId(dual_item_lids, dual_item_uids);
279
282
283 Integer local_size = 0;
284 for (auto const& item : dual_item_view)
285 if (item.owner() == domain_rank)
286 ++local_size;
289
290 Integer ghost_size = dual_node_uids.size() - local_size;
297
298 Integer icount = 0;
299 for (auto const& item : dual_item_view) {
300 if (item.owner() == domain_rank) {
302 }
303 else {
305 ghost_dual_node_owner.add(item.owner());
306 }
307 ++icount;
308 }
309
312 dual_node_family.endUpdate();
313
314 icount = 0;
315 Integer local_icount = 0;
316 Integer ghost_icount = 0;
317 for (auto const& item : dual_item_view) {
318 if (item.owner() == domain_rank)
320 else
322 ++icount;
323 }
324 }
325 }
326 else {
328 dual_node_family.endUpdate();
329 }
330
331 IItemFamily* dual_item_family = _dualItemFamily(dualItemKind(dual_node_kind));
332 if (dual_item_family) {
333
334 auto incremental_dual_item_connectivity = m_incremental_connectivities[index];
335 if (incremental_dual_item_connectivity == nullptr) {
337 new IncrementalItemConnectivity(dualNodeFamily(),
339 mesh::connectivityName(dualNodeFamily(), dual_item_family));
340
341 m_connectivity_mng->registerConnectivity(incremental_dual_item_connectivity);
342 m_incremental_connectivities[index] = incremental_dual_item_connectivity;
343 if (m_item_family_network)
344 m_item_family_network->addDependency(dualNodeFamily(), dual_item_family, incremental_dual_item_connectivity, false);
345 }
347 dual_item_family->itemsUniqueIdToLocalId(dual_item_lids, dual_item_uids);
348
352 }
353
354 //m_dual_node_to_connectivity_index.resize(&dual_node_family, _connectivityIndex(dual_node_kind));
355
356 m_connectivity_mng->setUpToDate(incremental_dual_item_connectivity);
357 }
358 }
359
360 m_update_sync_info = false;
361}
362
363/*---------------------------------------------------------------------------*/
364/*---------------------------------------------------------------------------*/
365
366void GraphDoFs::
368{
369 Trace::Setter mci(traceMng(), _className());
370 //m_dual_node_family.removeItems(dual_node_local_ids);
371 m_dof_mng.family(GraphDoFs::dualNodeFamilyName()).removeDoFs(dual_node_local_ids);
372 if (dual_node_local_ids.size() > 0)
373 m_update_sync_info = false;
374}
375
376/*---------------------------------------------------------------------------*/
377/*---------------------------------------------------------------------------*/
378
379void GraphDoFs::
381{
382 Trace::Setter mci(traceMng(), _className());
383 //m_link_family.removeItems(link_local_ids);
384 m_dof_mng.family(GraphDoFs::linkFamilyName()).removeDoFs(link_local_ids);
385 if (link_local_ids.size() > 0)
386 m_update_sync_info = false;
387}
388
389void GraphDoFs::
390removeConnectedItemsFromCells(Int32ConstArrayView cell_local_ids)
391{
392 std::set<Int32> cell_to_remove_set;
393 std::set<Int32> node_to_remove_set;
394 std::set<Int32> face_to_remove_set;
395 auto cell_family = m_mesh->cellFamily();
398 cell_to_remove_set.insert(icell->localId());
399 for (auto face : icell->faces()) {
400 if (face.itemBase().isSuppressed())
401 face_to_remove_set.insert(face.localId());
402 }
403 for (auto node : icell->nodes()) {
404 if (node.itemBase().isSuppressed())
405 node_to_remove_set.insert(node.localId());
406 }
407 }
408 {
409 std::set<Int32> link_to_remove_set;
410 ConnectivityItemVector dual_nodes(m_links_incremental_connectivity);
411 //ENUMERATE_DOF (ilink, linkFamily()->allItems())
412 for (auto ilink : linkFamily()->itemsInternal()) {
413 if (ilink->isSuppressed())
414 continue;
415 auto link_lid = ItemLocalId(ilink);
416 bool to_remove = false;
417 ENUMERATE_DOF (idual_node, dual_nodes.connectedItems(link_lid)) {
418 auto dual_item = m_graph_connectivity->dualItem(*idual_node);
419 switch (dual_item.kind()) {
420 case IK_Cell:
421 if (cell_to_remove_set.find(dual_item->localId()) != cell_to_remove_set.end())
422 to_remove = true;
423 break;
424 case IK_Face:
425 if (face_to_remove_set.find(dual_item->localId()) != face_to_remove_set.end())
426 to_remove = true;
427 break;
428 case IK_Node:
429 if (node_to_remove_set.find(dual_item->localId()) != node_to_remove_set.end())
430 to_remove = true;
431 break;
432 case IK_Particle:
433 if (dual_item.itemBase().isSuppressed())
434 to_remove = true;
435 break;
436 }
437 if (to_remove)
438 break;
439 }
440 if (to_remove) {
442 ENUMERATE_DOF (idual_node, dual_nodes.connectedItems(link_lid)) {
443 m_dualnodes_incremental_connectivity->removeConnectedItem(ItemLocalId(idual_node->localId()), link_lid);
444 }
445 }
446 }
447 m_detached_link_lids.resize(link_to_remove_set.size());
448 std::copy(std::begin(link_to_remove_set), std::end(link_to_remove_set), std::begin(m_detached_link_lids));
449
450 removeLinks(m_detached_link_lids);
451 //link_family->endUpdate() ;
452 m_detached_link_lids.clear();
453 }
454 {
455 auto incremental_dof2cell_connectivity = m_incremental_connectivities[m_connectivity_indexes_per_type[IT_DualCell]];
456 auto incremental_dof2face_connectivity = m_incremental_connectivities[m_connectivity_indexes_per_type[IT_DualFace]];
457 auto incremental_dof2node_connectivity = m_incremental_connectivities[m_connectivity_indexes_per_type[IT_DualNode]];
458 auto incremental_dof2part_connectivity = m_incremental_connectivities[m_connectivity_indexes_per_type[IT_DualParticle]];
459
460 //auto source_family = incremental_dof2cell_connectivity->sourceFamily() ;
461 //auto dof_family = dynamic_cast<DoFFamily*>(source_family) ;
462 //auto accessor = incremental_dof2cell_connectivity->connectivityAccessor() ;
463
464 //ENUMERATE_ITEM (idualnode, dualNodeFamily()->allItems())
465 for (auto idualnode : dualNodeFamily()->itemsInternal()) {
466 if (idualnode->isSuppressed())
467 continue;
469 //auto lid = idualnode->localId() ;
470 auto dual_item = m_graph_connectivity->dualItem(DoF(idualnode));
471 switch (dual_item.kind()) {
472 case IK_Cell:
473 if (cell_to_remove_set.find(dual_item.localId()) != cell_to_remove_set.end()) {
474 incremental_dof2cell_connectivity->replaceConnectedItem(dualnode_lid, 0, ItemLocalId(-1));
475 m_detached_dualnode_lids.add(dualnode_lid);
476 //info()<<" REMOVE DUALCELL : "<<idualnode->uniqueId();
477 }
478 break;
479 case IK_Face:
480 if (face_to_remove_set.find(dual_item.localId()) != face_to_remove_set.end()) {
481 incremental_dof2face_connectivity->replaceConnectedItem(dualnode_lid, 0, ItemLocalId(-1));
482 m_detached_dualnode_lids.add(dualnode_lid);
483 //info()<<" REMOVE DUALFACE : "<<idualnode->uniqueId();
484 }
485 break;
486 case IK_Node:
487 if (node_to_remove_set.find(dual_item.localId()) != node_to_remove_set.end()) {
488 incremental_dof2node_connectivity->replaceConnectedItem(dualnode_lid, 0, ItemLocalId(-1));
489 m_detached_dualnode_lids.add(dualnode_lid);
490 //info()<<" REMOVE DUALNODE : "<<idualnode->uniqueId();
491 }
492 break;
493 case IK_Particle:
494 if (dual_item.itemBase().isSuppressed()) {
495 incremental_dof2part_connectivity->replaceConnectedItem(dualnode_lid, 0, ItemLocalId(-1));
496 m_detached_dualnode_lids.add(dualnode_lid);
497 //info()<<" REMOVE DUALPART : "<<idualnode->uniqueId();
498 }
499 }
500 }
501
502 removeDualNodes(m_detached_dualnode_lids);
503 //dualNodeFamily()->endUpdate() ;
504 m_detached_dualnode_lids.clear();
505 }
506 m_update_sync_info = false;
507}
508/*---------------------------------------------------------------------------*/
509/*---------------------------------------------------------------------------*/
510
511bool GraphDoFs::
512isUpdated()
513{
514 if (!m_graph_allocated)
515 return true;
516
517 for (Integer index = 0; index < NB_DUAL_ITEM_TYPE; ++index) {
518 Integer dual_node_kind = m_dualnode_kinds[index];
519 auto dof2dual_incremental_connectivity = m_incremental_connectivities[_connectivityIndex(dual_node_kind)];
520
521 if (dof2dual_incremental_connectivity && !m_connectivity_mng->isUpToDate(dof2dual_incremental_connectivity))
522 m_update_sync_info = false;
523
524 if (!m_connectivity_mng->isUpToDate(m_dualnodes_incremental_connectivity))
525 m_update_sync_info = false;
526
527 if (!m_connectivity_mng->isUpToDate(m_links_incremental_connectivity))
528 m_update_sync_info = false;
529 }
530
531 Integer sync_info = (m_update_sync_info ? 0 : 1);
532 sync_info = m_mesh->parallelMng()->reduce(Parallel::ReduceSum, sync_info);
533 m_update_sync_info = sync_info == 0;
534
535 return m_update_sync_info;
536}
537
538void GraphDoFs::
539endUpdate()
540{
541 if (!m_graph_allocated)
542 return;
543
544 auto dualnode_family = dualNodeFamily();
545 auto link_family = linkFamily();
546
547 DualUniqueIdMng dual_uid_mng(traceMng());
548 for (Integer index = 0; index < NB_DUAL_ITEM_TYPE; ++index) {
549 Integer dual_node_kind = m_dualnode_kinds[index];
550 Arcane::eItemKind dual_item_kind = dualItemKind(dual_node_kind);
551 IItemFamily* dual_item_family = _dualItemFamily(dual_item_kind);
552
553 if (dual_item_family == nullptr || dual_item_family->nbItem() == 0)
554 continue;
555
556 auto dof2dual_incremental_connectivity = m_incremental_connectivities[_connectivityIndex(dual_node_kind)];
557 if (dof2dual_incremental_connectivity && !m_connectivity_mng->isUpToDate(dof2dual_incremental_connectivity)) {
558 //info() << "UPDATE DUALNODE CONNECTIVITY KIND " << index << " " << dual_node_kind << " " << dual_item_kind;
559 // Handle added nodes : create a dof for each own node added
560 Int32ArrayView source_family_added_items_lids;
561 Int32ArrayView source_family_removed_items_lids;
562 m_connectivity_mng->getSourceFamilyModifiedItems(dof2dual_incremental_connectivity, source_family_added_items_lids, source_family_removed_items_lids);
563
564 info() << " NUMBER OF REMOVE ITEMS : " << source_family_removed_items_lids.size();
565 info() << " NUMBER OF ADDED ITEMS : " << source_family_added_items_lids.size();
566 Int64UniqueArray dual_item_uids;
567 dual_item_uids.reserve(source_family_added_items_lids.size());
568 IntegerUniqueArray dual_node_lids;
569 dual_node_lids.reserve(source_family_added_items_lids.size());
570
571 ItemVector source_family_added_items(dualnode_family, source_family_added_items_lids);
572 ENUMERATE_DOF (idof, source_family_added_items) {
573 auto value = dual_uid_mng.uniqueIdOfDualItem(*idof);
574 if (std::get<0>(value) == dual_item_kind) {
575 dual_node_lids.add(idof->localId());
576 dual_item_uids.add(std::get<1>(value));
577 }
578 }
579
580 Int32SharedArray dual_item_lids(dual_item_uids.size());
581 dual_item_family->itemsUniqueIdToLocalId(dual_item_lids, dual_item_uids);
582
583 ENUMERATE_DOF (idual_node, dualnode_family->view(dual_node_lids)) {
584 dof2dual_incremental_connectivity->notifySourceItemAdded(ItemLocalId(*idual_node));
585 dof2dual_incremental_connectivity->addConnectedItem(ItemLocalId(*idual_node), ItemLocalId(dual_item_lids[idual_node.index()]));
586 //info()<<" ADD CONNECTED DUAL ITEM("<<idual_node->localId()<<" "<<idual_node->uniqueId()<<") "<<dual_item_lids[idual_node.index()]<<" "<<dual_item_uids[idual_node.index()] ;
587 }
588
589 // Update connectivity
590 //dof2dual_incremental_connectivity->updateConnectivity(source_family_added_items_lids,dual_lids);
591
592 // Update ghost
593 //synchronizer->synchronize();
594
595 // For test purpose only : try getSourceFamilyModifiedItem (must give back the new dofs created)
596 //Int32ArrayView target_family_added_item_lids, target_family_removed_item_lids;
597 //m_connectivity_mng->getTargetFamilyModifiedItems(dof2dual_incremental_connectivity,target_family_added_item_lids,target_family_removed_item_lids);
598 //_checkTargetFamilyInfo(dualnode_family.view(target_family_added_item_lids),lids);
599
600 //m_dual_node_to_connectivity_index.resize(dualnode_family, _connectivityIndex(dual_node_kind));
601
602 // Finalize connectivity update
603 m_connectivity_mng->setUpToDate(dof2dual_incremental_connectivity);
604 }
605 }
606
607 if (!m_connectivity_mng->isUpToDate(m_links_incremental_connectivity)) {
608
609 //info()<<"UPDATE LINK TO DUALNODE CONNECTIVITY" ;
610 // Handle added nodes : create a dof for each own node added
611 Int32ArrayView source_family_added_items_lids;
612 Int32ArrayView source_family_removed_items_lids;
613 m_connectivity_mng->getSourceFamilyModifiedItems(m_links_incremental_connectivity, source_family_added_items_lids, source_family_removed_items_lids);
614
615 info() << " NUMBER OF REMOVE ITEMS : " << source_family_removed_items_lids.size();
616 info() << " NUMBER OF ADDED ITEMS : " << source_family_added_items_lids.size();
617 ItemVector source_family_added_items(link_family, source_family_added_items_lids);
618
619 Int64UniqueArray link_uids;
620 link_uids.reserve(source_family_added_items_lids.size());
621 Int64UniqueArray dualnode_uids;
622 dualnode_uids.reserve(2 * source_family_added_items_lids.size());
623 ENUMERATE_DOF (ilink, source_family_added_items) {
624 link_uids.add(ilink->uniqueId());
625 auto value = dual_uid_mng.uniqueIdOfPairOfDualItems(*ilink);
626 eItemKind dualitem_kind_1 = std::get<0>(value.first);
627 Int64 dualitem_uid_1 = std::get<1>(value.first);
628 Int64 dof_uid_1 = dual_uid_mng.uniqueIdOf(dualitem_kind_1, dualitem_uid_1);
629 dualnode_uids.add(dof_uid_1);
630
631 eItemKind dualitem_kind_2 = std::get<0>(value.second);
632 Int64 dualitem_uid_2 = std::get<1>(value.second);
633 Int64 dof_uid_2 = dual_uid_mng.uniqueIdOf(dualitem_kind_2, dualitem_uid_2);
634 dualnode_uids.add(dof_uid_2);
635
636 //info()<<" ADDED DOF UID "<<ilink->uniqueId();
637 //info()<<" DUAL KIND 1="<<dualitem_kind_1<<" DUAL UID 1="<<dualitem_uid_1<<" DOF UID 1="<<dof_uid_1;
638 //info()<<" DUAL KIND 2="<<dualitem_kind_2<<" DUAL UID 2="<<dualitem_uid_2<<" DOF UID 2="<<dof_uid_2;
639 }
640
641 Integer nb_dual_nodes_per_link = 2;
642 Int32UniqueArray connected_dual_nodes_lids(dualnode_uids.size());
643
644 dualnode_family->itemsUniqueIdToLocalId(connected_dual_nodes_lids.view(), dualnode_uids);
645
646 Integer link_index = 0;
647 ENUMERATE_DOF (inewlink, source_family_added_items) {
648 m_links_incremental_connectivity->notifySourceItemAdded(ItemLocalId(*inewlink));
649 for (auto lid : connected_dual_nodes_lids.subConstView(link_index, nb_dual_nodes_per_link)) {
650 m_links_incremental_connectivity->addConnectedItem(ItemLocalId(*inewlink), ItemLocalId(lid));
651 m_dualnodes_incremental_connectivity->addConnectedItem(ItemLocalId(lid), ItemLocalId(*inewlink));
652 }
653 link_index += nb_dual_nodes_per_link;
654 }
655
656 // Finalize connectivity update
657 m_connectivity_mng->setUpToDate(m_links_incremental_connectivity);
658 m_connectivity_mng->setUpToDate(m_dualnodes_incremental_connectivity);
659 }
660
661 dualnode_family->computeSynchronizeInfos();
662 link_family->computeSynchronizeInfos();
663 m_update_sync_info = true;
664
665 updateAfterMeshChanged();
666
667 auto* x = new GraphIncrementalConnectivity(dualNodeFamily(),
668 linkFamily(),
669 m_dualnodes_incremental_connectivity,
670 m_links_incremental_connectivity,
671 m_incremental_connectivities,
672 m_dual_node_to_connectivity_index);
673 m_graph_connectivity.reset(x);
674
675 for (auto& obs : m_connectivity_observer) {
676 if (obs.get())
677 obs->notifyUpdateConnectivity();
678 }
679
680 for (auto& obs : m_graph_observer) {
681 if (obs.get())
682 obs->notifyUpdate();
683 }
684
685 //printDualNodes();
686 //printLinks();
687}
688
689/*---------------------------------------------------------------------------*/
690/*---------------------------------------------------------------------------*/
691
692void GraphDoFs::
693updateAfterMeshChanged()
694{
695 if (!m_graph_allocated)
696 return;
697
698 auto& dual_node_family = m_dof_mng.family(GraphDoFs::dualNodeFamilyName());
699 m_dual_node_to_connectivity_index.resize(&dual_node_family, -1);
700 ENUMERATE_DOF (idof, dual_node_family.allItems()) {
701 for (Integer index = 0; index < m_incremental_connectivities.size(); ++index) {
702 auto connectivity = m_incremental_connectivities[index];
703 if (connectivity && (connectivity->maxNbConnectedItem() > 0)) {
704 ConnectivityItemVector accessor(connectivity);
705 if (accessor.connectedItems(*idof).size() > 0) {
706 m_dual_node_to_connectivity_index[*idof] = index;
707 }
708 }
709 }
710 }
711 //endUpdate();
712}
713
714/*---------------------------------------------------------------------------*/
715/*---------------------------------------------------------------------------*/
716
717void GraphDoFs::
718printDualNodes() const
719{
720 ENUMERATE_DOF (idualnode, dualNodeFamily()->allItems()) {
721 info() << "DualNode : lid = " << idualnode->localId();
722 info() << " uid = " << idualnode->uniqueId();
723 info() << " owner = " << idualnode->owner();
724 auto dual_item = m_graph_connectivity->dualItem(*idualnode);
725 info() << " DualItem : lid = " << dual_item.localId();
726 info() << " uid = " << dual_item.uniqueId();
727 info() << " kind = " << dual_item.kind();
728 info() << " owner = " << dual_item.owner();
729 auto links = m_graph_connectivity->links(*idualnode);
730 for (auto const& link : links) {
731 info() << " Connected link : lid = " << link.localId();
732 info() << " uid = " << link.uniqueId();
733 info() << " owner = " << link.owner();
734 }
735 }
736}
737
738/*---------------------------------------------------------------------------*/
739/*---------------------------------------------------------------------------*/
740
741void GraphDoFs::
742printLinks() const
743{
744 ENUMERATE_DOF (ilink, linkFamily()->allItems()) {
745 info() << "Link : LID = " << ilink.localId();
746 info() << " UID = " << ilink->uniqueId();
747 info() << " OWNER = " << ilink->owner();
748 ENUMERATE_DOF (idual_node, m_graph_connectivity->dualNodes(*ilink)) {
749 info() << " Dof : index = " << idual_node.index();
750 info() << " Dof : LID = " << idual_node->localId();
751 info() << " UID = " << idual_node->uniqueId();
752 info() << " OWNER = " << idual_node->owner();
753 auto dual_item = m_graph_connectivity->dualItem(*idual_node);
754 info() << " dual item UID = " << dual_item.uniqueId();
755 info() << " KIND = " << dual_item.kind();
756 info() << " OWNER = " << dual_item.owner();
757 }
758 }
759}
760
761/*---------------------------------------------------------------------------*/
762/*---------------------------------------------------------------------------*/
763
764} // namespace Arcane::mesh
765
766/*---------------------------------------------------------------------------*/
767/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
#define ENUMERATE_DOF(name, group)
Enumérateur generique d'un groupe de degrés de liberté
#define ENUMERATE_CELL(name, group)
Enumérateur générique d'un groupe de mailles.
Gère la récupération des informations de connectivité.
classe degré de liberté.
Definition Item.h:1488
Interface d'une famille d'entités.
Index d'un Item dans une variable.
Definition ItemLocalId.h:40
Vue sur un tableau typé d'entités.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Connectivité incrémentale item->item[].
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.
Positionne une classe de message.
Vecteur 1D de données avec sémantique par valeur (style STL).
UniqueArray< Int64 > Int64UniqueArray
Tableau dynamique à une dimension d'entiers 64 bits.
Definition UtilsTypes.h:513
SharedArray< Int32 > Int32SharedArray
Tableau dynamique à une dimension d'entiers 32 bits.
Definition UtilsTypes.h:547
UniqueArray< Int32 > Int32UniqueArray
Tableau dynamique à une dimension d'entiers 32 bits.
Definition UtilsTypes.h:515
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.
ArrayView< Int32 > Int32ArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.
Definition UtilsTypes.h:611
Int32 Integer
Type représentant un entier.