15 typedef complex<double>
Cd_t;
16 typedef valarray<complex<double> >
Vcd_t;
17 complex<double>
ii(0.0, 1.0);
33 valarray<double> kz(Nz);
34 valarray<double> kx(Nx);
35 valarray<double> z(Nz);
36 valarray<double> x(Nx);
37 valarray<double> omval(Nx);
55 omval = omega * omval;
57 valarray<double>
y, Uy, U, Uyy(
N + 1);
62 U = 1.0 -
pow(
y, 2.0);
75 Lbc.L << 1.0, 0.0, 0.0, 0.0,
79 Rbc.L << 1.0, 0.0, 0.0, 0.0,
83 Lbc.eval.setConstant(-1.0);
84 Rbc.eval.setConstant(1.0);
100 C << 1.0, 0.0, 0.0, 0.0,
103 outf.open(
"data/file2.txt");
141 valarray<complex<double> > uvec(
Cd_t(0.0, 0.0), (
N + 1) * 4),
142 vvec(
Cd_t(0.0, 0.0), (
N + 1) * 4), wvec(
Cd_t(0.0, 0.0), (
N + 1) * 4),
143 pvec(
Cd_t(0.0, 0.0), (
N + 1) * 4);
144 valarray<double> u3d((
N + 1) * Nx * Nz), v3d((
N + 1) * Nx * Nz),
145 w3d((
N + 1) * Nx * Nz), p3d((
N + 1) * Nx * Nz);
147 for (
int k = 0; k < 4; k++)
149 complex<double> iiomega =
ii * omega;
150 double k2 = kx[k] * kx[k] + kz[k] * kz[k];
155 Delta.coef << 1.0, 0.0, -k2;
156 Delta2.
coef << 1.0, 0.0, -2 * k2, 0.0, k4;
158 Mmat << 1.0, 0.0, 0.0, 0.0,
161 0.0, 0.0, 0.0, 0.0 * Delta;
163 Lmat << (-
ii * kx[k] * U) + (Delta / Re), -Uy, 0.0, -
ii * kx[k],
164 0.0, (-
ii * kx[k] * U) + (Delta / Re), 0.0, -Dy,
165 0.0, 0.0, (-
ii * kx[k] * U) + (Delta / Re), -
ii * kz[k],
166 ii * kx[k], Dy,
ii * kz[k], 0.0;
169 A = ((iiomega * Mmat) - Lmat);
171 svd.
compute(A, B, C, Lbc, Rbc, Lbc, Rbc, 15 * (
N + 1));
172 std::cout <<
"eigenvalue: " << svd.
eigenvalues[0] <<
"\n";
176 outf << kx[k] <<
" " << kz[k] <<
" " << svd.
eigenvalues[0].real() <<
" " 179 uvec[slice(k,
N+1,Nz)] =
181 svd.eigenvectors(0,0).v;
183 vvec[slice(k,
N+1,Nz)] =
185 svd.eigenvectors(1,0).v;
187 wvec[slice(k,
N+1,Nz)] =
189 svd.eigenvectors(2,0).v;
191 pvec[slice(k,
N+1,Nz)] =
193 svd.eigenvectors(3,0).v;
196 Eigen::VectorXd xval, zval;
198 zval = Eigen::VectorXd::LinSpaced(100, -7.8, 7.8);
199 xval = Eigen::VectorXd::LinSpaced(100, 0, 12.7);
202 Vcd_t u3dc(
Cd_t(0.0, 0.0), (
N + 1) * Nx * Nz),
203 v3dc(
Cd_t(0.0, 0.0), (
N + 1) * Nx * Nz),
204 w3dc(
Cd_t(0.0, 0.0), (
N + 1) * Nx * Nz),
205 p3dc(
Cd_t(0.0, 0.0), (
N + 1) * Nx * Nz);
207 for (
int j = 0; j < xval.size(); j++)
210 for (
int k = 0; k < zval.size(); k++)
213 for (
int i = 0; i < 4; i++)
217 u3dc[slice(j * Nz + k,
N + 1, Nx * Nz)] +=
218 Vcd_t(uvec[slice(i,
N + 1, 4)]) *
219 exp((
ii * kx1 * x) + (
ii * kz1 * z));
220 v3dc[slice(j * Nz + k,
N + 1, Nx * Nz)] +=
221 Vcd_t(vvec[slice(i,
N + 1, 4)]) *
222 exp((
ii * kx1 * x) + (
ii * kz1 * z));
223 w3dc[slice(j * Nz + k,
N + 1, Nx * Nz)] +=
224 Vcd_t(wvec[slice(i,
N + 1, 4)]) *
225 exp((
ii * kx1 * x) + (
ii * kz1 * z));
226 p3dc[slice(j * Nz + k,
N + 1, Nx * Nz)] +=
227 Vcd_t(pvec[slice(i,
N + 1, 4)]) *
228 exp((
ii * kx1 * x) + (
ii * kz1 * z));
237 x.resize(xval.size());
238 z.resize(zval.size());
239 std::cout <<
"xval: \n" 241 std::cout <<
"zval: \n" 243 std::cout <<
"x.size(): " << xval.size() <<
'\n';
244 std::cout <<
"z.size(): " << zval.size() <<
'\n';
245 for (
int i = 0; i < xval.size(); i++)
249 for (
int i = 0; i < zval.size(); i++)
255 string filename(
"data/Ex11vec_noscale0385");
256 std::cout <<
"z.size(): " << z.size() <<
'\n';
BcMat will hold general Boundary conditions as LinopMats at evealuation points, as given by operator ...
valarray< complex< double > > Vcd_t
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > eval
Linop This class creates a Linear operator to solve TPBVPs.
complex< double > ii(0.0, 1.0)
void vtkExportCartesian3D(const std::string &flnm, const std::valarray< double > &x, const std::valarray< double > &y, const std::valarray< double > &z, const std::valarray< double > &u, const std::valarray< double > &v, const std::valarray< double > &w, const std::valarray< double > &p)
Exports all data of 3D velocity to a file. VTK file can be directly exported into paraview...
Eigen::Matrix< std::complex< T >, Eigen::Dynamic, 1 > eigenvalues
This class represents a block matrix operator. It is a matrix of operators.
void compute(const LinopMat< T > &A_, const BcMat< T > &Lbc_, const BcMat< T > &Rbc_, int num_vals)
Computes the singular values/functions of a Linear block matrix operator.
Eigen::Matrix< T, Eigen::Dynamic, 1 > coef
Stores the coefficients in the differential equation.
void setChebPts(std::valarray< T > &in)
This function sets points to evaluate a function so that a DCT will give represent the same function ...
valarray< complex< T > > pow(valarray< complex< T > > base, T power)
This class computes various SingularValues of a differential block matrix operator using using it's a...
int N
Specifies number of Chebyshev polynomials, default N = 31.
valarray< T > real(const valarray< complex< T > > &in)
real part of a complex valarray
std::valarray< SIS_TYPE > y(N+1)
void resize(int r_, int c_)
This clears all contents in the LinopMat, and then creates a fresh LinopMat of size r_ x c_...