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 -------------------------------------------------------------------------------
10 License
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 
32 template<class Type>
34 (
35  const faPatch& p,
37 )
38 :
40  refValueFunc_(nullptr)
41 {}
42 
43 
44 template<class Type>
46 (
47  const faPatch& p,
49  const Field<Type>& fld
50 )
51 :
53  refValueFunc_(nullptr)
54 {}
55 
56 
57 template<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 
87 template<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 
112 template<class Type>
114 (
115  const uniformFixedValueFaPatchField<Type>& ptf
116 )
117 :
119  refValueFunc_(ptf.refValueFunc_.clone(/*this->patch().patch()*/))
120 {}
121 
122 
123 template<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 
137 template<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 
151 template<class Type>
153 {
155  if (refValueFunc_)
156  {
157  refValueFunc_->writeData(os);
158  }
160 }
161 
162 
163 // ************************************************************************* //
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
dictionary dict
Author Zeljko Tukovic, FMENA Hrvoje Jasak, Wikki Ltd.
virtual void write(Ostream &os) const
Write.
Definition: faPatchField.C:253
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
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.
void writeValueEntry(Ostream &os) const
Write *this field as a "value" entry.
Definition: faPatchField.H:317
void extrapolateInternal()
Assign the patch field from the internal field.
Definition: faPatchField.C:60
uniformFixedValueFaPatchField(const faPatch &, const DimensionedField< Type, areaMesh > &)
Construct from patch and internal field.
Generic templated field type.
Definition: Field.H:62
void map(const UList< Type > &mapF, const labelUList &mapAddressing)
1 to 1 map from the given field
Definition: Field.C:303
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
OBJstream os(runTime.globalPath()/outputName)
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:72
virtual void write(Ostream &os) const
Write.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field, sets updated() to false.
Definition: faPatchField.C:241
This boundary condition provides a uniform fixed value condition.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: faPatchField.C:234
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
virtual void operator==(const faPatchField< Type > &)
Definition: faPatchField.C:423
volScalarField & p
bool readValueEntry(const dictionary &dict, IOobjectOption::readOption readOpt=IOobjectOption::LAZY_READ)
Read the "value" entry into *this.
Definition: faPatchField.C:30