Q.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) 2013-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 "Q.H"
27 #include "volFields.H"
28 #include "dictionary.H"
29 #include "fvcGrad.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
36 }
37 
38 
39 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 
41 Foam::Q::Q
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 {
54  // Check if the available mesh is an fvMesh, otherwise deactivate
55  if (!isA<fvMesh>(obr_))
56  {
57  active_ = false;
58  WarningIn
59  (
60  "Q::Q"
61  "("
62  "const word&, "
63  "const objectRegistry&, "
64  "const dictionary&, "
65  "const bool"
66  ")"
67  ) << "No fvMesh available, deactivating " << name_ << nl
68  << endl;
69  }
70 
71  read(dict);
72 
73  if (active_)
74  {
75  const fvMesh& mesh = refCast<const fvMesh>(obr_);
76 
77  volScalarField* QPtr
78  (
79  new volScalarField
80  (
81  IOobject
82  (
83  type(),
84  mesh.time().timeName(),
85  mesh,
88  ),
89  mesh,
91  )
92  );
93 
94  mesh.objectRegistry::store(QPtr);
95  }
96 }
97 
98 
99 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
100 
102 {}
103 
104 
105 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
106 
107 void Foam::Q::read(const dictionary& dict)
108 {
109  if (active_)
110  {
111  UName_ = dict.lookupOrDefault<word>("UName", "U");
112  }
113 }
114 
115 
117 {
118  if (active_)
119  {
120  const fvMesh& mesh = refCast<const fvMesh>(obr_);
121 
122  const volVectorField& U =
123  mesh.lookupObject<volVectorField>(UName_);
124 
125  const volTensorField gradU(fvc::grad(U));
126 
127  volScalarField& Q =
128  const_cast<volScalarField&>
129  (
131  );
132 
133  Q = 0.5*(sqr(tr(gradU)) - tr(((gradU) & (gradU))));
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 volScalarField& Q =
158  obr_.lookupObject<volScalarField>(type());
159 
160  Info<< type() << " " << name_ << " output:" << nl
161  << " writing field " << Q.name() << nl
162  << endl;
163 
164  Q.write();
165  }
166 }
167 
168 
169 // ************************************************************************* //
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: Q.C:138
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
virtual void write()
Calculate the Q and write.
Definition: Q.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
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
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.
Calculate the gradient of the given field.
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:243
virtual bool write() const
Write using setting from DB.
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.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
const word & name() const
Return name.
Definition: IOobject.H:260
virtual void read(const dictionary &)
Read the Q data.
Definition: Q.C:107
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:589
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Registry of regIOobjects.
virtual void execute()
Execute, currently does nothing.
Definition: Q.C:116
bool read(const char *, int32_t &)
Definition: int32IO.C:87
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:52
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: Q.C:147
dimensionedSymmTensor sqr(const dimensionedVector &dv)
This function object calculates and outputs the second invariant of the velocity gradient tensor [1/s...
Definition: Q.H:66
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
U
Definition: pEqn.H:82
defineTypeNameAndDebug(combustionModel, 0)
virtual ~Q()
Destructor.
Definition: Q.C:101