sampledSurfacesGrouping.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 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 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 Foam::label Foam::sampledSurfaces::classifyFields()
31 {
32  label nFields = 0;
33 
34  if (loadFromFiles_)
35  {
36  // Check files for a particular time
37  IOobjectList objects(mesh_, mesh_.time().timeName());
38  wordList allFields = objects.sortedNames();
39 
40  forAll(fieldSelection_, i)
41  {
42  labelList indices = findStrings(fieldSelection_[i], allFields);
43 
44  if (indices.size())
45  {
46  nFields += indices.size();
47  }
48  else
49  {
51  << "Cannot find field file matching "
52  << fieldSelection_[i] << endl;
53  }
54  }
55  }
56  else
57  {
58  // Check currently available fields
59  wordList allFields = mesh_.sortedNames();
60  labelList indices = findStrings(fieldSelection_, allFields);
61 
62  forAll(fieldSelection_, i)
63  {
64  labelList indices = findStrings(fieldSelection_[i], allFields);
65 
66  if (indices.size())
67  {
68  nFields += indices.size();
69  }
70  else
71  {
73  << "Cannot find registered field matching "
74  << fieldSelection_[i] << endl;
75  }
76  }
77  }
78 
79  return nFields;
80 }
81 
82 
83 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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:251
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Definition: Time.C:622
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:239
bool findStrings(const wordReListMatcher &matcher, const std::string &str)
Return true if string matches one of the regular expressions.
Definition: stringListOps.H:52
wordList sortedNames() const
Return the sorted list of names of the IOobjects.
List< label > labelList
A List of labels.
Definition: labelList.H:56
objects
List< word > wordList
A List of words.
Definition: fileName.H:54
#define WarningInFunction
Report a warning using Foam::Warning.