symmTransformField.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-2016 OpenFOAM Foundation
9  Copyright (C) 2023 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 \*---------------------------------------------------------------------------*/
28 
30 #include "FieldM.H"
31 
32 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
33 
34 template<class Type>
35 void Foam::transform
36 (
37  Field<Type>& result,
38  const symmTensor& rot,
39  const Field<Type>& fld
40 )
41 {
42  // std::transform
44  (
45  Type, result, =, transform, symmTensor, rot, Type, fld
46  );
47 }
48 
49 
50 template<class Type>
51 void Foam::transform
52 (
53  Field<Type>& result,
54  const symmTensorField& rot,
55  const Field<Type>& fld
56 )
57 {
58  if (rot.size() == 1)
59  {
60  return transform(result, rot.front(), fld);
61  }
62 
63  // std::transform
65  (
66  Type, result, =, transform, symmTensor, rot, Type, fld
67  );
68 }
69 
70 
71 template<class Type>
74 (
75  const symmTensorField& rot,
76  const Field<Type>& fld
77 )
78 {
79  auto tresult = tmp<Field<Type>>::New(fld.size());
80  transform(tresult.ref(), rot, fld);
81  return tresult;
82 }
83 
84 
85 template<class Type>
88 (
89  const symmTensorField& rot,
90  const tmp<Field<Type>>& tfld
91 )
92 {
93  tmp<Field<Type>> tresult = New(tfld);
94  transform(tresult.ref(), rot, tfld());
95  tfld.clear();
96  return tresult;
97 }
98 
99 
100 template<class Type>
103 (
104  const tmp<symmTensorField>& trot,
105  const Field<Type>& fld
106 )
107 {
108  auto tresult = tmp<Field<Type>>::New(fld.size());
109  transform(tresult.ref(), trot(), fld);
110  trot.clear();
111  return tresult;
112 }
113 
114 
115 template<class Type>
118 (
119  const tmp<symmTensorField>& trot,
120  const tmp<Field<Type>>& tfld
121 )
122 {
123  tmp<Field<Type>> tresult = New(tfld);
124  transform(tresult.ref(), trot(), tfld());
125  trot.clear();
126  tfld.clear();
127  return tresult;
128 }
129 
130 
131 template<class Type>
134 (
135  const symmTensor& rot,
136  const Field<Type>& fld
137 )
138 {
139  auto tresult = tmp<Field<Type>>::New(fld.size());
140  transform(tresult.ref(), rot, fld);
141  return tresult;
142 }
143 
144 
145 template<class Type>
148 (
149  const symmTensor& rot,
150  const tmp<Field<Type>>& tfld
151 )
152 {
153  tmp<Field<Type>> tresult = New(tfld);
154  transform(tresult.ref(), rot, tfld());
155  tfld.clear();
156  return tresult;
157 }
158 
159 
160 // ************************************************************************* //
#define TFOR_ALL_F_OP_FUNC_F_F(typeF1, f1, OP, FUNC, typeF2, f2, typeF3, f3)
Definition: FieldM.H:192
Field< symmTensor > symmTensorField
Specialisation of Field<T> for symmTensor.
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.
Generic templated field type.
Definition: Field.H:62
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
Definition: symmTensor.H:55
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
#define TFOR_ALL_F_OP_FUNC_S_F(typeF1, f1, OP, FUNC, typeS, s, typeF2, f2)
Definition: FieldM.H:277
void clear()
Clear exponents - resets to be dimensionless.
Definition: dimensionSet.C:136
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Declaration macros for Field<Type> algebra.
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:521