FreeFOAM The Cross-Platform CFD Toolkit
coordinateSystemNew.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 "coordinateSystem.H"
27 #include <OpenFOAM/dictionary.H>
28 
29 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
30 
32 (
33  const word& name,
34  const dictionary& dict
35 )
36 {
37  if (debug)
38  {
39  Pout<< "coordinateSystem::New(const word&, const dictionary&) : "
40  << "constructing coordinateSystem"
41  << endl;
42  }
43 
44  // construct base class directly, also allow 'cartesian' as an alias
45  word coordType(typeName_());
46  if
47  (
48  !dict.readIfPresent("type", coordType)
49  || coordType == typeName_()
50  || coordType == "cartesian"
51  )
52  {
53  return autoPtr<coordinateSystem>(new coordinateSystem(name, dict));
54  }
55 
56  dictionaryConstructorTable::iterator cstrIter =
57  dictionaryConstructorTablePtr_->find(coordType);
58 
59  if (cstrIter == dictionaryConstructorTablePtr_->end())
60  {
62  (
63  "coordinateSystem::New(const word&, const dictionary&)",
64  dict
65  ) << "Unknown coordinateSystem type " << coordType << nl << nl
66  << "Valid coordinateSystem types are :" << nl
67  << "[default: " << typeName_() << "]"
68  << dictionaryConstructorTablePtr_->sortedToc()
69  << exit(FatalIOError);
70  }
71 
72  return autoPtr<coordinateSystem>(cstrIter()(name, dict));
73 }
74 
75 
77 (
78  const word& coordType,
79  const word& name,
80  const point& origin,
81  const coordinateRotation& cr
82 )
83 {
84  if (debug)
85  {
86  Pout<< "coordinateSystem::New(const word&, const word&, "
87  << "const point&, const coordinateRotation&) : "
88  "constructing coordinateSystem"
89  << endl;
90  }
91 
92  origRotationConstructorTable::iterator cstrIter =
93  origRotationConstructorTablePtr_->find(coordType);
94 
95  if (cstrIter == origRotationConstructorTablePtr_->end())
96  {
98  (
99  "coordinateSystem::New(const word&, const word&, "
100  "const point&, const coordinateRotation&) : "
101  "constructing coordinateSystem"
102  ) << "Unknown coordinateSystem type " << coordType << nl << nl
103  << "Valid coordinateSystem types are :" << nl
104  << origRotationConstructorTablePtr_->sortedToc()
105  << exit(FatalError);
106  }
107 
108  return autoPtr<coordinateSystem>(cstrIter()(name, origin, cr));
109 }
110 
111 
113 (
114  Istream& is
115 )
116 {
117  word name(is);
118  dictionary dict(is);
119 
120  return New(name, dict);
121 }
122 
123 // ************************ vim: set sw=4 sts=4 et: ************************ //