Loading...
Searching...
No Matches
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
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 }
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 }
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 }
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 }
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 }
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)
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:89
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
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.
tensor rot_
The rotation tensor.
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.
point origin_
The coordinate system origin.
tmp< pointField > transformPointImpl(const PointField &localCart) const
Implementation for transformPoint() methods.
A class for managing temporary objects.
Definition tmp.H:75
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Definition tmp.H:215
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
dimensionSet invTransform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
Tensor< scalar > tensor
Definition symmTensor.H:57
errorManip< error > abort(error &err)
Definition errorManip.H:139
GeometricField< Type, pointPatchField, pointMesh > PointField
A point field for a given type.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
3D tensor transformation operations.