Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
ItemGroupDynamicMeshObserver.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7#include "arcane/mesh/ItemGroupDynamicMeshObserver.h"
8
9/*---------------------------------------------------------------------------*/
10/*---------------------------------------------------------------------------*/
11
12#include "arcane/mesh/DynamicMesh.h"
13#include "arcane/mesh/DynamicMeshIncrementalBuilder.h"
14#include "arcane/mesh/ItemFamily.h"
15
16#include "arcane/utils/ITraceMng.h"
17#include "arcane/utils/ArgumentException.h"
18
19#include "arcane/ItemPrinter.h"
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane::mesh
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
31executeExtend(const Int32ConstArrayView* new_items_info)
32{
33 IItemFamily* parent_family = m_mesh->parentGroup().itemFamily();
34
35 // Parent families have already been attached.
36 ARCANE_ASSERT((m_mesh->cellFamily()->parentFamily()->itemKind() == parent_family->itemKind()),
37 ("Bad Face parent family %s", m_mesh->cellFamily()->parentFamily()->name().localstr()));
38
39 ItemVectorView all_group(parent_family->view(*new_items_info));
40
41 m_mesh->incrementalBuilder()->addParentItems(all_group, IK_Cell);
42}
43
44/*---------------------------------------------------------------------------*/
45
48{
49 IItemFamily* family = m_mesh->cellFamily();
50 IItemFamily* parent_family = m_mesh->parentGroup().itemFamily();
51 ItemInfoListView parent_internals(parent_family);
52
53 // info contains the localIds deleted from the old group,
54 const Int32ConstArrayView& parent_deleted_lids = *info;
55
56 // The uniqueIds of the Cell are identical to the parent, so we search in the local family
57 Int64UniqueArray parent_uids;
58 parent_uids.reserve(parent_deleted_lids.size());
59 for (Integer i = 0; i < parent_deleted_lids.size(); ++i) {
60 Int64 parent_uid = parent_internals[parent_deleted_lids[i]].uniqueId();
61 if (parent_uid != NULL_ITEM_UNIQUE_ID) // prevent from completly detached items
62 {
63 parent_uids.add(parent_uid);
64 }
65 }
66
67 Int32UniqueArray to_delete_lids(parent_uids.size(), NULL_ITEM_LOCAL_ID);
68 family->itemsUniqueIdToLocalId(to_delete_lids,
69 parent_uids,
70 true); // Fatal if not found
71
72#ifdef ARCANE_DEBUG
73 ITraceMng* traceMng = m_mesh->traceMng();
74 ItemInfoListView internals(family);
75 for (Integer i = 0; i < parent_uids.size(); ++i) {
76 traceMng->debug(Trace::High) << "Reduce with item "
77 << ItemPrinter(internals[to_delete_lids[i]])
78 << " parent item " << parent_uids[i];
79 }
80#endif /* ARCANE_DEBUG */
81
82 m_mesh->removeCells(to_delete_lids);
83}
84
85/*---------------------------------------------------------------------------*/
86
89{
90 if (!pinfo)
91 throw ArgumentException(A_FUNCINFO, "Compact info required");
92
93 // Compaction is handled in ItemFamily::_compactFromParentFamily
94 // in order to proceed consistently family by family
95 if (arcaneIsDebug()) {
96 ITraceMng* trace_mng = m_mesh->traceMng();
97 const Int32ConstArrayView& old_to_new_ids = *pinfo;
98 IItemFamily* family = m_mesh->cellFamily();
99 ItemFamily* parent_family = ARCANE_CHECK_POINTER(dynamic_cast<ItemFamily*>(family->parentFamily()));
100 for (Integer i = 0; i < old_to_new_ids.size(); ++i) {
101 trace_mng->debug(Trace::Highest) << "OldToNew " << parent_family->name() << " " << i << " " << old_to_new_ids[i];
102 }
103 }
104}
105
106/*---------------------------------------------------------------------------*/
107
110{
111 ARCANE_FATAL("Not implemented");
112}
113
114/*---------------------------------------------------------------------------*/
115/*---------------------------------------------------------------------------*/
116
117} // End namespace Arcane::mesh
118
119/*---------------------------------------------------------------------------*/
120/*---------------------------------------------------------------------------*/
#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_FATAL(...)
Macro throwing a FatalErrorException.
Integer size() const
Number of elements in the vector.
void add(ConstReferenceType val)
Adds element val to the end of the array.
void reserve(Int64 new_capacity)
Reserves memory for new_capacity elements.
constexpr Integer size() const noexcept
Number of elements in the array.
Interface of an entity family.
Definition IItemFamily.h:83
virtual IItemFamily * parentFamily() const =0
IItemFamily parent.
virtual eItemKind itemKind() const =0
Entity kind.
virtual ItemVectorView view(Int32ConstArrayView local_ids)=0
View on the entities.
virtual void itemsUniqueIdToLocalId(Int32ArrayView local_ids, Int64ConstArrayView unique_ids, bool do_fatal=true) const =0
Converts an array of unique numbers to local numbers.
virtual TraceMessageDbg debug(Trace::eDebugLevel=Trace::Medium)=0
Stream for a debug message.
__host__ __device__ ItemUniqueId uniqueId(Int32 local_id) const
uniqueId() of the entity with local ID local_id
View of a list to obtain information about entities.
Utility class for printing information about an entity.
Definition ItemPrinter.h:35
View on a vector of entities.
String name() const override
Family name.
Definition ItemFamily.h:140
void executeReduce(const Int32ConstArrayView *info)
Execute the action associated with the extension.
void executeExtend(const Int32ConstArrayView *new_items_info)
Execute the action associated with the extension.
void executeInvalidate()
Execute the action associated with invalidation.
void executeCompact(const Int32ConstArrayView *pinfo)
Executes the action associated with compaction.
UniqueArray< Int64 > Int64UniqueArray
Dynamic 1D array of 64-bit integers.
Definition UtilsTypes.h:339
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:482
bool arcaneIsDebug()
True if the ARCANE_DEBUG macro is defined.
Definition Misc.cc:76
UniqueArray< Int32 > Int32UniqueArray
Dynamic 1D array of 32-bit integers.
Definition UtilsTypes.h:341
@ IK_Cell
Cell mesh entity.