Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
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\*---------------------------------------------------------------------------*/
29#include "symmTransformField.H"
30#include "FieldM.H"
31
32// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
33
34template<class Type>
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
50template<class Type>
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
71template<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
85template<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
100template<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
115template<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
131template<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
145template<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// ************************************************************************* //
Declaration macros for Field<Type> algebra.
#define TFOR_ALL_F_OP_FUNC_F_F(typeF1, f1, OP, FUNC, typeF2, f2, typeF3, f3)
Definition FieldM.H:192
#define TFOR_ALL_F_OP_FUNC_S_F(typeF1, f1, OP, FUNC, typeS, s, typeF2, f2)
Definition FieldM.H:277
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
T & front()
Access first element of the list, position [0].
Definition UListI.H:239
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
A class for managing temporary objects.
Definition tmp.H:75
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.
Field< symmTensor > symmTensorField
Specialisation of Field<T> for symmTensor.
SymmTensor< scalar > symmTensor
SymmTensor of scalars, i.e. SymmTensor<scalar>.
Definition symmTensor.H:55