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);
37  addCompoundToRunTimeSelectionTable(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 
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 
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 
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 
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)
Zip up two lists of values into a list of complex.
Definition: complexField.C:105
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::ReComplexField
complexField ReComplexField(const UList< scalar > &re)
Create complex field from a list of real (using imag == 0)
Definition: complexField.C:118
Foam::Im
scalarField Im(const UList< complex > &cf)
Extract imag component.
Definition: complexField.C:172
Foam::Field< complexVector >
Foam::constant::atomic::re
const dimensionedScalar re
Classical electron radius: default SI units: [m].
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::ImComplexField
complexField ImComplexField(const UList< scalar > &im)
Create complex field from a list of imag (using real == 0)
Definition: complexField.C:132
Foam::ReImSum
scalarField ReImSum(const UList< complex > &cf)
Sum real and imag components.
Definition: complexField.C:146
Foam::addCompoundToRunTimeSelectionTable
addCompoundToRunTimeSelectionTable(List< complex >, complexList)
Foam::defineCompoundTypeName
defineCompoundTypeName(List< complex >, complexList)
Foam::dimensioned::component
dimensioned< cmptType > component(const direction d) const
Return a component as a dimensioned<cmptType>
Definition: dimensionedType.C:450
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:103
Foam::Re
scalarField Re(const UList< complex > &cf)
Extract real component.
Definition: complexField.C:159
Foam::direction
uint8_t direction
Definition: direction.H:52
Foam::UList::size
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114