surfaceNormalFixedValueFvPatchVectorField.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-2016 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 
31 #include "volFields.H"
32 #include "fvPatchFieldMapper.H"
33 
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 
38 (
39  const fvPatch& p,
41 )
42 :
43  fixedValueFvPatchVectorField(p, iF),
44  refValue_(p.size()),
45  ramp_(nullptr)
46 {}
47 
48 
51 (
52  const fvPatch& p,
54  const dictionary& dict
55 )
56 :
57  fixedValueFvPatchVectorField(p, iF, dict, false),
58  refValue_("refValue", dict, p.size()),
59  ramp_(nullptr)
60 {
61  if (dict.found("ramp"))
62  {
63  ramp_ = Function1<scalar>::New("ramp", dict);
64  }
65 
66  tmp<vectorField> tvalues(refValue_*patch().nf());
67 
68  if (ramp_)
69  {
70  tvalues.ref() *= ramp_->value(this->db().time().timeOutputValue());
71  }
72 
73  fvPatchVectorField::operator=(tvalues);
74 }
75 
76 
79 (
81  const fvPatch& p,
83  const fvPatchFieldMapper& mapper
84 )
85 :
86  fixedValueFvPatchVectorField(p, iF),
87  refValue_(ptf.refValue_, mapper, pTraits<scalar>::zero),
88  ramp_(ptf.ramp_.clone())
89 {
90  // Note: refValue_ will have default value of 0 for unmapped faces. This
91  // can temporarily happen during e.g. redistributePar. We should not
92  // access ptf.patch() instead since redistributePar has destroyed this
93  // at the time of mapping.
94 
95  tmp<vectorField> tvalues(refValue_*patch().nf());
96 
97  if (ramp_)
98  {
99  tvalues.ref() *= ramp_->value(this->db().time().timeOutputValue());
100  }
101 
102  fvPatchVectorField::operator=(tvalues);
103 }
104 
105 
108 (
110 )
111 :
112  fixedValueFvPatchVectorField(ptf),
113  refValue_(ptf.refValue_),
114  ramp_(ptf.ramp_.clone())
115 {}
116 
117 
120 (
123 )
124 :
125  fixedValueFvPatchVectorField(ptf, iF),
126  refValue_(ptf.refValue_),
127  ramp_(ptf.ramp_.clone())
128 {}
129 
130 
131 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
132 
134 (
135  const fvPatchFieldMapper& mapper
136 )
137 {
138  fixedValueFvPatchVectorField::autoMap(mapper);
139  refValue_.autoMap(mapper);
140 }
141 
142 
144 (
145  const fvPatchVectorField& ptf,
146  const labelList& addr
147 )
148 {
149  fixedValueFvPatchVectorField::rmap(ptf, addr);
150 
152  refCast<const surfaceNormalFixedValueFvPatchVectorField>(ptf);
153 
154  refValue_.rmap(tiptf.refValue_, addr);
155 }
156 
157 
159 {
160  if (updated())
161  {
162  return;
163  }
164 
165  tmp<vectorField> tvalues(refValue_*patch().nf());
166 
167  if (ramp_)
168  {
169  tvalues.ref() *= ramp_->value(this->db().time().timeOutputValue());
170  }
171 
174 }
175 
176 
178 {
180  refValue_.writeEntry("refValue", os);
181  if (ramp_)
182  {
183  ramp_->writeData(os);
184  }
185 }
186 
187 
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 
190 namespace Foam
191 {
193  (
196  );
197 }
198 
199 // ************************************************************************* //
Foam::fvPatchField< vector >
volFields.H
Foam::fvPatchField< vector >::write
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:364
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::surfaceNormalFixedValueFvPatchVectorField::write
virtual void write(Ostream &) const
Write.
Definition: surfaceNormalFixedValueFvPatchVectorField.C:177
fvPatchFieldMapper.H
Foam::surfaceNormalFixedValueFvPatchVectorField::autoMap
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: surfaceNormalFixedValueFvPatchVectorField.C:134
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:258
Foam::surfaceNormalFixedValueFvPatchVectorField::surfaceNormalFixedValueFvPatchVectorField
surfaceNormalFixedValueFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
Definition: surfaceNormalFixedValueFvPatchVectorField.C:38
surfaceNormalFixedValueFvPatchVectorField.H
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fvPatchField< vector >::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:313
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::surfaceNormalFixedValueFvPatchVectorField
This boundary condition provides a surface-normal vector boundary condition by its magnitude.
Definition: surfaceNormalFixedValueFvPatchVectorField.H:95
Foam::List< label >
Foam::pTraits
Traits class for primitives.
Definition: pTraits.H:52
Foam::surfaceNormalFixedValueFvPatchVectorField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: surfaceNormalFixedValueFvPatchVectorField.C:158
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::makePatchTypeField
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
Foam::fvPatchField< vector >::operator=
virtual void operator=(const UList< vector > &)
Definition: fvPatchField.C:379
Foam::surfaceNormalFixedValueFvPatchVectorField::rmap
virtual void rmap(const fvPatchVectorField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: surfaceNormalFixedValueFvPatchVectorField.C:144
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54