16#include "arcane/mesh/PolyhedralMesh.h"
18#include "ItemFamilyNetwork.h"
19#include "ItemFamilyPolicyMng.h"
20#include "ItemGroupsSynchronize.h"
21#include "arcane/mesh/MeshExchangeMng.h"
22#include "arcane/core/ISubDomain.h"
23#include "arcane/core/ItemSharedInfo.h"
24#include "arcane/core/ItemTypeInfo.h"
25#include "arcane/core/ItemTypeMng.h"
26#include "arcane/core/VariableBuildInfo.h"
27#include "arcane/core/MeshBuildInfo.h"
29#include "arcane/core/AbstractService.h"
30#include "arcane/core/CommonVariables.h"
31#include "arcane/core/IMeshFactory.h"
32#include "arcane/core/ItemInternal.h"
33#include "arcane/core/IDoFFamily.h"
34#include "arcane/core/IMeshCompactMng.h"
35#include "arcane/core/IMeshCompacter.h"
36#include "arcane/core/IMeshExchanger.h"
37#include "arcane/core/IGhostLayerMng.h"
38#include "arcane/core/MeshVisitor.h"
39#include "arcane/core/internal/IItemFamilyInternal.h"
40#include "arcane/core/internal/IItemFamilySerializerMngInternal.h"
41#include "arcane/core/internal/IVariableMngInternal.h"
42#include "arcane/core/internal/IPolyhedralMeshModifier.h"
43#include "arcane/core/internal/IMeshModifierInternal.h"
44#include "arcane/core/Connectivity.h"
45#include "arcane/core/MeshStats.h"
47#include "arcane/mesh/ItemFamily.h"
48#include "arcane/mesh/DynamicMeshKindInfos.h"
49#include "arcane/mesh/UnstructuredMeshUtilities.h"
50#include "arcane/mesh/GhostLayerMng.h"
51#include "arcane/utils/ITraceMng.h"
52#include "arcane/utils/FatalErrorException.h"
53#include "arccore/base/StringBuilder.h"
55#ifdef ARCANE_HAS_POLYHEDRAL_MESH_TOOLS
57#include "arcane/core/IMeshMng.h"
58#include "arcane/core/MeshHandle.h"
59#include "arcane/core/IItemFamily.h"
60#include "arcane/core/internal/IMeshInternal.h"
61#include "arcane/core/IVariableSynchronizer.h"
62#include "arcane/mesh/ItemFamilyPolicyMng.h"
63#include "arcane/mesh/ItemFamilySerializer.h"
64#include "arcane/utils/Collection.h"
65#include "arcane/utils/List.h"
66#include "arcane/utils/PlatformUtils.h"
71#include "arcane/mesh/ItemConnectivityMng.h"
72#include "arcane/core/ItemPrinter.h"
73#include "arcane/mesh/FaceFamily.h"
74#include "arcane/mesh/GhostLayerBuilder.h"
79#define ARCANE_DEBUG_LOAD_BALANCING
81#ifdef ARCANE_DEBUG_LOAD_BALANCING
82static bool arcane_debug_load_balancing =
true;
84static bool arcane_debug_load_balancing =
false;
90void Arcane::mesh::PolyhedralMesh::
91_errorEmptyMesh()
const
93 ARCANE_FATAL(
"Cannot use PolyhedralMesh if Arcane is not linked with lib Neo");
99#ifdef ARCANE_HAS_POLYHEDRAL_MESH_TOOLS
104namespace Arcane::mesh
106namespace PolyhedralTools
110 Neo::FutureItemRange m_future_items;
111 std::shared_ptr<Neo::EndOfMeshUpdate> m_mesh_state =
nullptr;
115 void fillArrayView(Int32ArrayView local_ids, Neo::EndOfMeshUpdate mesh_state)
117 auto lids = m_future_items.get(mesh_state);
118 if (local_ids.size() != lids.size())
119 ARCANE_FATAL(
"Cannot fill local_ids view, its size {0} != {1} (added item size)", local_ids.size(), m_future_items.size());
120 std::copy(lids.begin(), lids.end(), local_ids.begin());
123 void fillArrayView(Int32ArrayView local_ids)
125 ARCANE_CHECK_POINTER2(m_mesh_state.get(),
"PolyhedralTools::ItemLocalIds must have a valid end of mesh state");
126 fillArrayView(local_ids, *m_mesh_state);
129 Integer size() const noexcept {
return m_future_items.size(); }
130 bool isFilled() const noexcept {
return m_mesh_state.get() !=
nullptr; };
131 void checkIsFilled(String error_message)
const noexcept
134 ARCANE_FATAL(
"Item local ids are not filled." + error_message);
136 friend class mesh::PolyhedralMeshImpl;
137 friend class mesh::PolyhedralMesh;
144class PolyhedralFamilySerializer;
145class PolyhedralFamilySerializerMng :
public IItemFamilySerializerMngInternal
147 PolyhedralMesh* m_mesh =
nullptr;
149 UniqueArray<PolyhedralFamilySerializer*> m_serializers;
153 explicit PolyhedralFamilySerializerMng(PolyhedralMesh* mesh)
159 void addSerializer(PolyhedralFamilySerializer* serializer)
161 m_serializers.push_back(serializer);
165 void finalizeItemAllocation()
override;
171class PolyhedralFamilySerializer :
public IItemFamilySerializer
175 PolyhedralMesh* m_mesh =
nullptr;
176 IItemFamily* m_family =
nullptr;
177 PolyhedralFamilySerializerMng* m_mng =
nullptr;
178 ItemData m_item_data;
179 UniqueArray<Int32Array*> m_deserialized_lids_array;
180 UniqueArray<std::shared_ptr<PolyhedralTools::ItemLocalIds>> m_future_item_lids_array;
181 ItemAllocationInfo::FamilyInfo m_family_info;
185 explicit PolyhedralFamilySerializer(PolyhedralMesh* mesh, IItemFamily* family, PolyhedralFamilySerializerMng* mng)
191 PolyhedralFamilySerializer(
const PolyhedralFamilySerializer&) =
delete;
192 PolyhedralFamilySerializer& operator=(
const PolyhedralFamilySerializer&) =
delete;
194 ArrayView<std::shared_ptr<PolyhedralTools::ItemLocalIds>> itemLidsArray() {
return m_future_item_lids_array.view(); }
198 void serializeItems(ISerializer* buf, Int32ConstArrayView items_local_ids)
override;
199 void deserializeItems(ISerializer* buf, Int32Array* items_local_ids)
override;
204 m_deserialized_lids_array.clear();
205 m_future_item_lids_array.clear();
206 m_family_info.clear();
209 void fillDeserializedLocalIds()
212 for (
auto item_lids_array : m_deserialized_lids_array) {
213 auto& future_item_lids = m_future_item_lids_array[index];
214 future_item_lids->checkIsFilled(
"Cannot fill deserialized local ids, future item local ids are not filled.");
215 item_lids_array->resize(future_item_lids->size());
216 future_item_lids->fillArrayView(item_lids_array->view());
222 IItemFamilySerializerMngInternal* mng()
228 void serializeItemRelations(ISerializer*, Int32ConstArrayView)
override {}
229 void deserializeItemRelations(ISerializer*, Int32Array*)
override {}
233 void _fillItemData(Int32ConstArrayView items_local_ids);
234 void _fillItemFamilyInfo(
const ItemData& item_data,
235 StringConstArrayView connected_family_names,
236 StringConstArrayView connectivity_names)
239 m_family_info.clear();
241 if (m_family != item_data.itemFamily())
242 ARCANE_FATAL(
"PolyhedralFamilySerializer: Family mismatch. Synchronized family is {0} and serialized family is {1}",
243 m_family->name(), item_data.itemFamily()->name());
244 m_family_info.name = item_data.itemFamily()->name();
245 m_family_info.item_kind = item_data.itemFamily()->itemKind();
246 auto& connected_family_infos = m_family_info.connected_family_infos;
247 auto nb_connected_family = item_data.itemInfos()[0];
248 connected_family_infos.resize(nb_connected_family);
249 auto& item_uids = m_family_info._item_uids_data;
250 item_uids.reserve(item_data.nbItems());
251 auto item_infos = item_data.itemInfos();
252 for (
auto connected_family_info : connected_family_infos) {
253 connected_family_info._connected_items_uids_data.reserve(4 * item_uids.size());
254 connected_family_info._nb_connected_items_per_item_data.reserve(item_uids.size());
256 for (
auto index = 1; index < item_infos.size();) {
257 item_uids.push_back(item_infos[index + 1]);
259 for (
auto connected_family_index = 0; connected_family_index < nb_connected_family; ++connected_family_index) {
261 auto* connected_family = m_mesh->findItemFamily(family_kind, connected_family_names[connected_family_index],
false,
false);
263 auto& current_connected_family_infos = connected_family_infos[connected_family_index];
264 current_connected_family_infos.item_kind = family_kind;
265 current_connected_family_infos.name = connected_family->name();
266 current_connected_family_infos.connectivity_name = connectivity_names[connected_family_index];
268 auto nb_connected_items =
static_cast<Int32
>(item_infos[index]);
270 current_connected_family_infos._nb_connected_items_per_item_data.push_back(nb_connected_items);
271 auto real_nb_connected_items = nb_connected_items;
272 if (m_family->itemKind() == IK_Face && connected_family->itemKind() == IK_Cell)
273 real_nb_connected_items = 2;
274 current_connected_family_infos._connected_items_uids_data.addRange(item_infos.subView(index, real_nb_connected_items));
275 index += real_nb_connected_items;
279 m_family_info.updateViewsFromInternalData();
281 m_family_info.item_owners = item_data.itemOwners();
284 IItemFamily* family()
const override
293void PolyhedralFamilySerializerMng::
294finalizeItemAllocation()
296 UniqueArray<std::shared_ptr<PolyhedralTools::ItemLocalIds>> future_item_lids;
297 for (
auto family_serializer : m_serializers) {
298 for (
auto& item_lids : family_serializer->itemLidsArray()) {
299 future_item_lids.push_back(item_lids);
302 m_mesh->applyScheduledAllocateItems(future_item_lids);
303 for (
auto family_serializer : m_serializers) {
304 family_serializer->fillDeserializedLocalIds();
306 m_serializers.clear();
312class PolyhedralFamilyPolicyMng
317 PolyhedralFamilyPolicyMng(PolyhedralMesh* mesh, ItemFamily* family)
318 : ItemFamilyPolicyMng(family)
327 return new PolyhedralFamilySerializer(m_mesh, m_family, m_mesh->polyhedralFamilySerializerMng());
332 PolyhedralMesh* m_mesh =
nullptr;
333 ItemFamily* m_family =
nullptr;
339class PolyhedralFamily
343 ItemSharedInfoWithType* m_shared_info =
nullptr;
347 PolyhedralMesh* m_mesh =
nullptr;
351 inline static const String m_arcane_item_lids_property_name{
"Arcane_Item_Lids" };
352 inline static const String m_arcane_remove_item_property_name{
"Arcane_Remove_Items" };
356 PolyhedralFamily(PolyhedralMesh* mesh, eItemKind ik, String name)
357 : ItemFamily(mesh, ik, name)
363 void preAllocate(Integer nb_item)
365 Integer nb_hash = itemsMap().nbBucket();
366 Integer wanted_size = 2 * (nb_item + nbItem());
367 if (nb_hash < wanted_size)
368 itemsMap().resize(wanted_size,
true);
369 m_empty_connectivity_indexes.resize(nb_item + nbItem(), 0);
370 m_empty_connectivity_nb_item.resize(nb_item + nbItem(), 0);
371 _updateEmptyConnectivity();
374 ItemInternal* _allocItem(
const Int64 uid,
const Int32 owner)
377 ItemInternal* item_internal = ItemFamily::_findOrAllocOne(uid, need_alloc);
379 item_internal->setUniqueId(uid);
381 _allocateInfos(item_internal, uid, m_shared_info);
383 item_internal->setOwner(owner, m_sub_domain_id);
384 return item_internal;
387 void addItems(Int64ConstSmallSpan uids, Int32ArrayView items)
390 addItems(uids, items, owners);
393 void addItems(Int64ConstSmallSpan uids, Int32ArrayView items, Int32ConstArrayView owners)
397 ARCANE_ASSERT((uids.size() == items.size()), (
"one must have items.size==uids.size()"));
398 preAllocate(uids.size());
400 for (
auto uid : uids) {
401 ItemInternal* ii = _allocItem(uid, owners[index]);
402 items[index] = ii->localId();
405 m_need_prepare_dump =
true;
406 _updateItemInternalList();
409 void removeItems(Int32ConstArrayView local_ids)
411 _removeMany(local_ids);
414 void _updateItemInternalList()
416 switch (itemKind()) {
418 m_item_internal_list->cells = _itemsInternal();
421 m_item_internal_list->faces = _itemsInternal();
424 m_item_internal_list->edges = _itemsInternal();
427 m_item_internal_list->nodes = _itemsInternal();
436 void _updateEmptyConnectivity()
438 auto item_internal_connectivity_list = itemInternalConnectivityList();
439 for (
auto item_kind = 0; item_kind < ItemInternalConnectivityList::MAX_ITEM_KIND; ++item_kind) {
440 item_internal_connectivity_list->_setConnectivityList(item_kind, m_empty_connectivity);
441 item_internal_connectivity_list->_setConnectivityIndex(item_kind, m_empty_connectivity_indexes);
442 item_internal_connectivity_list->_setConnectivityNbItem(item_kind, m_empty_connectivity_nb_item);
447 IDoFFamily* toDoFFamily()
override
453 void build()
override
456 m_sub_domain_id = subDomain()->subDomainId();
457 ItemTypeMng* itm = m_mesh->itemTypeMng();
458 ItemTypeInfo* dof_type_info = itm->typeFromId(IT_NullType);
459 m_shared_info = _findSharedInfo(dof_type_info);
460 _updateEmptyConnectivity();
461 ItemFamily::setPolicyMng(
new PolyhedralFamilyPolicyMng{ m_mesh,
this });
464 void addGhostItems(Int64ConstArrayView unique_ids, Int32ArrayView items, Int32ConstArrayView owners)
override
466 auto* polyhedral_mesh_modifier = m_mesh->_internalApi()->polyhedralMeshModifier();
468 polyhedral_mesh_modifier->addItems(unique_ids, items, owners, ItemFamily::itemKind(), name());
472 String name()
const override {
return ItemFamily::name(); }
473 String fullName()
const override {
return ItemFamily::fullName(); }
474 Integer nbItem()
const override {
return ItemFamily::nbItem(); }
475 ItemGroup allItems()
const override {
return ItemFamily::allItems(); }
476 void endUpdate()
override
478 return ItemFamily::endUpdate();
480 IItemFamily* itemFamily()
override {
return this; }
482 DoFVectorView addDoFs(Int64ConstArrayView dof_uids, Int32ArrayView dof_lids)
override
484 auto* polyhedral_mesh_modifier = m_mesh->_internalApi()->polyhedralMeshModifier();
486 polyhedral_mesh_modifier->addItems(dof_uids, dof_lids, ItemFamily::itemKind(), name());
487 return ItemFamily::view(dof_lids);
490 DoFVectorView addGhostDoFs(Int64ConstArrayView dof_uids, Int32ArrayView dof_lids,
491 Int32ConstArrayView owners)
override
493 addGhostItems(dof_uids, dof_lids, owners);
494 return ItemFamily::view(dof_lids);
497 void removeDoFs(Int32ConstArrayView items_local_id)
override
499 auto* mesh_modifier = m_mesh->_internalApi()->polyhedralMeshModifier();
500 mesh_modifier->removeItems(items_local_id, ItemFamily::itemKind(), m_name);
525 ISubDomain* m_subdomain;
526 Neo::Mesh m_mesh{
"Test" };
528 template <eItemKind IK>
531 static const Neo::ItemKind item_kind = Neo::ItemKind::IK_None;
536 static Neo::ItemKind itemKindArcaneToNeo(
eItemKind ik)
540 return Neo::ItemKind::IK_Cell;
542 return Neo::ItemKind::IK_Face;
544 return Neo::ItemKind::IK_Edge;
546 return Neo::ItemKind::IK_Node;
548 return Neo::ItemKind::IK_Dof;
551 return Neo::ItemKind::IK_None;
553 return Neo::ItemKind::IK_Node;
556 static eItemKind itemKindNeoToArcane(Neo::ItemKind ik)
559 case Neo::ItemKind::IK_Cell:
561 case Neo::ItemKind::IK_Face:
563 case Neo::ItemKind::IK_Edge:
565 case Neo::ItemKind::IK_Node:
567 case Neo::ItemKind::IK_Dof:
569 case Neo::ItemKind::IK_None:
577 explicit PolyhedralMeshImpl(ISubDomain* subDomain)
578 : m_subdomain(subDomain)
579 , m_mesh(String::format(subDomain->defaultMeshHandle().meshName(),
"Polyhedral").localstr(), subDomain->parallelMng()->commRank())
584 String name()
const {
return m_mesh.name(); }
586 Integer dimension()
const {
return m_mesh.dimension(); }
588 Integer nbNode()
const {
return m_mesh.nbNodes(); }
589 Integer nbEdge()
const {
return m_mesh.nbEdges(); }
590 Integer nbFace()
const {
return m_mesh.nbFaces(); }
591 Integer nbCell()
const {
return m_mesh.nbCells(); }
592 Integer nbItem(
eItemKind ik)
const {
return m_mesh.nbItems(itemKindArcaneToNeo(ik)); }
594 SmallSpan<const Neo::Mesh::Connectivity> connectivities(IItemFamily* source_family)
596 auto& neo_source_family = m_mesh.findFamily(itemKindArcaneToNeo(source_family->itemKind()), source_family->name().localstr());
597 auto connectivities = m_mesh.getConnectivities(neo_source_family);
598 return { connectivities.begin(), connectivities.size() };
601 static void _setFaceInfos(
Int32 mod_flags, Face& face)
603 Int32 face_flags = face.itemBase().flags();
604 face_flags &= ~ItemFlags::II_InterfaceFlags;
605 face_flags |= mod_flags;
606 face.mutableItemBase().setFlags(face_flags);
611 void addFamily(
eItemKind ik,
const String& name)
613 m_mesh.addFamily(itemKindArcaneToNeo(ik), name.localstr());
618 void scheduleAddItems(PolyhedralFamily* arcane_item_family,
620 PolyhedralTools::ItemLocalIds& item_local_ids)
627 void scheduleAddItems(PolyhedralFamily* arcane_item_family,
630 PolyhedralTools::ItemLocalIds& item_local_ids)
632 auto& added_items = item_local_ids.m_future_items;
633 auto& item_family = m_mesh.findFamily(itemKindArcaneToNeo(arcane_item_family->itemKind()),
634 arcane_item_family->name().localstr());
635 m_mesh.scheduleAddItems(item_family, std::vector<Int64>{ uids.begin(), uids.end() }, added_items);
637 auto& mesh_graph = m_mesh.internalMeshGraph();
638 item_family.addMeshScalarProperty<Neo::utils::Int32>(PolyhedralFamily::m_arcane_item_lids_property_name.localstr());
640 UniqueArray<Int64> uids_copy(uids);
641 UniqueArray<Int32> owners_copy(owners);
642 mesh_graph.addAlgorithm(Neo::MeshKernel::InProperty{ item_family, item_family.lidPropName() },
643 Neo::MeshKernel::OutProperty{ item_family, PolyhedralFamily::m_arcane_item_lids_property_name.localstr() },
644 "AddArcaneItems"+std::string{arcane_item_family->name().localstr()},
645 [arcane_item_family, uids_local=std::move(uids_copy), &added_items, owners_local=std::move(owners_copy)]
646 ([[maybe_unused]] Neo::ItemLidsProperty
const& lids_property,
647 Neo::MeshScalarPropertyT<Neo::utils::Int32>&) {
648 auto new_items_lids{added_items.new_items.localIds()};
649 Int32ConstSpan neo_items{ new_items_lids.data(),
static_cast<Int32>(new_items_lids.size()) };
650 UniqueArray<Int32> arcane_items(added_items.new_items.size());
651 if (owners_local.empty())
652 arcane_item_family->addItems(uids_local, arcane_items);
654 arcane_item_family->addItems(uids_local, arcane_items,
Int32ConstArrayView{ owners_local.size(), owners_local.data() });
656 if (!arcane_items.size() == added_items.new_items.size())
657 arcane_item_family->traceMng()->fatal() <<
"Inconsistent item lids generation between Arcane and Neo, nb items Neo "
658 << added_items.new_items.size() <<
" nb items Arcane " << arcane_items.size();
659 if (!std::equal(added_items.new_items.begin(), added_items.new_items.end(), arcane_items.begin())) {
660 arcane_item_family->traceMng()->info() <<
"Arcane Items " << arcane_items;
661 std::cout <<
"Neo Items ";
662 std::ranges::copy(neo_items,std::ostream_iterator<int>(std::cout,
" "));
664 arcane_item_family->traceMng()->fatal() <<
"Inconsistent item lids generation between Arcane and Neo in ItemFamily " << arcane_item_family->name();
671 void scheduleRemoveItems(PolyhedralFamily* arcane_item_family,
674 auto& item_family = m_mesh.findFamily(itemKindArcaneToNeo(arcane_item_family->itemKind()),
675 arcane_item_family->name().localstr());
676 Neo::ItemRange removed_items{ Neo::ItemLocalIds{ { local_ids.begin(), local_ids.end() }, 0, 0 } };
677 m_mesh.scheduleRemoveItems(item_family, removed_items);
679 auto& mesh_graph = m_mesh.internalMeshGraph();
680 item_family.addMeshScalarProperty<Neo::utils::Int32>(PolyhedralFamily::m_arcane_remove_item_property_name.localstr());
681 mesh_graph.addAlgorithm(Neo::MeshKernel::InProperty{ item_family, m_mesh._removeItemPropertyName(item_family) },
682 Neo::MeshKernel::OutProperty{ item_family, PolyhedralFamily::m_arcane_remove_item_property_name.localstr() },
683 "RemoveArcaneFamily"+std::string{arcane_item_family->name().localstr()},
684 [arcane_item_family, local_ids](Neo::MeshScalarPropertyT<Neo::utils::Int32>
const&,
685 Neo::MeshScalarPropertyT<Neo::utils::Int32>&) {
686 arcane_item_family->removeItems(local_ids);
692 void scheduleAddConnectivity(PolyhedralFamily* arcane_source_item_family,
693 PolyhedralTools::ItemLocalIds& source_items,
694 Integer nb_connected_items_per_item,
695 PolyhedralFamily* arcane_target_item_family,
700 _scheduleAddConnectivity(arcane_source_item_family,
702 nb_connected_items_per_item,
703 arcane_target_item_family,
710 void scheduleAddConnectivity(PolyhedralFamily* arcane_source_item_family,
711 PolyhedralTools::ItemLocalIds& source_items,
713 PolyhedralFamily* arcane_target_item_family,
715 String
const& connectivity_name)
717 _scheduleAddConnectivity(arcane_source_item_family,
719 std::vector<Int32>{ nb_connected_items_per_item.begin(), nb_connected_items_per_item.end() },
720 arcane_target_item_family,
728 void scheduleUpdateConnectivity(PolyhedralFamily* arcane_source_item_family,
729 PolyhedralTools::ItemLocalIds& source_items,
730 Integer nb_connected_items_per_item,
731 PolyhedralFamily* arcane_target_item_family,
736 _scheduleAddConnectivity(arcane_source_item_family,
738 nb_connected_items_per_item,
739 arcane_target_item_family,
742 Neo::Mesh::ConnectivityOperation::Modify);
747 void scheduleUpdateConnectivity(PolyhedralFamily* arcane_source_item_family,
748 PolyhedralTools::ItemLocalIds& source_items,
750 PolyhedralFamily* arcane_target_item_family,
752 String
const& connectivity_name)
754 _scheduleAddConnectivity(arcane_source_item_family,
756 std::vector<Int32>{ nb_connected_items_per_item.begin(), nb_connected_items_per_item.end() },
757 arcane_target_item_family,
760 Neo::Mesh::ConnectivityOperation::Modify);
766 template <
typename ConnectivitySizeType>
767 void _scheduleAddConnectivity(PolyhedralFamily* arcane_source_item_family,
768 PolyhedralTools::ItemLocalIds& source_items,
769 ConnectivitySizeType&& nb_connected_items_per_item,
770 PolyhedralFamily* arcane_target_item_family,
772 String
const& connectivity_name,
773 Neo::Mesh::ConnectivityOperation operation = Neo::Mesh::ConnectivityOperation::Add)
776 auto& source_family = m_mesh.findFamily(itemKindArcaneToNeo(arcane_source_item_family->itemKind()),
777 arcane_source_item_family->name().localstr());
778 auto& target_family = m_mesh.findFamily(itemKindArcaneToNeo(arcane_target_item_family->itemKind()),
779 arcane_target_item_family->name().localstr());
781 UniqueArray<Int64> target_item_uids_copy(target_item_uids);
783 std::vector<Int64> target_item_uids_filtered;
784 target_item_uids_filtered.reserve(target_item_uids.size());
785 std::copy_if(target_item_uids.begin(),
786 target_item_uids.end(),
787 std::back_inserter(target_item_uids_filtered),
788 [](
auto uid) { return uid != NULL_ITEM_UNIQUE_ID; });
790 m_mesh.scheduleAddConnectivity(source_family, source_items.m_future_items, target_family,
791 std::forward<ConnectivitySizeType>(nb_connected_items_per_item),
792 std::move(target_item_uids_filtered),
793 connectivity_name.localstr(),
796 auto& mesh_graph = m_mesh.internalMeshGraph();
797 std::string connectivity_add_output_property_name = std::string{
"EndOf" } + connectivity_name.localstr() +
"Add";
798 source_family.addScalarProperty<Neo::utils::Int32>(connectivity_add_output_property_name);
800 mesh_graph.addAlgorithm(Neo::MeshKernel::InProperty{ source_family, connectivity_name.localstr() },
801 Neo::MeshKernel::OutProperty{ source_family, connectivity_add_output_property_name },
802 "UpdateArcaneConnectivity"+std::string{connectivity_name.localstr()},
803 [arcane_source_item_family, arcane_target_item_family, &source_family, &target_family,
this]
804 (Neo::Mesh::ConnectivityPropertyType
const& neo_connectivity,
805 Neo::ScalarPropertyT<Neo::utils::Int32>&) {
806 auto rank = arcane_source_item_family->mesh()->parallelMng()->commRank();
807 Neo::printer(rank) <<
"==Algorithm update Arcane connectivity: "<< neo_connectivity.name() << Neo::endline;
808 auto item_internal_connectivity_list = arcane_source_item_family->itemInternalConnectivityList();
810 auto connectivity = m_mesh.getConnectivity(source_family, target_family, neo_connectivity.name());
812 auto& connectivity_values = source_family.getConcreteProperty<Neo::Mesh::ConnectivityPropertyType>(neo_connectivity.name());
813 Neo::MeshArrayPropertyProxyT<Neo::Mesh::ConnectivityPropertyType::PropertyDataType> connectivity_proxy{ connectivity_values };
814 auto nb_item_data = connectivity_proxy.arrayPropertySizes();
815 auto nb_item_size = connectivity_proxy.arrayPropertySizesSize();
816 item_internal_connectivity_list->_setConnectivityNbItem(arcane_target_item_family->itemKind(),
818 auto max_nb_connected_items = connectivity.maxNbConnectedItems();
819 item_internal_connectivity_list->_setMaxNbConnectedItem(arcane_target_item_family->itemKind(), max_nb_connected_items);
820 auto connectivity_values_data = connectivity_proxy.arrayPropertyData();
821 auto connectivity_values_size = connectivity_proxy.arrayPropertyDataSize();
822 item_internal_connectivity_list->_setConnectivityList(arcane_target_item_family->itemKind(),
823 Int32ArrayView{ Integer(connectivity_values_size), connectivity_values_data });
824 auto connectivity_index_data = connectivity_proxy.arrayPropertyIndex();
825 auto connectivity_index_size = connectivity_proxy.arrayPropertyIndexSize();
826 item_internal_connectivity_list->_setConnectivityIndex(arcane_target_item_family->itemKind(),
827 Int32ArrayView{ Integer(connectivity_index_size), connectivity_index_data }); }, Neo::MeshKernel::AlgorithmPropertyGraph::AlgorithmPersistence::KeepAfterExecution);
829 if (arcane_source_item_family->itemKind() ==
IK_Face && arcane_target_item_family->itemKind() ==
IK_Cell) {
830 std::string flag_definition_output_property_name{
"EndOfFlagDefinition" };
831 source_family.addScalarProperty<Neo::utils::Int32>(flag_definition_output_property_name);
833 mesh_graph.addAlgorithm(Neo::MeshKernel::InProperty{ source_family, connectivity_add_output_property_name }, Neo::MeshKernel::OutProperty{ source_family, flag_definition_output_property_name },
834 "UpdateFaceFlagsAfterConnectivityDefinition",
835 [arcane_source_item_family, arcane_target_item_family, target_item_uids_local = std::move(target_item_uids_copy), &source_items](Neo::ScalarPropertyT<Neo::utils::Int32>
const&, Neo::ScalarPropertyT<Neo::utils::Int32>
const&) {
836 auto current_face_index = 0;
837 auto arcane_faces = arcane_source_item_family->itemInfoListView();
839 arcane_target_item_family->itemsUniqueIdToLocalId(target_item_lids, target_item_uids_local,
false);
840 for (
auto face_lid : source_items.m_future_items.new_items) {
841 Face current_face = arcane_faces[face_lid].toFace();
842 if (target_item_lids[2 * current_face_index + 1] == NULL_ITEM_LOCAL_ID) {
845 _setFaceInfos(mod_flags, current_face);
847 else if (target_item_lids[2 * current_face_index] == NULL_ITEM_LOCAL_ID) {
855 ++current_face_index;
859 auto const isolated_items_property_name = m_mesh._isolatedItemLidsPropertyName(source_family,target_family);
860 std::string
const flag_update_output_property_name{
"EndOfFlagUpdate" };
861 source_family.addScalarProperty<Neo::utils::Int32>(flag_update_output_property_name);
863 mesh_graph.addAlgorithm(Neo::MeshKernel::InProperty{ source_family, isolated_items_property_name },
864 Neo::MeshKernel::OutProperty{ source_family, flag_update_output_property_name },
865 "UpdateFaceFlagsAfterCellRemoval",
866 [arcane_source_item_family,&source_family,connectivity_name](Neo::MeshScalarPropertyT<Neo::utils::Int32>
const&, Neo::ScalarPropertyT<Neo::utils::Int32>
const&) {
867 auto const rank = arcane_source_item_family->mesh()->parallelMng()->commRank();
868 Neo::printer(rank) <<
"==Algorithm update Face flags after cell removal" << Neo::endline;
870 auto const removed_target_item_index_prop_name = Neo::Mesh::removedTargetItemIndexfilteredItemPropertyName(connectivity_name.localstr());
871 auto& null_item_connected = source_family.getConcreteProperty<Neo::MeshArrayPropertyT<Neo::utils::Int32>>(removed_target_item_index_prop_name);
872 null_item_connected.debugPrint(rank);
873 ENUMERATE_(Face,iface,arcane_source_item_family->allItems())
875 Face current_face = *iface;
876 auto null_items_connected_to_face = null_item_connected[iface.localId()];
877 if (null_items_connected_to_face.size() > 2)
879 ARCANE_FATAL(
"More than one null item connected to face {0}",iface.localId());
882 if (null_items_connected_to_face.size() == 0)
886 if (null_items_connected_to_face[0] == 0)
891 else if (null_items_connected_to_face[0] == 1)
899 Neo::MeshKernel::AlgorithmPropertyGraph::AlgorithmPersistence::KeepAfterExecution
903 if (operation == Neo::Mesh::ConnectivityOperation::Modify)
905 auto isolated_item_property_name = m_mesh._isolatedItemLidsPropertyName(source_family, target_family);
906 auto end_of_isolated_removal_property_name = std::string{
"EndOf" } + isolated_item_property_name;
907 source_family.addScalarProperty<Neo::utils::Int32>(end_of_isolated_removal_property_name);
908 mesh_graph.addAlgorithm(Neo::MeshKernel::InProperty{ source_family, isolated_item_property_name },
909 Neo::MeshKernel::OutProperty{ source_family, end_of_isolated_removal_property_name },
910 "RemoveIsolatedArcaneItemsIn"+std::string{ arcane_source_item_family->name().localstr() },
911 [arcane_source_item_family](Neo::MeshScalarPropertyT<Neo::utils::Int32>
const& isolated_items_lids_property,
912 Neo::ScalarPropertyT<Neo::utils::Int32>& end_of_isolated_removal_property) {
913 end_of_isolated_removal_property.set(1);
916 isolated_item_lids.
reserve(isolated_items_lids_property.size());
917 ENUMERATE_(Item,iitem,arcane_source_item_family->allItems()) {
918 if (isolated_items_lids_property[iitem->localId()] == 1) {
919 isolated_item_lids.push_back(iitem->localId());
922 std::sort(isolated_item_lids.begin(), isolated_item_lids.end());
923 arcane_source_item_family->traceMng()->info() <<
"Remove isolated in Arcane for family "
924 << arcane_source_item_family->name() <<
" lids : " << isolated_item_lids;
925 isolated_items_lids_property.debugPrint();
926 arcane_source_item_family->removeItems(isolated_item_lids);
927 }, Neo::MeshKernel::AlgorithmPropertyGraph::AlgorithmPersistence::KeepAfterExecution);
934 auto& _item_family = m_mesh.findFamily(itemKindArcaneToNeo(item_family->itemKind()), item_family->name().localstr());
935 std::vector<Neo::utils::Real3> _node_coords(item_coords.size());
937 for (
auto&& node_coord : item_coords) {
938 _node_coords[node_index++] = Neo::utils::Real3{ node_coord.x, node_coord.y, node_coord.z };
940 m_mesh.scheduleSetItemCoords(_item_family, local_ids.m_future_items, _node_coords);
942 auto& mesh_graph = m_mesh.internalMeshGraph();
943 _item_family.addScalarProperty<
Int32>(
"NoOutProperty42");
944 mesh_graph.addAlgorithm(Neo::MeshKernel::InProperty{ _item_family, m_mesh._itemCoordPropertyName(_item_family) },
945 Neo::MeshKernel::OutProperty{ _item_family,
"NoOutProperty42" },
946 "UpdateArcaneCoordsIn"+std::string{item_family->name().localstr()},
947 [
this, item_family, &_item_family, &arcane_coords](Neo::Mesh::CoordPropertyType
const& item_coords_property,
948 Neo::ScalarPropertyT<Neo::utils::Int32>&) {
950 auto& all_items = _item_family.all();
951 VariableNodeReal3 node_coords{ VariableBuildInfo{ item_family->mesh(),
"NodeCoord" } };
952 for (
auto item : all_items) {
953 arcane_coords[ItemLocalId{ item }] = { item_coords_property[item].x,
954 item_coords_property[item].y,
955 item_coords_property[item].z };
962 Neo::EndOfMeshUpdate applyScheduledOperations() noexcept
964 return m_mesh.applyScheduledOperations();
968 template <>
class PolyhedralMeshImpl::ItemKindTraits<
IK_Cell>
970 static const Neo::ItemKind item_kind = Neo::ItemKind::IK_Cell;
972 template <>
class PolyhedralMeshImpl::ItemKindTraits<
IK_Face>
974 static const Neo::ItemKind item_kind = Neo::ItemKind::IK_Face;
976 template <>
class PolyhedralMeshImpl::ItemKindTraits<
IK_Edge>
978 static const Neo::ItemKind item_kind = Neo::ItemKind::IK_Edge;
980 template <>
class PolyhedralMeshImpl::ItemKindTraits<
IK_Node>
982 static const Neo::ItemKind item_kind = Neo::ItemKind::IK_Node;
984 template <>
class PolyhedralMeshImpl::ItemKindTraits<
IK_DoF>
986 static const Neo::ItemKind item_kind = Neo::ItemKind::IK_Dof;
991 void PolyhedralFamilySerializer::serializeItems(ISerializer* buf,
Int32ConstArrayView items_local_ids)
996 switch (buf->mode()) {
997 case ISerializer::ModeReserve: {
998 _fillItemData(items_local_ids);
999 m_item_data.serialize(buf);
1000 auto connectivities = m_mesh->_impl()->connectivities(m_family);
1001 for (
auto out_connectivity : connectivities) {
1002 buf->reserve(out_connectivity.target_family.name());
1003 buf->reserve(out_connectivity.name);
1008 m_item_data.serialize(buf);
1009 auto connectivities = m_mesh->_impl()->connectivities(m_family);
1010 for (
auto out_connectivity : connectivities) {
1011 buf->put(out_connectivity.target_family.name());
1012 buf->put(out_connectivity.name);
1018 deserializeItems(buf,
nullptr);
1026 void PolyhedralFamilySerializer::deserializeItems(ISerializer* buf,
Int32Array* items_local_ids)
1029 (
"Impossible to deserialize a buffer not in ModeGet. In ItemData::deserialize.Exiting"))
1034 if (items_local_ids)
1035 item_data.deserialize(buf, m_mesh, *items_local_ids);
1037 item_data.deserialize(buf, m_mesh);
1038 auto connectivities = m_mesh->_impl()->connectivities(m_family);
1039 auto nb_connectivities = connectivities.size();
1043 for (auto out_connectivity : connectivities) {
1044 buf->get(connected_family_names[index]);
1045 buf->get(connectivity_names[index]);
1048 _fillItemFamilyInfo(item_data, connected_family_names, connectivity_names);
1050 if (items_local_ids) {
1051 m_deserialized_lids_array.push_back(items_local_ids);
1054 m_future_item_lids_array.push_back(std::make_shared<PolyhedralTools::ItemLocalIds>());
1055 m_mesh->scheduleAllocateItems(m_family_info, *m_future_item_lids_array.back().get());
1058 m_mng->addSerializer(
this);
1064 m_item_data =
ItemData{ items_local_ids.size(), 0, m_family,
nullptr, m_family->parallelMng()->commRank() };
1065 Int64Array& item_infos = m_item_data.itemInfos();
1069 item_infos.reserve(1 + nb_item * 32);
1072 auto connectivities = mesh_impl->connectivities(m_family);
1073 item_infos.add(connectivities.size());
1074 bool is_face_family = m_family->itemKind() ==
IK_Face;
1077 item_infos.add(item->uniqueId().asInt64());
1078 item_owners[item.index()] = item->owner();
1079 for (
auto out_connectivity : connectivities) {
1080 auto target_family = m_mesh->findItemFamily(PolyhedralMeshImpl::itemKindNeoToArcane(out_connectivity.target_family.itemKind()),
1081 out_connectivity.target_family.name(),
false,
false);
1083 auto arcane_connected_items = target_family->itemInfoListView();
1084 bool is_face_cell_connection = is_face_family && target_family->itemKind() ==
IK_Cell;
1085 item_infos.add(PolyhedralMeshImpl::itemKindNeoToArcane(out_connectivity.target_family.itemKind()));
1086 auto connected_items = out_connectivity[item.localId()];
1087 auto nb_connected_items = connected_items.size();
1088 item_infos.add(nb_connected_items);
1089 if (is_face_cell_connection && item->itemBase().isBoundary() && item->itemBase().backCell().isNull()) {
1090 item_infos.add(NULL_ITEM_UNIQUE_ID);
1092 for (
auto connected_item_lid : connected_items) {
1093 item_infos.add(arcane_connected_items[connected_item_lid].uniqueId().asInt64());
1095 if (is_face_cell_connection && item->itemBase().isBoundary() && !item->itemBase().backCell().isNull()) {
1096 item_infos.add(NULL_ITEM_UNIQUE_ID);
1107class mesh::PolyhedralMesh::PolyhedralMeshModifier
1112 explicit PolyhedralMeshModifier(PolyhedralMesh* mesh)
1116 void addItems(Int64ConstArrayView unique_ids, Int32ArrayView local_ids, eItemKind ik,
const String& family_name)
override
1118 m_mesh->addItems(unique_ids, local_ids, ik, family_name);
1121 void addItems(Int64ConstArrayView unique_ids, Int32ArrayView local_ids, Int32ConstArrayView owners, eItemKind ik,
const String& family_name)
override
1123 m_mesh->addItems(unique_ids, local_ids, owners, ik, family_name);
1126 void removeItems(Int32ConstArrayView local_ids, eItemKind ik,
const String& family_name)
override
1128 m_mesh->removeItems(local_ids, ik, family_name);
1133 PolyhedralMesh* m_mesh;
1139class mesh::PolyhedralMesh::InternalApi
1145 explicit InternalApi(PolyhedralMesh* mesh)
1147 , m_connectivity_mng(std::make_unique<ItemConnectivityMng>(mesh->traceMng()))
1148 , m_polyhedral_mesh_modifier(std::make_unique<PolyhedralMeshModifier>(mesh))
1153 void setMeshKind(
const MeshKind& v)
override
1155 if (v.meshStructure() != eMeshStructure::Polyhedral && v.meshAMRKind() != eMeshAMRKind::None) {
1156 ARCANE_FATAL(
"Incompatible mesh structure ({0}) and amr kind ({1}) for Polyhedral mesh {2}. Must be (Polyhedral,None). ",
1157 v.meshStructure(), v.meshAMRKind(), m_mesh->name());
1159 m_mesh->m_mesh_kind = v;
1162 IItemConnectivityMng* dofConnectivityMng() const noexcept
override
1164 return m_connectivity_mng.get();
1167 IPolyhedralMeshModifier* polyhedralMeshModifier() const noexcept
override
1169 return m_polyhedral_mesh_modifier.get();
1172 void removeNeedRemoveMarkedItems()
override
1174 m_mesh->removeNeedRemoveMarkedItems();
1176 NodeLocalId addNode([[maybe_unused]] ItemUniqueId unique_id)
override
1180 FaceLocalId addFace([[maybe_unused]] ItemUniqueId unique_id,
1181 [[maybe_unused]] ItemTypeId type_id,
1182 [[maybe_unused]] ConstArrayView<Int64> nodes_uid)
override
1186 CellLocalId addCell([[maybe_unused]] ItemUniqueId unique_id,
1187 [[maybe_unused]] ItemTypeId type_id,
1188 [[maybe_unused]] ConstArrayView<Int64> nodes_uid)
override
1193 IItemFamilySerializerMngInternal* familySerializerMng() const noexcept
override
1195 return m_mesh->polyhedralFamilySerializerMng();
1198 ItemInternalMap& nodesMap()
override
1200 return m_mesh->_itemFamily(IK_Node)->itemsMap();
1203 ItemInternalMap& edgesMap()
override
1205 return m_mesh->_itemFamily(IK_Edge)->itemsMap();
1208 ItemInternalMap& facesMap()
override
1210 return m_mesh->_itemFamily(IK_Face)->itemsMap();
1213 ItemInternalMap& cellsMap()
override
1215 return m_mesh->_itemFamily(IK_Cell)->itemsMap();
1218 FaceFamily& trueFaceFamily()
override
1220 ARCANE_FATAL(
"PolyhedralMesh::trueFaceFamily() is not implemented. PolyhedralMesh has no concrete FaceFamily.");
1223 void printStats(Int32 level)
1225 m_mesh->traceMng()->info(level) <<
"-- -- Statistics";
1226 m_mesh->traceMng()->info(level) <<
"Number of nodes after addition &: "
1227 <<
" hashmap=" << m_mesh->_internalApi()->nodesMap().count();
1228 m_mesh->traceMng()->info(level) <<
"Number of edges after addition : "
1229 <<
" hashmap=" << m_mesh->_internalApi()->edgesMap().count();
1230 m_mesh->traceMng()->info(level) <<
"Number of faces after addition : "
1231 <<
" hashmap=" << m_mesh->_internalApi()->facesMap().count();
1232 m_mesh->traceMng()->info(level) <<
"Number of cells after addition : "
1233 <<
" hashmap=" << m_mesh->_internalApi()->cellsMap().count();
1234 m_mesh->traceMng()->info(level) <<
"--";
1239 PolyhedralMesh* m_mesh =
nullptr;
1240 std::unique_ptr<IItemConnectivityMng> m_connectivity_mng =
nullptr;
1241 std::unique_ptr<IPolyhedralMeshModifier> m_polyhedral_mesh_modifier =
nullptr;
1247class mesh::PolyhedralMesh::NoCompactionMeshCompacter
1252 explicit NoCompactionMeshCompacter(PolyhedralMesh* mesh)
1254 , m_trace_mng(mesh->traceMng())
1257 void doAllActions()
override { _info(); };
1259 void beginCompact()
override { _info(); };
1260 void compactVariablesAndGroups()
override { _info(); };
1261 void updateInternalReferences()
override { _info(); };
1262 void endCompact()
override { _info(); };
1263 void finalizeCompact()
override { _info(); };
1265 IMesh* mesh()
const override {
return m_mesh; };
1267 const ItemFamilyCompactInfos* findCompactInfos(IItemFamily*)
const override
1273 ePhase phase()
const override
1276 return ePhase::Ended;
1279 void setSorted(
bool)
override { _info(); };
1281 bool isSorted()
const override
1293 void _setCompactVariablesAndGroups(
bool)
override { _info(); };
1297 PolyhedralMesh* m_mesh =
nullptr;
1298 ITraceMng* m_trace_mng =
nullptr;
1300 void _info()
const { m_trace_mng->info() << A_FUNCINFO <<
"No compacting in PolyhedralMesh"; }
1306class mesh::PolyhedralMesh::NoCompactionMeshCompactMng
1311 explicit NoCompactionMeshCompactMng(PolyhedralMesh* mesh)
1313 , m_trace_mng(mesh->traceMng())
1314 , m_mesh_compacter{ std::make_unique<NoCompactionMeshCompacter>(m_mesh) }
1317 IMesh* mesh()
const override {
return m_mesh; }
1318 IMeshCompacter* beginCompact()
override
1321 return m_mesh_compacter.get();
1324 IMeshCompacter* beginCompact(IItemFamily* family)
override
1326 ARCANE_UNUSED(family);
1328 return m_mesh_compacter.get();
1331 void endCompact()
override { _info(); };
1333 IMeshCompacter* compacter()
override
1336 return m_mesh_compacter.get();
1341 PolyhedralMesh* m_mesh =
nullptr;
1342 ITraceMng* m_trace_mng =
nullptr;
1343 std::unique_ptr<IMeshCompacter> m_mesh_compacter =
nullptr;
1345 void _info()
const { m_trace_mng->info() << A_FUNCINFO <<
"No compacting in PolyhedralMesh"; }
1351mesh::PolyhedralMesh::
1354 m_mesh_handle._setMesh(
nullptr);
1363 return m_subdomain->traceMng();
1372 return m_mesh_handle;
1377mesh::PolyhedralMesh::
1378PolyhedralMesh(ISubDomain* subdomain,
const MeshBuildInfo& mbi)
1380, m_name{ mbi.name() }
1381, m_subdomain{ subdomain }
1382, m_mesh_handle{ m_subdomain->defaultMeshHandle() }
1383, m_properties(std::make_unique<Properties>(subdomain->propertyMng(), String(
"ArcaneMeshProperties_") + m_name))
1385, m_parallel_mng{ mbi.parallelMngRef().get() }
1386, m_mesh_part_info{ makeMeshPartInfoFromParallelMng(m_parallel_mng) }
1387, m_item_type_mng(ItemTypeMng::_singleton())
1388, m_mesh_kind(mbi.meshKind())
1389, m_polyhedral_family_serializer_mng{ std::make_unique<PolyhedralFamilySerializerMng>(this) }
1390, m_initial_allocator(*this)
1391, m_variable_mng{ subdomain->variableMng() }
1392, m_mesh_checker{ this }
1393, m_internal_api{ std::make_unique<InternalApi>(this) }
1394, m_compact_mng{ std::make_unique<NoCompactionMeshCompactMng>(this) }
1395, m_mesh_utilities{ std::make_unique<UnstructuredMeshUtilities>(this) }
1398, m_ghost_layer_mng{ std::make_unique<
GhostLayerMng>(m_trace_mng) }
1399, m_connectivity(VariableBuildInfo{ subdomain, mbi.name() +
"MeshConnectivity" })
1402 m_mesh_handle._setMesh(
this);
1403 m_mesh_item_internal_list.mesh =
this;
1404 m_default_arcane_families.fill(
nullptr);
1410void Arcane::mesh::PolyhedralMesh::
1413 _allocateItems(item_allocation_info, ArrayView<Int32UniqueArray>{});
1418void Arcane::mesh::PolyhedralMesh::
1419allocateItems(
const Arcane::ItemAllocationInfo& item_allocation_info, ArrayView<Int32UniqueArray> family_lids)
1421 _allocateItems(item_allocation_info, family_lids);
1426void Arcane::mesh::PolyhedralMesh::
1427_allocateItems(
const Arcane::ItemAllocationInfo& item_allocation_info, ArrayView<Int32UniqueArray> family_lids)
1430 m_subdomain->traceMng()->info() <<
"--PolyhedralMesh: allocate items --";
1431 UniqueArray<PolyhedralTools::ItemLocalIds> item_local_ids(item_allocation_info.family_infos.size());
1432 auto family_index = 0;
1434 for (
auto& family_info : item_allocation_info.family_infos) {
1435 bool create_if_needed =
true;
1436 auto* item_family = _findItemFamily(family_info.item_kind, family_info.name, create_if_needed);
1437 m_trace_mng->debug(
Trace::High) <<
"- Create items " << family_info.name;
1438 m_mesh->scheduleAddItems(item_family, family_info.item_uids, family_info.item_owners.constSmallSpan(), item_local_ids[family_index++]);
1442 for (
auto& family_info : item_allocation_info.family_infos) {
1443 auto* item_family = _findItemFamily(family_info.item_kind, family_info.name);
1444 m_trace_mng->debug(
Trace::High) <<
"- Current family " << family_info.name;
1445 for (
auto& current_connected_family_info : family_info.connected_family_infos) {
1446 auto connected_family = _findItemFamily(current_connected_family_info.item_kind, current_connected_family_info.name);
1447 m_trace_mng->debug(
Trace::High) <<
"- Create connectivity " << current_connected_family_info.connectivity_name;
1449 if (!connected_family) {
1450 ARCANE_WARNING((String::format(
"Cannot find family {0} with kind {1} "
1451 "The connectivity between {1} and this family is skipped",
1452 current_connected_family_info.name,
1453 current_connected_family_info.item_kind,
1454 item_family->name())
1458 m_mesh->scheduleAddConnectivity(item_family,
1459 item_local_ids[family_index],
1460 current_connected_family_info.nb_connected_items_per_item,
1462 current_connected_family_info.connected_items_uids,
1463 current_connected_family_info.connectivity_name);
1464 Connectivity connectivity{ m_connectivity };
1470 m_mesh->applyScheduledOperations();
1472 for (
auto& family_info : item_allocation_info.family_infos) {
1473 if (family_info.item_kind !=
IK_Node && family_info.item_coordinates.empty()) {
1476 auto* item_family = _findItemFamily(family_info.item_kind, family_info.name);
1477 if (item_family == itemFamily(
IK_Node)) {
1478 if (!m_arcane_node_coords.get()) {
1479 m_arcane_node_coords = std::make_unique<VariableNodeReal3>(VariableBuildInfo(
this, family_info.item_coordinates_variable_name));
1480 m_arcane_node_coords->setUsed(
true);
1484 auto arcane_item_coords_var_ptr = std::make_unique<VariableItemReal3>(VariableBuildInfo(
this, family_info.item_coordinates_variable_name),
1485 item_family->itemKind());
1486 arcane_item_coords_var_ptr->setUsed(
true);
1487 m_arcane_item_coords.push_back(std::move(arcane_item_coords_var_ptr));
1491 for (
auto& family : m_arcane_families) {
1492 family->endUpdate();
1498 for (
auto& family_info : item_allocation_info.family_infos) {
1499 if (family_info.item_coordinates.empty()) {
1503 auto* item_family = _findItemFamily(family_info.item_kind, family_info.name);
1504 if (item_family == itemFamily(
IK_Node)) {
1505 m_mesh->scheduleSetItemCoordinates(item_family, item_local_ids[family_index], family_info.item_coordinates, *m_arcane_node_coords);
1508 m_mesh->scheduleSetItemCoordinates(item_family, item_local_ids[family_index], family_info.item_coordinates, *m_arcane_item_coords[index++].get());
1510 auto mesh_state = m_mesh->applyScheduledOperations();
1511 m_is_allocated =
true;
1513 itemTypeMng()->setMeshWithGeneralCells(
this);
1515 if (!family_lids.empty()) {
1517 ARCANE_ASSERT((family_lids.size() == item_local_ids.size()), (
"Incoherence in item number"));
1518 for (
auto& lid_array : item_local_ids) {
1519 family_lids[index].resize(lid_array.size());
1520 lid_array.fillArrayView(family_lids[index].view(), mesh_state);
1528void Arcane::mesh::PolyhedralMesh::
1529scheduleAllocateItems(
const Arcane::ItemAllocationInfo::FamilyInfo& family_info, mesh::PolyhedralTools::ItemLocalIds& item_local_ids)
1532 m_subdomain->traceMng()->info() <<
"--PolyhedralMesh: schedule allocate items --";
1534 bool create_if_needed =
true;
1535 auto* item_family = _findItemFamily(family_info.item_kind, family_info.name, create_if_needed);
1536 m_trace_mng->debug(
Trace::High) <<
"- Current family " << family_info.name;
1537 m_trace_mng->debug(
Trace::High) <<
"- Create items ";
1538 m_mesh->scheduleAddItems(item_family, family_info.item_uids, family_info.item_owners.
constSmallSpan(), item_local_ids);
1540 for (
auto& current_connected_family_info : family_info.connected_family_infos) {
1541 auto connected_family = _findItemFamily(current_connected_family_info.item_kind, current_connected_family_info.name);
1542 m_trace_mng->debug(
Trace::High) <<
"- Create connectivity " << current_connected_family_info.connectivity_name;
1544 if (!connected_family) {
1545 ARCANE_WARNING((String::format(
"Cannot find family {0} with kind {1} "
1546 "The connectivity between {1} and this family is skipped",
1547 current_connected_family_info.name,
1548 current_connected_family_info.item_kind,
1549 item_family->name())
1553 m_mesh->scheduleUpdateConnectivity(item_family,
1555 current_connected_family_info.nb_connected_items_per_item,
1557 current_connected_family_info.connected_items_uids,
1558 current_connected_family_info.connectivity_name);
1564void Arcane::mesh::PolyhedralMesh::
1565applyScheduledAllocateItems(UniqueArray<std::shared_ptr<PolyhedralTools::ItemLocalIds>> item_lids)
1568 auto mesh_state = m_mesh->applyScheduledOperations();
1570 for (
auto item_local_ids : item_lids) {
1571 item_local_ids->m_mesh_state = std::make_shared<Neo::EndOfMeshUpdate>(mesh_state);
1575 for (
auto& family : m_arcane_families) {
1576 family->endUpdate();
1579 m_is_allocated =
true;
1581 itemTypeMng()->setMeshWithGeneralCells(
this);
1586void mesh::PolyhedralMesh::removeNeedRemoveMarkedItems()
1589 for (
auto family_index = 0; family_index < m_arcane_families.size(); ++family_index) {
1591 auto* family = m_arcane_families[family_index].get();
1593 items_to_remove.
reserve(family->nbItem());
1594 auto& items_map = family->itemsMap();
1595 if (items_map.count() == 0)
1597 items_map.eachItem([&](ItemBase item) {
1599 auto f = item.flags();
1602 item.toMutable().setFlags(f);
1603 items_to_remove.add(item.localId());
1606 if (!items_to_remove.empty()) {
1607 removeItems(items_to_remove, family);
1614Arcane::mesh::PolyhedralFamilySerializerMng* mesh::PolyhedralMesh::
1615polyhedralFamilySerializerMng()
1617 return m_polyhedral_family_serializer_mng.get();
1623void Arcane::mesh::PolyhedralMesh::
1626 for (
auto& family : m_arcane_families) {
1627 family->endUpdate();
1634void Arcane::mesh::PolyhedralMesh::
1635_computeFamilySynchronizeInfos()
1637 m_subdomain->traceMng()->info() <<
"Computing family synchronization information for " << name();
1638 for (
auto& family : m_arcane_families) {
1639 family->computeSynchronizeInfos();
1644 auto* var_syncer = cellFamily()->allItemsSynchronizer();
1645 Int32 iteration = m_subdomain->commonVariables().globalIteration();
1646 String file_name = String::format(
"{0}_sync_topology_iter{1}.json", name(), iteration);
1647 mesh_utils::dumpSynchronizerTopologyJSON(var_syncer, file_name);
1654void Arcane::mesh::PolyhedralMesh::
1655_notifyEndUpdateForFamilies()
1657 for (
auto& family : m_arcane_families)
1658 family->_internalApi()->notifyEndUpdateFromMesh();
1664void Arcane::mesh::PolyhedralMesh::
1665_computeGroupSynchronizeInfos()
1667 auto action = [](ItemGroup& group) {
1668 if (group.hasSynchronizer())
1669 group.synchronizer()->compute();
1672 m_trace_mng->info() <<
"Computing group synchronization information for " << name();
1673 meshvisitor::visitGroups(
this, action);
1691 return m_mesh->dimension();
1700 return m_mesh->nbNode();
1709 return m_mesh->nbEdge();
1718 return m_mesh->nbFace();
1727 return m_mesh->nbCell();
1736 return m_mesh->nbItem(ik);
1745 if (m_default_arcane_families[
IK_Node])
1746 return m_default_arcane_families[
IK_Node]->allItems();
1757 if (m_default_arcane_families[
IK_Edge])
1758 return m_default_arcane_families[
IK_Edge]->allItems();
1769 if (m_default_arcane_families[
IK_Face])
1770 return m_default_arcane_families[
IK_Face]->allItems();
1781 if (m_default_arcane_families[
IK_Cell])
1782 return m_default_arcane_families[
IK_Cell]->allItems();
1793 if (m_default_arcane_families[
IK_Node])
1794 return m_default_arcane_families[
IK_Node]->allItems().own();
1805 if (m_default_arcane_families[
IK_Edge])
1806 return m_default_arcane_families[
IK_Edge]->allItems().own();
1817 if (m_default_arcane_families[
IK_Face])
1818 return m_default_arcane_families[
IK_Face]->allItems().own();
1829 if (m_default_arcane_families[
IK_Cell])
1830 return m_default_arcane_families[
IK_Cell]->allItems().own();
1841 if (m_default_arcane_families[
IK_Cell])
1850mesh::PolyhedralFamily* mesh::PolyhedralMesh::
1851_createItemFamily(
eItemKind ik,
const String& name)
1853 m_mesh->addFamily(ik, name);
1854 m_arcane_families.push_back(std::make_unique<PolyhedralFamily>(
this, ik, name));
1855 auto current_family = m_arcane_families.back().get();
1856 if (m_default_arcane_families[ik] ==
nullptr) {
1857 m_default_arcane_families[ik] = current_family;
1858 _updateMeshInternalList(ik);
1860 m_item_family_collection.add(current_family);
1861 current_family->build();
1862 return current_family;
1871 return _createItemFamily(ik, name);
1877void mesh::PolyhedralMesh::
1880 createItemFamily(
IK_Cell,
"CellFamily");
1881 createItemFamily(
IK_Node,
"NodeFamily");
1882 auto cell_family = m_default_arcane_families[
IK_Cell];
1883 auto node_family = m_default_arcane_families[
IK_Node];
1886 PolyhedralTools::ItemLocalIds cell_lids, node_lids;
1887 m_mesh->scheduleAddItems(cell_family, cell_uids.constView(), cell_lids);
1888 m_mesh->scheduleAddItems(node_family, node_uids.constView(), node_lids);
1891 m_mesh->scheduleAddConnectivity(cell_family, cell_lids, nb_node, node_family, node_uids, String{
"CellToNodes" });
1892 m_mesh->scheduleAddConnectivity(node_family, node_lids, 1, cell_family,
1893 node_cells_uids, String{
"NodeToCells" });
1894 m_mesh->applyScheduledOperations();
1895 cell_family->endUpdate();
1896 node_family->endUpdate();
1909 for (
auto ik = 0; ik < NB_ITEM_KIND; ++ik) {
1912 m_empty_arcane_families[ik] = std::make_unique<mesh::PolyhedralFamily>(
this, (
eItemKind)ik, name);
1913 m_default_arcane_families[ik] = m_empty_arcane_families[ik].get();
1924 return m_default_arcane_families[
IK_Node];
1933 return m_default_arcane_families[
IK_Edge];
1942 return m_default_arcane_families[
IK_Face];
1951 return m_default_arcane_families[
IK_Cell];
1954void mesh::PolyhedralMesh::
1959 m_mesh_item_internal_list.cells = m_default_arcane_families[kind]->itemsInternal();
1960 m_mesh_item_internal_list._internalSetCellSharedInfo(m_default_arcane_families[kind]->commonItemSharedInfo());
1963 m_mesh_item_internal_list.faces = m_default_arcane_families[kind]->itemsInternal();
1964 m_mesh_item_internal_list._internalSetFaceSharedInfo(m_default_arcane_families[kind]->commonItemSharedInfo());
1967 m_mesh_item_internal_list.edges = m_default_arcane_families[kind]->itemsInternal();
1968 m_mesh_item_internal_list._internalSetEdgeSharedInfo(m_default_arcane_families[kind]->commonItemSharedInfo());
1971 m_mesh_item_internal_list.nodes = m_default_arcane_families[kind]->itemsInternal();
1972 m_mesh_item_internal_list._internalSetNodeSharedInfo(m_default_arcane_families[kind]->commonItemSharedInfo());
1984mesh::PolyhedralFamily* mesh::PolyhedralMesh::
1987 return m_default_arcane_families[ik];
1996 return _itemFamily(ik);
2005 return m_item_type_mng;
2011mesh::PolyhedralFamily* mesh::PolyhedralMesh::
2012_findItemFamily(
eItemKind ik,
const String& name,
bool create_if_needed)
2015 auto found_family = _itemFamily(ik);
2017 if (found_family->name() == name)
2018 return found_family;
2020 for (
auto& family : m_arcane_families) {
2021 if (family->itemKind() == ik && family->name() == name)
2022 return family.get();
2024 if (!create_if_needed)
2026 return _createItemFamily(ik, name);
2035 ARCANE_UNUSED(register_modifier_if_created);
2036 return _findItemFamily(ik, name, create_if_needed);
2042mesh::PolyhedralFamily* mesh::PolyhedralMesh::
2045 return m_default_arcane_families[ik];
2054 ARCANE_ASSERT(m_arcane_node_coords, (
"Node coordinates not yet loaded."));
2055 return *m_arcane_node_coords;
2065 for (
auto& family : m_arcane_families) {
2066 group = family->findGroup(name);
2079 m_all_groups.
clear();
2080 for (
auto& family : m_arcane_families) {
2082 m_all_groups.add(*i_group);
2084 return m_all_groups;
2093 for (
auto& family : m_arcane_families) {
2094 family->destroyGroups();
2104 return m_item_family_collection;
2113 return m_internal_api.get();
2122 return m_compact_mng.get();
2128void mesh::PolyhedralMesh::
2131 ARCANE_ASSERT((unique_ids.size() == local_ids.size()), (
"local and unique ids arrays must have same size"))
2132 auto* item_family = _findItemFamily(ik, family_name, false);
2133 PolyhedralTools::ItemLocalIds item_local_ids;
2134 m_mesh->scheduleAddItems(item_family, unique_ids, item_local_ids);
2135 auto mesh_state = m_mesh->applyScheduledOperations();
2136 item_local_ids.fillArrayView(local_ids, mesh_state);
2145 ARCANE_ASSERT((unique_ids.size() == local_ids.size() && (unique_ids.size() == owners.size())), (
"local/unique ids and owners arrays must have same size"))
2146 auto* item_family = _findItemFamily(ik, family_name, false);
2147 PolyhedralTools::ItemLocalIds item_local_ids;
2148 m_mesh->scheduleAddItems(item_family, unique_ids, owners, item_local_ids);
2149 auto mesh_state = m_mesh->applyScheduledOperations();
2150 item_local_ids.fillArrayView(local_ids, mesh_state);
2159 auto* item_family = _findItemFamily(ik, family_name,
false);
2161 ARCANE_FATAL(
"ItemFamily with name {0} and kind {1} does not exist in the mesh.", family_name, ik);
2163 m_mesh->scheduleRemoveItems(item_family, local_ids);
2164 m_mesh->applyScheduledOperations();
2170void mesh::PolyhedralMesh::
2173 if (local_ids.empty())
2176 ARCANE_FATAL(
"Invalid IItemFamily passed to removeItems.");
2178 removeItems(local_ids, family->itemKind(), family->name());
2187 addItems(nodes_uid, nodes_lid,
IK_Node, nodeFamily()->name());
2196 m_trace_mng->info() <<
"PolyhedralMesh::_exchangeItems() do_compact?=" <<
"false"
2197 <<
" nb_exchange=" << 0 <<
" version=" << 0;
2199 if (ghostLayerMng()->nbGhostLayer() > 1)
2200 updateGhostLayers(
true);
2202 if (!check_exchange.null()) {
2203 m_mesh_checker.checkGhostCells();
2204 m_trace_mng->pwarning() <<
"CHECKING SYNCHRONISATION !";
2205 m_mesh_checker.checkVariablesSynchronization();
2206 m_mesh_checker.checkItemGroupsSynchronization();
2208 if (checkLevel() >= 2)
2209 m_mesh_checker.checkValidMesh();
2210 else if (checkLevel() >= 1)
2211 m_mesh_checker.checkValidConnectivity();
2217void mesh::PolyhedralMesh::
2222 Trace::Setter mci(traceMng(), _className());
2227 if (arcane_debug_load_balancing) {
2228 for (
auto& family : m_arcane_families) {
2229 family->itemsNewOwner().checkIfSync();
2233 IMeshExchanger* iexchanger = m_mesh_exchange_mng->beginExchange();
2236 if (iexchanger->computeExchangeInfos()) {
2237 m_trace_mng->pwarning() <<
"No load balance is performed";
2238 m_mesh_exchange_mng->endExchange();
2243 iexchanger->processExchange();
2246 iexchanger->removeNeededItems();
2251 auto action = [](ItemGroup& group) {
2252 if (group.internal()->hasComputeFunctor() || group.isLocalToSubDomain())
2255 group.internal()->removeSuppressedItems();
2257 meshvisitor::visitGroups(
this, action);
2260 iexchanger->allocateReceivedItems();
2263 _endUpdateFamilies();
2264 _computeFamilySynchronizeInfos();
2267 iexchanger->updateItemGroups();
2269 _computeGroupSynchronizeInfos();
2271 iexchanger->updateVariables();
2275 m_mesh_checker.checkMeshFromReferenceFile();
2276 _notifyEndUpdateForFamilies();
2278 iexchanger->finalizeExchange();
2280 m_mesh_exchange_mng->endExchange();
2295 Trace::Setter mci(traceMng(), _className());
2296 traceMng()->info() <<
"PolyhedralMesh::updateGhostLayers() remove_old_ghost=" << remove_old_ghost;
2302 _internalUpdateGhost(
true, remove_old_ghost);
2303 _internalEndUpdateInit(
true);
2304 _synchronizeGroups();
2305 _computeGroupSynchronizeInfos();
2306 _internalEndUpdateResizeVariables();
2307 _synchronizeVariables();
2308 _internalEndUpdateFinal(
true);
2315void mesh::PolyhedralMesh::_internalUpdateGhost(
bool update_ghost_layer,
bool remove_old_ghost)
2317 if (update_ghost_layer) {
2318 if (remove_old_ghost) {
2319 _removeGhostItems();
2323 m_ghost_layer_builder->addGhostLayers(
true);
2333void mesh::PolyhedralMesh::_internalEndUpdateInit(
bool update_ghost_layer)
2340 _finalizeMeshChanged();
2345 if (update_ghost_layer) {
2347 _computeFamilySynchronizeInfos();
2353void mesh::PolyhedralMesh::_synchronizeGroups()
2355 for (
auto& family : m_arcane_families) {
2363void mesh::PolyhedralMesh::_internalEndUpdateResizeVariables()
2366 for (
auto& family : m_arcane_families)
2367 family->_internalApi()->resizeVariables(
true);
2372void mesh::PolyhedralMesh::_synchronizeVariables()
2374 typedef UniqueArray<IVariableSynchronizer*> OrderedSyncList;
2375 typedef std::map<IVariableSynchronizer*, VariableCollection> SyncList;
2376 OrderedSyncList ordered_sync_list;
2379 VariableCollection used_vars(subDomain()->variableMng()->usedVariables());
2380 for (VariableCollection::Enumerator i_var(used_vars); ++i_var;) {
2381 IVariable* var = *i_var;
2382 switch (var->itemKind()) {
2388 IVariableSynchronizer* synchronizer = 0;
2389 if (var->isPartial())
2390 synchronizer = var->itemGroup().synchronizer();
2392 synchronizer = var->itemFamily()->allItemsSynchronizer();
2393 IMesh* sync_mesh = synchronizer->itemGroup().mesh();
2394 if (sync_mesh !=
this)
2396 std::pair<SyncList::iterator, bool> inserter = sync_list.insert(std::make_pair(synchronizer, VariableCollection()));
2397 if (inserter.second) {
2398 ordered_sync_list.add(synchronizer);
2400 VariableCollection& collection = inserter.first->second;
2401 collection.add(var);
2409 for (
Integer i_sync = 0; i_sync < ordered_sync_list.size(); ++i_sync) {
2410 IVariableSynchronizer* synchronizer = ordered_sync_list[i_sync];
2411 VariableCollection& collection = sync_list[synchronizer];
2412 synchronizer->synchronize(collection);
2418void mesh::PolyhedralMesh::_internalEndUpdateFinal(
bool print_stat)
2420 _notifyEndUpdateForFamilies();
2423 MeshStats ms(traceMng(),
this, m_parallel_mng);
2430void mesh::PolyhedralMesh::_removeGhostItems()
2433 const Int32 sid = m_parallel_mng->commRank();
2436 UniqueArray<Int32> cells_to_remove;
2437 cells_to_remove.reserve(1000);
2440 cells_map.
eachItem([&](Item cell) {
2441 if (cell.owner() != sid)
2442 cells_to_remove.add(cell.localId());
2444 m_trace_mng->info() <<
"Number of cells to remove: " << cells_to_remove.size();
2445 removeItems(cells_to_remove,
IK_Cell,cellFamily()->name());
2455void mesh::PolyhedralMesh::
2456_finalizeMeshChanged()
2458 for (
auto& family : m_arcane_families) {
2459 m_trace_mng->debug() <<
"_finalizeMeshChanged on " << family->name() <<
" Family on Mesh " << name();
2460 family->endUpdate();
2471 auto want_dump =
false;
2472 auto need_compact =
false;
2473 m_trace_mng->info(4) <<
"DynamicMesh::prepareForDump() name=" << name()
2474 <<
" need_compact?=" << need_compact
2475 <<
" want_dump?=" << want_dump
2476 <<
" timestamp=" << 0;
2480 m_mesh_events.eventObservable(t).notify(MeshEventArgs(
this, t));
2485 for (
auto& family : m_arcane_families) {
2486 family->prepareForDump();
2492 m_mesh_events.eventObservable(t).notify(MeshEventArgs(
this, t));
2573 return m_mesh_utilities.get();
2582 IItemFamily* item_family = _itemFamily(ik);
2584 return item_family->itemsNewOwner();
2593 return m_mesh_checker.checkLevel();
2602 return m_item_family_network.get();
2611 return m_ghost_layer_mng.get();
2620 return m_internal_api.get();
2626mesh::PolyhedralMeshImpl* mesh::PolyhedralMesh::_impl()
2628 return m_mesh.get();
2644namespace Arcane::mesh
2653Arcane::mesh::PolyhedralMesh::
2654~PolyhedralMesh() =
default;
2659Arcane::mesh::PolyhedralMesh::
2661: EmptyMesh{ subdomain->traceMng() }
2662, m_subdomain{ subdomain }
2664, m_mesh_kind(mbi.meshKind())
2671void Arcane::mesh::PolyhedralMesh::
2672read([[maybe_unused]]
const String& filename)
2680void Arcane::mesh::PolyhedralMesh::
2681allocateItems(
const Arcane::ItemAllocationInfo& item_allocation_info)
2683 ARCANE_UNUSED(item_allocation_info);
2698class ARCANE_MESH_EXPORT PolyhedralMeshFactory
2717 static String name() {
return "ArcanePolyhedralMeshFactory"; }
2727#if ARCANE_HAS_POLYHEDRAL_MESH_TOOLS
2735 return PolyhedralMeshFactory::name();
#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_CHECK_POINTER2(ptr, text)
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.
This file contains the various service factories and macros for registering services.
#define ARCANE_SERVICE_INTERFACE(ainterface)
Macro to declare an interface when registering a service.
AbstractService(const ServiceBuildInfo &)
Constructor from a ServiceBuildInfo.
constexpr Integer size() const noexcept
Returns the size of the array.
SmallSpan< const T > constSmallSpan() const
Immutable view of this array.
void reserve(Int64 new_capacity)
Reserves memory for new_capacity elements.
void clear()
Removes all elements from the collection.
EnumeratorT< ItemGroup > Enumerator
static Integer kindsToConnectivity(eItemKind kindA, eItemKind kindB)
Type to connectivity conversion.
virtual ITraceMng * traceMng()=0
Associated message manager.
virtual NodeGroup ownNodes()=0
Group of all domain-specific nodes.
virtual MeshHandle handle() const =0
Handle on this mesh.
virtual IItemFamily * nodeFamily()=0
Returns the node family.
virtual String name() const =0
Mesh name.
virtual Integer nbCell()=0
Number of mesh cells.
virtual CellGroup ownCells()=0
Group of all domain-specific cells.
virtual FaceGroup ownFaces()=0
Group of all domain-specific faces.
virtual FaceGroup allFaces()=0
Group of all faces.
virtual Integer nbEdge()=0
Number of mesh edges.
virtual IItemFamily * itemFamily(eItemKind ik)=0
Returns the entity family of type ik.
virtual IItemFamily * edgeFamily()=0
Returns the edge family.
virtual Integer nbNode()=0
Number of mesh nodes.
virtual FaceGroup outerFaces()=0
Group of all faces on the boundary.
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.
virtual Integer nbItem(eItemKind ik)=0
Number of elements of type ik.
virtual Integer dimension()=0
Mesh dimension (1D, 2D, or 3D).
virtual IItemFamily * faceFamily()=0
Returns the face family.
virtual EdgeGroup ownEdges()=0
Group of all domain-specific edges.
virtual NodeGroup allNodes()=0
Group of all nodes.
virtual CellGroup allCells()=0
Group of all cells.
virtual Integer nbFace()=0
Number of mesh faces.
virtual IItemFamily * cellFamily()=0
Returns the cell family.
virtual IItemFamily * createItemFamily(eItemKind ik, const String &name)=0
Create a particle family named name.
virtual EdgeGroup allEdges()=0
Group of all edges.
Interface for managing the compaction of mesh families.
Management of mesh family compaction.
Interface of the service managing mesh reading.
virtual IVariableMng * variableMng() const =0
Variable manager associated with this manager.
Internal part of IMeshModifier.
virtual void updateGhostLayers()=0
Updates the ghost layer.
virtual void addNodes(Int64ConstArrayView nodes_uid, Int32ArrayView nodes_lid=Int32ArrayView())=0
Adds nodes.
virtual IMeshModifierInternal * _modifierInternalApi()=0
Internal API for Arcane.
virtual VariableNodeReal3 & nodesCoordinates()=0
Node coordinates.
virtual FaceGroup outerActiveFaces()=0
Group of all active faces on the boundary.
virtual void destroyGroups()=0
Destroys all groups of all families.
virtual IMeshUtilities * utilities()=0
Associated utility functions interface.
virtual CellGroup allLevelCells(const Integer &level)=0
Group of all cells of level level.
virtual FaceGroup innerActiveFaces()=0
Group of all active faces.
virtual ItemGroupCollection groups()=0
List of groups.
virtual ItemGroup findGroup(const String &name)=0
Returns the group with name name or a null group if none exists.
virtual String factoryName() const =0
Name of the factory used to create the mesh.
virtual IMeshInternal * _internalApi()=0
Internal Arcane API.
virtual CellGroup allActiveCells()=0
virtual FaceGroup allActiveFaces()=0
Group of all active faces.
virtual ItemTypeMng * itemTypeMng() const =0
Associated entity type manager.
virtual void prepareForDump()=0
Prepares the instance for dumping.
virtual CellGroup ownActiveCells()=0
Group of all active cells specific to the domain.
virtual CellGroup ownLevelCells(const Integer &level)=0
Group of all cells specific to the domain of level level.
virtual IGhostLayerMng * ghostLayerMng() const =0
Associated ghost layer manager.
virtual FaceGroup ownActiveFaces()=0
Group of all active faces specific to the domain.
virtual IItemFamilyNetwork * itemFamilyNetwork()=0
Family network interface (connected families).
virtual IMeshCompactMng * _compactMng()=0
virtual Integer checkLevel() const =0
Current check level.
virtual void exchangeItems()=0
Changes the owning subdomains of entities.
virtual VariableItemInt32 & itemsNewOwner(eItemKind kind)=0
Variable containing the identifier of the owning subdomain.
@ ModePut
The serializer expects reserve().
@ ModeGet
The serializer expects get().
Interface of the subdomain manager.
virtual ISubDomain * internalSubDomain() const =0
Temporary internal function to retrieve the subdomain.
virtual IVariableMngInternal * _internalApi()=0
Internal Arcane API.
@ II_FrontCellIsFirst
The first cell of the entity is the front cell.
@ II_NeedRemove
The entity must be removed.
@ II_HasBackCell
The entity has a back cell.
@ II_SubDomainBoundary
The entity is at the boundary of two subdomains.
@ II_Suppressed
The entity has just been suppressed.
@ II_Boundary
The entity is on the boundary.
@ II_HasFrontCell
The entity has a front cell.
@ II_BackCellIsFirst
The first cell of the entity is the back cell.
FaceGroup activeFaceGroup() const
Group of active faces.
FaceGroup innerActiveFaceGroup() const
Group of internal faces of the elements of this group.
FaceGroup ownActiveFaceGroup() const
Group of active faces belonging to the domain of the elements of this group.
CellGroup levelCellGroup(const Integer &level) const
Group of level l cells of the elements of this group.
CellGroup ownActiveCellGroup() const
Group of own active cells of the elements of this group.
CellGroup ownLevelCellGroup(const Integer &level) const
Group of own level l cells of the elements of this group.
FaceGroup outerActiveFaceGroup() const
Group of active external faces of the elements of this group.
CellGroup activeCellGroup() const
AMR.
FaceGroup outerFaceGroup() const
Group of external faces of the elements of this group.
Parameters necessary for building a mesh.
void build() override
Build-level construction of the service.
IPrimaryMesh * createMesh(IMeshMng *mm, const MeshBuildInfo &build_info) override
Creates a mesh with the information from build_info.
Structure containing the information to create a service.
Service creation properties.
Unicode character string.
Construction of ghost layers.
Manager for the policies of a family of entities.
Information to synchronize groups between sub-domains.
Associative array of ItemInternal.
void eachItem(const Lambda &lambda)
Template function to iterate over the instance's entities.
Interface for the mesh exchange manager between subdomains.
void endUpdate()
Notifies the instance that mesh modification is finished.
ItemVectorViewT< DoF > DoFVectorView
View over a vector of degrees of freedom.
ItemGroupT< Cell > CellGroup
Group of cells.
ItemGroupT< Face > FaceGroup
Group of faces.
ItemGroupT< Edge > EdgeGroup
Group of edges.
ItemGroupT< Node > NodeGroup
Group of nodes.
#define ARCANE_REGISTER_SERVICE(aclass, a_service_property,...)
Macro for registering a service.
MeshVariableScalarRefT< Node, Real3 > VariableNodeReal3
Coordinate type quantity at node.
ItemVariableScalarRefT< Real3 > VariableItemReal3
3D coordinate type quantity
ItemVariableScalarRefT< Int32 > VariableItemInt32
32-bit integer type quantity
Array< Int64 > Int64Array
Dynamic one-dimensional array of 64-bit integers.
UniqueArray< Int64 > Int64UniqueArray
Dynamic 1D array of 64-bit integers.
Collection< ItemGroup > ItemGroupCollection
Collection of mesh item groups.
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Collection< IItemFamily * > ItemFamilyCollection
Collection of item families.
Collection< IItemFamily * > IItemFamilyCollection
Collection of item families.
@ ST_Application
The service is used at the application level.
ConstArrayView< Int64 > Int64ConstArrayView
C equivalent of a 1D array of 64-bit integers.
SmallSpan< const Real3 > Real3ConstSmallSpan
Read-only view of a 1D array of Real3.
eMeshEventType
Events generated by IMesh.
@ EndPrepareDump
Event sent at the end of prepareForDump().
@ BeginPrepareDump
Event sent at the beginning of prepareForDump().
UniqueArray< Int32 > Int32UniqueArray
Dynamic 1D array of 32-bit integers.
ArrayView< Int32 > Int32ArrayView
C equivalent of a 1D array of 32-bit integers.
eItemKind
Mesh entity type.
@ IK_Particle
Particle mesh entity.
@ IK_Node
Node mesh entity.
@ IK_Cell
Cell mesh entity.
@ IK_Unknown
Unknown or uninitialized mesh entity.
@ IK_Face
Face mesh entity.
@ IK_DoF
Degree of Freedom mesh entity.
@ IK_Edge
Edge mesh entity.
SmallSpan< const Int64 > Int64ConstSmallSpan
Read-only view of a 1D array of 64-bit integers.
ARCCORE_SERIALIZE_EXPORT Ref< ISerializer > createSerializer()
Creates an instance of ISerializer.
const char * itemKindName(eItemKind kind)
Entity kind name.
Array< Int32 > Int32Array
Dynamic one-dimensional array of 32-bit integers.
UniqueArray< String > StringUniqueArray
Dynamic 1D array of strings.
Span< const Int32 > Int32ConstSpan
Read-only view of a 1D array of 32-bit integers.
SmallSpan< const Int32 > Int32ConstSmallSpan
Read-only view of a 1D array of 32-bit integers.
std::int32_t Int32
Signed integer type of 32 bits.