initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / meshTools / coordinateSystems / newCoordinateSystem.C
blob5c2570a6e22955a0a9f79869e4447111ed69140c
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 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 "coordinateSystem.H"
28 #include "dictionary.H"
30 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
32 Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
34     const word& coordType,
35     const word& name,
36     const point& origin,
37     const vector& axis,
38     const vector& dir
41     if (debug)
42     {
43         Pout<< "coordinateSystem::New(const word&, const word&, "
44             << "const vector&, const vector&, const vector&) : "
45                "constructing coordinateSystem"
46             << endl;
47     }
49     origAxisDirConstructorTable::iterator cstrIter =
50         origAxisDirConstructorTablePtr_->find(coordType);
52     if (cstrIter == origAxisDirConstructorTablePtr_->end())
53     {
54         FatalErrorIn
55         (
56             "coordinateSystem::New(const word&, const word&, "
57             "const vector&, const vector&, const vector&) : "
58             "constructing coordinateSystem"
59         )   << "Unknown coordinateSystem type " << coordType << nl << nl
60             << "Valid coordinateSystem types are :" << nl
61             << origAxisDirConstructorTablePtr_->toc()
62             << exit(FatalError);
63     }
65     return autoPtr<coordinateSystem>(cstrIter()(name, origin, axis, dir));
69 Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
71     const word& coordType,
72     const word& name,
73     const point& origin,
74     const coordinateRotation& cr
77     if (debug)
78     {
79         Pout<< "coordinateSystem::New(const word&, const word&, "
80             << "const vector&, const coordinateRotation&) : "
81                "constructing coordinateSystem"
82             << endl;
83     }
85     origRotationConstructorTable::iterator cstrIter =
86         origRotationConstructorTablePtr_->find(coordType);
88     if (cstrIter == origRotationConstructorTablePtr_->end())
89     {
90         FatalErrorIn
91         (
92             "coordinateSystem::New(const word&, const word&, "
93             "const vector&, const coordinateRotation&) : "
94             "constructing coordinateSystem"
95         )   << "Unknown coordinateSystem type " << coordType << nl << nl
96             << "Valid coordinateSystem types are :" << nl
97             << origRotationConstructorTablePtr_->toc()
98             << exit(FatalError);
99     }
101     return autoPtr<coordinateSystem>(cstrIter()(name, origin, cr));
105 Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
107     const word& name,
108     const dictionary& dict
111     if (debug)
112     {
113         Pout<< "coordinateSystem::New(const word&, const dictionary&) : "
114             << "constructing coordinateSystem"
115             << endl;
116     }
118     // default type is self
119     word coordType(typeName_());
120     if (dict.found("type"))
121     {
122         dict.lookup("type") >> coordType;
123     }
125     // can (must) construct base class directly
126     if (coordType == typeName_())
127     {
128         return autoPtr<coordinateSystem>(new coordinateSystem(name, dict));
129     }
131     dictionaryConstructorTable::iterator cstrIter =
132         dictionaryConstructorTablePtr_->find(coordType);
134     if (cstrIter == dictionaryConstructorTablePtr_->end())
135     {
136         FatalIOErrorIn
137         (
138             "coordinateSystem::New(const word&, const dictionary&)",
139             dict
140         )   << "Unknown coordinateSystem type " << coordType << nl << nl
141             << "Valid coordinateSystem types are :" << nl
142             << "[default: " << typeName_() << "]"
143             << dictionaryConstructorTablePtr_->toc()
144             << exit(FatalIOError);
145     }
147     return autoPtr<coordinateSystem>(cstrIter()(name, dict));
151 Foam::autoPtr<Foam::coordinateSystem> Foam::coordinateSystem::New
153     Istream& is
156     word name(is);
157     dictionary dict(is);
159     return New(name, dict);
162 // ************************************************************************* //