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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
32 template<class Type>
34 (
35  const fvPatch& p,
37 )
38 :
40  profile_(),
41  dir_(Zero),
42  origin_(0)
43 {}
44 
45 
46 template<class Type>
48 (
49  const fvPatch& p,
51  const Field<Type>& fld
52 )
53 :
55  profile_(),
56  dir_(Zero),
57  origin_(0)
58 {}
59 
60 
61 template<class Type>
63 (
64  const fvPatch& p,
66  const dictionary& dict
67 )
68 :
69  fixedValueFvPatchField<Type>(p, iF, dict, false),
70  profile_(Function1<Type>::New("profile", dict)),
71  dir_(dict.lookup("direction")),
72  origin_(dict.get<scalar>("origin"))
73 {
74  if (mag(dir_) < SMALL)
75  {
77  << "magnitude Direction must be greater than zero"
78  << abort(FatalError);
79  }
80 
81  // Ensure direction vector is normalized
82  dir_ /= mag(dir_);
83 
84  // Evaluate profile
85  this->evaluate();
86 }
87 
88 
89 template<class Type>
91 (
93  const fvPatch& p,
95  const fvPatchFieldMapper& mapper
96 )
97 :
98  fixedValueFvPatchField<Type>(p, iF), // Don't map
99  profile_(ptf.profile_.clone()),
100  dir_(ptf.dir_),
101  origin_(ptf.origin_)
102 {
103  // Evaluate profile since value not mapped
104  this->evaluate();
105 }
106 
107 
108 template<class Type>
110 (
112 )
113 :
115  profile_(ptf.profile_.clone()),
116  dir_(ptf.dir_),
117  origin_(ptf.origin_)
118 {}
119 
120 
121 template<class Type>
123 (
126 )
127 :
129  profile_(ptf.profile_.clone()),
130  dir_(ptf.dir_),
131  origin_(ptf.origin_)
132 {
133  // Evaluate the profile if defined
134  if (ptf.profile_.valid())
135  {
136  this->evaluate();
137  }
138 }
139 
140 
141 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
142 
143 template<class Type>
145 {
146  if (this->updated())
147  {
148  return;
149  }
150 
151  const scalarField dirCmpt((dir_ & this->patch().Cf()) - origin_);
152  fvPatchField<Type>::operator==(profile_->value(dirCmpt));
153 
155 }
156 
157 
158 template<class Type>
160 {
162  profile_->writeData(os);
163  os.writeEntry("direction", dir_);
164  os.writeEntry("origin", origin_);
165  this->writeEntry("value", os);
166 }
167 
168 
169 // ************************************************************************* //
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::Zero
static constexpr const zero Zero
Global zero.
Definition: zero.H:128
Foam::Function1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:56
Foam::fixedValueFvPatchField
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
Definition: fixedValueFvPatchField.H:80
Foam::fixedProfileFvPatchField
This boundary condition provides a fixed value profile condition.
Definition: fixedProfileFvPatchField.H:131
fixedProfileFvPatchField.H
Foam::Field
Generic templated field type.
Definition: Field.H:63
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:63
Foam::fixedProfileFvPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fixedProfileFvPatchField.C:144
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
Write.
Definition: fixedProfileFvPatchField.C:159
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:121
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:137
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:355
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:219
Foam::vtk::write
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
Definition: foamVtkOutputTemplates.C:35
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::fixedProfileFvPatchField::fixedProfileFvPatchField
fixedProfileFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: fixedProfileFvPatchField.C:34
Foam::stringOps::evaluate
string evaluate(const std::string &s, size_t pos=0, size_t len=std::string::npos)
Definition: stringOpsEvaluate.C:37
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54