Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / sampling / sampledSurface / sampledSurfaces / sampledSurfacesGrouping.C
blob744a26e5429e7fa57bbc4563e8351f95dafe94bf
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 "sampledSurfaces.H"
27 #include "volFields.H"
28 #include "IOobjectList.H"
29 #include "stringListOps.H"
31 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
33 void Foam::sampledSurfaces::clearFieldGroups()
35     scalarFields_.clear();
36     vectorFields_.clear();
37     sphericalTensorFields_.clear();
38     symmTensorFields_.clear();
39     tensorFields_.clear();
43 Foam::label Foam::sampledSurfaces::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::sampledSurfaces::classifyFields()
81     label nFields = 0;
82     clearFieldGroups();
84     // check files for a particular time
85     if (loadFromFiles_)
86     {
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         wordList allFields = mesh_.sortedNames();
106         labelList indices = findStrings(fieldSelection_, allFields);
108         forAll(indices, fieldI)
109         {
110             const word& fieldName = allFields[indices[fieldI]];
112             nFields += appendFieldGroup
113             (
114                 fieldName,
115                 mesh_.find(fieldName)()->type()
116             );
117         }
118     }
120     return nFields;
124 // ************************************************************************* //