14#include "arcane/materials/internal/MaterialModifierOperation.h"
16#include "arcane/utils/ITraceMng.h"
17#include "arcane/utils/FatalErrorException.h"
19#include "arcane/utils/IMemoryRessourceMng.h"
21#include "arcane/core/ItemPrinter.h"
22#include "arcane/core/ItemGroup.h"
23#include "arcane/core/IItemFamily.h"
24#include "arcane/core/materials/IMeshMaterial.h"
25#include "arcane/core/materials/internal/IMeshComponentInternal.h"
27#include "arcane/materials/internal/MeshMaterialVariableIndexer.h"
38MaterialModifierOperation::
39MaterialModifierOperation()
47MaterialModifierOperation::
48MaterialModifierOperation(IMeshMaterial* mat, SmallSpan<const Int32> ids,
bool is_add)
49: MaterialModifierOperation()
53 m_ids.resize(ids.size());
54 MemoryUtils::copy<Int32>(m_ids, ids);
71Int32 MaterialModifierOperation::
72_checkMaterialPresence(MaterialModifierOperation* operation)
88 if (presence_flags[lid]) {
90 <<
" is present several times in add/remove list for material mat=" << name;
93 presence_flags[lid] =
true;
96 if (operation->
isAdd()) {
97 for (
Int32 lid : mat_local_ids) {
98 if (presence_flags[lid]) {
100 <<
" is already in material mat=" << name;
106 for (
Int32 lid : mat_local_ids) {
107 presence_flags[lid] =
false;
111 if (presence_flags[lid]) {
113 <<
" is not in material mat=" << name;
135void MaterialModifierOperation::
136_filterValidIds(MaterialModifierOperation* operation,
Int32Array& valid_ids)
139 const bool do_add = operation->
isAdd();
152 if (!presence_flags[lid]) {
153 unique_occurence_lids.
add(lid);
154 presence_flags[lid] =
true;
161 for (
Int32 lid : mat_local_ids) {
162 if (presence_flags[lid]) {
170 for (
Int32 lid : mat_local_ids)
171 presence_flags[lid] =
false;
173 for (
Int32 lid : unique_occurence_lids) {
174 if (presence_flags[lid]) {
181 tm->
info(4) <<
"FILTERED_IDS n=" << valid_ids.
size() <<
" ids=" << valid_ids;
187void MaterialModifierOperation::
191 const bool filter_invalid =
true;
194 if (filter_invalid) {
197 m_ids.swap(filtered_ids);
200 ARCANE_FATAL(
"Invalid values for adding items in material name={0} nb_error={1}",
201 m_mat->name(), nb_error);
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
Memory and allocator management functions.
Integer size() const
Number of elements in the vector.
void clear()
Removes the elements from the array.
void add(ConstReferenceType val)
Adds element val to the end of the array.
void reserve(Int64 new_capacity)
Reserves memory for new_capacity elements.
Interface of an entity family.
virtual Int32 maxLocalId() const =0
virtual TraceMessage info()=0
Stream for an information message.
IItemFamily * itemFamily() const
Entity family to which this group belongs (0 for the null group).
View of a list to obtain information about entities.
Utility class for printing information about an entity.
virtual MeshMaterialVariableIndexer * variableIndexer() const =0
Indexer to access partial variables.
virtual String name() const =0
Component name.
virtual CellGroup cells() const =0
Group of cells for this material.
virtual ITraceMng * traceMng()=0
Associated trace manager.
virtual IMeshComponentInternal * _internalApi()=0
Internal API.
Interface of a mesh material.
IMeshMaterial * material() const
The material for which cells are to be added/removed.
bool isAdd() const
Indicates whether the operation is to add or remove cells from the material.
static Int32 _checkMaterialPresence(MaterialModifierOperation *operation)
Checks if the cells ids are already in the material mat.
static void _filterValidIds(MaterialModifierOperation *operation, Int32Array &valid_ids)
Filters the array of cells ids so that it is valid.
SmallSpan< const Int32 > ids() const
List of localId() of cells to add/remove.
Indexer for material variables.
View of an array of elements of type T.
Unicode character string.
1D data vector with value semantics (STL style).
Always enables tracing in Arcane parts concerning materials.
Int32 Integer
Type representing an integer.
Array< Int32 > Int32Array
Dynamic one-dimensional array of 32-bit integers.
std::int32_t Int32
Signed integer type of 32 bits.