Loading...
Searching...
No Matches
uniformFixedGradientFvPatchField.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) 2013-2016 OpenFOAM Foundation
9 Copyright (C) 2017-2023 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
30
31// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
33template<class Type>
35(
36 const fvPatch& p,
38)
41 refGradFunc_(nullptr)
42{}
43
44
45template<class Type>
47(
48 const fvPatch& p,
50 const Field<Type>& fld
51)
54 refGradFunc_(nullptr)
55{}
56
57
58template<class Type>
60(
61 const fvPatch& p,
63 const dictionary& dict
64)
65:
66 fixedGradientFvPatchField<Type>(p, iF), // Bypass dictionary constructor
67 refGradFunc_
68 (
69 PatchFunction1<Type>::New(p.patch(), "uniformGradient", dict)
70 )
71{
73
74 if (!this->readValueEntry(dict))
75 {
76 // Ensure field has initialised values
77 this->extrapolateInternal();
78
79 // Evaluate to assign a value
80 this->evaluate();
81 }
82}
83
84
85template<class Type>
87(
88 const uniformFixedGradientFvPatchField<Type>& ptf,
89 const fvPatch& p,
90 const DimensionedField<Type, volMesh>& iF,
91 const fvPatchFieldMapper& mapper
92)
94 fixedGradientFvPatchField<Type>(ptf, p, iF, mapper),
95 refGradFunc_(ptf.refGradFunc_.clone())
96{}
97
98
99template<class Type>
101(
103)
105 fixedGradientFvPatchField<Type>(ptf),
106 refGradFunc_(ptf.refGradFunc_.clone())
107{}
108
109
110template<class Type>
112(
115)
116:
117 fixedGradientFvPatchField<Type>(ptf, iF),
118 refGradFunc_(ptf.refGradFunc_.clone())
119{
120 // Evaluate the profile if defined
121 if (refGradFunc_)
122 {
123 this->evaluate();
125}
126
127
128// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
129
130template<class Type>
132{
133 if (this->updated())
134 {
135 return;
136 }
137
138 const scalar t = this->db().time().timeOutputValue();
139 // Extra safety on the evaluation
140 if (refGradFunc_)
141 {
142 this->gradient() = refGradFunc_->value(t);
143 }
144 else
145 {
146 this->gradient() = Zero;
148
150}
151
152
153template<class Type>
155{
157 if (refGradFunc_)
158 {
159 refGradFunc_->writeData(os);
160 }
162}
163
164
165// ************************************************************************* //
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
This boundary condition supplies a fixed gradient condition, such that the patch values are calculate...
virtual Field< Type > & gradient()
Return gradient at boundary.
virtual void write(Ostream &) const
Write.
fixedGradientFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Evaluate the patch field.
const objectRegistry & db() const
The associated objectRegistry.
virtual void readDict(const dictionary &dict)
Read dictionary entries.
const fvPatch & patch() const noexcept
Return the patch.
bool updated() const noexcept
True if the boundary condition has already been updated.
A FieldMapper for finite-volume patch fields.
static tmp< fvPatchField< Type > > New(const word &patchFieldType, const fvPatch &, const DimensionedField< Type, volMesh > &)
Return a pointer to a new patchField created on freestore given.
void writeValueEntry(Ostream &os) const
Write *this field as a "value" entry.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
bool readValueEntry(const dictionary &dict, IOobjectOption::readOption readOpt=IOobjectOption::LAZY_READ)
Read the "value" entry into *this.
void extrapolateInternal()
Assign the patch field from the internal field.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition fvPatch.H:71
This boundary condition provides a uniform fixed gradient condition.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
uniformFixedGradientFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
virtual tmp< fvPatchField< Type > > clone() const
Return a clone.
volScalarField & p
OBJstream os(runTime.globalPath()/outputName)
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.
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
dictionary dict