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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2012-2016 OpenFOAM Foundation
9  Copyright (C) 2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 "CodedSource.H"
30 
31 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
32 
33 template<class Type>
35 {
36  codedBase::setCodeContext(coeffs_);
37 
39  {
40  return false;
41  }
42 
43  coeffs_.readEntry("fields", fieldNames_);
44  applied_.setSize(fieldNames_.size(), false);
45 
46  dict.readCompat<word>("name", {{"redirectType", 1706}}, name_);
47 
48  // Code chunks
49 
50  codedBase::append("<codeCorrect>");
51  {
52  const entry& e =
53  coeffs_.lookupEntry("codeCorrect", keyType::LITERAL);
54 
55  e.readEntry(codeCorrect_);
56  dynamicCodeContext::inplaceExpand(codeCorrect_, coeffs_);
57 
58  codedBase::append(codeCorrect_);
59 
60  dynamicCodeContext::addLineDirective
61  (
62  codeCorrect_,
63  e.startLineNumber(),
64  coeffs_
65  );
66  }
67 
68  codedBase::append("<codeAddSup>");
69  {
70  const entry& e =
71  coeffs_.lookupEntry("codeAddSup", keyType::LITERAL);
72 
73  e.readEntry(codeAddSup_);
74  dynamicCodeContext::inplaceExpand(codeAddSup_, coeffs_);
75 
76  codedBase::append(codeAddSup_);
77 
78  dynamicCodeContext::addLineDirective
79  (
80  codeAddSup_,
81  e.startLineNumber(),
82  coeffs_
83  );
84  }
85 
86  codedBase::append("<codeConstrain>");
87  {
88  const entry& e =
89  coeffs_.lookupEntryCompat
90  (
91  "codeConstrain",
92  {{ "codeSetValue", 1812 }}, keyType::LITERAL
93  );
94 
95  e.readEntry(codeConstrain_);
96  dynamicCodeContext::inplaceExpand(codeConstrain_, coeffs_);
97 
98  codedBase::append(codeConstrain_);
99 
100  dynamicCodeContext::addLineDirective
101  (
102  codeConstrain_,
103  e.startLineNumber(),
104  coeffs_
105  );
106  }
107 
108  return true;
109 }
110 
111 
112 // ************************************************************************* //
Foam::entry
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:67
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
append
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
CodedSource.H
Foam::stringOps::inplaceExpand
void inplaceExpand(std::string &s, const HashTable< string, word, string::hash > &mapping, const char sigil='$')
Definition: stringOps.C:733
Foam::blockMeshTools::read
void read(Istream &, label &, const dictionary &)
In-place read with dictionary lookup.
Definition: blockMeshTools.C:33
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
Foam::fv::CodedSource::read
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: CodedSourceIO.C:34