Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
DoFFamily.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/* DoFFamily.cc (C) 2000-2024 */
9/* */
10/* Famille de degré de liberté */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/mesh/DoFFamily.h"
15
16#include "arcane/core/IMesh.h"
17#include "arcane/core/ItemTypeMng.h"
18#include "arcane/core/ItemTypeInfo.h"
19#include "arcane/core/IExtraGhostItemsBuilder.h"
20
21#include "arcane/mesh/ExtraGhostItemsManager.h"
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26namespace Arcane::mesh
27{
28
29Int64 DoFUids::
30getMaxItemUid(IItemFamily* family)
31{
32 Int64 max_uid = 0;
33 // This method can be used within IItemFamily::endUpdate when new items have been created but the groups are not yet updated.
34 // Therefore we use internal map enumeration instead of group enumeration
35 ItemFamily* item_family = ARCANE_CHECK_POINTER(dynamic_cast<ItemFamily*>(family));
36 item_family->itemsMap().eachItem([&](Item item) {
37 if (max_uid < item.uniqueId().asInt64())
38 max_uid = item.uniqueId().asInt64();
39 });
40 Int64 pmax_uid = family->mesh()->parallelMng()->reduce(Parallel::ReduceMax, max_uid);
41 return pmax_uid;
42}
43
44/*---------------------------------------------------------------------------*/
45/*---------------------------------------------------------------------------*/
46
48DoFFamily(IMesh* mesh, const String& name)
49 : ItemFamily(mesh,IK_DoF,name)
50, m_shared_info(nullptr)
51{}
52
53/*---------------------------------------------------------------------------*/
54/*---------------------------------------------------------------------------*/
55
56void DoFFamily::
57build()
58{
59 ItemFamily::build();
60 m_sub_domain_id = subDomain()->subDomainId();
61 ItemTypeMng* itm = m_mesh->itemTypeMng();
62 ItemTypeInfo* dof_type_info = itm->typeFromId(IT_NullType);
63 m_shared_info = _findSharedInfo(dof_type_info);
64}
65
66/*---------------------------------------------------------------------------*/
67/*---------------------------------------------------------------------------*/
68
72{
73 ARCANE_ASSERT((dof_uids.size() == dof_lids.size()),("in addDofs(uids,lids) given uids and lids array must have same size"))
75 return view(dof_lids);
76}
77
78/*---------------------------------------------------------------------------*/
79/*---------------------------------------------------------------------------*/
80
84{
85 ARCANE_ASSERT((dof_uids.size() == dof_lids.size() && (dof_uids.size() == owners.size())),("in addGhostDofs given uids, lids and owners array must have same size"))
87 return view(dof_lids);
88}
89
90/*---------------------------------------------------------------------------*/
91/*---------------------------------------------------------------------------*/
92
95{
96 Integer nb_item = unique_ids.size();
97 if (nb_item==0)
98 return;
99 preAllocate(nb_item);
100 for( Integer i=0; i<nb_item; ++i ){
101 Int64 uid = unique_ids[i];
102 ItemInternal* ii = _allocDoF(uid);
103 items[i] = ii->localId();
104 }
105
106 m_need_prepare_dump = true;
107}
108
109/*---------------------------------------------------------------------------*/
110/*---------------------------------------------------------------------------*/
111
114{
115 Integer nb_item = unique_ids.size();
116 if (nb_item==0)
117 return;
118 preAllocate(nb_item);
119 for( Integer i=0; i<nb_item; ++i ){
120 Int64 uid = unique_ids[i];
121 Int32 owner = owners[i];
122 ItemInternal* ii = _allocDoFGhost(uid,owner);
123 items[i] = ii->localId();
124 }
125
126 m_need_prepare_dump = true;
127}
128
129/*---------------------------------------------------------------------------*/
130/*---------------------------------------------------------------------------*/
131
134{
135 ARCANE_UNUSED(keep_ghost);
136 _removeMany(local_ids);
137
138 m_need_prepare_dump = true;
139
140}
141
142/*---------------------------------------------------------------------------*/
143/*---------------------------------------------------------------------------*/
144
145void
146DoFFamily::
148{
150}
151
152/*---------------------------------------------------------------------------*/
153/*---------------------------------------------------------------------------*/
154
155void
158{
159 debug() << "Creating the list of ghosts dofs";
161}
162
163/*---------------------------------------------------------------------------*/
164/*---------------------------------------------------------------------------*/
165
166void DoFFamily::
167_printInfos(Integer nb_added)
168{
169 Integer nb_in_map = itemsMap().count();
170
171 info() << "DoFFamily: added=" << nb_added
172 << " nb_internal=" << _infos().m_internals.size()
173 << " nb_free=" << _infos().m_free_internals.size()
174 << " map_nb_bucket=" << itemsMap().nbBucket()
175 << " map_size=" << nb_in_map;
176}
177
178/*---------------------------------------------------------------------------*/
179/*---------------------------------------------------------------------------*/
180
181void DoFFamily::
182preAllocate(Integer nb_item)
183{
184 // Copy paste de particle, pas utilise pour l'instant
185 Integer nb_hash = itemsMap().nbBucket();
186 Integer wanted_size = 2 * (nb_item + nbItem());
188 itemsMap().resize(wanted_size,true);
189}
190
191/*---------------------------------------------------------------------------*/
192/*---------------------------------------------------------------------------*/
193
194ItemInternal* DoFFamily::
195_allocDoF(const Int64 uid)
196{
197 bool need_alloc; // given by alloc
198 //ItemInternal* item_internal = ItemFamily::_allocOne(uid,need_alloc);
199 ItemInternal* item_internal = ItemFamily::_findOrAllocOne(uid,need_alloc);
200 if (!need_alloc)
201 item_internal->setUniqueId(uid);
202 else{
203 _allocateInfos(item_internal,uid,m_shared_info);
204 }
205 // Un dof appartient de base au sous-domaine qui l'a créé (sauf ghost)
206 item_internal->setOwner(m_sub_domain_id,m_sub_domain_id);
207 return item_internal;
208}
209
210/*---------------------------------------------------------------------------*/
211/*---------------------------------------------------------------------------*/
212
213ItemInternal* DoFFamily::
214_allocDoFGhost(const Int64 uid, const Int32 owner)
215{
216 bool need_alloc; // given by alloc
217 //ItemInternal* item_internal = ItemFamily::_allocOne(uid,need_alloc);
218 ItemInternal* item_internal = ItemFamily::_findOrAllocOne(uid,need_alloc);
219 //ItemInternal* item_internal = m_infos.findOrAllocOne(uid,need_alloc);
220 if (!need_alloc)
221 item_internal->setUniqueId(uid);
222 else{
223 _allocateInfos(item_internal,uid,m_shared_info);
224 }
225 // Une particule appartient toujours au sous-domaine qui l'a créée
226 item_internal->setOwner(owner,m_sub_domain_id);
227 return item_internal;
228}
229
230ItemInternal* DoFFamily::
231_findOrAllocDoF(const Int64 uid,bool& is_alloc)
232{
233 ItemInternal* item_internal = ItemFamily::_findOrAllocOne(uid,is_alloc);
234 if (!is_alloc) {
235 item_internal->setUniqueId(uid);
236 }
237 else {
238 _allocateInfos(item_internal,uid,m_shared_info);
239 // Un dof appartient de base au sous-domaine qui l'a créé (sauf ghost)
240 item_internal->setOwner(m_sub_domain_id,m_sub_domain_id);
241 }
242 return item_internal;
243}
244
245/*---------------------------------------------------------------------------*/
246/*---------------------------------------------------------------------------*/
247
248}
249
250/*---------------------------------------------------------------------------*/
251/*---------------------------------------------------------------------------*/
#define ARCANE_CHECK_POINTER(ptr)
Macro retournant le pointeur ptr s'il est non nul ou lancant une exception s'il est nul.
virtual ItemTypeMng * itemTypeMng() const =0
Gestionnaire de types d'entités associé
virtual Int32 subDomainId() const =0
Numéro du sous-domaine associé à ce gestionnaire.
Structure interne d'une entité de maillage.
Infos sur un type d'entité du maillage.
Gestionnaire des types d'entités de maillage.
Definition ItemTypeMng.h:66
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
DoFVectorView addGhostDoFs(Int64ConstArrayView dof_uids, Int32ArrayView dof_lids, Int32ConstArrayView owners) override
L'ajout de fantomes doit etre suivi d'un appel de computeSynchronizeInfos.
Definition DoFFamily.cc:83
void computeSynchronizeInfos() override
Operation collective.
Definition DoFFamily.cc:157
DoFFamily(IMesh *mesh, const String &name)
La famille ne peut pas etre cree directement, il faut utiliser le DoFManager.
Definition DoFFamily.cc:48
DoFVectorView addDoFs(Int64ConstArrayView dof_uids, Int32ArrayView dof_lids) override
En entree les uids des dofs et on recupere leurs lids.
Definition DoFFamily.cc:71
void internalRemoveItems(Int32ConstArrayView local_ids, bool keep_ghost=false) override
Supprime les entités donnés par local_ids.
Definition DoFFamily.cc:133
void addGhostItems(Int64ConstArrayView unique_ids, Int32ArrayView items, Int32ConstArrayView owners) override
Alloue des entités fantômes.
Definition DoFFamily.cc:113
Integer nbItem() const override
Nombre d'entités.
Definition DoFFamily.h:79
void _addItems(Int64ConstArrayView unique_ids, Int32ArrayView items)
Construction de l'item Family. C'est le DoFManager qui en a la responsabilite.
Definition DoFFamily.cc:94
UniqueArray< ItemInternal * > m_internals
ItemInternal des entités.
Int32UniqueArray m_free_internals
Liste des ItemInternal de m_item_internals_buffer libres.
Famille d'entités.
Definition ItemFamily.h:76
ItemVectorView view() override
Vue sur toutes les entités de la famille.
void computeSynchronizeInfos() override
Construit les structures nécessaires à la synchronisation.
ISubDomain * subDomain() const override
Sous-domaine associé
Int32 nbBucket() const
Nombre de buckets.
void resize(Int32 new_size, bool use_prime=false)
Redimensionne la table de hachage.
Int32 count() const
Nombre d'éléments de la table.
Integer size() const
Nombre d'éléments du vecteur.
Vue modifiable d'un tableau d'un type T.
Vue constante d'un tableau de type T.
Chaîne de caractères unicode.
TraceMessageDbg debug(Trace::eDebugLevel=Trace::Medium) const
Flot pour un message de debug.
TraceMessage info() const
Flot pour un message d'information.
@ IK_DoF
Entité de maillage de genre degre de liberte.