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 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  vector dir = p - origin_;
53  dir /= mag(dir) + vSmall;
54 
55  const vector axis = axis_/mag(axis_);
56  const vector r = dir - (dir & axis)*axis;
57 
58  return tensor(r, axis^r, axis);
59 }
60 
61 
62 void Foam::functionObjects::cylindrical::transform
63 (
64  vectorField& vf,
65  const vectorField& points
66 ) const
67 {
68  if (toCartesian_)
69  {
70  forAll(points, i)
71  {
72  vf[i] = this->R(points[i]).T() & vf[i];
73  }
74  }
75  else
76  {
77  forAll(points, i)
78  {
79  vf[i] = this->R(points[i]) & vf[i];
80  }
81  }
82 }
83 
84 
85 bool Foam::functionObjects::cylindrical::calc()
86 {
87  if (foundObject<volVectorField>(fieldName_))
88  {
89  const volVectorField& vf = lookupObject<volVectorField>(fieldName_);
90  const volVectorField& C = mesh_.C();
91 
92  tmp<volVectorField> tcvf(volVectorField::New(resultName_, vf));
93 
94  volVectorField& cvf = tcvf.ref();
95  transform(cvf.primitiveFieldRef(), C);
96 
97  forAll(vf.boundaryField(), patchi)
98  {
99  transform
100  (
101  cvf.boundaryFieldRef()[patchi],
102  C.boundaryField()[patchi]
103  );
104  }
105 
106  return store(resultName_, tcvf);
107  }
108  else
109  {
110  cannotFindObject<volVectorField>(fieldName_);
111 
112  return false;
113  }
114 
115  return true;
116 }
117 
118 
119 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
120 
122 (
123  const word& name,
124  const Time& runTime,
125  const dictionary& dict
126 )
127 :
129  (
130  name,
131  runTime,
132  dict,
133  dict.lookupOrDefault<Switch>("toCartesian", false)
134  ? "cartesian"
135  : typeName
136  ),
137  origin_(dict.lookup("origin")),
138  axis_(dict.lookup("axis")),
139  toCartesian_(dict.lookupOrDefault<Switch>("toCartesian", false))
140 {}
141 
142 
143 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
144 
146 {}
147 
148 
149 // ************************************************************************* //
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 >> &)
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:160
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:62
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:483
dimensioned< scalar > mag(const dimensioned< Type > &)
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