sampledSurfacesGrouping.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 | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "sampledSurfaces.H"
27 #include "volFields.H"
28 #include "IOobjectList.H"
29 #include "stringListOps.H"
30 
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 
34 {
35  label nFields = 0;
36 
37  if (loadFromFiles_)
38  {
39  // Check files for a particular time
40  IOobjectList objects(obr_, obr_.time().timeName());
41  wordList allFields = objects.sortedNames();
42 
44  {
45  labelList indices = findStrings(fieldSelection_[i], allFields);
46 
47  if (indices.size())
48  {
49  nFields += indices.size();
50  }
51  else
52  {
54  << "Cannot find field file matching "
55  << fieldSelection_[i] << endl;
56  }
57  }
58  }
59  else
60  {
61  // Check currently available fields
62  wordList allFields = obr_.sortedNames();
63  labelList indices = findStrings(fieldSelection_, allFields);
64 
66  {
67  labelList indices = findStrings(fieldSelection_[i], allFields);
68 
69  if (indices.size())
70  {
71  nFields += indices.size();
72  }
73  else
74  {
76  << "Cannot find registered field matching "
77  << fieldSelection_[i] << endl;
78  }
79  }
80  }
81 
82  return nFields;
83 }
84 
85 
86 // ************************************************************************* //
volFields.H
Foam::objectRegistry::sortedNames
wordList sortedNames() const
Return the sorted list of names of the IOobjects.
Definition: objectRegistry.C:121
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::sampledSurfaces::obr_
const objectRegistry & obr_
Const reference to database.
Definition: sampledSurfaces.H:97
Foam::objectRegistry::time
const Time & time() const
Return time.
Definition: objectRegistry.H:117
Foam::IOobjectList::sortedNames
wordList sortedNames() const
Return the sorted list of names of the IOobjects.
Definition: IOobjectList.C:227
IOobjectList.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
sampledSurfaces.H
Foam::sampledSurfaces::classifyFields
label classifyFields()
Return number of fields.
Definition: sampledSurfacesGrouping.C:33
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:59
Foam::IOobjectList
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:50
Foam::findStrings
bool findStrings(const wordReListMatcher &matcher, const std::string &str)
Return true if string matches one of the regular expressions.
Definition: stringListOps.H:52
Foam::sampledSurfaces::loadFromFiles_
const bool loadFromFiles_
Load fields from files (not from objectRegistry)
Definition: sampledSurfaces.H:100
Foam::Time::timeName
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Definition: Time.C:741
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
stringListOps.H
Operations on lists of strings.
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:259
Foam::sampledSurfaces::fieldSelection_
wordReList fieldSelection_
Names of fields to sample.
Definition: sampledSurfaces.H:109