TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
PE_Groups.h
1/****************************************************************************
2* Copyright (c) 2025, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#ifndef PE_Groups_included
17#define PE_Groups_included
18
19#include <TRUSTTabs_forward.h>
20#include <TRUST_Vector.h>
21#include <TRUST_Deriv.h>
22#include <Comm_Group.h>
23
24/*! @brief This class groups functions for creating, destroying and changing the active processor group.
25 *
26 * The creation of the main group must be done in MAIN.cpp and PE_Groups must be initialized by providing
27 * it with the main group. Other groups created will be of the same type.
28 *
29 * @sa Comm_Group
30 *
31 */
33{
34public:
35 inline static const Comm_Group& current_group();
36 static void create_group(const ArrOfInt& liste_pe, OWN_PTR(Comm_Group) &group, int force_Comm_Group_NoParallel = 0);
37 static void init_group(const ArrOfInt& liste_pe, OWN_PTR(Comm_Group) &group);
38 static int enter_group(const Comm_Group& group);
39 static void exit_group();
40 static const int& get_nb_groups();
41 static int rank_translate(int rank, const Comm_Group& group, const Comm_Group& dest_group = current_group());
42 static const Comm_Group& groupe_TRUST();
43 static const Comm_Group& get_node_group();
44 static const Comm_Group& get_node_master();
45 static const Comm_Group& get_user_defined_group();
46 static bool has_user_defined_group();
47
48 static void initialize(const Comm_Group& groupe_trio_u);
49 static void initialize_node(const Comm_Group& ngrp);
50 static void initialize_node_master(const Comm_Group& ngrp);
51 static void initialize_user_defined_group(const Comm_Group& ngrp);
52 static void finalize();
53
54private:
55 static int check_current_group();
56 // This pointer always points to the last element of the "groups" vector in the .cpp file
57 static const Comm_Group *current_group_;
58};
59
60/*! @brief Returns a reference to the current active processor group.
61 *
62 * @return Reference to the current Comm_Group.
63 */
65{
66 assert(check_current_group());
67 return *current_group_;
68}
69
70#endif
: This class describes a group of processors on which
Definition Comm_Group.h:37
This class groups functions for creating, destroying and changing the active processor group.
Definition PE_Groups.h:33
static void initialize_user_defined_group(const Comm_Group &ngrp)
static int enter_group(const Comm_Group &group)
If the local processor belongs to the group, the current group for this processor becomes "group" and...
static void create_group(const ArrOfInt &liste_pe, OWN_PTR(Comm_Group) &group, int force_Comm_Group_NoParallel=0)
Creates a new processor group (can be called anywhere in the code).
Definition PE_Groups.cpp:55
static void init_group(const ArrOfInt &liste_pe, OWN_PTR(Comm_Group) &group)
Initializes a new processor group that is already instantiated (can be called anywhere in the code).
Definition PE_Groups.cpp:81
static void initialize_node_master(const Comm_Group &ngrp)
Method to call after the initialization of trio_u_world, node_group, and TRUST's statistical counters...
static const int & get_nb_groups()
static void finalize()
Method to call at the end of execution, once back in groupe_TRUST() and just before destroying the ma...
static const Comm_Group & get_node_master()
Returns the group containing the master of my node.
static void initialize(const Comm_Group &groupe_trio_u)
Method to call at the beginning of execution (MAIN.cpp). Initializes current_group() with groupe_trio...
static void initialize_node(const Comm_Group &ngrp)
Method to call after the initialization of trio_u_world and TRUST's statistical counters.
static const Comm_Group & get_user_defined_group()
Returns a reference to the user-defined group.
static const Comm_Group & get_node_group()
Returns a reference to the node-level communicator group.
static bool has_user_defined_group()
static const Comm_Group & current_group()
Returns a reference to the current active processor group.
Definition PE_Groups.h:64
static int rank_translate(int rank, const Comm_Group &group, const Comm_Group &dest_group=current_group())
Computes the rank in the current group of the processor with rank "rank" in "group".
static const Comm_Group & groupe_TRUST()
Returns a reference to the group containing all TRUST processors.
static void exit_group()
Returns to the group that was active before the last successful enter_group() call (which returned 1)...