Loading...
Searching...
No Matches
fixedMeanFvPatchField.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) 2012-2016 OpenFOAM Foundation
9 Copyright (C) 2017-2025 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 "volFields.H"
31
32// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33
34template<class Type>
36(
37 const fvPatch& p,
39)
41 fixedValueFvPatchField<Type>(p, iF),
42 meanValue_()
43{}
44
45
46template<class Type>
48(
49 const fvPatch& p,
51 const dictionary& dict
52)
54 fixedValueFvPatchField<Type>(p, iF, dict),
55 meanValue_(Function1<Type>::New("meanValue", dict, &this->db()))
56{}
57
58
59template<class Type>
61(
63 const fvPatch& p,
65 const fvPatchFieldMapper& mapper
66)
68 fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
69 meanValue_(ptf.meanValue_.clone())
70{}
71
72
73template<class Type>
75(
77)
79 fixedValueFvPatchField<Type>(ptf),
80 meanValue_(ptf.meanValue_.clone())
81{}
82
83
84template<class Type>
86(
89)
90:
91 fixedValueFvPatchField<Type>(ptf, iF),
92 meanValue_(ptf.meanValue_.clone())
93{}
94
95
96// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
97
98template<class Type>
100{
101 if (this->updated())
102 {
103 return;
104 }
105
106 const scalar t = this->db().time().timeOutputValue();
107 Type meanValue = meanValue_->value(t);
108
109 Field<Type> newValues(this->patchInternalField());
110
111 Type meanValuePsi =
112 gWeightedAverage(this->patch().magSf(), newValues);
113
114 if (mag(meanValue) > SMALL && mag(meanValuePsi) > 0.5*mag(meanValue))
115 {
116 newValues *= mag(meanValue)/mag(meanValuePsi);
117 }
118 else
119 {
120 newValues += (meanValue - meanValuePsi);
121 }
122
123 this->operator==(newValues);
124
126}
127
128
129template<class Type>
131{
133 meanValue_->writeData(os);
135}
136
137
138// ************************************************************************* //
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
This boundary condition extrapolates field to the patch using the near-cell values and adjusts the di...
virtual void write(Ostream &) const
Write.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
fixedMeanFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
virtual tmp< fvPatchField< Type > > clone() const
Return a clone.
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
fixedValueFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
const objectRegistry & db() const
The associated objectRegistry.
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.
virtual void write(Ostream &) const
Write.
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch.
void writeValueEntry(Ostream &os) const
Write *this field as a "value" entry.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition fvPatch.H:71
volScalarField & p
OBJstream os(runTime.globalPath()/outputName)
Type gWeightedAverage(const UList< scalar > &weights, const UList< Type > &fld, const label comm)
The global weighted average of a field, using the mag() of the weights.
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
dictionary dict