waveModelNew.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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2015 IH-Cantabria
9 Copyright (C) 2016-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "waveModel.H"
30#include "fvMesh.H"
31
33(
34 const word& dictName,
35 const fvMesh& mesh,
36 const polyPatch& patch
37)
38{
39 IOdictionary waveDict
40 (
42 (
44 mesh.time().constant(),
45 mesh,
48 false // Not registering
49 )
50 );
51
52 word modelType("none");
53 dictionary patchDict;
54 if (waveDict.found(patch.name()))
55 {
56 patchDict = waveDict.subDict(patch.name());
57 modelType = patchDict.get<word>("waveModel");
58 }
59 else
60 {
62 << "Dictionary entry for patch " << patch.name() << " not found"
64 }
65
66 Info<< "Selecting waveModel " << modelType << endl;
67
68 auto* ctorPtr = patchConstructorTable(modelType);
69
70 if (!ctorPtr)
71 {
73 (
74 waveDict,
75 "waveModel",
76 modelType,
77 *patchConstructorTablePtr_
78 ) << exit(FatalIOError);
79 }
80
81 return autoPtr<waveModel>(ctorPtr(patchDict, mesh, patch));
82}
83
84
86(
87 const polyPatch& patch,
88 const fvMesh& mesh,
89 const word& waveDictName
90)
91{
92 const word modelName = waveModel::modelName(patch.name());
93
94 waveModel* modelPtr = mesh.getObjectPtr<waveModel>(modelName);
95
96 if (!modelPtr)
97 {
98 modelPtr = waveModel::New(waveDictName, mesh, patch).ptr();
99 modelPtr->store();
100 modelPtr->info(Info);
101 }
102
103 return *modelPtr;
104}
105
106
107// ************************************************************************* //
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
const word & constant() const
Return constant name.
Definition: TimePathsI.H:96
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition: dictionary.C:460
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
Definition: dictionaryI.H:87
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:290
Type * getObjectPtr(const word &name, const bool recursive=false) const
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:75
const word & modelName() const
Return const access to the name of the sub-model.
Definition: subModelBase.C:107
A class for managing temporary objects.
Definition: tmp.H:65
Base class for waveModels.
Definition: waveModel.H:61
static const word dictName
Dictionary name.
Definition: waveModel.H:230
virtual void info(Ostream &os) const
Info.
Definition: waveModel.C:422
static tmp< waveModel > lookupOrCreate(const polyPatch &patch, const fvMesh &mesh, const word &waveDictName)
Lookup waveModel from database, or create new.
Definition: waveModelNew.C:86
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:478
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
const word dictName("faMeshDefinition")
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
IOerror FatalIOError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130