uniformFixedGradientFaPatchField.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) 2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
32 template<class Type>
34 (
35  const faPatch& p,
37 )
38 :
40  refGradFunc_(nullptr)
41 {}
42 
43 
44 template<class Type>
46 (
47  const faPatch& p,
49  const Field<Type>& fld
50 )
51 :
53  refGradFunc_(nullptr)
54 {}
55 
56 
57 template<class Type>
59 (
60  const faPatch& p,
62  const dictionary& dict
63 )
64 :
65  fixedGradientFaPatchField<Type>(p, iF), // Bypass dictionary constructor
66  refGradFunc_
67  (
68  Function1<Type>::New
69  (
70  /* p.patch(), */
71  "uniformGradient",
72  dict
73  )
74  )
75 {
76  if (!this->readValueEntry(dict))
77  {
78  // Ensure field has reasonable initial values
79  this->extrapolateInternal();
80 
81  // Evaluate to assign a value
82  this->evaluate();
83  }
84 }
85 
86 
87 template<class Type>
89 (
90  const uniformFixedGradientFaPatchField<Type>& ptf,
91  const faPatch& p,
92  const DimensionedField<Type, areaMesh>& iF,
93  const faPatchFieldMapper& mapper
94 )
95 :
96  fixedGradientFaPatchField<Type>(ptf, p, iF, mapper),
97  refGradFunc_(ptf.refGradFunc_.clone(/*p.patch()*/))
98 {}
99 
100 
101 template<class Type>
103 (
105 )
106 :
108  refGradFunc_(ptf.refGradFunc_.clone(/*p.patch()*/))
109 {}
110 
111 
112 template<class Type>
114 (
117 )
118 :
119  fixedGradientFaPatchField<Type>(ptf, iF),
120  refGradFunc_(ptf.refGradFunc_.clone(/*this->patch().patch()*/))
121 {
122  // Evaluate the profile if defined
123  if (refGradFunc_)
124  {
125  this->evaluate();
126  }
127 }
128 
129 
130 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
131 
132 template<class Type>
134 {
135  if (this->updated())
136  {
137  return;
138  }
139 
140  const scalar t = this->db().time().timeOutputValue();
141 
142  // Extra safety on the evaluation
143  if (refGradFunc_)
144  {
145  this->gradient() = refGradFunc_->value(t);
146  }
147  else
148  {
149  this->gradient() = Zero;
150  }
151 
153 }
154 
155 
156 template<class Type>
158 {
160  if (refGradFunc_)
161  {
162  refGradFunc_->writeData(os);
163  }
165 }
166 
167 
168 // ************************************************************************* //
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
This boundary condition supplies a fixed gradient condition, such that the patch values are calculate...
void writeValueEntry(Ostream &os) const
Write *this field as a "value" entry.
Definition: faPatchField.H:317
void extrapolateInternal()
Assign the patch field from the internal field.
Definition: faPatchField.C:60
uniformFixedGradientFaPatchField(const faPatch &, const DimensionedField< Type, areaMesh > &)
Construct from patch and internal field.
virtual void write(Ostream &os) const
Write.
virtual void write(Ostream &) const
Write.
Generic templated field type.
Definition: Field.H:62
This boundary condition provides a uniform fixed gradient condition.
OBJstream os(runTime.globalPath()/outputName)
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:72
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: faPatchField.C:234
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
volScalarField & p
bool readValueEntry(const dictionary &dict, IOobjectOption::readOption readOpt=IOobjectOption::LAZY_READ)
Read the "value" entry into *this.
Definition: faPatchField.C:30
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127