14#include "arcane/utils/FatalErrorException.h"
15#include "arcane/utils/ITraceMng.h"
17#include "arcane/core/ISubDomain.h"
18#include "arcane/core/IMesh.h"
19#include "arcane/core/IMeshSubMeshTransition.h"
20#include "arcane/core/VariableTypes.h"
22#include "arcane/mesh/ItemSharedInfoList.h"
23#include "arcane/mesh/ItemFamily.h"
36ItemSharedInfoWithType::
37ItemSharedInfoWithType(ItemSharedInfo* shared_info, ItemTypeInfo* item_type)
38: m_shared_info(shared_info)
39, m_type_id(item_type->typeId())
43ItemSharedInfoWithType::
44ItemSharedInfoWithType(ItemSharedInfo* shared_info, ItemTypeInfo* item_type, Int32ConstArrayView buffer)
45: m_shared_info(shared_info)
46, m_type_id(item_type->typeId())
65 Int32 buf_size = buffer.size();
67 ARCANE_FATAL(
"Invalid buf size '{0}'. This is probably because your checkpoint is from a version of Arcane which is too old (before 3.6)",
70 m_nb_reference = buffer[3];
76void ItemSharedInfoWithType::
77serializeWrite(Int32ArrayView buffer)
79 buffer[0] = m_type_id;
84 buffer[3] = m_nb_reference;
110 bool operator<(
const ItemNumElements& b)
const
114 cout <<
"Compare:\nTHIS=";
118 cout <<
"\nVAL=" << compare(b);
127 inline bool compare(
const ItemNumElements& b)
const
129 return m_type < b.m_type;
134 void print(std::ostream& o)
const
136 o <<
" Type=" << m_type;
143bool ItemSharedInfoList::ItemNumElements::m_debug =
false;
180, m_common_item_shared_info(common_shared_info)
181, m_item_kind(family->itemKind())
183, m_infos_map(new ItemSharedInfoMap())
187 var_name = var_name +
"_SharedInfoList";
200 delete m_item_shared_infos_buffer;
206void ItemSharedInfoList::
209 Integer n = m_item_shared_infos.size();
210 info(4) <<
"ItemSharedInfoList: write: " << m_family->
name()
211 <<
" count=" << n <<
" changed=" << m_list_changed;
212 log() <<
"ItemSharedInfoList: write: " << m_family->
name()
213 <<
" count=" << n <<
" changed=" << m_list_changed;
217 m_list_changed =
false;
219 Integer element_size = ItemSharedInfoWithType::serializeSize();
220 m_variables->m_infos_values.
resize(n, element_size);
221 for (
Integer i = 0; i < n; ++i) {
222 m_item_shared_infos[i]->serializeWrite(m_variables->m_infos_values[i]);
234void ItemSharedInfoList::
237 Integer element_size = ItemSharedInfoWithType::serializeSize();
239 info() <<
"ItemSharedInfoList: read: " << m_family->
name() <<
" count=" << n;
244 Integer stored_size = m_variables->m_infos_values[0].size();
245 if (stored_size == ItemSharedInfoWithType::serializeSize()) {
247 else if (stored_size != element_size) {
251 if (stored_size != 13 && stored_size != 9)
252 ARCANE_FATAL(
"Incoherence of saved data (most probably due to a"
253 " difference of versions between the protection and the executable."
254 " stored_size={0} element_size={1} count={2}",
255 stored_size, element_size, n);
260 m_item_shared_infos.clear();
261 m_infos_map->clear();
266 for (
Integer i = 0; i < n; ++i)
269 ItemTypeMng* itm = m_family->mesh()->itemTypeMng();
270 for (
Integer i = 0; i < n; ++i) {
273 ItemTypeInfo* it = itm->typeFromId(buffer[0]);
274 ItemSharedInfoWithType* isi = m_item_shared_infos[i];
275 *isi = ItemSharedInfoWithType(m_common_item_shared_info, it, buffer);
278 std::pair<ItemSharedInfoMap::iterator, bool> old = m_infos_map->insert(std::make_pair(ine, isi));
283 ItemNumElements::m_debug =
true;
284 bool compare = m_infos_map->find(ine) != m_infos_map->end();
285 fatal() <<
"INTERNAL: ItemSharedInfoList::readfromDump(): SharedInfo already present family=" << m_family->name()
287 <<
" type=" << it->typeId()
288 <<
" compare=" << compare
289 <<
"\nNEW_INE=(" << ine <<
")"
290 <<
"\nOLD_INE=(" << old.first->first <<
")"
291 <<
"\nNEW_ISI=(" << *isi <<
")"
292 <<
"\nOLD_ISI=(" << *old.first->second <<
")";
303 bool has_error =
false;
305 info() <<
"ItemSharedInfoList: check valid family=" << m_family->name()
307 <<
" list=" << m_item_shared_infos.size()
308 <<
" free=" << m_free_item_shared_infos.size()
309 <<
" changed=" << m_list_changed;
313 for (
Integer i = 0, n = m_item_shared_infos.size(); i < n; ++i) {
315 if (item->index() != i) {
316 error() <<
"The index (" << item->index() <<
") from the list 'ItemSharedInfo' "
317 <<
"of the family " << m_family->name() <<
" is not "
318 <<
"coherent with its internal value (" << i <<
")";
332 ItemNumElements ine(
type->typeId());
333 ItemSharedInfoMap::const_iterator i = m_infos_map->find(ine);
334 if (i != m_infos_map->end())
338 Integer old_index = isi->index();
340 isi->setIndex(old_index);
341 std::pair<ItemSharedInfoMap::iterator, bool> old = m_infos_map->insert(std::make_pair(ine, isi));
348 ItemNumElements::m_debug =
true;
349 bool compare = m_infos_map->find(ine) != m_infos_map->end();
350 fatal() <<
"INTERNAL: ItemSharedInfoList::findSharedInfo() SharedInfo already present\n"
352 <<
" type=" <<
type->typeId()
353 <<
" compare=" << compare
354 <<
"\nNEW_INE=(" << ine <<
")"
355 <<
"\nOLD_INE=(" << old.first->first <<
")"
356 <<
"\nNEW_ISI=(" << *isi <<
")"
357 <<
"\nOLD_ISI=(" << *old.first->second <<
")";
366void ItemSharedInfoList::
369 info() <<
"--- ItemSharedInfos: family=" << m_family->
name();
370 for (ConstIterT<ItemSharedInfoMap> i(*m_infos_map); i(); ++i) {
371 info() <<
"INE: " << i->first;
372 info() <<
"ISI: " << *i->second;
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
constexpr Integer dim1Size() const
Number of elements in the first dimension.
Internal shared structure of a mesh entity.
Info on a mesh entity type.
Buffer for multiple allocation.
Unicode character string.
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
TraceMessage fatal() const
Flow for a fatal error message.
TraceMessage log() const
Flow for a log message.
TraceMessage info() const
Flow for an information message.
TraceMessage error() const
Flow for an error message.
ITraceMng * traceMng() const
Trace manager.
Parameters necessary for building a variable.
virtual void resize(Integer new_size)
Reallocates the number of elements in the first dimension of the array.
IMesh * mesh() const override
Associated mesh.
String name() const override
Family name.
Integer m_nb_item_shared_info
Number of allocated objects.
~ItemSharedInfoList()
Frees resources.
void checkValid()
Checks if the internal structures of the instance are valid.
Temporary class to hold an ItemSharedInfo and an entity type.
VariableRefArray2T< Int32 > VariableArray2Int32
Two-dimensional array variable of 32-bit integer type.
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.