transformerTemplates.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
27 
28 template<class Type>
29 Type Foam::transformer::transform(const Type& x) const
30 {
31  if (transforms())
32  {
33  return Foam::transform(T(), x);
34  }
35  else
36  {
37  return x;
38  }
39 }
40 
41 
42 template<class Type>
44 (
45  Field<Type>& res,
46  const Field<Type>& fld
47 ) const
48 {
49  if (transforms())
50  {
51  return Foam::transform(res, T(), fld);
52  }
53 }
54 
55 
56 template<class Type>
58 (
59  const Field<Type>& fld
60 ) const
61 {
62  if (transforms())
63  {
64  return Foam::transform(T(), fld);
65  }
66  else
67  {
68  return fld;
69  }
70 }
71 
72 
73 template<class Type>
75 (
76  const tmp<Field<Type>>& tfld
77 ) const
78 {
79  if (transforms())
80  {
81  return Foam::transform(T(), tfld);
82  }
83  else
84  {
85  return tfld;
86  }
87 }
88 
89 
90 template<class Type, template<class> class Container>
91 void Foam::transformer::transformList(Container<Type>& l) const
92 {
93  if (transforms())
94  {
95  forAllIter(typename Container<Type>, l, iter)
96  {
97  *iter = Foam::transform(T(), *iter);
98  }
99  }
100 }
101 
102 
103 template<class Type>
104 Type Foam::transformer::invTransform(const Type& x) const
105 {
106  if (transforms())
107  {
108  return Foam::transform(invT(), x);
109  }
110  else
111  {
112  return x;
113  }
114 }
115 
116 
117 template<class Type>
119 (
120  Field<Type>& res,
121  const Field<Type>& fld
122 ) const
123 {
124  if (transforms())
125  {
126  Foam::transform(res, invT(), fld);
127  }
128 }
129 
130 
131 template<class Type>
133 (
134  const Field<Type>& fld
135 ) const
136 {
137  if (transforms())
138  {
139  return Foam::transform(invT(), fld);
140  }
141  else
142  {
143  return fld;
144  }
145 }
146 
147 
148 template<class Type>
150 (
151  const tmp<Field<Type>>& tfld
152 ) const
153 {
154  if (transforms())
155  {
156  return Foam::transform(invT(), tfld);
157  }
158  else
159  {
160  return tfld;
161  }
162 }
163 
164 
165 template<class Type, template<class> class Container>
166 void Foam::transformer::invTransformList(Container<Type>& l) const
167 {
168  if (transforms())
169  {
170  tensor invT = this->invT();
171 
172  forAllIter(typename Container<Type>, l, iter)
173  {
174  *iter = Foam::transform(invT, *iter);
175  }
176  }
177 }
178 
179 
180 // ************************************************************************* //
void invTransformList(Container< Type > &) const
Inverse transform the given container.
bool transforms() const
Return true if the transformer transforms a type.
Definition: transformerI.H:133
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:459
void transformList(Container< Type > &) const
Transform the given container.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Pre-declare SubField and related Field type.
Definition: Field.H:56
tensor invT() const
Return the inverse transformation tensor.
Definition: transformerI.H:100
const tensor & T() const
Return the transformation tensor.
Definition: transformerI.H:94
Type transform(const Type &) const
Transform the given type.
A class for managing temporary objects.
Definition: PtrList.H:53
Type invTransform(const Type &) const
Inverse transform the given type.
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:483