uniformFixedValueFvFieldSource.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-2024 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 
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class Type>
32 (
34  const dictionary& dict
35 )
36 :
37  fvFieldSource<Type>(iF, dict),
38  uniformValue_
39  (
40  Function1<Type>::New
41  (
42  "uniformValue",
43  this->db().time().userUnits(),
44  iF.dimensions(),
45  dict
46  )
47  )
48 {}
49 
50 
51 template<class Type>
53 (
56 )
57 :
58  fvFieldSource<Type>(field, iF),
59  uniformValue_(field.uniformValue_, false)
60 {}
61 
62 
63 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
64 
65 template<class Type>
67 {}
68 
69 
70 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
71 
72 template<class Type>
75 (
76  const fvSource& source
77 ) const
78 {
79  const Type v = uniformValue_->value(this->db().time().value());
80  return tmp<Field<Type>>(new Field<Type>(source.nCells(), v));
81 }
82 
83 
84 template<class Type>
87 (
88  const fvSource& source
89 ) const
90 {
91  return tmp<scalarField>(new scalarField(source.nCells(), scalar(0)));
92 }
93 
94 
95 template<class Type>
97 {
100  (
101  os,
102  this->db().time().userUnits(),
103  this->internalField().dimensions(),
104  uniformValue_()
105  );
106 }
107 
108 
109 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Pre-declare SubField and related Field type.
Definition: Field.H:83
Run-time selectable general function of one variable.
Definition: Function1.H:125
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
virtual void write(Ostream &) const
Write.
Base class for finite volume sources.
Definition: fvSource.H:52
virtual label nCells() const
Return the number of cells that the source applies to.
Definition: fvSource.C:66
A class for managing temporary objects.
Definition: tmp.H:55
This source condition provides a uniform fixed value.
virtual tmp< scalarField > internalCoeff(const fvSource &) const
Return the internal coefficient.
virtual void write(Ostream &) const
Write.
uniformFixedValueFvFieldSource(const DimensionedField< Type, volMesh > &, const dictionary &dict)
Construct from internal field and dictionary.
virtual tmp< Field< Type > > sourceValue(const fvSource &) const
Return the source value.
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
const HashTable< dimensionSet > & dimensions()
Get the table of dimension sets.
Definition: dimensionSets.C:96
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
dictionary dict