fieldCoordinateSystemTransform.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2015-2018 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::functionObjects::fieldCoordinateSystemTransform
29 
30 Group
31  grpFieldFunctionObjects
32 
33 Description
34  Transforms a user-specified selection of fields from global Cartesian
35  coordinates to a local coordinate system.
36  The fields are run-time modifiable.
37 
38 Usage
39  Example of function object specification:
40  \verbatim
41  fieldCoordinateSystemTransform1
42  {
43  type fieldCoordinateSystemTransform;
44  libs ("libfieldFunctionObjects.so");
45  ...
46  fields ( U UMean UPrime2Mean );
47 
48  coordinateSystem
49  {
50  origin (0.001 0 0);
51  rotation
52  {
53  type axes;
54  e1 (1 0.15 0);
55  e3 (0 0 -1);
56  }
57  }
58  }
59  \endverbatim
60 
61  Where the entries comprise:
62  \table
63  Property | Description | Required | Default value
64  type | type name: fieldCoordinateSystemTransform | yes |
65  fields | list of fields to be transformed | yes |
66  coordinateSystem | local coordinate system | yes |
67  \endtable
68 
69 See also
70  Foam::functionObjects::fvMeshFunctionObject
71  Foam::coordinateSystem
72 
73 SourceFiles
74  fieldCoordinateSystemTransform.C
75  fieldCoordinateSystemTransformTemplates.C
76 
77 \*---------------------------------------------------------------------------*/
78 
79 #ifndef functionObjects_fieldCoordinateSystemTransform_H
80 #define functionObjects_fieldCoordinateSystemTransform_H
81 
82 #include "fvMeshFunctionObject.H"
83 #include "coordinateSystem.H"
84 #include "volFieldSelection.H"
85 
86 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
87 
88 namespace Foam
89 {
90 namespace functionObjects
91 {
92 
93 /*---------------------------------------------------------------------------*\
94  Class fieldCoordinateSystemTransform Declaration
95 \*---------------------------------------------------------------------------*/
96 
97 class fieldCoordinateSystemTransform
98 :
99  public fvMeshFunctionObject
100 {
101 protected:
102 
103  // Protected Data
104 
105  //- Fields to transform
106  volFieldSelection fieldSet_;
107 
108  //- Coordinate system to transform to
109  autoPtr<coordinateSystem> csysPtr_;
110 
111  //- Demand-driven non-uniform rotation field (surface fields)
112  // Eg, for cylindrical coordinates
113  mutable autoPtr<surfaceTensorField> rotTensorSurface_;
114 
115  //- Demand-driven non-uniform rotation field (volume fields)
116  // Eg, for cylindrical coordinates
118 
119 
120  // Protected Member Functions
121 
122  //- Return the name of the transformed field
123  word transformFieldName(const word& fieldName) const;
124 
125  //- Demand-driven non-uniform rotation field for surface fields
126  const surfaceTensorField& srotTensor() const;
127 
128  //- Demand-driven non-uniform rotation field for volume fields
129  const volTensorField& vrotTensor() const;
130 
131 
132  //- Transform the given field
133  template<class FieldType>
134  void transformField(const FieldType& field);
135 
136  //- Transform the given field
137  template<class FieldType, class RotationFieldType>
138  void transformField
139  (
140  const RotationFieldType& rot,
141  const FieldType& field
142  );
143 
144  //- Transform the given field if has the specified element type
145  template<class Type>
146  void transform(const word& fieldName);
147 
148 
149 public:
150 
151  //- Runtime type information
152  TypeName("fieldCoordinateSystemTransform");
153 
154 
155  // Constructors
156 
157  //- Construct from Time and dictionary
159  (
160  const word& name,
161  const Time& runTime,
162  const dictionary& dict
163  );
164 
165 
166  //- Destructor
167  virtual ~fieldCoordinateSystemTransform() = default;
168 
169 
170  // Member Functions
171 
172  //- Read the input data
173  virtual bool read(const dictionary&);
174 
175  //- Calculate the transformed fields
176  virtual bool execute();
177 
178  //- Write the transformed fields
179  virtual bool write();
180 };
181 
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 } // End namespace functionObjects
186 } // End namespace Foam
187 
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 
190 #ifdef NoRepository
192 #endif
193 
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 
196 #endif
197 
198 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
fvMeshFunctionObject.H
Foam::functionObjects::fieldCoordinateSystemTransform::vrotTensor
const volTensorField & vrotTensor() const
Demand-driven non-uniform rotation field for volume fields.
Definition: fieldCoordinateSystemTransform.C:134
Foam::functionObjects::fieldCoordinateSystemTransform::csysPtr_
autoPtr< coordinateSystem > csysPtr_
Coordinate system to transform to.
Definition: fieldCoordinateSystemTransform.H:128
Foam::functionObjects::fieldCoordinateSystemTransform::rotTensorSurface_
autoPtr< surfaceTensorField > rotTensorSurface_
Demand-driven non-uniform rotation field (surface fields)
Definition: fieldCoordinateSystemTransform.H:132
Foam::functionObjects::fieldCoordinateSystemTransform::transform
void transform(const word &fieldName)
Transform the given field if has the specified element type.
Definition: fieldCoordinateSystemTransformTemplates.C:71
Foam::functionObjects::fieldCoordinateSystemTransform::fieldCoordinateSystemTransform
fieldCoordinateSystemTransform(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: fieldCoordinateSystemTransform.C:54
Foam::functionObjects::fieldCoordinateSystemTransform
Transforms a user-specified selection of fields from global Cartesian coordinates to a local coordina...
Definition: fieldCoordinateSystemTransform.H:116
Foam::functionObjects::fieldCoordinateSystemTransform::transformField
void transformField(const FieldType &field)
Transform the given field.
Definition: fieldCoordinateSystemTransformTemplates.C:38
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
coordinateSystem.H
Foam::functionObjects::fieldCoordinateSystemTransform::execute
virtual bool execute()
Calculate the transformed fields.
Definition: fieldCoordinateSystemTransform.C:193
Foam::functionObjects::fieldCoordinateSystemTransform::read
virtual bool read(const dictionary &)
Read the input data.
Definition: fieldCoordinateSystemTransform.C:179
Foam::functionObjects::volFieldSelection
Helper class to manage solver field selections.
Definition: volFieldSelection.H:52
fieldCoordinateSystemTransformTemplates.C
field
rDeltaTY field()
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
volFieldSelection.H
Foam::functionObjects::fieldCoordinateSystemTransform::fieldSet_
volFieldSelection fieldSet_
Fields to transform.
Definition: fieldCoordinateSystemTransform.H:125
Foam::functionObjects::fieldCoordinateSystemTransform::rotTensorVolume_
autoPtr< volTensorField > rotTensorVolume_
Demand-driven non-uniform rotation field (volume fields)
Definition: fieldCoordinateSystemTransform.H:136
Foam::functionObjects::fieldCoordinateSystemTransform::~fieldCoordinateSystemTransform
virtual ~fieldCoordinateSystemTransform()=default
Destructor.
Foam::functionObjects::fieldCoordinateSystemTransform::write
virtual bool write()
Write the transformed fields.
Definition: fieldCoordinateSystemTransform.C:214
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::functionObject::name
const word & name() const
Return the name of this functionObject.
Definition: functionObject.C:131
Foam::functionObjects::fieldCoordinateSystemTransform::TypeName
TypeName("fieldCoordinateSystemTransform")
Runtime type information.
Foam::functionObjects::fieldCoordinateSystemTransform::srotTensor
const surfaceTensorField & srotTensor() const
Demand-driven non-uniform rotation field for surface fields.
Definition: fieldCoordinateSystemTransform.C:89
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
Foam::functionObjects::fieldCoordinateSystemTransform::transformFieldName
word transformFieldName(const word &fieldName) const
Return the name of the transformed field.
Definition: fieldCoordinateSystemTransform.C:80