externalCoupled.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) 2015-2019 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "externalCoupled.H"
29 #include "stringListOps.H"
31 #include "OSspecific.H"
32 #include "Fstream.H"
33 #include "volFields.H"
34 #include "globalIndex.H"
35 #include "fvMesh.H"
36 #include "DynamicField.H"
37 
38 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
39 
40 namespace Foam
41 {
42 namespace functionObjects
43 {
44  defineTypeNameAndDebug(externalCoupled, 0);
45 
47  (
48  functionObject,
49  externalCoupled,
50  dictionary
51  );
52 } // End namespace functionObject
53 } // End namespace Foam
54 
56 
57 
58 namespace Foam
59 {
61 //- Write list content with size, bracket, content, bracket one-per-line.
62 // This makes for consistent for parsing, regardless of the list length.
63 template <class T>
64 static void writeList(Ostream& os, const string& header, const UList<T>& L)
65 {
66  // Header string
67  os << header.c_str() << nl;
68 
69  // Write size and start delimiter
70  os << L.size() << nl
71  << token::BEGIN_LIST << nl;
72 
73  // Write contents
74  forAll(L, i)
75  {
76  os << L[i] << nl;
77  }
78 
79  // Write end delimiter
80  os << token::END_LIST << nl << endl;
81 }
83 
84 } // End namespace Foam
85 
86 
87 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
88 
89 Foam::fileName Foam::functionObjects::externalCoupled::groupDir
90 (
91  const fileName& commsDir,
92  const word& regionGroupName,
93  const wordRe& groupName
94 )
95 {
96  fileName result
97  (
98  commsDir
99  /regionGroupName
100  /string::validate<fileName>(groupName)
101  );
102  result.clean();
103 
104  return result;
105 }
106 
107 
108 void Foam::functionObjects::externalCoupled::readColumns
109 (
110  const label nRows,
111  const label nColumns,
112  autoPtr<IFstream>& masterFilePtr,
113  List<scalarField>& data
114 ) const
115 {
116  // Get sizes for all processors
117  const globalIndex globalFaces(nRows);
118 
119  PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
120  if (Pstream::master())
121  {
122  string line;
123 
124  // Read data from file and send to destination processor
125 
126  for (label proci = 0; proci < Pstream::nProcs(); ++proci)
127  {
128  // Temporary storage
129  List<scalarField> values(nColumns);
130 
131  // Number of rows to read for processor proci
132  const label procNRows = globalFaces.localSize(proci);
133 
134  forAll(values, columni)
135  {
136  values[columni].setSize(procNRows);
137  }
138 
139  for (label rowi = 0; rowi < procNRows; ++rowi)
140  {
141  // Get a line
142  do
143  {
144  if (!masterFilePtr().good())
145  {
146  FatalIOErrorInFunction(masterFilePtr())
147  << "Trying to read data for processor " << proci
148  << " row " << rowi
149  << ". Does your file have as many rows as there are"
150  << " patch faces (" << globalFaces.size()
151  << ") ?" << exit(FatalIOError);
152  }
153 
154  masterFilePtr().getLine(line);
155  }
156  while (line.empty() || line[0] == '#');
157 
158  IStringStream lineStr(line);
159 
160  for (label columni = 0; columni < nColumns; ++columni)
161  {
162  lineStr >> values[columni][rowi];
163  }
164  }
165 
166  // Send to proci
167  UOPstream str(proci, pBufs);
168  str << values;
169  }
170  }
171  pBufs.finishedSends();
172 
173  // Read from PstreamBuffers
174  UIPstream str(Pstream::masterNo(), pBufs);
175  str >> data;
176 }
177 
178 
179 void Foam::functionObjects::externalCoupled::readLines
180 (
181  const label nRows,
182  autoPtr<IFstream>& masterFilePtr,
183  OStringStream& lines
184 ) const
185 {
186  // Get sizes for all processors
187  const globalIndex globalFaces(nRows);
188 
189  PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
190 
191  if (Pstream::master())
192  {
193  string line;
194 
195  // Read line from file and send to destination processor
196 
197  for (label proci = 0; proci < Pstream::nProcs(); ++proci)
198  {
199  // Number of rows to read for processor proci
200  const label procNRows = globalFaces.localSize(proci);
201 
202  UOPstream toProc(proci, pBufs);
203 
204  for (label rowi = 0; rowi < procNRows; ++rowi)
205  {
206  // Get a line
207  do
208  {
209  if (!masterFilePtr().good())
210  {
211  FatalIOErrorInFunction(masterFilePtr())
212  << "Trying to read data for processor " << proci
213  << " row " << rowi
214  << ". Does your file have as many rows as there are"
215  << " patch faces (" << globalFaces.size()
216  << ") ?" << exit(FatalIOError);
217  }
218 
219  masterFilePtr().getLine(line);
220  }
221  while (line.empty() || line[0] == '#');
222 
223  // Send line to the destination processor
224  toProc << line;
225  }
226  }
227  }
228 
229 
230  pBufs.finishedSends();
231 
232  // Read lines from PstreamBuffers
233  UIPstream str(Pstream::masterNo(), pBufs);
234  for (label rowi = 0; rowi < nRows; ++rowi)
235  {
236  string line(str);
237  lines << line.c_str() << nl;
238  }
239 }
240 
241 
243 (
245  const fileName& commsDir,
246  const wordRe& groupName
247 )
248 {
249  wordList regionNames(meshes.size());
250  forAll(meshes, i)
251  {
252  regionNames[i] = meshes[i].dbDir();
253  }
254 
255  // Make sure meshes are provided in sorted order
256  checkOrder(regionNames);
257 
258  fileName dir(groupDir(commsDir, compositeName(regionNames), groupName));
259 
260  autoPtr<OFstream> osPointsPtr;
261  autoPtr<OFstream> osFacesPtr;
262  if (Pstream::master())
263  {
264  mkDir(dir);
265  osPointsPtr.reset(new OFstream(dir/"patchPoints"));
266  osFacesPtr.reset(new OFstream(dir/"patchFaces"));
267 
268  osPointsPtr() << "// Group: " << groupName << endl;
269  osFacesPtr() << "// Group: " << groupName << endl;
270 
271  Info<< typeName << ": writing geometry to " << dir << endl;
272  }
273 
274  // Individual region/patch entries
275 
276  DynamicList<face> allFaces;
278 
279  labelList pointToGlobal;
280  labelList uniquePointIDs;
281  for (const fvMesh& mesh : meshes)
282  {
283  const labelList patchIDs
284  (
285  mesh.boundaryMesh().patchSet
286  (
287  List<wordRe>{groupName}
288  ).sortedToc()
289  );
290 
291  for (const label patchi : patchIDs)
292  {
293  const polyPatch& p = mesh.boundaryMesh()[patchi];
294 
295  mesh.globalData().mergePoints
296  (
297  p.meshPoints(),
298  p.meshPointMap(),
299  pointToGlobal,
300  uniquePointIDs
301  );
302 
303  label proci = Pstream::myProcNo();
304 
305  List<pointField> collectedPoints(Pstream::nProcs());
306  collectedPoints[proci] = pointField(mesh.points(), uniquePointIDs);
307  Pstream::gatherList(collectedPoints);
308 
309  List<faceList> collectedFaces(Pstream::nProcs());
310  faceList& patchFaces = collectedFaces[proci];
311  patchFaces = p.localFaces();
312  forAll(patchFaces, facei)
313  {
314  inplaceRenumber(pointToGlobal, patchFaces[facei]);
315  }
316  Pstream::gatherList(collectedFaces);
317 
318  if (Pstream::master())
319  {
320  allPoints.clear();
321  allFaces.clear();
322 
323  for (label proci=0; proci < Pstream::nProcs(); ++proci)
324  {
325  allPoints.append(collectedPoints[proci]);
326  allFaces.append(collectedFaces[proci]);
327  }
328 
329  Info<< typeName << ": mesh " << mesh.name()
330  << ", patch " << p.name()
331  << ": writing " << allPoints.size() << " points to "
332  << osPointsPtr().name() << nl
333  << typeName << ": mesh " << mesh.name()
334  << ", patch " << p.name()
335  << ": writing " << allFaces.size() << " faces to "
336  << osFacesPtr().name() << endl;
337 
338  // The entry name (region / patch)
339  const string entryHeader =
340  patchKey + ' ' + mesh.name() + ' ' + p.name();
341 
342  writeList(osPointsPtr(), entryHeader, allPoints);
343  writeList(osFacesPtr(), entryHeader, allFaces);
344  }
345  }
346  }
347 }
348 
349 
351 (
352  const wordList& regionNames
353 )
354 {
355  if (regionNames.size() == 0)
356  {
358  << "Empty regionNames" << abort(FatalError);
359  return word::null;
360  }
361  else if (regionNames.size() == 1)
362  {
363  if (regionNames[0] == polyMesh::defaultRegion)
364  {
365  // For compatibility with single region cases
366  // - suppress single region name
367  return word::null;
368  }
369  else
370  {
371  return regionNames[0];
372  }
373  }
374 
375  // Enforce lexical ordering
376  checkOrder(regionNames);
377 
378  word composite(regionNames[0]);
379  for (label i = 1; i < regionNames.size(); ++i)
380  {
381  composite += "_" + regionNames[i];
382  }
383 
384  return composite;
385 }
386 
387 
388 void Foam::functionObjects::externalCoupled::checkOrder
389 (
390  const wordList& regionNames
391 )
392 {
393  labelList order(sortedOrder(regionNames));
394  if (order != identity(regionNames.size()))
395  {
397  << "regionNames " << regionNames << " not in alphabetical order :"
398  << order << exit(FatalError);
399  }
400 }
401 
402 
403 void Foam::functionObjects::externalCoupled::initCoupling()
404 {
405  if (initialisedCoupling_)
406  {
407  return;
408  }
409 
410  // Write the geometry if not already there
411  forAll(regionGroupNames_, regioni)
412  {
413  const word& compName = regionGroupNames_[regioni];
414  const wordList& regionNames = regionGroupRegions_[regioni];
415 
416  // Get the meshes for the region-group
417  UPtrList<const fvMesh> meshes(regionNames.size());
418  forAll(regionNames, regi)
419  {
420  meshes.set(regi, time_.findObject<fvMesh>(regionNames[regi]));
421  }
422 
423  const labelList& groups = regionToGroups_[compName];
424 
425  for (const label groupi : groups)
426  {
427  const wordRe& groupName = groupNames_[groupi];
428 
429  bool geomExists = false;
430  if (Pstream::master())
431  {
432  fileName dir(groupDir(commDirectory(), compName, groupName));
433 
434  geomExists =
435  isFile(dir/"patchPoints")
436  || isFile(dir/"patchFaces");
437  }
438 
439  Pstream::scatter(geomExists);
440 
441  if (!geomExists)
442  {
443  writeGeometry(meshes, commDirectory(), groupName);
444  }
445  }
446  }
447 
448  if (slaveFirst())
449  {
450  // Wait for initial data to be made available
451  waitForSlave();
452 
453  // Read data passed back from external source
454  readDataMaster();
455  }
456 
457  initialisedCoupling_ = true;
458 }
459 
460 
461 void Foam::functionObjects::externalCoupled::performCoupling()
462 {
463  // Ensure coupling has been initialised
464  initCoupling();
465 
466  // Write data for external source
467  writeDataMaster();
468 
469  // Signal external source to execute (by removing lock file)
470  // - Wait for slave to provide data
471  useSlave();
472 
473  // Wait for response - and catch any abort information sent from slave
474  const auto action = waitForSlave();
475 
476  // Remove old data files from OpenFOAM
477  removeDataMaster();
478 
479  // Read data passed back from external source
480  readDataMaster();
481 
482  // Signal external source to wait (by creating the lock file)
483  useMaster();
484 
485  // Update information about last triggering
486  lastTrigger_ = time_.timeIndex();
487 
488  // Process any abort information sent from slave
489  if
490  (
491  action != time_.stopAt()
492  && action != Time::stopAtControls::saUnknown
493  )
494  {
495  Info<< type() << ": slave requested action "
496  << Time::stopAtControlNames[action] << endl;
497 
498  time_.stopAt(action);
499  }
500 }
501 
502 
503 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
504 
505 Foam::functionObjects::externalCoupled::externalCoupled
506 (
507  const word& name,
508  const Time& runTime,
509  const dictionary& dict
510 )
511 :
514  calcFrequency_(-1),
515  lastTrigger_(-1),
516  initialisedCoupling_(false)
517 {
518  read(dict);
519 
520  if (!slaveFirst())
521  {
522  useMaster();
523  }
524 }
525 
526 
527 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
528 
530 {
531  // Not initialized or overdue
532  if
533  (
534  !initialisedCoupling_
535  || (time_.timeIndex() >= lastTrigger_ + calcFrequency_)
536  )
537  {
538  performCoupling();
539  }
540 
541  return false;
542 }
543 
544 
546 {
547  performCoupling();
548 
549  return true;
550 }
551 
552 
554 {
556 
557  // Remove old data files
558  removeDataMaster();
559  removeDataSlave();
560  shutdown();
561 
562  return true;
563 }
564 
565 
567 {
570 
571  calcFrequency_ = dict.lookupOrDefault("calcFrequency", 1);
572 
573  // Leave trigger intact
574 
575  // Get names of all fvMeshes (and derived types)
576  wordList allRegionNames(time_.lookupClass<fvMesh>().sortedToc());
577 
578  const dictionary& allRegionsDict = dict.subDict("regions");
579  for (const entry& dEntry : allRegionsDict)
580  {
581  if (!dEntry.isDict())
582  {
583  FatalIOErrorInFunction(allRegionsDict)
584  << "Regions must be specified in dictionary format"
585  << exit(FatalIOError);
586  }
587 
588  const wordRe regionGroupName(dEntry.keyword());
589  const dictionary& regionDict = dEntry.dict();
590 
591  labelList regionIDs = findStrings(regionGroupName, allRegionNames);
592 
593  const wordList regionNames(allRegionNames, regionIDs);
594 
595  regionGroupNames_.append(compositeName(regionNames));
596  regionGroupRegions_.append(regionNames);
597 
598  for (const entry& dEntry : regionDict)
599  {
600  if (!dEntry.isDict())
601  {
602  FatalIOErrorInFunction(regionDict)
603  << "Regions must be specified in dictionary format"
604  << exit(FatalIOError);
605  }
606 
607  const wordRe groupName(dEntry.keyword());
608  const dictionary& groupDict = dEntry.dict();
609 
610  const label nGroups = groupNames_.size();
611  const wordList readFields(groupDict.get<wordList>("readFields"));
612  const wordList writeFields(groupDict.get<wordList>("writeFields"));
613 
614  auto fnd = regionToGroups_.find(regionGroupNames_.last());
615  if (fnd.found())
616  {
617  fnd().append(nGroups);
618  }
619  else
620  {
621  regionToGroups_.insert
622  (
623  regionGroupNames_.last(),
624  labelList(one(), nGroups)
625  );
626  }
627  groupNames_.append(groupName);
628  groupReadFields_.append(readFields);
629  groupWriteFields_.append(writeFields);
630  }
631  }
632 
633 
634  Info<< type() << ": Communicating with regions:" << endl;
635  for (const word& compName : regionGroupNames_)
636  {
637  Info<< "Region: " << compName << nl << incrIndent;
638  const labelList& groups = regionToGroups_[compName];
639  for (const label groupi : groups)
640  {
641  const wordRe& groupName = groupNames_[groupi];
642 
643  Info<< indent << "patchGroup: " << groupName << "\t"
644  << nl
645  << incrIndent
646  << indent << "Reading fields: "
647  << groupReadFields_[groupi]
648  << nl
649  << indent << "Writing fields: "
650  << groupWriteFields_[groupi]
651  << nl
652  << decrIndent;
653  }
654  Info<< decrIndent;
655  }
656  Info<< endl;
657 
658 
659  // Note: we should not have to make directories since the geometry
660  // should already be written - but just make sure
661  if (Pstream::master())
662  {
663  for (const word& compName : regionGroupNames_)
664  {
665  const labelList& groups = regionToGroups_[compName];
666  for (const label groupi : groups)
667  {
668  const wordRe& groupName = groupNames_[groupi];
669 
670  fileName dir(groupDir(commDirectory(), compName, groupName));
671 
672  if (!isDir(dir))
673  {
674  Log << type() << ": creating communications directory "
675  << dir << endl;
676  mkDir(dir);
677  }
678  }
679  }
680  }
681 
682  return true;
683 }
684 
685 
687 {
688  forAll(regionGroupNames_, regioni)
689  {
690  const word& compName = regionGroupNames_[regioni];
691  const wordList& regionNames = regionGroupRegions_[regioni];
692 
693  // Get the meshes for the region-group
694  UPtrList<const fvMesh> meshes(regionNames.size());
695  forAll(regionNames, regi)
696  {
697  meshes.set(regi, time_.findObject<fvMesh>(regionNames[regi]));
698  }
699 
700  const labelList& groups = regionToGroups_[compName];
701 
702  for (const label groupi : groups)
703  {
704  const wordRe& groupName = groupNames_[groupi];
705  const wordList& fieldNames = groupReadFields_[groupi];
706 
707  for (const word& fieldName : fieldNames)
708  {
709  const bool ok =
710  (
711  readData<scalar>(meshes, groupName, fieldName)
712  || readData<vector>(meshes, groupName, fieldName)
713  || readData<sphericalTensor>(meshes, groupName, fieldName)
714  || readData<symmTensor>(meshes, groupName, fieldName)
715  || readData<tensor>(meshes, groupName, fieldName)
716  );
717 
718  if (!ok)
719  {
721  << "Field " << fieldName << " in regions " << compName
722  << " was not found." << endl;
723  }
724  }
725  }
726  }
727 }
728 
729 
731 {
732  forAll(regionGroupNames_, regioni)
733  {
734  const word& compName = regionGroupNames_[regioni];
735  const wordList& regionNames = regionGroupRegions_[regioni];
736 
737  // Get the meshes for the region-group
738  UPtrList<const fvMesh> meshes(regionNames.size());
739  forAll(regionNames, regi)
740  {
741  meshes.set(regi, time_.findObject<fvMesh>(regionNames[regi]));
742  }
743 
744  const labelList& groups = regionToGroups_[compName];
745 
746  for (const label groupi : groups)
747  {
748  const wordRe& groupName = groupNames_[groupi];
749  const wordList& fieldNames = groupWriteFields_[groupi];
750 
751  for (const word& fieldName : fieldNames)
752  {
753  const bool ok =
754  (
755  writeData<scalar>(meshes, groupName, fieldName)
756  || writeData<vector>(meshes, groupName, fieldName)
757  || writeData<sphericalTensor>(meshes, groupName, fieldName)
758  || writeData<symmTensor>(meshes, groupName, fieldName)
759  || writeData<tensor>(meshes, groupName, fieldName)
760  );
761 
762  if (!ok)
763  {
765  << "Field " << fieldName << " in regions " << compName
766  << " was not found." << endl;
767  }
768  }
769  }
770  }
771 }
772 
773 
775 {
776  if (!Pstream::master())
777  {
778  return;
779  }
780 
781  Log << type() << ": removing data files written by master" << nl;
782 
783  for (const word& compName : regionGroupNames_)
784  {
785  const labelList& groups = regionToGroups_[compName];
786  for (const label groupi : groups)
787  {
788  const wordRe& groupName = groupNames_[groupi];
789  const wordList& fieldNames = groupReadFields_[groupi];
790 
791  for (const word& fieldName : fieldNames)
792  {
793  Foam::rm
794  (
795  groupDir(commDirectory(), compName, groupName)
796  / fieldName + ".out"
797  );
798  }
799  }
800  }
801 }
802 
803 
805 {
806  if (!Pstream::master())
807  {
808  return;
809  }
810 
811  Log << type() << ": removing data files written by slave" << nl;
812 
813  for (const word& compName : regionGroupNames_)
814  {
815  const labelList& groups = regionToGroups_[compName];
816  for (const label groupi : groups)
817  {
818  const wordRe& groupName = groupNames_[groupi];
819  const wordList& fieldNames = groupReadFields_[groupi];
820 
821  for (const word& fieldName : fieldNames)
822  {
823  Foam::rm
824  (
825  groupDir(commDirectory(), compName, groupName)
826  / fieldName + ".in"
827  );
828  }
829  }
830  }
831 }
832 
833 
835 {
836  return true;
837 }
838 
839 
840 // ************************************************************************* //
Foam::entry
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:67
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:74
volFields.H
Foam::functionObjects::externalCoupled::readDataMaster
virtual void readDataMaster()
Read data files (all regions, all fields) on master (OpenFOAM)
Definition: externalCoupled.C:686
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::autoPtr::reset
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
Definition: autoPtrI.H:158
L
const vector L(dict.get< vector >("L"))
OSspecific.H
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::UPstream::commsTypes::nonBlocking
Foam::UPstream::masterNo
static constexpr int masterNo() noexcept
Process index of the master.
Definition: UPstream.H:432
Foam::functionObjects::externalCoupled::read
virtual bool read(const dictionary &dict)
Read and set the function object if its data have changed.
Definition: externalCoupled.C:566
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::polyMesh::defaultRegion
static word defaultRegion
Return the default region name.
Definition: polyMesh.H:312
Foam::DynamicList
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:57
Foam::HashTableOps::values
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
Definition: HashOps.H:149
globalIndex.H
Foam::UPstream::nProcs
static label nProcs(const label communicator=0)
Number of processes in parallel run.
Definition: UPstream.H:426
Foam::read
bool read(const char *buf, int32_t &val)
Same as readInt32.
Definition: int32.H:108
Foam::VectorSpace::size
static constexpr direction size()
Return the number of elements in the VectorSpace = Ncmpts.
Definition: VectorSpaceI.H:92
Foam::functionObjects::timeFunctionObject
Virtual base class for function objects with a reference to Time.
Definition: timeFunctionObject.H:56
Foam::one
A class representing the concept of 1 (one), which can be used to avoid manipulating objects that are...
Definition: one.H:60
Foam::Pstream::scatter
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Distribute without modification. Reverse of gather.
Definition: gatherScatter.C:150
Foam::isFile
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: MSwindows.C:658
Foam::rm
bool rm(const fileName &file)
Remove a file (or its gz equivalent), returning true if successful.
Definition: MSwindows.C:994
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
Foam::string
A class for handling character strings derived from std::string.
Definition: string.H:73
Foam::incrIndent
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:314
Foam::wordRe
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition: wordRe.H:72
Foam::functionObjects::addToRunTimeSelectionTable
addToRunTimeSelectionTable(functionObject, add, dictionary)
externalCoupled.H
Foam::inplaceRenumber
void inplaceRenumber(const labelUList &oldToNew, IntListType &input)
Inplace renumber the values (not the indices) of a list.
Definition: ListOpsTemplates.C:61
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
Foam::DynamicField
Dynamically sized Field.
Definition: DynamicField.H:51
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:59
Foam::Time::stopAtControlNames
static const Enum< stopAtControls > stopAtControlNames
Names for stopAtControls.
Definition: Time.H:119
Foam::label
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:62
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::DynamicList::append
DynamicList< T, SizeMin > & append(const T &val)
Append an element to the end of this list.
Definition: DynamicListI.H:472
Foam::DynamicList::clear
void clear()
Clear the addressed list, i.e. set the size to zero.
Definition: DynamicListI.H:348
Foam::writeFields
void writeFields(const fvMesh &mesh, const wordHashSet &selectedFields)
Foam::UPtrList
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: UPtrList.H:63
meshes
PtrList< fvMesh > meshes(regionNames.size())
Foam::vtk::writeList
void writeList(vtk::formatter &fmt, const UList< uint8_t > &values)
Write a list of uint8_t values.
Definition: foamVtkOutput.C:112
Foam::functionObject::read
virtual bool read(const dictionary &dict)
Read and set the function object if its data have changed.
Definition: functionObject.C:137
Foam::functionObjects::externalCoupled::end
virtual bool end()
Called when Time::run() determines that the time-loop exits.
Definition: externalCoupled.C:553
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::functionObjects::externalCoupled::removeDataMaster
virtual void removeDataMaster() const
Remove data files written by master (OpenFOAM)
Definition: externalCoupled.C:774
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:84
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::externalCoupled::writeDataMaster
virtual void writeDataMaster() const
Write data files (all regions, all fields) from master (OpenFOAM)
Definition: externalCoupled.C:730
Foam::decrIndent
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:321
Foam::findStrings
labelList findStrings(const regExp &matcher, const UList< StringType > &input, const bool invert=false)
Return list indices for strings matching the regular expression.
Definition: stringListOps.H:75
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:137
Foam::indent
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:307
Foam::HashTable::sortedToc
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
Definition: HashTable.C:136
Foam::functionObjects::externalCoupled::patchKey
static string patchKey
Name of patch key, e.g. '// Patch:' when looking for start of patch data.
Definition: externalCoupled.H:326
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::functionObject::end
virtual bool end()
Called when Time::run() determines that the time-loop exits.
Definition: functionObject.C:154
Foam::OFstream
Output to file stream, using an OSstream.
Definition: OFstream.H:99
Foam::readFields
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const wordHashSet &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the templated type.
Definition: ReadFieldsTemplates.C:312
Foam::UPstream::myProcNo
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Definition: UPstream.H:444
Foam::UPstream::master
static bool master(const label communicator=0)
Am I the master process.
Definition: UPstream.H:438
Foam::functionObjects::defineTypeNameAndDebug
defineTypeNameAndDebug(fvMeshFunctionObject, 0)
Foam::functionObjects::externalCoupled::removeDataSlave
virtual void removeDataSlave() const
Remove data files written by slave (external code)
Definition: externalCoupled.C:804
Foam::functionObjects::externalCoupled::write
virtual bool write()
Write, currently a no-op.
Definition: externalCoupled.C:834
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::externalFileCoupler
Encapsulates the logic for coordinating between OpenFOAM and an external application.
Definition: externalFileCoupler.H:107
Foam::functionObjects::externalCoupled::execute
virtual bool execute()
Called at each ++ or += of the time-loop.
Definition: externalCoupled.C:529
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:355
Foam::Pstream::gatherList
static void gatherList(const List< commsStruct > &comms, List< T > &Values, const int tag, const label comm)
Gather data but keep individual values separate.
Definition: gatherScatterList.C:52
DynamicField.H
Foam::nl
constexpr char nl
Definition: Ostream.H:372
Fstream.H
Input/output from file streams.
Foam::List< word >
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::identity
labelList identity(const label len, label start=0)
Create identity map of the given length with (map[i] == i)
Definition: labelList.C:38
Foam::word::null
static const word null
An empty word.
Definition: word.H:77
Foam::functionObjects::readFields
Reads fields from the time directories and adds them to the mesh database for further post-processing...
Definition: readFields.H:108
Foam::token::END_LIST
End list [isseparator].
Definition: token.H:118
stringListOps.H
Operations on lists of strings.
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:375
Foam::externalFileCoupler::readDict
bool readDict(const dictionary &dict)
Read communication settings from dictionary.
Definition: externalFileCoupler.C:153
Foam::DelaunayMeshTools::allPoints
tmp< pointField > allPoints(const Triangulation &t)
Extract all points in vertex-index order.
Foam::sortedOrder
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
Foam::functionObjects::externalCoupled::writeGeometry
static void writeGeometry(const UPtrList< const fvMesh > &meshes, const fileName &commsDir, const wordRe &groupName)
Write geometry for the group as region/patch.
Definition: externalCoupled.C:243
Foam::token::BEGIN_LIST
Begin list [isseparator].
Definition: token.H:117
Foam::mkDir
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
Definition: MSwindows.C:507
Foam::functionObjects::externalCoupled::compositeName
static word compositeName(const wordList &)
Create single name by appending words (in sorted order),.
Definition: externalCoupled.C:351
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:294
Log
#define Log
Report write to Foam::Info if the local log switch is true.
Definition: messageStream.H:332
Foam::isDir
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
Definition: MSwindows.C:643