Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
ItemFamilyNetwork.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/* ItemFamilyNetwork.cc (C) 2000-2022 */
9/* */
10/* ItemFamily relations through their connectivities. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "ItemFamilyNetwork.h"
15
16/*---------------------------------------------------------------------------*/
17
18/*---------------------------------------------------------------------------*/
19/*---------------------------------------------------------------------------*/
20
21namespace Arcane::mesh
22{
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
30{
33 m_connectivity_list.add(master_to_slave_connectivity);
34 m_connectivity_status[master_to_slave_connectivity] = std::make_pair(false,is_deep_connectivity); // connectivity not stored by default
35 }
36 m_families.insert(master_family);
37 m_families.insert(slave_family);
38
39 m_is_activated = true ;
40}
41
42/*---------------------------------------------------------------------------*/
43/*---------------------------------------------------------------------------*/
44
47{
49 m_connectivity_list.add(source_to_target_connectivity);
50 if(m_connectivity_status.find(source_to_target_connectivity)==m_connectivity_status.end())
51 m_connectivity_status[source_to_target_connectivity] = std::make_pair(false,true); // connectivity not stored by default
52 m_families.insert(source_family);
53 m_families.insert(target_family);
54 m_is_activated = true ;
55}
56
57/*---------------------------------------------------------------------------*/
58/*---------------------------------------------------------------------------*/
59
66
67/*---------------------------------------------------------------------------*/
68/*---------------------------------------------------------------------------*/
69
72{
73 // Up to now DirectedGraph and DirectedAcyclicGraph are not hypergraph, we cannot have multiple edges between two same nodes.
74 // => we just check the name is OK
75 auto* connectivity = m_dependency_graph.getEdge(source_family,target_family);
76 is_dependency = false;
77 if (connectivity)
78 {
79 _checkConnectivityName(*connectivity,name);
80 is_dependency = true;
81 return *connectivity;
82 }
83 connectivity = m_relation_graph.getEdge(source_family,target_family);
84 if (connectivity)
85 {
86 _checkConnectivityName(*connectivity,name);
87 return *connectivity;
88 }
89 else return nullptr;
90}
91
92/*---------------------------------------------------------------------------*/
93/*---------------------------------------------------------------------------*/
94
101
102/*---------------------------------------------------------------------------*/
103/*---------------------------------------------------------------------------*/
104
107{
109 if (con) {
110 if (!isStored(con)) con = nullptr;
111 }
112 return con;
113}
114/*---------------------------------------------------------------------------*/
115/*---------------------------------------------------------------------------*/
116
119{
120 return m_connectivity_list;
121}
122
123/*---------------------------------------------------------------------------*/
124/*---------------------------------------------------------------------------*/
125
128{
129 return _getConnectivitiesFromGraph(m_dependency_graph.outEdges(source_family));
130}
131
132/*---------------------------------------------------------------------------*/
133/*---------------------------------------------------------------------------*/
134
136getParentDependencies(IItemFamily* target_family)
137{
138 return _getConnectivitiesFromGraph(m_dependency_graph.inEdges(target_family));
139}
140
141/*---------------------------------------------------------------------------*/
142/*---------------------------------------------------------------------------*/
143
146{
147 return _getConnectivitiesFromGraph(m_relation_graph.outEdges(source_family));
148}
149
150/*---------------------------------------------------------------------------*/
151/*---------------------------------------------------------------------------*/
152
154getParentRelations(IItemFamily* target_family)
155{
156 return _getConnectivitiesFromGraph(m_relation_graph.inEdges(target_family));
157}
158
159/*---------------------------------------------------------------------------*/
160/*---------------------------------------------------------------------------*/
161
164{
165 return _getConnectivitiesFromGraph(m_relation_graph.outEdges(source_family), m_dependency_graph.outEdges(source_family));
166}
167
168/*---------------------------------------------------------------------------*/
169/*---------------------------------------------------------------------------*/
170
172getParentConnectivities(IItemFamily* target_family)
173{
174 return _getConnectivitiesFromGraph(m_relation_graph.inEdges(target_family), m_dependency_graph.inEdges(target_family));
175}
176
177/*---------------------------------------------------------------------------*/
178/*---------------------------------------------------------------------------*/
179
181_getConnectivitiesFromGraph(const ConnectivityGraph::ConnectedEdgeSet& connectivity_edges)
182{
184 Integer index(0);
185 for (const auto& connectivity_edge : connectivity_edges){
186 connectivities[index++] = connectivity_edge;
187 }
188 return connectivities;
189}
190
191/*---------------------------------------------------------------------------*/
192/*---------------------------------------------------------------------------*/
193
194SharedArray<IIncrementalItemConnectivity*> ItemFamilyNetwork::
195_getConnectivitiesFromGraph(const ConnectivityGraph::ConnectedEdgeSet& connectivity_edges1, const ConnectivityGraph::ConnectedEdgeSet& connectivity_edges2)
196{
197 SharedArray<IIncrementalItemConnectivity*> connectivities(connectivity_edges1.size()+connectivity_edges2.size());
198 Integer index(0);
199 for (const auto& connectivity_edge : connectivity_edges1){
200 connectivities[index++] = connectivity_edge;
201 }
202 for (const auto& connectivity_edge : connectivity_edges2){
203 connectivities[index++] = connectivity_edge;
204 }
205 return connectivities;
206}
207
208/*---------------------------------------------------------------------------*/
209/*---------------------------------------------------------------------------*/
210
213{
214 _getConnectivityStatus(connectivity).second.first = true;
215}
216
217/*---------------------------------------------------------------------------*/
218/*---------------------------------------------------------------------------*/
219
222{
223 return _getConnectivityStatus(connectivity).second.first;
224}
225
228{
229 return _getConnectivityStatus(connectivity).second.second;
230}
231/*---------------------------------------------------------------------------*/
232/*---------------------------------------------------------------------------*/
233
234void ItemFamilyNetwork::
235_checkConnectivityName(IIncrementalItemConnectivity* connectivity, const String& name)
236{
237 if (connectivity->name() != name) throw FatalErrorException(String::format("Found connectivity ({0}) has not the expected name ({1}) ",connectivity->name(),name));
238}
239
240/*---------------------------------------------------------------------------*/
241/*---------------------------------------------------------------------------*/
242
244getFamilies(eSchedulingOrder order) const
245{
247
248 switch (order)
249 {
250 case TopologicalOrder:
251 for (const auto& family : m_dependency_graph.topologicalSort())
252 families.add(family);
253 break;
254 case InverseTopologicalOrder:
255 for (const auto& family : m_dependency_graph.topologicalSort().reverseOrder())
256 families.add(family);
257 break;
258 case Unknown:
259 ARCANE_FATAL("Cannot schedule task, scheduling order is unkwnown. Set Scheduling order");
260 break;
261 }
262 return families;
263}
264
266schedule(IItemFamilyNetworkTask task, eSchedulingOrder scheduling_order)
267{
268 switch (scheduling_order) {
269 case TopologicalOrder:
270 for (const auto& family : m_dependency_graph.topologicalSort())
271 task(family);
272 break;
273 case InverseTopologicalOrder:
274 for (const auto& family : m_dependency_graph.topologicalSort().reverseOrder())
275 task(family);
276 break;
277 case Unknown:
278 ARCANE_FATAL("Cannot schedule task, scheduling order is unkwnown. Set Scheduling order");
279 break;
280 }
281}
282
283/*---------------------------------------------------------------------------*/
284/*---------------------------------------------------------------------------*/
285
286std::pair<IIncrementalItemConnectivity* const,std::pair<bool,bool>>& ItemFamilyNetwork::
287_getConnectivityStatus(IIncrementalItemConnectivity* connectivity)
288{
289 auto connectivity_iterator = m_connectivity_status.find(connectivity);
290 if (connectivity_iterator == m_connectivity_status.end())
291 ARCANE_FATAL("Cannot find connectivity {0} between families {1} and {2}",
292 connectivity->name(),connectivity->sourceFamily(),connectivity->targetFamily());
293 return *(connectivity_iterator);
294}
295
296/*---------------------------------------------------------------------------*/
297/*---------------------------------------------------------------------------*/
298
300{
301 Integer graph_id = m_registred_graphs.size() ;
302 m_registred_graphs.add(graph) ;
303 return graph_id ;
304}
305
307{
308 m_registred_graphs[graph_id] = nullptr ;
309}
310
312{
313 for(auto graph : m_registred_graphs)
314 {
315 graph->modifier()->removeConnectedItemsFromCells(local_ids) ;
316 }
317}
318
319/*---------------------------------------------------------------------------*/
320/*---------------------------------------------------------------------------*/
321} // End namespace Arcane::mesh
322
323/*---------------------------------------------------------------------------*/
324/*---------------------------------------------------------------------------*/
325
326
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Interface d'un graphe du maillage.
Definition IGraph2.h:90
Interface pour gérer une connectivité incrémentale.
virtual String name() const =0
Nom de la connectivité
virtual IItemFamily * targetFamily() const =0
Famille cible.
virtual IItemFamily * sourceFamily() const =0
Famille source.
Interface d'une famille d'entités.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
void setIsStored(IIncrementalItemConnectivity *connectivity) override
Positionne une connectivité comme étant stockée. A l'ajout les connectivités sont décrites comme non ...
List< IIncrementalItemConnectivity * > getConnectivities() override
Obtenir la liste de toutes les connectivités, qu'elles soient relation ou dépendance.
void addRelation(IItemFamily *source_family, IItemFamily *target_family, IIncrementalItemConnectivity *source_to_target_connectivity) override
SharedArray< IIncrementalItemConnectivity * > getChildRelations(IItemFamily *source_family) override
Obtenir la liste de toutes les relations, filles d'une famille source_family ou parentes d'une famill...
SharedArray< IIncrementalItemConnectivity * > getChildConnectivities(IItemFamily *source_family) override
Obtenir la liste de toutes les connectivités (dépendances ou relations), filles d'une famille source_...
bool isStored(IIncrementalItemConnectivity *connectivity) override
Récupère l'information relative au stockage de la connectivité
Integer registerConnectedGraph(IGraph2 *graph) override
enregistre un graphe gérant des DoFs connectés au maillage
const std::set< IItemFamily * > & getFamilies() const override
Obtenir la liste de toutes les familles.
void addDependency(IItemFamily *master_family, IItemFamily *slave_family, IIncrementalItemConnectivity *master_to_slave_connectivity, bool is_deep_connectivity) override
SharedArray< IIncrementalItemConnectivity * > getChildDependencies(IItemFamily *source_family) override
Obtenir la liste de toutes les dépendances, filles d'une famille source_family ou parentes d'une fami...
bool isDeep(IIncrementalItemConnectivity *connectivity) override
Récupère l'information relative au stockage de la connectivité
void removeConnectedDoFsFromCells(Int32ConstArrayView local_ids) override
supprime les DoFs et les liens entre DoFs connectés aux mailles supprimées
IIncrementalItemConnectivity * getConnectivity(IItemFamily *source_family, IItemFamily *target_family, const String &name) override
Obtenir une connectivité entre les familles source_family et target_family de nom name,...
IIncrementalItemConnectivity * getStoredConnectivity(IItemFamily *source_family, IItemFamily *target_family, const String &name) override
Retourne, si elle es associée à un stockage, la connectivité entre les familles source_family et targ...
void releaseConnectedGraph(Integer graph_id) override
dé enregistre un graphe gérant des DoFs connectés au maillage
void schedule(IItemFamilyNetworkTask task, eSchedulingOrder order=TopologicalOrder) override
Ordonnance l'exécution d'une tâche, dans l'ordre topologique ou topologique inverse du graphe de dépe...
Vue constante d'un tableau de type T.
Exception lorsqu'une erreur fatale est survenue.
Chaîne de caractères unicode.
Int32 Integer
Type représentant un entier.