Skip to content

Commit

Permalink
Merge pull request #792 from arcaneframework/dev/gg-cleanup-materials3
Browse files Browse the repository at this point in the history
Cleanup materials
  • Loading branch information
grospelliergilles authored Jul 9, 2023
2 parents fae37fd + ef48eb8 commit 05af9ad
Show file tree
Hide file tree
Showing 18 changed files with 170 additions and 154 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class MatCommandContainerBase
void _init()
{
m_nb_item = m_items.nbItem();
m_matvar_indexes = m_items.matvarIndexes();
m_matvar_indexes = m_items._matvarIndexes();
m_global_cells_local_id = m_items._internalLocalIds();
}
};
Expand Down
2 changes: 1 addition & 1 deletion arcane/src/arcane/core/materials/ComponentItemVector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Impl(IMeshComponent* component,ConstArrayView<ComponentItemInternal*> items_inte
{
m_matvar_indexes.copy(matvar_indexes);
m_items_local_id.copy(items_local_id);
m_part_data->setFromMatVarIndexes(matvar_indexes);
m_part_data->_setFromMatVarIndexes(matvar_indexes);
}

/*---------------------------------------------------------------------------*/
Expand Down
11 changes: 11 additions & 0 deletions arcane/src/arcane/core/materials/ComponentItemVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ namespace Arcane::Materials
*/
class ARCANE_CORE_EXPORT ComponentItemVector
{
friend class EnvCellVector;
friend class MatCellVector;

/*!
* \brief Implémentation de ComponentItemVector.
*/
Expand Down Expand Up @@ -127,13 +130,21 @@ class ARCANE_CORE_EXPORT ComponentItemVector

//! Interne à Arcane
//@{
ARCANE_DEPRECATED_REASON("Y2023: This method is internal to Arcane")
ConstArrayView<MatVarIndex> matvarIndexes() const { return m_p->m_matvar_indexes; }

ARCANE_DEPRECATED_REASON("Y2023: This method is internal to Arcane")
ConstArrayView<ComponentItemInternal*> itemsInternalView() const
{
return m_p->m_items_internal.constView();
}
//@}

private:

ConstArrayView<MatVarIndex> _matvarIndexes() const { return m_p->m_matvar_indexes; }
ConstArrayView<ComponentItemInternal*> _itemsInternalView() const { return m_p->m_items_internal.constView(); }

protected:

void _setItemsInternal(ConstArrayView<ComponentItemInternal*> globals,
Expand Down
20 changes: 18 additions & 2 deletions arcane/src/arcane/core/materials/ComponentItemVectorView.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
namespace ArcaneTest
{
class MeshMaterialTesterModule;
class MaterialHeatTestModule;
}
namespace Arcane::Accelerator::impl
{
class MatCommandContainerBase;
}

namespace Arcane::Materials
Expand All @@ -45,7 +50,9 @@ class ARCANE_CORE_EXPORT ComponentItemVectorView
friend class ComponentItemVector;
friend class MatItemVectorView;
friend class EnvItemVectorView;
friend Arcane::Accelerator::impl::MatCommandContainerBase;
friend ArcaneTest::MeshMaterialTesterModule;
friend ArcaneTest::MaterialHeatTestModule;
template<typename ViewType,typename LambdaType>
friend class LambdaMatItemRangeFunctorT;

Expand Down Expand Up @@ -87,18 +94,27 @@ class ARCANE_CORE_EXPORT ComponentItemVectorView

//! Interne à Arcane
//@{
ARCANE_DEPRECATED_REASON("Y2023: This method is internal to Arcane")
ConstArrayView<ComponentItemInternal*> itemsInternalView() const
{ return m_items_internal_main_view; }

// Tableau des MatVarIndex de cette vue.
ARCANE_DEPRECATED_REASON("Y2023: This method is internal to Arcane")
ConstArrayView<MatVarIndex> matvarIndexes() const { return m_matvar_indexes_view; }

//! Tableau des localId() des entités associées
ConstArrayView<Int32> _internalLocalIds() const { return m_items_local_id_view; }
//@}

private:

ConstArrayView<ComponentItemInternal*> _itemsInternalView() const
{ return m_items_internal_main_view; }

// Tableau des MatVarIndex de cette vue.
ConstArrayView<MatVarIndex> _matvarIndexes() const { return m_matvar_indexes_view; }

//! Tableau des localId() des entités associées
ConstArrayView<Int32> _internalLocalIds() const { return m_items_local_id_view; }

/*!
* \internal
* \brief Créé une sous-vue de cette vue.
Expand Down
6 changes: 3 additions & 3 deletions arcane/src/arcane/core/materials/EnvItemVector.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
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* EnvItemVector.h (C) 2000-2022 */
/* EnvItemVector.h (C) 2000-2023 */
/* */
/* Vecteur sur les entités d'un milieu. */
/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -53,7 +53,7 @@ class ARCANE_CORE_EXPORT EnvCellVector
//! Vue sur ce vecteur
EnvCellVectorView view() const
{
return {_component(),matvarIndexes(),itemsInternalView(),_localIds() };
return {_component(),_matvarIndexes(),_itemsInternalView(),_localIds() };
}

//! Milieu associé
Expand Down
35 changes: 19 additions & 16 deletions arcane/src/arcane/core/materials/IMeshComponent.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
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* IMeshComponent.h (C) 2000-2022 */
/* IMeshComponent.h (C) 2000-2023 */
/* */
/* Interface d'un composant (matériau ou milieu) d'un maillage. */
/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -33,7 +33,7 @@ class ARCANE_CORE_EXPORT IMeshComponent
{
public:

virtual ~IMeshComponent(){}
virtual ~IMeshComponent() = default;

public:

Expand All @@ -44,7 +44,7 @@ class ARCANE_CORE_EXPORT IMeshComponent
virtual ITraceMng* traceMng() =0;

//! Nom du composant
virtual const String& name() const =0;
virtual String name() const =0;

/*!
* \brief Groupe des mailles de ce matériau.
Expand All @@ -55,18 +55,6 @@ class ARCANE_CORE_EXPORT IMeshComponent
*/
virtual CellGroup cells() const =0;

/*!
* \internal
* Indexeur pour accéder aux variables partielles.
*/
virtual MeshMaterialVariableIndexer* variableIndexer() const =0;

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

/*!
* \brief Identifiant du composant.
*
Expand Down Expand Up @@ -126,6 +114,21 @@ class ARCANE_CORE_EXPORT IMeshComponent
* Si isEnvironment()==false, retourne \a nullptr
*/
virtual IMeshEnvironment* asEnvironment() =0;

public:

/*!
* \internal
* Indexeur pour accéder aux variables partielles.
*/
virtual MeshMaterialVariableIndexer* variableIndexer() const =0;

/*!
* \internal
* Vue sur les mailles du composant.
*/
ARCANE_DEPRECATED_REASON("Y2023: This method is internal to Arcane")
virtual ConstArrayView<ComponentItemInternal*> itemsInternalView() const =0;
};

/*---------------------------------------------------------------------------*/
Expand Down
6 changes: 3 additions & 3 deletions arcane/src/arcane/core/materials/MatItemVector.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
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* MatItemVector.h (C) 2000-2022 */
/* MatItemVector.h (C) 2000-2023 */
/* */
/* Vecteur sur les entités d'un matériau. */
/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -57,7 +57,7 @@ class ARCANE_CORE_EXPORT MatCellVector
//! Vue sur ce vecteur
MatCellVectorView view() const
{
return {_component(),matvarIndexes(),itemsInternalView(),_localIds()};
return {_component(),_matvarIndexes(),_itemsInternalView(),_localIds()};
}

//! Matériau associé
Expand Down
6 changes: 3 additions & 3 deletions arcane/src/arcane/core/materials/MeshComponentPartData.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
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* MeshComponentPartData.cc (C) 2000-2022 */
/* MeshComponentPartData.cc (C) 2000-2023 */
/* */
/* Données d'une partie (pure ou partielle) d'un constituant. */
/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -74,7 +74,7 @@ _notifyValueIndexesChanged()
/*---------------------------------------------------------------------------*/

void MeshComponentPartData::
setFromMatVarIndexes(ConstArrayView<MatVarIndex> matvar_indexes)
_setFromMatVarIndexes(ConstArrayView<MatVarIndex> matvar_indexes)
{
Int32Array& pure_indexes = m_value_indexes[(Int32)eMatPart::Pure];
Int32Array& impure_indexes = m_value_indexes[(Int32)eMatPart::Impure];
Expand Down
31 changes: 16 additions & 15 deletions arcane/src/arcane/core/materials/MeshComponentPartData.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
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* MeshComponentPartData.h (C) 2000-2022 */
/* MeshComponentPartData.h (C) 2000-2023 */
/* */
/* Données séparées en parties pure et impures d'un constituant . */
/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -36,29 +36,21 @@ namespace Arcane::Materials
class ARCANE_CORE_EXPORT MeshComponentPartData
: public TraceAccessor
{
friend class MeshComponentData;
friend class ComponentItemVector;

public:

MeshComponentPartData(IMeshComponent* component);
explicit MeshComponentPartData(IMeshComponent* component);
MeshComponentPartData(const MeshComponentPartData& rhs) = default;
virtual ~MeshComponentPartData();

public:
~MeshComponentPartData() override;

public:

void setComponentItemInternalView(ConstArrayView<ComponentItemInternal*> v)
{
m_items_internal = v;
}

void setFromMatVarIndexes(ConstArrayView<MatVarIndex> matvar_indexes);

Int32 impureVarIdx() const { return m_impure_var_idx; }

IMeshComponent* component() const { return m_component; }

ConstArrayView<ComponentItemInternal*> itemsInternal() const { return m_items_internal; }

void checkValid() const;

//! Vue sur la partie pure
Expand All @@ -82,6 +74,15 @@ class ARCANE_CORE_EXPORT MeshComponentPartData
return m_items_internal_indexes[(Int32)k];
}

private:

void _setComponentItemInternalView(ConstArrayView<ComponentItemInternal*> v)
{
m_items_internal = v;
}

void _setFromMatVarIndexes(ConstArrayView<MatVarIndex> matvar_indexes);

//! Il faut appeler notifyValueIndexesChanged() après modification du tableau.
Int32Array& _mutableValueIndexes(eMatPart k)
{
Expand Down
24 changes: 12 additions & 12 deletions arcane/src/arcane/materials/AllEnvData.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ forceRecompute(bool compute_all)
// de la maille milieu correspondante (globale ou partielle suivant le cas)

// Redimensionne les tableaux des infos
// ATTENTION: il ne doivent plus être redimensionnés par la suite sous peine
// ATTENTION : ils ne doivent plus être redimensionnés par la suite sous peine
// de tout invalider.
m_item_internal_data.resizeNbAllEnvCell(max_local_id);
m_item_internal_data.resizeNbEnvCell(total_env_cell);
Expand Down Expand Up @@ -313,9 +313,9 @@ forceRecompute(bool compute_all)
}

for( MeshEnvironment* env : true_environments ){
env->componentData()->rebuildPartData();
env->componentData()->_rebuildPartData();
for( MeshMaterial* mat : env->trueMaterials() )
mat->componentData()->rebuildPartData();
mat->componentData()->_rebuildPartData();
}

m_material_mng->checkValid();
Expand Down Expand Up @@ -348,9 +348,9 @@ forceRecompute(bool compute_all)

// Met à jour le AllCellToAllEnvCell s'il a été initialisé si la fonctionnalité est activé
if (m_material_mng->isCellToAllEnvCellForRunCommand()) {
auto* allCell2AllEnvCell(m_material_mng->getAllCellToAllEnvCell());
if (allCell2AllEnvCell)
allCell2AllEnvCell->bruteForceUpdate(m_material_mng->mesh()->allCells().internal()->itemsLocalId());
auto* all_cell_to_all_env_cell(m_material_mng->getAllCellToAllEnvCell());
if (all_cell_to_all_env_cell)
all_cell_to_all_env_cell->bruteForceUpdate(m_material_mng->mesh()->allCells().internal()->itemsLocalId());
else
m_material_mng->createAllCellToAllEnvCell(platform::getDefaultDataAllocator());
}
Expand Down Expand Up @@ -528,7 +528,7 @@ _copyBetweenPartialsAndGlobals(Int32ConstArrayView pure_local_ids,
* Retourne le nombre d'erreurs.
*/
Integer AllEnvData::
_checkMaterialPrescence(IMeshMaterial* mat,Int32ConstArrayView ids,eOperation operation)
_checkMaterialPresence(IMeshMaterial* mat,Int32ConstArrayView ids,eOperation operation)
{
// TODO: faut-il vérifier la validité des \a ids
//(ils sont compris entre 0 et max_loca_id-1) ?
Expand Down Expand Up @@ -599,7 +599,7 @@ void AllEnvData::
_filterValidIds(IMeshMaterial* mat,Int32ConstArrayView ids,bool do_add,Int32Array& valid_ids)
{
// TODO: faut-il vérifier la validité des \a ids
//(ils sont compris entre 0 et max_loca_id-1) ?
//(ils sont compris entre 0 et max_local_id-1) ?

MeshMaterialVariableIndexer* indexer = mat->variableIndexer();
IItemFamily* item_family = mat->cells().itemFamily();
Expand Down Expand Up @@ -666,11 +666,11 @@ updateMaterialDirect(IMeshMaterial* mat,Int32ConstArrayView ids,
eOperation operation)
{
UniqueArray<Int32> filtered_ids;
bool filter_invalid = true;
const bool filter_invalid = true;
// Vérifie dans le cas des mailles à ajouter si elles ne sont pas déjà
// dans le matériau et dans le cas des mailles à supprimer si elles y sont.
if (arcaneIsCheck()){
Integer nb_error = _checkMaterialPrescence(mat,ids,operation);
Integer nb_error = _checkMaterialPresence(mat, ids, operation);
if (nb_error!=0){
if (filter_invalid){
_filterValidIds(mat,ids,true,filtered_ids);
Expand All @@ -695,7 +695,7 @@ _updateMaterialDirect(IMeshMaterial* mat,Int32ConstArrayView ids,eOperation oper
_throwBadOperation(operation);
bool is_add = (operation==eOperation::Add);

MeshMaterial* true_mat = dynamic_cast<MeshMaterial*>(mat);
auto* true_mat = dynamic_cast<MeshMaterial*>(mat);
if (!true_mat)
throw NotImplementedException(A_FUNCINFO,"material is not an instance of MeshMaterial");

Expand All @@ -711,7 +711,7 @@ _updateMaterialDirect(IMeshMaterial* mat,Int32ConstArrayView ids,eOperation oper

// S'il est possible d'avoir plusieurs matériaux par milieu, il faut gérer
// pour chaque maille si le milieu évolue suite à l'ajout/suppression de matériau.
// les deux cas sont:
// Les deux cas sont :
// - en cas d'ajout, le milieu évolue pour une maille s'il n'y avait pas
// de matériau avant. Dans ce cas le milieu est ajouté à la maille.
// - en cas de suppression, le milieu évolue dans la maille s'il y avait
Expand Down
Loading

0 comments on commit 05af9ad

Please sign in to comment.