complexVectorField.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 OpenFOAM Foundation
9  Copyright (C) 2019 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 
29 #include "complexVectorField.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineCompoundTypeName(List<complexVector>, complexVectorList);
38 }
39 
40 
41 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
42 
44 (
45  const UList<vector>& re,
46  const UList<vector>& im
47 )
48 {
49  complexVectorField cvf(re.size());
50 
51  for (direction cmpt=0; cmpt<vector::nComponents; ++cmpt)
52  {
53  forAll(cvf, i)
54  {
55  cvf[i].component(cmpt).Re() = re[i].component(cmpt);
56  cvf[i].component(cmpt).Im() = im[i].component(cmpt);
57  }
58  }
59 
60  return cvf;
61 }
62 
63 
65 {
66  complexVectorField cvf(re.size());
67 
68  for (direction cmpt=0; cmpt<vector::nComponents; ++cmpt)
69  {
70  forAll(cvf, i)
71  {
72  cvf[i].component(cmpt).Re() = re[i].component(cmpt);
73  cvf[i].component(cmpt).Im() = 0.0;
74  }
75  }
76 
77  return cvf;
78 }
79 
80 
81 Foam::complexVectorField Foam::ImComplexField(const UList<vector>& im)
82 {
83  complexVectorField cvf(im.size());
84 
85  for (direction cmpt=0; cmpt<vector::nComponents; ++cmpt)
86  {
87  forAll(cvf, i)
88  {
89  cvf[i].component(cmpt).Re() = 0.0;
90  cvf[i].component(cmpt).Im() = im[i].component(cmpt);
91  }
92  }
93 
94  return cvf;
95 }
96 
97 
98 Foam::vectorField Foam::ReImSum(const UList<complexVector>& cvf)
99 {
100  vectorField vf(cvf.size());
101 
102  for (direction cmpt=0; cmpt<vector::nComponents; ++cmpt)
103  {
104  forAll(cvf, i)
105  {
106  vf[i].component(cmpt) =
107  cvf[i].component(cmpt).Re() + cvf[i].component(cmpt).Im();
108  }
109  }
110 
111  return vf;
112 }
113 
114 
115 Foam::vectorField Foam::Re(const UList<complexVector>& cvf)
116 {
117  vectorField vf(cvf.size());
118 
119  for (direction cmpt=0; cmpt<vector::nComponents; ++cmpt)
120  {
121  forAll(cvf, i)
122  {
123  vf[i].component(cmpt) = cvf[i].component(cmpt).Re();
124  }
125  }
126 
127  return vf;
128 }
129 
130 
131 Foam::vectorField Foam::Im(const UList<complexVector>& cvf)
132 {
133  vectorField vf(cvf.size());
134 
135  for (direction cmpt=0; cmpt<vector::nComponents; ++cmpt)
136  {
137  forAll(cvf, i)
138  {
139  vf[i].component(cmpt) = cvf[i].component(cmpt).Im();
140  }
141  }
142 
143  return vf;
144 }
145 
146 
147 Foam::complexVectorField Foam::operator^
148 (
149  const UList<vector>& vf,
150  const UList<complexVector>& cvf
151 )
152 {
153  return ComplexField(vf^Re(cvf), vf^Im(cvf));
154 }
155 
156 
157 // ************************************************************************* //
Foam::ComplexField
complexField ComplexField(const UList< scalar > &re, const UList< scalar > &im)
Definition: complexField.C:98
forAll
#define forAll(list, i)
Definition: stdFoam.H:349
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:48
Foam::ReComplexField
complexField ReComplexField(const UList< scalar > &re)
Definition: complexField.C:111
Foam::Im
scalarField Im(const UList< complex > &cf)
Definition: complexField.C:165
Foam::Field
Generic templated field type.
Definition: Field.H:59
Foam::complexVectorField
Field< complexVector > complexVectorField
Specialisation of Field<T> for complexVector.
Definition: complexVectorField.H:48
Foam::constant::atomic::re
const dimensionedScalar re
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Definition: atmBoundaryLayer.C:26
Foam::Field::component
tmp< Field< cmptType > > component(const direction) const
Definition: Field.C:532
Foam::ImComplexField
complexField ImComplexField(const UList< scalar > &im)
Definition: complexField.C:125
Foam::ReImSum
scalarField ReImSum(const UList< complex > &cf)
Definition: complexField.C:139
Foam::addCompoundToRunTimeSelectionTable
addCompoundToRunTimeSelectionTable(List< complex >, complexList)
Foam::defineCompoundTypeName
defineCompoundTypeName(List< complex >, complexList)
Foam::dimensioned::component
dimensioned< cmptType > component(const direction d) const
Definition: dimensionedType.C:443
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:58
complexVectorField.H
Foam::UList
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:99
Foam::Re
scalarField Re(const UList< complex > &cf)
Definition: complexField.C:152
Foam::direction
uint8_t direction
Definition: direction.H:46
Foam::UList::size
void size(const label n)
Definition: UList.H:110