OpenFOAM
v2512
The open source CFD toolbox
Loading...
Searching...
No Matches
findCloudFields.H
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) 2018-2022 OpenCFD Ltd.
9
-------------------------------------------------------------------------------
10
License
11
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
12
13
Description
14
Check time directories for lagrangian data.
15
16
\*---------------------------------------------------------------------------*/
17
18
// The fields for each cloud:
19
List<HashTable<HashTable<word>>>
regionCloudFields
(
meshes
.size());
20
21
// Identify if lagrangian data exist at any time step.
22
if
(timeDirs.size() && doLagrangian)
23
{
24
Info<<
"Search for lagrangian ... "
<< flush;
25
26
forAll
(
meshes
, regioni)
27
{
28
const
fvMesh&
mesh
=
meshes
[regioni];
29
auto
& cloudFields =
regionCloudFields
[regioni];
30
31
const
word&
regionName
=
regionNames
[regioni];
32
33
const
fileName cloudPrefix
34
(
35
polyMesh::regionName(
regionName
)/cloud::prefix
36
);
37
38
for
(
const
instant& inst : timeDirs)
39
{
40
const
word&
timeName
= inst.name();
41
42
// DO NOT USE -->> runTime.setTime(timeDirs[timeI], timeI); <<--
43
// It incurs a large overhead when done so frequently.
44
45
fileNameList cloudDirs
46
(
47
readDir
48
(
49
mesh
.time().path()/
timeName
/cloudPrefix,
50
fileName::DIRECTORY
51
)
52
);
53
54
for
(fileName& cloudDir : cloudDirs)
55
{
56
const
word
cloudName
(std::move(cloudDir));
57
58
IOobjectList cloudObjs
59
(
60
mesh
,
61
timeName
,
62
cloudPrefix/
cloudName
63
);
64
65
// Clouds require "coordinates".
66
// The "positions" are for v1706 and lower.
67
// - detect and remove since these are treated specially
68
69
bool
isCloud =
false
;
70
if
(cloudObjs.erase(
"coordinates"
))
71
{
72
isCloud =
true
;
73
}
74
if
(cloudObjs.erase(
"positions"
))
75
{
76
isCloud =
true
;
77
}
78
79
if
(isCloud)
80
{
81
// Save the cloud fields on a per cloud basis
82
auto
& fieldsPerCloud = cloudFields(
cloudName
);
83
84
forAllConstIters
(cloudObjs, fieldIter)
85
{
86
const
IOobject*
io
= *fieldIter;
87
88
// Field name/type
89
fieldsPerCloud.insert
90
(
91
io
->name(),
92
io
->headerClassName()
93
);
94
}
95
}
96
}
97
}
98
}
99
100
if
(Pstream::parRun())
101
{
102
for
(
auto
& cloudFields :
regionCloudFields
)
103
{
104
Pstream::mapCombineReduce
105
(
106
cloudFields,
107
HashTableOps::plusEqOp<word>()
108
);
109
}
110
}
111
}
112
113
// Sorted list of cloud names
114
List<wordList>
regionCloudNames
(
meshes
.size());
115
116
{
117
wordHashSet allRegionClouds;
118
119
forAll
(
regionCloudNames
, regioni)
120
{
121
regionCloudNames
[regioni] =
regionCloudFields
[regioni].sortedToc();
122
123
allRegionClouds.insert(
regionCloudNames
[regioni]);
124
}
125
126
const
wordList
allCloudNames
(allRegionClouds.sortedToc());
127
128
if
(allRegionClouds.empty())
129
{
130
Info<<
"none detected."
<< endl;
131
}
132
else
133
{
134
// Complete the echo information - as flatOutput
135
allRegionClouds.writeList(Info) << endl;
136
}
137
}
138
139
140
// ************************************************************************* //
cloudName
const word cloudName(propsDict.get< word >("cloud"))
mesh
dynamicFvMesh & mesh
Definition
createDynamicFvMesh.H:6
regionName
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
meshes
Foam::PtrList< Foam::fvMesh > meshes(regionNames.size())
allCloudNames
const wordList allCloudNames(allRegionClouds.sortedToc())
regionCloudNames
List< wordList > regionCloudNames(meshes.size())
regionCloudFields
List< HashTable< HashTable< word > > > regionCloudFields(meshes.size())
io
const auto & io
Definition
findMeshDefinitionDict.H:139
regionNames
wordList regionNames
Definition
getAllRegionOptions.H:33
timeName
word timeName
Definition
getTimeIndex.H:3
Foam::wordList
List< word > wordList
List of word.
Definition
fileName.H:60
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition
stdFoam.H:299
forAllConstIters
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
Definition
stdFoam.H:235
applications
utilities
postProcessing
dataConversion
foamToEnsight
findCloudFields.H
Generated by
1.16.1