Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
ItemFamilySerializer.cc
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/* ItemFamilySerializer.cc (C) 2000-2018 */
9/* */
10/* Unique Serializer valid for any item family. */
11/* Requires the use of the family graph: ItemFamilyNetwork */
12/*---------------------------------------------------------------------------*/
13
14
15
16/*---------------------------------------------------------------------------*/
17/*---------------------------------------------------------------------------*/
18
19#include "arcane/IItemFamily.h"
20#include "arcane/IParallelMng.h"
21#include "arcane/IMesh.h"
22#include "arcane/ItemEnumerator.h"
23#include "arcane/ConnectivityItemVector.h"
24
25#include "arcane/mesh/ItemFamilySerializer.h"
26#include "arcane/mesh/ItemFamilyNetwork.h"
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31ARCANE_BEGIN_NAMESPACE
32
33ARCANE_MESH_BEGIN_NAMESPACE
34
35/*---------------------------------------------------------------------------*/
36/*---------------------------------------------------------------------------*/
37
38void ItemFamilySerializer::
39serializeItems(ISerializer* buf, Int32ConstArrayView local_ids)
40{
41 m_family->traceMng()->debug(Trace::High) << "_serializeItems : "
42 << m_family->mesh()->name() << " "
43 << m_family->name() << " "
44 << m_family->parentFamilyDepth();
45
46 Int32UniqueArray created_item_lids(local_ids.size()); // todo ne pas donner les lids car ils ne sont pas utilisés ensuite
47 // Serialize items along with their dependencies
48 ItemData item_dependencies_data(local_ids.size(),0,created_item_lids, m_family, m_family_modifier, m_family->parallelMng()->commRank());
49 _fillItemDependenciesData(item_dependencies_data,local_ids);
50 item_dependencies_data.serialize(buf); // ItemData handles the state of the ISerializer
51}
52
53/*---------------------------------------------------------------------------*/
54/*---------------------------------------------------------------------------*/
55
56void ItemFamilySerializer::
57deserializeItems(ISerializer* buf,Int32Array* local_ids)
58{
59 _deserializeItemsOrRelations(buf, local_ids);
60}
61
62/*---------------------------------------------------------------------------*/
63/*---------------------------------------------------------------------------*/
64
65void ItemFamilySerializer::
66_deserializeItemsOrRelations(ISerializer *buf, Int32Array *local_ids)
67{
68 // Deserialize items (if m_deserialize_items) or items relations
69 ItemData item_data; // it may be dependencies or relations
70 if (local_ids) {
71 item_data.deserialize(buf, m_family->mesh(), *local_ids);
72 }
73 else {
74 item_data.deserialize(buf, m_family->mesh());
75 }
76
77 // Add items (or append relations to existing items)
78 m_mesh_builder->addFamilyItems(item_data);
79}
80
81/*---------------------------------------------------------------------------*/
82/*---------------------------------------------------------------------------*/
83
84void ItemFamilySerializer::
86{
87 m_family->traceMng()->debug(Trace::High) << "_serializeItems relations : "
88 << m_family->mesh()->name() << " "
89 << m_family->name() << " "
90 << m_family->parentFamilyDepth();
91
92 Int32UniqueArray created_item_lids(local_ids.size()); // todo ne pas donner les lids car ils ne sont pas utilisés ensuite
93 // Serialize items along with their relations
94 ItemData item_relations_data(local_ids.size(),0,created_item_lids, m_family, m_family_modifier, m_family->parallelMng()->commRank());
95 _fillItemRelationsData(item_relations_data,local_ids);
96 item_relations_data.serialize(buf); // ItemData handles the state of the ISerializer
97}
98
99/*---------------------------------------------------------------------------*/
100/*---------------------------------------------------------------------------*/
101
102void ItemFamilySerializer::
103deserializeItemRelations(ISerializer* buf,Int32Array* local_ids)
104{
105 _deserializeItemsOrRelations(buf, local_ids);
106}
107
108/*---------------------------------------------------------------------------*/
109/*---------------------------------------------------------------------------*/
110
111void ItemFamilySerializer::
112_fillItemDependenciesData(ItemData& item_data, Int32ConstArrayView local_ids)
113{
114 Int64Array& item_infos = item_data.itemInfos();
115 Int32ArrayView item_owners = item_data.itemOwners();
116 // Reserve size
117 const Integer nb_item = local_ids.size();
118 item_infos.reserve(1+nb_item*32); // Size evaluation for hexa cell (the more data to store) : 1_family_info + nb_item *(2_info_per_family + 6 (faces) + 12 (edges) + 8 (vertices) connected elements) = 1 + nb_item *(6 + 6 + 12 +8)
119 // Fill item data (cf ItemData.h)
120 IItemFamilyNetwork* family_network = m_family->mesh()->itemFamilyNetwork();
121 auto out_connectivities = family_network->getChildDependencies(m_family); // Only dependencies are needed to create item. Relations are treated separately
122 item_infos.add(out_connectivities.size());
123 ENUMERATE_ITEM(item, m_family->view(local_ids))
124 {
125 item_infos.add(item->type());
126 item_infos.add(item->uniqueId().asInt64());
127 item_owners[item.index()] = item->owner();
129 {
131 {
132 item_infos.add(out_connectivity->targetFamily()->itemKind());
133 item_infos.add(out_connectivity->nbConnectedItem(ItemLocalId(item)));
136 item_infos.add(connected_item->uniqueId().asInt64());
137 }
138 }
139 }
140 }
141}
142
143void ItemFamilySerializer::
144_fillItemRelationsData(ItemData& item_data, Int32ConstArrayView local_ids)
145{
146 // Fill item relations, ie upward connectivities and extra connectivities (eg dof)
147 Int64Array& item_infos = item_data.itemInfos();
148 Int32ArrayView item_owners = item_data.itemOwners();
149 // Reserve size
150 const Integer nb_item = local_ids.size();
151 item_infos.reserve(1+nb_item*32); // Size evaluation for hexa cell (the more data to store) : 1_family_info + nb_item *(2_info_per_family + 6 (faces) + 12 (edges) + 8 (vertices) connected elements) = 1 + nb_item *(6 + 6 + 12 +8)
152 // Fill item data (cf ItemData.h)
153 IItemFamilyNetwork* family_network = m_family->mesh()->itemFamilyNetwork();
154 auto out_connectivities = family_network->getChildRelations(m_family); // Only relations are taken
155 item_infos.add(out_connectivities.size());
156 ENUMERATE_ITEM(item, m_family->view(local_ids)){
157 item_infos.add(item->type());
158 item_infos.add(item->uniqueId().asInt64());
159 item_owners[item.index()] = item->owner();
160 for (auto out_connectivity : out_connectivities)
161 {
162 item_infos.add(out_connectivity->targetFamily()->itemKind());
163 item_infos.add(out_connectivity->nbConnectedItem(ItemLocalId(item)));
164 ConnectivityItemVector connectivity_accessor(out_connectivity);
165 ENUMERATE_ITEM(connected_item, connectivity_accessor.connectedItems(ItemLocalId(item)))
166 {
167 item_infos.add(connected_item->uniqueId().asInt64());
168 }
169 }
170 }
171}
172
173/*---------------------------------------------------------------------------*/
174/*---------------------------------------------------------------------------*/
175
176IItemFamily* ItemFamilySerializer::
177family() const
178{
179 return m_family;
180}
181
182/*---------------------------------------------------------------------------*/
183/*---------------------------------------------------------------------------*/
184
185ARCANE_MESH_END_NAMESPACE
186ARCANE_END_NAMESPACE
187
188/*---------------------------------------------------------------------------*/
189/*---------------------------------------------------------------------------*/
#define ENUMERATE_ITEM(name, group)
Enumérateur générique d'un groupe de noeuds.
Tableau d'items de types quelconques.
Gère la récupération des informations de connectivité.
virtual SharedArray< IIncrementalItemConnectivity * > getChildRelations(IItemFamily *source_family)=0
Obtenir la liste de toutes les relations, filles d'une famille source_family ou parentes d'une famill...
Interface d'une famille d'entités.
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
Vue modifiable d'un tableau d'un type T.
Vue constante d'un tableau de type T.
virtual TraceMessageDbg debug(Trace::eDebugLevel=Trace::Medium)=0
Flot pour un message de debug.
ITraceMng * traceMng() const
Gestionnaire de trace.
Vecteur 1D de données avec sémantique par valeur (style STL).
Array< Int64 > Int64Array
Tableau dynamique à une dimension d'entiers 64 bits.
Definition UtilsTypes.h:325
ArrayView< Int32 > Int32ArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.
Definition UtilsTypes.h:611
Int32 Integer
Type représentant un entier.