uniformInletOutletFvFieldSource.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  uniformInletValue_
39  (
40  Function1<Type>::New
41  (
42  "uniformInletValue",
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  uniformInletValue_(field.uniformInletValue_, 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 scalar t = this->db().time().value();
80  const Type v = uniformInletValue_->value(t);
81  return tmp<Field<Type>>(new Field<Type>(source.nCells(), v));
82 }
83 
84 
85 template<class Type>
88 (
89  const fvSource& source
90 ) const
91 {
92  return
93  neg0(source.source(this->internalField().name()))
94  *scalarField(source.nCells(), scalar(1));
95 }
96 
97 
98 template<class Type>
100 {
102  writeEntry
103  (
104  os,
105  this->db().time().userUnits(),
106  this->internalField().dimensions(),
107  uniformInletValue_()
108  );
109 }
110 
111 
112 // ************************************************************************* //
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 tmp< scalarField > source(const word &fieldName) const =0
Return the source value.
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 when the source is positive, and the internal va...
virtual tmp< scalarField > internalCoeff(const fvSource &) const
Return the internal coefficient.
virtual tmp< Field< Type > > sourceValue(const fvSource &) const
Return the source value.
uniformInletOutletFvFieldSource(const DimensionedField< Type, volMesh > &, const dictionary &dict)
Construct from internal field and dictionary.
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
dimensionedScalar neg0(const dimensionedScalar &ds)
dictionary dict