Skip to content

Commit

Permalink
Merge pull request #1637 from arcaneframework/dev/gg-add-post-initial…
Browse files Browse the repository at this point in the history
…-partitioner-operation

Add support for additional operation after mesh creation
  • Loading branch information
grospelliergilles authored Sep 23, 2024
2 parents d280518 + e08c5ab commit 0517970
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 37 deletions.
26 changes: 19 additions & 7 deletions arcane/src/arcane/core/ICaseMeshMasterService.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// -*- 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-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: Apache-2.0
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* ICaseMeshMasterService.h (C) 2000-2020 */
/* ICaseMeshMasterService.h (C) 2000-2024 */
/* */
/* Interface du service gérant les maillages du jeu de données. */
/*---------------------------------------------------------------------------*/
#ifndef ARCANE_ICASEMESHMASTERSERVICE_H
#define ARCANE_ICASEMESHMASTERSERVICE_H
#ifndef ARCANE_CORE_ICASEMESHMASTERSERVICE_H
#define ARCANE_CORE_ICASEMESHMASTERSERVICE_H
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/

#include "arcane/ArcaneTypes.h"
#include "arcane/core/ArcaneTypes.h"

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -42,26 +42,38 @@ namespace Arcane
* Il existe une troisième phase optionnelle qui n'est effectuée que en
* parallèle et qui consiste à partitionner les maillages, via l'appel
* à partitionMeshes().
*
* Enfin, il est possible d'appliquer à la fin de la création du maillage
* un traitement supplémentaire sur le maillage. Par exemple, il est possible
* de subdiviser le maillage actuel. Cela se fait par l'appel à
* applyAdditionalOperationsOnMeshes().
*/
class ICaseMeshMasterService
{
public:

virtual ~ICaseMeshMasterService() = default;

public:

//! Créé les maillages
virtual void createMeshes() =0;
//! Créé les maillages
virtual void allocateMeshes() =0;
//! Partitionne les maillages
virtual void partitionMeshes() =0;
//! Applique les éventuelles opérations additionnelles sur le maillage crée.
virtual void applyAdditionalOperationsOnMeshes() {}

public:
virtual ICaseOptions* _options() =0;

virtual ICaseOptions* _options() = 0;
};

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

} // End namespace Arcane
} // namespace Arcane

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
Expand Down
23 changes: 14 additions & 9 deletions arcane/src/arcane/core/ICaseMeshService.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// -*- 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-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: Apache-2.0
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* ICaseMeshService.h (C) 2000-2020 */
/* ICaseMeshService.h (C) 2000-2024 */
/* */
/* Interface du service gérant un maillage du jeu de données. */
/*---------------------------------------------------------------------------*/
#ifndef ARCANE_ICASEMESHSERVICE_H
#define ARCANE_ICASEMESHSERVICE_H
#ifndef ARCANE_CORE_ICASEMESHSERVICE_H
#define ARCANE_CORE_ICASEMESHSERVICE_H
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/

#include "arcane/ArcaneTypes.h"
#include "arcane/core/ArcaneTypes.h"

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
Expand All @@ -32,10 +32,12 @@ namespace Arcane
* créé.. Dans cette phase, seule la classe gérant les maillage est créée
* mais ces derniers ne sont pas encore utilisables.
* - une deuxième phase lors de l'appel à allocateMeshItems() où le maillage
* est alloué et intialisé. Cela correspond soit à la lecture du maillage,
* est alloué et initialisé. Cela correspond soit à la lecture du maillage,
* soit à la création dynamique des entités.
* - une troisième phase qui consiste à partitionner le maillage si le code
* s'exécute en parallèle.
* - une quatrième phase qui permet d'effectuer un traitement sur le maillage
* créé comme par exemple une sub-division.
*/
class ICaseMeshService
{
Expand All @@ -46,13 +48,16 @@ class ICaseMeshService
public:

//! Créé le maillage avec le nom \a name
virtual void createMesh(const String& name) =0;
virtual void createMesh(const String& name) = 0;

//! Alloue les éléments du maillage
virtual void allocateMeshItems() =0;
virtual void allocateMeshItems() = 0;

//! Partitionne le maillage.
virtual void partitionMesh() =0;
virtual void partitionMesh() = 0;

//! Applique les opérations après tout le reste.
virtual void applyAdditionalOperations() {}
};

/*---------------------------------------------------------------------------*/
Expand Down
2 changes: 1 addition & 1 deletion arcane/src/arcane/impl/ArcaneBasicMeshSubdividerService.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ ArcaneBasicMeshSubdividerService(const ServiceBuildInfo& sbi)
void ArcaneBasicMeshSubdividerService::
subdivideMesh([[maybe_unused]] IPrimaryMesh* mesh)
{
warning() << "Function not implemented";
warning() << "SubdivideMesh: Function not implemented";
}

/*---------------------------------------------------------------------------*/
Expand Down
32 changes: 22 additions & 10 deletions arcane/src/arcane/impl/ArcaneCaseMeshMasterService.cc
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
// -*- 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-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: Apache-2.0
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* ArcaneCaseMeshMasterService.h (C) 2000-2020 */
/* ArcaneCaseMeshMasterService.h (C) 2000-2024 */
/* */
/* Service Arcane gérant les maillages du jeu de données. */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/

#include "arcane/ServiceFactory.h"
#include "arcane/ICaseMeshMasterService.h"
#include "arcane/IMeshBuilder.h"
#include "arcane/IMainFactory.h"
#include "arcane/ICaseMeshService.h"
#include "arcane/MeshBuildInfo.h"
#include "arcane/core/ServiceFactory.h"
#include "arcane/core/ICaseMeshMasterService.h"
#include "arcane/core/IMainFactory.h"
#include "arcane/core/ICaseMeshService.h"
#include "arcane/core/MeshBuildInfo.h"
#include "arcane/impl/ArcaneCaseMeshMasterService_axl.h"

/*---------------------------------------------------------------------------*/
Expand All @@ -32,9 +31,14 @@ class ArcaneCaseMeshMasterService
: public ArcaneArcaneCaseMeshMasterServiceObject
{
public:
ArcaneCaseMeshMasterService(const ServiceBuildInfo& sbi)
: ArcaneArcaneCaseMeshMasterServiceObject(sbi), m_sub_domain(sbi.subDomain()){}

explicit ArcaneCaseMeshMasterService(const ServiceBuildInfo& sbi)
: ArcaneArcaneCaseMeshMasterServiceObject(sbi)
, m_sub_domain(sbi.subDomain())
{}

private:

void createMeshes() override
{
if (m_is_created)
Expand Down Expand Up @@ -71,6 +75,14 @@ class ArcaneCaseMeshMasterService
s->partitionMesh();
}

void applyAdditionalOperationsOnMeshes() override
{
if (!m_is_allocated)
ARCANE_FATAL("Meshes are not allocated. call allocateMeshes() before");
for (ICaseMeshService* s : options()->mesh)
s->applyAdditionalOperations();
}

ICaseOptions* _options() override
{
return options()->caseOptions();
Expand Down
42 changes: 32 additions & 10 deletions arcane/src/arcane/impl/ArcaneCaseMeshService.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class ArcaneCaseMeshService
void createMesh(const String& default_name) override;
void allocateMeshItems() override;
void partitionMesh() override;
void applyAdditionalOperations() override;

private:

Expand All @@ -77,6 +78,7 @@ class ArcaneCaseMeshService
void _doInitialPartition();
void _doInitialPartition2(const String& name);
void _setGhostLayerInfos();
void _checkMeshCreationAndAllocation(bool is_check_allocated);
};

/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -156,34 +158,54 @@ createMesh(const String& default_name)
void ArcaneCaseMeshService::
allocateMeshItems()
{
if (!m_mesh)
ARCANE_FATAL("Mesh is not created. You should call createMesh() before");
_checkMeshCreationAndAllocation(false);

ARCANE_CHECK_POINTER(m_mesh_builder);

_setGhostLayerInfos();

m_mesh_builder->allocateMeshItems(m_mesh);

// TODO: Faire cela après les opérations additionnelles
_initializeVariables();
}

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

void ArcaneCaseMeshService::
partitionMesh()
{
_checkMeshCreationAndAllocation(true);

if (m_mesh->meshPartInfo().nbPart() > 1)
if (!m_partitioner_name.empty())
_doInitialPartition();
}

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

void ArcaneCaseMeshService::
applyAdditionalOperations()
{
_checkMeshCreationAndAllocation(true);

IMeshSubdivider* subdivider = options()->subdivider();
if (subdivider)
subdivider->subdivideMesh(m_mesh);

_initializeVariables();
}

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

void ArcaneCaseMeshService::
partitionMesh()
_checkMeshCreationAndAllocation(bool is_check_allocated)
{
if (!m_mesh)
ARCANE_FATAL("Mesh is not created. You should call createMesh() before");
if (!m_mesh->isAllocated())
if (is_check_allocated && !m_mesh->isAllocated())
ARCANE_FATAL("Mesh is not allocated. You should call initializeMesh() before");

if (m_mesh->meshPartInfo().nbPart()>1)
if (!m_partitioner_name.empty())
_doInitialPartition();
}

/*---------------------------------------------------------------------------*/
Expand Down
1 change: 1 addition & 0 deletions arcane/src/arcane/impl/SubDomain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,7 @@ doInitMeshPartition()
else{
if (m_case_mesh_master_service.get()){
m_case_mesh_master_service->partitionMeshes();
m_case_mesh_master_service->applyAdditionalOperationsOnMeshes();
}
else
if (m_legacy_mesh_builder->m_use_internal_mesh_partitioner)
Expand Down

0 comments on commit 0517970

Please sign in to comment.