Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
ItemConnectivitySelector.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 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/* ItemConnectivitySelector.h (C) 2000-2021 */
9/* */
10/* Sélection entre les connectivités historiques et à la demande. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_MESH_ITEMCONNECTIVITYSELECTOR_H
13#define ARCANE_MESH_ITEMCONNECTIVITYSELECTOR_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/String.h"
18#include "arcane/utils/ArrayView.h"
19#include "arcane/utils/TraceAccessor.h"
20#include "arcane/utils/FatalErrorException.h"
21
22#include "arcane/mesh/MeshGlobal.h"
23
24#include "arcane/ItemInternal.h"
25
26#include "arcane/mesh/ConnectivityNewWithDependenciesTypes.h"
27
28#include "arcane/IItemFamilyNetwork.h"
29
30#include <type_traits>
31
32/*---------------------------------------------------------------------------*/
33/*---------------------------------------------------------------------------*/
34
35namespace Arcane
36{
37class IItemFamily;
38class IIncrementalItemConnectivity;
39}
40
41namespace Arcane::mesh
42{
43
44/*---------------------------------------------------------------------------*/
45/*---------------------------------------------------------------------------*/
46
47class ItemFamily;
48
49/*---------------------------------------------------------------------------*/
50/*---------------------------------------------------------------------------*/
54class ARCANE_MESH_EXPORT ItemConnectivitySelector
55: public TraceAccessor
56{
57 public:
58
60 const String& connectivity_name,Integer connectivity_index);
62 {
63 }
64 public:
65
66 virtual void build();
67 ARCCORE_DEPRECATED_2021("This method always return 'nullptr'")
68 virtual IIncrementalItemConnectivity* legacyConnectivity() const { return nullptr; }
69 virtual IIncrementalItemConnectivity* customConnectivity() const =0;
70 ARCCORE_DEPRECATED_2021("This method doesn't do anything")
71 virtual void updateItemConnectivityList(Int32ConstArrayView) const {}
72 virtual void checkValidConnectivityList() const =0;
73 virtual void compactConnectivities() =0;
74
75 public:
76
77 void setPreAllocatedSize(Integer size);
78 Integer preAllocatedSize() const { return m_pre_allocated_size; }
79 Int32 itemConnectivityIndex() const { return m_item_connectivity_index; }
80
81 protected:
82
83 virtual void _createCustomConnectivity(const String& name) =0;
84 virtual void _buildCustomConnectivity() =0;
85
86 protected:
87
88 ItemFamily* m_source_family;
89 IItemFamily* m_target_family;
90 String m_connectivity_name;
91 Integer m_pre_allocated_size;
92 // Numéro dans ItemInternalConnectivityList. (-1) si aucun.
93 Int32 m_item_connectivity_index;
94 ItemInternalConnectivityList* m_item_connectivity_list;
95 bool m_is_built;
96};
97
98/*---------------------------------------------------------------------------*/
99/*---------------------------------------------------------------------------*/
103template<typename ConnectivityIndexType,typename CustomType>
104class ARCANE_MESH_EXPORT ItemConnectivitySelectorT
106{
107 public:
108
110 const String& connectivity_name)
111 : ItemConnectivitySelector(source_family,target_family,connectivity_name,ConnectivityIndexType::connectivityIndex())
112 , m_custom_connectivity(nullptr)
113 {
114 }
116 {
117 // NOTE: les connectivités sont détuites par les familles.
118 }
119
120 public:
121
122 IIncrementalItemConnectivity* customConnectivity() const override
123 {
124 return trueCustomConnectivity();
125 }
126
127 void checkValidConnectivityList() const override
128 {
129 if (m_item_connectivity_index<0)
130 return;
131 auto x = m_item_connectivity_list;
132 ItemConnectivityContainerView ref_con_view = m_custom_connectivity->connectivityContainerView();
133 x->containerView(m_item_connectivity_index).checkSame(ref_con_view);
134 }
135
136 void compactConnectivities() override
137 {
138 if (m_custom_connectivity)
139 m_custom_connectivity->compactConnectivityList();
140 }
141
142 public:
143
144 void addConnectedItem(ItemLocalId item_lid,ItemLocalId sub_item_lid)
145 {
146 if (m_custom_connectivity)
147 m_custom_connectivity->addConnectedItem(item_lid,sub_item_lid);
148 }
149
150 void removeConnectedItem(ItemLocalId item_lid,ItemLocalId sub_item_lid)
151 {
152 if (m_custom_connectivity)
153 m_custom_connectivity->removeConnectedItem(item_lid,sub_item_lid);
154 }
155
156 void removeConnectedItems(ItemLocalId item_lid)
157 {
158 if (m_custom_connectivity)
159 m_custom_connectivity->removeConnectedItems(item_lid);
160 }
161
163 {
164 if (m_custom_connectivity)
165 m_custom_connectivity->replaceConnectedItems(item_lid,sub_item_lids);
166 }
167
168 void replaceItem(ItemLocalId item_lid,Integer index,ItemLocalId sub_item_lid)
169 {
170 if (m_custom_connectivity)
171 m_custom_connectivity->replaceConnectedItem(item_lid,index,sub_item_lid);
172 }
173
174 bool hasConnectedItem(ItemLocalId source_item, ItemLocalId target_local_id) const
175 {
176 if (m_custom_connectivity)
177 return m_custom_connectivity->hasConnectedItem(source_item,target_local_id);
178
179 return false;
180 }
181
182 CustomType* trueCustomConnectivity() const { return m_custom_connectivity; }
183
184 protected:
185
186 void _createCustomConnectivity(const String& name) override
187 {
188 m_custom_connectivity = new CustomType(m_source_family,m_target_family,name);
189 }
190
191 // used only with family dependencies. The concrete type of families are needed only for FaceToCellConnectivity
192 // where the IncrementalItemConnectivity has been overloaded (to handle back/front cell connectivity)
193 template <class SourceFamily, class TargetFamily>
194 void _createCustomConnectivity(const String& name)
195 {
196 m_custom_connectivity = new typename CustomConnectivity<SourceFamily,TargetFamily>::type(m_source_family,m_target_family,name);
197 }
198
199 void _buildCustomConnectivity() override
200 {
201 // Indique à l'IncrementalItemConnectivity qu'elle doit mettre à jour
202 // les accesseurs de ItemInternal.
203 if (m_custom_connectivity)
204 m_custom_connectivity->setItemConnectivityList(m_item_connectivity_list,
205 m_item_connectivity_index);
206 }
207
208 public:
209 // Build called when using family dependencies
210 template<class SourceFamily, class TargetFamily>
211 void build()
212 {
213 if (m_is_built)
214 return;
215
217 info() << "Family: " << m_source_family->fullName()
218 << " create new connectivity: " << m_connectivity_name;
219
220 _buildCustomConnectivity();
221 m_is_built = true;
222 }
223
224 private:
225
226 CustomType* m_custom_connectivity;
227};
228
229/*---------------------------------------------------------------------------*/
230/*---------------------------------------------------------------------------*/
231
232} // End namespace Arcane::mesh
233
234/*---------------------------------------------------------------------------*/
235/*---------------------------------------------------------------------------*/
236
237#endif
Interface pour gérer une connectivité incrémentale.
Interface d'une famille d'entités.
Vues sur les conteneurs contenant les connectivités. Cette classe permet de rendre opaque en dehors d...
Informations de connectivité, pour une famille d'entité, permettant la transition entre les anciennes...
Index d'un Item dans une variable.
Definition ItemLocalId.h:40
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Connectivité incrémentale item->item[].
Sélection entre les connectivités historiques et à la demande.
Sélection entre les connectivités historiques et à la demande.
Famille d'entités.
Definition ItemFamily.h:76
Vue constante d'un tableau de type T.
Chaîne de caractères unicode.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-