Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / sampling / probes / probesGrouping.C
blob7c94051834a42d1b06cf35fe9751826b90ba7c4d
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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.
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.
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "probes.H"
27 #include "volFields.H"
28 #include "IOobjectList.H"
29 #include "stringListOps.H"
31 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
33 void Foam::probes::clearFieldGroups()
35     scalarFields_.clear();
36     vectorFields_.clear();
37     sphericalTensorFields_.clear();
38     symmTensorFields_.clear();
39     tensorFields_.clear();
43 Foam::label Foam::probes::appendFieldGroup
45     const word& fieldName,
46     const word& fieldType
49     if (fieldType == volScalarField::typeName)
50     {
51         scalarFields_.append(fieldName);
52         return 1;
53     }
54     else if (fieldType == volVectorField::typeName)
55     {
56         vectorFields_.append(fieldName);
57         return 1;
58     }
59     else if (fieldType == volSphericalTensorField::typeName)
60     {
61         sphericalTensorFields_.append(fieldName);
62         return 1;
63     }
64     else if (fieldType == volSymmTensorField::typeName)
65     {
66         symmTensorFields_.append(fieldName);
67         return 1;
68     }
69     else if (fieldType == volTensorField::typeName)
70     {
71         tensorFields_.append(fieldName);
72         return 1;
73     }
75     return 0;
79 Foam::label Foam::probes::classifyFields()
81     label nFields = 0;
82     clearFieldGroups();
84     if (loadFromFiles_)
85     {
86         // check files for a particular time
87         IOobjectList objects(mesh_, mesh_.time().timeName());
88         wordList allFields = objects.sortedNames();
90         labelList indices = findStrings(fieldSelection_, allFields);
92         forAll(indices, fieldI)
93         {
94             const word& fieldName = allFields[indices[fieldI]];
96             nFields += appendFieldGroup
97             (
98                 fieldName,
99                 objects.find(fieldName)()->headerClassName()
100             );
101         }
102     }
103     else
104     {
105         // check currently available fields
106         wordList allFields = mesh_.sortedNames();
107         labelList indices = findStrings(fieldSelection_, allFields);
109         forAll(indices, fieldI)
110         {
111             const word& fieldName = allFields[indices[fieldI]];
113             nFields += appendFieldGroup
114             (
115                 fieldName,
116                 mesh_.find(fieldName)()->type()
117             );
118         }
119     }
121     return nFields;
124 // ************************************************************************* //