OpenFOAM: API Guide
v2112
The open source CFD toolbox
sampledSetsGrouping.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) 2011-2016 OpenFOAM Foundation
9
Copyright (C) 2017 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
29
#include "
sampledSets.H
"
30
#include "
volFields.H
"
31
#include "
IOobjectList.H
"
32
#include "
UIndirectList.H
"
33
#include "
ListOps.H
"
34
35
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
36
37
void
Foam::sampledSets::clearFieldGroups()
38
{
39
scalarFields_.clear();
40
vectorFields_.clear();
41
sphericalTensorFields_.clear();
42
symmTensorFields_.clear();
43
tensorFields_.clear();
44
}
45
46
47
Foam::label Foam::sampledSets::classifyFields()
48
{
49
label nFields = 0;
50
clearFieldGroups();
51
52
wordList
allFields;
// Just needed for warnings
53
HashTable<wordHashSet> available;
54
55
if
(loadFromFiles_)
56
{
57
// Check files for a particular time
58
IOobjectList objects(mesh_, mesh_.time().timeName());
59
60
allFields = objects.names();
61
available = objects.classes(fieldSelection_);
62
}
63
else
64
{
65
// Check currently available fields
66
allFields = mesh_.names();
67
available = mesh_.classes(fieldSelection_);
68
}
69
70
DynamicList<label> missed(fieldSelection_.size());
71
72
// Detect missing fields
73
forAll
(fieldSelection_, i)
74
{
75
if
(!
ListOps::found
(allFields, fieldSelection_[i]))
76
{
77
missed.append(i);
78
}
79
}
80
81
if
(missed.size())
82
{
83
WarningInFunction
84
<<
nl
85
<<
"Cannot find "
86
<< (loadFromFiles_ ?
"field file"
:
"registered field"
)
87
<<
" matching "
88
<< UIndirectList<wordRe>(fieldSelection_, missed) <<
endl
;
89
}
90
91
forAllConstIters
(available, iter)
92
{
93
const
word& fieldType = iter.key();
94
const
wordList
fieldNames
= iter.val().sortedToc();
95
96
const
label
count
=
fieldNames
.size();
// pre-filtered, so non-empty
97
98
if
(fieldType == volScalarField::typeName)
99
{
100
scalarFields_.
append
(
fieldNames
);
101
nFields +=
count
;
102
}
103
else
if
(fieldType == volVectorField::typeName)
104
{
105
vectorFields_.append(
fieldNames
);
106
nFields +=
count
;
107
}
108
else
if
(fieldType == volSphericalTensorField::typeName)
109
{
110
sphericalTensorFields_.append(
fieldNames
);
111
nFields +=
count
;
112
}
113
else
if
(fieldType == volSymmTensorField::typeName)
114
{
115
symmTensorFields_.append(
fieldNames
);
116
nFields +=
count
;
117
}
118
else
if
(fieldType == volTensorField::typeName)
119
{
120
tensorFields_.append(
fieldNames
);
121
nFields +=
count
;
122
}
123
}
124
125
return
nFields;
126
}
127
128
129
// ************************************************************************* //
volFields.H
UIndirectList.H
Foam::List::append
void append(const T &val)
Append an element at the end of the list.
Definition:
ListI.H:175
IOobjectList.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition:
Ostream.H:369
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition:
stdFoam.H:296
sampledSets.H
Foam::wordList
List< word > wordList
A List of words.
Definition:
fileName.H:62
fieldNames
const wordRes fieldNames(propsDict.getOrDefault< wordRes >("fields", wordRes()))
Foam::nl
constexpr char nl
Definition:
Ostream.H:404
forAllConstIters
forAllConstIters(mixture.phases(), phase)
Definition:
pEqn.H:28
Foam::BitOps::count
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Definition:
BitOps.H:77
Foam::ListOps::found
bool found(const ListType &input, const UnaryPredicate &pred, const label start=0)
True if there is a value in the list that satisfies the predicate.
Definition:
ListOpsTemplates.C:1156
ListOps.H
Various functions to operate on Lists.
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition:
messageStream.H:328
src
sampling
sampledSet
sampledSets
sampledSetsGrouping.C
Generated by
1.8.17
OPENFOAM® is a registered
trademark
of OpenCFD Ltd.