1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Specialisation of Field\<T\> for complex and complexVector.
28 \*---------------------------------------------------------------------------*/
30 #include "complexFields.H"
31 #include "addToRunTimeSelectionTable.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 defineCompoundTypeName(List<complex>, complexList);
41 addCompoundToRunTimeSelectionTable(List<complex>, complexList);
43 complexField ComplexField(const UList<scalar>& re, const UList<scalar>& im)
45 complexField cf(re.size());
57 complexField ReComplexField(const UList<scalar>& sf)
59 complexField cf(sf.size());
71 complexField ImComplexField(const UList<scalar>& sf)
73 complexField cf(sf.size());
85 scalarField ReImSum(const UList<complex>& cf)
87 scalarField sf(cf.size());
91 sf[i] = cf[i].Re() + cf[i].Im();
98 scalarField Re(const UList<complex>& cf)
100 scalarField sf(cf.size());
111 scalarField Im(const UList<complex>& cf)
113 scalarField sf(cf.size());
124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 defineCompoundTypeName(List<complexVector>, complexVectorList);
127 addCompoundToRunTimeSelectionTable(List<complexVector>, complexVectorList);
129 complexVectorField ComplexField(const UList<vector>& re, const UList<vector>& im)
131 complexVectorField cvf(re.size());
133 for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
137 cvf[i].component(cmpt).Re() = re[i].component(cmpt);
138 cvf[i].component(cmpt).Im() = im[i].component(cmpt);
146 complexVectorField ReComplexField(const UList<vector>& vf)
148 complexVectorField cvf(vf.size());
150 for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
154 cvf[i].component(cmpt).Re() = vf[i].component(cmpt);
155 cvf[i].component(cmpt).Im() = 0.0;
163 complexVectorField ImComplexField(const UList<vector>& vf)
165 complexVectorField cvf(vf.size());
167 for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
171 cvf[i].component(cmpt).Re() = 0.0;
172 cvf[i].component(cmpt).Im() = vf[i].component(cmpt);
180 vectorField ReImSum(const UList<complexVector>& cvf)
182 vectorField vf(cvf.size());
184 for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
188 vf[i].component(cmpt) =
189 cvf[i].component(cmpt).Re() + cvf[i].component(cmpt).Im();
197 vectorField Re(const UList<complexVector>& cvf)
199 vectorField vf(cvf.size());
201 for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
205 vf[i].component(cmpt) = cvf[i].component(cmpt).Re();
213 vectorField Im(const UList<complexVector>& cvf)
215 vectorField vf(cvf.size());
217 for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
221 vf[i].component(cmpt) = cvf[i].component(cmpt).Im();
229 complexVectorField operator^
231 const UList<vector>& vf,
232 const UList<complexVector>& cvf
235 return ComplexField(vf^Re(cvf), vf^Im(cvf));
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 } // End namespace Foam
243 // ************************************************************************* //