Skip to content

Commit

Permalink
Merge pull request #794 from arcaneframework/dev/gg-cleanup-materials4
Browse files Browse the repository at this point in the history
Create internal API for 'IMeshComponent' and remove some internal deprecated methods
  • Loading branch information
grospelliergilles authored Jul 10, 2023
2 parents 43feaf1 + 679f75b commit 5fcf979
Show file tree
Hide file tree
Showing 18 changed files with 147 additions and 47 deletions.
6 changes: 3 additions & 3 deletions arcane/src/arcane/core/materials/ComponentItem.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
//-----------------------------------------------------------------------------
// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// Copyright 2000-2023 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: Apache-2.0
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* ComponentItem.h (C) 2000-2022 */
/* ComponentItem.h (C) 2000-2023 */
/* */
/* Entité composant d'une maillage multi-matériau. */
/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -89,7 +89,7 @@ class ARCANE_CORE_EXPORT ComponentCell
//! Maille arcane
Cell globalCell() const
{
return Cell(m_internal->globalItem());
return Cell(m_internal->globalItemBase());
}

/*!
Expand Down
6 changes: 1 addition & 5 deletions arcane/src/arcane/core/materials/ComponentItemInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class ARCANE_CORE_EXPORT ComponentItemInternal
{
private:

//static const Int64 UID_MASK = 0x00ffffff;
static const int MAT_INDEX_OFFSET = 10;

//! Entité nulle
Expand Down Expand Up @@ -120,11 +119,8 @@ class ARCANE_CORE_EXPORT ComponentItemInternal
//! Première entité sous-composant.
ComponentItemInternal* firstSubItem() const { return m_first_sub_component_item; }

//! ItemInternal de l'entité Item correspondante.
ItemInternal* globalItem() { return m_global_item; }

//! Entité globale correspondante.
Item globalItem2() { return m_global_item; }
impl::ItemBase globalItemBase() { return m_global_item; }

//! Positionne le nombre de sous-composants.
void setNbSubItem(Int32 nb_sub_item)
Expand Down
4 changes: 2 additions & 2 deletions arcane/src/arcane/core/materials/ComponentItemVector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ ComponentItemVector(IMeshComponent* component)

ComponentItemVector::
ComponentItemVector(ComponentItemVectorView rhs)
: m_p(new Impl(rhs.component(),rhs.itemsInternalView(),
rhs.matvarIndexes(),rhs._internalLocalIds()))
: m_p(new Impl(rhs.component(),rhs._itemsInternalView(),
rhs._matvarIndexes(),rhs._internalLocalIds()))
{
}

Expand Down
6 changes: 3 additions & 3 deletions arcane/src/arcane/core/materials/ComponentItemVectorView.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
//-----------------------------------------------------------------------------
// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// Copyright 2000-2023 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: Apache-2.0
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* ComponentItemVectorView.cc (C) 2000-2022 */
/* ComponentItemVectorView.cc (C) 2000-2023 */
/* */
/* Vue sur un vecteur sur des entités composants. */
/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -65,7 +65,7 @@ _subView(Integer begin,Integer size)
}

ConstArrayView<ComponentItemInternal*> mn = m_items_internal_main_view.subView(begin,size);
ConstArrayView<MatVarIndex> mvs = matvarIndexes().subView(begin,size);
ConstArrayView<MatVarIndex> mvs = _matvarIndexes().subView(begin,size);
ConstArrayView<Int32> ids = _internalLocalIds().subView(begin,size);

return ComponentItemVectorView(m_component,mvs,mn,ids);
Expand Down
5 changes: 5 additions & 0 deletions arcane/src/arcane/core/materials/ComponentItemVectorView.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,16 @@ class ARCANE_CORE_EXPORT ComponentItemVectorView
friend class ComponentItemVector;
friend class MatItemVectorView;
friend class EnvItemVectorView;
friend class MatCellEnumerator;
friend class EnvCellEnumerator;
friend class ComponentCellEnumerator;
friend Arcane::Accelerator::impl::MatCommandContainerBase;
friend ArcaneTest::MeshMaterialTesterModule;
friend ArcaneTest::MaterialHeatTestModule;
template<typename ViewType,typename LambdaType>
friend class LambdaMatItemRangeFunctorT;
template<typename DataType> friend class
MaterialVariableArrayTraits;

protected:

Expand Down
6 changes: 6 additions & 0 deletions arcane/src/arcane/core/materials/IMeshComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

namespace Arcane::Materials
{
class IMeshComponentInternal;

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -129,6 +130,11 @@ class ARCANE_CORE_EXPORT IMeshComponent
*/
ARCANE_DEPRECATED_REASON("Y2023: This method is internal to Arcane")
virtual ConstArrayView<ComponentItemInternal*> itemsInternalView() const =0;

public:

//! API interne
virtual IMeshComponentInternal* _internalApi() =0;
};

/*---------------------------------------------------------------------------*/
Expand Down
10 changes: 5 additions & 5 deletions arcane/src/arcane/core/materials/MatItem.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
//-----------------------------------------------------------------------------
// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// Copyright 2000-2023 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: Apache-2.0
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* MatItem.h (C) 2000-2022 */
/* MatItem.h (C) 2000-2023 */
/* */
/* Entités matériau et milieux. */
/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -66,7 +66,7 @@ class MatCell
//! Maille arcane
Cell globalCell() const
{
return Cell(m_internal->globalItem());
return Cell(m_internal->globalItemBase());
}

//! Materiau associé
Expand Down Expand Up @@ -121,7 +121,7 @@ class EnvCell
Int32 nbMaterial() const { return m_internal->nbSubItem(); }

//! Maille arcane
Cell globalCell() const { return Cell(m_internal->globalItem()); }
Cell globalCell() const { return Cell(m_internal->globalItemBase()); }

//! Maille contenant les infos sur tous les milieux
AllEnvCell allEnvCell() const;
Expand Down Expand Up @@ -176,7 +176,7 @@ class AllEnvCell
Int32 nbEnvironment() { return m_internal->nbSubItem(); }

//! Maille arcane standard
Cell globalCell() const { return Cell(m_internal->globalItem()); }
Cell globalCell() const { return Cell(m_internal->globalItemBase()); }

//! i-ème maille milieu
EnvCell cell(Integer i) const
Expand Down
17 changes: 9 additions & 8 deletions arcane/src/arcane/core/materials/MatItemEnumerator.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
//-----------------------------------------------------------------------------
// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// Copyright 2000-2023 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: Apache-2.0
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* MatItemEnumerator.cc (C) 2000-2022 */
/* MatItemEnumerator.cc (C) 2000-2023 */
/* */
/* Enumérateurs sur les mailles materiaux. */
/*---------------------------------------------------------------------------*/
Expand All @@ -18,6 +18,7 @@
#include "arcane/core/materials/IMeshBlock.h"
#include "arcane/core/materials/MatItemVector.h"
#include "arcane/core/materials/EnvItemVector.h"
#include "arcane/core/materials/internal/IMeshComponentInternal.h"

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
Expand All @@ -34,7 +35,7 @@ namespace Arcane::Materials
MatCellEnumerator MatCellEnumerator::
create(IMeshMaterial* mat)
{
return MatCellEnumerator(mat->itemsInternalView(),
return MatCellEnumerator(mat->_internalApi()->itemsInternalView(),
mat->variableIndexer()->matvarIndexes(),mat);
}

Expand All @@ -53,7 +54,7 @@ create(const MatCellVector& miv)
MatCellEnumerator MatCellEnumerator::
create(MatCellVectorView v)
{
return MatCellEnumerator(v.itemsInternalView(),v.matvarIndexes(),v.component());
return MatCellEnumerator(v._itemsInternalView(),v._matvarIndexes(),v.component());
}

/*---------------------------------------------------------------------------*/
Expand All @@ -65,7 +66,7 @@ create(MatCellVectorView v)
EnvCellEnumerator EnvCellEnumerator::
create(IMeshEnvironment* env)
{
return EnvCellEnumerator(env->itemsInternalView(),
return EnvCellEnumerator(env->_internalApi()->itemsInternalView(),
env->variableIndexer()->matvarIndexes(),env);
}

Expand All @@ -84,7 +85,7 @@ create(const EnvCellVector& miv)
EnvCellEnumerator EnvCellEnumerator::
create(EnvCellVectorView v)
{
return EnvCellEnumerator(v.itemsInternalView(),v.matvarIndexes(),v.component());
return EnvCellEnumerator(v._itemsInternalView(),v._matvarIndexes(),v.component());
}

/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -173,7 +174,7 @@ create(IMeshComponent* component)
{
MeshMaterialVariableIndexer* vi = component->variableIndexer();

return ComponentCellEnumerator(component->itemsInternalView(),
return ComponentCellEnumerator(component->_internalApi()->itemsInternalView(),
vi->matvarIndexes(),component);
}

Expand All @@ -192,7 +193,7 @@ create(const ComponentItemVector& v)
ComponentCellEnumerator ComponentCellEnumerator::
create(ComponentItemVectorView v)
{
return ComponentCellEnumerator(v.itemsInternalView(),v.matvarIndexes(),
return ComponentCellEnumerator(v._itemsInternalView(),v._matvarIndexes(),
v.component());
}

Expand Down
10 changes: 2 additions & 8 deletions arcane/src/arcane/core/materials/MatItemEnumerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,16 +351,13 @@ class ARCANE_CORE_EXPORT CellComponentCellEnumerator

public:

// TODO: rendre obsolète
explicit CellComponentCellEnumerator(ComponentItemInternal* super_item)
: m_index(0), m_size(super_item->nbSubItem()), m_items_begin(super_item->firstSubItem())
{
}
explicit CellComponentCellEnumerator(ComponentCell super_item)
: m_index(0), m_size(super_item.internal()->nbSubItem()), m_items_begin(super_item.internal()->firstSubItem())
{
}

public:

void operator++() { ++m_index; }
bool hasNext() const { return m_index<m_size; }

Expand Down Expand Up @@ -391,9 +388,6 @@ template <typename ComponentCellType> class CellComponentCellEnumeratorT
{
public:

explicit CellComponentCellEnumeratorT(ComponentItemInternal* super_item)
: CellComponentCellEnumerator(super_item){}

explicit CellComponentCellEnumeratorT(ComponentCell super_item)
: CellComponentCellEnumerator(super_item){}

Expand Down
7 changes: 5 additions & 2 deletions arcane/src/arcane/core/materials/MaterialsCoreGlobal.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
//-----------------------------------------------------------------------------
// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// Copyright 2000-2023 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: Apache-2.0
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* MaterialsCoreGlobal.cc (C) 2000-2022 */
/* MaterialsCoreGlobal.cc (C) 2000-2023 */
/* */
/* Déclarations générales des matériaux de Arcane. */
/*---------------------------------------------------------------------------*/
Expand All @@ -22,6 +22,9 @@
#include "arcane/core/materials/IMeshMaterialVariableFactoryMng.h"
#include "arcane/core/materials/IMeshMaterialVariableFactory.h"

// Pas utilisé directement mais nécessaire pour la définition des symboles.
#include "arcane/core/materials/internal/IMeshComponentInternal.h"

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

Expand Down
51 changes: 51 additions & 0 deletions arcane/src/arcane/core/materials/internal/IMeshComponentInternal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
//-----------------------------------------------------------------------------
// Copyright 2000-2023 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: Apache-2.0
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* IMeshComponentInternal.h (C) 2000-2023 */
/* */
/* API interne Arcane de 'IMeshComponent'. */
/*---------------------------------------------------------------------------*/
#ifndef ARCANE_CORE_MATERIALS_INTERNAL_IMESHCOMPONENTINTERNAL_H
#define ARCANE_CORE_MATERIALS_INTERNAL_IMESHCOMPONENTINTERNAL_H
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/

#include "arcane/core/ItemTypes.h"
#include "arcane/core/materials/MaterialsCoreGlobal.h"

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

namespace Arcane::Materials
{

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/*!
* \brief API interne Arcane de 'IMeshComponent'.
*/
class ARCANE_CORE_EXPORT IMeshComponentInternal
{
public:

virtual ~IMeshComponentInternal() = default;

public:

//! Vue sur les mailles du composant.
virtual ConstArrayView<ComponentItemInternal*> itemsInternalView() const = 0;
};

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

} // namespace Arcane::Materials

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

#endif
1 change: 1 addition & 0 deletions arcane/src/arcane/core/srcs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ set(ARCANE_MATERIALS_SOURCES
materials/MeshMaterialVariableComputeFunction.h
materials/IMeshMaterialVariableComputeFunction.h
materials/internal/IMeshMaterialVariableInternal.h
materials/internal/IMeshComponentInternal.h
)

set(ARCANE_INTERNAL_SOURCES
Expand Down
1 change: 1 addition & 0 deletions arcane/src/arcane/materials/MeshEnvironment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ MeshEnvironment(IMeshMaterialMng* mm, const String& name, Int32 env_id)
, m_nb_mat_per_cell(VariableBuildInfo(mm->mesh(), mm->name() + "_CellNbMaterial_" + name))
, m_data(this, name, env_id, false)
, m_non_const_this(this)
, m_internal_api(this)
{
}

Expand Down
1 change: 1 addition & 0 deletions arcane/src/arcane/materials/MeshMaterial.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ MeshMaterial(MeshMaterialInfo* infos, MeshEnvironment* env,
, m_user_material(nullptr)
, m_data(this, name, mat_id, true)
, m_non_const_this(this)
, m_internal_api(this)
{
if (!env)
throw ArgumentException(A_FUNCINFO,
Expand Down
4 changes: 2 additions & 2 deletions arcane/src/arcane/materials/MeshMaterialMng.cc
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ checkValid()
ComponentItemInternal* eii = ec.internal();
if (all_env_cell.internal()!=eii->superItem())
ARCANE_FATAL("Bad corresponding allEnvItem() in env_item uid={0}",cell_uid);
if (eii->globalItem2()!=cell)
if (eii->globalItemBase()!=cell)
ARCANE_FATAL("Bad corresponding globalItem() in env_item");
if (eii->level()!=LEVEL_ENVIRONMENT)
ARCANE_FATAL("Bad level '{0}' for in env_item",eii->level());
Expand All @@ -679,7 +679,7 @@ checkValid()
ComponentItemInternal* mci = mc.internal();
if (eii!=mci->superItem())
ARCANE_FATAL("Bad corresponding env_item in mat_item");
if (mci->globalItem2()!=cell)
if (mci->globalItemBase()!=cell)
ARCANE_FATAL("Bad corresponding globalItem() in mat_item");
if (mci->level()!=LEVEL_MATERIAL)
ARCANE_FATAL("Bad level '{0}' for in mat_item",mci->level());
Expand Down
2 changes: 1 addition & 1 deletion arcane/src/arcane/materials/MeshMaterialVariableArray.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ saveData(IMeshComponent* component,IData* data,
Integer current_dim1_size = values.dim1Size();
Integer added_dim1_size = component_view.nbItem();
values.resizeNoInit(current_dim1_size+added_dim1_size,dim2_size);
ConstArrayView<MatVarIndex> mvi_indexes = component_view.matvarIndexes();
ConstArrayView<MatVarIndex> mvi_indexes = component_view._matvarIndexes();

for( Integer i=0, n=mvi_indexes.size(); i<n; ++i ){
MatVarIndex mvi = mvi_indexes[i];
Expand Down
Loading

0 comments on commit 5fcf979

Please sign in to comment.