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-2020 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 user-specified coordinate system.
36 
37  Operands:
38  \table
39  Operand | Type | Location
40  input | {vol,surface}<Type>Field(s) <!--
41  --> | $FOAM_CASE/<time>/<inpField>s
42  output file | - | -
43  output field | {vol,surface}<Type>Field(s) <!--
44  --> | $FOAM_CASE/<time>/<outField>s
45  \endtable
46 
47  where \c <Type>=Scalar/Vector/SphericalTensor/SymmTensor/Tensor.
48 
49 Usage
50  Minimal example by using \c system/controlDict.functions:
51  \verbatim
52  fieldCoordinateSystemTransform1
53  {
54  // Mandatory entries (unmodifiable)
55  type fieldCoordinateSystemTransform;
56  libs (fieldFunctionObjects);
57 
58  // Mandatory entries (runtime modifiable)
59  fields ( U UMean UPrime2Mean );
60  coordinateSystem
61  {
62  origin (0.001 0 0);
63  rotation
64  {
65  type axes;
66  e1 (1 0.15 0);
67  e3 (0 0 -1);
68  }
69  }
70 
71  // Optional (inherited) entries
72  ...
73  }
74  \endverbatim
75 
76  where the entries mean:
77  \table
78  Property | Description | Type | Req'd | Dflt
79  type | Type name: fieldCoordinateSystemTransform | word | yes | -
80  libs | Library name: fieldFunctionObjects | word | yes | -
81  fields | Names of the operand fields | wordList | yes | -
82  coordinateSystem | Local coordinate system | dict | yes | -
83 
84  The inherited entries are elaborated in:
85  - \link functionObject.H \endlink
86  - \link coordinateSystem.H \endlink
87 
88  Usage by the \c postProcess utility is not available.
89 
90 See also
91  - Foam::functionObject
92  - Foam::functionObjects::fvMeshFunctionObject
93  - Foam::coordinateSystem
94  - ExtendedCodeGuide::functionObjects::field::fieldCoordinateSystemTransform
95 
96 SourceFiles
97  fieldCoordinateSystemTransform.C
98  fieldCoordinateSystemTransformTemplates.C
99 
100 \*---------------------------------------------------------------------------*/
101 
102 #ifndef functionObjects_fieldCoordinateSystemTransform_H
103 #define functionObjects_fieldCoordinateSystemTransform_H
104 
105 #include "fvMeshFunctionObject.H"
106 #include "coordinateSystem.H"
107 #include "volFieldSelection.H"
108 
109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
110 
111 namespace Foam
112 {
113 namespace functionObjects
114 {
115 
116 /*---------------------------------------------------------------------------*\
117  Class fieldCoordinateSystemTransform Declaration
118 \*---------------------------------------------------------------------------*/
119 
120 class fieldCoordinateSystemTransform
121 :
122  public fvMeshFunctionObject
123 {
124 protected:
125 
126  // Protected Data
127 
128  //- Fields to transform
129  volFieldSelection fieldSet_;
130 
131  //- Coordinate system to transform to
132  autoPtr<coordinateSystem> csysPtr_;
133 
134  //- Demand-driven non-uniform rotation field (surface fields)
135  // Eg, for cylindrical coordinates
136  mutable autoPtr<surfaceTensorField> rotTensorSurface_;
137 
138  //- Demand-driven non-uniform rotation field (volume fields)
139  // Eg, for cylindrical coordinates
140  mutable autoPtr<volTensorField> rotTensorVolume_;
141 
142 
143  // Protected Member Functions
144 
145  //- Return the name of the transformed field
146  word transformFieldName(const word& fieldName) const;
147 
148  //- Demand-driven non-uniform rotation field for surface fields
149  const surfaceTensorField& srotTensor() const;
150 
151  //- Demand-driven non-uniform rotation field for volume fields
152  const volTensorField& vrotTensor() const;
153 
154 
155  //- Transform the given field
156  template<class FieldType>
157  void transformField(const FieldType& field);
158 
159  //- Transform the given field
160  template<class FieldType, class RotationFieldType>
161  void transformField
162  (
163  const RotationFieldType& rot,
164  const FieldType& field
165  );
166 
167  //- Transform the given field if has the specified element type
168  template<class Type>
169  void transform(const word& fieldName);
170 
171 
172 public:
173 
174  //- Runtime type information
175  TypeName("fieldCoordinateSystemTransform");
176 
177 
178  // Constructors
179 
180  //- Construct from Time and dictionary
181  fieldCoordinateSystemTransform
182  (
183  const word& name,
184  const Time& runTime,
185  const dictionary& dict
186  );
187 
188  //- No copy construct
189  fieldCoordinateSystemTransform(const fieldCoordinateSystemTransform&)
190  = delete;
191 
192  //- No copy assignment
193  void operator=(const fieldCoordinateSystemTransform&) = delete;
194 
195 
196  //- Destructor
197  virtual ~fieldCoordinateSystemTransform() = default;
198 
199 
200  // Member Functions
201 
202  //- Read the input data
203  virtual bool read(const dictionary&);
204 
205  //- Calculate the transformed fields
206  virtual bool execute();
207 
208  //- Write the transformed fields
209  virtual bool write();
210 };
211 
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 } // End namespace functionObjects
216 } // End namespace Foam
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 #ifdef NoRepository
222 #endif
223 
224 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225 
226 #endif
227 
228 // ************************************************************************* //
TypeName
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::volTensorField
GeometricField< tensor, fvPatchField, volMesh > volTensorField
Definition: volFieldsFwd.H:66
fvMeshFunctionObject.H
Foam::surfaceTensorField
GeometricField< tensor, fvsPatchField, surfaceMesh > surfaceTensorField
Definition: surfaceFieldsFwd.H:64
Foam::read
bool read(const char *buf, int32_t &val)
Same as readInt32.
Definition: int32.H:108
Foam::transform
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:521
coordinateSystem.H
fieldCoordinateSystemTransformTemplates.C
field
rDeltaTY field()
dict
dictionary dict
Definition: searchingEngine.H:14
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
volFieldSelection.H
Foam::vtk::write
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
Definition: foamVtkOutputTemplates.C:36
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59