gradTemplates.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) 2012-2022 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 "fvcGrad.H"
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 template<class Type>
31 bool Foam::functionObjects::grad::calcGrad()
32 {
33  if (foundObject<VolField<Type>>(fieldName_))
34  {
35  return store
36  (
38  fvc::grad(lookupObject<VolField<Type>>(fieldName_)),
40  );
41  }
42  else if (foundObject<SurfaceField<Type>>(fieldName_))
43  {
44  return store
45  (
47  fvc::grad(lookupObject<SurfaceField<Type>>(fieldName_)),
49  );
50  }
51  else
52  {
53  return false;
54  }
55 }
56 
57 
58 // ************************************************************************* //
word resultName_
Name of result field.
const word fieldName_
Name of field to process.
const fvMesh & mesh_
Reference to the fvMesh.
const ObjectType & lookupObject(const word &fieldName) const
Lookup object from the objectRegistry.
bool foundObject(const word &fieldName) const
Find field in the objectRegistry.
bool store(const tmp< ObjectType > &tfield)
Store the given field in the objectRegistry.
const fvSolution & solution() const
Return the fvSchemes.
Definition: fvMesh.C:1761
bool changing() const
Is mesh changing.
Definition: polyMesh.H:490
bool cache(const word &name) const
Return true if the given field should be cached.
Definition: solution.C:216
Calculate the gradient of the given field.
tmp< VolField< typename outerProduct< vector, Type >::type > > grad(const SurfaceField< Type > &ssf)
Definition: fvcGrad.C:46