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-2024 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_
55  (
56  Function1<Type>::New("profile", dimLength, iF.dimensions(), dict)
57  ),
58  origin_(dict.lookup<scalar>("origin", dimLength)),
59  direction_(dict.lookup<vector>("direction", dimless))
60 {
61  if (mag(direction_) == 0)
62  {
64  << "The direction must be non-zero"
65  << abort(FatalError);
66  }
67 
68  // Normalise the direction
69  direction_ /= mag(direction_);
70 
71  // Evaluate profile
72  this->evaluate();
73 }
74 
75 
76 template<class Type>
78 (
80  const fvPatch& p,
82  const fieldMapper& mapper
83 )
84 :
85  fixedValueFvPatchField<Type>(p, iF), // Don't map
86  profile_(ptf.profile_, false),
87  origin_(ptf.origin_),
88  direction_(ptf.direction_)
89 {
90  // Evaluate profile since value not mapped
91  this->evaluate();
92 }
93 
94 
95 template<class Type>
97 (
100 )
101 :
102  fixedValueFvPatchField<Type>(ptf, iF),
103  profile_(ptf.profile_, false),
104  origin_(ptf.origin_),
105  direction_(ptf.direction_)
106 {
107  // Evaluate the profile if defined
108  if (ptf.profile_.valid())
109  {
110  this->evaluate();
111  }
112 }
113 
114 
115 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
116 
117 template<class Type>
119 {
120  if (this->updated())
121  {
122  return;
123  }
124 
125  const scalarField dirCmpt((direction_ & this->patch().Cf()) - origin_);
126 
127  fvPatchField<Type>::operator==(profile_->value(dirCmpt));
128 
130 }
131 
132 
133 template<class Type>
135 {
137  writeEntry(os, profile_());
138  writeEntry(os, "direction", direction_);
139  writeEntry(os, "origin", origin_);
140  writeEntry(os, "value", *this);
141 }
142 
143 
144 // ************************************************************************* //
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:83
Run-time selectable general function of one variable.
Definition: Function1.H:125
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:162
Abstract base class for field mapping.
Definition: fieldMapper.H:48
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...
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field, sets Updated to false.
Definition: fvPatchField.C:209
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:229
virtual void operator==(const fvPatchField< Type > &)
Definition: fvPatchField.C:415
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:202
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:334
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
const HashTable< dimensionSet > & dimensions()
Get the table of dimension sets.
Definition: dimensionSets.C:96
errorManip< error > abort(error &err)
Definition: errorManip.H:131
const dimensionSet dimless
const dimensionSet dimLength
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