uncollatedFileOperation.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2017 OpenFOAM Foundation
9  Copyright (C) 2020-2024 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
31 #include "Time.H"
32 #include "Fstream.H"
34 #include "decomposedBlockData.H"
35 #include "dummyISstream.H"
36 
37 /* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
38 
39 namespace Foam
40 {
41 namespace fileOperations
42 {
43  defineTypeNameAndDebug(uncollatedFileOperation, 0);
45  (
46  fileOperation,
47  uncollatedFileOperation,
48  word
49  );
51  (
52  fileOperation,
53  uncollatedFileOperation,
54  comm
55  );
56 
57  // Threaded MPI: not required
59  (
60  fileOperationInitialise,
61  fileOperationInitialise_unthreaded,
62  word,
63  uncollated
64  );
65 }
66 }
67 
68 
69 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
70 
72 (
73  const bool checkGlobal,
74  const bool isFile,
75  const IOobject& io,
76  const bool search
77 ) const
78 {
79  if (io.instance().isAbsolute())
80  {
81  fileName objectPath(io.instance()/io.name());
82 
84  {
85  return objectPath;
86  }
87  }
88  else
89  {
90  fileName path(io.path());
91  fileName objectPath(path/io.name());
92 
94  {
95  return objectPath;
96  }
97  else
98  {
99  if
100  (
101  checkGlobal
102  && io.time().processorCase()
103  && (
104  io.instance() == io.time().system()
105  || io.instance() == io.time().constant()
106  )
107  )
108  {
109  // Constant & system can come from global case
110 
111  fileName parentPath =
112  (
113  io.rootPath()/io.globalCaseName()
114  /io.instance()/io.db().dbDir()/io.local()/io.name()
115  );
116 
117  if (isFileOrDir(isFile, parentPath))
118  {
119  return parentPath;
120  }
121  }
122 
123  // Check if parallel "procesors" directory
124  if (io.time().processorCase())
125  {
126  const refPtr<dirIndexList> pDirs
127  (
129  (
130  io.objectPath()
131  )
132  );
133 
134  for (const dirIndex& dirIdx : pDirs())
135  {
136  const fileName& pDir = dirIdx.first();
137  fileName objPath =
138  processorsPath(io, io.instance(), pDir)
139  /io.name();
140  if (objPath != objectPath && isFileOrDir(isFile, objPath))
141  {
142  return objPath;
143  }
144  }
145  }
146 
147 
148  // Check for approximately same time. E.g. if time = 1e-2 and
149  // directory is 0.01 (due to different time formats)
150  if (search && !Foam::isDir(path))
151  {
152  word newInstancePath = io.time().findInstancePath
153  (
154  instant(io.instance())
155  );
156 
157  if (newInstancePath.size())
158  {
159  fileName fName
160  (
161  io.rootPath()/io.caseName()
162  /newInstancePath/io.db().dbDir()/io.local()/io.name()
163  );
164 
165  if (isFileOrDir(isFile, fName))
166  {
167  return fName;
168  }
169  }
170  }
171  }
172  }
174  return fileName();
175 }
176 
177 
180 (
181  const fileName& fName
182 ) const
183 {
184  // No additional parallel synchronisation
185  return fileOperation::lookupAndCacheProcessorsPath(fName, false);
186 }
187 
189 // * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
190 
191 namespace Foam
192 {
193 
194 // Construction helper: self/world/local communicator and IO ranks
196 {
197  // Default is COMM_SELF (only involves itself)
198  Tuple2<label, labelList> commAndIORanks
199  (
202  );
203 
204  if (UPstream::parRun() && commAndIORanks.second().size() > 1)
205  {
206  // Multiple masters: ranks for my IO range
207  commAndIORanks.first() = UPstream::allocateCommunicator
208  (
210  fileOperation::subRanks(commAndIORanks.second())
211  );
212  }
213 
214  return commAndIORanks;
215 }
216 
217 } // End namespace Foam
218 
219 
220 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
221 
222 void Foam::fileOperations::uncollatedFileOperation::init(bool verbose)
223 {
224  verbose = (verbose && Foam::infoDetailLevel > 0);
225 
226  if (verbose)
227  {
229  << "I/O : " << typeName << endl;
230  }
231 }
232 
233 
235 (
236  bool verbose
237 )
238 :
240  (
242  ),
243  managedComm_(getManagedComm(comm_)) // Possibly locally allocated
244 {
245  init(verbose);
246 }
247 
248 
250 (
251  const Tuple2<label, labelList>& commAndIORanks,
252  const bool distributedRoots,
253  bool verbose
254 )
255 :
256  fileOperation(commAndIORanks, distributedRoots),
257  managedComm_(-1) // Externally managed
258 {
259  init(verbose);
260 }
261 
262 
264 {
265  // From externally -> locally managed
266  managedComm_ = getManagedComm(comm_);
267 }
268 
269 
270 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
271 
273 {
274  // Wait for any outstanding file operations
275  flush();
276 
278 }
279 
280 
281 // * * * * * * * * * * * * * Filesystem Operations * * * * * * * * * * * * * //
282 
284 (
285  const fileName& dir,
286  mode_t mode
287 ) const
288 {
289  return Foam::mkDir(dir, mode);
290 }
291 
292 
294 (
295  const fileName& fName,
296  mode_t mode
297 ) const
298 {
299  return Foam::chMod(fName, mode);
300 }
301 
302 
304 (
305  const fileName& fName,
306  const bool followLink
307 ) const
308 {
309  return Foam::mode(fName, followLink);
310 }
311 
312 
314 (
315  const fileName& fName,
316  const bool followLink
317 ) const
318 {
319  return Foam::type(fName, followLink);
320 }
321 
322 
324 (
325  const fileName& fName,
326  const bool checkGzip,
327  const bool followLink
328 ) const
329 {
330  return Foam::exists(fName, checkGzip, followLink);
331 }
332 
333 
335 (
336  const fileName& fName,
337  const bool followLink
338 ) const
339 {
340  return Foam::isDir(fName, followLink);
341 }
342 
343 
345 (
346  const fileName& fName,
347  const bool checkGzip,
348  const bool followLink
349 ) const
350 {
351  return Foam::isFile(fName, checkGzip, followLink);
352 }
353 
354 
356 (
357  const fileName& fName,
358  const bool followLink
359 ) const
360 {
361  return Foam::fileSize(fName, followLink);
362 }
363 
364 
366 (
367  const fileName& fName,
368  const bool followLink
369 ) const
370 {
371  return Foam::lastModified(fName, followLink);
372 }
373 
374 
376 (
377  const fileName& fName,
378  const bool followLink
379 ) const
380 {
381  return Foam::highResLastModified(fName, followLink);
382 }
383 
384 
386 (
387  const fileName& fName,
388  const std::string& ext
389 ) const
390 {
391  return Foam::mvBak(fName, ext);
392 }
393 
394 
396 (
397  const fileName& fName
398 ) const
399 {
400  return Foam::rm(fName);
401 }
402 
403 
405 (
406  const fileName& dir,
407  const bool silent,
408  const bool emptyOnly
409 ) const
410 {
411  return Foam::rmDir(dir, silent, emptyOnly);
412 }
413 
414 
416 (
417  const fileName& dir,
418  const fileName::Type type,
419  const bool filtergz,
420  const bool followLink
421 ) const
422 {
423  return Foam::readDir(dir, type, filtergz, followLink);
424 }
425 
426 
428 (
429  const fileName& src,
430  const fileName& dst,
431  const bool followLink
432 ) const
433 {
434  return Foam::cp(src, dst, followLink);
435 }
436 
437 
439 (
440  const fileName& src,
441  const fileName& dst
442 ) const
443 {
444  return Foam::ln(src, dst);
445 }
446 
447 
449 (
450  const fileName& src,
451  const fileName& dst,
452  const bool followLink
453 ) const
454 {
455  return Foam::mv(src, dst, followLink);
456 }
457 
458 
459 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
460 
462 (
463  const bool checkGlobal,
464  const IOobject& io,
465  const word& typeName,
466  const bool search
467 ) const
468 {
469  if (debug)
470  {
471  Pout<< "uncollatedFileOperation::filePath :"
472  << " objectPath:" << io.objectPath()
473  << " checkGlobal:" << checkGlobal << endl;
474  }
475 
476  fileName objPath(filePathInfo(checkGlobal, true, io, search));
477 
478  if (debug)
479  {
480  Pout<< "uncollatedFileOperation::filePath :"
481  << " Returning from file searching:" << endl
482  << " objectPath:" << io.objectPath() << endl
483  << " filePath :" << objPath << endl << endl;
484  }
485  return objPath;
486 }
487 
488 
490 (
491  const bool checkGlobal,
492  const IOobject& io,
493  const bool search
494 ) const
495 {
496  if (debug)
497  {
498  Pout<< "uncollatedFileOperation::dirPath :"
499  << " objectPath:" << io.objectPath()
500  << " checkGlobal:" << checkGlobal << endl;
501  }
502 
503  fileName objPath(filePathInfo(checkGlobal, false, io, search));
504 
505  if (debug)
506  {
507  Pout<< "uncollatedFileOperation::dirPath :"
508  << " Returning from directory searching:" << endl
509  << " objectPath:" << io.objectPath() << endl
510  << " dirPath :" << objPath << endl << endl;
511  }
512  return objPath;
513 }
514 
515 
517 (
518  const objectRegistry& db,
519  const fileName& instance,
520  const fileName& local,
521  word& newInstance
522 ) const
523 {
524  if (debug)
525  {
526  Pout<< "uncollatedFileOperation::readObjects :"
527  << " db:" << db.objectPath()
528  << " instance:" << instance << endl;
529  }
530 
531  //- Use non-time searching version
532  fileNameList objectNames
533  (
534  fileOperation::readObjects(db, instance, local, newInstance)
535  );
536 
537  if (newInstance.empty())
538  {
539  // Find similar time
540  word newInst = db.time().findInstancePath(instant(instance));
541 
542  if (!newInst.empty() && newInst != instance)
543  {
544  // Try with new time
545  objectNames = fileOperation::readObjects
546  (
547  db,
548  newInst,
549  local,
550  newInstance
551  );
552  }
553  }
554 
555  if (debug)
556  {
557  Pout<< "uncollatedFileOperation::readObjects :"
558  << " newInstance:" << newInstance
559  << " objectNames:" << objectNames << endl;
560  }
561 
562  return objectNames;
563 }
564 
565 
567 (
568  IOobject& io,
569  const fileName& fName,
570  const word& typeName
571 ) const
572 {
573  if (debug)
574  {
575  Pout<< "uncollatedFileOperation::readHeader :"
576  << " fName:" << fName
577  << " typeName:" << typeName << endl;
578  }
579  if (fName.empty())
580  {
581  if (IOobject::debug)
582  {
584  << "file " << io.objectPath() << " could not be opened"
585  << endl;
586  }
587 
588  return false;
589  }
590 
591  autoPtr<ISstream> isPtr(NewIFstream(fName));
592 
593  if (!isPtr || !isPtr->good())
594  {
595  return false;
596  }
597 
598  // Regular header or from decomposed data
599  bool ok = decomposedBlockData::readHeader(io, *isPtr);
600 
601  if (debug)
602  {
603  Pout<< "uncollatedFileOperation::readHeader :"
604  << " for fName:" << fName
605  << " ok:" << ok
606  << " headerClassName:" << io.headerClassName() << endl;
607  }
608 
609  return ok;
610 }
611 
612 
615 (
616  regIOobject& io,
617  const fileName& fName,
618  const word& typeName,
619  const bool readOnProc
620 ) const
621 {
622  if (!readOnProc)
623  {
624  return autoPtr<ISstream>(new dummyISstream());
625  }
626 
627  if (fName.empty())
628  {
630  << "cannot find file " << io.objectPath()
631  << exit(FatalError);
632  }
633 
634  autoPtr<ISstream> isPtr = NewIFstream(fName);
635 
636  if (!isPtr || !isPtr->good())
637  {
639  (
640  "uncollatedFileOperation::readStream()",
641  __FILE__,
642  __LINE__,
643  fName,
644  0
645  ) << "cannot open file"
646  << exit(FatalIOError);
647  }
648  else if (!io.readHeader(*isPtr))
649  {
650  FatalIOErrorInFunction(*isPtr)
651  << "problem while reading header for object " << io.name()
652  << exit(FatalIOError);
653  }
654 
656  {
657  // Short circuit: non-collated format.
658  return isPtr;
659  }
660  else
661  {
662  // Analyse the objectpath to find out the processor we're trying
663  // to access
664  label proci = detectProcessorPath(io.objectPath());
665 
666  if (proci == -1)
667  {
668  FatalIOErrorInFunction(*isPtr)
669  << "could not detect processor number"
670  << " from objectPath:" << io.objectPath()
671  << " fName:" << fName
672  << exit(FatalIOError);
673  }
674 
675  // Analyse the fileName for any processor subset. Note: this
676  // should really be part of filePath() which should return
677  // both file and index in file.
678  fileName path, procDir, local;
679  procRangeType group;
680  label nProcs;
681  splitProcessorPath(fName, path, procDir, local, group, nProcs);
682 
683  // The local rank (offset)
684  if (!group.empty())
685  {
686  proci = proci - group.start();
687  }
688 
689  // Read data and return as stream
690  return decomposedBlockData::readBlock(proci, *isPtr, io);
691  }
692 }
693 
694 
696 (
697  regIOobject& io,
698  const bool masterOnly,
700  const word& typeName
701 ) const
702 {
703  bool ok = false;
704 
705  if (!masterOnly || UPstream::master(UPstream::worldComm))
706  {
707  if (debug)
708  {
709  Pout<< "uncollatedFileOperation::read :"
710  << " Reading object " << io.objectPath()
711  << " from file " << endl;
712  }
713 
714  // Set flag for e.g. codeStream
715  const bool oldGlobal = io.globalObject(masterOnly);
716 
717  // If codeStream originates from dictionary which is
718  // not IOdictionary we have a problem so use global
719  const bool oldMasterOnly = regIOobject::masterOnlyReading;
720  regIOobject::masterOnlyReading = masterOnly;
721 
722  const bool oldParRun = UPstream::parRun();
723  if (masterOnly)
724  {
725  // Reading on master only.
726  // Avoid side effects from io.readStream below.
727  UPstream::parRun(false);
728  }
729 
730  // Read file
731  ok = io.readData(io.readStream(typeName));
732  io.close();
733 
734  // Restore flags
735  io.globalObject(oldGlobal);
736  regIOobject::masterOnlyReading = oldMasterOnly;
737  UPstream::parRun(oldParRun);
738 
739  if (debug)
740  {
741  Pout<< "uncollatedFileOperation::read :"
742  << " Done reading object " << io.objectPath()
743  << " from file " << endl;
744  }
745  }
746 
747  if (masterOnly && UPstream::parRun())
748  {
749  // Broadcast regIOobject content, with writeData/readData handling
751  {
752  OPBstream os(UPstream::worldComm, format);
753 
754  os << io.headerClassName() << io.note();
755  bool okWrite = io.writeData(os);
756  ok = ok && okWrite;
757  }
758  else
759  {
760  IPBstream is(UPstream::worldComm, format);
761 
762  is >> io.headerClassName() >> io.note();
763  ok = io.readData(is);
764  }
765  }
766 
767  return ok;
768 }
769 
770 
773 (
774  const fileName& filePath
775 ) const
776 {
777  return autoPtr<ISstream>(new IFstream(filePath));
778 }
779 
780 
783 (
784  const fileName& pathName,
785  IOstreamOption streamOpt,
786  const bool writeOnProc
787 ) const
788 {
789  return autoPtr<OSstream>(new OFstream(pathName, streamOpt));
790 }
791 
792 
795 (
797  const fileName& pathName,
798  IOstreamOption streamOpt,
799  const bool writeOnProc
800 ) const
801 {
802  return autoPtr<OSstream>(new OFstream(atomic, pathName, streamOpt));
803 }
804 
805 
806 // ************************************************************************* //
bool mvBak(const fileName &src, const std::string &ext="bak")
Rename to a corresponding backup file.
Definition: POSIX.C:1357
virtual bool exists(const fileName &, const bool checkGzip=true, const bool followLink=true) const
Does the name exist (as DIRECTORY or FILE) in the file system?
bool mv(const fileName &src, const fileName &dst, const bool followLink=false)
Rename src to dst.
Definition: POSIX.C:1324
A class for handling file names.
Definition: fileName.H:72
off_t fileSize(const fileName &name, const bool followLink=true)
Return size of file or -1 on failure (normally follows symbolic links).
Definition: POSIX.C:905
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
virtual bool mv(const fileName &src, const fileName &dst, const bool followLink=false) const
Rename src to dst.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:608
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition: stringOps.H:54
virtual bool chMod(const fileName &, const mode_t) const
Set the file mode.
fileName processorsPath(const IOobject &io, const word &instance, const word &procDir) const
Generate path (like io.path) with provided instance and any.
static autoPtr< ISstream > readBlock(const label blocki, ISstream &is, IOobject &headerIO)
Read selected block (non-seeking) + header information.
static void freeCommunicator(const label communicator, const bool withComponents=true)
Free a previously allocated communicator.
Definition: UPstream.C:567
virtual fileName filePath(const bool checkGlobal, const IOobject &io, const word &typeName, const bool search) const
Search for an object. checkGlobal : also check undecomposed case.
Output to file stream as an OSstream, normally using std::ofstream for the actual output...
Definition: OFstream.H:71
int infoDetailLevel
Global for selective suppression of Info output.
uncollatedFileOperation(bool verbose=false)
Default construct.
virtual bool read(regIOobject &, const bool masterOnly, const IOstreamOption::streamFormat format, const word &typeName) const
Top-level read.
virtual mode_t mode(const fileName &, const bool followLink=true) const
Return the file mode.
virtual fileNameList readObjects(const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
Search directory for objects. Used in IOobjectList.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
bool cp(const fileName &src, const fileName &dst, const bool followLink=true)
Copy the source to the destination (recursively if necessary).
Definition: POSIX.C:1063
fileName filePathInfo(const bool checkGlobal, const bool isFile, const IOobject &io, const bool search) const
Search for an object.
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:1061
virtual bool readHeader(IOobject &, const fileName &, const word &typeName) const
Read object header from supplied file.
virtual bool rmDir(const fileName &dir, const bool silent=false, const bool emptyOnly=false) const
Remove a directory and its contents.
virtual double highResLastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
static constexpr label commSelf() noexcept
Communicator within the current rank only.
Definition: UPstream.H:436
A simple container for options an IOstream can normally have.
virtual bool mkDir(const fileName &, mode_t=0777) const
Make directory.
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
Definition: UPstream.H:421
A class for managing references or pointers (no reference counting)
Definition: HashPtrTable.H:49
An encapsulation of filesystem-related operations.
fileName objectPath() const
The complete path + object name.
Definition: IOobjectI.H:284
Macros for easy insertion into run-time selection tables.
virtual bool isFile(const fileName &, const bool checkGzip=true, const bool followLink=true) const
Does the name exist as a FILE in the file system?
refPtr< dirIndexList > lookupAndCacheProcessorsPath(const fileName &objectPath, const bool syncPar) const
Lookup name of processorsDDD using cache.
constexpr const char *const group
Group name for atomic constants.
addToRunTimeSelectionTable(fileOperation, collatedFileOperation, word)
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
Definition: POSIX.C:860
Tuple2< fileName, Tuple2< pathType, int > > dirIndex
Augment fileName with pathType and local offset.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:799
atomicType
Atomic operations (output)
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
Definition: POSIX.C:614
virtual fileNameList readDir(const fileName &, const fileName::Type=fileName::FILE, const bool filtergz=true, const bool followLink=true) const
Read a directory and return the entries as a string list.
virtual bool isDir(const fileName &, const bool followLink=true) const
Does the name exist as a DIRECTORY in the file system?
virtual autoPtr< ISstream > NewIFstream(const fileName &) const
Generate an ISstream that reads a file.
A class for handling words, derived from Foam::string.
Definition: word.H:63
const Time & time() const noexcept
Return time registry.
virtual bool cp(const fileName &src, const fileName &dst, const bool followLink=true) const
Copy, recursively if necessary, the source to the destination.
virtual refPtr< dirIndexList > lookupProcessorsPath(const fileName &objectPath) const
Lookup name of processorsDDD using cache.
time_t lastModified(const fileName &name, const bool followLink=true)
Return time of last file modification (normally follows symbolic links).
Definition: POSIX.C:930
addNamedToRunTimeSelectionTable(fileOperationInitialise, fileOperationInitialise_collated, word, collated)
bool exists(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist (as DIRECTORY or FILE) in the file system?
Definition: POSIX.C:835
virtual off_t fileSize(const fileName &, const bool followLink=true) const
Return size of file.
bool local
Definition: EEqn.H:20
virtual time_t lastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
virtual bool rm(const fileName &) const
Remove a file, returning true if successful otherwise false.
static bool isCollatedType(const word &objectType)
True if object type is a known collated type.
#define DetailInfo
Definition: evalEntry.C:30
static word findInstancePath(const UList< instant > &timeDirs, const instant &t)
Search instantList for matching time value, return the instance name or word::null if nothing is equa...
Definition: TimePaths.C:125
static bool readHeader(IOobject &io, Istream &is)
Read header as per IOobject with additional handling of decomposedBlockData.
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: POSIX.C:1237
bool rmDir(const fileName &directory, const bool silent=false, const bool emptyOnly=false)
Remove a directory and its contents recursively,.
Definition: POSIX.C:1433
virtual bool ln(const fileName &src, const fileName &dst) const
Create a softlink. dst should not exist. Returns true if.
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
Input from file stream as an ISstream, normally using std::ifstream for the actual input...
Definition: IFstream.H:51
static Tuple2< label, labelList > getCommPattern()
static labelRange subRanks(const labelUList &mainIOranks)
Get (contiguous) range/bounds of ranks addressed within the given main io-ranks.
virtual fileName dirPath(const bool checkGlobal, const IOobject &io, const bool search) const
Search for a directory. checkGlobal : also check undecomposed.
bool chMod(const fileName &name, const mode_t mode)
Set the file/directory mode, return true on success.
Definition: POSIX.C:757
static bool isFileOrDir(const bool isFile, const fileName &)
Helper: check for file (isFile) or directory (!isFile)
word format(conversionProperties.get< word >("format"))
static bool masterOnlyReading
To flag master-only reading of objects.
Definition: regIOobject.H:86
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
Definition: POSIX.C:877
virtual void storeComm() const
Transfer ownership of communicator to this fileOperation. Use with caution.
Ostream & flush(Ostream &os)
Flush stream.
Definition: Ostream.H:521
virtual bool mvBak(const fileName &, const std::string &ext="bak") const
Rename to a corresponding backup file.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:637
const T2 & second() const noexcept
Access the second element.
Definition: Tuple2.H:142
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
Definition: UPstream.H:1094
virtual fileNameList readObjects(const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
Search directory for objects. Used in IOobjectList.
streamFormat
Data format (ascii | binary)
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:68
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
Definition: fileName.C:642
virtual autoPtr< OSstream > NewOFstream(const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool writeOnProc=true) const
Generate an OSstream that writes a file.
static labelList getGlobalIORanks()
Get list of global IO ranks from FOAM_IORANKS env variable. If set, these correspond to the IO master...
defineTypeNameAndDebug(collatedFileOperation, 0)
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Registry of regIOobjects.
const T1 & first() const noexcept
Access the first element.
Definition: Tuple2.H:132
List< fileName > fileNameList
List of fileName.
Definition: fileNameList.H:32
fileNameList readDir(const fileName &directory, const fileName::Type type=fileName::Type::FILE, const bool filtergz=true, const bool followLink=true)
Read a directory and return the entries as a fileName List.
Definition: POSIX.C:963
Dummy input stream, which can be used as a placeholder for interfaces taking an Istream or ISstream...
Definition: dummyISstream.H:52
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:180
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
Definition: POSIX.C:773
virtual fileName objectPath(const IOobject &io, const word &typeName) const
Generate disk file name for object. Opposite of filePath.
virtual fileName::Type type(const fileName &, const bool followLink=true) const
Return the file type: DIRECTORY, FILE or SYMLINK.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Type
Enumerations to handle directory entry types.
Definition: fileName.H:81
static label allocateCommunicator(const label parent, const labelRange &subRanks, const bool withComponents=true)
Allocate new communicator with contiguous sub-ranks on the parent communicator.
Definition: UPstream.C:260
Namespace for OpenFOAM.
double highResLastModified(const fileName &, const bool followLink=true)
Return time of last file modification.
Definition: POSIX.C:946
virtual autoPtr< ISstream > readStream(regIOobject &, const fileName &, const word &typeName, const bool readOnProc=true) const
Reads header for regIOobject and returns an ISstream.
bool rm(const fileName &file)
Remove a file (or its gz equivalent), returning true if successful.
Definition: POSIX.C:1404
IOerror FatalIOError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL IO ERROR&#39; header text and ...
#define InfoInFunction
Report an information message using Foam::Info.