OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
processcomm.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 - 2013 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 "processcomm.h"
36 #include "intarray.h"
37 #include "combuff.h"
38 #include "dyncombuff.h"
39 
40 #ifdef __USE_MPI
41  #include <mpi.h>
42 #endif
43 
44 namespace oofem {
46 {
47  if ( t == CBT_static ) {
48  send_buff = new StaticCommunicationBuffer(MPI_COMM_WORLD);
49  recv_buff = new StaticCommunicationBuffer(MPI_COMM_WORLD);
50  } else {
51  send_buff = new DynamicCommunicationBuffer(MPI_COMM_WORLD);
52  recv_buff = new DynamicCommunicationBuffer(MPI_COMM_WORLD);
53  }
54 }
55 
56 
58  toSend(), toReceive()
59 {
60  this->rank = rank;
61  this->pcBuffer = b;
62  this->mode = m;
63 }
64 
65 
67 {
68  delete send_buff;
69  delete recv_buff;
70 }
71 
72 
73 int
75 {
76  int result = 1;
77  if ( !toSend.isEmpty() || ( this->mode == CommMode_Dynamic ) ) {
78  // fprintf (stderr, "\nNlDEIDynamicDomainComunicator :: initExchange: sending to %d",rank);
79  result = giveProcessCommunicatorBuff()->initSend(this->rank, tag);
80  } else {
82  }
83 
84  return result;
85 }
86 
87 
88 int
90 {
91  int result = 1;
92  if ( !toReceive.isEmpty() || ( this->mode == CommMode_Dynamic ) ) {
93  // fprintf (stderr, "\nNlDEIDynamicDomainComunicator :: initExchange: recv from %d",rank);
94  result &= giveProcessCommunicatorBuff()->initReceive(this->rank, tag);
95  } else {
97  }
98 
99  return result;
100 }
101 
102 
103 int
105 {
106  int result = 1;
107  result &= initSend(tag);
108  result &= initReceive(tag);
109 
110  return result;
111 }
112 
113 int
115 {
116  return waitCompletion();
117 }
118 
119 void
121 {
123 }
124 
125 int
127 {
128  if ( !toSend.isEmpty() || ( this->mode == CommMode_Dynamic ) ) {
130  } else {
131  return 1;
132  }
133 }
134 
135 int
137 {
138  if ( !toReceive.isEmpty() || ( this->mode == CommMode_Dynamic ) ) {
140  } else {
141  return 1;
142  }
143 }
144 
145 int
147 {
148  return ( sendCompleted() && receiveCompleted() );
149 }
150 
151 int
153 {
154  while ( !testCompletion() ) {
155  ;
156  }
157 
158  return 1;
159 }
160 } // end namespace oofem
int finishExchange()
Finishes the exchange. After this call all communication buffers can be reused.
Definition: processcomm.C:114
bool isEmpty() const
Checks if receiver is empty (i.e., zero sized).
Definition: intarray.h:208
CommBuffType
Definition: commbufftype.h:40
The ProcessCommunicator and corresponding buffers (represented by this class) are separated in order ...
Definition: processcomm.h:64
ProcessCommunicatorBuff * pcBuffer
Communicator buffers representation.
Definition: processcomm.h:183
void init()
Initializes receiver buffers.
Definition: processcomm.h:103
CommunicatorMode
The communicator mode determines the communication.
int initExchange(int tag)
Initializes data exchange with associated problem.
Definition: processcomm.C:104
int rank
Associated partition (problem) number (rank)
Definition: processcomm.h:180
CommunicatorMode mode
Mode.
Definition: processcomm.h:190
int initReceive(int rank, int tag)
Initialize the receive data exchange with associate problem.
Definition: processcomm.h:142
void clearBuffers()
Clears all buffer contents.
Definition: processcomm.C:120
CommunicationBuffer * send_buff
Send buffer.
Definition: processcomm.h:68
CommunicationBuffer * recv_buff
Receive buffer.
Definition: processcomm.h:70
ProcessCommunicatorBuff * giveProcessCommunicatorBuff()
Returns communication buffer.
Definition: processcomm.h:210
ProcessCommunicatorBuff(CommBuffType t)
Constructor, creates empty send and receive com buffs in MPI_COMM_WORLD.
Definition: processcomm.C:45
IntArray toReceive
Nodes to receive.
Definition: processcomm.h:188
IntArray toSend
Nodes to send.
Definition: processcomm.h:186
(Dynamic) In this case the communication pattern and the amount of data sent between nodes is not kno...
ProcessCommunicator(ProcessCommunicatorBuff *b, int irank, CommunicatorMode m=CommMode_Static)
Constructor.
Definition: processcomm.C:57
int initSend(int tag)
Initialize the send data exchange with associate problem.
Definition: processcomm.C:74
void initSendBuff()
Initializes send buffer to empty state. All packed data are lost.
Definition: processcomm.h:99
void initRecvBuff()
Initializes send buffer to empty state. All packed data are lost.
Definition: processcomm.h:101
the oofem namespace is to define a context or scope in which all oofem names are defined.
int initSend(int rank, int tag)
Initialize the send data exchange with associate problem.
Definition: processcomm.h:134
int initReceive(int tag)
Initialize the receive data exchange with associate problem.
Definition: processcomm.C:89

This page is part of the OOFEM documentation. Copyright (c) 2011 Borek Patzak
Project e-mail: info@oofem.org
Generated at Tue Jan 2 2018 20:07:30 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011