initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / meshTools / coordinateSystems / coordinateSystems.C
blobeb54637951898c55f7e80b33526b1a340d02132c
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     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, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "coordinateSystems.H"
28 #include "IOPtrList.H"
29 #include "Time.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 namespace Foam
35     defineTypeNameAndDebug(coordinateSystems, 0);
36     defineTemplateTypeNameAndDebug(IOPtrList<coordinateSystem>, 0);
39 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
41 Foam::coordinateSystems::coordinateSystems(const IOobject& io)
43     IOPtrList<coordinateSystem>(io)
47 Foam::coordinateSystems::coordinateSystems
49     const IOobject& io,
50     const PtrList<coordinateSystem>& lst
53     IOPtrList<coordinateSystem>(io, lst)
57 Foam::coordinateSystems::coordinateSystems
59     const IOobject& io,
60     const Xfer<PtrList<coordinateSystem> >& lst
63     IOPtrList<coordinateSystem>(io, lst)
67 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
69 // Read construct from registry, or return previously registered
70 const Foam::coordinateSystems& Foam::coordinateSystems::New
72     const objectRegistry& obr
75     if (obr.foundObject<coordinateSystems>(typeName))
76     {
77         return obr.lookupObject<coordinateSystems>(typeName);
78     }
79     else
80     {
81         return obr.store
82         (
83             new coordinateSystems
84             (
85                 IOobject
86                 (
87                     typeName,
88                     "constant",
89                     obr,
90                     IOobject::READ_IF_PRESENT,
91                     IOobject::NO_WRITE
92                 )
93             )
94         );
95     }
99 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
101 Foam::label Foam::coordinateSystems::find(const word& keyword) const
103     forAll(*this, i)
104     {
105         if (keyword == operator[](i).name())
106         {
107             return i;
108         }
109     }
111     return -1;
115 bool Foam::coordinateSystems::found(const word& keyword) const
117     return find(keyword) >= 0;
121 Foam::wordList Foam::coordinateSystems::toc() const
123     wordList keywords(size());
125     forAll(*this, i)
126     {
127         keywords[i] = operator[](i).name();
128     }
130     return keywords;
134 bool Foam::coordinateSystems::writeData(Ostream& os, bool subDict) const
136     os << nl << size() << nl << token::BEGIN_LIST;
138     forAll(*this, i)
139     {
140         os << nl;
141         operator[](i).writeDict(os, subDict);
142     }
144     os << token::END_LIST << nl;
146     return os.good();
150 // ************************************************************************* //