14#include "arcane/utils/FatalErrorException.h"
15#include "arcane/utils/ITraceMng.h"
16#include "arcane/utils/StringBuilder.h"
17#include "arcane/utils/ScopedPtr.h"
18#include "arcane/utils/NotImplementedException.h"
19#include "arcane/utils/NotSupportedException.h"
20#include "arcane/utils/ArgumentException.h"
21#include "arcane/utils/CheckedConvert.h"
22#include "arcane/utils/PlatformUtils.h"
23#include "arcane/utils/OStringStream.h"
24#include "arcane/utils/ValueConvert.h"
25#include "arcane/utils/CStringUtils.h"
27#include "arcane/core/IParallelMng.h"
28#include "arcane/core/ISubDomain.h"
29#include "arcane/core/VariableTypes.h"
30#include "arcane/core/IVariableMng.h"
31#include "arcane/core/IVariable.h"
32#include "arcane/core/IMesh.h"
33#include "arcane/core/IMeshSubMeshTransition.h"
34#include "arcane/core/IApplication.h"
35#include "arcane/core/IDataFactoryMng.h"
36#include "arcane/core/ItemInfoListView.h"
37#include "arcane/core/ItemPairGroup.h"
38#include "arcane/core/ItemPairGroupImpl.h"
39#include "arcane/core/IMeshUtilities.h"
40#include "arcane/core/IVariableSynchronizer.h"
41#include "arcane/core/ItemInternalSortFunction.h"
42#include "arcane/core/Properties.h"
43#include "arcane/core/ItemFamilyCompactInfos.h"
44#include "arcane/core/IMeshMng.h"
45#include "arcane/core/IMeshCompacter.h"
46#include "arcane/core/IMeshCompactMng.h"
47#include "arcane/core/MeshPartInfo.h"
48#include "arcane/core/ParallelMngUtils.h"
49#include "arcane/core/internal/IDataInternal.h"
50#include "arcane/core/internal/IItemFamilyInternal.h"
51#include "arcane/core/internal/IIncrementalItemConnectivityInternal.h"
52#include "arcane/core/datatype/IDataOperation.h"
54#include "arcane/mesh/ItemFamily.h"
55#include "arcane/mesh/ItemSharedInfoList.h"
56#include "arcane/mesh/ItemConnectivityInfo.h"
57#include "arcane/mesh/ItemConnectivitySelector.h"
58#include "arcane/mesh/AbstractItemFamilyTopologyModifier.h"
59#include "arcane/mesh/DynamicMeshKindInfos.h"
61#include "arcane/core/parallel/GhostItemsVariableParallelOperation.h"
62#include "arcane/core/parallel/IStat.h"
64#include "arcane/core/IIncrementalItemConnectivity.h"
65#include "arcane/core/IItemConnectivityMng.h"
66#include "arcane/core/IItemFamilyPolicyMng.h"
68#include "arcane/core/ItemPrinter.h"
69#include "arcane/core/ConnectivityItemVector.h"
70#include "arcane/core/IndexedItemConnectivityView.h"
72#include "arcane/mesh/ItemProperty.h"
73#include "arcane/mesh/ItemData.h"
74#include "arcane/mesh/ConnectivityNewWithDependenciesTypes.h"
90 template <
typename DataType>
void
91 _offsetArrayByOne(Array<DataType>* array)
93 Array<DataType>& v = *array;
94 MeshUtils::checkResizeArray(v, v.size() + 1,
false);
96 for (
Int32 i = (n - 1); i >= 1; --i)
110 explicit InternalApi(ItemFamily* family)
118 return m_family->_unstructuredItemInternalConnectivityList();
122 return m_family->_topologyModifier();
126 return m_family->commonItemSharedInfo();
130 m_family->_addSourceConnectivity(connectivity);
134 m_family->_addTargetConnectivity(connectivity);
138 return m_family->_endAllocate();
142 return m_family->_notifyEndUpdateFromMesh();
146 return m_family->_addVariable(var);
150 return m_family->_removeVariable(var);
154 m_family->_resizeShMemVariables();
155 m_family->_resizeVariables(force_resize);
160 ItemFamily* m_family =
nullptr;
171 const String& family_name,
173 const String& shared_data_name,
174 const String& unique_ids_name,
175 const String& items_owner_name,
176 const String& items_flags_name,
177 const String& items_type_id_name,
178 const String& items_nb_parent_name,
179 const String& groups_name,
180 const String& current_id_name,
181 const String& new_owner_name,
182 const String& parent_mesh_name,
183 const String& parent_family_name,
184 const String& parent_family_depth_name,
185 const String& child_meshes_name,
186 const String& child_families_name)
271, m_internal_api(new InternalApi(this))
272, m_sub_domain(
mesh->subDomain())
274, m_item_internal_list(
mesh->meshItemInternalList())
275, m_common_item_shared_info(new
ItemSharedInfo(this, m_item_internal_list, &m_item_connectivity_list))
277, m_used_variables(&_cmpIVariablePtr)
278, m_used_shmem_variables(&_cmpIVariablePtr)
280, m_sub_domain_id(
mesh->meshPartInfo().partRank())
283 m_infos->setItemFamily(
this);
284 m_connectivity_selector_list_by_item_kind.resize(ItemInternalConnectivityList::MAX_ITEM_KIND);
293 delete m_topology_modifier;
296 delete m_local_connectivity_info;
297 delete m_global_connectivity_info;
298 delete m_item_sort_function;
299 delete m_internal_variables;
300 delete m_item_shared_infos;
302 for (ItemConnectivitySelector* ics : m_connectivity_selector_list)
305 delete m_common_item_shared_info;
306 delete m_internal_api;
313_variableName(
const String& base_name)
const
315 return m_name + base_name;
324 m_item_type_mng = m_mesh->itemTypeMng();
328 if (!m_topology_modifier)
329 m_topology_modifier =
new AbstractItemFamilyTopologyModifier(
this);
331 m_full_name = m_mesh->name() +
"_" + m_name;
333 m_local_connectivity_info =
new ItemConnectivityInfo();
334 m_global_connectivity_info =
new ItemConnectivityInfo();
336 IParallelMng* pm = m_mesh->parallelMng();
337 if (!pm->isParallel()) {
338 m_default_sub_domain_owner = 0;
339 m_is_parallel =
false;
342 m_is_parallel =
true;
352 String var_unique_ids_name(_variableName(
"FamilyUniqueIds"));
353 String var_owner_name(_variableName(
"FamilyOwner"));
354 String var_flags_name(_variableName(
"FamilyFlags"));
355 String var_typeid_name(_variableName(
"FamilyItemTypeId"));
356 String var_nb_parent_name(_variableName(
"FamilyItemNbParent"));
357 String var_count_name(_variableName(
"FamilyItemsShared"));
358 String var_groups_name(_variableName(
"FamilyGroupsName"));
359 String var_current_id_name(_variableName(
"FamilyCurrentId"));
360 String var_new_owner_name(_variableName(
"FamilyNewOwnerName"));
361 String var_parent_mesh_name(_variableName(
"ParentMeshName"));
362 String var_parent_family_name(_variableName(
"ParentFamilyName"));
363 String var_parent_family_depth_name(_variableName(
"ParentFamilyDepthName"));
364 String var_child_meshes_name(_variableName(
"ChildMeshesName"));
365 String var_child_families_name(_variableName(
"ChildFamiliesName"));
367 var_unique_ids_name, var_owner_name,
368 var_flags_name, var_typeid_name, var_nb_parent_name, var_groups_name,
369 var_current_id_name, var_new_owner_name,
370 var_parent_mesh_name, var_parent_family_name,
371 var_parent_family_depth_name,
372 var_child_meshes_name,
373 var_child_families_name);
377 m_items_unique_id = &m_internal_variables->m_items_unique_id._internalTrueData()->_internalDeprecatedValue();
378 m_items_owner = &m_internal_variables->m_items_owner._internalTrueData()->_internalDeprecatedValue();
379 m_items_flags = &m_internal_variables->m_items_flags._internalTrueData()->_internalDeprecatedValue();
380 m_items_type_id = &m_internal_variables->m_items_type_id._internalTrueData()->_internalDeprecatedValue();
381 m_items_nb_parent = &m_internal_variables->m_items_nb_parent._internalTrueData()->_internalDeprecatedValue();
384 _addOnSizeChangedObservable(m_internal_variables->m_items_unique_id);
385 _addOnSizeChangedObservable(m_internal_variables->m_items_owner);
386 _addOnSizeChangedObservable(m_internal_variables->m_items_flags);
387 _addOnSizeChangedObservable(m_internal_variables->m_items_type_id);
388 _addOnSizeChangedObservable(m_internal_variables->m_items_nb_parent);
395 m_item_sort_function = _defaultItemSortFunction();
399 if (s ==
"TRUE" || s ==
"1") {
400 info() <<
"WARNING: Using legacy 'compactItem()' without compactReference()'";
401 m_use_legacy_compact_item =
true;
406 m_do_shrink_after_allocate = (v.value() != 0);
416 return m_infos->findOne(uid);
421 return m_infos->itemsMap();
423const DynamicMeshKindInfos& ItemFamily::
429const DynamicMeshKindInfos& ItemFamily::
440 m_infos->removeOne(ItemCompatibility::_itemInternal(item));
445 m_infos->detachOne(ItemCompatibility::_itemInternal(item));
450 return m_infos->itemsInternal();
452ItemInternal* ItemFamily::
453_itemInternal(
Int32 local_id)
455 return m_infos->itemInternal(local_id);
457ItemInternal* ItemFamily::
458_allocOne(
Int64 unique_id)
460 return m_infos->allocOne(unique_id);
462ItemInternal* ItemFamily::
463_allocOne(
Int64 unique_id,
bool& need_alloc)
465 return m_infos->allocOne(unique_id, need_alloc);
467ItemInternal* ItemFamily::
468_findOrAllocOne(
Int64 uid,
bool& is_alloc)
470 return m_infos->findOrAllocOne(uid, is_alloc);
473_setHasUniqueIdMap(
bool v)
475 m_infos->setHasUniqueIdMap(v);
480 m_infos->removeMany(local_ids);
483_removeDetachedOne(Item item)
485 m_infos->removeDetachedOne(ItemCompatibility::_itemInternal(item));
490 return m_infos->kind();
499 return m_infos->nbItem();
508 return m_infos->maxUsedLocalId();
517 return m_infos->itemsInternal();
535 return m_parent_family;
544 m_parent_family = parent;
546 m_parent_family_depth = 1;
548 m_parent_family_depth = 0;
551 m_parent_family->addChildFamily(
this);
553 ARCANE_ASSERT((m_parent_family_depth < 2), (
"Not test if more than one depth level"));
562 return m_parent_family_depth;
572 m_child_families.add(true_family);
582 for (
Integer i = 0; i < m_child_families.size(); ++i) {
583 collection.add(m_child_families[i]);
594 return m_internal_variables->m_items_new_owner;
604 m_item_shared_infos->checkValid();
613 _checkValidConnectivity();
627 _computeConnectivityInfo(m_local_connectivity_info);
628 _computeConnectivityInfo(m_global_connectivity_info);
653 if (!m_parent_family) {
654 m_internal_variables->setUsed();
656 if (m_do_shrink_after_allocate)
657 _shrinkConnectivityAndPrintInfos();
664_shrinkConnectivityAndPrintInfos()
667 ItemConnectivityMemoryInfo mem_info;
668 for (ItemConnectivitySelector* cs : m_connectivity_selector_list) {
669 IIncrementalItemConnectivity* c = cs->customConnectivity();
670 c->_internalApi()->addMemoryInfos(mem_info);
672 const Int64 total_capacity = mem_info.m_total_capacity;
673 const Int64 total_size = mem_info.m_total_size;
674 Int64 ratio = 100 * (total_capacity - total_size);
675 ratio /= (total_size + 1);
677 const Int64 mega_byte = 1024 * 1024;
678 Int64 capacity_mega_byte = (mem_info.m_total_capacity * sizeof_int32) / mega_byte;
679 info() <<
"MemoryUsed for family name=" <<
name() <<
" size=" << mem_info.m_total_size
680 <<
" capacity=" << mem_info.m_total_capacity
681 <<
" capacity (MegaByte)=" << capacity_mega_byte
682 <<
" ratio=" << ratio;
685 std::ostream& o = ostr();
687 for (ItemConnectivitySelector* cs : m_connectivity_selector_list) {
688 IIncrementalItemConnectivity* c = cs->customConnectivity();
691 c->_internalApi()->shrinkMemory();
696 info() << ostr.str();
705 bool need_end_update = m_infos->changed();
706 info(4) <<
"ItemFamily::endUpdate() " <<
fullName() <<
" need_end_update?=" << need_end_update;
707 if (!need_end_update) {
713 if (m_need_prepare_dump) {
714 _computeConnectivityInfo(m_local_connectivity_info);
719 m_item_need_prepare_dump =
true;
720 _computeConnectivityInfo(m_local_connectivity_info);
725 m_connectivity_mng->setModifiedItems(
this, m_infos->addedItems(), m_infos->removedItems());
727 m_infos->finalizeMeshChanged();
736_endUpdate(
bool need_check_remove)
738 _resizeShMemVariables();
739 if (_partialEndUpdate())
742 _resizeVariables(
false);
744 <<
" hashmapsize=" << itemsMap().nbBucket()
745 <<
" nb_group=" << m_item_groups.count();
747 _updateGroups(need_check_remove);
765 _updateGroup(group,
true);
772_updateGroup(
ItemGroup group,
bool need_check_remove)
775 if (group == m_infos->allItems())
780 if (need_check_remove) {
792_updateGroups(
bool need_check_remove)
795 ItemGroup group = *i;
796 _updateGroup(group, need_check_remove);
806 _updateVariable(variable);
822_resizeVariables(
bool force_resize)
826 <<
" nb_item=" <<
nbItem()
827 <<
" currentsize=" << m_current_variable_item_size;
828 if (force_resize || (
maxLocalId() != m_current_variable_item_size)) {
829 info(4) <<
"ItemFamily::resizeVariables: name=" <<
fullName()
831 <<
" nb_item=" <<
nbItem()
832 <<
" currentsize=" << m_current_variable_item_size
834 <<
" nb_var=" << m_used_variables.size();
838 for (
IVariable* var : m_used_variables) {
839 _updateVariable(var);
848_resizeShMemVariables()
850 for (IVariable* var : m_used_shmem_variables) {
851 _updateVariable(var);
859itemsUniqueIdToLocalId(ArrayView<Int64> ids,
bool do_fatal)
const
861 m_infos->itemsUniqueIdToLocalId(ids, do_fatal);
872 m_infos->itemsUniqueIdToLocalId(local_ids, unique_ids, do_fatal);
883 m_infos->itemsUniqueIdToLocalId(local_ids, unique_ids, do_fatal);
919 return m_mesh->parallelMng();
928 _checkNeedEndUpdate();
929 return m_infos->allItems();
938 debug(
Trace::High) <<
"ItemFamily:createGroup(name,Int32ConstArrayView): " << m_name <<
":"
939 <<
" group_name=" <<
name
940 <<
" count=" << elements.
size()
941 <<
" override=" << do_override;
943 _checkNeedEndUpdate();
971 fatal() <<
"Attempting to create an already existing group '" <<
name <<
"'";
974 debug() <<
"ItemFamily:createGroup(name): " << m_name <<
":"
977 _processNewGroup(group);
991 fatal() <<
"Group already existing but with a different parent";
993 fatal() <<
"A group can not be its own parent name=" <<
name;
996 fatal() <<
"Attempting to create an already existing group '" <<
name <<
"'";
999 fatal() <<
"Attempting to create a group '" <<
name <<
"' with no parent.";
1000 debug() <<
"ItemFamily:createGroup(name,parent): " << m_name <<
":"
1002 <<
" parent=" << parent.
name();
1004 _processNewGroup(group);
1014 _invalidateComputedGroups();
1016 m_item_groups.clear();
1020 m_item_groups.add(group);
1033 debug() <<
"ItemFamily::notifyItemsOwnerChanged()";
1040 for (
Integer i = 0; i < m_child_families.size(); ++i) {
1043 for (
Integer z = 0, zs = items.
size(); z < zs; ++z) {
1044 impl::MutableItemBase item(items[z]);
1047 Item parent_item = item.parentBase(0);
1048 ARCANE_ASSERT((parent_item.
uniqueId() == item.
uniqueId()), (
"Inconsistent parent uid"));
1063 ARCANE_FATAL(
"Incoherent family name={0} wanted={1} current={2}",
1066 m_item_groups.add(group);
1067 m_need_prepare_dump =
true;
1071 if (!m_is_parallel && m_mesh->
meshPartInfo().nbPart() == 1)
1081 return m_item_groups;
1090 for (
const ItemGroup& group : m_item_groups) {
1105 if (create_if_needed)
1117 itemsMap().notifyUniqueIdsChanged();
1124_checkNeedEndUpdate()
const
1126 if (m_infos->changed())
1127 ARCANE_FATAL(
"missing call to endUpdate() after modification");
1136 info(4) <<
"ItemFamily::prepareForDump(): " <<
fullName()
1137 <<
" need=" << m_need_prepare_dump
1138 <<
" item-need=" << m_item_need_prepare_dump
1139 <<
" m_item_shared_infos->hasChanged()=" << m_item_shared_infos->hasChanged()
1140 <<
" nb_item=" << m_infos->nbItem();
1143 auto* p = m_properties;
1144 p->setInt32(
"dump-version", 0x0307);
1145 p->setInt32(
"nb-item", m_infos->nbItem());
1150 if (m_item_need_prepare_dump || m_item_shared_infos->hasChanged()) {
1151 info(4) <<
"Prepare for dump:2: name=" << m_name <<
" nb_alloc=" << m_nb_allocate_info
1152 <<
" uid_size=" << m_items_unique_id->size() <<
" cap=" << m_items_unique_id->capacity()
1153 <<
" byte=" << m_items_unique_id->capacity() *
sizeof(
Int64);
1159 m_infos->prepareForDump();
1160 m_item_shared_infos->prepareForDump();
1161 m_need_prepare_dump =
true;
1163 m_item_need_prepare_dump =
false;
1164 if (m_need_prepare_dump) {
1165 Integer nb_item = m_infos->nbItem();
1167 _resizeItemVariables(nb_item,
true);
1170 <<
" saveid=" << m_internal_variables->m_current_id();
1172 m_internal_variables->m_items_shared_data_index.resize(nb_item);
1173 IntegerArrayView items_shared_data_index(m_internal_variables->m_items_shared_data_index);
1174 info(4) <<
"ItemFamily::prepareForDump(): " << m_name
1175 <<
" count=" << nb_item <<
" currentid=" <<
m_current_id;
1178 for (
Integer i = 0; i < nb_item; ++i) {
1184 for (
Integer i = 0; i < nb_item; ++i) {
1187 items_shared_data_index[i] = isi->index();
1191 info() <<
"Item: SHARED_INDEX = " << items_shared_data_index[i]
1193 <<
" lid = " << item->
localId()
1194 <<
" dataindex = " << item->dataIndex()
1195 <<
" flags = " << item->
flags();
1203 if (m_parent_family) {
1204 m_internal_variables->m_parent_family_name = m_parent_family->name();
1205 m_internal_variables->m_parent_mesh_name = m_parent_family->mesh()->name();
1207 m_internal_variables->m_parent_family_depth = m_parent_family_depth;
1208 const Integer child_count = m_child_families.size();
1209 m_internal_variables->m_child_meshes_name.resize(child_count);
1210 m_internal_variables->m_child_families_name.resize(child_count);
1211 for (
Integer i = 0; i < child_count; ++i) {
1212 m_internal_variables->m_child_meshes_name[i] = m_child_families[i]->mesh()->name();
1213 m_internal_variables->m_child_families_name[i] = m_child_families[i]->name();
1228 m_internal_variables->m_groups_name.resize(nb_group_to_save);
1230 Integer current_group_index = 0;
1235 m_internal_variables->m_groups_name[current_group_index] = group.
name();
1236 ++current_group_index;
1245 _applyCheckNeedUpdateOnGroups();
1247 m_need_prepare_dump =
false;
1260 Int32 dump_version = 0;
1265 bool use_type_variable =
false;
1268 auto* p = m_properties;
1269 if (p->get(
"dump-version", x))
1271 if (dump_version >= 0x0307) {
1272 use_type_variable =
true;
1273 nb_item = p->getInt32(
"nb-item");
1274 Int32 cid = p->getInt32(
"current-change-id");
1275 Int32 expected_cid = m_internal_variables->m_current_id();
1276 if (cid != expected_cid)
1277 ARCANE_FATAL(
"Bad value for current id mesh={0} id={1} expected={2}",
1282 const bool allow_old_version =
true;
1283 if (!allow_old_version)
1284 if (dump_version < 0x0307)
1285 ARCANE_FATAL(
"Your checkpoint is from a version of Arcane which is too old (mininum version is 3.7)");
1290 const MeshPartInfo& part_info = m_mesh->meshPartInfo();
1291 m_sub_domain_id = part_info.partRank();
1292 if (m_infos->allItems().isOwn() && part_info.nbPart() > 1)
1293 m_infos->allItems().setOwn(
false);
1302 IntegerArrayView items_shared_data_index(m_internal_variables->m_items_shared_data_index);
1303 if (!use_type_variable)
1304 nb_item = items_shared_data_index.
size();
1306 info(4) <<
"ItemFamily::readFromDump(): " <<
fullName()
1307 <<
" count=" << nb_item
1309 <<
" saveid=" << m_internal_variables->m_current_id()
1310 <<
" use_type_variable?=" << use_type_variable
1311 <<
" dump_version=" << dump_version;
1313 if (!use_type_variable) {
1320 _handleOldCheckpoint();
1324 if (m_internal_variables->m_current_id() ==
m_current_id) {
1325 debug() <<
"Family unchanged. Nothing to do.";
1332 _invalidateComputedGroups();
1339 m_current_variable_item_size = 0;
1343 IMeshMng* mesh_mng = m_mesh->meshMng();
1344 if (!m_internal_variables->m_parent_mesh_name().null()) {
1346 m_parent_family = parent_mesh->
findItemFamily(m_internal_variables->m_parent_family_name(),
true);
1348 m_parent_family_depth = m_internal_variables->m_parent_family_depth();
1349 ARCANE_ASSERT((m_internal_variables->m_child_meshes_name.size() == m_internal_variables->m_child_families_name.size()),
1350 (
"Incompatible child mesh/family sizes"));
1351 Integer child_count = m_internal_variables->m_child_families_name.size();
1352 for (
Integer i = 0; i < child_count; ++i) {
1355 m_child_families.add(
dynamic_cast<ItemFamily*
>(child_family));
1359 m_item_shared_infos->readFromDump();
1360 m_infos->readFromDump();
1365 if (use_type_variable) {
1367 for (
Integer i = 0; i < nb_item; ++i) {
1369 ItemTypeId type_id{ m_common_item_shared_info->m_type_ids[i] };
1371 Int64 uid = m_items_unique_id_view[i];
1373 item->_setSharedInfo(isi->sharedInfo(), type_id);
1378 auto item_shared_infos = m_item_shared_infos->itemSharedInfos();
1379 for (
Integer i = 0; i < nb_item; ++i) {
1380 Integer shared_data_index = items_shared_data_index[i];
1382 Int64 uid = m_items_unique_id_view[i];
1384 item->_setSharedInfo(isi->sharedInfo(), isi->itemTypeId());
1390 m_infos->allItems().clear();
1393 for (
auto& c : m_source_incremental_item_connectivities)
1394 c->notifyReadFromDump();
1400 _invalidateComputedGroups();
1411_applyCheckNeedUpdateOnGroups()
1416 if (group == m_infos->allItems())
1426_invalidateComputedGroups()
1432 ItemGroup group = *i;
1433 if (!group.internal()->parentGroup().null()) {
1450 debug() <<
"ItemFamily::readFromDump(): number of group: " << groups_var.
size();
1451 for (
Integer i = 0, is = groups_var.
size(); i < is; ++i) {
1453 debug() <<
"Readign group again: " <<
name;
1461 for (
ItemGroup& group : m_item_groups) {
1462 group.incrementTimestamp();
1478 if (global_changed != 0)
1498 m_need_prepare_dump =
true;
1506 m_item_need_prepare_dump =
true;
1519 if (!m_use_legacy_compact_item) {
1522 _applyCheckNeedUpdateOnGroups();
1554 m_infos->beginCompactItems(compact_infos);
1557 m_infos->checkValid();
1562 for (
auto& c : m_source_incremental_item_connectivities)
1563 c->notifySourceFamilyLocalIdChanged(new_to_old_ids);
1565 for (
auto& c : m_target_incremental_item_connectivities)
1566 c->notifyTargetFamilyLocalIdChanged(old_to_new_ids);
1569 c->notifySourceFamilyLocalIdChanged(new_to_old_ids);
1572 c->notifyTargetFamilyLocalIdChanged(old_to_new_ids);
1579 if (m_parent_family_depth > 0)
1590finishCompactItems(ItemFamilyCompactInfos& compact_infos)
1593 m_infos->checkValid();
1595 m_infos->finishCompactItems(compact_infos);
1597 for (ItemConnectivitySelector* ics : m_connectivity_selector_list)
1598 ics->compactConnectivities();
1613 ARCANE_ASSERT(source.size() == destination.
size(),
1614 (
"Can't copy. Source and destination have different size !"));
1616 if (source.size() != 0) {
1617 for (
IVariable* var : m_used_variables) {
1624 for (
IVariable* var : m_used_shmem_variables) {
1646 ARCANE_ASSERT(first_source.
size() == destination.
size(),
1647 (
"Can't copy. : first_source and destination have different size !"));
1648 ARCANE_ASSERT(second_source.
size() == destination.
size(),
1649 (
"Can't copy : second_source and destination have different size !"));
1651 if (first_source.
size() != 0) {
1652 for (
IVariable* var : m_used_variables) {
1657 for (
IVariable* var : m_used_shmem_variables) {
1679 for (
IVariable* var : m_used_variables) {
1683 for (
IVariable* var : m_used_shmem_variables) {
1688 m_variable_synchronizer->changeLocalIds(old_to_new_ids);
1698 for (
Integer i = 0; i < m_child_families.size(); ++i)
1703 <<
" nb_item=" <<
nbItem();
1708 m_current_variable_item_size =
nbItem();
1721compactConnectivities()
1726 c->notifySourceFamilyLocalIdChanged(new_to_old_ids);
1729 c->notifyTargetFamilyLocalIdChanged(old_to_new_ids);
1743 if (m_parent_family_depth > 1)
1746 ARCANE_ASSERT((
nbItem() == 0 || !old_to_new_lids.
empty()), (
"Empty oldToNewLocalIds"));
1747 debug() <<
"\tfrom parent family " << m_parent_family->name();
1748 if (
this == m_parent_family)
1751 for (
Integer z = 0, zs = items.
size(); z < zs; ++z) {
1753 Int32 old_parent_lid = item->parentId(0);
1754 item->
setParent(0, old_to_new_lids[old_parent_lid]);
1767 ARCANE_UNUSED(local_ids);
1768 ARCANE_UNUSED(keep_ghost);
1781 if (m_sub_domain_id != part_rank)
1782 ARCANE_FATAL(
"Family {0} Bad value for partRank ({1}) expected={2}",
1783 fullName(), m_sub_domain_id, part_rank);
1791_reserveInfosMemory(
Integer memory)
1793 ARCANE_UNUSED(memory);
1802 ARCANE_UNUSED(new_size);
1811 ARCANE_UNUSED(memory);
1819_findSharedInfo(ItemTypeInfo*
type)
1821 return m_item_shared_infos->findSharedInfo(type);
1831 m_need_prepare_dump =
true;
1838_allocateInfos(ItemInternal* item,
Int64 uid, ItemTypeInfo*
type)
1840 ItemSharedInfoWithType* isi = _findSharedInfo(type);
1841 _allocateInfos(item, uid, isi);
1848_resizeItemVariables(
Int32 new_size,
bool force_resize)
1850 bool is_resize = MeshUtils::checkResizeArray(*m_items_unique_id, new_size + 1, force_resize);
1851 is_resize |= MeshUtils::checkResizeArray(*m_items_owner, new_size + 1, force_resize);
1852 is_resize |= MeshUtils::checkResizeArray(*m_items_flags, new_size + 1, force_resize);
1853 is_resize |= MeshUtils::checkResizeArray(*m_items_type_id, new_size + 1, force_resize);
1854 if (m_parent_family_depth > 0)
1855 is_resize |= MeshUtils::checkResizeArray(*m_items_nb_parent, new_size, force_resize);
1861 (*m_items_unique_id)[0] = NULL_ITEM_UNIQUE_ID;
1862 (*m_items_flags)[0] = 0;
1863 (*m_items_owner)[0] = A_NULL_RANK;
1864 (*m_items_type_id)[0] = IT_NullType;
1875 Int32 local_id = item->localId();
1876 _resizeItemVariables(local_id + 1,
false);
1881 ItemTypeId iti = isi->itemTypeId();
1882 item->_setSharedInfo(isi->sharedInfo(), iti);
1884 item->reinitialize(uid, m_default_sub_domain_owner, m_sub_domain_id);
1885 ++m_nb_allocate_info;
1887 for (
auto& c : m_source_incremental_item_connectivities)
1888 c->notifySourceItemAdded(ItemLocalId(local_id));
1895_preAllocate(
Int32 nb_item,
bool pre_alloc_connectivity)
1898 m_infos->itemsMap().resize(nb_item,
true);
1899 _resizeItemVariables(nb_item,
false);
1900 for (
auto& c : m_source_incremental_item_connectivities)
1901 c->reserveMemoryForNbSourceItems(nb_item, pre_alloc_connectivity);
1908_notifyDataIndexChanged()
1922 sub_domains.
copy(ranks);
1935 if (m_is_parallel && m_mesh->meshPartInfo().nbPart() ==
parallelMng()->commSize()) {
1936 m_variable_synchronizer->compute();
1974 return &m_items_unique_id_view;
1990 if (!var && throw_exception) {
2018 info() <<
"ItemFamily::checkUniqueIds name=" <<
name() <<
" n=" << nb_item
2019 <<
" total=" << all_unique_ids.
size();
2020 for (
Integer i = 0; i < nb_item; ++i)
2021 items_map.
add(unique_ids[i], 0);
2022 for (
Integer i = 0, is = all_unique_ids.
size(); i < is; ++i) {
2027 for (
Integer i = 0; i < nb_item; ++i) {
2028 Integer nb_ref = items_map[unique_ids[i]];
2030 fatal() <<
"Duplicate unique_id=" << unique_ids[i];
2050 auto i = m_adjacency_groups.find(at);
2052 if (i == m_adjacency_groups.end()) {
2053 debug() <<
"** BUILD ADJENCY_ITEMS : " << group.
name() <<
" x "
2054 << sub_group.
name() <<
" link=" << link_kind <<
" nblayer=" << layer;
2057 m_adjacency_groups.insert(std::make_pair(at, v));
2060 debug() <<
"** FOUND KNOWN ADJENCY_ITEMS! : " << group.
name() <<
" x "
2061 << sub_group.
name() <<
" link=" << link_kind <<
" nblayer=" << layer;
2071 return m_local_connectivity_info;
2080 return m_global_connectivity_info;
2128 ARCANE_FATAL(
"Can not add a variable to a different family");
2131 m_used_shmem_variables.insert(var);
2133 m_used_variables.insert(var);
2144 m_used_shmem_variables.erase(var);
2146 m_used_variables.erase(var);
2155 for (
IVariable* var : m_used_variables) {
2156 collection.add(var);
2158 for (
IVariable* var : m_used_shmem_variables) {
2159 collection.add(var);
2169 return m_variable_synchronizer.get();
2178 if (m_item_sort_function == sort_function)
2180 delete m_item_sort_function;
2181 m_item_sort_function = sort_function;
2182 if (!m_item_sort_function)
2183 m_item_sort_function = _defaultItemSortFunction();
2192 return m_item_sort_function;
2201 m_variable_synchronizer->synchronize(variables);
2210 m_variable_synchronizer->synchronize(variables, local_ids);
2219 ARCANE_UNUSED(unique_ids);
2220 ARCANE_UNUSED(items);
2221 ARCANE_UNUSED(owners);
2231 if (!m_mesh->itemFamilyNetwork())
2232 ARCANE_FATAL(
"Family name='{0}': IMesh::itemFamilyNetwork() is null",
name());
2241 for (
auto child_connectivity : child_connectivities) {
2242 child_families.
add(child_connectivity->targetFamily());
2243 child_families_to_current_family.
add(m_mesh->itemFamilyNetwork()->getConnectivity(child_families.
back(),
this, connectivityName(child_families.
back(),
this)));
2244 if (child_families_to_current_family.
back() ==
nullptr)
2245 fatal() <<
"removeItems2 needs reverse connectivity. Missing Connectivity " << connectivityName(child_families.
back(),
this);
2247 child_families_has_extra_parent_properties.
back().resize(child_families.
back(),
false);
2248 for (
auto parent_connectivity : m_mesh->itemFamilyNetwork()->getParentDependencies(child_families.
back())) {
2249 if (parent_connectivity == child_connectivity)
2252 _getConnectedItems(parent_connectivity, connected_items);
2253 _fillHasExtraParentProperty(child_families_has_extra_parent_properties[index], connected_items);
2259 for (
auto removed_item_lid_int64 : removed_item_lids) {
2260 Int32 removed_item_lid = CheckedConvert::toInt32(removed_item_lid_int64);
2262 for (
auto child_connectivity : child_connectivities) {
2265 if (!this->
itemsInternal()[removed_item_lid]->isDetached()) {
2266 child_families_to_current_family[index]->removeConnectedItem(
ItemLocalId(connected_item),
ItemLocalId(removed_item_lid));
2269 if (!child_families_has_extra_parent_properties[index][connected_item] && child_families_to_current_family[index]->nbConnectedItem(
ItemLocalId(connected_item)) == 0) {
2270 item_data_list[child_connectivity->targetFamily()->itemKind()].itemInfos().add((
Int64)connected_item.localId());
2278 for (
auto removed_item_lid_int64 : removed_item_lids) {
2279 Int32 removed_item_lid = CheckedConvert::toInt32(removed_item_lid_int64);
2280 for (
auto child_relation : m_mesh->itemFamilyNetwork()->getChildRelations(
this)) {
2289 is_removed_item.resize(
this,
false);
2290 for (
auto removed_item_lid_int64 : removed_item_lids) {
2291 Int32 removed_item_lid = CheckedConvert::toInt32(removed_item_lid_int64);
2292 is_removed_item[*(this->
itemsInternal()[removed_item_lid])] =
true;
2294 for (
auto parent_relation : m_mesh->itemFamilyNetwork()->getParentRelations(
this)) {
2295 for (
auto source_item : parent_relation->sourceFamily()->itemsInternal()) {
2296 if (source_item->isSuppressed())
2300 if (is_removed_item[connected_item])
2301 parent_relation->removeConnectedItem(
ItemLocalId(source_item), connected_item);
2306 for (
auto removed_item_lid_int64 : removed_item_lids) {
2307 Int32 removed_item_lid = CheckedConvert::toInt32(removed_item_lid_int64);
2308 ItemInternal* removed_item = m_infos->itemInternal(removed_item_lid);
2310 m_infos->removeDetachedOne(removed_item);
2313 m_infos->removeOne(removed_item);
2327 if (source_item->isSuppressed())
2329 target_family_connected_items.
add(connectivity_accessor.connectedItems(
ItemLocalId(source_item)).localIds());
2337_fillHasExtraParentProperty(ItemScalarProperty<bool>& child_families_has_extra_parent, ItemVectorView connected_items)
2340 child_families_has_extra_parent[connected_item] =
true;
2351 ARCANE_ASSERT((m_mesh->itemFamilyNetwork()->getParentDependencies(
this).empty()), (
"Only cells are detached, no parent dependencies are to be found."))
2354 for (auto removed_item_lid : local_ids) {
2355 for (
auto child_relation : m_mesh->itemFamilyNetwork()->getChildRelations(
this)) {
2356 ConnectivityItemVector connectivity_accessor(child_relation);
2357 ENUMERATE_ITEM (connected_item, connectivity_accessor.connectedItems(ItemLocalId(removed_item_lid))) {
2358 child_relation->removeConnectedItem(ItemLocalId(removed_item_lid), ItemLocalId(connected_item));
2363 ItemScalarProperty<bool> is_detached_item;
2364 is_detached_item.resize(
this,
false);
2365 for (
auto detached_item_lid : local_ids) {
2366 is_detached_item[*(this->itemsInternal()[detached_item_lid])] =
true;
2368 for (
auto parent_relation : m_mesh->itemFamilyNetwork()->getParentRelations(
this)) {
2369 for (auto source_item : parent_relation->sourceFamily()->itemsInternal()) {
2370 if (source_item->isSuppressed())
2372 ConnectivityItemVector connectivity_accessor(parent_relation);
2373 ENUMERATE_ITEM (connected_item, connectivity_accessor.connectedItems(ItemLocalId(source_item))) {
2374 if (is_detached_item[connected_item]) {
2375 parent_relation->removeConnectedItem(ItemLocalId(source_item), connected_item);
2381 for (
auto detached_item_lid : local_ids) {
2382 m_infos->detachOne(m_infos->itemInternal(detached_item_lid));
2390removeNeedRemoveMarkedItems()
2392 ItemInternalMap& item_map = itemsMap();
2393 if (item_map.
count() == 0)
2396 if (!m_mesh->itemFamilyNetwork())
2397 ARCANE_FATAL(
"Family name='{0}': IMesh::itemFamilyNetwork() is null",
name());
2398 if (!IItemFamilyNetwork::plug_serializer)
2399 ARCANE_FATAL(
"family name='{0}': removeNeedMarkedItems() cannot be called if ItemFamilyNetwork is unplugged.",
name());
2403 items_to_remove.
reserve(1000);
2404 items_to_remove_lids.
reserve(1000);
2406 item_map.
eachItem([&](impl::ItemBase item) {
2411 items_to_remove.
add(item._itemInternal());
2415 info() <<
"Number of " <<
itemKind() <<
" of family " <<
name() <<
" to remove: " << items_to_remove.
size();
2416 if (items_to_remove.
size() == 0)
2422 is_removed_item.resize(
this,
false);
2423 for (
auto removed_item : items_to_remove) {
2424 is_removed_item[*removed_item] =
true;
2427 for (
auto parent_connectivity : m_mesh->itemFamilyNetwork()->getParentRelations(
this)) {
2429 if (source_item->isSuppressed())
2433 if (is_removed_item[connected_item]) {
2440 m_infos->removeMany(items_to_remove_lids);
2468_defaultItemSortFunction()
2479 if (m_policy_mng == policy_mng)
2483 m_policy_mng = policy_mng;
2490addSourceConnectivity(IItemConnectivity* connectivity)
2492 m_source_item_connectivities.insert(connectivity);
2501 m_target_item_connectivities.insert(connectivity);
2510 m_source_item_connectivities.erase(m_source_item_connectivities.find(connectivity));
2519 m_target_item_connectivities.erase(m_target_item_connectivities.find(connectivity));
2528 ARCANE_ASSERT((m_connectivity_mng == NULL || m_connectivity_mng == connectivity_mng),
2529 (
"Connectivity Manager must be unique"))
2530 m_connectivity_mng = connectivity_mng;
2539 return m_infos->itemListChangedEvent();
2550 if (old_uid == unique_id)
2553 iitem->setUniqueId(unique_id);
2555 if (m_infos->hasUniqueIdMap()) {
2556 ItemInternalMap& item_map = itemsMap();
2557 item_map.
remove(old_uid);
2558 item_map.
add(unique_id, iitem);
2584_checkValidConnectivity()
2591 ARCANE_FATAL(
"family={0}: local item lid={1} is null", fullName(), item);
2599 Item i2 = m_common_item_shared_info->m_items_internal[item.localId()];
2601 ARCANE_FATAL(
"family={0}: incoherent item internal lid={1} i1={2} i2={3}",
2605 constexpr Int32 MAX_KIND = ItemInternalConnectivityList::MAX_ITEM_KIND;
2606 std::array<Int32, MAX_KIND> computed_max;
2607 computed_max.fill(0);
2609 for (
Integer i = 0; i < MAX_KIND; ++i) {
2612 Int32 stored_max_nb = m_item_connectivity_list.maxNbConnectedItem(i);
2613 const Int32 con_nb_item_size = con_view.nbSourceItem();
2615 info(4) <<
"Family name=" << fullName() <<
" I=" << i <<
" nb_item_size=" << con_nb_item_size;
2618 if (con_nb_item_size != 0) {
2623 Int32 x = con_view.nbItem(i);
2627 if (stored_max_nb < max_nb)
2628 ARCANE_FATAL(
"Bad value for max connected item family={0} kind={1} stored={2} computed={3}",
2629 name(), i, stored_max_nb, max_nb);
2630 computed_max[i] = max_nb;
2636 std::array<Int32, MAX_KIND> stored_max;
2638 auto* ci = m_local_connectivity_info;
2639 stored_max[ItemInternalConnectivityList::NODE_IDX] = ci->maxNodePerItem();
2640 stored_max[ItemInternalConnectivityList::EDGE_IDX] = ci->maxEdgePerItem();
2641 stored_max[ItemInternalConnectivityList::FACE_IDX] = ci->maxFacePerItem();
2642 stored_max[ItemInternalConnectivityList::CELL_IDX] = ci->maxCellPerItem();
2645 stored_max[ItemInternalConnectivityList::HPARENT_IDX] = computed_max[ItemInternalConnectivityList::HPARENT_IDX];
2646 stored_max[ItemInternalConnectivityList::HCHILD_IDX] = computed_max[ItemInternalConnectivityList::HCHILD_IDX];
2647 for (
Integer i = 0; i < MAX_KIND; ++i)
2648 if (stored_max[i] < computed_max[i])
2649 ARCANE_FATAL(
"Bad value for local_connectivity_info family={0} kind={1} stored={2} computed={3}",
2650 name(), i, stored_max[i], computed_max[i]);
2652 for (
auto ics : m_connectivity_selector_list)
2653 ics->checkValidConnectivityList();
2660_addConnectivitySelector(ItemConnectivitySelector* selector)
2662 m_connectivity_selector_list.add(selector);
2669_buildConnectivitySelectors()
2671 m_connectivity_selector_list_by_item_kind.clear();
2672 m_connectivity_selector_list_by_item_kind.resize(ItemInternalConnectivityList::MAX_ITEM_KIND);
2673 m_connectivity_selector_list_by_item_kind.fill(
nullptr);
2675 for (ItemConnectivitySelector* ics : m_connectivity_selector_list) {
2677 Int32 i = ics->itemConnectivityIndex();
2679 if (m_connectivity_selector_list_by_item_kind[i])
2680 ARCANE_FATAL(
"Can not have two connectivity selector for same item kind");
2681 m_connectivity_selector_list_by_item_kind[i] = ics;
2692 delete m_topology_modifier;
2693 m_topology_modifier = tm;
2706_updateItemsSharedFlag()
2715 for (
Integer i = 0; i < nb_rank; ++i) {
2717 for (
auto id : shared_ids)
2728 ici->fill(itemInternalConnectivityList());
2729 info(5) <<
"COMPUTE CONNECTIVITY INFO family=" << name() <<
" v=" << ici
2738_handleOldCheckpoint()
2742 _offsetArrayByOne(m_items_unique_id);
2743 _offsetArrayByOne(m_items_flags);
2744 _offsetArrayByOne(m_items_owner);
2745 (*m_items_unique_id)[0] = NULL_ITEM_UNIQUE_ID;
2746 (*m_items_flags)[0] = 0;
2747 (*m_items_owner)[0] = A_NULL_RANK;
2757 template <
typename DataType>
2758 ArrayView<DataType> _getView(Array<DataType>* v)
2760 Int32 n = v->size();
2761 return v->subView(1, n - 1);
2769 m_common_item_shared_info->m_unique_ids = _getView(m_items_unique_id);
2770 m_common_item_shared_info->m_flags = _getView(m_items_flags);
2771 m_common_item_shared_info->m_type_ids = _getView(m_items_type_id);
2772 m_common_item_shared_info->m_owners = _getView(m_items_owner);
2773 m_common_item_shared_info->m_parent_item_ids = m_items_nb_parent->view();
2775 m_items_unique_id_view = _getView(m_items_unique_id);
2784 m_observers.addObserver(
this, &ItemFamily::_updateItemViews,
2785 var_ref.variable()->onSizeChangedObservable());
2794 return m_internal_api;
#define ARCANE_CHECK_POINTER(ptr)
Macro returning the pointer ptr if it is not null or throwing an exception if it is null.
#define ARCANE_THROW(exception_class,...)
Macro for throwing an exception with formatting.
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
bool checkResizeArray(Array< DataType > &array, Int64 new_size, bool force_resize)
Resizes an array that is indexed by 'ItemLocalId'.
Integer size() const
Number of elements in the vector.
Exception when an argument is invalid.
constexpr Integer size() const noexcept
Returns the size of the array.
void resize(Int64 s)
Changes the number of elements in the array to s.
void copy(Span< const T > rhs)
Copies the values from rhs into the instance.
void add(ConstReferenceType val)
Adds element val to the end of the array.
T & back()
Last element of the array.
void reserve(Int64 new_capacity)
Reserves memory for new_capacity elements.
ArrayView< T > view() const
Mutable view of this array.
Manages the retrieval of connectivity information.
ItemVectorView connectedItems(ItemLocalId item)
Returns the entities connected to item.
Constant view of an array of type T.
constexpr Integer size() const noexcept
Number of elements in the array.
constexpr bool empty() const noexcept
true if the array is empty (size()==0)
static std::optional< Int32 > tryParseFromEnvironment(StringView s, bool throw_if_invalid)
Class managing observers associated with an event.
Hash table for associative arrays.
Data * lookup(KeyTypeConstRef id)
Searches for the value corresponding to key id.
bool add(KeyTypeConstRef id, const ValueType &value)
Adds the value value corresponding to key id.
virtual IDataOperation * createDataOperation(Parallel::eReduceType rt)=0
Creates an operation performing a reduction of type rt.
Interface of an operation on a data.
Interface for managing an incremental connectivity.
virtual void removeConnectedItem(ItemLocalId source_item, ItemLocalId target_local_id)=0
Removes the entity with localId() target_local_id from the connectivity of source_item.
Interface for the source of an incremental connectivity.
virtual IItemFamily * sourceFamily() const =0
Source family.
virtual Ref< IIncrementalItemSourceConnectivity > toSourceReference()=0
Returns a reference to the instance.
Interface for the target of an incremental connectivity.
virtual Ref< IIncrementalItemTargetConnectivity > toTargetReference()=0
Returns a reference to the instance.
Interface for connectivity information by entity type.
virtual void notifyLocalIdChanged(IItemFamily *item_family, Int32ConstArrayView old_to_new_ids, Integer nb_item)=0
Update of modified items, possibly compacted.
Interface to manage connectivity.
Internal part of IItemFamily.
Interface for entity family policies.
Interface for modifying the topology of entities within a family.
Interface of an entity family.
virtual Integer parentFamilyDepth() const =0
Gives the nesting depth of the current mesh.
virtual ItemInternalArrayView itemsInternal()=0
Internal array of entities.
virtual void notifyItemsOwnerChanged()=0
Notifies that the entities specific to the family's subdomain have been modified.
Interface of an entity sorting function.
virtual String name() const =0
Mesh name.
virtual IItemFamily * findItemFamily(eItemKind ik, const String &name, bool create_if_needed=false, bool register_modifier_if_created=false)=0
Returns the family named name.
Interface for managing the compaction of mesh families.
virtual void endCompact()=0
Signals that the compaction is finished.
virtual IMeshCompacter * beginCompact()=0
Starts a compaction on all families of the mesh.
Management of mesh family compaction.
virtual void setSorted(bool v)=0
Indicates whether entities should be sorted during compaction.
virtual void doAllActions()=0
Executes all compaction actions successively.
virtual MeshHandle * findMeshHandle(const String &name, bool throw_exception)=0
Searches for the mesh with name name.
virtual void computeAdjacency(const ItemPairGroup &adjacency_array, eItemKind link_kind, Integer nb_layer)
Calculates adjacencies, stored in adjacency_array.
virtual IMeshUtilities * utilities()=0
Associated utility functions interface.
virtual ItemTypeMng * itemTypeMng() const =0
Associated entity type manager.
virtual IMeshCompactMng * _compactMng()=0
virtual const MeshPartInfo & meshPartInfo() const =0
Mesh part information.
Interface of the parallelism manager for a subdomain.
virtual void allGatherVariable(ConstArrayView< char > send_buf, Array< char > &recv_buf)=0
Performs an all-gather operation across all processors.
virtual char reduce(eReduceType rt, char v)=0
Performs a reduction of type rt on the real v and returns the value.
Interface of the subdomain manager.
virtual IVariableMng * variableMng()=0
Returns the variable manager.
Variable manager interface.
virtual IVariable * findVariableFullyQualified(const String &name)=0
Returns the fully qualified variable named name or 0 if no such name exists.
Interface of a variable synchronization service.
virtual void changeLocalIds(Int32ConstArrayView old_to_new_ids)=0
Called when the local IDs of the entities are modified.
virtual String fullName() const =0
Full variable name (with family prefix).
@ PSubDomainDepend
Indicates that the variable value is dependent on the subdomain.
@ PTemporary
Indicates that the variable is temporary.
@ PInShMem
Indicates that the variable must be allocated in shared memory.
@ PExecutionDepend
Indicates that the variable value is dependent on the execution.
@ PPrivate
Indicates that the variable is private.
@ PNoRestore
Indicates that the variable should not be restored.
@ PNoDump
Indicates that the variable should not be saved.
virtual int property() const =0
Returns the properties of the variable.
virtual IDataFactoryMng * dataFactoryMng() const =0
Data factory associated with the variable.
virtual void resizeFromGroup()=0
Sets the number of elements for a mesh variable.
virtual ItemGroup itemGroup() const =0
Associated mesh group.
virtual void compact(Int32ConstArrayView new_to_old_ids)=0
Compresses the variable's values.
virtual void copyItemsMeanValues(Int32ConstArrayView first_source, Int32ConstArrayView second_source, Int32ConstArrayView destination)=0
Copies the mean values of entities numbered first_source and second_source into entities numbered des...
virtual IItemFamily * itemFamily() const =0
Associated entity family.
virtual String name() const =0
Variable name.
virtual void copyItemsValues(Int32ConstArrayView source, Int32ConstArrayView destination)=0
Copies the values of entities numbered source into entities numbered destination.
Base class for a view on unstructured connectivity.
bool isSuppressed() const
True if the entity is suppressed.
ItemUniqueId uniqueId() const
Unique number of the entity.
MutableItemBase toMutable()
Mutable interface of this entity.
Int32 flags() const
Flags of the entity.
bool isDetached() const
True if the entity is detached.
ItemTypeInfo * typeInfo() const
Type of the entity.
Int32 localId() const
Local number (in the subdomain) of the entity.
Information to manage the compaction of entities of a family.
Int32ConstArrayView newToOldLocalIds() const
Conversion between new and old local IDs.
Int32ConstArrayView oldToNewLocalIds() const
Conversion between old and new local IDs.
Event arguments for entity addition or deletion.
Flags for entity characteristics.
@ II_NeedRemove
The entity must be removed.
@ II_Shared
The entity is shared by another subdomain.
@ II_Suppressed
The entity has just been suppressed.
Brief: Implementation of a mesh entity group.
bool checkNeedUpdate()
Updates the group if necessary.
void destroy()
Destroys the group. After this call, the group becomes a null group.
void removeSuppressedItems()
Removes entities from the group whose isSuppressed() flag is true.
bool hasComputeFunctor() const
Indicates if the group is calculated.
ItemGroup parentGroup()
Parent group.
void changeIds(Int32ConstArrayView old_to_new_ids)
Changes the indices of the group entities.
ItemGroupImpl * internal() const
Returns the group implementation.
IVariableSynchronizer * synchronizer() const
Group synchronizer.
const String & name() const
Group name.
bool isLocalToSubDomain() const
True if the group is local to the subdomain.
void invalidate(bool force_recompute=false)
Invalidates the group.
ItemVectorView view() const
View of the group entities.
Integer size() const
Number of elements in the group.
IItemFamily * itemFamily() const
Entity family to which this group belongs (0 for the null group).
void setItems(Int32ConstArrayView items_local_id)
Sets the entities of the group.
eItemKind itemKind() const
Group kind. This is the kind of its elements.
bool hasSynchronizer() const
Indicates if the group has an active synchronizer.
bool isAllItems() const
Indicates if the group is that of all entities.
void checkValid()
Internal check of group validity.
bool null() const
true means the group is the null group
void setOwn(bool v)
Sets whether the group property is local or not.
View of a list to obtain information about entities.
Connectivity information, for an entity family, allowing transition between old and new connectivity ...
Interface for an entity sorting function.
Internal structure of a mesh entity.
Index of an Item in a variable.
Implementation of an array of lists of entities.
Utility class for printing information about an entity.
Internal shared structure of a mesh entity.
Type of an entity (Item).
Mesh entity type manager.
ItemTypeInfo * typeFromId(Integer id) const
Type corresponding to the number id.
Unique identifier of an entity.
View on a vector of entities.
void add(Int32 local_id)
Adds an entity with local ID local_id to the end of the vector.
Base class for a mesh element.
Int32 owner() const
Owner subdomain number of the entity.
ItemUniqueId uniqueId() const
Unique identifier across all domains.
Implementation of a collection of elements in vector form.
ListEnumeratorT< ItemGroup > Enumerator
IMesh * mesh() const
Associated mesh.
Information about a partitioned mesh.
void setOwner(Integer suid, Int32 current_sub_domain)
Sets the sub-domain number of the entity owner.
void setFlags(Int32 f)
Sets the entity flags.
void setParent(Int32 aindex, Int32 parent_local_id)
Sets the i-th parent (currently aindex must be 0).
Exception when a function is not implemented.
Exception when an operation is not supported.
Parallel operations on ghost entities.
void applyOperation(IDataOperation *operation) override
Applies the operation.
void addVariable(IVariable *variable) override
Adds a variable to the list of variables concerned by the operation.
void setItemFamily(IItemFamily *family) override
Positions the entity family on which the operation is to be performed.
T * get() const
Returns the object referenced by the instance.
Encapsulation of an automatically destructing pointer.
1D vector of data with reference semantics.
Unicode character string constructor.
String toString() const
Returns the constructed character string.
Unicode character string.
const char * localstr() const
Returns the conversion of the instance into UTF-8 encoding.
TraceMessageDbg debug(Trace::eDebugLevel=Trace::Medium) const
Flow for a debug message.
TraceMessage fatal() const
Flow for a fatal error message.
TraceMessage info() const
Flow for an information message.
ITraceMng * traceMng() const
Trace manager.
1D data vector with value semantics (STL style).
Parameters necessary for building a variable.
IVariable * variable() const
Associated variable.
Mesh information for a given entity kind.
Information on connectivity by entity type.
Integer maxNodePerItem() const override
Maximum number of nodes per entity.
Integer maxCellPerItem() const override
Maximum number of cells per entity.
Integer maxFacePerItem() const override
Maximum number of faces per entity.
Integer maxEdgePerItem() const override
Maximum number of edges per entity.
void resizeVariables(bool force_resize) override
Resizes the variables of this family.
void removeVariable(IVariable *var) override
Removes a variable from this family.
void notifyEndUpdateFromMesh() override
Indicates the end of modification by the mesh.
ItemInternalConnectivityList * unstructuredItemInternalConnectivityList() override
Information on unstructured connectivities.
void addVariable(IVariable *var) override
Adds a variable to this family.
void endAllocate() override
Indicates the end of allocation.
ItemSharedInfo * commonItemSharedInfo() override
Instance of ItemSharedInfo for the family entities.
IItemFamilyTopologyModifier * topologyModifier() override
Topology modifier interface.
VariableArrayInt64 m_items_unique_id
Contains the uniqueIds() of the entities in this family.
VariableArrayInteger m_items_shared_data_index
Index in the ItemSharedInfo array for each entity.
VariableArrayInt32 m_items_flags
Contains the flags() of the entities in this family.
VariableArrayInt16 m_items_type_id
Contains the typeId() of the entities in this family.
VariableArrayInt32 m_items_owner
Contains the owner() of the entities in this family.
VariableItemInt32 m_items_new_owner
Contains the owning sub-domain of the entity.
VariableArrayInt32 m_items_nb_parent
Contains the parent() of the entities in this family.
bool hasUniqueIdMap() const override
Indicates if the family has a uniqueId to localId conversion table.
IMesh * mesh() const override
Associated mesh.
void partialEndUpdateVariable(IVariable *variable) override
Updates a variable.
void _compactItems(bool do_sort)
Compresses the entities.
void partialEndUpdate() override
Partial update.
String fullName() const override
Full family name (with the mesh's name).
void _compactFromParentFamily(const ItemFamilyCompactInfos &compact_infos)
Compresses the connectivities.
void _checkComputeSynchronizeInfos(Int32 changed)
Test collectif permettant de savoir s'il faut mettre à jour les infos de synchro.
void _compactOnlyItems(bool do_sort)
Compresses the entities without updating references.
EventObservableView< const ItemFamilyItemListChangedEventArgs & > itemListChangedEvent() override
Event for entity addition and deletion.
void clearItems() override
Deletes all entities in the family.
ItemPairGroup findAdjencyItems(const ItemGroup &group, const ItemGroup &sub_group, eItemKind link_kind, Integer layer) override
Searches for an adjacency list.
void destroyGroups() override
Deletes all groups in this family.
void prepareForDump() override
Prepares data for dumping.
ItemInternalConnectivityList m_item_connectivity_list
Accessor for connectivities via Item and ItemInternal.
void addChildFamily(IItemFamily *family) override
Adds a family as a dependency.
void checkValid() override
Check the validity of internal structures (internal).
ItemInternal * findOneItem(Int64 uid) override
Unique ID entity unique_id.
IParallelMng * parallelMng() const override
Associated parallelism manager.
void endUpdate() override
Notifies the end of modification of the entity list.
void compactVariablesAndGroups(const ItemFamilyCompactInfos &compact_infos)
Compresses the variables and groups.
void usedVariables(VariableCollection collection) override
Adds the list of variables used by this family to the collection.
ITraceMng * traceMng() const override
Associated trace manager.
ItemGroup createGroup(const String &name, Int32ConstArrayView elements, bool do_override=false) override
Creates an entity group named name containing the entities local_ids.
eItemKind itemKind() const override
Entity kind.
Integer m_current_id
Family identifier.
VariableItemInt32 & itemsNewOwner() override
Variable containing the number of the new subdomain owning the entity.
void copyItemsValues(Int32ConstArrayView source, Int32ConstArrayView destination) override
void copyItemsMeanValues(Int32ConstArrayView first_source, Int32ConstArrayView second_source, Int32ConstArrayView destination) override
ItemGroup allItems() const override
Group of all entities.
void internalRemoveItems(Int32ConstArrayView local_ids, bool keep_ghost=false) override
Removes the entities given by local_ids.
void addGhostItems(Int64ConstArrayView unique_ids, Int32ArrayView items, Int32ConstArrayView owners) override
Allocates ghost entities.
void getCommunicatingSubDomains(Int32Array &sub_domains) const override
List of communicating sub-domains for the entities.
void reduceFromGhostItems(IVariable *v, IDataOperation *operation) override
Applies a reduction operation from ghost items.
ItemConnectivitySet m_target_item_connectivities
connectivite ou ItemFamily == SourceFamily
IItemFamily * parentFamily() const override
IItemFamily parent.
void setHasUniqueIdMap(bool v) override
Indicates whether the family has a conversion table from uniqueId to localId.
ItemInfoListView itemInfoListView() override
View on the entity information list.
static bool _cmpIVariablePtr(const IVariable *a, const IVariable *b)
Function to compare two variable names (strcmp).
void removeItems2(ItemDataList &item_data_list) override
Removes entities.
void setParentFamily(IItemFamily *parent) override
Positions the parent IItemFamily.
void compactItems(bool do_sort) override
Compresses the entities.
Integer nbItem() const override
Number of entities.
void notifyItemsUniqueIdChanged() override
Notifies that the unique IDs of the entities have been modified.
ItemVectorView view() override
View on all entities in the family.
void synchronize(VariableCollection variables) override
Synchronizes the variables variables.
ItemPairGroup findAdjacencyItems(const ItemGroup &group, const ItemGroup &sub_group, eItemKind link_kind, Integer layer) override
Searches for an adjacency list.
ItemInternalList itemsInternal() override
Internal array of entities.
void computeSynchronizeInfos() override
Constructs the structures necessary for synchronization.
void checkValidConnectivity() override
Verification of the validity of internal structures concerning connectivity.
void _updateItemsSharedFlag()
Positions Item::isShared() info for the entities of the family.
IVariable * findVariable(const String &name, bool throw_exception) override
Searches for the variable name name associated with this family.
void _readGroups()
Relit les groupes depuis une protection et les recréer si besoin.
Int32 maxLocalId() const override
void setItemSortFunction(IItemInternalSortFunction *sort_function) override
Positions the entity sorting function.
IItemInternalSortFunction * itemSortFunction() const override
Entity sorting function.
ISubDomain * subDomain() const override
Associated sub-domain.
virtual void _notifyEndUpdateFromMesh()
IVariableSynchronizer * allItemsSynchronizer() override
Synchronizer on all entities of the family.
void notifyItemsOwnerChanged() override
Notifies that the entities specific to the family's subdomain have been modified.
Integer parentFamilyDepth() const override
Gives the nesting depth of the current mesh.
ItemGroupCollection groups() const override
Collection of groups in this family.
IItemConnectivityMng * m_connectivity_mng
connectivite ou ItemFamily == TargetFamily
IItemConnectivityInfo * localConnectivityInfos() const override
Information on local connectivity within the subdomain for this family.
IItemFamilyCollection childFamilies() override
Child families of this family.
void partialEndUpdateGroup(const ItemGroup &group) override
Updates a group.
IItemConnectivityInfo * globalConnectivityInfos() const override
Information on global connectivity across all subdomains.
void checkUniqueIds(Int64ConstArrayView unique_ids) override
Checks that the unique_ids are truly unique for all subdomains.
ItemGroup findGroup(const String &name) const override
Searches for a group.
void readFromDump() override
Reads data from a dump.
String name() const override
Family name.
Associative array of ItemInternal.
void remove(Int64 key)
Removes the value associated with the key key.
void eachItem(const Lambda &lambda)
Template function to iterate over the instance's entities.
bool add(Int64 key, ItemInternal *v)
Adds the value v corresponding to the key key.
Int32 count() const
Number of elements in the table.
Mesh info for a given entity type.
Temporary class to hold an ItemSharedInfo and an entity type.
VariableRefArrayT< Int32 > VariableArrayInt32
Array variable of 32-bit integer type.
VariableRefArrayT< Int64 > VariableArrayInt64
Array variable of 64-bit integer type.
VariableRefArrayT< Int16 > VariableArrayInt16
Array variable of 16-bit integer type.
VariableRefScalarT< String > VariableScalarString
Scalar variable of character string type.
VariableRefArrayT< Integer > VariableArrayInteger
Array variable of integer type.
VariableRefArrayT< String > VariableArrayString
Array variable of character string type.
ItemVariableScalarRefT< Int32 > VariableItemInt32
32-bit integer type quantity
VariableRefScalarT< Integer > VariableScalarInteger
Scalar variable of integer type.
bool isLess(const char *s1, const char *s2)
Returns true if s1 is less than (alphabetical order) s2 , false otherwise.
eReduceType
Supported reduction types.
@ ReduceMax
Maximum of values.
Ref< IVariableSynchronizer > createSynchronizerRef(IParallelMng *pm, IItemFamily *family)
Returns an interface to synchronize variables on the group of the family family.
ArrayView< Int64 > Int64ArrayView
C equivalent of a 1D array of 64-bit integers.
bool arcaneIsCheck()
True if running in check mode.
UniqueArray< Int64 > Int64UniqueArray
Dynamic 1D array of 64-bit integers.
Collection< ItemGroup > ItemGroupCollection
Collection of mesh item groups.
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
List< ItemGroup > ItemGroupList
Array of mesh item groups.
ArrayView< Integer > IntegerArrayView
C equivalent of a 1D array of integers.
ConstArrayView< ItemInternal * > ItemInternalList
Type of the internal list of entities.
Collection< IItemFamily * > IItemFamilyCollection
Collection of item families.
ConstArrayView< Int64 > Int64ConstArrayView
C equivalent of a 1D array of 64-bit integers.
ArrayView< Int32 > Int32ArrayView
C equivalent of a 1D array of 32-bit integers.
eItemKind
Mesh entity type.
Array< Int32 > Int32Array
Dynamic one-dimensional array of 32-bit integers.
std::int32_t Int32
Signed integer type of 32 bits.