FreeFOAM The Cross-Platform CFD Toolkit
coordinateSystems.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
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 "coordinateSystems.H"
27 #include <OpenFOAM/IOPtrList.H>
28 #include <OpenFOAM/Time.H>
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34  defineTypeNameAndDebug(coordinateSystems, 0);
35  defineTemplateTypeNameAndDebug(IOPtrList<coordinateSystem>, 0);
36 }
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
40 Foam::coordinateSystems::coordinateSystems(const IOobject& io)
41 :
43 {}
44 
45 
46 Foam::coordinateSystems::coordinateSystems
47 (
48  const IOobject& io,
49  const PtrList<coordinateSystem>& lst
50 )
51 :
53 {}
54 
55 
56 Foam::coordinateSystems::coordinateSystems
57 (
58  const IOobject& io,
59  const Xfer<PtrList<coordinateSystem> >& lst
60 )
61 :
63 {}
64 
65 
66 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
67 
68 // Read construct from registry, or return previously registered
70 (
71  const objectRegistry& obr
72 )
73 {
74  if (obr.foundObject<coordinateSystems>(typeName))
75  {
76  return obr.lookupObject<coordinateSystems>(typeName);
77  }
78  else
79  {
80  return obr.store
81  (
83  (
84  IOobject
85  (
86  typeName,
87  "constant",
88  obr,
91  )
92  )
93  );
94  }
95 }
96 
97 
98 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
99 
100 Foam::label Foam::coordinateSystems::find(const word& keyword) const
101 {
102  forAll(*this, i)
103  {
104  if (keyword == operator[](i).name())
105  {
106  return i;
107  }
108  }
109 
110  return -1;
111 }
112 
113 
114 bool Foam::coordinateSystems::found(const word& keyword) const
115 {
116  return find(keyword) >= 0;
117 }
118 
119 
121 {
122  wordList keywords(size());
123 
124  forAll(*this, i)
125  {
126  keywords[i] = operator[](i).name();
127  }
128 
129  return keywords;
130 }
131 
132 
133 bool Foam::coordinateSystems::writeData(Ostream& os, bool subDict) const
134 {
135  os << nl << size() << nl << token::BEGIN_LIST;
136 
137  forAll(*this, i)
138  {
139  os << nl;
140  operator[](i).writeDict(os, subDict);
141  }
142 
143  os << token::END_LIST << nl;
144 
145  return os.good();
146 }
147 
148 
149 // ************************ vim: set sw=4 sts=4 et: ************************ //