Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
10License
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
32template<class Type>
34(
35 const faPatch& p,
37)
40 refGradFunc_(nullptr)
41{}
42
43
44template<class Type>
46(
47 const faPatch& p,
49 const Field<Type>& fld
50)
53 refGradFunc_(nullptr)
54{}
55
56
57template<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 &iF.db()
74 )
75 )
76{
77 if (!this->readValueEntry(dict))
78 {
79 // Ensure field has reasonable initial values
80 this->extrapolateInternal();
81
82 // Evaluate to assign a value
83 this->evaluate();
84 }
85}
86
87
88template<class Type>
90(
91 const uniformFixedGradientFaPatchField<Type>& ptf,
92 const faPatch& p,
93 const DimensionedField<Type, areaMesh>& iF,
94 const faPatchFieldMapper& mapper
95)
97 fixedGradientFaPatchField<Type>(ptf, p, iF, mapper),
98 refGradFunc_(ptf.refGradFunc_.clone(/*p.patch()*/))
99{}
100
101
102template<class Type>
104(
106)
108 fixedGradientFaPatchField<Type>(ptf),
109 refGradFunc_(ptf.refGradFunc_.clone(/*p.patch()*/))
110{}
111
112
113template<class Type>
115(
118)
119:
120 fixedGradientFaPatchField<Type>(ptf, iF),
121 refGradFunc_(ptf.refGradFunc_.clone(/*this->patch().patch()*/))
122{
123 // Evaluate the profile if defined
124 if (refGradFunc_)
125 {
126 this->evaluate();
128}
129
130
131// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
132
133template<class Type>
135{
136 if (this->updated())
137 {
138 return;
139 }
140
141 const scalar t = this->db().time().timeOutputValue();
142
143 // Extra safety on the evaluation
144 if (refGradFunc_)
145 {
146 this->gradient() = refGradFunc_->value(t);
147 }
148 else
149 {
150 this->gradient() = Zero;
152
154}
155
156
157template<class Type>
159{
161 if (refGradFunc_)
162 {
163 refGradFunc_->writeData(os);
164 }
166}
167
168
169// ************************************************************************* //
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
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition Function1.H:92
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
const objectRegistry & db() const
The associated objectRegistry.
bool updated() const noexcept
True if the boundary condition has already been updated.
A FieldMapper for finite-area patch fields.
static tmp< faPatchField< Type > > New(const word &patchFieldType, const word &actualPatchType, const faPatch &, const DimensionedField< Type, areaMesh > &)
Return a pointer to a new patchField created on freestore given patch and internal field.
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.
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition faPatch.H:76
This boundary condition supplies a fixed gradient condition, such that the patch values are calculate...
virtual void write(Ostream &) const
Write.
virtual Field< Type > & gradient() noexcept
The reference gradient at boundary.
fixedGradientFaPatchField(const faPatch &, const DimensionedField< Type, areaMesh > &)
Construct from patch and internal field.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Evaluate the patch field.
This boundary condition provides a uniform fixed gradient condition.
uniformFixedGradientFaPatchField(const faPatch &, const DimensionedField< Type, areaMesh > &)
Construct from patch and internal field.
virtual tmp< faPatchField< Type > > clone() const
Return clone.
virtual void write(Ostream &os) const
Write includes "value" entry.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
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