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-2015 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
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 
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  resultName_(name),
54  log_(true)
55 {
56  // Check if the available mesh is an fvMesh, otherwise deactivate
57  if (!isA<fvMesh>(obr_))
58  {
59  active_ = false;
61  << "No fvMesh available, deactivating " << name_ << nl
62  << endl;
63  }
64 
65  read(dict);
66 
67  if (active_)
68  {
69  const fvMesh& mesh = refCast<const fvMesh>(obr_);
70 
71  volVectorField* vorticityPtr
72  (
73  new volVectorField
74  (
75  IOobject
76  (
77  resultName_,
78  mesh.time().timeName(),
79  mesh,
80  IOobject::NO_READ,
81  IOobject::NO_WRITE
82  ),
83  mesh,
84  dimensionedVector("0", dimless/dimTime, vector::zero)
85  )
86  );
87 
88  mesh.objectRegistry::store(vorticityPtr);
89  }
90 }
91 
92 
93 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
94 
96 {}
97 
98 
99 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
100 
102 {
103  if (active_)
104  {
105  log_.readIfPresent("log", dict);
106  dict.readIfPresent("UName", UName_);
107 
108  if (!dict.readIfPresent("resultName", resultName_))
109  {
110  resultName_ = name_;
111  if (UName_ != "U")
112  {
113  resultName_ = resultName_ + "(" + UName_ + ")";
114  }
115  }
116  }
117 }
118 
119 
121 {
122  if (active_)
123  {
124  const volVectorField& U = obr_.lookupObject<volVectorField>(UName_);
125 
127  const_cast<volVectorField&>
128  (
129  obr_.lookupObject<volVectorField>(resultName_)
130  );
131 
132  vorticity = fvc::curl(U);
133  }
134 }
135 
136 
138 {
139  // Do nothing
140 }
141 
142 
144 {
145  // Do nothing
146 }
147 
148 
150 {
151  if (active_)
152  {
153  const volVectorField& vorticity =
154  obr_.lookupObject<volVectorField>(resultName_);
155 
156  if (log_) Info
157  << type() << " " << name_ << " output:" << nl
158  << " writing field " << vorticity.name() << nl
159  << endl;
160 
161  vorticity.write();
162  }
163 }
164 
165 
166 // ************************************************************************* //
volFields.H
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::dimless
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47
Foam::fvc::curl
tmp< GeometricField< Type, fvPatchField, volMesh > > curl(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition: fvcCurl.C:45
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::dictionary::readIfPresent
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
Definition: dictionaryTemplates.C:94
Foam::read
bool read(const char *, int32_t &)
Definition: int32IO.C:87
Foam::vorticity::read
virtual void read(const dictionary &)
Read the vorticity data.
Definition: vorticity.C:101
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::vorticity::write
virtual void write()
Calculate the vorticity and write.
Definition: vorticity.C:149
U
U
Definition: pEqn.H:46
fvcCurl.H
Calculate the curl of the given volField by constructing the Hodge-dual of the symmetric part of the ...
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::vorticity::vorticity
vorticity(const vorticity &)
Disallow default bitwise copy construct.
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::vorticity
This function object calculates and outputs the vorticity, the curl of the velocity as a volvectorFie...
Definition: vorticity.H:106
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
vorticity.H
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:41
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
dictionary.H
Foam::vorticity::timeSet
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: vorticity.C:143
Foam::vorticity::name
virtual const word & name() const
Return name of the set of vorticity.
Definition: vorticity.H:164
Foam::type
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:588
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::vorticity::end
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: vorticity.C:137
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:259
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Foam::vorticity::execute
virtual void execute()
Execute, currently does nothing.
Definition: vorticity.C:120
Foam::vorticity::~vorticity
virtual ~vorticity()
Destructor.
Definition: vorticity.C:95