Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions arcane/src/arcane/core/ItemTypeInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
#include "arcane/utils/Array.h"

#include "arcane/core/ItemTypeId.h"
// No longer used but keep for compatibility
// No longer used but keep for compatibility (October 2026)
// Remove this in future versions of Arcane
#include "arcane/core/ItemTypeMng.h"

/*---------------------------------------------------------------------------*/
Expand All @@ -30,7 +31,6 @@ class ItemTypeMng;

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/

/*!
* \ingroup Mesh
* \brief Info on a mesh entity type.
Expand All @@ -39,11 +39,6 @@ class ItemTypeMng;
* a hexahedral cell, a quadrilateral cell.
*
* \sa ItemTypeMng
*
* There should only be one instance per entity type. Creation of a
* type is done by the derived class ItemTypeInfoBuilder. Types must
* be created before any mesh creation (i.e. during
* the initialization of the architecture).
*/
class ItemTypeInfo
{
Expand Down Expand Up @@ -190,7 +185,6 @@ class ItemTypeInfo
Integer m_first_item_index = 0;
String m_type_name;
const ItemTypeInfo* m_linear_type = this;
ItemTypeMng* m_mng = nullptr;
Array<Int32>* m_ids_buffer = nullptr;
};

Expand Down
18 changes: 14 additions & 4 deletions arcane/src/arcane/core/ItemTypeInfoBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ _checkDimension(Int16 dim)
/*---------------------------------------------------------------------------*/

void ItemTypeInfoBuilder::
setInfos(ItemTypeMng* mng, ItemTypeId type_id, String type_name,
Dimension dimension, Int32 nb_node, Int32 nb_edge, Int32 nb_face)
_setInfos(Array<Int32>* ids_buffer, ItemTypeId type_id, String type_name, Dimension dimension,
Int32 nb_node, Int32 nb_edge, Int32 nb_face)
{
m_mng = mng;
m_ids_buffer = &mng->m_ids_buffer;
m_ids_buffer = ids_buffer;
m_type_id = type_id;
m_linear_type_id = type_id;
m_linear_type = this;
m_dimension = static_cast<Int16>(dimension);
m_nb_node = nb_node;
m_type_name = type_name;
Expand All @@ -59,6 +59,16 @@ setInfos(ItemTypeMng* mng, ItemTypeId type_id, String type_name,
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/

void ItemTypeInfoBuilder::
setInfos(ItemTypeMng* mng, ItemTypeId type_id, String type_name,
Dimension dimension, Int32 nb_node, Int32 nb_edge, Int32 nb_face)
{
_setInfos(&mng->m_ids_buffer, type_id, type_name, dimension, nb_node, nb_edge, nb_face);
}

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/

void ItemTypeInfoBuilder::
setInfos(ItemTypeMng* mng, ItemTypeId type_id, String type_name,
Int32 nb_node, Int32 nb_edge, Int32 nb_face)
Expand Down
11 changes: 11 additions & 0 deletions arcane/src/arcane/core/ItemTypeInfoBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
class ItemTypeInfoBuilder
: public ItemTypeInfo
{
friend class ItemTypeMng;

public:

//! Dimension of the type
Expand Down Expand Up @@ -197,7 +199,16 @@
m_has_center_node = has_center_node;
}

private:

// Only for ItemTypeMng
/*!
* \brief Positions the information for a type.
*/
void _setInfos(Array<Int32>* ids_buffer, ItemTypeId type_id, String type_name, Dimension dimension,
Int32 nb_node, Int32 nb_edge, Int32 nb_face);

private:

Check warning on line 211 in arcane/src/arcane/core/ItemTypeInfoBuilder.h

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this redundant access specifier; it does not change the accessibility level.

See more on https://sonarcloud.io/project/issues?id=arcaneframework_framework&issues=AaFpVWDm2AsIuq_zolTI&open=AaFpVWDm2AsIuq_zolTI&pullRequest=2842

void _setNbEdgeAndFace(Integer nb_edge, Integer nb_face);
void _checkDimension(Int16 dim);
Expand Down
27 changes: 19 additions & 8 deletions arcane/src/arcane/core/ItemTypeMng.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1565,16 +1565,28 @@ getPolygonType(Int16 nb_node) const

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
// Create a custom type to handle the polyhedron
// The type is temporary
ItemTypeInfo* ItemTypeMng::
_findOrAddPolyhedron(Int16 nb_node, ConstArrayView<Int16> faces_nb_nodes, ConstArrayView<Int16> faces_nodes)
/*!
* \brief Fill a type to create a custom temporary type for generic Polyhedron.
*
* Fill \a type with information for a polyhedron.
* \a ids_buffer will be used to store connectivities informations.
* It must remain valid until the type is no longer used.
*
* \param nb_node number of nodes of the polyhedron.
* \pram faces_nb_node number of nodes of each face.
* \param faces_nodes list of nodes of the faces. The elements
* from `0` to `faces_nb_node[0]-1` are the node index of the first face,
* the elements from `faces_nb_nodes[0]` to `face_nb_nodes[0]+faces_nb_node[1]-1`
* are the nodes index of the second face and so on.
*/
void ItemTypeMng::
_fillTemporaryTypeForPolyhedron(ItemTypeInfoBuilder* type, Array<Int32>* ids_buffer, Int16 nb_node,
ConstArrayView<Int16> faces_nb_nodes,
ConstArrayView<Int16> faces_nodes)
{
// TODO: Remove the memory leak when adding information to this type.
ItemTypeInfoBuilder* type = m_types_buffer->allocOne();
Int32 nb_face = faces_nb_nodes.size();
// TODO: need compute number of edges.
type->setInfos(this, IT_GenericPolyhedron, "Polyhedron", ItemTypeInfoBuilder::Dimension::Dim3, nb_node, 0, nb_face);
type->_setInfos(ids_buffer, ITI_GenericPolyhedron, "Polyhedron", ItemTypeInfoBuilder::Dimension::Dim3, nb_node, 0, nb_face);
type->setIsValidForCell(true);
Int32 index_in_face_node = 0;
for (Int32 i = 0; i < nb_face; ++i) {
Expand All @@ -1585,7 +1597,6 @@ _findOrAddPolyhedron(Int16 nb_node, ConstArrayView<Int16> faces_nb_nodes, ConstA
index_in_face_node += nb_node_in_face;
}
//type->computeFaceEdgeInfos();
return type;
}

/*---------------------------------------------------------------------------*/
Expand Down
6 changes: 4 additions & 2 deletions arcane/src/arcane/core/ItemTypeMng.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class ARCANE_CORE_EXPORT ItemTypeMng

public:

/*!
/*!
* \brief Effective constructor.
*
* This method should only be called before initializing
Expand Down Expand Up @@ -224,7 +224,9 @@ class ARCANE_CORE_EXPORT ItemTypeMng
//! Reads types from a file named filename
void _readTypes(IParallelSuperMng* parallel_mng, const String& filename);
void _addPolygonType(Int16 type_id, Int32 nb_node, const String& type_name);
ItemTypeInfo* _findOrAddPolyhedron(Int16 nb_node, ConstArrayView<Int16> faces_nb_nodes, ConstArrayView<Int16> faces_nodes);
void _fillTemporaryTypeForPolyhedron(ItemTypeInfoBuilder* type, Array<Int32>* ids_buffer, Int16 nb_node,
ConstArrayView<Int16> faces_nb_nodes,
ConstArrayView<Int16> faces_nodes);
};

/*---------------------------------------------------------------------------*/
Expand Down
9 changes: 4 additions & 5 deletions arcane/src/arcane/core/internal/ItemTypeMngInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ class ARCANE_CORE_EXPORT ItemTypeMngInternal

public:

/*!
* \brief Find or add a type for a generic Polyhedron.
*/
ItemTypeInfo* findOrAddPolyhedron(Int16 nb_node, ConstArrayView<Int16> faces_nb_nodes, ConstArrayView<Int16> faces_nodes)
void fillTemporaryTypeForPolyhedron(ItemTypeInfoBuilder* type, Array<Int32>* ids_buffer, Int16 nb_node,
ConstArrayView<Int16> faces_nb_node,
ConstArrayView<Int16> faces_nodes)
{
return m_item_type_mng->_findOrAddPolyhedron(nb_node, faces_nb_nodes, faces_nodes);
m_item_type_mng->_fillTemporaryTypeForPolyhedron(type, ids_buffer, nb_node, faces_nb_node, faces_nodes);
}

private:
Expand Down
16 changes: 11 additions & 5 deletions arcane/src/arcane/mesh/OneMeshItemAdder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "arcane/core/MeshToMeshTransposer.h"
#include "arcane/core/IParallelMng.h"
#include "arcane/core/ItemPrinter.h"
#include "arcane/core/ItemTypeInfoBuilder.h"
#include "arcane/core/internal/ItemTypeMngInternal.h"

#include "arcane/mesh/DynamicMesh.h"
Expand Down Expand Up @@ -818,6 +819,9 @@
info() << "AddNewPolyhedronCell nb_connectivity=" << connectivity_infos.size()
<< " c=" << connectivity_infos;

// TODO: Use a class to handle the creation of the type and store all the working

Check warning on line 822 in arcane/src/arcane/mesh/OneMeshItemAdder.cc

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this "TODO" comment.

See more on https://sonarcloud.io/project/issues?id=arcaneframework_framework&issues=AaFpVWQx2AsIuq_zolTJ&open=AaFpVWQx2AsIuq_zolTJ&pullRequest=2842
// buffer instead of re-allocating them for each polyhedron.

// Checks if the cell already exists (in which case nothing is done).
// TODO: Search if a cell with same uniqueId() already exists.

Expand All @@ -844,10 +848,10 @@
// the next elements are nodes of face0, then node of face1, ...

SmallArray<Int64> cell_nodes_uid;
Int32 array_size = connectivity_infos[0];
Int32 array_size = static_cast<Int32>(connectivity_infos[0]);

Check warning on line 851 in arcane/src/arcane/mesh/OneMeshItemAdder.cc

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace the redundant type with "auto".

See more on https://sonarcloud.io/project/issues?id=arcaneframework_framework&issues=AaFpVWQx2AsIuq_zolTK&open=AaFpVWQx2AsIuq_zolTK&pullRequest=2842
if (array_size != connectivity_infos.size())
ARCANE_FATAL("Incoherent size array_size={0} connectivity_info={1}", array_size, connectivity_infos.size());
Int32 scheme_version = connectivity_infos[1];
Int32 scheme_version = static_cast<Int32>(connectivity_infos[1]);

Check warning on line 854 in arcane/src/arcane/mesh/OneMeshItemAdder.cc

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace the redundant type with "auto".

See more on https://sonarcloud.io/project/issues?id=arcaneframework_framework&issues=AaFpVWQx2AsIuq_zolTL&open=AaFpVWQx2AsIuq_zolTL&pullRequest=2842
if (scheme_version != 1)
ARCANE_FATAL("Insupported scheme version '{0}'. Only supported value is 1", scheme_version);
const Int32 cell_nb_face = static_cast<Int32>(connectivity_infos[2]);
Expand Down Expand Up @@ -889,9 +893,11 @@
if (is_verbose)
info() << "EndCreateTypeForPolyhedron nb_node=" << nodes_of_cell.size();
ItemTypeMngInternal* api = m_item_type_mng->_internalApi();
ItemTypeInfo* cell_type_info = api->findOrAddPolyhedron(nodes_of_cell.size(),
arcane_faces_nb_node, arcane_faces_nodes);
CellInfoProxy cell_info_proxy(ITI_GenericPolyhedron, cell_type_info, cell_uid, owner, nodes_of_cell, allow_build_face);
SmallArray<Int32> type_ids_buffer;
ItemTypeInfoBuilder cell_type_info;
api->fillTemporaryTypeForPolyhedron(&cell_type_info, &type_ids_buffer, nodes_of_cell.size(),
arcane_faces_nb_node, arcane_faces_nodes);
CellInfoProxy cell_info_proxy(ITI_GenericPolyhedron, &cell_type_info, cell_uid, owner, nodes_of_cell, allow_build_face);
return _addOneCell(cell_info_proxy);
}

Expand Down
Loading