newWaveSuperposition.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) 2017-2019 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 "waveSuperposition.H"
27 
28 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
29 
31 (
32  const objectRegistry& db
33 )
34 {
36  {
38  }
39 
40  const IOdictionary dict
41  (
42  IOobject
43  (
44  dictName,
45  db.time().constant(),
46  db,
47  IOobject::MUST_READ,
48  IOobject::NO_WRITE,
49  false
50  )
51  );
52 
53  const word type =
54  dict.lookupOrDefault<word>("type", waveSuperposition::typeName);
55 
56  objectRegistryConstructorTable::iterator cstrIter =
57  objectRegistryConstructorTablePtr_->find(type);
58 
59  if (cstrIter == objectRegistryConstructorTablePtr_->end())
60  {
62  << "Unknown " << waveSuperposition::typeName << " " << type
63  << nl << nl << "Valid types are:" << nl
64  << objectRegistryConstructorTablePtr_->sortedToc()
65  << exit(FatalError);
66  }
67 
68  waveSuperposition* ptr = cstrIter()(db).ptr();
69 
70  ptr->store();
71 
72  return *ptr;
73 }
74 
75 
76 // ************************************************************************* //
A wrapper around a list of wave models. Superimposes the modelled values of elevation and velocity...
dictionary dict
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
bool foundObject(const word &name) const
Is the named Type found?
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:52
A class for handling words, derived from string.
Definition: word.H:59
const word & constant() const
Return constant name.
Definition: TimePaths.H:124
const word dictName("particleTrackDict")
static const waveSuperposition & New(const objectRegistry &db)
Return a reference to the wave model on the given database,.
void store()
Transfer ownership of this object to its registry.
Definition: regIOobjectI.H:34
static const char nl
Definition: Ostream.H:265
const Time & time() const
Return time.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
Registry of regIOobjects.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92