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  return store(resultName_, tcvf);
106  }
107  else
108  {
109  cannotFindObject<volVectorField>(fieldName_);
110 
111  return false;
112  }
113 
114  return true;
115 }
116 
117 
118 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
119 
121 (
122  const word& name,
123  const Time& runTime,
124  const dictionary& dict
125 )
126 :
128  (
129  name,
130  runTime,
131  dict,
132  dict.lookupOrDefault<Switch>("toCartesian", false)
133  ? "cartesian"
134  : typeName
135  ),
136  origin_(dict.lookup("origin")),
137  axis_(dict.lookup("axis")),
138  toCartesian_(dict.lookupOrDefault<Switch>("toCartesian", false))
139 {}
140 
141 
142 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
143 
145 {}
146 
147 
148 // ************************************************************************* //
static const Foam::dimensionedScalar C("C", Foam::dimTemperature, 234.5)
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Macros for easy insertion into run-time selection tables.
static tmp< GeometricField< Type, PatchField, GeoMesh > > New(const word &name, const Internal &, const PtrList< PatchField< Type >> &, 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 keyword definitions, which are a keyword followed by any number of values (e....
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)
Namespace for OpenFOAM.
VolField< vector > volVectorField
Definition: volFieldsFwd.H:65
Tensor< scalar > tensor
Tensor of scalars.
Definition: tensor.H:51
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:504
dimensionSet normalised(const dimensionSet &)
Definition: dimensionSet.C:510
Field< vector > vectorField
Specialisation of Field<T> for vector.
static scalar R(const scalar a, const scalar x)
Definition: invIncGamma.C:102
dictionary dict
volScalarField & p