vorticity.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 | Copyright (C) 2014 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 
26 #include "vorticity.H"
27 #include "volFields.H"
28 #include "dictionary.H"
29 #include "fvcCurl.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(vorticity, 0);
36 }
37 
38 
39 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 
41 Foam::vorticity::vorticity
42 (
43  const word& name,
44  const objectRegistry& obr,
45  const dictionary& dict,
46  const bool loadFromFiles
47 )
48 :
49  name_(name),
50  obr_(obr),
51  active_(true),
52  UName_("U"),
53  outputName_(typeName)
54 {
55  // Check if the available mesh is an fvMesh, otherwise deactivate
56  if (!isA<fvMesh>(obr_))
57  {
58  active_ = false;
59  WarningIn
60  (
61  "vorticity::vorticity"
62  "("
63  "const word&, "
64  "const objectRegistry&, "
65  "const dictionary&, "
66  "const bool"
67  ")"
68  ) << "No fvMesh available, deactivating " << name_ << nl
69  << endl;
70  }
71 
72  read(dict);
73 
74  if (active_)
75  {
76  const fvMesh& mesh = refCast<const fvMesh>(obr_);
77 
78  volVectorField* vorticityPtr
79  (
80  new volVectorField
81  (
82  IOobject
83  (
84  outputName_,
85  mesh.time().timeName(),
86  mesh,
89  ),
90  mesh,
92  )
93  );
94 
95  mesh.objectRegistry::store(vorticityPtr);
96  }
97 }
98 
99 
100 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
101 
103 {}
104 
105 
106 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
107 
109 {
110  if (active_)
111  {
112  UName_ = dict.lookupOrDefault<word>("UName", "U");
113  if (UName_ != "U")
114  {
115  outputName_ = typeName + "(" + UName_ + ")";
116  }
117  }
118 }
119 
120 
122 {
123  if (active_)
124  {
125  const volVectorField& U = obr_.lookupObject<volVectorField>(UName_);
126 
128  const_cast<volVectorField&>
129  (
130  obr_.lookupObject<volVectorField>(outputName_)
131  );
132 
133  vorticity = fvc::curl(U);
134  }
135 }
136 
137 
139 {
140  if (active_)
141  {
142  execute();
143  }
144 }
145 
146 
148 {
149  // Do nothing
150 }
151 
152 
154 {
155  if (active_)
156  {
157  const volVectorField& vorticity =
158  obr_.lookupObject<volVectorField>(outputName_);
159 
160  Info<< type() << " " << name_ << " output:" << nl
161  << " writing field " << vorticity.name() << nl
162  << endl;
163 
164  vorticity.write();
165  }
166 }
167 
168 
169 // ************************************************************************* //
virtual void execute()
Execute, currently does nothing.
Definition: vorticity.C:121
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: vorticity.C:147
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
This function object calculates the vorticity, the curl of the velocity.
Definition: vorticity.H:58
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
tmp< GeometricField< Type, fvPatchField, volMesh > > curl(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition: fvcCurl.C:45
virtual void write()
Calculate the vorticity and write.
Definition: vorticity.C:153
A class for handling words, derived from string.
Definition: word.H:59
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Definition: Time.C:741
messageStream Info
dynamicFvMesh & mesh
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Namespace for OpenFOAM.
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:243
virtual bool write() const
Write using setting from DB.
Calculate the curl of the given volField by constructing the Hodge-dual of the symmetric part of the ...
static const char nl
Definition: Ostream.H:260
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
#define WarningIn(functionName)
Report a warning using Foam::Warning.
virtual ~vorticity()
Destructor.
Definition: vorticity.C:102
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
virtual void read(const dictionary &)
Read the vorticity data.
Definition: vorticity.C:108
const word & name() const
Return name.
Definition: IOobject.H:260
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:589
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: vorticity.C:138
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Registry of regIOobjects.
static const Vector zero
Definition: Vector.H:80
bool read(const char *, int32_t &)
Definition: int32IO.C:87
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47
U
Definition: pEqn.H:82
defineTypeNameAndDebug(combustionModel, 0)