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-2025 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 dictionary& dict
36 )
37 :
38  fixedValueFvPatchField<Type>(p, iF, dict, false),
39  profile_
40  (
41  Function1<Type>::New("profile", dimLength, iF.dimensions(), dict)
42  ),
43  origin_(dict.lookup<scalar>("origin", dimLength)),
44  direction_(dict.lookup<vector>("direction", dimless))
45 {
46  if (mag(direction_) == 0)
47  {
49  << "The direction must be non-zero"
50  << abort(FatalError);
51  }
52 
53  // Normalise the direction
54  direction_ /= mag(direction_);
55 
56  // Evaluate profile
57  this->evaluate();
58 }
59 
60 
61 template<class Type>
63 (
65  const fvPatch& p,
67  const fieldMapper& mapper
68 )
69 :
70  fixedValueFvPatchField<Type>(p, iF), // Don't map
71  profile_(ptf.profile_, false),
72  origin_(ptf.origin_),
73  direction_(ptf.direction_)
74 {
75  // Evaluate profile since value not mapped
76  this->evaluate();
77 }
78 
79 
80 template<class Type>
82 (
85 )
86 :
87  fixedValueFvPatchField<Type>(ptf, iF),
88  profile_(ptf.profile_, false),
89  origin_(ptf.origin_),
90  direction_(ptf.direction_)
91 {
92  // Evaluate the profile if defined
93  if (ptf.profile_.valid())
94  {
95  this->evaluate();
96  }
97 }
98 
99 
100 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
101 
102 template<class Type>
104 {
105  if (this->updated())
106  {
107  return;
108  }
109 
110  const scalarField dirCmpt((direction_ & this->patch().Cf()) - origin_);
111 
112  fvPatchField<Type>::operator==(profile_->value(dirCmpt));
113 
115 }
116 
117 
118 template<class Type>
120 {
122  writeEntry(os, profile_());
123  writeEntry(os, "direction", direction_);
124  writeEntry(os, "origin", origin_);
125  writeEntry(os, "value", *this);
126 }
127 
128 
129 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
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 keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
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.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
fixedProfileFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
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:217
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:237
virtual void operator==(const fvPatchField< Type > &)
Definition: fvPatchField.C:423
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:210
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
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
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 mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
error FatalError
dictionary dict
volScalarField & p