Loading...
Searching...
No Matches
userValue.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) 2024 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28#include "userValue.H"
31// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32
33namespace Foam
34{
35namespace substitutionModels
36{
39 (
43 );
44}
45}
46
47
48// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49
50Foam::substitutionModels::userValue::userValue
51(
52 const dictionary& dict,
53 const Time& time
54)
55:
57 entries_()
58{
59 // Populate entries
60 const dictionary& entriesDict = dict.subDict("entries");
61 for (const auto& e : entriesDict)
62 {
63 entries_.insert(cleanKey(e.keyword()), string(e.stream()));
64 }
65}
66
67
68// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
69
71(
72 const word& keyName
73) const
74{
75 return entries_.found(keyName);
76}
77
78
80(
81 const word& key,
82 string& buffer
83) const
84{
85 if (!valid(key)) return false;
87 buffer.replaceAll(keyify(key), entries_[key]);
88
89 return true;
90}
91
92
94{
95 return entries_.sortedToc();
96}
97
98
99// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
string & replaceAll(const std::string &s1, const std::string &s2, size_type pos=0)
Replace all occurrences of sub-string s1 with s2, beginning at pos in the string.
Definition string.C:117
Base class for substitution models.
static word cleanKey(const string &str)
Clean the key text.
static string keyify(const word &w)
Return a key representation from a word.
The userValue substitution model. Dictionaries can be retrieved from an object registry,...
Definition userValue.H:98
virtual bool apply(const word &key, string &buffer) const
Apply substitutions to this string buffer.
Definition userValue.C:73
virtual bool valid(const word &keyName) const
Return true of model applies to this keyName.
Definition userValue.C:64
virtual wordList keys() const
Return a word list of the keys.
Definition userValue.C:86
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
Namespace for OpenFOAM.
List< word > wordList
List of word.
Definition fileName.H:60
dictionary dict
volScalarField & e