scaledFixedValueFvPatchField.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) 2019 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 
30 #include "volFields.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
34 template<class Type>
36 (
37  const fvPatch& p,
39 )
40 :
41  fixedValueFvPatchField<Type>(p, iF),
42  scalePtr_(),
43  refValuePtr_(fvPatchField<Type>::New("refValue", p, iF))
44 {}
45 
46 
47 template<class Type>
49 (
50  const fvPatch& p,
52  const dictionary& dict
53 )
54 :
55  fixedValueFvPatchField<Type>(p, iF, dict, false),
56  scalePtr_(PatchFunction1<scalar>::New(p.patch(), "scale", dict)),
57  refValuePtr_(fvPatchField<Type>::New(p, iF, dict.subDict("refValue")))
58 {
60  {
62  << typeName << " condition can only be applied to fixed value "
63  << "conditions"
64  << exit(FatalIOError);
65  }
66 
67  const scalarField s(scalePtr_->value(this->db().time().timeOutputValue()));
68  this->operator==(s*refValuePtr_());
69 }
70 
71 
72 template<class Type>
74 (
76  const fvPatch& p,
78  const fvPatchFieldMapper& mapper
79 )
80 :
81  fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
82  scalePtr_(ptf.scalePtr_.clone(p.patch())),
83  refValuePtr_(fvPatchField<Type>::New(ptf.refValue(), p, iF, mapper))
84 {}
85 
86 
87 template<class Type>
89 (
91 )
92 :
93  fixedValueFvPatchField<Type>(spf),
94  scalePtr_(spf.scalePtr_.clone(spf.patch().patch())),
95  refValuePtr_(spf.refValue().clone())
96 {}
97 
98 
99 template<class Type>
101 (
102  const scaledFixedValueFvPatchField& spf,
104 )
105 :
106  fixedValueFvPatchField<Type>(spf, iF),
107  scalePtr_(spf.scalePtr_.clone(spf.patch().patch())),
108  refValuePtr_(spf.refValue().clone())
109 {}
110 
111 
112 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
113 
114 template<class Type>
116 (
117  const fvPatchFieldMapper& m
118 )
119 {
121  refValuePtr_->autoMap(m);
122 
123  scalePtr_().autoMap(m);
124 
125  if (scalePtr_().constant())
126  {
127  // If mapper is not dependent on time we're ok to evaluate
128  this->evaluate();
129  }
130 }
131 
132 
133 template<class Type>
135 (
136  const fvPatchField<Type>& ptf,
137  const labelList& addr
138 )
139 {
141 
142  const scaledFixedValueFvPatchField& sptf =
143  refCast<const scaledFixedValueFvPatchField>(ptf);
144 
145  refValuePtr_->rmap(sptf.refValue(), addr);
146 
147  scalePtr_().rmap(sptf.scalePtr_(), addr);
148 }
149 
150 
151 template<class Type>
153 {
154  if (this->updated())
155  {
156  return;
157  }
158 
159  refValuePtr_->evaluate();
160 
161  const scalarField s(scalePtr_->value(this->db().time().timeOutputValue()));
162 
163  // Note: setting this field value using = operator (not ==)
164  Field<Type>::operator=(s*refValuePtr_());
165 
167 }
168 
169 
170 template<class Type>
172 {
174 
175  scalePtr_->writeData(os);
176 
177  os.beginBlock("refValue");
178  refValuePtr_->write(os);
179  os.endBlock();
180 }
181 
182 
183 template<class Type>
185 (
186  const fvPatchField<Type>& ptf
187 )
188 {
189  const scalarField s(scalePtr_->value(this->db().time().timeOutputValue()));
190 
191  forAll(s, facei)
192  {
193  const scalar si = s[facei];
194  if (mag(si) > ROOTVSMALL)
195  {
196  refValuePtr_->operator[](facei) = ptf[facei]/si;
197  }
198  }
199 
201 }
202 
203 
204 template<class Type>
206 {
207  const scalarField s(scalePtr_->value(this->db().time().timeOutputValue()));
208 
209  forAll(s, facei)
210  {
211  const scalar si = s[facei];
212  if (mag(si) > ROOTVSMALL)
213  {
214  refValuePtr_->operator[](facei) = tf[facei]/si;
215  }
216  }
217 
219 }
220 
221 
222 template<class Type>
224 {
225  const scalarField s(scalePtr_->value(this->db().time().timeOutputValue()));
226 
227  forAll(s, facei)
228  {
229  const scalar si = s[facei];
230  if (mag(si) > ROOTVSMALL)
231  {
232  refValuePtr_->operator[](facei) = t/si;
233  }
234  }
235 
237 }
238 
239 
240 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:47
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:63
volFields.H
Foam::fvPatchField::write
virtual void write(Ostream &) const
Definition: fvPatchField.C:377
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:46
p
volScalarField & p
Definition: createFieldRefs.H:8
s
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;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputSpray.H:25
Foam::FatalIOError
IOerror FatalIOError
Foam::Ostream::beginBlock
virtual Ostream & beginBlock(const keyType &kw)
Definition: Ostream.C:84
Foam::scaledFixedValueFvPatchField
This condition applies a scalar multiplier to the value of another boundary condition.
Definition: scaledFixedValueFvPatchField.H:100
Foam::fixedValueFvPatchField
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
Definition: fixedValueFvPatchField.H:76
forAll
#define forAll(list, i)
Definition: stdFoam.H:349
Foam::scaledFixedValueFvPatchField::scalePtr_
autoPtr< PatchFunction1< scalar > > scalePtr_
Definition: scaledFixedValueFvPatchField.H:109
Foam::scaledFixedValueFvPatchField::write
virtual void write(Ostream &) const
Definition: scaledFixedValueFvPatchField.C:164
Foam::Field
Generic templated field type.
Definition: Field.H:59
Foam::operator==
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Foam::scaledFixedValueFvPatchField::autoMap
virtual void autoMap(const fvPatchFieldMapper &m)
Definition: scaledFixedValueFvPatchField.C:109
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::scaledFixedValueFvPatchField::scaledFixedValueFvPatchField
scaledFixedValueFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Definition: scaledFixedValueFvPatchField.C:29
Foam::scaledFixedValueFvPatchField::refValue
const fvPatchField< Type > & refValue() const
Definition: scaledFixedValueFvPatchField.H:185
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::Ostream::endBlock
virtual Ostream & endBlock()
Definition: Ostream.C:102
Foam::fvPatchField< Type >::rmap
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Definition: fvPatchField.C:304
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:119
os
OBJstream os(runTime.globalPath()/outputName)
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::PatchFunction1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: PatchFunction1.H:56
Foam::Ostream::write
virtual bool write(const token &tok)=0
Foam::fvPatchField< Type >::updateCoeffs
virtual void updateCoeffs()
Definition: fvPatchField.C:314
Foam::Field::operator=
void operator=(const Field< Type > &)
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Definition: DimensionedFieldReuseFunctions.H:100
Foam::isA
const TargetType * isA(const Type &t)
Definition: typeInfo.H:210
Foam::foamVersion::patch
const std::string patch
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:58
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::scaledFixedValueFvPatchField::operator==
virtual void operator==(const fvPatchField< Type > &ptf)
Definition: scaledFixedValueFvPatchField.C:178
Foam::fvPatchField::clone
virtual tmp< fvPatchField< Type > > clone() const
Definition: fvPatchField.H:215
Foam::scaledFixedValueFvPatchField::updateCoeffs
virtual void updateCoeffs()
Definition: scaledFixedValueFvPatchField.C:145
Foam::vtk::write
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Definition: foamVtkOutputTemplates.C:29
Foam::fvPatch::patch
const polyPatch & patch() const
Definition: fvPatch.H:157
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Definition: error.H:494
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:41
Foam::fvPatchField::patch
const fvPatch & patch() const
Definition: fvPatchField.H:353
Foam::scaledFixedValueFvPatchField::refValuePtr_
tmp< fvPatchField< Type > > refValuePtr_
Definition: scaledFixedValueFvPatchField.H:112
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:52
constant
constant condensation/saturation model.
Foam::scaledFixedValueFvPatchField::rmap
virtual void rmap(const fvPatchField< Type > &ptf, const labelList &addr)
Definition: scaledFixedValueFvPatchField.C:128
Foam::fvPatchField< Type >::autoMap
virtual void autoMap(const fvPatchFieldMapper &)
Definition: fvPatchField.C:241
scaledFixedValueFvPatchField.H
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:50
Foam::stringOps::evaluate
string evaluate(label fieldWidth, const std::string &s, size_t pos=0, size_t len=std::string::npos)
Definition: stringOpsEvaluate.C:30