OpenLB 1.7
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | List of all members
olb::ParBuf Class Reference

#include <parallelIO.h>

+ Inheritance diagram for olb::ParBuf:
+ Collaboration diagram for olb::ParBuf:

Public Types

enum  Modes { normal , serial }
 

Public Member Functions

 ParBuf (std::streambuf *_originalBuf)
 
Modes getMode () const
 
void setMode (Modes _mode)
 

Protected Member Functions

int_type overflow (int_type c) override
 
std::streamsize xsputn (const char *s, std::streamsize num) override
 
int_type uflow () override
 
int_type underflow () override
 
std::streamsize xsgetn (char *s, std::streamsize num) override
 

Detailed Description

Definition at line 37 of file parallelIO.h.

Member Enumeration Documentation

◆ Modes

Enumerator
normal 
serial 

Definition at line 39 of file parallelIO.h.

Constructor & Destructor Documentation

◆ ParBuf()

olb::ParBuf::ParBuf ( std::streambuf * _originalBuf)

Definition at line 112 of file parallelIO.h.

113 : originalBuf(_originalBuf), mode(normal)
114{ }

Member Function Documentation

◆ getMode()

ParBuf::Modes olb::ParBuf::getMode ( ) const

Definition at line 136 of file parallelIO.h.

137{
138 return mode;
139}

◆ overflow()

std::streambuf::int_type olb::ParBuf::overflow ( int_type c)
overrideprotected

Definition at line 117 of file parallelIO.h.

118{
119 int_type returnVal = c;
120 if (c != EOF) {
121#ifdef PARALLEL_MODE_MPI
122 if (singleton::mpi().isMainProcessor()) {
123#endif
124 returnVal = originalBuf->sputc((char)c);
125#ifdef PARALLEL_MODE_MPI
126 }
127 if (mode==normal) {
128 singleton::mpi().bCast(&returnVal, 1);
129 }
130#endif
131 }
132 return returnVal;
133}
void bCast(T *sendBuf, int sendCount, int root=0, MPI_Comm comm=MPI_COMM_WORLD)
Broadcast data from one processor to multiple processors.
platform_constant int c[Q][D]
MpiManager & mpi()

References olb::singleton::MpiManager::bCast(), olb::singleton::mpi(), and normal.

+ Here is the call graph for this function:

◆ setMode()

void olb::ParBuf::setMode ( ParBuf::Modes _mode)

Definition at line 142 of file parallelIO.h.

143{
144 mode = _mode;
145}

◆ uflow()

std::streambuf::int_type olb::ParBuf::uflow ( )
overrideprotected

Definition at line 163 of file parallelIO.h.

164{
165 int_type value;
166#ifdef PARALLEL_MODE_MPI
167 if (singleton::mpi().isMainProcessor()) {
168#endif
169 value = originalBuf->sbumpc();
170#ifdef PARALLEL_MODE_MPI
171 }
172 if (mode==normal) {
173 singleton::mpi().bCast(&value, 1);
174 }
175#endif
176 return value;
177}
typename std::integral_constant< TYPE, VALUE >::type value
Identity type to wrap non-type template arguments.
Definition meta.h:96

References olb::singleton::MpiManager::bCast(), olb::singleton::mpi(), and normal.

+ Here is the call graph for this function:

◆ underflow()

std::streambuf::int_type olb::ParBuf::underflow ( )
overrideprotected

Definition at line 180 of file parallelIO.h.

181{
182 int_type value;
183#ifdef PARALLEL_MODE_MPI
184 if (singleton::mpi().isMainProcessor()) {
185#endif
186 value = originalBuf->sgetc();
187#ifdef PARALLEL_MODE_MPI
188 }
189 if (mode==normal) {
190 singleton::mpi().bCast(&value, 1);
191 }
192#endif
193 return value;
194}

References olb::singleton::MpiManager::bCast(), olb::singleton::mpi(), and normal.

+ Here is the call graph for this function:

◆ xsgetn()

std::streamsize olb::ParBuf::xsgetn ( char * s,
std::streamsize num )
overrideprotected

Definition at line 197 of file parallelIO.h.

198{
199 std::streamsize sizeRead=0;
200#ifdef PARALLEL_MODE_MPI
201 if (singleton::mpi().isMainProcessor()) {
202#endif
203 sizeRead = originalBuf->sgetn(s, num);
204#ifdef PARALLEL_MODE_MPI
205 }
206 if (mode==normal) {
207 int intSizeRead = (int) sizeRead;
208 singleton::mpi().bCast(&intSizeRead, 1);
209 singleton::mpi().bCast(s, intSizeRead);
210 sizeRead = (std::streamsize) intSizeRead;
211 }
212#endif
213 return sizeRead;
214}

References olb::singleton::MpiManager::bCast(), olb::singleton::mpi(), and normal.

+ Here is the call graph for this function:

◆ xsputn()

std::streamsize olb::ParBuf::xsputn ( const char * s,
std::streamsize num )
overrideprotected

Definition at line 148 of file parallelIO.h.

149{
150#ifdef PARALLEL_MODE_MPI
151 if (singleton::mpi().isMainProcessor()) {
152#endif
153 return originalBuf->sputn(s,num);
154#ifdef PARALLEL_MODE_MPI
155 }
156 else {
157 return num;
158 }
159#endif
160}

References olb::singleton::mpi().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: