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-2023 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  const Field<Type>& fld
36 )
37 :
38  fixedValueFvPatchField<Type>(p, iF, fld),
39  profile_(),
40  origin_(0),
41  direction_(Zero)
42 {}
43 
44 
45 template<class Type>
47 (
48  const fvPatch& p,
50  const dictionary& dict
51 )
52 :
53  fixedValueFvPatchField<Type>(p, iF, dict, false),
54  profile_(Function1<Type>::New("profile", dict)),
55  origin_(dict.lookup<scalar>("origin")),
56  direction_(dict.lookup("direction"))
57 {
58  if (mag(direction_) == 0)
59  {
61  << "The direction must be non-zero"
62  << abort(FatalError);
63  }
64 
65  // Normalise the direction
66  direction_ /= mag(direction_);
67 
68  // Evaluate profile
69  this->evaluate();
70 }
71 
72 
73 template<class Type>
75 (
77  const fvPatch& p,
79  const fvPatchFieldMapper& mapper
80 )
81 :
82  fixedValueFvPatchField<Type>(p, iF), // Don't map
83  profile_(ptf.profile_, false),
84  origin_(ptf.origin_),
85  direction_(ptf.direction_)
86 {
87  // Evaluate profile since value not mapped
88  this->evaluate();
89 }
90 
91 
92 template<class Type>
94 (
97 )
98 :
99  fixedValueFvPatchField<Type>(ptf, iF),
100  profile_(ptf.profile_, false),
101  origin_(ptf.origin_),
102  direction_(ptf.direction_)
103 {
104  // Evaluate the profile if defined
105  if (ptf.profile_.valid())
106  {
107  this->evaluate();
108  }
109 }
110 
111 
112 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
113 
114 template<class Type>
116 {
117  if (this->updated())
118  {
119  return;
120  }
121 
122  const scalarField dirCmpt((direction_ & this->patch().Cf()) - origin_);
123 
124  fvPatchField<Type>::operator==(profile_->value(dirCmpt));
125 
127 }
128 
129 
130 template<class Type>
132 {
134  writeEntry(os, profile_());
135  writeEntry(os, "direction", direction_);
136  writeEntry(os, "origin", origin_);
137  writeEntry(os, "value", *this);
138 }
139 
140 
141 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Pre-declare SubField and related Field type.
Definition: Field.H:82
Run-time selectable general function of one variable.
Definition: Function1.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
This boundary condition provides a fixed value profile condition.
virtual void write(Ostream &) const
Write.
fixedProfileFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &, const Field< Type > &fld)
Construct from patch and internal field and patch field.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
Foam::fvPatchFieldMapper.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field, sets Updated to false.
Definition: fvPatchField.C:211
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:231
virtual void operator==(const fvPatchField< Type > &)
Definition: fvPatchField.C:417
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:204
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
gmvFile<< "tracers "<< particles.size()<< nl;{ pointField positions(particles.size());label particlei=0;forAllConstIter(Cloud< passiveParticle >, particles, iter) { positions[particlei++]=iter().position(mesh);} for(i=0;i< pTraits< point >::nComponents;i++) { forAll(positions, particlei) { gmvFile<< component(positions[particlei], i)<< ' ';} gmvFile<< nl;}}forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
static const zero Zero
Definition: zero.H:97
errorManip< error > abort(error &err)
Definition: errorManip.H:131
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
dimensioned< scalar > mag(const dimensioned< Type > &)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
error FatalError
dictionary dict
volScalarField & p