CodedSourceIO.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 | Copyright (C) 2012-2015 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 "CodedSource.H"
27 #include "stringOps.H"
28 
29 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
30 
31 template<class Type>
33 {
35  {
36  coeffs_.lookup("fieldNames") >> fieldNames_;
37  applied_.setSize(fieldNames_.size(), false);
38  coeffs_.lookup("redirectType") >> redirectType_;
39 
40  // Code snippets
41  {
42  const entry& e = coeffs_.lookupEntry
43  (
44  "codeCorrect",
45  false,
46  false
47  );
48  codeCorrect_ = stringOps::trim(e.stream());
49  stringOps::inplaceExpand(codeCorrect_, coeffs_);
50  dynamicCodeContext::addLineDirective
51  (
52  codeCorrect_,
53  e.startLineNumber(),
54  coeffs_.name()
55  );
56  }
57 
58  {
59  const entry& e = coeffs_.lookupEntry
60  (
61  "codeAddSup",
62  false,
63  false
64  );
65  codeAddSup_ = stringOps::trim(e.stream());
66  stringOps::inplaceExpand(codeAddSup_, coeffs_);
67  dynamicCodeContext::addLineDirective
68  (
69  codeAddSup_,
70  e.startLineNumber(),
71  coeffs_.name()
72  );
73  }
74 
75  {
76  const entry& e = coeffs_.lookupEntry
77  (
78  "codeSetValue",
79  false,
80  false
81  );
82  codeSetValue_ = stringOps::trim(e.stream());
83  stringOps::inplaceExpand(codeSetValue_, coeffs_);
84  dynamicCodeContext::addLineDirective
85  (
86  codeSetValue_,
87  e.startLineNumber(),
88  coeffs_.name()
89  );
90  }
91 
92  return true;
93  }
94  else
95  {
96  return false;
97  }
98 }
99 
100 
101 // ************************************************************************* //
Foam::entry
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:65
Foam::read
bool read(const char *, int32_t &)
Definition: int32IO.C:87
Foam::dimensioned::name
const word & name() const
Return const reference to name.
Definition: dimensionedType.C:235
CodedSource.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: doubleFloat.H:94
Foam::fv::CodedSource::read
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: CodedSourceIO.C:32
stringOps.H
Foam::stringOps::inplaceExpand
string & inplaceExpand(string &, const HashTable< string, word, string::hash > &mapping, const char sigil='$')
Inplace expand occurences of variables according to the mapping.
Definition: stringOps.C:86
Foam::stringOps::trim
string trim(const string &)
Return string trimmed of leading and trailing whitespace.
Definition: stringOps.C:922