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-2025 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& model,
71 ) const
72 {
74  << "cannot be called for a genericFvFieldSource"
75  " (actual type " << actualTypeName() << ")"
76  << "\n on source " << model.name()
77  << " of field " << this->internalField().name()
78  << " in file " << this->internalField().objectPath()
79  << "\n You are probably trying to solve for a field with a "
80  "generic source condition."
81  << abort(FatalError);
82 
83  return NullObjectRef<DimensionedField<Type, volMesh>>();
84 }
85 
86 
87 template<class Type>
90 (
91  const fvSource& model,
92  const scalarField& source,
93  const labelUList& cells
94 ) const
95 {
97  << "cannot be called for a genericFvFieldSource"
98  " (actual type " << actualTypeName() << ")"
99  << "\n on source " << model.name()
100  << " of field " << this->internalField().name()
101  << " in file " << this->internalField().objectPath()
102  << "\n You are probably trying to solve for a field with a "
103  "generic source condition."
104  << abort(FatalError);
105 
106  return NullObjectRef<Field<Type>>();
107 }
108 
109 
110 template<class Type>
113 (
114  const fvSource& model,
116 ) const
117 {
119  << "cannot be called for a genericFvFieldSource"
120  " (actual type " << actualTypeName() << ")"
121  << "\n on source " << model.name()
122  << " of field " << this->internalField().name()
123  << " in file " << this->internalField().objectPath()
124  << "\n You are probably trying to solve for a field with a "
125  "generic source condition."
126  << abort(FatalError);
127 
128  return NullObjectRef<DimensionedField<scalar, volMesh>>();
129 }
130 
131 
132 template<class Type>
135 (
136  const fvSource& model,
137  const scalarField& source,
138  const labelUList& cells
139 ) const
140 {
142  << "cannot be called for a genericFvFieldSource"
143  " (actual type " << actualTypeName() << ")"
144  << "\n on source " << model.name()
145  << " of field " << this->internalField().name()
146  << " in file " << this->internalField().objectPath()
147  << "\n You are probably trying to solve for a field with a "
148  "generic source condition."
149  << abort(FatalError);
150 
151  return NullObjectRef<scalarField>();
152 }
153 
154 
155 template<class Type>
157 {
158  writeEntry(os, "type", actualTypeName());
159 
160  forAllConstIter(dictionary, dict_, iter)
161  {
162  if (iter().keyword() != "type")
163  {
164  iter().write(os);
165  }
166  }
167 }
168 
169 
170 // ************************************************************************* //
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:476
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 keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
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:57
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 void write(Ostream &) const
Write.
genericFvFieldSource(const DimensionedField< Type, volMesh > &, const dictionary &)
Construct internal field and dictionary.
virtual ~genericFvFieldSource()
Destructor.
virtual tmp< DimensionedField< Type, volMesh > > sourceValue(const fvSource &model, const DimensionedField< scalar, volMesh > &source) const
Return the source value.
virtual tmp< DimensionedField< scalar, volMesh > > internalCoeff(const fvSource &model, const DimensionedField< scalar, volMesh > &source) const
Return the source value.
A class for managing temporary objects.
Definition: tmp.H:55
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
const cellShapeList & cells
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