waveSuperpositionNew.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-2020 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 #include "Time.H"
28 
29 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
30 
32 (
33  const objectRegistry& db
34 )
35 {
37  {
39  }
40 
41  const IOdictionary dict
42  (
43  IOobject
44  (
45  dictName,
46  db.time().constant(),
47  db,
48  IOobject::MUST_READ,
49  IOobject::NO_WRITE,
50  false
51  )
52  );
53 
54  const word type =
55  dict.lookupOrDefault<word>("type", waveSuperposition::typeName);
56 
57  objectRegistryConstructorTable::iterator cstrIter =
58  objectRegistryConstructorTablePtr_->find(type);
59 
60  if (cstrIter == objectRegistryConstructorTablePtr_->end())
61  {
63  << "Unknown " << waveSuperposition::typeName << " " << type
64  << nl << nl << "Valid types are:" << nl
65  << objectRegistryConstructorTablePtr_->sortedToc()
66  << exit(FatalError);
67  }
68 
69  waveSuperposition* ptr = cstrIter()(db).ptr();
70 
71  ptr->store();
72 
73  return *ptr;
74 }
75 
76 
77 // ************************************************************************* //
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:306
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:53
A class for handling words, derived from string.
Definition: word.H:59
const word & constant() const
Return constant name.
Definition: TimePaths.H:123
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:40
static const char nl
Definition: Ostream.H:260
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:98
const word dictName("noiseDict")