1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 defineTemplateTypeNameAndDebug(IOPtrList<coordinateSystem>, 0);
37 const Foam::word Foam::coordinateSystems::dataType("coordinateSystem");
39 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 Foam::coordinateSystems::coordinateSystems()
45 Foam::coordinateSystems::coordinateSystems
47 const objectRegistry& registry,
49 const fileName& instance
52 IOPtrList<coordinateSystem> newList
59 IOobject::READ_IF_PRESENT,
61 false // don't register
69 Foam::coordinateSystems::coordinateSystems
74 IOPtrList<coordinateSystem> newList(io);
79 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
82 Foam::label Foam::coordinateSystems::find(const word& keyword) const
86 if (keyword == operator[](i).name())
96 bool Foam::coordinateSystems::found(const word& keyword) const
98 return find(keyword) >= 0;
102 Foam::wordList Foam::coordinateSystems::toc() const
104 wordList keywords(size());
108 keywords[i] = operator[](i).name();
115 bool Foam::coordinateSystems::rewriteDict(dictionary& dict, bool noType) const
117 if (dict.found(dataType) && !dict.isDict(dataType))
119 word name(dict.lookup(dataType));
120 label i = find(name);
124 dict.remove(dataType);
125 dict.add(dataType, operator[](i).dict(noType));
131 "Foam::coordinateSystems::rewriteDict(dictionary&, bool) const"
132 ) << "could not rewrite " << dataType << " " << name << nl
133 << "available coordinate systems: " << toc() << nl << nl
143 bool Foam::coordinateSystems::writeData(Ostream& os, bool subDict) const
145 // Write size of list
148 // Write beginning of contents
149 os << nl << token::BEGIN_LIST;
151 // Write list contents
155 operator[](i).writeDict(os, subDict);
158 // Write end of contents
159 os << token::END_LIST << nl;
161 // Check state of IOstream
166 // ************************************************************************* //