14#include "arcane/materials/internal/MeshComponentData.h"
16#include "arcane/utils/FatalErrorException.h"
18#include "arcane/core/IItemFamily.h"
19#include "arcane/core/ItemPrinter.h"
20#include "arcane/core/materials/IMeshMaterialMng.h"
21#include "arcane/core/materials/internal/IMeshMaterialMngInternal.h"
23#include "arcane/materials/internal/MeshMaterialVariableIndexer.h"
24#include "arcane/materials/internal/MeshComponentPartData.h"
37 Int16 component_id, ComponentItemSharedInfo* shared_info,
39: TraceAccessor(component->traceMng())
40, m_component(component)
41, m_component_id(component_id)
43, m_constituent_local_id_list(shared_info, String(
"MeshComponentDataIdList") + name)
47 m_variable_indexer =
new MeshMaterialVariableIndexer(traceMng(), name);
48 m_is_indexer_owner =
true;
59 if (m_is_indexer_owner)
60 delete m_variable_indexer;
69void MeshComponentData::
73 m_part_data->_setConstituentListView(m_constituent_local_id_list.view());
79void MeshComponentData::
80_resizeItemsInternal(Integer nb_item)
82 m_constituent_local_id_list.resize(nb_item);
89void MeshComponentData::
90_setVariableIndexer(MeshMaterialVariableIndexer* indexer)
92 m_variable_indexer = indexer;
93 m_is_indexer_owner =
false;
99void MeshComponentData::
100_setItems(
const ItemGroup& group)
103 if (m_variable_indexer)
104 m_variable_indexer->setCells(group);
110void MeshComponentData::
113 m_part_data =
new MeshComponentPartData(m_component, m_name);
114 m_part_data->setRecomputeFunctor(&m_recompute_part_data_functor);
127void MeshComponentData::
137 for (
Integer i = 0, nb = current_internals.
size(); i < nb; ++i) {
138 Int32 lid = local_ids[i];
139 Int32 new_lid = old_to_new_ids[lid];
140 if (new_lid != NULL_ITEM_LOCAL_ID) {
141 new_internals.
add(current_internals[i]);
148 _resizeItemsInternal(new_internals.
size());
156void MeshComponentData::
162 const bool do_lazy_evaluation =
true;
163 if (do_lazy_evaluation)
164 m_part_data->setNeedRecompute();
166 m_part_data->_setFromMatVarIndexes(m_variable_indexer->matvarIndexes(), queue);
172void MeshComponentData::
173_rebuildPartDataDirect()
175 RunQueue& queue = m_component->materialMng()->_internalApi()->runQueue();
176 m_part_data->_setFromMatVarIndexes(m_variable_indexer->matvarIndexes(), queue);
182void MeshComponentData::
185 if (!arcaneIsCheck())
188 info(4) <<
"Check valid component name=" << name();
189 m_variable_indexer->checkValid();
193 if (m_items != m_variable_indexer->cells())
194 ARCANE_FATAL(
"Incoherent group for component name={0} data={1} indexer={2}",
195 name(), m_items.name(), m_variable_indexer->cells().name());
204 IItemFamily* family = m_items.itemFamily();
205 UniqueArray<Int32> presence(family->maxLocalId());
208 presence[iitem.itemLocalId()] = 1;
211 for (Integer i = 0, n = indexer_local_ids.size(); i < n; ++i)
212 presence[indexer_local_ids[i]] += 2;
213 ItemInfoListView items_internal = family->itemInfoListView();
215 for (Integer i = 0, n = presence.size(); i < n; ++i) {
216 Int32 v = presence[i];
217 if (v == 3 || v == 0)
219 Cell cell(items_internal[i]);
221 info(4) <<
"WARNING: Incoherence between group and internals "
222 <<
" component=" << name() <<
" v=" << v
223 <<
" cell=" << ItemPrinter(cell);
226 warning() <<
"WARNING: Incoherence between group and internals "
227 <<
" component=" << name() <<
" nb_error=" << nb_error;
233 ConstArrayView<MatVarIndex> mat_var_indexes(m_variable_indexer->matvarIndexes());
234 Integer nb_val = mat_var_indexes.size();
235 info(4) <<
"CheckValid component_name=" << name()
236 <<
" matvar_indexes=" << mat_var_indexes;
237 info(4) <<
"Cells=" << m_variable_indexer->cells().view().localIds();
238 for (Integer i = 0; i < nb_val; ++i) {
239 MatVarIndex component_mvi = m_constituent_local_id_list.variableIndex(i);
240 MatVarIndex mvi = mat_var_indexes[i];
241 if (component_mvi != mvi)
242 ARCANE_FATAL(
"Bad 'var_index' environment={3} component='{0}' direct='{1}' i={2}",
243 component_mvi, mvi, i, name());
247 m_part_data->checkValid();
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
Integer size() const
Number of elements in the vector.
Execution queue for an accelerator.
void add(ConstReferenceType val)
Adds element val to the end of the array.
Constant view of an array of type T.
constexpr Integer size() const noexcept
Number of elements in the array.
Index of an Item in a variable.
Interface of a component (material or environment) of a mesh.
Data of a constituent (material or medium) of a mesh.
ConstituentItemLocalIdList m_constituent_local_id_list
List of ConstituentItemIndex for this constituent.
1D data vector with value semantics (STL style).
Always enables tracing in Arcane parts concerning materials.
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
std::int16_t Int16
Signed integer type of 16 bits.
@ Cell
The mesh is AMR by cell.
std::int32_t Int32
Signed integer type of 32 bits.