diff --git a/arcane/src/arcane/core/ICaseMeshMasterService.h b/arcane/src/arcane/core/ICaseMeshMasterService.h index ab128ef81b..3bbbb6b695 100644 --- a/arcane/src/arcane/core/ICaseMeshMasterService.h +++ b/arcane/src/arcane/core/ICaseMeshMasterService.h @@ -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" /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ @@ -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 /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ diff --git a/arcane/src/arcane/core/ICaseMeshService.h b/arcane/src/arcane/core/ICaseMeshService.h index 0ea8b6bfe0..5ec66ff19a 100644 --- a/arcane/src/arcane/core/ICaseMeshService.h +++ b/arcane/src/arcane/core/ICaseMeshService.h @@ -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" /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ @@ -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 { @@ -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() {} }; /*---------------------------------------------------------------------------*/ diff --git a/arcane/src/arcane/impl/ArcaneBasicMeshSubdividerService.cc b/arcane/src/arcane/impl/ArcaneBasicMeshSubdividerService.cc index 45f7061a8a..46c82e9f0b 100644 --- a/arcane/src/arcane/impl/ArcaneBasicMeshSubdividerService.cc +++ b/arcane/src/arcane/impl/ArcaneBasicMeshSubdividerService.cc @@ -53,7 +53,7 @@ ArcaneBasicMeshSubdividerService(const ServiceBuildInfo& sbi) void ArcaneBasicMeshSubdividerService:: subdivideMesh([[maybe_unused]] IPrimaryMesh* mesh) { - warning() << "Function not implemented"; + warning() << "SubdivideMesh: Function not implemented"; } /*---------------------------------------------------------------------------*/ diff --git a/arcane/src/arcane/impl/ArcaneCaseMeshMasterService.cc b/arcane/src/arcane/impl/ArcaneCaseMeshMasterService.cc index 64cb9f7972..13765421d3 100644 --- a/arcane/src/arcane/impl/ArcaneCaseMeshMasterService.cc +++ b/arcane/src/arcane/impl/ArcaneCaseMeshMasterService.cc @@ -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" /*---------------------------------------------------------------------------*/ @@ -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) @@ -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(); diff --git a/arcane/src/arcane/impl/ArcaneCaseMeshService.cc b/arcane/src/arcane/impl/ArcaneCaseMeshService.cc index cf80d93674..bae4bb9424 100644 --- a/arcane/src/arcane/impl/ArcaneCaseMeshService.cc +++ b/arcane/src/arcane/impl/ArcaneCaseMeshService.cc @@ -59,6 +59,7 @@ class ArcaneCaseMeshService void createMesh(const String& default_name) override; void allocateMeshItems() override; void partitionMesh() override; + void applyAdditionalOperations() override; private: @@ -77,6 +78,7 @@ class ArcaneCaseMeshService void _doInitialPartition(); void _doInitialPartition2(const String& name); void _setGhostLayerInfos(); + void _checkMeshCreationAndAllocation(bool is_check_allocated); }; /*---------------------------------------------------------------------------*/ @@ -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(); } /*---------------------------------------------------------------------------*/ diff --git a/arcane/src/arcane/impl/SubDomain.cc b/arcane/src/arcane/impl/SubDomain.cc index 028703227e..44a7de7ec7 100644 --- a/arcane/src/arcane/impl/SubDomain.cc +++ b/arcane/src/arcane/impl/SubDomain.cc @@ -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)