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 
33 Foam::label Foam::sampledSurfaces::classifyFields()
34 {
35  label nFields = 0;
36 
37  if (loadFromFiles_)
38  {
39  // Check files for a particular time
40  IOobjectList objects(mesh_, mesh_.time().timeName());
41  wordList allFields = objects.sortedNames();
42 
43  forAll(fieldSelection_, i)
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 = mesh_.sortedNames();
63  labelList indices = findStrings(fieldSelection_, allFields);
64 
65  forAll(fieldSelection_, i)
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 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Definition: Time.C:715
Operations on lists of strings.
bool findStrings(const wordReListMatcher &matcher, const std::string &str)
Return true if string matches one of the regular expressions.
Definition: stringListOps.H:52
List< label > labelList
A List of labels.
Definition: labelList.H:56
List< word > wordList
A List of words.
Definition: fileName.H:54
wordList sortedNames() const
Return the sorted list of names of the IOobjects.
#define WarningInFunction
Report a warning using Foam::Warning.
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:243