findCloudFields.H
Go to the documentation of this file.
1 // check all time directories for the following:
2 
3 // The fields for each cloud:
4 HashTable<HashTable<word>> cloudFields;
5 
6 // Identify if lagrangian data exist at any time step.
7 if (timeDirs.size() && doLagrangian)
8 {
9  const fileName& baseDir = mesh.time().path();
10  const fileName cloudPrefix(regionPrefix/cloud::prefix);
11 
12  Info<< "Searching for lagrangian ... " << flush;
13 
14  for (const instant& inst : timeDirs)
15  {
16  const word& timeName = inst.name();
17 
18  // DO NOT USE -->> runTime.setTime(timeDirs[timeI], timeI); <<--
19  // It incurs a large overhead when done so frequently.
20 
21  fileNameList cloudDirs
22  (
23  readDir
24  (
25  baseDir/timeName/cloudPrefix,
26  fileName::DIRECTORY
27  )
28  );
29 
30  for (fileName& cloudDir : cloudDirs)
31  {
32  const word cloudName(std::move(cloudDir));
33 
34  IOobjectList cloudObjs
35  (
36  mesh,
37  timeName,
38  cloudPrefix/cloudName
39  );
40 
41  // Clouds require "coordinates".
42  // The "positions" are for v1706 and lower.
43  // - detect and remove since these are treated specially
44 
45  bool isCloud = false;
46  if (cloudObjs.erase("coordinates"))
47  {
48  isCloud = true;
49  }
50  if (cloudObjs.erase("positions"))
51  {
52  isCloud = true;
53  }
54 
55  if (isCloud)
56  {
57  // Save the cloud fields on a per cloud basis
58  auto& fieldsPerCloud = cloudFields(cloudName);
59 
60  forAllConstIters(cloudObjs, fieldIter)
61  {
62  const IOobject* io = *fieldIter;
63 
64  // Field name/type
65  fieldsPerCloud.insert(io->name(), io->headerClassName());
66  }
67  }
68  }
69  }
70 
71  if (Pstream::parRun())
72  {
73  Pstream::mapCombineGather(cloudFields, HashTableOps::plusEqOp<word>());
74  Pstream::mapCombineScatter(cloudFields);
75  }
76 
77  if (cloudFields.empty())
78  {
79  Info<< "none detected." << endl;
80  }
81 }
82 
83 
84 // Sorted list of cloud names
85 const wordList cloudNames(cloudFields.sortedToc());
86 
87 if (cloudNames.size())
88 {
89  // Complete the echo information - as flatOutput
90  cloudNames.writeList(Info) << endl;
91 }
92 
93 
94 // ************************************************************************* //
cloudName
const word cloudName(propsDict.get< word >("cloud"))
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:59
Foam::flush
Ostream & flush(Ostream &os)
Flush stream.
Definition: Ostream.H:342
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
timeName
word timeName
Definition: getTimeIndex.H:3
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
cloudNames
const wordList cloudNames(cloudFields.sortedToc())
Foam::fileNameList
List< fileName > fileNameList
A List of fileNames.
Definition: fileNameList.H:58
forAllConstIters
forAllConstIters(mixture.phases(), phase)
Definition: pEqn.H:28
Foam::readDir
fileNameList readDir(const fileName &directory, const fileName::Type type=fileName::FILE, const bool filtergz=true, const bool followLink=true)
Read a directory and return the entries as a fileName List.
Definition: MSwindows.C:707
cloudFields
HashTable< HashTable< word > > cloudFields
Definition: findCloudFields.H:4