flowType.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2016-2025 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 "flowType.H"
27 #include "fvcGrad.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace functionObjects
35 {
37 
39  (
41  flowType,
43  );
44 }
45 }
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
50 (
51  const word& name,
52  const Time& runTime,
53  const dictionary& dict
54 )
55 :
56  fvMeshFunctionObject(name, runTime, dict),
57  writeLocalObjects(obr_, false),
58  fieldName_(dict.lookupOrDefault<word>("field", "U")),
59  resultName_
60  (
61  dict.found("result")
62  ? dict.lookup<word>("result")
63  : name
64  )
65 {
66  read(dict);
67 }
68 
69 
70 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
71 
73 {}
74 
75 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
76 
78 {
81 
82  resetLocalObjectNames(wordList{resultName_, "magSqrDevGradU"});
83 
84  return true;
85 }
86 
87 
89 {
90  return wordList(1, fieldName_);
91 }
92 
93 
95 {
96  if (foundObject<volVectorField>(fieldName_))
97  {
98  const volVectorField& U = lookupObject<volVectorField>(fieldName_);
99  const volTensorField devGradU(dev(fvc::grad(U)));
100 
101  store
102  (
103  resultName_,
104  -(devGradU && devGradU.T())
105  /max
106  (
107  store("magSqrDevGradU", magSqr(devGradU)),
108  dimensionedScalar(sqr(dimRate), rootVSmall)
109  )
110  );
111 
112  return true;
113  }
114  else
115  {
116  cannotFindObject<volVectorField>(fieldName_);
117 
118  return false;
119  }
120 }
121 
122 
124 {
125  return writeLocalObjects::write();
126 }
127 
128 
129 // ************************************************************************* //
bool found
Macros for easy insertion into run-time selection tables.
Generic GeometricField class.
tmp< GeometricField< Type, GeoMesh, Field > > T() const
Return transpose (only if it is a tensor field)
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Abstract base-class for Time/database functionObjects.
Calculates and writes a field in the range -1 to 1, in which:
Definition: flowType.H:85
virtual ~flowType()
Destructor.
Definition: flowType.C:72
virtual wordList fields() const
Return the list of fields required.
Definition: flowType.C:88
flowType(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: flowType.C:50
virtual bool execute()
Calculate the flowType fields.
Definition: flowType.C:94
virtual bool write()
Write the flowType fields.
Definition: flowType.C:123
virtual bool read(const dictionary &)
Read the data.
Definition: flowType.C:77
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
virtual bool read(const dictionary &)
Read optional controls.
FunctionObject base class for managing a list of objects on behalf of the inheriting function object,...
virtual bool read(const dictionary &)
Read the list of objects to be written.
virtual bool write()
Write function.
A class for handling words, derived from string.
Definition: word.H:63
Calculate the gradient of the given field.
U
Definition: pEqn.H:72
defineTypeNameAndDebug(fvMeshFunctionObject, 0)
addToRunTimeSelectionTable(functionObject, fvModel, dictionary)
tmp< VolField< typename outerProduct< vector, Type >::type > > grad(const SurfaceField< Type > &ssf)
Definition: fvcGrad.C:46
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
Definition: units.C:346
Namespace for OpenFOAM.
List< word > wordList
A List of words.
Definition: fileName.H:54
tmp< DimensionedField< typename outerProduct< Type, Type >::type, GeoMesh, Field >> sqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void dev(pointPatchField< tensor > &, const pointPatchField< tensor > &)
const dimensionSet & dimRate
Definition: dimensions.C:152
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
tmp< DimensionedField< scalar, GeoMesh, Field > > magSqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
dictionary dict