cylindricalFunctionObject.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) 2020-2024 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 
27 #include "volFields.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace functionObjects
35 {
37 
39  (
43  );
44 }
45 }
46 
47 
48 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
49 
50 Foam::tensor Foam::functionObjects::cylindrical::R(const vector& p) const
51 {
52  const vector dir = normalised(p - origin_);
53 
54  const vector axis = normalised(axis_);
55  const vector r = dir - (dir & axis)*axis;
56 
57  return tensor(normalised(r), normalised(axis^r), axis);
58 }
59 
60 
61 void Foam::functionObjects::cylindrical::transform
62 (
63  vectorField& vf,
64  const vectorField& points
65 ) const
66 {
67  if (toCartesian_)
68  {
69  forAll(points, i)
70  {
71  vf[i] = this->R(points[i]).T() & vf[i];
72  }
73  }
74  else
75  {
76  forAll(points, i)
77  {
78  vf[i] = this->R(points[i]) & vf[i];
79  }
80  }
81 }
82 
83 
84 bool Foam::functionObjects::cylindrical::calc()
85 {
86  if (foundObject<volVectorField>(fieldName_))
87  {
88  const volVectorField& vf = lookupObject<volVectorField>(fieldName_);
89  const volVectorField& C = mesh_.C();
90 
91  tmp<volVectorField> tcvf(volVectorField::New(resultName_, vf));
92 
93  volVectorField& cvf = tcvf.ref();
94  transform(cvf.primitiveFieldRef(), C);
95 
96  forAll(vf.boundaryField(), patchi)
97  {
98  transform
99  (
100  cvf.boundaryFieldRef()[patchi],
101  C.boundaryField()[patchi]
102  );
103  }
104 
105  store(resultName_, tcvf);
106 
107  return true;
108  }
109  else
110  {
111  cannotFindObject<volVectorField>(fieldName_);
112 
113  return false;
114  }
115 
116  return true;
117 }
118 
119 
120 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
121 
123 (
124  const word& name,
125  const Time& runTime,
126  const dictionary& dict
127 )
128 :
130  (
131  name,
132  runTime,
133  dict,
134  dict.lookupOrDefault<Switch>("toCartesian", false)
135  ? "cartesian"
136  : typeName
137  ),
138  origin_(dict.lookup("origin")),
139  axis_(dict.lookup("axis")),
140  toCartesian_(dict.lookupOrDefault<Switch>("toCartesian", false))
141 {}
142 
143 
144 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
145 
147 {}
148 
149 
150 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:433
Macros for easy insertion into run-time selection tables.
static tmp< GeometricField< Type, GeoMesh, PrimitiveField > > New(const word &name, const Internal &, const PtrList< Patch > &, const HashPtrTable< Source > &=HashPtrTable< Source >())
Return a temporary field constructed from name,.
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:61
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.
Transforms the specified velocity field into a cylindrical polar coordinate system or back to Cartesi...
cylindrical(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
A class for handling words, derived from string.
Definition: word.H:62
label patchi
const pointField & points
defineTypeNameAndDebug(adjustTimeStepToCombustion, 0)
addToRunTimeSelectionTable(functionObject, adjustTimeStepToCombustion, dictionary)
static const coefficient C("C", dimTemperature, 234.5)
Namespace for OpenFOAM.
VolField< vector > volVectorField
Definition: volFieldsFwd.H:63
Tensor< scalar > tensor
Tensor of scalars.
Definition: tensor.H:51
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:501
dimensionSet normalised(const dimensionSet &)
Definition: dimensionSet.C:507
Field< vector > vectorField
Specialisation of Field<T> for vector.
static scalar R(const scalar a, const scalar x)
Definition: invIncGamma.C:102
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
dictionary dict
volScalarField & p