OOFEM 3.0
Loading...
Searching...
No Matches
communicator.C
Go to the documentation of this file.
1/*
2 *
3 * ##### ##### ###### ###### ### ###
4 * ## ## ## ## ## ## ## ### ##
5 * ## ## ## ## #### #### ## # ##
6 * ## ## ## ## ## ## ## ##
7 * ## ## ## ## ## ## ## ##
8 * ##### ##### ## ###### ## ##
9 *
10 *
11 * OOFEM : Object Oriented Finite Element Code
12 *
13 * Copyright (C) 1993 - 2025 Borek Patzak
14 *
15 *
16 *
17 * Czech Technical University, Faculty of Civil Engineering,
18 * Department of Structural Mechanics, 166 29 Prague, Czech Republic
19 *
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License as published by the Free Software Foundation; either
23 * version 2.1 of the License, or (at your option) any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 * Lesser General Public License for more details.
29 *
30 * You should have received a copy of the GNU Lesser General Public
31 * License along with this library; if not, write to the Free Software
32 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33 */
34
35#include "communicator.h"
36#include "intarray.h"
37
38#include <cstdarg>
39#include <cstdint>
40
41#ifdef __USE_MPI
42 #include <mpi.h>
43#endif
44
45namespace oofem {
46CommunicatorBuff :: CommunicatorBuff(int s, CommBuffType t)
47{
48 this->processCommBuffs.reserve(s);
49 for ( int i = 0; i < s; ++i ) {
50 this->processCommBuffs.emplace_back(t);
51 }
52}
53
54
55Communicator :: Communicator(EngngModel *emodel, CommunicatorBuff *b, int rank, int size, CommunicatorMode m) :
56 rank(rank),
57 engngModel(emodel),
58 mode(m)
59{
60 processComms.reserve(size);
61 for ( int i = 0; i < size; i++ ) {
62 processComms.emplace_back(b->giveProcessCommunicatorBuff ( i ), i, mode);
63 }
64}
65
66
67int
68Communicator :: initExchange(int tag)
69{
70 int result = 1;
71 for ( auto &pc : processComms ) {
72 result &= pc.initExchange(tag);
73 }
74
75 return result;
76}
77
78int
79Communicator :: finishExchange()
80{
81 int result = 1;
82 for ( auto &pc : processComms ) {
83 result &= pc.finishExchange();
84 }
85
86 return result;
87}
88
89
90
91int
92Communicator :: initSend(int tag)
93{
94 int result = 1;
95 for ( auto &pc : processComms ) {
96 result &= pc.initSend(tag);
97 }
98
99 return result;
100}
101
102int
103Communicator :: initReceive(int tag)
104{
105 int result = 1;
106 for ( auto &pc : processComms) {
107 result &= pc.initReceive(tag);
108 }
109
110 return result;
111}
112
113void
114Communicator :: clearBuffers()
115{
116 for ( auto &pc : processComms ) {
117 pc.clearBuffers();
118 }
119}
120
121std :: string
122Communicator :: errorInfo(const char *func) const
123{
124 return std::string("Communicator::") + func + ", Rank: " + std::to_string(rank);
125}
126} // end namespace oofem
ProcessCommunicatorBuff * giveProcessCommunicatorBuff(int i)
std::vector< ProcessCommunicatorBuff > processCommBuffs
Array of process communicators.
int rank
Rank of process.
EngngModel * engngModel
Engineering model.
CommunicatorMode mode
Mode.
std::vector< ProcessCommunicator > processComms
Array of process communicators.

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011