14#include "arcane/mesh/PolyhedralMesh.h"
16#include "arcane/core/ISubDomain.h"
17#include "arcane/core/ItemSharedInfo.h"
18#include "arcane/core/ItemTypeInfo.h"
19#include "arcane/core/ItemTypeMng.h"
20#include "arcane/core/VariableBuildInfo.h"
21#include "arcane/core/MeshBuildInfo.h"
23#include "arcane/core/AbstractService.h"
24#include "arcane/core/IMeshFactory.h"
25#include "arcane/core/ItemInternal.h"
26#include "arcane/core/IDoFFamily.h"
27#include "arcane/core/IMeshCompactMng.h"
28#include "arcane/core/IMeshCompacter.h"
29#include "arcane/core/internal/IVariableMngInternal.h"
30#include "arcane/core/internal/IPolyhedralMeshModifier.h"
32#include "arcane/mesh/ItemFamily.h"
33#include "arcane/mesh/DynamicMeshKindInfos.h"
34#include "arcane/utils/ITraceMng.h"
35#include "arcane/utils/FatalErrorException.h"
37#ifdef ARCANE_HAS_POLYHEDRAL_MESH_TOOLS
39#include "arcane/core/IMeshMng.h"
40#include "arcane/core/MeshHandle.h"
41#include "arcane/core/IItemFamily.h"
42#include "arcane/core/internal/IMeshInternal.h"
43#include "arcane/utils/Collection.h"
44#include "arcane/utils/List.h"
47#include "ItemConnectivityMng.h"
54void Arcane::mesh::PolyhedralMesh::
55_errorEmptyMesh()
const
57 ARCANE_FATAL(
"Cannot use PolyhedralMesh if Arcane is not linked with lib Neo");
86 inline static const String m_arcane_item_lids_property_name{
"Arcane_Item_Lids" };
87 inline static const String m_arcane_remove_item_property_name{
"Arcane_Remove_Items" };
97 void preAllocate(Integer
nb_item)
99 Integer
nb_hash = itemsMap().nbBucket();
105 _updateEmptyConnectivity();
125 ARCANE_ASSERT((uids.
size() == items.
size()), (
"one must have items.size==uids.size()"));
127 preAllocate(uids.
size());
129 for (
auto uid : uids) {
131 items[index++] =
ii->localId();
133 m_need_prepare_dump =
true;
134 _updateItemInternalList();
142 void _updateItemInternalList()
144 switch (itemKind()) {
146 m_item_internal_list->cells = _itemsInternal();
149 m_item_internal_list->faces = _itemsInternal();
152 m_item_internal_list->edges = _itemsInternal();
155 m_item_internal_list->nodes = _itemsInternal();
164 void _updateEmptyConnectivity()
167 for (
auto item_kind = 0; item_kind < ItemInternalConnectivityList::MAX_ITEM_KIND; ++item_kind) {
180 void build()
override {
182 m_sub_domain_id = subDomain()->subDomainId();
186 _updateEmptyConnectivity();
192 Integer
nbItem()
const override {
return ItemFamily::nbItem(); }
194 void endUpdate()
override { info() <<
"END UPDATE "<< m_name ;
return ItemFamily::endUpdate(); }
195 IItemFamily* itemFamily()
override {
return this; }
208 ARCANE_NOT_YET_IMPLEMENTED(
"");
215 auto*
mesh_modifier = m_mesh->_internalApi()->polyhedralMeshModifier();
229#ifdef ARCANE_HAS_POLYHEDRAL_MESH_TOOLS
246 class PolyhedralMeshImpl
248 ISubDomain* m_subdomain;
249 Neo::Mesh m_mesh{
"Test" };
251 template <eItemKind IK>
254 static const Neo::ItemKind item_kind = Neo::ItemKind::IK_None;
257 static Neo::ItemKind itemKindArcaneToNeo(eItemKind ik)
261 return Neo::ItemKind::IK_Cell;
263 return Neo::ItemKind::IK_Face;
265 return Neo::ItemKind::IK_Edge;
267 return Neo::ItemKind::IK_Node;
269 return Neo::ItemKind::IK_Dof;
272 return Neo::ItemKind::IK_None;
274 return Neo::ItemKind::IK_Node;
281 Neo::FutureItemRange m_future_items;
284 void fillArrayView(Int32ArrayView local_ids, Neo::EndOfMeshUpdate mesh_state)
286 auto lids = m_future_items.get(mesh_state);
287 std::copy(lids.begin(),lids.end(),local_ids.begin());
289 friend class PolyhedralMeshImpl;
294 explicit PolyhedralMeshImpl(ISubDomain* subDomain)
295 : m_subdomain(subDomain)
300 String name()
const {
return m_mesh.name(); }
302 Integer dimension()
const {
return m_mesh.dimension(); }
304 Integer nbNode()
const {
return m_mesh.nbNodes(); }
305 Integer nbEdge()
const {
return m_mesh.nbEdges(); }
306 Integer nbFace()
const {
return m_mesh.nbFaces(); }
307 Integer nbCell()
const {
return m_mesh.nbCells(); }
308 Integer nbItem(eItemKind ik)
const {
return m_mesh.nbItems(itemKindArcaneToNeo(ik)); }
310 static void _setFaceInfos(
Int32 mod_flags, Face& face)
312 Int32 face_flags = face.itemBase().flags();
313 face_flags &= ~ItemFlags::II_InterfaceFlags;
314 face_flags |= mod_flags;
315 face.mutableItemBase().setFlags(face_flags);
320 void addFamily(eItemKind ik,
const String& name)
322 m_mesh.addFamily(itemKindArcaneToNeo(ik), name.localstr());
327 void scheduleAddItems(PolyhedralFamily* arcane_item_family,
328 Int64ConstSmallSpan uids,
329 ItemLocalIds& item_local_ids)
331 auto& added_items = item_local_ids.m_future_items;
332 auto& item_family = m_mesh.findFamily(itemKindArcaneToNeo(arcane_item_family->itemKind()),
333 arcane_item_family->name().localstr());
334 m_mesh.scheduleAddItems(item_family, std::vector<Int64>{ uids.begin(), uids.end() }, added_items);
336 auto& mesh_graph = m_mesh.internalMeshGraph();
337 item_family.addMeshScalarProperty<Neo::utils::Int32>(PolyhedralFamily::m_arcane_item_lids_property_name.localstr());
338 mesh_graph.addAlgorithm(Neo::MeshKernel::InProperty{ item_family, item_family.lidPropName() },
339 Neo::MeshKernel::OutProperty{ item_family, PolyhedralFamily::m_arcane_item_lids_property_name.localstr() },
340 [arcane_item_family, uids,added_items](Neo::ItemLidsProperty
const& lids_property,
341 Neo::MeshScalarPropertyT<Neo::utils::Int32>&) {
343 arcane_item_family->addItems(uids, arcane_items);
344 arcane_item_family->traceMng()->debug(
Trace::Highest) << arcane_items;
346 auto neo_lids = lids_property.values();
347 if (!std::equal(neo_lids.begin(), neo_lids.end(), arcane_items.begin()))
348 if (!std::equal(added_items.new_items.begin(), added_items.new_items.end(), arcane_items.begin()))
349 arcane_item_family->traceMng()->fatal() <<
"Inconsistent item lids generation between Arcane and Neo.";
355 void scheduleRemoveItems(PolyhedralFamily* arcane_item_family,
356 Int32ConstArrayView local_ids)
358 auto& item_family = m_mesh.findFamily(itemKindArcaneToNeo(arcane_item_family->itemKind()),
359 arcane_item_family->name().localstr());
360 Neo::ItemRange removed_items{Neo::ItemLocalIds{{local_ids.begin(),local_ids.end()},0,0}};
361 m_mesh.scheduleRemoveItems(item_family, removed_items);
363 auto& mesh_graph = m_mesh.internalMeshGraph();
364 item_family.addMeshScalarProperty<Neo::utils::Int32>(PolyhedralFamily::m_arcane_remove_item_property_name.localstr());
365 mesh_graph.addAlgorithm(Neo::MeshKernel::InProperty{ item_family, m_mesh._removeItemPropertyName(item_family) },
366 Neo::MeshKernel::OutProperty{ item_family, PolyhedralFamily::m_arcane_remove_item_property_name.localstr() },
367 [arcane_item_family,local_ids](Neo::MeshScalarPropertyT<Neo::utils::Int32>
const&,
368 Neo::MeshScalarPropertyT<Neo::utils::Int32>&) {
370 arcane_item_family->removeItems(local_ids);
376 void scheduleAddConnectivity(PolyhedralFamily* arcane_source_item_family,
377 ItemLocalIds& source_items,
378 Integer nb_connected_items_per_item,
379 PolyhedralFamily* arcane_target_item_family,
380 Int64ConstArrayView target_items_uids,
384 _scheduleAddConnectivity(arcane_source_item_family,
386 nb_connected_items_per_item,
387 arcane_target_item_family,
394 void scheduleAddConnectivity(PolyhedralFamily* arcane_source_item_family,
395 ItemLocalIds& source_items,
396 Int32ConstSmallSpan nb_connected_items_per_item,
397 PolyhedralFamily* arcane_target_item_family,
398 Int64ConstSmallSpan target_items_uids,
399 String
const& connectivity_name)
401 _scheduleAddConnectivity(arcane_source_item_family,
403 std::vector<Int32>{ nb_connected_items_per_item.begin(), nb_connected_items_per_item.end() },
404 arcane_target_item_family,
412 template <
typename ConnectivitySizeType>
413 void _scheduleAddConnectivity(PolyhedralFamily* arcane_source_item_family,
414 ItemLocalIds& source_items,
415 ConnectivitySizeType&& nb_connected_items_per_item,
416 PolyhedralFamily* arcane_target_item_family,
417 Int64ConstSmallSpan target_item_uids,
418 String
const& connectivity_name)
421 auto& source_family = m_mesh.findFamily(itemKindArcaneToNeo(arcane_source_item_family->itemKind()),
422 arcane_source_item_family->name().localstr());
423 auto& target_family = m_mesh.findFamily(itemKindArcaneToNeo(arcane_target_item_family->itemKind()),
424 arcane_target_item_family->name().localstr());
426 std::vector<Int64> target_item_uids_filtered;
427 target_item_uids_filtered.reserve(target_item_uids.size());
428 std::copy_if(target_item_uids.begin(),
429 target_item_uids.end(),
430 std::back_inserter(target_item_uids_filtered),
431 [](
auto uid) { return uid != NULL_ITEM_UNIQUE_ID; });
433 m_mesh.scheduleAddConnectivity(source_family, source_items.m_future_items, target_family,
434 std::forward<ConnectivitySizeType>(nb_connected_items_per_item),
435 std::move(target_item_uids_filtered),
436 connectivity_name.localstr());
438 auto& mesh_graph = m_mesh.internalMeshGraph();
439 std::string connectivity_add_output_property_name = std::string{
"EndOf" } + connectivity_name.localstr() +
"Add";
440 source_family.addScalarProperty<Neo::utils::Int32>(connectivity_add_output_property_name);
441 mesh_graph.addAlgorithm(Neo::MeshKernel::InProperty{ source_family, connectivity_name.localstr() },
442 Neo::MeshKernel::OutProperty{ source_family, connectivity_add_output_property_name },
443 [arcane_source_item_family, arcane_target_item_family, &source_family, &target_family,
this, connectivity_name](Neo::Mesh::ConnectivityPropertyType
const&,
444 Neo::ScalarPropertyT<Neo::utils::Int32>&) {
445 auto item_internal_connectivity_list = arcane_source_item_family->itemInternalConnectivityList();
447 auto connectivity = m_mesh.getConnectivity(source_family, target_family, connectivity_name.localstr());
449 auto& connectivity_values = source_family.getConcreteProperty<Neo::Mesh::ConnectivityPropertyType>(connectivity_name.localstr());
450 Neo::MeshArrayPropertyProxyT<Neo::Mesh::ConnectivityPropertyType::PropertyDataType> connectivity_proxy{connectivity_values};
451 auto nb_item_data = connectivity_proxy.arrayPropertyOffsets();
452 auto nb_item_size = connectivity_proxy.arrayPropertyOffsetsSize();
453 item_internal_connectivity_list->_setConnectivityNbItem(arcane_target_item_family->itemKind(),
455 auto max_nb_connected_items = connectivity.maxNbConnectedItems();
456 item_internal_connectivity_list->_setMaxNbConnectedItem(arcane_target_item_family->itemKind(), max_nb_connected_items);
457 auto connectivity_values_data = connectivity_proxy.arrayPropertyData();
458 auto connectivity_values_size = connectivity_proxy.arrayPropertyDataSize();
459 item_internal_connectivity_list->_setConnectivityList(arcane_target_item_family->itemKind(),
461 auto connectivity_index_data = connectivity_proxy.arrayPropertyIndex();
462 auto connectivity_index_size = connectivity_proxy.arrayPropertyIndexSize();
463 item_internal_connectivity_list->_setConnectivityIndex(arcane_target_item_family->itemKind(),
467 if (arcane_source_item_family->itemKind() ==
IK_Face && arcane_target_item_family->itemKind() ==
IK_Cell) {
468 std::string flag_definition_output_property_name{
"EndOfFlagDefinition" };
469 source_family.addScalarProperty<Neo::utils::Int32>(flag_definition_output_property_name);
470 mesh_graph.addAlgorithm(Neo::MeshKernel::InProperty{ source_family, connectivity_add_output_property_name }, Neo::MeshKernel::OutProperty{ source_family, flag_definition_output_property_name },
471 [arcane_source_item_family,
this, target_item_uids, &source_items](Neo::ScalarPropertyT<Neo::utils::Int32>
const&, Neo::ScalarPropertyT<Neo::utils::Int32>
const&) {
472 auto current_face_index = 0;
473 auto arcane_faces = arcane_source_item_family->itemInfoListView();
474 for (
auto face_lid : source_items.m_future_items.new_items) {
475 Face current_face = arcane_faces[face_lid].toFace();
476 if (target_item_uids[2 * current_face_index + 1] == NULL_ITEM_LOCAL_ID) {
479 Int32 mod_flags = (target_item_uids[2 * current_face_index] != NULL_ITEM_LOCAL_ID) ? (ItemFlags::II_Boundary | ItemFlags::II_HasBackCell | ItemFlags::II_BackCellIsFirst) : 0;
480 _setFaceInfos(mod_flags, current_face);
482 else if (target_item_uids[2 * current_face_index] == NULL_ITEM_LOCAL_ID) {
484 _setFaceInfos(ItemFlags::II_Boundary | ItemFlags::II_HasFrontCell | ItemFlags::II_FrontCellIsFirst, current_face);
488 _setFaceInfos(ItemFlags::II_HasFrontCell | ItemFlags::II_HasBackCell | ItemFlags::II_BackCellIsFirst, current_face);
490 ++current_face_index;
498 void scheduleSetItemCoordinates(PolyhedralFamily* item_family, ItemLocalIds& local_ids, Real3ConstSmallSpan item_coords, VariableItemReal3& arcane_coords)
500 auto& _item_family = m_mesh.findFamily(itemKindArcaneToNeo(item_family->itemKind()), item_family->name().localstr());
501 std::vector<Neo::utils::Real3> _node_coords(item_coords.size());
503 for (
auto&& node_coord : item_coords) {
504 _node_coords[node_index++] = Neo::utils::Real3{ node_coord.x, node_coord.y, node_coord.z };
506 m_mesh.scheduleSetItemCoords(_item_family, local_ids.m_future_items, _node_coords);
508 auto& mesh_graph = m_mesh.internalMeshGraph();
509 _item_family.addScalarProperty<
Int32>(
"NoOutProperty42");
510 mesh_graph.addAlgorithm(Neo::MeshKernel::InProperty{ _item_family, m_mesh._itemCoordPropertyName(_item_family) },
511 Neo::MeshKernel::OutProperty{ _item_family,
"NoOutProperty42" },
512 [
this, item_family, &_item_family, &arcane_coords](Neo::Mesh::CoordPropertyType
const& item_coords_property,
513 Neo::ScalarPropertyT<Neo::utils::Int32>&) {
515 auto& all_items = _item_family.all();
516 VariableNodeReal3 node_coords{ VariableBuildInfo{ item_family->mesh(),
"NodeCoord" } };
517 for (
auto item : all_items) {
518 arcane_coords[ItemLocalId{ item }] = { item_coords_property[item].x,
519 item_coords_property[item].y,
520 item_coords_property[item].z };
530 Neo::EndOfMeshUpdate applyScheduledOperations() noexcept
532 return m_mesh.applyScheduledOperations();
537 template <>
class PolyhedralMeshImpl::ItemKindTraits<
IK_Cell>
539 static const Neo::ItemKind item_kind = Neo::ItemKind::IK_Cell;
541 template <>
class PolyhedralMeshImpl::ItemKindTraits<
IK_Face>
543 static const Neo::ItemKind item_kind = Neo::ItemKind::IK_Face;
545 template <>
class PolyhedralMeshImpl::ItemKindTraits<
IK_Edge>
547 static const Neo::ItemKind item_kind = Neo::ItemKind::IK_Edge;
549 template <>
class PolyhedralMeshImpl::ItemKindTraits<
IK_Node>
551 static const Neo::ItemKind item_kind = Neo::ItemKind::IK_Node;
553 template <>
class PolyhedralMeshImpl::ItemKindTraits<
IK_DoF>
555 static const Neo::ItemKind item_kind = Neo::ItemKind::IK_Dof;
563class mesh::PolyhedralMesh::PolyhedralMeshModifier
564:
public IPolyhedralMeshModifier
568 explicit PolyhedralMeshModifier(PolyhedralMesh* mesh)
572 void addItems(Int64ConstArrayView unique_ids, Int32ArrayView local_ids, eItemKind ik,
const String& family_name)
override
574 m_mesh->addItems(unique_ids,local_ids,ik,family_name);
577 void removeItems(Int32ConstArrayView local_ids, eItemKind ik,
const String& family_name)
override
579 m_mesh->removeItems(local_ids, ik, family_name);
583 PolyhedralMesh* m_mesh;
589class mesh::PolyhedralMesh::InternalApi
590:
public IMeshInternal
594 explicit InternalApi(PolyhedralMesh* mesh)
596 , m_connectivity_mng(std::make_unique<ItemConnectivityMng>(mesh->traceMng()))
597 , m_polyhedral_mesh_modifier(std::make_unique<PolyhedralMeshModifier>(mesh))
602 void setMeshKind(
const MeshKind& v)
override
604 if (v.meshStructure() != eMeshStructure::Polyhedral && v.meshAMRKind() != eMeshAMRKind::None) {
605 ARCANE_FATAL(
"Incompatible mesh structure ({0}) and amr kind ({1}) for Polyhedral mesh {2}. Must be (Polyhedral,None). ",
606 v.meshStructure(),v.meshAMRKind(), m_mesh->name());
608 m_mesh->m_mesh_kind = v;
611 IItemConnectivityMng* dofConnectivityMng() const noexcept
override
613 return m_connectivity_mng.get();
616 IPolyhedralMeshModifier* polyhedralMeshModifier() const noexcept
override
618 return m_polyhedral_mesh_modifier.get();
623 PolyhedralMesh* m_mesh =
nullptr;
624 std::unique_ptr<IItemConnectivityMng> m_connectivity_mng =
nullptr;
625 std::unique_ptr<IPolyhedralMeshModifier> m_polyhedral_mesh_modifier =
nullptr;
631class mesh::PolyhedralMesh::NoCompactionMeshCompacter
632:
public IMeshCompacter
635 explicit NoCompactionMeshCompacter(PolyhedralMesh* mesh)
637 , m_trace_mng(mesh->traceMng()){}
639 void doAllActions()
override {_info();};
641 void beginCompact()
override {_info();};
642 void compactVariablesAndGroups()
override {_info();};
643 void updateInternalReferences()
override {_info();};
644 void endCompact()
override {_info();};
645 void finalizeCompact()
override {_info();};
647 IMesh* mesh()
const override {
return m_mesh;};
649 const ItemFamilyCompactInfos* findCompactInfos(IItemFamily* family)
const override {_info();
return nullptr;}
651 ePhase phase()
const override {_info();
return ePhase::Ended;}
653 void setSorted(
bool v)
override {_info();};
655 bool isSorted()
const override {_info();
return false;};
659 void _setCompactVariablesAndGroups(
bool v)
override {_info();};
662 PolyhedralMesh* m_mesh =
nullptr;
663 ITraceMng* m_trace_mng =
nullptr;
665 void _info()
const {m_trace_mng->info() << A_FUNCINFO <<
"No compacting in PolyhedralMesh";}
671class mesh::PolyhedralMesh::NoCompactionMeshCompactMng
672:
public IMeshCompactMng
675 explicit NoCompactionMeshCompactMng(PolyhedralMesh* mesh)
677 , m_trace_mng(mesh->traceMng())
678 , m_mesh_compacter{std::make_unique<NoCompactionMeshCompacter>(m_mesh)}
681 IMesh* mesh()
const override {
return m_mesh;}
682 IMeshCompacter* beginCompact()
override
685 return m_mesh_compacter.get();
688 IMeshCompacter* beginCompact(IItemFamily* family)
override
690 ARCANE_UNUSED(family);
692 return m_mesh_compacter.get();
695 void endCompact()
override {_info();};
697 IMeshCompacter* compacter()
override
700 return m_mesh_compacter.get();
705 PolyhedralMesh* m_mesh =
nullptr;
706 ITraceMng* m_trace_mng =
nullptr;
707 std::unique_ptr<IMeshCompacter> m_mesh_compacter =
nullptr;
709 void _info()
const {m_trace_mng->info() << A_FUNCINFO <<
"No compacting in PolyhedralMesh";}
715mesh::PolyhedralMesh::
718 m_mesh_handle._setMesh(
nullptr);
724ITraceMng* mesh::PolyhedralMesh::
727 return m_subdomain->traceMng();
733MeshHandle mesh::PolyhedralMesh::
736 return m_mesh_handle;
742mesh::PolyhedralMesh::
743PolyhedralMesh(ISubDomain* subdomain,
const MeshBuildInfo& mbi)
744: EmptyMesh{ subdomain->traceMng() }
745, m_name{ mbi.name() }
746, m_subdomain{ subdomain }
747, m_mesh_handle{ m_subdomain->defaultMeshHandle() }
748, m_properties(std::make_unique<Properties>(subdomain->propertyMng(), String(
"ArcaneMeshProperties_") + m_name))
749, m_mesh{ std::make_unique<mesh::PolyhedralMeshImpl>(m_subdomain) }
750, m_parallel_mng{ mbi.parallelMngRef().get() }
751, m_mesh_part_info{ makeMeshPartInfoFromParallelMng(m_parallel_mng) }
752, m_item_type_mng(ItemTypeMng::_singleton())
753, m_mesh_kind(mbi.meshKind())
754, m_initial_allocator(*this)
755, m_variable_mng{ subdomain->variableMng() }
756, m_mesh_checker{ this }
757, m_internal_api{std::make_unique<InternalApi>(this)}
758, m_compact_mng{std::make_unique<NoCompactionMeshCompactMng>(this)}
760 m_mesh_handle._setMesh(
this);
761 m_mesh_item_internal_list.mesh =
this;
762 m_default_arcane_families.fill(
nullptr);
768void Arcane::mesh::PolyhedralMesh::
772 m_subdomain->traceMng()->info() <<
"--PolyhedralMesh : allocate items --";
773 UniqueArray<PolyhedralMeshImpl::ItemLocalIds> item_local_ids(item_allocation_info.family_infos.size());
774 auto family_index = 0;
776 for (
auto& family_info : item_allocation_info.family_infos) {
777 bool create_if_needed =
true;
778 auto* item_family = _findItemFamily(family_info.item_kind, family_info.name,create_if_needed);
779 m_trace_mng->debug() <<
" Create items " << family_info.name;
780 m_mesh->scheduleAddItems(item_family, family_info.item_uids, item_local_ids[family_index++]);
784 for (
auto& family_info : item_allocation_info.family_infos) {
785 auto* item_family = _findItemFamily(family_info.item_kind, family_info.name);
786 m_trace_mng->debug(
Trace::High) <<
"Current family " << family_info.name;
787 for (
auto& current_connected_family_info : family_info.connected_family_info) {
788 auto connected_family = _findItemFamily(current_connected_family_info.item_kind, current_connected_family_info.name);
789 m_trace_mng->debug(
Trace::High) <<
" Create connectivity " << current_connected_family_info.connectivity_name;
791 if (!connected_family) {
792 ARCANE_WARNING((String::format(
"Cannot find family {0} with kind {1} "
793 "The connectivity between {1} and this family is skipped",
794 current_connected_family_info.name,
795 current_connected_family_info.item_kind,
800 m_mesh->scheduleAddConnectivity(item_family,
801 item_local_ids[family_index],
802 current_connected_family_info.nb_connected_items_per_item,
804 current_connected_family_info.connected_items_uids,
805 current_connected_family_info.connectivity_name);
810 m_mesh->applyScheduledOperations();
812 for (
auto& family_info : item_allocation_info.family_infos) {
813 if (family_info.item_coordinates.empty()) {
817 auto* item_family = _findItemFamily(family_info.item_kind, family_info.name);
818 if (item_family == itemFamily(
IK_Node)) {
819 m_arcane_node_coords = std::make_unique<VariableNodeReal3>(VariableBuildInfo(
this, family_info.item_coordinates_variable_name));
820 m_arcane_node_coords->setUsed(
true);
823 auto arcane_item_coords_var_ptr = std::make_unique<VariableItemReal3>(VariableBuildInfo(
this, family_info.item_coordinates_variable_name),
824 item_family->itemKind());
825 arcane_item_coords_var_ptr->setUsed(
true);
826 m_arcane_item_coords.push_back(std::move(arcane_item_coords_var_ptr));
830 for (
auto& family : m_arcane_families) {
837 for (
auto& family_info : item_allocation_info.family_infos) {
838 if (family_info.item_coordinates.empty()) {
842 auto* item_family = _findItemFamily(family_info.item_kind, family_info.name);
843 if (item_family == itemFamily(
IK_Node)) {
844 m_mesh->scheduleSetItemCoordinates(item_family, item_local_ids[family_index], family_info.item_coordinates, *m_arcane_node_coords);
847 m_mesh->scheduleSetItemCoordinates(item_family, item_local_ids[family_index], family_info.item_coordinates, *m_arcane_item_coords[index++].get());
849 m_mesh->applyScheduledOperations();
850 m_is_allocated =
true;
852 itemTypeMng()->setMeshWithGeneralCells(
this);
915 return m_mesh->
nbItem(ik);
924 if (m_default_arcane_families[
IK_Node])
925 return m_default_arcane_families[
IK_Node]->allItems();
936 if (m_default_arcane_families[
IK_Edge])
937 return m_default_arcane_families[
IK_Edge]->allItems();
948 if (m_default_arcane_families[
IK_Face])
949 return m_default_arcane_families[
IK_Face]->allItems();
960 if (m_default_arcane_families[
IK_Cell])
961 return m_default_arcane_families[
IK_Cell]->allItems();
972 if (m_default_arcane_families[
IK_Node])
973 return m_default_arcane_families[
IK_Node]->allItems().own();
984 if (m_default_arcane_families[
IK_Edge])
985 return m_default_arcane_families[
IK_Edge]->allItems().own();
996 if (m_default_arcane_families[
IK_Face])
997 return m_default_arcane_families[
IK_Face]->allItems().own();
1008 if (m_default_arcane_families[
IK_Cell])
1009 return m_default_arcane_families[
IK_Cell]->allItems().own();
1020 if (m_default_arcane_families[
IK_Cell])
1021 return m_default_arcane_families[
IK_Cell]->allItems().outerFaceGroup();
1029mesh::PolyhedralFamily* mesh::PolyhedralMesh::
1030_createItemFamily(
eItemKind ik,
const String& name)
1032 m_mesh->addFamily(ik, name);
1033 m_arcane_families.push_back(std::make_unique<PolyhedralFamily>(
this, ik, name));
1034 auto current_family = m_arcane_families.back().get();
1035 if (m_default_arcane_families[ik] ==
nullptr) {
1036 m_default_arcane_families[ik] = current_family;
1037 _updateMeshInternalList(ik);
1039 m_item_family_collection.add(current_family);
1040 current_family->build();
1041 return current_family;
1050 return _createItemFamily(ik, name);
1056void mesh::PolyhedralMesh::
1059 createItemFamily(
IK_Cell,
"CellFamily");
1060 createItemFamily(
IK_Node,
"NodeFamily");
1061 auto cell_family = m_default_arcane_families[
IK_Cell];
1062 auto node_family = m_default_arcane_families[
IK_Node];
1065 PolyhedralMeshImpl::ItemLocalIds cell_lids, node_lids;
1066 m_mesh->scheduleAddItems(cell_family, cell_uids.constView(), cell_lids);
1067 m_mesh->scheduleAddItems(node_family, node_uids.constView(), node_lids);
1069 m_mesh->scheduleAddConnectivity(cell_family, cell_lids, nb_node, node_family, node_uids, String{
"CellToNodes" });
1070 m_mesh->scheduleAddConnectivity(node_family, node_lids, 1, cell_family,
1072 m_mesh->applyScheduledOperations();
1074 node_family->endUpdate();
1083void mesh::PolyhedralMesh::
1087 for (
auto ik = 0; ik < NB_ITEM_KIND; ++ik) {
1090 m_empty_arcane_families[ik] = std::make_unique<mesh::PolyhedralFamily>(
this, (
eItemKind)ik, name);
1091 m_default_arcane_families[ik] = m_empty_arcane_families[ik].get();
1102 return m_default_arcane_families[
IK_Node];
1111 return m_default_arcane_families[
IK_Edge];
1120 return m_default_arcane_families[
IK_Face];
1129 return m_default_arcane_families[
IK_Cell];
1132void mesh::PolyhedralMesh::
1137 m_mesh_item_internal_list.cells = m_default_arcane_families[kind]->itemsInternal();
1138 m_mesh_item_internal_list._internalSetCellSharedInfo(m_default_arcane_families[kind]->commonItemSharedInfo());
1141 m_mesh_item_internal_list.faces = m_default_arcane_families[kind]->itemsInternal();
1142 m_mesh_item_internal_list._internalSetFaceSharedInfo(m_default_arcane_families[kind]->commonItemSharedInfo());
1145 m_mesh_item_internal_list.edges = m_default_arcane_families[kind]->itemsInternal();
1146 m_mesh_item_internal_list._internalSetEdgeSharedInfo(m_default_arcane_families[kind]->commonItemSharedInfo());
1149 m_mesh_item_internal_list.nodes = m_default_arcane_families[kind]->itemsInternal();
1150 m_mesh_item_internal_list._internalSetNodeSharedInfo(m_default_arcane_families[kind]->commonItemSharedInfo());
1162mesh::PolyhedralFamily* mesh::PolyhedralMesh::
1165 return m_default_arcane_families[ik];
1174 return _itemFamily(ik);
1183 return m_item_type_mng;
1189mesh::PolyhedralFamily* mesh::PolyhedralMesh::
1190_findItemFamily(
eItemKind ik,
const String& name,
bool create_if_needed)
1193 auto found_family = _itemFamily(ik);
1195 if (found_family->name() == name)
1196 return found_family;
1198 for (
auto& family : m_arcane_families) {
1199 if (family->itemKind() == ik && family->name() == name)
1200 return family.get();
1202 if (!create_if_needed)
1204 return _createItemFamily(ik, name);
1213 ARCANE_UNUSED(register_modifier_if_created);
1214 return _findItemFamily(ik, name, create_if_needed);
1220mesh::PolyhedralFamily* mesh::PolyhedralMesh::
1223 return m_default_arcane_families[ik];
1232 ARCANE_ASSERT(m_arcane_node_coords, (
"Node coordinates not yet loaded."));
1233 return *m_arcane_node_coords;
1243 for (
auto& family : m_arcane_families) {
1244 group = family->findGroup(name);
1257 m_all_groups.clear();
1258 for (
auto& family : m_arcane_families) {
1260 m_all_groups.add(*i_group);
1262 return m_all_groups;
1271 for (
auto& family : m_arcane_families) {
1272 family->destroyGroups();
1282 return m_item_family_collection;
1291 return m_internal_api.get();
1300 return m_compact_mng.get();
1306void mesh::PolyhedralMesh::
1309 auto* item_family = _findItemFamily(ik, family_name,
false);
1310 PolyhedralMeshImpl::ItemLocalIds item_local_ids;
1311 m_mesh->scheduleAddItems(item_family,unique_ids,item_local_ids);
1312 auto mesh_state = m_mesh->applyScheduledOperations();
1313 item_local_ids.fillArrayView(local_ids,mesh_state);
1319void mesh::PolyhedralMesh::
1322 auto* item_family = _findItemFamily(ik, family_name,
false);
1323 m_mesh->scheduleRemoveItems(item_family,local_ids);
1324 m_mesh->applyScheduledOperations();
1333 return allCells().activeCellGroup();
1341 return allCells().ownActiveCellGroup();
1350 return allCells().levelCellGroup(level);
1359 return allCells().ownLevelCellGroup(level);
1368 return allCells().activeFaceGroup();
1377 return allCells().ownActiveFaceGroup();
1386 return allCells().innerActiveFaceGroup();
1394 return allCells().outerActiveFaceGroup();
1420Arcane::mesh::PolyhedralMesh::
1421~PolyhedralMesh() =
default;
1426Arcane::mesh::PolyhedralMesh::
1431, m_mesh_kind(
mbi.meshKind())
1438void Arcane::mesh::PolyhedralMesh::
1439read([[maybe_unused]]
const String& filename)
1447void Arcane::mesh::PolyhedralMesh::
1450 ARCANE_UNUSED(item_allocation_info);
1480 ISubDomain*
sd =
mm->variableMng()->_internalApi()->internalSubDomain();
1484 static String name() {
return "ArcanePolyhedralMeshFactory"; }
1488 ServiceProperty(PolyhedralMeshFactory::name().localstr(), ST_Application),
1494#if ARCANE_HAS_POLYHEDRAL_MESH_TOOLS
1499String mesh::PolyhedralMesh::
1502 return PolyhedralMeshFactory::name();
#define ARCANE_CHECK_POINTER(ptr)
Macro retournant le pointeur ptr s'il est non nul ou lancant une exception s'il est nul.
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Ce fichier contient les différentes fabriques de services et macro pour enregistrer les services.
#define ARCANE_SERVICE_INTERFACE(ainterface)
Macro pour déclarer une interface lors de l'enregistrement d'un service.
Classe de base d'un service.
EnumeratorT< ItemGroup > Enumerator
Type d'un itérateur sur toute la collection.
Interface d'une famille de DoF.
Interface d'une famille d'entités.
virtual NodeGroup ownNodes()=0
Groupe de tous les noeuds propres au domaine.
virtual IItemFamily * nodeFamily()=0
Retourne la famille des noeuds.
virtual String name() const =0
Nom du maillage.
virtual Integer nbCell()=0
Nombre de mailles du maillage.
virtual CellGroup ownCells()=0
Groupe de toutes les mailles propres au domaine.
virtual FaceGroup ownFaces()=0
Groupe de toutes les faces propres au domaine.
virtual FaceGroup allFaces()=0
Groupe de toutes les faces.
virtual Integer nbEdge()=0
Nombre d'arêtes du maillage.
virtual IItemFamily * itemFamily(eItemKind ik)=0
Retourne la famille d'entité de type ik.
virtual IItemFamily * edgeFamily()=0
Retourne la famille des arêtes.
virtual Integer nbNode()=0
Nombre de noeuds du maillage.
virtual FaceGroup outerFaces()=0
Groupe de toutes les faces sur la frontière.
virtual IItemFamily * findItemFamily(eItemKind ik, const String &name, bool create_if_needed=false, bool register_modifier_if_created=false)=0
Retourne la famille de nom name.
virtual Integer nbItem(eItemKind ik)=0
Nombre d'éléments du genre ik.
virtual Integer dimension()=0
Dimension du maillage (1D, 2D ou 3D).
virtual IItemFamily * faceFamily()=0
Retourne la famille des faces.
virtual EdgeGroup ownEdges()=0
Groupe de toutes les arêtes propres au domaine.
virtual NodeGroup allNodes()=0
Groupe de tous les noeuds.
virtual CellGroup allCells()=0
Groupe de toutes les mailles.
virtual Integer nbFace()=0
Nombre de faces du maillage.
virtual IItemFamily * cellFamily()=0
Retourne la famille des mailles.
virtual IItemFamily * createItemFamily(eItemKind ik, const String &name)=0
Créé une famille de particule de nom name.
virtual EdgeGroup allEdges()=0
Groupe de toutes les arêtes.
Interface du service gérant la lecture d'un maillage.
Interface du gestionnaire des maillages.
virtual VariableNodeReal3 & nodesCoordinates()=0
Coordonnées des noeuds.
virtual FaceGroup outerActiveFaces()=0
Groupe de toutes les faces actives sur la frontière.
virtual void destroyGroups()=0
Détruit tous les groupes de toutes les familles.
virtual CellGroup allLevelCells(const Integer &level)=0
Groupe de toutes les mailles de niveau level.
virtual FaceGroup innerActiveFaces()=0
Groupe de toutes les faces actives.
virtual ItemGroupCollection groups()=0
Liste des groupes.
virtual ItemGroup findGroup(const String &name)=0
Retourne le groupe de nom name ou le groupe nul s'il n'y en a pas.
virtual IMeshInternal * _internalApi()=0
API interne à Arcane.
virtual CellGroup allActiveCells()=0
virtual FaceGroup allActiveFaces()=0
Groupe de toutes les faces actives.
virtual ItemTypeMng * itemTypeMng() const =0
Gestionnaire de types d'entités associé
virtual CellGroup ownActiveCells()=0
Groupe de toutes les mailles actives et propres au domaine.
virtual CellGroup ownLevelCells(const Integer &level)=0
Groupe de toutes les mailles propres de niveau level.
virtual FaceGroup ownActiveFaces()=0
Groupe de toutes les faces actives propres au domaine.
virtual IMeshCompactMng * _compactMng()=0
Interface du gestionnaire d'un sous-domaine.
Groupe d'entités de maillage.
Structure interne d'une entité de maillage.
Infos sur un type d'entité du maillage.
Gestionnaire des types d'entités de maillage.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Paramètres nécessaires à la construction d'un maillage.
void build() override
Construction de niveau build du service.
IPrimaryMesh * createMesh(IMeshMng *mm, const MeshBuildInfo &build_info) override
Créé un maillage avec les informations de build_info.
Structure contenant les informations pour créer un service.
Integer nbCell() override
Nombre de mailles du maillage.
Integer dimension() override
Dimension du maillage (1D, 2D ou 3D).
Integer nbNode() override
Nombre de noeuds du maillage.
void endUpdate() override
Notifie l'instance de la fin de la modification du maillage.
Integer nbEdge() override
Nombre d'arêtes du maillage.
Integer nbItem(eItemKind ik) override
Nombre d'éléments du genre ik.
Integer nbFace() override
Nombre de faces du maillage.
Classe temporaire pour conserver un ItemSharedInfo et un type d'entité.
IDoFFamily * toDoFFamily() override
Retourne l'interface de la famille de particule de cette famille.
DoFVectorView addGhostDoFs(Int64ConstArrayView dof_uids, Int32ArrayView dof_lids, Int32ConstArrayView owners)
L'ajout de fantomes doit etre suivi d'un appel de computeSynchronizeInfos.
void endUpdate() override
Notifie la fin de modification de la liste des entités.
Integer nbItem() const override
Nombre d'entités.
String name() const override
Nom de la famille.
DoFVectorView addDoFs(Int64ConstArrayView dof_uids, Int32ArrayView dof_lids)
En entree les uids des dofs et on recupere leurs lids.
String fullName() const override
Nom complet de la famille (avec celui du maillage)
ItemGroup allItems() const override
Groupe de toutes les entités.
Vue modifiable d'un tableau d'un type T.
constexpr Integer size() const noexcept
Retourne la taille du tableau.
void resize(Int64 s)
Change le nombre d'éléments du tableau à s.
Vue constante d'un tableau de type T.
Vue d'un tableau d'éléments de type T.
constexpr ARCCORE_HOST_DEVICE bool empty() const noexcept
Retourne true si le tableau est vide (dimension nulle)
constexpr ARCCORE_HOST_DEVICE SizeType size() const noexcept
Retourne la taille du tableau.
Chaîne de caractères unicode.
Vecteur 1D de données avec sémantique par valeur (style STL).
ItemGroupT< Cell > CellGroup
Groupe de mailles.
ItemGroupT< Face > FaceGroup
Groupe de faces.
ItemGroupT< Edge > EdgeGroup
Groupe d'arêtes.
ItemGroupT< Node > NodeGroup
Groupe de noeuds.
#define ARCANE_REGISTER_SERVICE(aclass, a_service_property,...)
Macro pour enregistrer un service.
MeshVariableScalarRefT< Node, Real3 > VariableNodeReal3
Grandeur au noeud de type coordonnées.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
UniqueArray< Int64 > Int64UniqueArray
Tableau dynamique à une dimension d'entiers 64 bits.
Collection< ItemGroup > ItemGroupCollection
Collection de groupes d'éléments du maillage.
Collection< IItemFamily * > ItemFamilyCollection
Collection de familles d'entités.
ConstArrayView< Int32 > Int32ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.
Collection< IItemFamily * > IItemFamilyCollection
Collection de familles d'entités.
UniqueArray< Int32 > Int32UniqueArray
Tableau dynamique à une dimension d'entiers 32 bits.
eItemKind
Genre d'entité de maillage.
@ IK_Particle
Entité de maillage de genre particule.
@ IK_Node
Entité de maillage de genre noeud.
@ IK_Cell
Entité de maillage de genre maille.
@ IK_Unknown
Entité de maillage de genre inconnu ou non initialisé
@ IK_Face
Entité de maillage de genre face.
@ IK_DoF
Entité de maillage de genre degre de liberte.
@ IK_Edge
Entité de maillage de genre arête.
const char * itemKindName(eItemKind kind)
Nom du genre d'entité.
ConstArrayView< Int64 > Int64ConstArrayView
Equivalent C d'un tableau à une dimension d'entiers 64 bits.
ArrayView< Int32 > Int32ArrayView
Equivalent C d'un tableau à une dimension d'entiers 32 bits.
@ Highest
Niveau le plus élevé
Int32 Integer
Type représentant un entier.