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  origin_(0),
40  direction_(Zero)
41 {}
42 
43 
44 template<class Type>
46 (
47  const fvPatch& p,
49  const Field<Type>& fld
50 )
51 :
53  profile_(),
54  origin_(0),
55  direction_(Zero)
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  origin_(dict.lookup<scalar>("origin")),
70  direction_(dict.lookup("direction"))
71 {
72  if (mag(direction_) == 0)
73  {
75  << "The direction must be non-zero"
76  << abort(FatalError);
77  }
78 
79  // Normalise the direction
80  direction_ /= mag(direction_);
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  origin_(ptf.origin_),
99  direction_(ptf.direction_)
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  origin_(ptf.origin_),
115  direction_(ptf.direction_)
116 {}
117 
118 
119 template<class Type>
121 (
124 )
125 :
127  profile_(ptf.profile_, false),
128  origin_(ptf.origin_),
129  direction_(ptf.direction_)
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((direction_ & this->patch().Cf()) - origin_);
150 
151  fvPatchField<Type>::operator==(profile_->value(dirCmpt));
152 
154 }
155 
156 
157 template<class Type>
159 {
161  writeEntry(os, profile_());
162  writeEntry(os, "direction", direction_);
163  writeEntry(os, "origin", origin_);
164  writeEntry(os, "value", *this);
165 }
166 
167 
168 // ************************************************************************* //
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:52
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
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.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
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:54
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