Lambda2.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 "Lambda2.H"
27 #include "volFields.H"
28 #include "dictionary.H"
30 #include "fvcGrad.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(Lambda2, 0);
37 }
38 
39 
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 
42 Foam::Lambda2::Lambda2
43 (
44  const word& name,
45  const objectRegistry& obr,
46  const dictionary& dict,
47  const bool loadFromFiles
48 )
49 :
50  name_(name),
51  obr_(obr),
52  active_(true),
53  UName_("U")
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  "Lambda2::Lambda2"
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  volScalarField* Lambda2Ptr
79  (
80  new volScalarField
81  (
82  IOobject
83  (
84  type(),
85  mesh.time().timeName(),
86  mesh,
89  ),
90  mesh,
92  )
93  );
94 
95  mesh.objectRegistry::store(Lambda2Ptr);
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  }
114 }
115 
116 
118 {
119  if (active_)
120  {
121  const fvMesh& mesh = refCast<const fvMesh>(obr_);
122 
123  const volVectorField& U =
124  mesh.lookupObject<volVectorField>(UName_);
125 
126  const volTensorField gradU(fvc::grad(U));
127 
128  const volTensorField SSplusWW
129  (
130  (symm(gradU) & symm(gradU))
131  + (skew(gradU) & skew(gradU))
132  );
133 
135  const_cast<volScalarField&>
136  (
138  );
139 
140  Lambda2 = -eigenValues(SSplusWW)().component(vector::Y);
141  }
142 }
143 
144 
146 {
147  if (active_)
148  {
149  execute();
150  }
151 }
152 
153 
155 {
156  // Do nothing
157 }
158 
159 
161 {
162  if (active_)
163  {
164  const volScalarField& Lambda2 =
165  obr_.lookupObject<volScalarField>(type());
166 
167  Info<< type() << " " << name_ << " output:" << nl
168  << " writing field " << Lambda2.name() << nl
169  << endl;
170 
171  Lambda2.write();
172  }
173 }
174 
175 
176 // ************************************************************************* //
virtual void read(const dictionary &)
Read the Lambda2 data.
Definition: Lambda2.C:108
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
dimensionedVector eigenValues(const dimensionedTensor &dt)
dimensionedTensor skew(const dimensionedTensor &dt)
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
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.
Calculate the gradient of the given field.
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:243
virtual void execute()
Execute, currently does nothing.
Definition: Lambda2.C:117
virtual bool write() const
Write using setting from DB.
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: Lambda2.C:145
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 void write()
Calculate the Lambda2 and write.
Definition: Lambda2.C:160
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
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
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:589
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: Lambda2.C:154
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Registry of regIOobjects.
This function object calculates and outputs the second largest eigenvalue of the sum of the square of...
Definition: Lambda2.H:63
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
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
U
Definition: pEqn.H:82
defineTypeNameAndDebug(combustionModel, 0)
virtual ~Lambda2()
Destructor.
Definition: Lambda2.C:102