coordinateSystemNew.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
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 
28 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
29 
31 (
32  const objectRegistry& obr,
33  const dictionary& dict
34 )
35 {
36  const entry* entryPtr = dict.lookupEntryPtr(typeName_(), false, false);
37 
38  // Non-dictionary entry is a lookup into global coordinateSystems
39  if (entryPtr && !entryPtr->isDict())
40  {
41  const word name(entryPtr->stream());
42 
45 
46  if (css.PtrDictionary<coordinateSystem>::found(name))
47  {
48  if (debug)
49  {
51  << "Using global coordinate system: " << name << endl;
52  }
53 
54  return css[name].clone();
55  }
56  else
57  {
59  << "could not find coordinate system: " << name << nl
60  << "available coordinate systems: " << css.toc() << nl << nl
61  << exit(FatalError);
62 
63  return autoPtr<coordinateSystem>(nullptr);
64  }
65  }
66  else
67  {
68  const dictionary& coordDict = dict.subDict(typeName_());
69  const word coordType = coordDict.lookup("type");
70 
71  dictionaryConstructorTable::iterator cstrIter =
72  dictionaryConstructorTablePtr_->find(coordType);
73 
74  if (cstrIter == dictionaryConstructorTablePtr_->end())
75  {
77  (
78  dict
79  ) << "Unknown coordinateSystem type "
80  << coordType << nl << nl
81  << "Valid coordinateSystem types are :" << nl
82  << dictionaryConstructorTablePtr_->sortedToc()
83  << exit(FatalIOError);
84  }
85 
86  return autoPtr<coordinateSystem>(cstrIter()(coordType, coordDict));
87  }
88 }
89 
90 
92 (
93  const word& name,
94  const dictionary& dict
95 )
96 {
97  const word coordType = dict.lookup("type");
98 
99  dictionaryConstructorTable::iterator cstrIter =
100  dictionaryConstructorTablePtr_->find(coordType);
101 
102  if (cstrIter == dictionaryConstructorTablePtr_->end())
103  {
105  (
106  dict
107  ) << "Unknown coordinateSystem type "
108  << coordType << nl << nl
109  << "Valid coordinateSystem types are :" << nl
110  << dictionaryConstructorTablePtr_->sortedToc()
111  << exit(FatalIOError);
112  }
113 
114  return autoPtr<coordinateSystem>(cstrIter()(name, dict));
115 }
116 
117 
118 // ************************************************************************* //
dictionary dict
Provides a centralised coordinateSystem collection.
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
const entry * lookupEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
Definition: dictionary.C:702
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:1002
A class for handling words, derived from string.
Definition: word.H:59
virtual bool isDict() const
Return true if this entry is a dictionary.
Definition: entry.H:156
static const char nl
Definition: Ostream.H:260
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
static autoPtr< coordinateSystem > New(const objectRegistry &obr, const dictionary &dict)
Select constructed from dictionary and objectRegistry.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:318
Registry of regIOobjects.
virtual ITstream & stream() const =0
Return token stream if this entry is a primitive entry.
A keyword and a list of tokens is an &#39;entry&#39;.
Definition: entry.H:65
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:864
IOerror FatalIOError
#define InfoInFunction
Report an information message using Foam::Info.