Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
FullItemInfo.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/* FullItemInfo.h (C) 2000-2021 */
9/* */
10/* Information de sérialisation d'une maille. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/mesh/FullItemInfo.h"
15
16#include "arcane/ISerializer.h"
17#include "arcane/ItemInternal.h"
18#include "arcane/ItemInternalEnumerator.h"
19
20#include "arcane/mesh/DynamicMesh.h"
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane::mesh
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
33 ItemTypeMng* itm, Integer parent_info,
34 bool has_edge, bool has_amr, bool with_flags)
35: m_nb_node(0)
36, m_nb_edge(0)
37, m_nb_face(0)
38, m_first_edge(0)
39, m_first_face(0)
40, m_memory_used(0)
41, m_type(0)
42, m_first_parent_node(0)
43, m_first_parent_edge(0)
44, m_first_parent_face(0)
45, m_first_parent_cell(0)
46, m_parent_info(parent_info)
47, m_has_edge(has_edge)
48, m_first_hParent_cell(0)
49, m_has_amr(has_amr)
50, m_with_flags(with_flags)
51{
52 Integer item_type_id = (Integer)cells_infos[cell_index];
53 ItemTypeInfo* it = itm->typeFromId(item_type_id);
54 m_type = it;
56 m_infos = Int64ConstArrayView(m_memory_used,&cells_infos[cell_index]);
57}
58
59/*---------------------------------------------------------------------------*/
60/*---------------------------------------------------------------------------*/
61
62void FullCellInfo::
63print(std::ostream& o) const
64{
65 o << "Cell uid=" << uniqueId()
66 << " nb_node=" << nbNode()
67 << " nb_edge=" << nbEdge()
68 << " nb_face=" << nbFace()
69 << ' ';
70 for( Integer z=0, zs=nbNode(); z<zs; ++z )
71 o << " N" << z << "=" << nodeUniqueId(z);
72 for( Integer z=0, zs=nbEdge(); z<zs; ++z )
73 o << " E" << z << "=" << edgeUniqueId(z);
74 for( Integer z=0, zs=nbFace(); z<zs; ++z )
75 o << " F" << z << "=" << faceUniqueId(z);
76}
77
78/*---------------------------------------------------------------------------*/
79/*---------------------------------------------------------------------------*/
80
81Integer FullCellInfo::
82memoryUsed(ItemTypeInfo* it, Integer parent_info, bool has_edge, bool has_amr,bool with_flags)
83{
84 Integer memory_used = 0;
85 // description de base d'une cellule
86 memory_used += 3 + 2*it->nbLocalNode() + 2*it->nbLocalFace();
87 if (has_edge)
88 memory_used += 2*it->nbLocalEdge();
89 // Facteur *2 : uid + type (tous sauf node)
90 if (parent_info & PI_Node)
91 memory_used += it->nbLocalNode();
92 if (parent_info & PI_Edge)
93 memory_used += 2*it->nbLocalEdge();
94 if (parent_info & PI_Face)
95 memory_used += 2*it->nbLocalFace();
96 if (parent_info & PI_Cell)
97 memory_used += 2;
99 if(has_amr)
100 memory_used += 3;
101 if(with_flags)
102 memory_used += 1;
103
104 return memory_used;
105}
106
107namespace
108{
109class SerializerDumpAdapter
110{
111 public:
112 SerializerDumpAdapter(ISerializer* s) : m_serializer(s){}
113 void put(Int64 v)
114 {
115 m_serializer->putInt64(v);
116 }
117 private:
118 ISerializer* m_serializer;
119};
120
121class ArrayDumpAdapter
122{
123 public:
124 ArrayDumpAdapter(Array<Int64>& a) : m_array_ref(a){}
125 void put(Int64 v)
126 {
127 m_array_ref.add(v);
128 }
129 private:
130 Array<Int64>& m_array_ref;
131};
132
133template<typename Adapter> void
134_dumpCellInfo(Cell cell,Adapter buf, Integer parent_info,
135 bool has_edge, bool has_amr,bool with_flags)
136{
137 buf.put(cell.type());
138 buf.put(cell.uniqueId().asInt64());
139 buf.put(cell.owner());
140 // Ajoute la liste des noeuds
141 for( Item node : cell.nodes() ){
142 buf.put(node.uniqueId().asInt64());
143 buf.put(node.owner());
144 }
145 // Ajoute la liste des arêtes
146 if (has_edge)
147 for( Edge edge : cell.edges() ){
148 buf.put(edge.uniqueId().asInt64());
149 buf.put(edge.owner());
150 }
151 // Ajoute la liste des faces
152 for( Face face : cell.faces() ){
153 buf.put(face.uniqueId().asInt64());
154 buf.put(face.owner());
155 }
156 if (parent_info & FullCellInfo::PI_Node) {
157 for( Node node : cell.nodes() ){
158 Item parent = node.parent(0);
159 buf.put(parent.uniqueId().asInt64());
160 }
161 }
162 if (parent_info & FullCellInfo::PI_Edge) {
163 for( Edge edge : cell.edges() ){
164 Item parent = edge.parent(0);
165 buf.put(parent.uniqueId().asInt64());
166 buf.put(parent.type());
167 }
168 }
169 if (parent_info & FullCellInfo::PI_Face) {
170 for( Face face : cell.faces() ){
171 Item parent = face.parent(0);
172 buf.put(parent.uniqueId().asInt64());
173 buf.put(parent.type());
174 }
175 }
176 if (parent_info & FullCellInfo::PI_Cell) {
177 Item parent = cell.parent(0);
178 buf.put(parent.uniqueId().asInt64());
179 buf.put(parent.type());
180 }
182 if(has_amr){
183 buf.put(cell.level());
184 if(cell.level() == 0){
185 buf.put(NULL_ITEM_ID);
186 buf.put(NULL_ITEM_ID);
187 }
188 else {
189 Cell hParent = cell.hParent();
190 buf.put(hParent.uniqueId().asInt64());
191 buf.put(hParent.whichChildAmI(cell));
192 }
193 }
194 if (with_flags)
195 buf.put(cell.itemBase().flags());
196}
197
198}
199
200/*---------------------------------------------------------------------------*/
201/*---------------------------------------------------------------------------*/
202
203void FullCellInfo::
204dump(ItemInternal* icell,ISerializer* buf, Integer parent_info,
205 bool has_edge, bool has_amr,bool with_flags)
206{
207 SerializerDumpAdapter adapter(buf);
208 _dumpCellInfo(icell,adapter,parent_info,has_edge,has_amr,with_flags);
209}
210
211void FullCellInfo::
212dump(Cell cell,Array<Int64>& buf, Integer parent_info,
213 bool has_edge, bool has_amr,bool with_flags)
214{
215 ArrayDumpAdapter adapter(buf);
216 _dumpCellInfo(cell,adapter,parent_info,has_edge,has_amr,with_flags);
217}
218
219/*---------------------------------------------------------------------------*/
220/*---------------------------------------------------------------------------*/
221
222Integer FullCellInfo::
223parentInfo(IMesh * mesh)
224{
225 Integer info = 0;
226 if (mesh->cellFamily()->parentFamily())
227 info |= PI_Cell;
228 if (mesh->faceFamily()->parentFamily())
229 info |= PI_Face;
230 if (mesh->edgeFamily()->parentFamily())
231 info |= PI_Edge;
232 if (mesh->nodeFamily()->parentFamily())
233 info |= PI_Node;
234 return info;
235}
236
237/*---------------------------------------------------------------------------*/
238/*---------------------------------------------------------------------------*/
239
242{
243 m_nb_node = m_type->nbLocalNode();
244 if (m_has_edge)
245 m_nb_edge = m_type->nbLocalEdge();
246 else
247 m_nb_edge = 0;
248 m_nb_face = m_type->nbLocalFace();
249 m_first_edge = 3 + m_nb_node*2;
250 m_first_face = m_first_edge + m_nb_edge*2;
251 m_first_parent_node = m_first_face + m_nb_face*2;
252 m_first_parent_edge = m_first_parent_node;
253 if (m_parent_info & PI_Node)
254 m_first_parent_edge += m_nb_node;
255 m_first_parent_face = m_first_parent_edge;
256 if (m_parent_info & PI_Edge)
257 m_first_parent_face += m_nb_edge*2;
258 m_first_parent_cell = m_first_parent_face;
259 if (m_parent_info & PI_Face)
260 m_first_parent_cell += m_nb_face*2;
261 m_memory_used = m_first_parent_cell;
262 if (m_parent_info & PI_Cell)
263 m_memory_used += 2;
265 if(m_has_amr){
266 m_first_hParent_cell = m_memory_used;
267 m_memory_used += 3;
268 }
269 if(m_with_flags)
270 m_memory_used += 1;
271}
272
273/*---------------------------------------------------------------------------*/
274/*---------------------------------------------------------------------------*/
275
276} // End namespace Arcane::mesh
277
278/*---------------------------------------------------------------------------*/
279/*---------------------------------------------------------------------------*/
Infos sur un type d'entité du maillage.
Integer nbLocalEdge() const
Nombre d'arêtes de l'entité
Integer nbLocalNode() const
Nombre de noeuds de l'entité
Integer nbLocalFace() const
Nombre de faces de l'entité
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
FullCellInfo(Int64ConstArrayView cells_infos, Integer cell_index, ItemTypeMng *itm, Integer parent_info, bool has_edge, bool has_amr, bool with_flags=false)
Référence les infos d'une maille.
void add(ConstReferenceType val)
Ajoute l'élément val à la fin du tableau.
Vue constante d'un tableau de type T.
ConstArrayView< Int64 > Int64ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 64 bits.
Definition UtilsTypes.h:638
Int32 Integer
Type représentant un entier.