fieldCoordinateSystemTransformTemplates.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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2017 OpenFOAM Foundation
9 Copyright (C) 2016-2018 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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\*---------------------------------------------------------------------------*/
28
30#include "volFields.H"
31#include "surfaceFields.H"
33
34// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35
36template<class FieldType>
37void Foam::functionObjects::fieldCoordinateSystemTransform::transformField
38(
39 const FieldType& field
40)
41{
42 word transFieldName(transformFieldName(field.name()));
43
44 store
45 (
46 transFieldName,
48 );
49}
50
51
52template<class FieldType, class RotationFieldType>
53void Foam::functionObjects::fieldCoordinateSystemTransform::transformField
54(
55 const RotationFieldType& rot,
56 const FieldType& field
57)
58{
59 word transFieldName(transformFieldName(field.name()));
60
61 store
62 (
63 transFieldName,
65 );
66}
67
68
69template<class Type>
70void Foam::functionObjects::fieldCoordinateSystemTransform::transform
71(
72 const word& fieldName
73)
74{
75 typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
76 typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
77
78 // Scalar quantities (bool, label, scalar) and sphericalTensor quantities
79 // are transform invariant. Use (pTraits<Type>::nComponents == 1) to avoid
80 // avoid generating a tensor field for a non-uniform transformation.
81
82 if (foundObject<VolFieldType>(fieldName))
83 {
85 << type() << ": Field " << fieldName << " already in database"
86 << endl;
87
88 if (csysPtr_->uniform() || pTraits<Type>::nComponents == 1)
89 {
90 transformField<VolFieldType>
91 (
92 lookupObject<VolFieldType>(fieldName)
93 );
94 }
95 else
96 {
97 transformField<VolFieldType>
98 (
99 vrotTensor(),
100 lookupObject<VolFieldType>(fieldName)
101 );
102 }
103 }
104 else if (foundObject<SurfaceFieldType>(fieldName))
105 {
107 << type() << ": Field " << fieldName << " already in database"
108 << endl;
109
110 if (csysPtr_->uniform() || pTraits<Type>::nComponents == 1)
111 {
112 transformField<SurfaceFieldType>
113 (
114 lookupObject<SurfaceFieldType>(fieldName)
115 );
116 }
117 else
118 {
119 transformField<SurfaceFieldType>
120 (
121 srotTensor(),
122 lookupObject<SurfaceFieldType>(fieldName)
123 );
124 }
125 }
126 else
127 {
128 IOobject fieldHeader
129 (
130 fieldName,
131 mesh_.time().timeName(),
132 mesh_,
133 IOobject::MUST_READ,
134 IOobject::NO_WRITE
135 );
136
137 if (fieldHeader.typeHeaderOk<VolFieldType>(true, true, false))
138 {
140 << type() << ": Field " << fieldName << " read from file"
141 << endl;
142
143 if (csysPtr_->uniform() || pTraits<Type>::nComponents == 1)
144 {
145 transformField<VolFieldType>
146 (
147 lookupObject<VolFieldType>(fieldName)
148 );
149 }
150 else
151 {
152 transformField<VolFieldType>
153 (
154 vrotTensor(),
155 lookupObject<VolFieldType>(fieldName)
156 );
157 }
158 }
159 else if (fieldHeader.typeHeaderOk<SurfaceFieldType>(true, true, false))
160 {
162 << type() << ": Field " << fieldName << " read from file"
163 << endl;
164
165 if (csysPtr_->uniform() || pTraits<Type>::nComponents == 1)
166 {
167 transformField<SurfaceFieldType>
168 (
169 lookupObject<SurfaceFieldType>(fieldName)
170 );
171 }
172 else
173 {
174 transformField<SurfaceFieldType>
175 (
176 srotTensor(),
177 lookupObject<SurfaceFieldType>(fieldName)
178 );
179 }
180 }
181 }
182}
183
184
185// ************************************************************************* //
rDeltaTY field()
#define DebugInfo
Report an information message using Foam::Info.
type
Types of root.
Definition: Roots.H:55
dimensionSet invTransform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:542
dimensioned< tensor > dimensionedTensor
Dimensioned tensor obtained from generic dimensioned type.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
Foam::surfaceFields.
Spatial transformation functions for GeometricField.