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-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 "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 
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  resultName_(name),
55  log_(true)
56 {
57  // Check if the available mesh is an fvMesh, otherwise deactivate
58  if (!isA<fvMesh>(obr_))
59  {
60  active_ = false;
62  << "No fvMesh available, deactivating " << name_ << nl
63  << endl;
64  }
65 
66  read(dict);
67 
68  if (active_)
69  {
70  const fvMesh& mesh = refCast<const fvMesh>(obr_);
71 
72  volScalarField* Lambda2Ptr
73  (
74  new volScalarField
75  (
76  IOobject
77  (
78  resultName_,
79  mesh.time().timeName(),
80  mesh,
81  IOobject::NO_READ,
82  IOobject::NO_WRITE
83  ),
84  mesh,
86  )
87  );
88 
89  mesh.objectRegistry::store(Lambda2Ptr);
90  }
91 }
92 
93 
94 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
95 
97 {}
98 
99 
100 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
101 
103 {
104  if (active_)
105  {
106  log_.readIfPresent("log", dict);
107  dict.readIfPresent("UName", UName_);
108 
109  if (!dict.readIfPresent("resultName", resultName_))
110  {
111  resultName_ = name_;
112  if (UName_ != "U")
113  {
114  resultName_ = resultName_ + "(" + UName_ + ")";
115  }
116  }
117  }
118 }
119 
120 
122 {
123  if (active_)
124  {
125  const fvMesh& mesh = refCast<const fvMesh>(obr_);
126 
127  const volVectorField& U =
129 
130  const volTensorField gradU(fvc::grad(U));
131 
132  const volTensorField SSplusWW
133  (
134  (symm(gradU) & symm(gradU))
135  + (skew(gradU) & skew(gradU))
136  );
137 
139  const_cast<volScalarField&>
140  (
141  mesh.lookupObject<volScalarField>(resultName_)
142  );
143 
144  Lambda2 = -eigenValues(SSplusWW)().component(vector::Y);
145  }
146 }
147 
148 
150 {
151  // Do nothing
152 }
153 
154 
156 {
157  // Do nothing
158 }
159 
160 
162 {
163  if (active_)
164  {
165  const volScalarField& Lambda2 =
166  obr_.lookupObject<volScalarField>(resultName_);
167 
168  if (log_) Info
169  << type() << " " << name_ << " output:" << nl
170  << " writing field " << Lambda2.name() << nl
171  << endl;
172 
173  Lambda2.write();
174  }
175 }
176 
177 
178 // ************************************************************************* //
volFields.H
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::symm
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
Definition: dimensionedSymmTensor.C:82
Foam::component
void component(FieldField< Field, typename FieldField< Field, Type >::cmptType > &sf, const FieldField< Field, Type > &f, const direction d)
Definition: FieldFieldFunctions.C:41
Foam::dimless
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47
Foam::fvc::grad
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:52
Foam::Vector< scalar >::Y
@ Y
Definition: Vector.H:89
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::Lambda2::name
virtual const word & name() const
Return name of the set of Lambda2.
Definition: Lambda2.H:165
Foam::skew
dimensionedTensor skew(const dimensionedTensor &dt)
Definition: dimensionedTensor.C:135
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::Lambda2::end
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: Lambda2.C:149
Foam::Lambda2::timeSet
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: Lambda2.C:155
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
U
U
Definition: pEqn.H:46
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::Lambda2::Lambda2
Lambda2(const Lambda2 &)
Disallow default bitwise copy construct.
Foam::eigenValues
dimensionedVector eigenValues(const dimensionedTensor &dt)
Definition: dimensionedTensor.C:146
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Lambda2.H
Foam::Lambda2::write
virtual void write()
Calculate the Lambda2 and write.
Definition: Lambda2.C:161
dict
dictionary dict
Definition: searchingEngine.H:14
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
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
Foam::Lambda2::read
virtual void read(const dictionary &)
Read the Lambda2 data.
Definition: Lambda2.C:102
Foam::Lambda2
This function object calculates and outputs the second largest eigenvalue of the sum of the square of...
Definition: Lambda2.H:107
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:49
Foam::Lambda2::execute
virtual void execute()
Execute, currently does nothing.
Definition: Lambda2.C:121
fvcGrad.H
Calculate the gradient of the given field.
dictionary.H
Foam::Lambda2::~Lambda2
virtual ~Lambda2()
Destructor.
Definition: Lambda2.C:96
Foam::objectRegistry::lookupObject
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
Definition: objectRegistryTemplates.C:165
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::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
zeroGradientFvPatchFields.H
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