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-2020 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 (
111 )
112 :
114  profile_(ptf.profile_, false),
115  origin_(ptf.origin_),
116  direction_(ptf.direction_)
117 {
118  // Evaluate the profile if defined
119  if (ptf.profile_.valid())
120  {
121  this->evaluate();
122  }
123 }
124 
125 
126 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
127 
128 template<class Type>
130 {
131  if (this->updated())
132  {
133  return;
134  }
135 
136  const scalarField dirCmpt((direction_ & this->patch().Cf()) - origin_);
137 
138  fvPatchField<Type>::operator==(profile_->value(dirCmpt));
139 
141 }
142 
143 
144 template<class Type>
146 {
148  writeEntry(os, profile_());
149  writeEntry(os, "direction", direction_);
150  writeEntry(os, "origin", origin_);
151  writeEntry(os, "value", *this);
152 }
153 
154 
155 // ************************************************************************* //
Run-time selectable general function of one variable.
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
void evaluate(GeometricField< Type, PatchField, GeoMesh > &result, const Function1< Type > &func, const GeometricField< Type, PatchField, GeoMesh > &x)
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:323
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:62
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