Arcane  4.2.3.0
Developer documentation
Loading...
Searching...
No Matches
ArcaneParallelMngSplitterMeshBuilderCustomiser.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* MeshPartitionerTesterService.cc (C) 2000-2022 */
9/* */
10/* Mesh partitioner tester. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/NotImplementedException.h"
15#include "arcane/utils/CheckedConvert.h"
16
17#include "arcane/core/IParallelMng.h"
18#include "arcane/core/IMeshBuilderCustomiser.h"
19#include "arcane/core/MeshBuildInfo.h"
20
21#include "arcane/impl/ArcaneParallelMngSplitterMeshBuilderCustomiser_axl.h"
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26namespace Arcane
27{
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32class ArcaneParallelMngSplitterMeshBuilderCustomiser
34{
35 public:
36
37 explicit ArcaneParallelMngSplitterMeshBuilderCustomiser(const ServiceBuildInfo& sbi)
39 , m_default_parallel_mng(sbi.subDomain()->parallelMng())
40 {
41 }
42
43 void applyCustomisation(MeshBuildInfo& build_info) override
44 {
45 Int32 divider = options()->subsetRatio();
46 if (divider < 0)
47 ARCANE_FATAL("subset-ratio '{0}' is strictly positive",divider);
48 IParallelMng* pm = m_default_parallel_mng;
49 Int32 my_rank = pm->commRank();
50 Int32 nb_rank = pm->commSize();
51 UniqueArray<int> kept_ranks;
52 kept_ranks.reserve(nb_rank);
53 for (Int32 i = 0; i < nb_rank; ++i) {
54 if ((i % divider) == 0)
55 kept_ranks.add(i);
56 }
57 info() << "Splitting IParallelMng my_rank=" << my_rank;
58 info() << "RanksToKeep=" << kept_ranks;
59 Ref<IParallelMng> new_pm = pm->createSubParallelMngRef(kept_ranks);
60 if (new_pm.get())
61 info() << "Rank=" << my_rank << " RankAfter=" << new_pm.get()->commRank();
62 else
63 info() << "Rank=" << my_rank << ": I am not in the new IParallelMng";
64 build_info.addParallelMng(new_pm);
65 }
66
67 private:
68
69 IParallelMng* m_default_parallel_mng = nullptr;
70};
71
72ARCANE_REGISTER_SERVICE_ARCANEPARALLELMNGSPLITTERMESHBUILDERCUSTOMISER(ArcaneParallelMngSplitterMeshBuilderCustomiser,
73 ArcaneParallelMngSplitterMeshBuilderCustomiser);
74
75/*---------------------------------------------------------------------------*/
76/*---------------------------------------------------------------------------*/
77
78} // namespace Arcane
79
80/*---------------------------------------------------------------------------*/
81/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
CaseOptionsArcaneParallelMngSplitterMeshBuilderCustomiser * options() const
Options du jeu de données du service.
void applyCustomisation(MeshBuildInfo &build_info) override
Modify build_info to customise mesh creation.
void add(ConstReferenceType val)
Adds element val to the end of the array.
void reserve(Int64 new_capacity)
Reserves memory for new_capacity elements.
Interface of the parallelism manager for a subdomain.
virtual Int32 commRank() const =0
Rank of this instance in the communicator.
virtual Int32 commSize() const =0
Number of instances in the communicator.
virtual Ref< IParallelMng > createSubParallelMngRef(Int32ConstArrayView kept_ranks)=0
Creates a new parallelism manager for a subset of ranks.
virtual IParallelMng * parallelMng()=0
Returns the parallelism manager.
Parameters necessary for building a mesh.
MeshBuildInfo & addParallelMng(Ref< IParallelMng > pm)
Sets the parallelism manager to create the mesh.
InstanceType * get() const
Associated instance or nullptr if none.
Reference to an instance.
ISubDomain * subDomain() const
Access to the associated ISubDomain.
Structure containing the information to create a service.
TraceMessage info() const
Flow for an information message.
1D data vector with value semantics (STL style).
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int32_t Int32
Signed integer type of 32 bits.