12 PetscScalar Re = params.
Re;
13 PetscScalar alpha = params.
alpha;
14 PetscScalar omega = params.
omega;
15 PetscScalar beta = params.
beta;
16 PetscScalar i=PETSC_i;
17 PetscScalar k=alpha*alpha+beta*beta;
30 {d, Uy, O, i*alpha*I},
33 {i*alpha*I, grid.
Dy, i*beta*I, O }
64 std::vector<PetscInt> rowBCs = {n-2,n-1,2*n-2,2*n-1,3*n-2,3*n-1};
68 for(PetscInt j=0; j<n; ++j){
69 L(rowBCs[0],j,grid.
T(0,j,PETSC_TRUE));
70 L(rowBCs[1],j,grid.
T(n-1,j,PETSC_TRUE));
71 L(rowBCs[2],n+j,grid.
T(0,j,PETSC_TRUE));
72 L(rowBCs[3],n+j,grid.
T(n-1,j,PETSC_TRUE));
73 L(rowBCs[4],2*n+j,grid.
T(0,j,PETSC_TRUE));
74 L(rowBCs[5],2*n+j,grid.
T(n-1,j,PETSC_TRUE));
114 std::vector<PetscInt> rowBCs = {0,n-1,n,2*n-1,2*n,3*n-1};
142 params.
omega = omega;
144 return std::make_tuple(omega,eig_vec);
153 PetscInt n = grid.
ny;
154 PetscScalar Re = params.
Re;
155 PetscScalar alpha = params.
alpha;
156 PetscScalar omega = params.
omega;
157 PetscScalar beta = params.
beta;
158 PetscScalar i=PETSC_i;
171 SPIMat d(Dyy + i*Re*omega*I - beta*beta*I,
"d");
178 {O, O, d, -i*Re*beta*I},
182 {-i*Re*U, O, O, -i*Re*I},
196 std::vector<PetscInt> rowBCs = {n-2,n-1,2*n-2,2*n-1,3*n-2,3*n-1};
199 L2.zero_rows(rowBCs);
200 for(PetscInt j=0; j<n; ++j){
201 L0(rowBCs[0],j,grid.
T(0,j,PETSC_TRUE));
202 L0(rowBCs[1],j,grid.
T(n-1,j,PETSC_TRUE));
203 L0(rowBCs[2],n+j,grid.
T(0,j,PETSC_TRUE));
204 L0(rowBCs[3],n+j,grid.
T(n-1,j,PETSC_TRUE));
205 L0(rowBCs[4],2*n+j,grid.
T(0,j,PETSC_TRUE));
206 L0(rowBCs[5],2*n+j,grid.
T(n-1,j,PETSC_TRUE));
232 PetscInt rowBCs[] = {0,n-1,n,2*n-1,2*n,3*n-1};
233 for(PetscInt rowi : rowBCs){
259 params.
alpha = alpha;
261 return std::make_tuple(alpha,eig_vec);
265 {O, O, O, O, I, O, O, O},
266 {O, O, O, O, O, I, O, O},
267 {O, O, O, O, O, O, I, O},
268 {O, O, O, O, O, O, O, I},
269 {d, -Re*Uy, O, O, -i*Re*U, O, O, -i*Re*I},
270 {O, d, O, -Re*Dy, O, -i*Re*U, O, O},
271 {O, O, d, -i*Re*beta*I,O, O, -i*Re*U, O},
272 {O, Dy, i*beta*I, O, i*I, O, O, O},
275 {I, O, O, O, O, O, O, O},
276 {O, I, O, O, O, O, O, O},
277 {O, O, I, O, O, O, O, O},
278 {O, O, O, I, O, O, O, O},
279 {O, O, O, O, I, O, O, O},
280 {O, O, O, O, O, I, O, O},
281 {O, O, O, O, O, O, I, O},
282 {O, O, O, O, O, O, O, O},
286 PetscInt rowBCs[] = {4*n,5*n-1,5*n,6*n-1,6*n,7*n-1};
287 for(PetscInt rowi : rowBCs){
299 std::tie(alpha,eigl_vec,eig_vec) =
SPI::eig(M,L,1./alpha);
302 params.
alpha = alpha;
304 return std::make_tuple(alpha,eig_vec);
307 d = 1./Re*(Dyy - beta*beta*I) + i*omega*I;
310 {O, i*Dy, -beta*I, O, O, O},
313 {-i*d, i*(Uy-U*Dy),beta*U, O, -1./Re*Dy, -i*beta/Re*I},
314 {O, i*Re*d, O, -i*Re*Dy, Re*U, O},
315 {O, O, i*Re*d, beta*Re*I, O, Re*U},
327 PetscInt rowBCs[] = {0*n,1*n-1,1*n,2*n-1,2*n,3*n-1};
328 for(PetscInt rowi : rowBCs){
338 std::tie(alpha,eigl_vec,eig_vec) =
SPI::eig_init(L,M,alpha,q.
conj(),q,1e-16,20000);
340 std::tie(alpha,eigl_vec,eig_vec) =
SPI::eig(L,M,alpha,1e-12,20000);
343 params.
alpha = alpha;
345 return std::make_tuple(alpha,eig_vec);
354 PetscInt n = grid.
ny;
355 PetscScalar Re = params.
Re;
356 PetscScalar alpha = params.
alpha;
357 PetscScalar omega = params.
omega;
358 PetscScalar beta = params.
beta;
359 PetscScalar i=PETSC_i;
372 SPIMat d(Dyy + i*Re*omega*I - beta*beta*I,
"d");
379 {O, O, d, -i*Re*beta*I},
383 {-i*Re*U, O, O, -i*Re*I},
412 std::vector<PetscInt> rowBCs = {n-2,n-1,2*n-2,2*n-1,3*n-2,3*n-1};
415 L2.zero_rows(rowBCs);
416 for(PetscInt j=0; j<n; ++j){
417 L0(rowBCs[0],j,grid.
T(0,j,PETSC_TRUE));
418 L0(rowBCs[1],j,grid.
T(n-1,j,PETSC_TRUE));
419 L0(rowBCs[2],n+j,grid.
T(0,j,PETSC_TRUE));
420 L0(rowBCs[3],n+j,grid.
T(n-1,j,PETSC_TRUE));
421 L0(rowBCs[4],2*n+j,grid.
T(0,j,PETSC_TRUE));
422 L0(rowBCs[5],2*n+j,grid.
T(n-1,j,PETSC_TRUE));
448 PetscInt rowBCs[] = {0,n-1,n,2*n-1,2*n,3*n-1};
449 for(PetscInt rowi : rowBCs){
487 std::tie(alpha,eigl_vec,eig_vec) =
eig(L,M,alpha);
489 params.
alpha = alpha;
501 {dLdomega4, O4}})(),
"dLdomega");
508 {O4, -L2_noBCs_physical}})(),
"M noBCs physical");
510 {i*Re*
eye(n), O, O, O},
511 {O, i*Re*
eye(n),O, O},
512 {O, O, i*Re*
eye(n),O},
517 {dLdomega4_physical, O4}})(),
"dLdomega");
532 {grid.
T,O,O,O,O,O,O,O},
533 {O,grid.
T,O,O,O,O,O,O},
534 {O,O,grid.
T,O,O,O,O,O},
535 {O,O,O,grid.
T,O,O,O,O},
536 {O,O,O,O,grid.
T,O,O,O},
537 {O,O,O,O,O,grid.
T,O,O},
538 {O,O,O,O,O,O,grid.
T,O},
539 {O,O,O,O,O,O,O,grid.
T},
568 cg = (M_noBCs_physical*(T*eig_vec)).dot(T*eigl_vec) / ((dLdomega_physical*(T*eig_vec))).
dot(T*eigl_vec);
569 SPI::printfc(
"in LST_spatial_cg physical noBCs cg = %.10f + %.10fi",cg);
620 SPI::printfc(
"in LST_spatial_cg physical integrate cg = %.10f + %.10fi",cg);
621 cg = (((eig_vec)).dot(M*eigl_vec)) / ((dLdomega*(eig_vec)).
dot(eigl_vec));
622 SPI::printfc(
"in LST_spatial_cg physical dot cg = %.10f + %.10fi",cg);
625 return std::make_tuple(alpha,cg,eigl_vec,eig_vec);
629 {O, O, O, O, I, O, O, O},
630 {O, O, O, O, O, I, O, O},
631 {O, O, O, O, O, O, I, O},
632 {O, O, O, O, O, O, O, I},
633 {d, -Re*Uy, O, O, -i*Re*U, O, O, -i*Re*I},
634 {O, d, O, -Re*Dy, O, -i*Re*U, O, O},
635 {O, O, d, -i*Re*beta*I,O, O, -i*Re*U, O},
636 {O, Dy, i*beta*I, O, i*I, O, O, O},
639 {I, O, O, O, O, O, O, O},
640 {O, I, O, O, O, O, O, O},
641 {O, O, I, O, O, O, O, O},
642 {O, O, O, I, O, O, O, O},
643 {O, O, O, O, I, O, O, O},
644 {O, O, O, O, O, I, O, O},
645 {O, O, O, O, O, O, I, O},
646 {O, O, O, O, O, O, O, O},
650 PetscInt rowBCs[] = {4*n,5*n-1,5*n,6*n-1,6*n,7*n-1};
651 for(PetscInt rowi : rowBCs){
663 std::tie(alpha,eigl_vec,eig_vec) =
SPI::eig(M,L,1./alpha);
666 params.
alpha = alpha;
669 return std::make_tuple(alpha,alpha,eig_vec,eig_vec);
672 d = 1./Re*(Dyy - beta*beta*I) + i*omega*I;
675 {O, i*Dy, -beta*I, O, O, O},
678 {-i*d, i*(Uy-U*Dy),beta*U, O, -1./Re*Dy, -i*beta/Re*I},
679 {O, i*Re*d, O, -i*Re*Dy, Re*U, O},
680 {O, O, i*Re*d, beta*Re*I, O, Re*U},
692 PetscInt rowBCs[] = {0*n,1*n-1,1*n,2*n-1,2*n,3*n-1};
693 for(PetscInt rowi : rowBCs){
705 std::tie(alpha,eigl_vec,eig_vec) =
SPI::eig(L,M,alpha,1e-12,20000);
708 params.
alpha = alpha;
711 return std::make_tuple(alpha,alpha,eig_vec,eig_vec);
722 PetscInt ny = grid.
ny;
723 PetscScalar Re = params.
Re;
724 PetscScalar Reinv = 1./Re;
725 PetscScalar alpha = params.
alpha;
726 PetscScalar omega = params.
omega;
727 PetscScalar beta = params.
beta;
728 PetscScalar i=PETSC_i;
752 Uxy = S1S0That*Uxy*T;
757 Wxy = S1S0That*Wxy*T;
774 SPIMat d(VDy - Reinv*Dyy + i*beta*W + (-i*omega + beta*beta*Reinv)*I,
"d");
815 SPIMat ibetaWx = i*beta*Wx;
817 {ibetaWx, Uxy, O, O },
819 {O, Wxy, ibetaWx, O },
843 std::vector<PetscInt> rowBCs = {1*ny-2,1*ny-1,2*ny-2,2*ny-1,3*ny-2,3*ny-1};
850 for(PetscInt j=0; j<ny; ++j){
851 ABC0(rowBCs[0],j,grid.
T(0,j,PETSC_TRUE));
852 ABC0(rowBCs[1],j,grid.
T(ny-1,j,PETSC_TRUE));
853 ABC0(rowBCs[2],ny+j,grid.
T(0,j,PETSC_TRUE));
854 ABC0(rowBCs[3],ny+j,grid.
T(ny-1,j,PETSC_TRUE));
855 ABC0(rowBCs[4],2*ny+j,grid.
T(0,j,PETSC_TRUE));
856 ABC0(rowBCs[5],2*ny+j,grid.
T(ny-1,j,PETSC_TRUE));
869 std::vector<PetscInt> rowBCs = {0*ny,1*ny-1,1*ny,2*ny-1,2*ny,3*ny-1};
881 {dA0, ABC0}})(),
"L0");
884 {dA1, ABC1}})(),
"L1");
887 {dA2, ABC2}})(),
"L2");
933 std::tie(alpha,eigl_vec,eig_vec) =
SPI::eig_init(L,M,alpha,ql,qr);
935 std::tie(alpha,eigl_vec,eig_vec) =
SPI::eig(L,M,alpha);
940 params.
alpha = alpha;
947 })(),
"dLdomega 4nx4n");
952 })(),
"dLdomega 8nx8n");
957 })(),
"dLdomega 16nx16n");
982 {t,O,O,O,O,O,O,O,O,O,O,O,O,O,O,O},
983 {O,t,O,O,O,O,O,O,O,O,O,O,O,O,O,O},
984 {O,O,t,O,O,O,O,O,O,O,O,O,O,O,O,O},
985 {O,O,O,t,O,O,O,O,O,O,O,O,O,O,O,O},
986 {O,O,O,O,t,O,O,O,O,O,O,O,O,O,O,O},
987 {O,O,O,O,O,t,O,O,O,O,O,O,O,O,O,O},
988 {O,O,O,O,O,O,t,O,O,O,O,O,O,O,O,O},
989 {O,O,O,O,O,O,O,t,O,O,O,O,O,O,O,O},
990 {O,O,O,O,O,O,O,O,t,O,O,O,O,O,O,O},
991 {O,O,O,O,O,O,O,O,O,t,O,O,O,O,O,O},
992 {O,O,O,O,O,O,O,O,O,O,t,O,O,O,O,O},
993 {O,O,O,O,O,O,O,O,O,O,O,t,O,O,O,O},
994 {O,O,O,O,O,O,O,O,O,O,O,O,t,O,O,O},
995 {O,O,O,O,O,O,O,O,O,O,O,O,O,t,O,O},
996 {O,O,O,O,O,O,O,O,O,O,O,O,O,O,t,O},
997 {O,O,O,O,O,O,O,O,O,O,O,O,O,O,O,t}
1000 {-i*
eye(ny), O, O, O},
1001 {O, -i*
eye(ny), O, O},
1002 {O, O, -i*
eye(ny), O},
1004 })(),
"dLdomega 4nx4n");
1007 {dLdomega4_physical,O4},
1008 {O4, dLdomega4_physical}
1009 })(),
"dLdomega 8nx8n");
1013 {dLdomega8_physical,O8}
1014 })(),
"dLdomega 16nx16n");
1016 {Reinv*
eye(ny), O, O, O},
1017 {O, Reinv*
eye(ny), O, O},
1018 {O, O, Reinv*
eye(ny), O},
1022 {ABC2_physical, D2 },
1023 {dA2, ABC2_physical}})(),
"L2");
1026 {O8, -L2_physical}})(),
"M");
1035 PetscScalar numerator = (((M_physical*(T*eig_vec))).
dot(T*eigl_vec));
1036 PetscScalar denominator = (((dLdomega_physical*(T*eig_vec))).
dot(T*eigl_vec));
1037 cg = numerator/denominator;
1040 cg = ((M*eig_vec).
dot(eigl_vec)) / ((dLdomega*eig_vec).dot(eigl_vec));
1042 return std::make_tuple(alpha,cg,eigl_vec,eig_vec);
1052 PetscInt ny = grid.
ny;
1053 PetscScalar Re = params.
Re;
1054 PetscScalar Reinv = 1.0/Re;
1055 PetscScalar alpha = params.
alpha;
1056 PetscScalar omega = params.
omega;
1057 PetscScalar beta = params.
beta;
1058 PetscScalar i=PETSC_i;
1079 Uxy = S1S0That*Uxy*T;
1084 Wxy = S1S0That*Wxy*T;
1097 SPIMat d(VDy - Reinv*Dyy + i*beta*W + (-i*omega + beta*beta*Reinv)*I,
"d");
1129 {Wx, Wy, d, ibetaI},
1138 SPIMat ibetaWx(i*beta*Wx);
1140 {ibetaWx, Uxy, O, O },
1141 {O, ibetaWx, O, O },
1142 {O, Wxy, ibetaWx, O },
1166 std::vector<PetscInt> rowBCs = {1*ny-2,1*ny-1,2*ny-2,2*ny-1,3*ny-2,3*ny-1};
1173 for(PetscInt j=0; j<ny; ++j){
1174 ABC0(rowBCs[0],j,grid.
T(0,j,PETSC_TRUE));
1175 ABC0(rowBCs[1],j,grid.
T(ny-1,j,PETSC_TRUE));
1176 ABC0(rowBCs[2],ny+j,grid.
T(0,j,PETSC_TRUE));
1177 ABC0(rowBCs[3],ny+j,grid.
T(ny-1,j,PETSC_TRUE));
1178 ABC0(rowBCs[4],2*ny+j,grid.
T(0,j,PETSC_TRUE));
1179 ABC0(rowBCs[5],2*ny+j,grid.
T(ny-1,j,PETSC_TRUE));
1197 std::vector<PetscInt> rowBCs = {0*ny,1*ny-1,1*ny,2*ny-1,2*ny,3*ny-1};
1209 {dA0, ABC0}})(),
"L0");
1212 {dA1, ABC1}})(),
"L1");
1215 {dA2, ABC2}})(),
"L2");
1270 params.
alpha = alpha;
1272 return std::make_tuple(alpha,eig_vec);
1282 PetscInt ny = grid.
ny;
1283 PetscScalar Re = params.
Re;
1284 PetscScalar Reinv = 1.0/Re;
1285 PetscScalar alpha = params.
alpha;
1286 PetscScalar omega = params.
omega;
1287 PetscScalar beta = params.
beta;
1288 PetscScalar i=PETSC_i;
1309 Uxy = S1S0That*Uxy*T;
1314 Wxy = S1S0That*Wxy*T;
1323 SPIMat d(VDy - Reinv*Dyy + i*beta*W + (-i*omega + beta*beta*Reinv)*I,
"d");
1355 {Wx, Wy, d, ibetaI},
1364 SPIMat ibetaWx(i*beta*Wx);
1366 {ibetaWx, Uxy, O, O },
1367 {O, ibetaWx, O, O },
1368 {O, Wxy, ibetaWx, O },
1373 std::vector<PetscInt> rowBCs = {1*ny-2,1*ny-1,2*ny-2,2*ny-1,3*ny-2,3*ny-1};
1380 for(PetscInt j=0; j<ny; ++j){
1381 ABC0(rowBCs[0],j,grid.
T(0,j,PETSC_TRUE));
1382 ABC0(rowBCs[1],j,grid.
T(ny-1,j,PETSC_TRUE));
1383 ABC0(rowBCs[2],ny+j,grid.
T(0,j,PETSC_TRUE));
1384 ABC0(rowBCs[3],ny+j,grid.
T(ny-1,j,PETSC_TRUE));
1385 ABC0(rowBCs[4],2*ny+j,grid.
T(0,j,PETSC_TRUE));
1386 ABC0(rowBCs[5],2*ny+j,grid.
T(ny-1,j,PETSC_TRUE));
1404 std::vector<PetscInt> rowBCs = {0*ny,1*ny-1,1*ny,2*ny-1,2*ny,3*ny-1};
1416 {dA0, ABC0}})(),
"L0");
1419 {dA1, ABC1}})(),
"L1");
1422 {dA2, ABC2}})(),
"L2");
1476 params.
alpha = alpha;
1478 return std::make_tuple(alpha,eig_vec);
1486 std::vector<PetscScalar> &alphas,
1487 std::vector<SPIVec> &qrs
1489 PetscInt ny = grid.
ny;
1490 PetscScalar Re = params.
Re;
1491 PetscScalar Reinv = 1./Re;
1493 std::vector<PetscScalar> _alphas;
1494 std::vector<SPIVec> eig_vecs;
1495 PetscScalar omega = params.
omega;
1496 PetscScalar beta = params.
beta;
1497 PetscScalar i=PETSC_i;
1518 Uxy = S1S0That*Uxy*T;
1523 Wxy = S1S0That*Wxy*T;
1536 SPIMat d(VDy - Reinv*Dyy + i*beta*W + (-i*omega + beta*beta*Reinv)*I,
"d");
1563 {Wx, Wy, d, i*beta*I},
1564 {O, Dy, i*beta*I,O }
1573 {i*beta*Wx, Uxy, O, O },
1574 {O, i*beta*Wx, O, O },
1575 {O, Wxy, i*beta*Wx, O },
1599 std::vector<PetscInt> rowBCs = {1*ny-2,1*ny-1,2*ny-2,2*ny-1,3*ny-2,3*ny-1};
1606 for(PetscInt j=0; j<ny; ++j){
1607 ABC0(rowBCs[0],j,grid.
T(0,j,PETSC_TRUE));
1608 ABC0(rowBCs[1],j,grid.
T(ny-1,j,PETSC_TRUE));
1609 ABC0(rowBCs[2],ny+j,grid.
T(0,j,PETSC_TRUE));
1610 ABC0(rowBCs[3],ny+j,grid.
T(ny-1,j,PETSC_TRUE));
1611 ABC0(rowBCs[4],2*ny+j,grid.
T(0,j,PETSC_TRUE));
1612 ABC0(rowBCs[5],2*ny+j,grid.
T(ny-1,j,PETSC_TRUE));
1630 std::vector<PetscInt> rowBCs = {0*ny,1*ny-1,1*ny,2*ny-1,2*ny,3*ny-1};
1642 {dA0, ABC0}})(),
"L0");
1645 {dA1, ABC1}})(),
"L1");
1648 {dA2, ABC2}})(),
"L2");
1704 return std::make_tuple(_alphas,eig_vecs);