uniformFixedValuePointPatchField.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) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 \*---------------------------------------------------------------------------*/
28 
30 #include "SubField.H"
31 #include "polyPatch.H"
32 
33 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
34 
35 template<class Type>
36 const Foam::polyPatch&
38 {
39  const polyMesh& mesh = p.boundaryMesh().mesh()();
40  label patchi = mesh.boundaryMesh().findPatchID(p.name());
41 
42  if (patchi == -1)
43  {
45  << "Cannot use uniformFixedValue on patch " << p.name()
46  << " since there is no underlying mesh patch" << exit(FatalError);
47  }
48  return mesh.boundaryMesh()[patchi];
49 }
50 
51 
52 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
53 
54 template<class Type>
57 (
58  const pointPatch& p,
60 )
61 :
63  uniformValue_()
64 {}
65 
66 
67 template<class Type>
70 (
71  const pointPatch& p,
73  const dictionary& dict
74 )
75 :
77  uniformValue_
78  (
80  (
81  this->getPatch(p),
82  "uniformValue",
83  dict,
84  false // generate point values
85  )
86  )
87 {
88  if (dict.found("value"))
89  {
91  (
92  Field<Type>("value", dict, p.size())
93  );
94  }
95  else
96  {
97  this->evaluate();
98  }
99 }
100 
101 
102 template<class Type>
105 (
107  const pointPatch& p,
109  const pointPatchFieldMapper& mapper
110 )
111 :
112  fixedValuePointPatchField<Type>(ptf, p, iF, mapper),
113  uniformValue_(ptf.uniformValue_.clone(this->getPatch(p)))
114 {
115  if (mapper.direct() && !mapper.hasUnmapped())
116  {
117  // Use mapping instead of re-evaluation
118  this->map(ptf, mapper);
119  }
120  else
121  {
122  // Evaluate since value not mapped
123  this->evaluate();
124  }
125 }
126 
127 
128 template<class Type>
131 (
133 )
134 :
136  uniformValue_(ptf.uniformValue_.clone(this->getPatch(this->patch())))
137 {}
138 
139 
140 template<class Type>
143 (
146 )
147 :
149  uniformValue_(ptf.uniformValue_.clone(this->getPatch(this->patch())))
150 {}
151 
152 
153 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
154 
155 template<class Type>
157 (
158  const pointPatchFieldMapper& mapper
159 )
160 {
162  uniformValue_().autoMap(mapper);
163 
164  if (uniformValue_().constant())
165  {
166  // If mapper is not dependent on time we're ok to evaluate
167  this->evaluate();
168  }
169 }
170 
171 
172 template<class Type>
174 (
175  const pointPatchField<Type>& ptf,
176  const labelList& addr
177 )
178 {
180 
181  const uniformFixedValuePointPatchField& tiptf =
182  refCast<const uniformFixedValuePointPatchField>(ptf);
183 
184  uniformValue_().rmap(tiptf.uniformValue_(), addr);
185 }
186 
187 
188 template<class Type>
190 {
191  if (this->updated())
192  {
193  return;
194  }
195  const scalar t = this->db().time().timeOutputValue();
196  fixedValuePointPatchField<Type>::operator==(uniformValue_->value(t));
198 }
199 
200 
201 template<class Type>
203 write(Ostream& os) const
204 {
205  // Note: write value
207  uniformValue_->writeData(os);
208 }
209 
210 
211 // ************************************************************************* //
p
volScalarField & p
Definition: createFieldRefs.H:8
SubField.H
uniformFixedValuePointPatchField.H
polyPatch.H
Foam::pointPatch
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:58
Foam::FieldMapper::direct
virtual bool direct() const =0
Foam::FieldMapper::hasUnmapped
virtual bool hasUnmapped() const =0
Are there unmapped values? I.e. do all size() elements get.
Foam::pointPatchField
Abstract base class for point-mesh patch fields.
Definition: pointMVCWeight.H:60
Foam::pointPatchFieldMapper
Foam::pointPatchFieldMapper.
Definition: pointPatchFieldMapper.H:48
Foam::fixedValuePointPatchField
A FixedValue boundary condition for pointField.
Definition: fixedValuePointPatchField.H:51
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::operator==
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
Foam::uniformFixedValuePointPatchField::uniformFixedValuePointPatchField
uniformFixedValuePointPatchField(const pointPatch &, const DimensionedField< Type, pointMesh > &)
Construct from patch and internal field.
Definition: uniformFixedValuePointPatchField.C:57
Foam::uniformFixedValuePointPatchField::rmap
virtual void rmap(const pointPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: uniformFixedValuePointPatchField.C:174
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::PatchFunction1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: PatchFunction1.H:60
Foam::uniformFixedValuePointPatchField
Enables the specification of a uniform fixed value boundary condition.
Definition: uniformFixedValuePointPatchField.H:68
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::uniformFixedValuePointPatchField::write
virtual void write(Ostream &) const
Write.
Definition: uniformFixedValuePointPatchField.C:203
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::uniformFixedValuePointPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: uniformFixedValuePointPatchField.C:189
Foam::List< label >
Foam::vtk::write
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
Definition: foamVtkOutputTemplates.C:36
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::uniformFixedValuePointPatchField::autoMap
virtual void autoMap(const pointPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: uniformFixedValuePointPatchField.C:157
constant
constant condensation/saturation model.
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54
Foam::stringOps::evaluate
string evaluate(label fieldWidth, const std::string &s, size_t pos=0, size_t len=std::string::npos)
String evaluation with specified (positive, non-zero) field width.
Definition: stringOpsEvaluate.C:37