fixedProfileFvPatchField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2015-2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class Type>
32 (
33  const fvPatch& p,
35 )
36 :
38  profile_(),
39  dir_(Zero),
40  origin_(0)
41 {}
42 
43 
44 template<class Type>
46 (
47  const fvPatch& p,
49  const Field<Type>& fld
50 )
51 :
53  profile_(),
54  dir_(Zero),
55  origin_(0)
56 {}
57 
58 
59 template<class Type>
61 (
62  const fvPatch& p,
64  const dictionary& dict
65 )
66 :
67  fixedValueFvPatchField<Type>(p, iF, dict, false),
68  profile_(Function1<Type>::New("profile", dict)),
69  dir_(dict.lookup("direction")),
70  origin_(readScalar(dict.lookup("origin")))
71 {
72  if (mag(dir_) < small)
73  {
75  << "magnitude Direction must be greater than zero"
76  << abort(FatalError);
77  }
78 
79  // Ensure direction vector is normalized
80  dir_ /= mag(dir_);
81 
82  // Evaluate profile
83  this->evaluate();
84 }
85 
86 
87 template<class Type>
89 (
91  const fvPatch& p,
93  const fvPatchFieldMapper& mapper
94 )
95 :
96  fixedValueFvPatchField<Type>(p, iF), // Don't map
97  profile_(ptf.profile_, false),
98  dir_(ptf.dir_),
99  origin_(ptf.origin_)
100 {
101  // Evaluate profile since value not mapped
102  this->evaluate();
103 }
104 
105 
106 template<class Type>
108 (
110 )
111 :
113  profile_(ptf.profile_, false),
114  dir_(ptf.dir_),
115  origin_(ptf.origin_)
116 {}
117 
118 
119 template<class Type>
121 (
124 )
125 :
127  profile_(ptf.profile_, false),
128  dir_(ptf.dir_),
129  origin_(ptf.origin_)
130 {
131  // Evaluate the profile if defined
132  if (ptf.profile_.valid())
133  {
134  this->evaluate();
135  }
136 }
137 
138 
139 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
140 
141 template<class Type>
143 {
144  if (this->updated())
145  {
146  return;
147  }
148 
149  const scalarField dirCmpt((dir_ & this->patch().Cf()) - origin_);
150  fvPatchField<Type>::operator==(profile_->value(dirCmpt));
151 
153 }
154 
155 
156 template<class Type>
158 {
160  writeEntry(os, profile_());
161  writeEntry(os, "direction", dir_);
162  writeEntry(os, "origin", origin_);
163  writeEntry(os, "value", *this);
164 }
165 
166 
167 // ************************************************************************* //
#define readScalar
Definition: doubleScalar.C:38
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:53
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
fixedProfileFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
dictionary dict
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
void write(Ostream &, const label, const dictionary &)
Write with dictionary lookup.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Pre-declare SubField and related Field type.
Definition: Field.H:56
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
Foam::fvPatchFieldMapper.
static const zero Zero
Definition: zero.H:97
errorManip< error > abort(error &err)
Definition: errorManip.H:131
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
This boundary condition provides a fixed value profile condition.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
dimensioned< scalar > mag(const dimensioned< Type > &)
virtual void write(Ostream &) const
Write.
volScalarField & p