fixedProfileFvPatchField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2015-2016 OpenFOAM Foundation
9  Copyright (C) 2020-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class Type>
35 (
36  const fvPatch& p,
38 )
39 :
40  fixedValueFvPatchField<Type>(p, iF),
41  profile_(),
42  dir_(Zero),
43  origin_(0)
44 {}
45 
46 
47 template<class Type>
49 (
50  const fvPatch& p,
52  const Field<Type>& fld
53 )
54 :
55  fixedValueFvPatchField<Type>(p, iF, fld),
56  profile_(),
57  dir_(Zero),
58  origin_(0)
59 {}
60 
61 
62 template<class Type>
64 (
65  const fvPatch& p,
67  const dictionary& dict
68 )
69 :
70  fixedValueFvPatchField<Type>(p, iF, dict, false),
71  profile_(Function1<Type>::New("profile", dict, &this->db())),
72  dir_(dict.lookup("direction")),
73  origin_(dict.get<scalar>("origin"))
74 {
75  if (mag(dir_) < SMALL)
76  {
78  << "magnitude Direction must be greater than zero"
79  << abort(FatalError);
80  }
81 
82  // Ensure direction vector is normalized
83  dir_ /= mag(dir_);
84 
85  // Evaluate profile
86  this->evaluate();
87 }
88 
89 
90 template<class Type>
92 (
94  const fvPatch& p,
96  const fvPatchFieldMapper& mapper
97 )
98 :
99  fixedValueFvPatchField<Type>(p, iF), // Don't map
100  profile_(ptf.profile_.clone()),
101  dir_(ptf.dir_),
102  origin_(ptf.origin_)
103 {
104  // Evaluate profile since value not mapped
105  this->evaluate();
106 }
107 
108 
109 template<class Type>
111 (
113 )
114 :
115  fixedValueFvPatchField<Type>(ptf),
116  profile_(ptf.profile_.clone()),
117  dir_(ptf.dir_),
118  origin_(ptf.origin_)
119 {}
120 
121 
122 template<class Type>
124 (
127 )
128 :
129  fixedValueFvPatchField<Type>(ptf, iF),
130  profile_(ptf.profile_.clone()),
131  dir_(ptf.dir_),
132  origin_(ptf.origin_)
133 {
134  // Evaluate the profile if defined
135  if (ptf.profile_)
136  {
137  this->evaluate();
138  }
139 }
140 
141 
142 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
143 
144 template<class Type>
146 {
147  if (this->updated())
148  {
149  return;
150  }
151 
152  const scalarField dirCmpt((dir_ & this->patch().Cf()) - origin_);
153  fvPatchField<Type>::operator==(profile_->value(dirCmpt));
154 
156 }
157 
158 
159 template<class Type>
161 {
163  profile_->writeData(os);
164  os.writeEntry("direction", dir_);
165  os.writeEntry("origin", origin_);
166  this->writeEntry("value", os);
167 }
168 
169 
170 // ************************************************************************* //
Foam::fvPatchField::write
virtual void write(Ostream &) const
Definition: fvPatchField.C:377
Foam::fvPatchField::operator==
virtual void operator==(const fvPatchField< Type > &)
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:46
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::Zero
static constexpr const zero Zero
Definition: zero.H:131
Foam::Function1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: propellerInfo.H:287
Foam::fixedValueFvPatchField
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
Definition: fixedValueFvPatchField.H:76
Foam::fixedProfileFvPatchField
This boundary condition provides a fixed value profile condition.
Definition: fixedProfileFvPatchField.H:127
fixedProfileFvPatchField.H
Foam::Field< Type >
Foam::operator==
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::fixedProfileFvPatchField::updateCoeffs
virtual void updateCoeffs()
Definition: fixedProfileFvPatchField.C:138
Foam::fvPatchField< Type >::evaluate
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Definition: fvPatchField.C:334
Foam::radiation::lookup
Lookup type of boundary radiation properties.
Definition: lookup.H:57
fld
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputLagrangian.H:23
Foam::fixedProfileFvPatchField::write
virtual void write(Ostream &) const
Definition: fixedProfileFvPatchField.C:153
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:119
os
OBJstream os(runTime.globalPath()/outputName)
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:139
Foam::fvPatchField< Type >::updateCoeffs
virtual void updateCoeffs()
Definition: fvPatchField.C:314
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Definition: DimensionedFieldReuseFunctions.H:100
FatalErrorInFunction
#define FatalErrorInFunction
Definition: error.H:465
Foam::foamVersion::patch
const std::string patch
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Definition: Ostream.H:232
Foam::vtk::write
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Definition: foamVtkOutputTemplates.C:29
Foam::PtrListOps::get
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:41
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:52
Foam::fixedProfileFvPatchField::fixedProfileFvPatchField
fixedProfileFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Definition: fixedProfileFvPatchField.C:28
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:50
Foam::stringOps::evaluate
string evaluate(label fieldWidth, const std::string &s, size_t pos=0, size_t len=std::string::npos)
Definition: stringOpsEvaluate.C:30