decomposedBlockData.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2017 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "decomposedBlockData.H"
27 #include "OPstream.H"
28 #include "IPstream.H"
29 #include "PstreamBuffers.H"
30 #include "OFstream.H"
31 #include "IFstream.H"
32 #include "IStringStream.H"
33 #include "dictionary.H"
34 #include <sys/time.h>
35 #include "objectRegistry.H"
36 
37 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41  defineTypeNameAndDebug(decomposedBlockData, 0);
42 }
43 
44 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 
47 (
48  const label comm,
49  const IOobject& io,
50  const UPstream::commsTypes commsType
51 )
52 :
53  regIOobject(io),
54  commsType_(commsType),
55  comm_(comm)
56 {
57  // Temporary warning
59  {
61  << "decomposedBlockData " << name()
62  << " constructed with IOobject::MUST_READ_IF_MODIFIED"
63  " but decomposedBlockData does not support automatic rereading."
64  << endl;
65  }
66  if
67  (
68  (
71  )
72  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
73  )
74  {
75  read();
76  }
77 }
78 
79 
81 (
82  const label comm,
83  const IOobject& io,
84  const UList<char>& list,
85  const UPstream::commsTypes commsType
86 )
87 :
88  regIOobject(io),
89  commsType_(commsType),
90  comm_(comm)
91 {
92  // Temporary warning
94  {
96  << "decomposedBlockData " << name()
97  << " constructed with IOobject::MUST_READ_IF_MODIFIED"
98  " but decomposedBlockData does not support automatic rereading."
99  << endl;
100  }
101 
102  if
103  (
104  (
107  )
108  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
109  )
110  {
111  read();
112  }
113  else
114  {
115  List<char>::operator=(list);
116  }
117 }
118 
119 
121 (
122  const label comm,
123  const IOobject& io,
124  const Xfer<List<char>>& list,
125  const UPstream::commsTypes commsType
126 )
127 :
128  regIOobject(io),
129  commsType_(commsType),
130  comm_(comm)
131 {
132  // Temporary warning
134  {
136  << "decomposedBlockData " << name()
137  << " constructed with IOobject::MUST_READ_IF_MODIFIED"
138  " but decomposedBlockData does not support automatic rereading."
139  << endl;
140  }
141 
142  List<char>::transfer(list());
143 
144  if
145  (
146  (
149  )
150  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
151  )
152  {
153  read();
154  }
155 }
156 
157 
158 // * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
159 
161 {}
162 
163 
164 // * * * * * * * * * * * * * * * Members Functions * * * * * * * * * * * * * //
165 
167 {
168  if (debug)
169  {
170  Pout<< "decomposedBlockData::readMasterHeader:"
171  << " stream:" << is.name() << endl;
172  }
173 
174  // Master-only reading of header
175  is.fatalCheck("read(Istream&)");
176 
177  List<char> data(is);
178  is.fatalCheck("read(Istream&) : reading entry");
179  string buf(data.begin(), data.size());
180  IStringStream str(is.name(), buf);
181 
182  return io.readHeader(str);
183 }
184 
185 
187 (
188  Ostream& os,
189  const IOstream::versionNumber version,
190  const IOstream::streamFormat format,
191  const word& type,
192  const string& note,
193  const fileName& location,
194  const word& name
195 )
196 {
198  << "FoamFile\n{\n"
199  << " version " << version << ";\n"
200  << " format " << format << ";\n"
201  << " class " << type << ";\n";
202  if (note.size())
203  {
204  os << " note " << note << ";\n";
205  }
206 
207  if (location.size())
208  {
209  os << " location " << location << ";\n";
210  }
211 
212  os << " object " << name << ";\n"
213  << "}" << nl;
214 
215  IOobject::writeDivider(os) << nl;
216 }
217 
218 
220 (
221  const label blocki,
222  Istream& is,
223  IOobject& headerIO
224 )
225 {
226  if (debug)
227  {
228  Pout<< "decomposedBlockData::readBlock:"
229  << " stream:" << is.name() << " attempt to read block " << blocki
230  << endl;
231  }
232 
233  is.fatalCheck("read(Istream&)");
234 
235  List<char> data;
236  autoPtr<ISstream> realIsPtr;
237 
238  if (blocki == 0)
239  {
240  is >> data;
241  is.fatalCheck("read(Istream&) : reading entry");
242 
243  string buf(data.begin(), data.size());
244  realIsPtr = new IStringStream(is.name(), buf);
245 
246  // Read header
247  if (!headerIO.readHeader(realIsPtr()))
248  {
249  FatalIOErrorInFunction(realIsPtr())
250  << "problem while reading header for object "
251  << is.name() << exit(FatalIOError);
252  }
253  }
254  else
255  {
256  // Read master for header
257  is >> data;
258  is.fatalCheck("read(Istream&) : reading entry");
259 
262  {
263  string buf(data.begin(), data.size());
264  IStringStream headerStream(is.name(), buf);
265 
266  // Read header
267  if (!headerIO.readHeader(headerStream))
268  {
269  FatalIOErrorInFunction(headerStream)
270  << "problem while reading header for object "
271  << is.name() << exit(FatalIOError);
272  }
273  ver = headerStream.version();
274  fmt = headerStream.format();
275  }
276 
277  for (label i = 1; i < blocki+1; i++)
278  {
279  // Read data, override old data
280  is >> data;
281  is.fatalCheck("read(Istream&) : reading entry");
282  }
283  string buf(data.begin(), data.size());
284  realIsPtr = new IStringStream(is.name(), buf);
285 
286  // Apply master stream settings to realIsPtr
287  realIsPtr().format(fmt);
288  realIsPtr().version(ver);
289  }
290  return realIsPtr;
291 }
292 
293 
295 (
296  const label comm,
297  autoPtr<ISstream>& isPtr,
298  List<char>& data,
299  const UPstream::commsTypes commsType
300 )
301 {
302  if (debug)
303  {
304  Pout<< "decomposedBlockData::readBlocks:"
305  << " stream:" << (isPtr.valid() ? isPtr().name() : "invalid")
306  << " commsType:" << Pstream::commsTypeNames[commsType]
307  << " comm:" << comm << endl;
308  }
309 
310  bool ok = false;
311 
312  if (commsType == UPstream::commsTypes::scheduled)
313  {
314  if (UPstream::master(comm))
315  {
316  Istream& is = isPtr();
317  is.fatalCheck("read(Istream&)");
318 
319  // Read master data
320  {
321  is >> data;
322  is.fatalCheck("read(Istream&) : reading entry");
323  }
324 
325  // Read slave data
326  for
327  (
328  label proci = 1;
329  proci < UPstream::nProcs(comm);
330  proci++
331  )
332  {
333  List<char> elems(is);
334  is.fatalCheck("read(Istream&) : reading entry");
335 
336  OPstream os
337  (
339  proci,
340  0,
342  comm
343  );
344  os << elems;
345  }
346 
347  ok = is.good();
348  }
349  else
350  {
351  IPstream is
352  (
355  0,
357  comm
358  );
359  is >> data;
360  }
361  }
362  else
363  {
364  PstreamBuffers pBufs
365  (
368  comm
369  );
370 
371  if (UPstream::master(comm))
372  {
373  Istream& is = isPtr();
374  is.fatalCheck("read(Istream&)");
375 
376  // Read master data
377  {
378  is >> data;
379  is.fatalCheck("read(Istream&) : reading entry");
380  }
381 
382  // Read slave data
383  for
384  (
385  label proci = 1;
386  proci < UPstream::nProcs(comm);
387  proci++
388  )
389  {
390  List<char> elems(is);
391  is.fatalCheck("read(Istream&) : reading entry");
392 
393  UOPstream os(proci, pBufs);
394  os << elems;
395  }
396  }
397 
398  labelList recvSizes;
399  pBufs.finishedSends(recvSizes);
400 
401  if (!UPstream::master(comm))
402  {
403  UIPstream is(UPstream::masterNo(), pBufs);
404  is >> data;
405  }
406  }
407 
408  Pstream::scatter(ok, Pstream::msgType(), comm);
409 
410  return ok;
411 }
412 
413 
415 (
416  const label comm,
417  const fileName& fName,
418  autoPtr<ISstream>& isPtr,
419  IOobject& headerIO,
420  const UPstream::commsTypes commsType
421 )
422 {
423  if (debug)
424  {
425  Pout<< "decomposedBlockData::readBlocks:"
426  << " stream:" << (isPtr.valid() ? isPtr().name() : "invalid")
427  << " commsType:" << Pstream::commsTypeNames[commsType] << endl;
428  }
429 
430  bool ok = false;
431 
432  List<char> data;
433  autoPtr<ISstream> realIsPtr;
434 
435  if (commsType == UPstream::commsTypes::scheduled)
436  {
437  if (UPstream::master(comm))
438  {
439  Istream& is = isPtr();
440  is.fatalCheck("read(Istream&)");
441 
442  // Read master data
443  {
444  is >> data;
445  is.fatalCheck("read(Istream&) : reading entry");
446 
447  string buf(data.begin(), data.size());
448  realIsPtr = new IStringStream(fName, buf);
449 
450  // Read header
451  if (!headerIO.readHeader(realIsPtr()))
452  {
453  FatalIOErrorInFunction(realIsPtr())
454  << "problem while reading header for object "
455  << is.name() << exit(FatalIOError);
456  }
457  }
458 
459  // Read slave data
460  for
461  (
462  label proci = 1;
463  proci < UPstream::nProcs(comm);
464  proci++
465  )
466  {
467  is >> data;
468  is.fatalCheck("read(Istream&) : reading entry");
469 
470  OPstream os
471  (
473  proci,
474  0,
476  comm
477  );
478  os << data;
479  }
480 
481  ok = is.good();
482  }
483  else
484  {
485  IPstream is
486  (
489  0,
491  comm
492  );
493  is >> data;
494 
495  string buf(data.begin(), data.size());
496  realIsPtr = new IStringStream(fName, buf);
497  }
498  }
499  else
500  {
501  PstreamBuffers pBufs
502  (
505  comm
506  );
507 
508  if (UPstream::master(comm))
509  {
510  Istream& is = isPtr();
511  is.fatalCheck("read(Istream&)");
512 
513  // Read master data
514  {
515  is >> data;
516  is.fatalCheck("read(Istream&) : reading entry");
517 
518  string buf(data.begin(), data.size());
519  realIsPtr = new IStringStream(fName, buf);
520 
521  // Read header
522  if (!headerIO.readHeader(realIsPtr()))
523  {
524  FatalIOErrorInFunction(realIsPtr())
525  << "problem while reading header for object "
526  << is.name() << exit(FatalIOError);
527  }
528  }
529 
530  // Read slave data
531  for
532  (
533  label proci = 1;
534  proci < UPstream::nProcs(comm);
535  proci++
536  )
537  {
538  List<char> elems(is);
539  is.fatalCheck("read(Istream&) : reading entry");
540 
541  UOPstream os(proci, pBufs);
542  os << elems;
543  }
544 
545  ok = is.good();
546  }
547 
548  labelList recvSizes;
549  pBufs.finishedSends(recvSizes);
550 
551  if (!UPstream::master(comm))
552  {
553  UIPstream is(UPstream::masterNo(), pBufs);
554  is >> data;
555 
556  string buf(data.begin(), data.size());
557  realIsPtr = new IStringStream(fName, buf);
558  }
559  }
560 
561  Pstream::scatter(ok, Pstream::msgType(), comm);
562 
563  // version
564  string versionString(realIsPtr().version().str());
565  Pstream::scatter(versionString, Pstream::msgType(), comm);
566  realIsPtr().version(IStringStream(versionString)());
567 
568  // stream
569  {
570  OStringStream os;
571  os << realIsPtr().format();
572  string formatString(os.str());
573  Pstream::scatter(formatString, Pstream::msgType(), comm);
574  realIsPtr().format(formatString);
575  }
576 
577  word name(headerIO.name());
578  Pstream::scatter(name, Pstream::msgType(), comm);
579  headerIO.rename(name);
581  Pstream::scatter(headerIO.note(), Pstream::msgType(), comm);
582  //Pstream::scatter(headerIO.instance(), Pstream::msgType(), comm);
583  //Pstream::scatter(headerIO.local(), Pstream::msgType(), comm);
584 
585  return realIsPtr;
586 }
587 
588 
590 (
591  const label comm,
592  autoPtr<OSstream>& osPtr,
593  List<std::streamoff>& start,
594  const UList<char>& data,
595  const UPstream::commsTypes commsType,
596  const bool syncReturnState
597 )
598 {
599  if (debug)
600  {
601  Pout<< "decomposedBlockData::writeBlocks:"
602  << " stream:" << (osPtr.valid() ? osPtr().name() : "invalid")
603  << " data:" << data.size()
604  << " commsType:" << Pstream::commsTypeNames[commsType] << endl;
605  }
606 
607  bool ok = true;
608 
609  labelList recvSizes(Pstream::nProcs(comm));
610  recvSizes[Pstream::myProcNo(comm)] = data.byteSize();
611  Pstream::gatherList(recvSizes, Pstream::msgType(), comm);
612 
613  if (commsType == UPstream::commsTypes::scheduled)
614  {
615  if (UPstream::master(comm))
616  {
617  start.setSize(UPstream::nProcs(comm));
618 
619  OSstream& os = osPtr();
620 
621  // Write master data
622  {
623  os << nl << "// Processor" << UPstream::masterNo() << nl;
624  start[UPstream::masterNo()] = os.stdStream().tellp();
625  os << data;
626  }
627  // Write slaves
628  List<char> elems;
629  for (label proci = 1; proci < UPstream::nProcs(comm); proci++)
630  {
631  elems.setSize(recvSizes[proci]);
633  (
635  proci,
636  elems.begin(),
637  elems.size(),
639  comm
640  );
641 
642  os << nl << nl << "// Processor" << proci << nl;
643  start[proci] = os.stdStream().tellp();
644  os << elems;
645  }
646 
647  ok = os.good();
648  }
649  else
650  {
652  (
655  data.begin(),
656  data.byteSize(),
658  comm
659  );
660  }
661  }
662  else
663  {
664  if (debug)
665  {
666  struct timeval tv;
667  gettimeofday(&tv, nullptr);
668  Pout<< "Starting sending at:"
669  << 1.0*tv.tv_sec+tv.tv_usec/1e6 << " s"
670  << Foam::endl;
671  }
672 
673 
674  label startOfRequests = Pstream::nRequests();
675 
676  if (!UPstream::master(comm))
677  {
679  (
682  data.begin(),
683  data.byteSize(),
685  comm
686  );
687  Pstream::waitRequests(startOfRequests);
688  }
689  else
690  {
691  List<List<char>> recvBufs(Pstream::nProcs(comm));
692  for (label proci = 1; proci < UPstream::nProcs(comm); proci++)
693  {
694  recvBufs[proci].setSize(recvSizes[proci]);
696  (
698  proci,
699  recvBufs[proci].begin(),
700  recvSizes[proci],
702  comm
703  );
704  }
705 
706  if (debug)
707  {
708  struct timeval tv;
709  gettimeofday(&tv, nullptr);
710  Pout<< "Starting master-only writing at:"
711  << 1.0*tv.tv_sec+tv.tv_usec/1e6 << " s"
712  << Foam::endl;
713  }
714 
715  start.setSize(UPstream::nProcs(comm));
716 
717  OSstream& os = osPtr();
718 
719  // Write master data
720  {
721  os << nl << "// Processor" << UPstream::masterNo() << nl;
722  start[UPstream::masterNo()] = os.stdStream().tellp();
723  os << data;
724  }
725 
726  if (debug)
727  {
728  struct timeval tv;
729  gettimeofday(&tv, nullptr);
730  Pout<< "Starting slave writing at:"
731  << 1.0*tv.tv_sec+tv.tv_usec/1e6 << " s"
732  << Foam::endl;
733  }
734 
735  // Write slaves
736  for (label proci = 1; proci < UPstream::nProcs(comm); proci++)
737  {
738  os << nl << nl << "// Processor" << proci << nl;
739  start[proci] = os.stdStream().tellp();
740 
741  if (Pstream::finishedRequest(startOfRequests+proci-1))
742  {
743  os << recvBufs[proci];
744  }
745  }
746 
747  Pstream::resetRequests(startOfRequests);
748 
749  ok = os.good();
750  }
751  }
752  if (debug)
753  {
754  struct timeval tv;
755  gettimeofday(&tv, nullptr);
756  Pout<< "Finished master-only writing at:"
757  << 1.0*tv.tv_sec+tv.tv_usec/1e6 << " s"
758  << Foam::endl;
759  }
760 
761  if (syncReturnState)
762  {
763  //- Enable to get synchronised error checking. Is the one that keeps
764  // slaves as slow as the master (which does all the writing)
765  Pstream::scatter(ok, Pstream::msgType(), comm);
766  }
767 
768  return ok;
769 }
770 
771 
773 {
774  autoPtr<ISstream> isPtr;
775  fileName objPath(fileHandler().filePath(false, *this, word::null));
776  if (UPstream::master(comm_))
777  {
778  isPtr.reset(new IFstream(objPath));
779  IOobject::readHeader(isPtr());
780  }
781 
782  List<char>& data = *this;
783  return readBlocks(comm_, isPtr, data, commsType_);
784 }
785 
786 
788 {
789  const List<char>& data = *this;
790 
791  string str
792  (
793  reinterpret_cast<const char*>(data.cbegin()),
794  data.byteSize()
795  );
796 
797  IOobject io(*this);
798  if (Pstream::master())
799  {
800  IStringStream is(name(), str);
801  io.readHeader(is);
802  }
803 
804  // Scatter header information
805 
806  // version
807  string versionString(os.version().str());
808  Pstream::scatter(versionString);
809 
810  // stream
811  string formatString;
812  {
813  OStringStream os;
814  os << os.format();
815  formatString = os.str();
816  Pstream::scatter(formatString);
817  }
818 
819  //word masterName(name());
820  //Pstream::scatter(masterName);
821 
822  Pstream::scatter(io.headerClassName());
823  Pstream::scatter(io.note());
824  //Pstream::scatter(io.instance(), Pstream::msgType(), comm);
825  //Pstream::scatter(io.local(), Pstream::msgType(), comm);
826 
827  fileName masterLocation(instance()/db().dbDir()/local());
828  Pstream::scatter(masterLocation);
829 
830  if (!Pstream::master())
831  {
832  writeHeader
833  (
834  os,
835  IOstream::versionNumber(IStringStream(versionString)()),
836  IOstream::formatEnum(formatString),
837  io.headerClassName(),
838  io.note(),
839  masterLocation,
840  name()
841  );
842  }
843 
844  os.writeQuoted(str, false);
845 
846  if (!Pstream::master())
847  {
849  }
850 
851  return os.good();
852 }
853 
854 
856 (
860  const bool valid
861 ) const
862 {
863  autoPtr<OSstream> osPtr;
864  if (UPstream::master(comm_))
865  {
866  // Note: always write binary. These are strings so readable
867  // anyway. They have already be tokenised on the sending side.
868  osPtr.reset(new OFstream(objectPath(), IOstream::BINARY, ver, cmp));
869  IOobject::writeHeader(osPtr());
870  }
871  List<std::streamoff> start;
872  return writeBlocks(comm_, osPtr, start, *this, commsType_);
873 }
874 
875 
877 {
878  label nBlocks = 0;
879 
880  IFstream is(fName);
881  is.fatalCheck("decomposedBlockData::numBlocks(const fileName&)");
882 
883  if (!is.good())
884  {
885  return nBlocks;
886  }
887 
888  // Skip header
889  token firstToken(is);
890 
891  if
892  (
893  is.good()
894  && firstToken.isWord()
895  && firstToken.wordToken() == "FoamFile"
896  )
897  {
898  dictionary headerDict(is);
899  is.version(headerDict.lookup("version"));
900  is.format(headerDict.lookup("format"));
901  }
902 
903  List<char> data;
904  while (is.good())
905  {
906  token sizeToken(is);
907  if (!sizeToken.isLabel())
908  {
909  return nBlocks;
910  }
911  is.putBack(sizeToken);
912 
913  is >> data;
914  nBlocks++;
915  }
916 
917  return nBlocks;
918 }
919 
920 
921 // ************************************************************************* //
bool isLabel() const
Definition: tokenI.H:254
decomposedBlockData(const label comm, const IOobject &, const UPstream::commsTypes=UPstream::commsTypes::scheduled)
Construct given an IOobject.
A simple container for copying or transferring objects of type <T>.
Definition: Xfer.H:85
virtual ~decomposedBlockData()
Destructor.
static bool readBlocks(const label comm, autoPtr< ISstream > &isPtr, List< char > &data, const UPstream::commsTypes commsType)
Read data into *this. ISstream is only valid on master.
Generic output stream.
Definition: OSstream.H:51
bool isWord() const
Definition: tokenI.H:213
static streamFormat formatEnum(const word &)
Return stream format of given format name.
Definition: IOstream.C:39
virtual bool read()
Read object.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
static int masterNo()
Process index of the master.
Definition: UPstream.H:406
const word & name() const
Return name.
Definition: IOobject.H:291
A class for handling file names.
Definition: fileName.H:69
static Stream & writeBanner(Stream &os, bool noHint=false)
Write the standard OpenFOAM file/dictionary banner.
Definition: IOobjectI.H:45
virtual bool writeData(Ostream &) const
Write separated content. Assumes content is the serialised data.
void finishedSends(const bool block=true)
Mark all sends as having been done. This will start receives.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
commsTypes
Types of communications.
Definition: UPstream.H:64
const word & wordToken() const
Definition: tokenI.H:218
Output to file stream.
Definition: OFstream.H:82
static Stream & writeDivider(Stream &os)
Write the standard file section divider.
Definition: IOobjectI.H:98
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:163
virtual void rename(const word &newName)
Rename.
Definition: IOobject.H:321
A token holds items read from Istream.
Definition: token.H:69
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Definition: UPstream.H:418
const_iterator cbegin() const
Return const_iterator to begin traversing the constant UList.
Definition: UListI.H:230
void putBack(const token &)
Put back token.
Definition: Istream.C:30
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
static label numBlocks(const fileName &)
Detect number of blocks in a file.
static bool master(const label communicator=0)
Am I the master process.
Definition: UPstream.H:412
static bool writeBlocks(const label comm, autoPtr< OSstream > &osPtr, List< std::streamoff > &start, const UList< char > &, const UPstream::commsTypes, const bool syncReturnState=true)
Write *this. Ostream only valid on master. Returns starts of.
static bool finishedRequest(const label i)
Non-blocking comms: has request i finished?
Definition: UPstream.C:125
static label nRequests()
Get number of outstanding requests.
Definition: UPstream.C:107
static int & msgType()
Message tag of standard messages.
Definition: UPstream.H:465
versionNumber version() const
Return the stream version.
Definition: IOstream.H:399
bool good() const
Return true if next operation might succeed.
Definition: IOstream.H:333
virtual Ostream & writeQuoted(const std::string &, const bool quoted=true)=0
Write std::string surrounded by quotes.
Input inter-processor communications stream.
Definition: IPstream.H:50
Input inter-processor communications stream operating on external buffer.
Definition: UIPstream.H:53
bool readHeader(Istream &)
Read header.
string & note()
Return non-constant access to the optional note.
Definition: IOobject.H:309
bool read(const char *, int32_t &)
Definition: int32IO.C:85
void reset(T *=0)
If object pointer already set, delete object and set to given.
Definition: autoPtrI.H:114
A class for handling words, derived from string.
Definition: word.H:59
virtual const fileName & name() const
Return the name of the stream.
Definition: IOstream.H:297
static void writeHeader(Ostream &os, const IOstream::versionNumber version, const IOstream::streamFormat format, const word &type, const string &note, const fileName &location, const word &name)
Helper: write FoamFile IOobject header.
static void resetRequests(const label sz)
Truncate number of outstanding requests.
Definition: UPstream.C:113
iterator begin()
Return an iterator to begin traversing the UList.
Definition: UListI.H:216
streamFormat
Enumeration for the format of data in the stream.
Definition: IOstream.H:86
static const word null
An empty word.
Definition: word.H:77
const fileOperation & fileHandler()
Get current file handler.
streamFormat format() const
Return current stream format.
Definition: IOstream.H:377
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
Definition: autoPtrI.H:83
void fatalCheck(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:105
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:61
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Distribute without modification. Reverse of gather.
compressionType
Enumeration for the format of data in the stream.
Definition: IOstream.H:193
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
Output inter-processor communications stream operating on external buffer.
Definition: UOPstream.H:54
static label read(const commsTypes commsType, const int fromProcNo, char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label communicator=0)
Read into given buffer from given processor and return the.
Definition: UIPread.C:79
static const char nl
Definition: Ostream.H:262
defineTypeNameAndDebug(combustionModel, 0)
static bool write(const commsTypes commsType, const int toProcNo, const char *buf, const std::streamsize bufSize, const int tag=UPstream::msgType(), const label communicator=0)
Write given buffer to given processor.
Definition: UOPwrite.C:34
Input from file stream.
Definition: IFstream.H:81
static const NamedEnum< commsTypes, 3 > commsTypeNames
Definition: UPstream.H:71
Output inter-processor communications stream.
Definition: OPstream.H:50
Buffers for inter-processor communications streams (UOPstream, UIPstream).
static void waitRequests(const label start=0)
Wait until all requests (from start onwards) have finished.
Definition: UPstream.C:117
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
virtual bool writeObject(IOstream::streamFormat, IOstream::versionNumber, IOstream::compressionType, const bool valid) const
Write using given format, version and compression.
void operator=(const UList< T > &)
Assignment to UList operator. Takes linear time.
Definition: List.C:376
virtual ostream & stdStream()
Access to underlying std::ostream.
Definition: OSstream.H:178
void setSize(const label)
Reset size of List.
Definition: List.C:281
static autoPtr< ISstream > readBlock(const label blocki, Istream &is, IOobject &headerIO)
Read selected block (non-seeking) + header information.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
Definition: UPstream.H:400
static Stream & writeEndDivider(Stream &os)
Write the standard end file divider.
Definition: IOobjectI.H:108
static bool readMasterHeader(IOobject &, Istream &)
Read header. Call only on master.
#define WarningInFunction
Report a warning using Foam::Warning.
static const versionNumber currentVersion
Current version number.
Definition: IOstream.H:206
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:331
string str() const
Return the versionNumber as a character string.
Definition: IOstream.C:116
std::streamsize byteSize() const
Return the binary size in number of characters of the UList.
Definition: UList.C:100
Input from memory buffer stream.
Definition: IStringStream.H:49
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
string str() const
Return the string.
Version number type.
Definition: IOstream.H:96
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:65
bool writeHeader(Ostream &) const
Write header.
label size() const
Return the number of elements in the UList.
Definition: UListI.H:299
readOption readOpt() const
Definition: IOobject.H:353
const word & headerClassName() const
Return name of the class name read from header.
Definition: IOobject.H:297
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
Output to memory buffer stream.
Definition: OStringStream.H:49
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
Definition: List.C:342
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:576
IOerror FatalIOError