forked from ZmengXu/conditionalAverage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconditionalAverageGrouping.C
149 lines (127 loc) · 4.29 KB
/
conditionalAverageGrouping.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "conditionalAverage.H"
#include "IOobjectList.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::conditionalAverage::clearFieldGroups()
{
scalarFields_.clear();
vectorFields_.clear();
sphericalTensorFields_.clear();
symmTensorFields_.clear();
tensorFields_.clear();
}
Foam::label Foam::conditionalAverage::appendFieldGroup
(
const word& fieldName,
const word& fieldType
)
{
if (fieldType == volScalarField::typeName)
{
scalarFields_.append(fieldName);
return 1;
}
else if (fieldType == volVectorField::typeName)
{
vectorFields_.append(fieldName);
return 1;
}
else if (fieldType == volSphericalTensorField::typeName)
{
sphericalTensorFields_.append(fieldName);
return 1;
}
else if (fieldType == volSymmTensorField::typeName)
{
symmTensorFields_.append(fieldName);
return 1;
}
else if (fieldType == volTensorField::typeName)
{
tensorFields_.append(fieldName);
return 1;
}
return 0;
}
Foam::label Foam::conditionalAverage::classifyFields()
{
label nFields = 0;
clearFieldGroups();
if (loadFromFiles_)
{
// Check files for a particular time
IOobjectList objects(fvMeshFunctionObject::mesh_, fvMeshFunctionObject::mesh_.time().timeName());
wordList allFields = objects.sortedNames();
forAll(fieldSelection_, i)
{
labelList indices = findStrings(fieldSelection_[i], allFields);
if (indices.size())
{
forAll(indices, fieldi)
{
const word& fieldName = allFields[indices[fieldi]];
nFields += appendFieldGroup
(
fieldName,
objects.find(fieldName)()->headerClassName()
);
}
}
else
{
WarningInFunction
<< "Cannot find field file matching "
<< fieldSelection_[i] << endl;
}
}
}
else
{
// Check currently available fields
wordList allFields = fvMeshFunctionObject::mesh_.sortedNames();
labelList indices = findStrings(fieldSelection_, allFields);
forAll(fieldSelection_, i)
{
labelList indices = findStrings(fieldSelection_[i], allFields);
if (indices.size())
{
forAll(indices, fieldi)
{
const word& fieldName = allFields[indices[fieldi]];
nFields += appendFieldGroup
(
fieldName,
fvMeshFunctionObject::mesh_.find(fieldName)()->type()
);
}
}
else
{
WarningInFunction
<< "Cannot find registered field matching "
<< fieldSelection_[i] << endl;
}
}
}
return nFields;
}
// ************************************************************************* //