Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
ItemConnectivity.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/* ItemConnectivity.cc (C) 2000-2024 */
9/* */
10/* External connectivities. First version with DoF */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/mesh/ItemConnectivity.h"
15#include "arcane/mesh/ExtraGhostItemsManager.h"
16
17#include <set>
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22ARCANE_BEGIN_NAMESPACE
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27void ItemConnectivity::
28compute()
29{
30 ItemVectorView from_items = _sourceFamily()->allItems().own().view();
31 ItemVectorView to_items = _targetFamily()->allItems().own().view();
32 ARCANE_ASSERT((from_items.size() == to_items.size()),
33 ("Connected families must have the same number of items "))
34 m_item_property.resize(_sourceFamily(),NULL_ITEM_LOCAL_ID);
35 // Link from and to items
36 Integer i = 0;
37 ENUMERATE_ITEM(iitem,from_items){
38 m_item_property[iitem] = to_items[i++].localId();
39 }
40}
41
42/*---------------------------------------------------------------------------*/
43/*---------------------------------------------------------------------------*/
44
45void ItemArrayConnectivity::
46compute()
47{
48 ItemVectorView from_items = _sourceFamily()->allItems().own().view();
49 ItemVectorView to_items = _targetFamily()->allItems().own().view();
50 ARCANE_ASSERT((from_items.size()*m_nb_dof_per_item == to_items.size()),
51 ("Incorrect connected family size. Should be FromFamily.own.size * nb_element_per_item"))
52 m_item_property.resize(_sourceFamily(),m_nb_dof_per_item,NULL_ITEM_LOCAL_ID);
53 Integer i = 0;
54 ENUMERATE_ITEM(iitem,from_items){
55 for (Integer j = 0; j < m_nb_dof_per_item ; ++j)
56 m_item_property[iitem][j] = to_items[i++].localId();
57 }
58}
59
60/*---------------------------------------------------------------------------*/
61/*---------------------------------------------------------------------------*/
62
63void ItemMultiArrayConnectivity::
64compute(IntegerConstArrayView nb_dof_per_item)
65{
66 ItemVectorView from_items = _sourceFamily()->allItems().own().view();
67 DoFVectorView to_items = _targetFamily()->allItems().own().view();
68 Integer total_nb_dof_per_item = 0;
69 for (Integer i = 0; i < nb_dof_per_item.size(); ++i)
70 total_nb_dof_per_item += nb_dof_per_item[i];
71
72 ARCANE_ASSERT((total_nb_dof_per_item == to_items.size()),
73 ("Incorrect connected family size. Should be equal to the sum of array nb_element_per_item elements"))
74
75 m_item_property.resize(_sourceFamily(),nb_dof_per_item,NULL_ITEM_LOCAL_ID);
76
77 Integer i = 0;
78 ENUMERATE_ITEM(iitem,from_items){
79 for (Integer j = 0; j < nb_dof_per_item[iitem->localId()]; ++j)
80 m_item_property[iitem][j] = to_items[i++].localId();
81 }
82}
83
84/*---------------------------------------------------------------------------*/
85/*---------------------------------------------------------------------------*/
86
87void ItemConnectivity::
89{
90 ARCANE_ASSERT((from_items.size() == to_items.size()),("from_items and to_items arrays must have the same size to update connectivity"))
91 // Adapt to possible evolution of from family size
92 m_item_property.resize(_sourceFamily(),NULL_ITEM_LOCAL_ID);
93 ItemVectorView from_items_view = _sourceFamily()->view(from_items);
94 for (Integer i = 0; i < from_items_view.size(); ++i)
95 m_item_property[from_items_view[i]] = to_items[i];
96}
97
98/*---------------------------------------------------------------------------*/
99/*---------------------------------------------------------------------------*/
100
101void ItemArrayConnectivity::
103{
104 ARCANE_ASSERT((from_items.size() == to_items.size()),("from_items and to_items arrays must have the same size to update connectivity"))
105 // Adapt to possible evolution of from family size
106 m_item_property.resize(_sourceFamily(),m_nb_dof_per_item, NULL_ITEM_LOCAL_ID);
107 IntegerSharedArray to_items_index(_sourceFamily()->maxLocalId(),0);// index in the connexion : from 0 to nb_dof_per_item -1. Fill with 0
108 std::set<Int32> from_items_set;
109 ItemVectorView from_items_view = _sourceFamily()->view(from_items);
110 for (Integer i = 0; i < from_items.size(); ++i){
111 if (! from_items_set.insert(from_items[i]).second)
112 ++to_items_index[from_items[i]]; // update the index in the connexion
113 m_item_property[from_items_view[i]][to_items_index[from_items[i]]] = to_items[i];
114 }
115}
116
117/*---------------------------------------------------------------------------*/
118/*---------------------------------------------------------------------------*/
119
120void ItemMultiArrayConnectivity::
122{
123 ARCANE_ASSERT((from_items.size() == to_items.size()),
124 ("from_items and to_items arrays must have the same size to update connectivity"))
125 // Resize item property
126 IntegerSharedArray nb_connected_element_per_item(m_item_property.dim2Sizes()); // Array indexed by lids
127
128 // Adapt to possible evolution of from family size
129 nb_connected_element_per_item.resize(_sourceFamily()->maxLocalId(),0);
130
131 // Remove history
132 for (Integer i = 0; i < from_items.size(); ++i)
134 for (Integer i = 0; i < from_items.size(); ++i)
136 m_item_property.resize(_sourceFamily(),nb_connected_element_per_item,NULL_ITEM_LOCAL_ID);
137
138 // Update item property
139 IntegerSharedArray to_items_index(_sourceFamily()->maxLocalId(),0);// index in the connexion : from 0 to nb_dof_per_item -1. Fill with 0
140 std::set<Int32> from_items_set;
141 ItemVectorView from_items_view = _sourceFamily()->view(from_items);
142 for (Integer i = 0; i < from_items.size(); ++i){
143 if (! from_items_set.insert(from_items[i]).second)
144 ++to_items_index[from_items[i]]; // update the index in the connexion
145 m_item_property[from_items_view[i]][to_items_index[from_items[i]]] = to_items[i];
146 }
147}
148
149/*---------------------------------------------------------------------------*/
150/*---------------------------------------------------------------------------*/
151
152void ItemConnectivity::
153notifyTargetFamilyLocalIdChanged(Int32ConstArrayView old_to_new_ids)
154{
155 m_item_property.resize(_sourceFamily(), NULL_ITEM_LOCAL_ID);
156 ENUMERATE_ITEM(item,_sourceFamily()->allItems())
157 {
158 if (m_item_property[item] != NULL_ITEM_LOCAL_ID)
159 m_item_property[item] = old_to_new_ids[m_item_property[item]];
160 }
161}
162
163/*---------------------------------------------------------------------------*/
164/*---------------------------------------------------------------------------*/
165
166void ItemArrayConnectivity::
167notifyTargetFamilyLocalIdChanged(Int32ConstArrayView old_to_new_ids)
168{
169 ENUMERATE_ITEM(item,_sourceFamily()->allItems())
170 {
171 for (Integer i = 0; i < m_nb_dof_per_item; ++i)
172 {
173 if (m_item_property[item][i] != NULL_ITEM_LOCAL_ID)
174 m_item_property[item][i] = old_to_new_ids[m_item_property[item][i]];
175 }
176 }
177}
178
179/*---------------------------------------------------------------------------*/
180/*---------------------------------------------------------------------------*/
181
182void ItemMultiArrayConnectivity::
183notifyTargetFamilyLocalIdChanged(Int32ConstArrayView old_to_new_ids)
184{
185 ENUMERATE_ITEM(item,_sourceFamily()->allItems())
186 {
187 for (Integer i = 0; i < m_item_property.dim2Sizes()[item.localId()]; ++i)
188 {
189 if (m_item_property[item][i] != NULL_ITEM_LOCAL_ID)
190 m_item_property[item][i] = old_to_new_ids[m_item_property[item][i]];
191 }
192 }
193}
194
195/*---------------------------------------------------------------------------*/
196/*---------------------------------------------------------------------------*/
197
198ARCANE_END_NAMESPACE
199
200/*---------------------------------------------------------------------------*/
201/*---------------------------------------------------------------------------*/
#define ENUMERATE_ITEM(name, group)
Enumérateur générique d'un groupe de noeuds.
Vue sur un vecteur d'entités.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Vue constante d'un tableau de type T.
Vecteur 1D de données avec sémantique par référence.
ItemVectorViewT< DoF > DoFVectorView
Vue sur un vecteur de degre de liberte.
Definition ItemTypes.h:315
Int32 Integer
Type représentant un entier.