Loading...
Searching...
No Matches
uniformFixedValueFaPatchField.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)
39 fixedValueFaPatchField<Type>(p, iF),
40 refValueFunc_(nullptr)
41{}
42
43
44template<class Type>
46(
47 const faPatch& p,
49 const Field<Type>& fld
50)
52 fixedValueFaPatchField<Type>(p, iF, fld),
53 refValueFunc_(nullptr)
54{}
55
56
57template<class Type>
59(
60 const faPatch& p,
62 const dictionary& dict
63)
64:
65 fixedValueFaPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ),
66 refValueFunc_
67 (
68 Function1<Type>::New
69 (
70 /* p.patch(), */
71 "uniformValue",
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
87template<class Type>
89(
90 const uniformFixedValueFaPatchField<Type>& ptf,
91 const faPatch& p,
92 const DimensionedField<Type, areaMesh>& iF,
93 const faPatchFieldMapper& mapper
94)
95:
96 fixedValueFaPatchField<Type>(p, iF), // Don't map
97 refValueFunc_(ptf.refValueFunc_.clone(/*p.patch()*/))
98{
99 if (mapper.direct() && !mapper.hasUnmapped())
100 {
101 // Use mapping instead of re-evaluation
102 this->map(ptf, mapper);
103 }
104 else
105 {
106 // Evaluate since value not mapped
107 this->evaluate();
108 }
109}
110
111
112template<class Type>
114(
116)
118 fixedValueFaPatchField<Type>(ptf),
119 refValueFunc_(ptf.refValueFunc_.clone(/*this->patch().patch()*/))
120{}
121
122
123template<class Type>
125(
128)
129:
130 fixedValueFaPatchField<Type>(ptf, iF),
131 refValueFunc_(ptf.refValueFunc_.clone(/*this->patch().patch()*/))
132{}
133
134
135// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
136
137template<class Type>
139{
140 if (this->updated())
141 {
142 return;
143 }
144
145 const scalar t = this->db().time().timeOutputValue();
146 faPatchField<Type>::operator==(refValueFunc_->value(t));
148}
149
150
151template<class Type>
153{
155 if (refValueFunc_)
156 {
157 refValueFunc_->writeData(os);
158 }
160}
161
162
163// ************************************************************************* //
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...
virtual bool direct() const =0
Is it a direct (non-interpolating) mapper?
virtual bool hasUnmapped() const =0
Any unmapped values?
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
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
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 operator==(const faPatchField< Type > &)
virtual void write(Ostream &os) const
Write.
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.
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
Author Zeljko Tukovic, FMENA Hrvoje Jasak, Wikki Ltd.
fixedValueFaPatchField(const faPatch &, const DimensionedField< Type, areaMesh > &)
Construct from patch and internal field.
This boundary condition provides a uniform fixed value condition.
virtual tmp< faPatchField< Type > > clone() const
Return clone.
uniformFixedValueFaPatchField(const faPatch &, const DimensionedField< Type, areaMesh > &)
Construct from patch and internal field.
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.
dictionary dict