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"
60#include "arcane/mesh/internal/UniqueIdKeySortFunction.h"
62#include "arcane/core/parallel/GhostItemsVariableParallelOperation.h"
63#include "arcane/core/parallel/IStat.h"
65#include "arcane/core/IIncrementalItemConnectivity.h"
66#include "arcane/core/IItemConnectivityMng.h"
67#include "arcane/core/IItemFamilyPolicyMng.h"
69#include "arcane/core/ItemPrinter.h"
70#include "arcane/core/ConnectivityItemVector.h"
71#include "arcane/core/IndexedItemConnectivityView.h"
73#include "arcane/mesh/ItemProperty.h"
74#include "arcane/mesh/ItemData.h"
75#include "arcane/mesh/ConnectivityNewWithDependenciesTypes.h"
91 template <
typename DataType>
void
92 _offsetArrayByOne(Array<DataType>* array)
94 Array<DataType>& v = *array;
95 MeshUtils::checkResizeArray(v, v.size() + 1,
false);
97 for (
Int32 i = (n - 1); i >= 1; --i)
111 explicit InternalApi(ItemFamily* family)
119 return m_family->_unstructuredItemInternalConnectivityList();
123 return m_family->_topologyModifier();
127 return m_family->commonItemSharedInfo();
131 m_family->_addSourceConnectivity(connectivity);
135 m_family->_addTargetConnectivity(connectivity);
139 return m_family->_endAllocate();
143 return m_family->_notifyEndUpdateFromMesh();
147 return m_family->_addVariable(var);
151 return m_family->_removeVariable(var);
155 m_family->_resizeShMemVariables();
156 m_family->_resizeVariables(force_resize);
161 ItemFamily* m_family =
nullptr;
172 const String& family_name,
174 const String& shared_data_name,
175 const String& unique_ids_name,
176 const String& items_owner_name,
177 const String& items_flags_name,
178 const String& items_type_id_name,
179 const String& items_nb_parent_name,
180 const String& groups_name,
181 const String& current_id_name,
182 const String& new_owner_name,
183 const String& parent_mesh_name,
184 const String& parent_family_name,
185 const String& parent_family_depth_name,
186 const String& child_meshes_name,
187 const String& child_families_name)
272, m_internal_api(new InternalApi(this))
273, m_sub_domain(
mesh->subDomain())
275, m_item_internal_list(
mesh->meshItemInternalList())
276, m_common_item_shared_info(new
ItemSharedInfo(this, m_item_internal_list, &m_item_connectivity_list))
278, m_used_variables(&_cmpIVariablePtr)
279, m_used_shmem_variables(&_cmpIVariablePtr)
281, m_sub_domain_id(
mesh->meshPartInfo().partRank())
284 m_infos->setItemFamily(
this);
285 m_connectivity_selector_list_by_item_kind.resize(ItemInternalConnectivityList::MAX_ITEM_KIND);
294 delete m_topology_modifier;
297 delete m_local_connectivity_info;
298 delete m_global_connectivity_info;
299 delete m_item_sort_function;
300 delete m_internal_variables;
301 delete m_item_shared_infos;
303 for (ItemConnectivitySelector* ics : m_connectivity_selector_list)
306 delete m_common_item_shared_info;
307 delete m_internal_api;
314_variableName(
const String& base_name)
const
316 return m_name + base_name;
325 m_item_type_mng = m_mesh->itemTypeMng();
329 if (!m_topology_modifier)
330 m_topology_modifier =
new AbstractItemFamilyTopologyModifier(
this);
332 m_full_name = m_mesh->name() +
"_" + m_name;
334 m_local_connectivity_info =
new ItemConnectivityInfo();
335 m_global_connectivity_info =
new ItemConnectivityInfo();
337 IParallelMng* pm = m_mesh->parallelMng();
338 if (!pm->isParallel()) {
339 m_default_sub_domain_owner = 0;
340 m_is_parallel =
false;
343 m_is_parallel =
true;
353 String var_unique_ids_name(_variableName(
"FamilyUniqueIds"));
354 String var_owner_name(_variableName(
"FamilyOwner"));
355 String var_flags_name(_variableName(
"FamilyFlags"));
356 String var_typeid_name(_variableName(
"FamilyItemTypeId"));
357 String var_nb_parent_name(_variableName(
"FamilyItemNbParent"));
358 String var_count_name(_variableName(
"FamilyItemsShared"));
359 String var_groups_name(_variableName(
"FamilyGroupsName"));
360 String var_current_id_name(_variableName(
"FamilyCurrentId"));
361 String var_new_owner_name(_variableName(
"FamilyNewOwnerName"));
362 String var_parent_mesh_name(_variableName(
"ParentMeshName"));
363 String var_parent_family_name(_variableName(
"ParentFamilyName"));
364 String var_parent_family_depth_name(_variableName(
"ParentFamilyDepthName"));
365 String var_child_meshes_name(_variableName(
"ChildMeshesName"));
366 String var_child_families_name(_variableName(
"ChildFamiliesName"));
368 var_unique_ids_name, var_owner_name,
369 var_flags_name, var_typeid_name, var_nb_parent_name, var_groups_name,
370 var_current_id_name, var_new_owner_name,
371 var_parent_mesh_name, var_parent_family_name,
372 var_parent_family_depth_name,
373 var_child_meshes_name,
374 var_child_families_name);
378 m_items_unique_id = &m_internal_variables->m_items_unique_id._internalTrueData()->_internalDeprecatedValue();
379 m_items_owner = &m_internal_variables->m_items_owner._internalTrueData()->_internalDeprecatedValue();
380 m_items_flags = &m_internal_variables->m_items_flags._internalTrueData()->_internalDeprecatedValue();
381 m_items_type_id = &m_internal_variables->m_items_type_id._internalTrueData()->_internalDeprecatedValue();
382 m_items_nb_parent = &m_internal_variables->m_items_nb_parent._internalTrueData()->_internalDeprecatedValue();
385 _addOnSizeChangedObservable(m_internal_variables->m_items_unique_id);
386 _addOnSizeChangedObservable(m_internal_variables->m_items_owner);
387 _addOnSizeChangedObservable(m_internal_variables->m_items_flags);
388 _addOnSizeChangedObservable(m_internal_variables->m_items_type_id);
389 _addOnSizeChangedObservable(m_internal_variables->m_items_nb_parent);
396 m_item_sort_function = _defaultItemSortFunction();
400 if (s ==
"TRUE" || s ==
"1") {
401 info() <<
"WARNING: Using legacy 'compactItem()' without compactReference()'";
402 m_use_legacy_compact_item =
true;
407 m_do_shrink_after_allocate = (v.value() != 0);
417 return m_infos->findOne(uid);
422 return m_infos->itemsMap();
424const DynamicMeshKindInfos& ItemFamily::
430const DynamicMeshKindInfos& ItemFamily::
441 m_infos->removeOne(ItemCompatibility::_itemInternal(item));
446 m_infos->detachOne(ItemCompatibility::_itemInternal(item));
451 return m_infos->itemsInternal();
453ItemInternal* ItemFamily::
454_itemInternal(
Int32 local_id)
456 return m_infos->itemInternal(local_id);
458ItemInternal* ItemFamily::
459_allocOne(
Int64 unique_id)
461 return m_infos->allocOne(unique_id);
463ItemInternal* ItemFamily::
464_allocOne(
Int64 unique_id,
bool& need_alloc)
466 return m_infos->allocOne(unique_id, need_alloc);
468ItemInternal* ItemFamily::
469_findOrAllocOne(
Int64 uid,
bool& is_alloc)
471 return m_infos->findOrAllocOne(uid, is_alloc);
474_setHasUniqueIdMap(
bool v)
476 m_infos->setHasUniqueIdMap(v);
481 m_infos->removeMany(local_ids);
484_removeDetachedOne(Item item)
486 m_infos->removeDetachedOne(ItemCompatibility::_itemInternal(item));
491 return m_infos->kind();
500 return m_infos->nbItem();
509 return m_infos->maxUsedLocalId();
518 return m_infos->itemsInternal();
536 return m_parent_family;
545 m_parent_family = parent;
547 m_parent_family_depth = 1;
549 m_parent_family_depth = 0;
552 m_parent_family->addChildFamily(
this);
554 ARCANE_ASSERT((m_parent_family_depth < 2), (
"Not test if more than one depth level"));
563 return m_parent_family_depth;
573 m_child_families.add(true_family);
583 for (
Integer i = 0; i < m_child_families.size(); ++i) {
584 collection.add(m_child_families[i]);
595 return m_internal_variables->m_items_new_owner;
605 m_item_shared_infos->checkValid();
614 _checkValidConnectivity();
628 _computeConnectivityInfo(m_local_connectivity_info);
629 _computeConnectivityInfo(m_global_connectivity_info);
633 cs->customConnectivity()->_internalApi()->notifyEndUpdateFromMesh();
657 if (!m_parent_family) {
658 m_internal_variables->setUsed();
660 if (m_do_shrink_after_allocate)
661 _shrinkConnectivityAndPrintInfos();
668_shrinkConnectivityAndPrintInfos()
671 ItemConnectivityMemoryInfo mem_info;
672 for (ItemConnectivitySelector* cs : m_connectivity_selector_list) {
673 IIncrementalItemConnectivity* c = cs->customConnectivity();
674 c->_internalApi()->addMemoryInfos(mem_info);
676 const Int64 total_capacity = mem_info.m_total_capacity;
677 const Int64 total_size = mem_info.m_total_size;
678 Int64 ratio = 100 * (total_capacity - total_size);
679 ratio /= (total_size + 1);
681 const Int64 mega_byte = 1024 * 1024;
682 Int64 capacity_mega_byte = (mem_info.m_total_capacity * sizeof_int32) / mega_byte;
683 info() <<
"MemoryUsed for family name=" <<
name() <<
" size=" << mem_info.m_total_size
684 <<
" capacity=" << mem_info.m_total_capacity
685 <<
" capacity (MegaByte)=" << capacity_mega_byte
686 <<
" ratio=" << ratio;
689 std::ostream& o = ostr();
691 for (ItemConnectivitySelector* cs : m_connectivity_selector_list) {
692 IIncrementalItemConnectivity* c = cs->customConnectivity();
695 c->_internalApi()->shrinkMemory();
700 info() << ostr.str();
709 bool need_end_update = m_infos->changed();
710 info(4) <<
"ItemFamily::endUpdate() " <<
fullName() <<
" need_end_update?=" << need_end_update;
711 if (!need_end_update) {
717 if (m_need_prepare_dump) {
718 _computeConnectivityInfo(m_local_connectivity_info);
723 m_item_need_prepare_dump =
true;
724 _computeConnectivityInfo(m_local_connectivity_info);
729 m_connectivity_mng->setModifiedItems(
this, m_infos->addedItems(), m_infos->removedItems());
731 m_infos->finalizeMeshChanged();
740_endUpdate(
bool need_check_remove)
742 _resizeShMemVariables();
743 if (_partialEndUpdate())
746 _resizeVariables(
false);
748 <<
" hashmapsize=" << itemsMap().nbBucket()
749 <<
" nb_group=" << m_item_groups.count();
751 _updateGroups(need_check_remove);
769 _updateGroup(group,
true);
776_updateGroup(
ItemGroup group,
bool need_check_remove)
779 if (group == m_infos->allItems())
784 if (need_check_remove) {
796_updateGroups(
bool need_check_remove)
799 ItemGroup group = *i;
800 _updateGroup(group, need_check_remove);
810 _updateVariable(variable);
826_resizeVariables(
bool force_resize)
830 <<
" nb_item=" <<
nbItem()
831 <<
" currentsize=" << m_current_variable_item_size;
832 if (force_resize || (
maxLocalId() != m_current_variable_item_size)) {
833 info(4) <<
"ItemFamily::resizeVariables: name=" <<
fullName()
835 <<
" nb_item=" <<
nbItem()
836 <<
" currentsize=" << m_current_variable_item_size
838 <<
" nb_var=" << m_used_variables.size();
842 for (
IVariable* var : m_used_variables) {
843 _updateVariable(var);
852_resizeShMemVariables()
854 for (IVariable* var : m_used_shmem_variables) {
855 _updateVariable(var);
863itemsUniqueIdToLocalId(ArrayView<Int64> ids,
bool do_fatal)
const
865 m_infos->itemsUniqueIdToLocalId(ids, do_fatal);
876 m_infos->itemsUniqueIdToLocalId(local_ids, unique_ids, do_fatal);
887 m_infos->itemsUniqueIdToLocalId(local_ids, unique_ids, do_fatal);
923 return m_mesh->parallelMng();
932 _checkNeedEndUpdate();
933 return m_infos->allItems();
942 debug(
Trace::High) <<
"ItemFamily:createGroup(name,Int32ConstArrayView): " << m_name <<
":"
943 <<
" group_name=" <<
name
944 <<
" count=" << elements.
size()
945 <<
" override=" << do_override;
947 _checkNeedEndUpdate();
975 fatal() <<
"Attempting to create an already existing group '" <<
name <<
"'";
978 debug() <<
"ItemFamily:createGroup(name): " << m_name <<
":"
981 _processNewGroup(group);
995 fatal() <<
"Group already existing but with a different parent";
997 fatal() <<
"A group can not be its own parent name=" <<
name;
1000 fatal() <<
"Attempting to create an already existing group '" <<
name <<
"'";
1003 fatal() <<
"Attempting to create a group '" <<
name <<
"' with no parent.";
1004 debug() <<
"ItemFamily:createGroup(name,parent): " << m_name <<
":"
1006 <<
" parent=" << parent.
name();
1008 _processNewGroup(group);
1018 _invalidateComputedGroups();
1020 m_item_groups.clear();
1024 m_item_groups.add(group);
1037 debug() <<
"ItemFamily::notifyItemsOwnerChanged()";
1044 for (
Integer i = 0; i < m_child_families.size(); ++i) {
1047 for (
Integer z = 0, zs = items.
size(); z < zs; ++z) {
1048 impl::MutableItemBase item(items[z]);
1051 Item parent_item = item.parentBase(0);
1052 ARCANE_ASSERT((parent_item.
uniqueId() == item.
uniqueId()), (
"Inconsistent parent uid"));
1067 ARCANE_FATAL(
"Incoherent family name={0} wanted={1} current={2}",
1070 m_item_groups.add(group);
1071 m_need_prepare_dump =
true;
1075 if (!m_is_parallel && m_mesh->
meshPartInfo().nbPart() == 1)
1085 return m_item_groups;
1094 for (
const ItemGroup& group : m_item_groups) {
1109 if (create_if_needed)
1121 itemsMap().notifyUniqueIdsChanged();
1128_checkNeedEndUpdate()
const
1130 if (m_infos->changed())
1131 ARCANE_FATAL(
"missing call to endUpdate() after modification");
1140 info(4) <<
"ItemFamily::prepareForDump(): " <<
fullName()
1141 <<
" need=" << m_need_prepare_dump
1142 <<
" item-need=" << m_item_need_prepare_dump
1143 <<
" m_item_shared_infos->hasChanged()=" << m_item_shared_infos->hasChanged()
1144 <<
" nb_item=" << m_infos->nbItem();
1147 auto* p = m_properties;
1148 p->setInt32(
"dump-version", 0x0307);
1149 p->setInt32(
"nb-item", m_infos->nbItem());
1154 if (m_item_need_prepare_dump || m_item_shared_infos->hasChanged()) {
1155 info(4) <<
"Prepare for dump:2: name=" << m_name <<
" nb_alloc=" << m_nb_allocate_info
1156 <<
" uid_size=" << m_items_unique_id->size() <<
" cap=" << m_items_unique_id->capacity()
1157 <<
" byte=" << m_items_unique_id->capacity() *
sizeof(
Int64);
1163 m_infos->prepareForDump();
1164 m_item_shared_infos->prepareForDump();
1165 m_need_prepare_dump =
true;
1167 m_item_need_prepare_dump =
false;
1168 if (m_need_prepare_dump) {
1169 Integer nb_item = m_infos->nbItem();
1171 _resizeItemVariables(nb_item,
true);
1174 <<
" saveid=" << m_internal_variables->m_current_id();
1176 m_internal_variables->m_items_shared_data_index.resize(nb_item);
1177 IntegerArrayView items_shared_data_index(m_internal_variables->m_items_shared_data_index);
1178 info(4) <<
"ItemFamily::prepareForDump(): " << m_name
1179 <<
" count=" << nb_item <<
" currentid=" <<
m_current_id;
1182 for (
Integer i = 0; i < nb_item; ++i) {
1188 for (
Integer i = 0; i < nb_item; ++i) {
1191 items_shared_data_index[i] = isi->index();
1195 info() <<
"Item: SHARED_INDEX = " << items_shared_data_index[i]
1197 <<
" lid = " << item->
localId()
1198 <<
" dataindex = " << item->dataIndex()
1199 <<
" flags = " << item->
flags();
1207 if (m_parent_family) {
1208 m_internal_variables->m_parent_family_name = m_parent_family->name();
1209 m_internal_variables->m_parent_mesh_name = m_parent_family->mesh()->name();
1211 m_internal_variables->m_parent_family_depth = m_parent_family_depth;
1212 const Integer child_count = m_child_families.size();
1213 m_internal_variables->m_child_meshes_name.resize(child_count);
1214 m_internal_variables->m_child_families_name.resize(child_count);
1215 for (
Integer i = 0; i < child_count; ++i) {
1216 m_internal_variables->m_child_meshes_name[i] = m_child_families[i]->mesh()->name();
1217 m_internal_variables->m_child_families_name[i] = m_child_families[i]->name();
1232 m_internal_variables->m_groups_name.resize(nb_group_to_save);
1234 Integer current_group_index = 0;
1239 m_internal_variables->m_groups_name[current_group_index] = group.
name();
1240 ++current_group_index;
1249 _applyCheckNeedUpdateOnGroups();
1251 m_need_prepare_dump =
false;
1264 Int32 dump_version = 0;
1269 bool use_type_variable =
false;
1272 auto* p = m_properties;
1273 if (p->get(
"dump-version", x))
1275 if (dump_version >= 0x0307) {
1276 use_type_variable =
true;
1277 nb_item = p->getInt32(
"nb-item");
1278 Int32 cid = p->getInt32(
"current-change-id");
1279 Int32 expected_cid = m_internal_variables->m_current_id();
1280 if (cid != expected_cid)
1281 ARCANE_FATAL(
"Bad value for current id mesh={0} id={1} expected={2}",
1286 const bool allow_old_version =
true;
1287 if (!allow_old_version)
1288 if (dump_version < 0x0307)
1289 ARCANE_FATAL(
"Your checkpoint is from a version of Arcane which is too old (mininum version is 3.7)");
1294 const MeshPartInfo& part_info = m_mesh->meshPartInfo();
1295 m_sub_domain_id = part_info.partRank();
1296 if (m_infos->allItems().isOwn() && part_info.nbPart() > 1)
1297 m_infos->allItems().setOwn(
false);
1306 IntegerArrayView items_shared_data_index(m_internal_variables->m_items_shared_data_index);
1307 if (!use_type_variable)
1308 nb_item = items_shared_data_index.
size();
1310 info(4) <<
"ItemFamily::readFromDump(): " <<
fullName()
1311 <<
" count=" << nb_item
1313 <<
" saveid=" << m_internal_variables->m_current_id()
1314 <<
" use_type_variable?=" << use_type_variable
1315 <<
" dump_version=" << dump_version;
1317 if (!use_type_variable) {
1324 _handleOldCheckpoint();
1328 if (m_internal_variables->m_current_id() ==
m_current_id) {
1329 debug() <<
"Family unchanged. Nothing to do.";
1336 _invalidateComputedGroups();
1343 m_current_variable_item_size = 0;
1347 IMeshMng* mesh_mng = m_mesh->meshMng();
1348 if (!m_internal_variables->m_parent_mesh_name().null()) {
1350 m_parent_family = parent_mesh->
findItemFamily(m_internal_variables->m_parent_family_name(),
true);
1352 m_parent_family_depth = m_internal_variables->m_parent_family_depth();
1353 ARCANE_ASSERT((m_internal_variables->m_child_meshes_name.size() == m_internal_variables->m_child_families_name.size()),
1354 (
"Incompatible child mesh/family sizes"));
1355 Integer child_count = m_internal_variables->m_child_families_name.size();
1356 for (
Integer i = 0; i < child_count; ++i) {
1359 m_child_families.add(
dynamic_cast<ItemFamily*
>(child_family));
1363 m_item_shared_infos->readFromDump();
1364 m_infos->readFromDump();
1369 if (use_type_variable) {
1371 for (
Integer i = 0; i < nb_item; ++i) {
1373 ItemTypeId type_id{ m_common_item_shared_info->m_type_ids[i] };
1375 Int64 uid = m_items_unique_id_view[i];
1377 item->_setSharedInfo(isi->sharedInfo(), type_id);
1382 auto item_shared_infos = m_item_shared_infos->itemSharedInfos();
1383 for (
Integer i = 0; i < nb_item; ++i) {
1384 Integer shared_data_index = items_shared_data_index[i];
1386 Int64 uid = m_items_unique_id_view[i];
1388 item->_setSharedInfo(isi->sharedInfo(), isi->itemTypeId());
1394 m_infos->allItems().clear();
1397 for (
auto& c : m_source_incremental_item_connectivities)
1398 c->notifyReadFromDump();
1404 _invalidateComputedGroups();
1415_applyCheckNeedUpdateOnGroups()
1420 if (group == m_infos->allItems())
1430_invalidateComputedGroups()
1436 ItemGroup group = *i;
1437 if (!group.internal()->parentGroup().null()) {
1454 debug() <<
"ItemFamily::readFromDump(): number of group: " << groups_var.
size();
1455 for (
Integer i = 0, is = groups_var.
size(); i < is; ++i) {
1457 debug() <<
"Readign group again: " <<
name;
1465 for (
ItemGroup& group : m_item_groups) {
1466 group.incrementTimestamp();
1482 if (global_changed != 0)
1502 m_need_prepare_dump =
true;
1510 m_item_need_prepare_dump =
true;
1523 if (!m_use_legacy_compact_item) {
1526 _applyCheckNeedUpdateOnGroups();
1558 m_infos->beginCompactItems(compact_infos);
1561 m_infos->checkValid();
1566 for (
auto& c : m_source_incremental_item_connectivities)
1567 c->notifySourceFamilyLocalIdChanged(new_to_old_ids);
1569 for (
auto& c : m_target_incremental_item_connectivities)
1570 c->notifyTargetFamilyLocalIdChanged(old_to_new_ids);
1573 c->notifySourceFamilyLocalIdChanged(new_to_old_ids);
1576 c->notifyTargetFamilyLocalIdChanged(old_to_new_ids);
1583 if (m_parent_family_depth > 0)
1594finishCompactItems(ItemFamilyCompactInfos& compact_infos)
1597 m_infos->checkValid();
1599 m_infos->finishCompactItems(compact_infos);
1601 for (ItemConnectivitySelector* ics : m_connectivity_selector_list)
1602 ics->compactConnectivities();
1617 ARCANE_ASSERT(source.size() == destination.
size(),
1618 (
"Can't copy. Source and destination have different size !"));
1620 if (source.size() != 0) {
1621 for (
IVariable* var : m_used_variables) {
1628 for (
IVariable* var : m_used_shmem_variables) {
1650 ARCANE_ASSERT(first_source.
size() == destination.
size(),
1651 (
"Can't copy. : first_source and destination have different size !"));
1652 ARCANE_ASSERT(second_source.
size() == destination.
size(),
1653 (
"Can't copy : second_source and destination have different size !"));
1655 if (first_source.
size() != 0) {
1656 for (
IVariable* var : m_used_variables) {
1661 for (
IVariable* var : m_used_shmem_variables) {
1683 for (
IVariable* var : m_used_variables) {
1687 for (
IVariable* var : m_used_shmem_variables) {
1692 m_variable_synchronizer->changeLocalIds(old_to_new_ids);
1702 for (
Integer i = 0; i < m_child_families.size(); ++i)
1707 <<
" nb_item=" <<
nbItem();
1712 m_current_variable_item_size =
nbItem();
1725compactConnectivities()
1730 c->notifySourceFamilyLocalIdChanged(new_to_old_ids);
1733 c->notifyTargetFamilyLocalIdChanged(old_to_new_ids);
1747 if (m_parent_family_depth > 1)
1750 ARCANE_ASSERT((
nbItem() == 0 || !old_to_new_lids.
empty()), (
"Empty oldToNewLocalIds"));
1751 debug() <<
"\tfrom parent family " << m_parent_family->name();
1752 if (
this == m_parent_family)
1755 for (
Integer z = 0, zs = items.
size(); z < zs; ++z) {
1757 Int32 old_parent_lid = item->parentId(0);
1758 item->
setParent(0, old_to_new_lids[old_parent_lid]);
1771 ARCANE_UNUSED(local_ids);
1772 ARCANE_UNUSED(keep_ghost);
1785 if (m_sub_domain_id != part_rank)
1786 ARCANE_FATAL(
"Family {0} Bad value for partRank ({1}) expected={2}",
1787 fullName(), m_sub_domain_id, part_rank);
1795_reserveInfosMemory(
Integer memory)
1797 ARCANE_UNUSED(memory);
1806 ARCANE_UNUSED(new_size);
1815 ARCANE_UNUSED(memory);
1823_findSharedInfo(ItemTypeInfo*
type)
1825 return m_item_shared_infos->findSharedInfo(type);
1835 m_need_prepare_dump =
true;
1842_allocateInfos(ItemInternal* item,
Int64 uid, ItemTypeInfo*
type)
1844 ItemSharedInfoWithType* isi = _findSharedInfo(type);
1845 _allocateInfos(item, uid, isi);
1852_resizeItemVariables(
Int32 new_size,
bool force_resize)
1854 bool is_resize = MeshUtils::checkResizeArray(*m_items_unique_id, new_size + 1, force_resize);
1855 is_resize |= MeshUtils::checkResizeArray(*m_items_owner, new_size + 1, force_resize);
1856 is_resize |= MeshUtils::checkResizeArray(*m_items_flags, new_size + 1, force_resize);
1857 is_resize |= MeshUtils::checkResizeArray(*m_items_type_id, new_size + 1, force_resize);
1858 if (m_parent_family_depth > 0)
1859 is_resize |= MeshUtils::checkResizeArray(*m_items_nb_parent, new_size, force_resize);
1865 (*m_items_unique_id)[0] = NULL_ITEM_UNIQUE_ID;
1866 (*m_items_flags)[0] = 0;
1867 (*m_items_owner)[0] = A_NULL_RANK;
1868 (*m_items_type_id)[0] = IT_NullType;
1879 Int32 local_id = item->localId();
1880 _resizeItemVariables(local_id + 1,
false);
1885 ItemTypeId iti = isi->itemTypeId();
1886 item->_setSharedInfo(isi->sharedInfo(), iti);
1888 item->reinitialize(uid, m_default_sub_domain_owner, m_sub_domain_id);
1889 ++m_nb_allocate_info;
1891 for (
auto& c : m_source_incremental_item_connectivities)
1892 c->notifySourceItemAdded(ItemLocalId(local_id));
1902 return m_infos->nbItem() == 0 && m_infos->hasNoItemInternal();
1924 m_infos->allocMany(uids, lids);
1925 const Int32 max_local_id = lids[nb - 1];
1926 _resizeItemVariables(max_local_id + 1,
false);
1931 for (
Int32 i = 0; i < nb; ++i) {
1933 item->_setSharedInfo(shared_info, iti);
1934 item->reinitialize(uids[i], owner, m_sub_domain_id);
1936 m_nb_allocate_info += nb;
1938 for (
auto& c : m_source_incremental_item_connectivities)
1939 c->_internalNotifySourceItemsAdded(lids);
1946_preAllocate(
Int32 nb_item,
bool pre_alloc_connectivity)
1949 m_infos->itemsMap().resize(nb_item,
true);
1950 _resizeItemVariables(nb_item,
false);
1951 for (
auto& c : m_source_incremental_item_connectivities)
1952 c->reserveMemoryForNbSourceItems(nb_item, pre_alloc_connectivity);
1959_notifyDataIndexChanged()
1973 sub_domains.
copy(ranks);
1986 if (m_is_parallel && m_mesh->meshPartInfo().nbPart() ==
parallelMng()->commSize()) {
1987 m_variable_synchronizer->compute();
2025 return &m_items_unique_id_view;
2041 if (!var && throw_exception) {
2069 info() <<
"ItemFamily::checkUniqueIds name=" <<
name() <<
" n=" << nb_item
2070 <<
" total=" << all_unique_ids.
size();
2071 for (
Integer i = 0; i < nb_item; ++i)
2072 items_map.
add(unique_ids[i], 0);
2073 for (
Integer i = 0, is = all_unique_ids.
size(); i < is; ++i) {
2078 for (
Integer i = 0; i < nb_item; ++i) {
2079 Integer nb_ref = items_map[unique_ids[i]];
2081 fatal() <<
"Duplicate unique_id=" << unique_ids[i];
2101 auto i = m_adjacency_groups.find(at);
2103 if (i == m_adjacency_groups.end()) {
2104 debug() <<
"** BUILD ADJENCY_ITEMS : " << group.
name() <<
" x "
2105 << sub_group.
name() <<
" link=" << link_kind <<
" nblayer=" << layer;
2108 m_adjacency_groups.insert(std::make_pair(at, v));
2111 debug() <<
"** FOUND KNOWN ADJENCY_ITEMS! : " << group.
name() <<
" x "
2112 << sub_group.
name() <<
" link=" << link_kind <<
" nblayer=" << layer;
2122 return m_local_connectivity_info;
2131 return m_global_connectivity_info;
2179 ARCANE_FATAL(
"Can not add a variable to a different family");
2182 m_used_shmem_variables.insert(var);
2184 m_used_variables.insert(var);
2195 m_used_shmem_variables.erase(var);
2197 m_used_variables.erase(var);
2206 for (
IVariable* var : m_used_variables) {
2207 collection.add(var);
2209 for (
IVariable* var : m_used_shmem_variables) {
2210 collection.add(var);
2220 return m_variable_synchronizer.get();
2229 if (m_item_sort_function == sort_function)
2231 delete m_item_sort_function;
2232 m_item_sort_function = sort_function;
2233 if (!m_item_sort_function)
2234 m_item_sort_function = _defaultItemSortFunction();
2243 return m_item_sort_function;
2252 m_variable_synchronizer->synchronize(variables);
2261 m_variable_synchronizer->synchronize(variables, local_ids);
2270 ARCANE_UNUSED(unique_ids);
2271 ARCANE_UNUSED(items);
2272 ARCANE_UNUSED(owners);
2282 if (!m_mesh->itemFamilyNetwork())
2283 ARCANE_FATAL(
"Family name='{0}': IMesh::itemFamilyNetwork() is null",
name());
2292 for (
auto child_connectivity : child_connectivities) {
2293 child_families.
add(child_connectivity->targetFamily());
2294 child_families_to_current_family.
add(m_mesh->itemFamilyNetwork()->getConnectivity(child_families.
back(),
this, connectivityName(child_families.
back(),
this)));
2295 if (child_families_to_current_family.
back() ==
nullptr)
2296 fatal() <<
"removeItems2 needs reverse connectivity. Missing Connectivity " << connectivityName(child_families.
back(),
this);
2298 child_families_has_extra_parent_properties.
back().resize(child_families.
back(),
false);
2299 for (
auto parent_connectivity : m_mesh->itemFamilyNetwork()->getParentDependencies(child_families.
back())) {
2300 if (parent_connectivity == child_connectivity)
2303 _getConnectedItems(parent_connectivity, connected_items);
2304 _fillHasExtraParentProperty(child_families_has_extra_parent_properties[index], connected_items);
2310 for (
auto removed_item_lid_int64 : removed_item_lids) {
2311 Int32 removed_item_lid = CheckedConvert::toInt32(removed_item_lid_int64);
2313 for (
auto child_connectivity : child_connectivities) {
2316 if (!this->
itemsInternal()[removed_item_lid]->isDetached()) {
2317 child_families_to_current_family[index]->removeConnectedItem(
ItemLocalId(connected_item),
ItemLocalId(removed_item_lid));
2320 if (!child_families_has_extra_parent_properties[index][connected_item] && child_families_to_current_family[index]->nbConnectedItem(
ItemLocalId(connected_item)) == 0) {
2321 item_data_list[child_connectivity->targetFamily()->itemKind()].itemInfos().add((
Int64)connected_item.localId());
2329 for (
auto removed_item_lid_int64 : removed_item_lids) {
2330 Int32 removed_item_lid = CheckedConvert::toInt32(removed_item_lid_int64);
2331 for (
auto child_relation : m_mesh->itemFamilyNetwork()->getChildRelations(
this)) {
2340 is_removed_item.resize(
this,
false);
2341 for (
auto removed_item_lid_int64 : removed_item_lids) {
2342 Int32 removed_item_lid = CheckedConvert::toInt32(removed_item_lid_int64);
2343 is_removed_item[*(this->
itemsInternal()[removed_item_lid])] =
true;
2345 for (
auto parent_relation : m_mesh->itemFamilyNetwork()->getParentRelations(
this)) {
2346 for (
auto source_item : parent_relation->sourceFamily()->itemsInternal()) {
2347 if (source_item->isSuppressed())
2351 if (is_removed_item[connected_item])
2352 parent_relation->removeConnectedItem(
ItemLocalId(source_item), connected_item);
2357 for (
auto removed_item_lid_int64 : removed_item_lids) {
2358 Int32 removed_item_lid = CheckedConvert::toInt32(removed_item_lid_int64);
2359 ItemInternal* removed_item = m_infos->itemInternal(removed_item_lid);
2361 m_infos->removeDetachedOne(removed_item);
2364 m_infos->removeOne(removed_item);
2378 if (source_item->isSuppressed())
2380 target_family_connected_items.
add(connectivity_accessor.connectedItems(
ItemLocalId(source_item)).localIds());
2388_fillHasExtraParentProperty(ItemScalarProperty<bool>& child_families_has_extra_parent, ItemVectorView connected_items)
2391 child_families_has_extra_parent[connected_item] =
true;
2402 ARCANE_ASSERT((m_mesh->itemFamilyNetwork()->getParentDependencies(
this).empty()), (
"Only cells are detached, no parent dependencies are to be found."))
2405 for (auto removed_item_lid : local_ids) {
2406 for (
auto child_relation : m_mesh->itemFamilyNetwork()->getChildRelations(
this)) {
2407 ConnectivityItemVector connectivity_accessor(child_relation);
2408 ENUMERATE_ITEM (connected_item, connectivity_accessor.connectedItems(ItemLocalId(removed_item_lid))) {
2409 child_relation->removeConnectedItem(ItemLocalId(removed_item_lid), ItemLocalId(connected_item));
2414 ItemScalarProperty<bool> is_detached_item;
2415 is_detached_item.resize(
this,
false);
2416 for (
auto detached_item_lid : local_ids) {
2417 is_detached_item[*(this->itemsInternal()[detached_item_lid])] =
true;
2419 for (
auto parent_relation : m_mesh->itemFamilyNetwork()->getParentRelations(
this)) {
2420 for (auto source_item : parent_relation->sourceFamily()->itemsInternal()) {
2421 if (source_item->isSuppressed())
2423 ConnectivityItemVector connectivity_accessor(parent_relation);
2424 ENUMERATE_ITEM (connected_item, connectivity_accessor.connectedItems(ItemLocalId(source_item))) {
2425 if (is_detached_item[connected_item]) {
2426 parent_relation->removeConnectedItem(ItemLocalId(source_item), connected_item);
2432 for (
auto detached_item_lid : local_ids) {
2433 m_infos->detachOne(m_infos->itemInternal(detached_item_lid));
2441removeNeedRemoveMarkedItems()
2443 ItemInternalMap& item_map = itemsMap();
2444 if (item_map.
count() == 0)
2447 if (!m_mesh->itemFamilyNetwork())
2448 ARCANE_FATAL(
"Family name='{0}': IMesh::itemFamilyNetwork() is null",
name());
2449 if (!IItemFamilyNetwork::plug_serializer)
2450 ARCANE_FATAL(
"family name='{0}': removeNeedMarkedItems() cannot be called if ItemFamilyNetwork is unplugged.",
name());
2454 items_to_remove.
reserve(1000);
2455 items_to_remove_lids.
reserve(1000);
2457 item_map.
eachItem([&](impl::ItemBase item) {
2462 items_to_remove.
add(item._itemInternal());
2466 info() <<
"Number of " <<
itemKind() <<
" of family " <<
name() <<
" to remove: " << items_to_remove.
size();
2467 if (items_to_remove.
size() == 0)
2473 is_removed_item.resize(
this,
false);
2474 for (
auto removed_item : items_to_remove) {
2475 is_removed_item[*removed_item] =
true;
2478 for (
auto parent_connectivity : m_mesh->itemFamilyNetwork()->getParentRelations(
this)) {
2480 if (source_item->isSuppressed())
2484 if (is_removed_item[connected_item]) {
2491 m_infos->removeMany(items_to_remove_lids);
2519_defaultItemSortFunction()
2521 auto comparison_sort = std::make_unique<ItemInternalSortFunction<CompareUniqueIdWithSuppression>>(
"ArcaneUniqueId");
2523 if (use_legacy && use_legacy.value() != 0)
2524 return comparison_sort.release();
2525 return std::make_unique<UniqueIdKeySortFunction>(
"ArcaneUniqueId", std::move(comparison_sort)).release();
2534 if (m_policy_mng == policy_mng)
2538 m_policy_mng = policy_mng;
2545addSourceConnectivity(IItemConnectivity* connectivity)
2547 m_source_item_connectivities.insert(connectivity);
2556 m_target_item_connectivities.insert(connectivity);
2565 m_source_item_connectivities.erase(m_source_item_connectivities.find(connectivity));
2574 m_target_item_connectivities.erase(m_target_item_connectivities.find(connectivity));
2583 ARCANE_ASSERT((m_connectivity_mng == NULL || m_connectivity_mng == connectivity_mng),
2584 (
"Connectivity Manager must be unique"))
2585 m_connectivity_mng = connectivity_mng;
2594 return m_infos->itemListChangedEvent();
2605 if (old_uid == unique_id)
2608 iitem->setUniqueId(unique_id);
2610 if (m_infos->hasUniqueIdMap()) {
2611 ItemInternalMap& item_map = itemsMap();
2612 item_map.
remove(old_uid);
2613 item_map.
add(unique_id, iitem);
2639_checkValidConnectivity()
2646 ARCANE_FATAL(
"family={0}: local item lid={1} is null", fullName(), item);
2654 Item i2 = m_common_item_shared_info->m_items_internal[item.localId()];
2656 ARCANE_FATAL(
"family={0}: incoherent item internal lid={1} i1={2} i2={3}",
2660 constexpr Int32 MAX_KIND = ItemInternalConnectivityList::MAX_ITEM_KIND;
2661 std::array<Int32, MAX_KIND> computed_max;
2662 computed_max.fill(0);
2664 for (
Integer i = 0; i < MAX_KIND; ++i) {
2667 Int32 stored_max_nb = m_item_connectivity_list.maxNbConnectedItem(i);
2668 const Int32 con_nb_item_size = con_view.nbSourceItem();
2670 info(4) <<
"Family name=" << fullName() <<
" I=" << i <<
" nb_item_size=" << con_nb_item_size;
2673 if (con_nb_item_size != 0) {
2678 Int32 x = con_view.nbItem(i);
2682 if (stored_max_nb < max_nb)
2683 ARCANE_FATAL(
"Bad value for max connected item family={0} kind={1} stored={2} computed={3}",
2684 name(), i, stored_max_nb, max_nb);
2685 computed_max[i] = max_nb;
2691 std::array<Int32, MAX_KIND> stored_max;
2693 auto* ci = m_local_connectivity_info;
2694 stored_max[ItemInternalConnectivityList::NODE_IDX] = ci->maxNodePerItem();
2695 stored_max[ItemInternalConnectivityList::EDGE_IDX] = ci->maxEdgePerItem();
2696 stored_max[ItemInternalConnectivityList::FACE_IDX] = ci->maxFacePerItem();
2697 stored_max[ItemInternalConnectivityList::CELL_IDX] = ci->maxCellPerItem();
2700 stored_max[ItemInternalConnectivityList::HPARENT_IDX] = computed_max[ItemInternalConnectivityList::HPARENT_IDX];
2701 stored_max[ItemInternalConnectivityList::HCHILD_IDX] = computed_max[ItemInternalConnectivityList::HCHILD_IDX];
2702 for (
Integer i = 0; i < MAX_KIND; ++i)
2703 if (stored_max[i] < computed_max[i])
2704 ARCANE_FATAL(
"Bad value for local_connectivity_info family={0} kind={1} stored={2} computed={3}",
2705 name(), i, stored_max[i], computed_max[i]);
2707 for (
auto ics : m_connectivity_selector_list)
2708 ics->checkValidConnectivityList();
2715_addConnectivitySelector(ItemConnectivitySelector* selector)
2717 m_connectivity_selector_list.add(selector);
2724_buildConnectivitySelectors()
2726 m_connectivity_selector_list_by_item_kind.clear();
2727 m_connectivity_selector_list_by_item_kind.resize(ItemInternalConnectivityList::MAX_ITEM_KIND);
2728 m_connectivity_selector_list_by_item_kind.fill(
nullptr);
2730 for (ItemConnectivitySelector* ics : m_connectivity_selector_list) {
2732 Int32 i = ics->itemConnectivityIndex();
2734 if (m_connectivity_selector_list_by_item_kind[i])
2735 ARCANE_FATAL(
"Can not have two connectivity selector for same item kind");
2736 m_connectivity_selector_list_by_item_kind[i] = ics;
2747 delete m_topology_modifier;
2748 m_topology_modifier = tm;
2761_updateItemsSharedFlag()
2770 for (
Integer i = 0; i < nb_rank; ++i) {
2772 for (
auto id : shared_ids)
2783 ici->fill(itemInternalConnectivityList());
2784 info(5) <<
"COMPUTE CONNECTIVITY INFO family=" << name() <<
" v=" << ici
2793_handleOldCheckpoint()
2797 _offsetArrayByOne(m_items_unique_id);
2798 _offsetArrayByOne(m_items_flags);
2799 _offsetArrayByOne(m_items_owner);
2800 (*m_items_unique_id)[0] = NULL_ITEM_UNIQUE_ID;
2801 (*m_items_flags)[0] = 0;
2802 (*m_items_owner)[0] = A_NULL_RANK;
2812 template <
typename DataType>
2813 ArrayView<DataType> _getView(Array<DataType>* v)
2815 Int32 n = v->size();
2816 return v->subView(1, n - 1);
2824 m_common_item_shared_info->m_unique_ids = _getView(m_items_unique_id);
2825 m_common_item_shared_info->m_flags = _getView(m_items_flags);
2826 m_common_item_shared_info->m_type_ids = _getView(m_items_type_id);
2827 m_common_item_shared_info->m_owners = _getView(m_items_owner);
2828 m_common_item_shared_info->m_parent_item_ids = m_items_nb_parent->view();
2830 m_items_unique_id_view = _getView(m_items_unique_id);
2839 m_observers.addObserver(
this, &ItemFamily::_updateItemViews,
2840 var_ref.variable()->onSizeChangedObservable());
2849 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)
Template class for converting a type.
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 ...
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).
Info on a mesh entity type.
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.
Selection between historical and on-demand connectivities.
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 canAllocateBulk() const
Whether _allocateInfosBulk() can be used: nothing allocated, nothing freed.
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
void _allocateInfosBulk(Int64ConstArrayView uids, ItemTypeInfo *type, Int32 owner, Int32ArrayView lids)
Allocates every item of uids at once.
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.