cylindrical.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2015 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 "cylindrical.H"
27 #include "axesRotation.H"
29 #include "polyMesh.H"
30 #include "tensorIOField.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(cylindrical, 0);
38  (
39  coordinateRotation,
40  cylindrical,
41  dictionary
42  );
44  (
45  coordinateRotation,
46  cylindrical,
47  objectRegistry
48  );
49 }
50 
51 
52 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
53 
55 (
56  const objectRegistry& obr,
57  const List<label>& cells
58 )
59 {
60  const polyMesh& mesh = refCast<const polyMesh>(obr);
61  const vectorField& cc = mesh.cellCentres();
62 
63  if (cells.size())
64  {
65  Rptr_.reset(new tensorField(cells.size()));
66 
67  tensorField& R = Rptr_();
68  forAll(cells, i)
69  {
70  label cellI = cells[i];
71  vector dir = cc[cellI] - origin_;
72  dir /= mag(dir) + VSMALL;
73 
74  R[i] = axesRotation(e3_, dir).R();
75  }
76  }
77  else
78  {
79  Rptr_.reset(new tensorField(mesh.nCells()));
80 
81  tensorField& R = Rptr_();
82  forAll(cc, cellI)
83  {
84  vector dir = cc[cellI] - origin_;
85  dir /= mag(dir) + VSMALL;
86 
87  R[cellI] = axesRotation(e3_, dir).R();
88  }
89  }
90 }
91 
92 
93 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
94 
96 (
97  const dictionary& dict,
98  const objectRegistry& obr
99 )
100 :
101  Rptr_(),
102  origin_(point::zero),
103  e3_(vector::zero)
104 {
105  // If origin is specified in the coordinateSystem
106  if (dict.parent().found("origin"))
107  {
108  dict.parent().lookup("origin") >> origin_;
109  }
110 
111  // rotation axis
112  dict.lookup("e3") >> e3_;
113 
114  init(obr);
115 }
116 
117 
119 (
120  const objectRegistry& obr,
121  const vector& axis,
122  const point& origin
123 )
124 :
125  Rptr_(),
126  origin_(origin),
127  e3_(axis)
128 {
129  init(obr);
130 }
131 
132 
134 (
135  const objectRegistry& obr,
136  const vector& axis,
137  const point& origin,
138  const List<label>& cells
139 )
140 :
141  Rptr_(),
142  origin_(origin),
143  e3_(axis)
144 {
145  init(obr, cells);
146 }
147 
148 
150 :
151  Rptr_(),
152  origin_(),
153  e3_()
154 {
156  << " cylindrical can not be constructed from dictionary "
157  << " use the construtctor : "
158  "("
159  " const dictionary&, const objectRegistry&"
160  ")"
161  << exit(FatalIOError);
162 }
163 
164 
166 :
167  Rptr_(),
168  origin_(vector::zero),
169  e3_(vector::zero)
170 {
171  Rptr_() = R;
172 }
173 
174 
176 :
177  Rptr_(r.Rptr_, false), // clone
178  origin_(r.origin_),
179  e3_(r.e3_)
180 {}
181 
182 
183 
184 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
185 
187 {
188  if (!Rptr_.empty())
189  {
190  Rptr_.clear();
191  }
192 }
193 
194 
196 (
197  const polyMesh& mesh,
198  const labelList& cells
199 )
200 {
201  const vectorField& cc = mesh.cellCentres();
202  tensorField& R = Rptr_();
203 
204  forAll(cells, i)
205  {
206  label cellI = cells[i];
207  vector dir = cc[cellI] - origin_;
208  dir /= mag(dir) + VSMALL;
209 
210  R[cellI] = axesRotation(e3_, dir).R();
211  }
212 }
213 
214 
216 (
217  const vectorField& vf
218 ) const
219 {
220  if (Rptr_->size() != vf.size())
221  {
223  << "vectorField st has different size to tensorField "
224  << abort(FatalError);
225  }
226 
227  return (Rptr_() & vf);
228 }
229 
230 
232 {
234  return vector::zero;
235 }
236 
237 
239 (
240  const vector& v,
241  const label cmptI
242 ) const
243 {
244  return (Rptr_()[cmptI] & v);
245 }
246 
247 
249 (
250  const vectorField& vf
251 ) const
252 {
253  return (Rptr_().T() & vf);
254 }
255 
256 
258 {
260  return vector::zero;
261 }
262 
263 
265 (
266  const vector& v,
267  const label cmptI
268 ) const
269 {
270  return (Rptr_()[cmptI].T() & v);
271 }
272 
273 
275 (
276  const tensorField& tf
277 ) const
278 {
279  if (Rptr_->size() != tf.size())
280  {
282  << "tensorField st has different size to tensorField Tr"
283  << abort(FatalError);
284  }
285  return (Rptr_() & tf & Rptr_().T());
286 }
287 
288 
290 (
291  const tensor& t
292 ) const
293 {
295 
296  return tensor::zero;
297 }
298 
299 
301 (
302  const tensorField& tf,
303  const labelList& cellMap
304 ) const
305 {
306  if (cellMap.size() != tf.size())
307  {
309  << "tensorField tf has different size to tensorField Tr"
310  << abort(FatalError);
311  }
312 
313  const tensorField& R = Rptr_();
314  const tensorField Rtr(R.T());
315  tmp<tensorField> tt(new tensorField(cellMap.size()));
316  tensorField& t = tt();
317  forAll(cellMap, i)
318  {
319  const label cellI = cellMap[i];
320  t[i] = R[cellI] & tf[i] & Rtr[cellI];
321  }
322 
323  return tt;
324 }
325 
326 
328 (
329  const vectorField& vf
330 ) const
331 {
332  if (Rptr_->size() != vf.size())
333  {
335  << "tensorField vf has different size to tensorField Tr"
336  << abort(FatalError);
337  }
338 
339  tmp<symmTensorField> tfld(new symmTensorField(Rptr_->size()));
340  symmTensorField& fld = tfld();
341 
342  const tensorField& R = Rptr_();
343  forAll(fld, i)
344  {
345  fld[i] = transformPrincipal(R[i], vf[i]);
346  }
347  return tfld;
348 }
349 
350 
352 (
353  const vector& v
354 ) const
355 {
357  return symmTensor::zero;
358 }
359 
360 
362 {
363  os.writeKeyword("e3") << e3() << token::END_STATEMENT << nl;
364 }
365 
366 
367 // ************************************************************************* //
Foam::cylindrical::transformVector
virtual tmp< symmTensorField > transformVector(const vectorField &vf) const
Transform vectorField using transformation tensorField and return.
Definition: cylindrical.C:328
Foam::Tensor
Templated 3D tensor derived from VectorSpace adding construction from 9 components,...
Definition: complexI.H:224
Foam::token::END_STATEMENT
@ END_STATEMENT
Definition: token.H:99
Foam::cylindrical::R
virtual const tensor & R() const
Return local-to-global transformation tensor.
Definition: cylindrical.H:146
Foam::SymmTensor< scalar >
Foam::Vector< scalar >::zero
static const Vector zero
Definition: Vector.H:80
cylindrical.H
Foam::cylindrical::transformTensor
virtual tmp< tensorField > transformTensor(const tensorField &tf) const
Transform tensor field using transformation tensorField.
Definition: cylindrical.C:275
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::cylindrical::cylindrical
cylindrical(const dictionary &, const objectRegistry &)
Construct from dictionary and objectRegistry.
Definition: cylindrical.C:96
Foam::axesRotation
A coordinate rotation specified using global axis.
Definition: axesRotation.H:60
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
Foam::tensorField
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
Definition: primitiveFieldsFwd.H:52
tensorIOField.H
Foam::cylindrical
A local coordinate rotation. The cell based rotational field can be created in two ways:
Definition: cylindrical.H:63
Foam::FatalIOError
IOerror FatalIOError
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
polyMesh.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::symmTensorField
Field< symmTensor > symmTensorField
Specialisation of Field<T> for symmTensor.
Definition: primitiveFieldsFwd.H:51
Foam::axesRotation::R
virtual const tensor & R() const
Return local-to-global transformation tensor.
Definition: axesRotation.H:144
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::cylindrical::clear
virtual void clear()
Reset rotation to an identity rotation.
Definition: cylindrical.C:186
tf
const tensorField & tf
Definition: getPatchFieldTensor.H:36
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:365
R
#define R(A, B, C, D, E, F, K, M)
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:55
Foam::cylindrical::Rptr_
autoPtr< tensorField > Rptr_
AutoPtr to transformation tensor.
Definition: cylindrical.H:70
Foam::cylindrical::transform
virtual tmp< vectorField > transform(const vectorField &tf) const
Transform vectorField using transformation tensor field.
Definition: cylindrical.C:216
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
fld
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Foam::Tensor::zero
static const Tensor zero
Definition: Tensor.H:80
Foam::SymmTensor< scalar >::zero
static const SymmTensor zero
Definition: SymmTensor.H:77
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::primitiveMesh::cellCentres
const vectorField & cellCentres() const
Definition: primitiveMeshCellCentresAndVols.C:211
Foam::cylindrical::invTransform
virtual tmp< vectorField > invTransform(const vectorField &vf) const
Inverse transform vectorField using transformation tensor field.
Definition: cylindrical.C:249
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::Vector< scalar >
Foam::List< label >
Foam::Ostream::writeKeyword
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:59
cells
const cellShapeList & cells
Definition: gmvOutputHeader.H:3
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
axesRotation.H
Foam::cylindrical::init
void init(const objectRegistry &obr, const List< label > &cells=List< label >())
Init transformation tensor field.
Definition: cylindrical.C:55
Foam::cylindrical::updateCells
virtual void updateCells(const polyMesh &mesh, const labelList &cells)
Update the rotation for a list of cells.
Definition: cylindrical.C:196
Foam::cylindrical::write
virtual void write(Ostream &) const
Write.
Definition: cylindrical.C:361
Foam::zero
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Definition: zero.H:47