Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
IndexedIncrementalItemConnectivityMng.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 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/* IndexedIncrementalItemConnectivityMng.cc (C) 2000-2024 */
9/* */
10/* Manager for 'IIndexedIncrementalItemConnectivity'. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/mesh/IndexedIncrementalItemConnectivityMng.h"
15
16#include "arcane/core/IndexedItemConnectivityView.h"
17#include "arcane/core/IIndexedIncrementalItemConnectivity.h"
18#include "arcane/mesh/IncrementalItemConnectivity.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane::mesh
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
29class IndexedIncrementalItemConnectivity
31{
32 public:
33
34 explicit IndexedIncrementalItemConnectivity(IncrementalItemConnectivity* x)
35 : m_true_connectivity(x)
36 {}
37
38 public:
39
41 {
42 return m_true_connectivity;
43 }
45 {
46 return m_true_connectivity->connectivityView();
47 }
48
49 public:
50
51 IncrementalItemConnectivity* m_true_connectivity;
52};
53
54/*---------------------------------------------------------------------------*/
55/*---------------------------------------------------------------------------*/
56
57IndexedIncrementalItemConnectivityMng::
58IndexedIncrementalItemConnectivityMng(ITraceMng* tm)
59: TraceAccessor(tm)
60{
61}
62
63/*---------------------------------------------------------------------------*/
64/*---------------------------------------------------------------------------*/
65
67findOrCreateConnectivity(IItemFamily* source, IItemFamily* target, const String& name)
68{
72 auto x = m_connectivity_map.find(name);
73 if (x != m_connectivity_map.end()) {
74 connectivity = x->second;
75 IIncrementalItemConnectivity* c2 = connectivity->connectivity();
76 IItemFamily* old_source = c2->sourceFamily();
77 IItemFamily* old_target = c2->targetFamily();
78 if (old_source != source)
79 ARCANE_FATAL("A connectivity with the same name '{0}' already exists but with a different source"
80 " old_source={1} new_source={2}",
81 name, old_source->name(), source->name());
82 if (old_target != target)
83 ARCANE_FATAL("A connectivity with the same name '{0}' already exists but with a different target"
84 " old_target={1} new_target={2}",
85 name, old_target->name(), target->name());
86 }
87 else {
88 // The created connectivities are automatically deallocated by the families
89 auto* true_connectivity = new mesh::IncrementalItemConnectivity(source, target, name);
91 m_connectivity_map.insert(std::make_pair(name, connectivity));
92
93 // Adds existing entities to the connectivity.
94 true_connectivity->_internalNotifySourceItemsAdded(source->allItems().view().localIds());
95 }
96 return connectivity;
97}
98
99/*---------------------------------------------------------------------------*/
100/*---------------------------------------------------------------------------*/
101
103findConnectivity(const String& name)
104{
105 auto x = m_connectivity_map.find(name);
106 if (x != m_connectivity_map.end())
107 return x->second;
108 ARCANE_FATAL("No connectivity with name '{0}'", name);
109}
110
111/*---------------------------------------------------------------------------*/
112/*---------------------------------------------------------------------------*/
113
114} // namespace Arcane::mesh
115
116/*---------------------------------------------------------------------------*/
117/*---------------------------------------------------------------------------*/
#define ARCANE_CHECK_POINTER(ptr)
Macro returning the pointer ptr if it is not null or throwing an exception if it is null.
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
Interface for managing an incremental connectivity.
virtual IItemFamily * targetFamily() const =0
Target family.
virtual IItemFamily * sourceFamily() const =0
Source family.
Interface to manage incremental connectivity.
Interface of an entity family.
Definition IItemFamily.h:83
virtual String name() const =0
Family name.
Base class for a view on unstructured connectivity.
Reference to an instance.
Ref< IIndexedIncrementalItemConnectivity > findConnectivity(const String &name) override
Searches for or creates a connectivity.
Ref< IIndexedIncrementalItemConnectivity > findOrCreateConnectivity(IItemFamily *source, IItemFamily *target, const String &name) override
Searches for or creates a connectivity.
IIncrementalItemConnectivity * connectivity() override
Interface of the associated connectivity.
IndexedItemConnectivityViewBase view() const override
View of the connectivity.
auto makeRef(InstanceType *t) -> Ref< InstanceType >
Creates a reference on a pointer.