coordinateSystemTemplates.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) 2018 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28#include "coordinateSystem.H"
29#include "transform.H"
30
31// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
32
33template<class PointField>
36{
37 const label len = global.size();
38
39 auto tresult = tmp<tensorField>::New(len);
40 auto& result = tresult.ref();
41
42 for (label i=0; i<len; ++i)
43 {
44 result[i] = this->R(global[i]);
45 }
46
47 return tresult;
48}
49
50
51template<class PointField>
54{
55 const label len = localCart.size();
56
57 auto tresult = tmp<pointField>::New(len);
58 auto& result = tresult.ref();
59
60 for (label i=0; i<len; ++i)
61 {
62 result[i] = Foam::transform(rot_, localCart[i]) + origin_;
63 }
64
65 return tresult;
66}
67
68
69template<class PointField>
72{
73 const label len = global.size();
74
75 auto tresult = tmp<pointField>::New(len);
76 auto& result = tresult.ref();
77
78 for (label i=0; i<len; ++i)
79 {
80 result[i] = Foam::invTransform(rot_, global[i] - origin_);
81 }
82
83 return tresult;
84}
85
86
87template<class RetType, class Type, class BinaryOp>
90(
91 const tensor& tt,
92 const UList<Type>& input,
93 const BinaryOp& bop
94)
95{
96 const label len = input.size();
97
98 auto tresult = tmp<Field<RetType>>::New(len);
99 auto& result = tresult.ref();
100
101 for (label i=0; i<len; ++i)
102 {
103 result[i] = bop(tt, input[i]);
104 }
105
106 return tresult;
107}
108
109
110template<class RetType, class PointField, class Type, class BinaryOp>
113(
114 const PointField& global,
115 const UList<Type>& input,
116 const BinaryOp& bop
117) const
118{
119 const label len = input.size();
120
121 if (len != global.size())
122 {
124 << "positions has different size from input field"
125 << abort(FatalError);
126 }
127
128 auto tresult = tmp<Field<RetType>>::New(len);
129 auto& result = tresult.ref();
130
131 for (label i=0; i<len; ++i)
132 {
133 result[i] = bop(this->R(global[i]), input[i]);
134 }
135
136 return tresult;
137}
138
139
140template<class RetType, class PointField, class Type, class BinaryOp>
143(
144 const PointField& global,
145 const Type& input,
146 const BinaryOp& bop
147) const
148{
149 const label len = global.size();
150
151 auto tresult = tmp<Field<RetType>>::New(len);
152 auto& result = tresult.ref();
153
154 for (label i=0; i<len; ++i)
155 {
156 result[i] = bop(this->R(global[i]), input);
157 }
158
159 return tresult;
160}
161
162
163// ************************************************************************* //
#define R(A, B, C, D, E, F, K, M)
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:94
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
tmp< tensorField > rotationsImpl(const PointField &global) const
Implementation for R() methods.
tmp< pointField > invTransformPointImpl(const PointField &global) const
Implementation for transformPosition() methods.
tmp< Field< RetType > > oneToOneImpl(const PointField &global, const UList< Type > &input, const BinaryOp &bop) const
Use position-dependent transform tensors for multiple inputs.
static tmp< Field< RetType > > manyTimesImpl(const tensor &tt, const UList< Type > &input, const BinaryOp &bop)
Apply single transform tensor for multiple inputs.
tmp< Field< RetType > > oneToManyImpl(const PointField &global, const Type &input, const BinaryOp &bop) const
Use position-dependent transform tensors for single input.
virtual const tensor & R() const
Return const reference to the rotation tensor.
tmp< pointField > transformPointImpl(const PointField &localCart) const
Implementation for transformPoint() methods.
A class for managing temporary objects.
Definition: tmp.H:65
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
dimensionSet invTransform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:542
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:536
static Istream & input(Istream &is, IntRange< T > &range)
Definition: IntRanges.C:55
errorManip< error > abort(error &err)
Definition: errorManip.H:144
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
error FatalError
3D tensor transformation operations.