Loading...
Searching...
No Matches
fixedGradientFaPatchField.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) 2016-2017 Wikki Ltd
9 Copyright (C) 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\*---------------------------------------------------------------------------*/
30#include "dictionary.H"
31
32// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
33
34template<class Type>
36(
37 const dictionary& dict,
39)
40{
41 if (!IOobjectOption::isAnyRead(readOpt)) return false;
42 const auto& p = faPatchFieldBase::patch();
43
44
45 const auto* eptr = dict.findEntry("gradient", keyType::LITERAL);
46
47 if (eptr)
48 {
49 gradient_.assign(*eptr, p.size());
50 return true;
51 }
52
54 {
56 << "Required entry 'gradient' : missing for patch " << p.name()
57 << " in dictionary " << dict.relativeName() << nl
59 }
60
61 return false;
62}
63
64
65// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
66
67template<class Type>
69(
70 const faPatch& p,
72)
74 faPatchField<Type>(p, iF),
75 gradient_(p.size(), Zero)
76{}
77
78
79template<class Type>
81(
82 const faPatch& p,
84 const dictionary& dict,
86)
87:
88 faPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ),
89 gradient_(p.size())
90{
91 if (readGradientEntry(dict, requireGrad))
92 {
93 evaluate();
94 }
95 else
96 {
97 // Not read (eg, optional and missing):
98 // - treat as zero-gradient, do not evaluate
100 gradient_ = Zero;
101 }
102}
103
104
105template<class Type>
107(
108 const fixedGradientFaPatchField<Type>& ptf,
109 const faPatch& p,
110 const DimensionedField<Type, areaMesh>& iF,
111 const faPatchFieldMapper& mapper
112)
114 faPatchField<Type>(ptf, p, iF, mapper),
115 gradient_(ptf.gradient_, mapper)
116{}
117
118
119template<class Type>
121(
123)
125 faPatchField<Type>(ptf),
126 gradient_(ptf.gradient_)
127{}
128
129
130template<class Type>
132(
135)
136:
137 faPatchField<Type>(ptf, iF),
138 gradient_(ptf.gradient_)
139{}
140
141
142// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
143
144template<class Type>
146(
147 const faPatchFieldMapper& m
148)
151 gradient_.autoMap(m);
152}
153
154
155template<class Type>
157(
158 const faPatchField<Type>& ptf,
159 const labelList& addr
160)
161{
162 faPatchField<Type>::rmap(ptf, addr);
163
166
167 gradient_.rmap(fgptf.gradient_, addr);
168}
169
170
171template<class Type>
173{
174 if (!this->updated())
175 {
176 this->updateCoeffs();
177 }
178
179 Field<Type>::operator=
180 (
181 this->patchInternalField() + gradient_/this->patch().deltaCoeffs()
182 );
185}
186
187
188template<class Type>
191(
192 const tmp<scalarField>&
193) const
196}
197
198
199template<class Type>
202(
203 const tmp<scalarField>&
204) const
206 return gradient()/this->patch().deltaCoeffs();
207}
208
209
210template<class Type>
214 return tmp<Field<Type>>::New(this->size(), Zero);
215}
216
217
218template<class Type>
225
226template<class Type>
228{
230 gradient_.writeEntry("gradient", os);
231}
232
233
234// ************************************************************************* //
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
void autoMap(const FieldMapper &map, const bool applyFlip=true)
Map from self.
Definition Field.C:465
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
static bool isReadRequired(readOption opt) noexcept
True if (MUST_READ | READ_MODIFIED) bits are set.
readOption
Enumeration defining read preferences.
static bool isAnyRead(readOption opt) noexcept
True if any reading may be required (ie, != NO_READ).
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
void size(const label n)
Definition UList.H:118
commsTypes
Communications types.
Definition UPstream.H:81
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
bool updated() const noexcept
True if the boundary condition has already been updated.
const faPatch & patch() const noexcept
Return the patch.
A FieldMapper for finite-area patch fields.
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
faPatchField(const faPatch &, const DimensionedField< Type, areaMesh > &)
Construct from patch and internal field.
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch.
virtual void rmap(const faPatchField< Type > &, const labelList &)
Reverse map the given faPatchField onto this faPatchField.
virtual void write(Ostream &os) const
Write.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
void extrapolateInternal()
Assign the patch field from the internal field.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Evaluate the patch field, sets updated() to false.
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 tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the.
virtual Field< Type > & gradient() noexcept
The reference gradient at boundary.
virtual void rmap(const faPatchField< Type > &, const labelList &)
Reverse map the given faPatchField onto this faPatchField.
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< scalarField > &) const
Return the matrix diagonal coefficients corresponding to the.
fixedGradientFaPatchField(const faPatch &, const DimensionedField< Type, areaMesh > &)
Construct from patch and internal field.
bool readGradientEntry(const dictionary &dict, IOobjectOption::readOption readOpt=IOobjectOption::LAZY_READ)
Read the "gradient" entry into corresponding member.
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the.
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< scalarField > &) const
Return the matrix source coefficients corresponding to the.
virtual void autoMap(const faPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Evaluate the patch field.
@ LITERAL
String literal.
Definition keyType.H:82
A traits class, which is primarily used for primitives and vector-space.
Definition pTraits.H:64
A class for managing temporary objects.
Definition tmp.H:75
volScalarField & p
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition error.H:629
OBJstream os(runTime.globalPath()/outputName)
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
Definition typeInfo.H:172
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.
List< label > labelList
A List of labels.
Definition List.H:62
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
dictionary dict