genericFvFieldSource.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) 2023 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 "genericFvFieldSource.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class Type>
32 (
34  const dictionary& dict
35 )
36 :
37  genericFieldBase(dict.lookup("type")),
38  fvFieldSource<Type>(iF, dict),
39  dict_(dict)
40 {}
41 
42 
43 template<class Type>
45 (
46  const genericFvFieldSource<Type>& stf,
48 )
49 :
50  genericFieldBase(stf),
51  fvFieldSource<Type>(stf, iF),
52  dict_(stf.dict_)
53 {}
54 
55 
56 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
57 
58 template<class Type>
60 {}
61 
62 
63 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
64 
65 template<class Type>
68 (
69  const fvSource& source
70 ) const
71 {
73  << "cannot be called for a genericFvFieldSource"
74  " (actual type " << actualTypeName() << ")"
75  << "\n on source " << source.name()
76  << " of field " << this->internalField().name()
77  << " in file " << this->internalField().objectPath()
78  << "\n You are probably trying to solve for a field with a "
79  "generic source condition."
80  << abort(FatalError);
81 
82  return NullObjectRef<Field<Type>>();
83 }
84 
85 
86 template<class Type>
89 (
90  const fvSource& source
91 ) const
92 {
94  << "cannot be called for a genericFvFieldSource"
95  " (actual type " << actualTypeName() << ")"
96  << "\n on source " << source.name()
97  << " of field " << this->internalField().name()
98  << " in file " << this->internalField().objectPath()
99  << "\n You are probably trying to solve for a field with a "
100  "generic source condition."
101  << abort(FatalError);
102 
103  return NullObjectRef<scalarField>();
104 }
105 
106 
107 template<class Type>
109 {
110  writeEntry(os, "type", actualTypeName());
111 
112  forAllConstIter(dictionary, dict_, iter)
113  {
114  if (iter().keyword() != "type")
115  {
116  iter().write(os);
117  }
118  }
119 }
120 
121 
122 // ************************************************************************* //
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:477
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Base class for finite-volume field sources.
Definition: fvFieldSource.H:62
const word & name() const
Return const access to the source name.
Definition: fvModelI.H:47
Base class for finite volume sources.
Definition: fvSource.H:52
Base class for generic field types. Facilitates down-casting so that the actual type can be queried.
This provides a generic source condition, useful as a fallback for handling unknown types when post-p...
virtual tmp< scalarField > internalCoeff(const fvSource &) const
Return the internal coefficient.
virtual void write(Ostream &) const
Write.
virtual tmp< Field< Type > > sourceValue(const fvSource &) const
Return the source energy value.
genericFvFieldSource(const DimensionedField< Type, volMesh > &, const dictionary &)
Construct internal field and dictionary.
virtual ~genericFvFieldSource()
Destructor.
A class for managing temporary objects.
Definition: tmp.H:55
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
errorManip< error > abort(error &err)
Definition: errorManip.H:131
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
error FatalError
dictionary dict