35 #include <boost/algorithm/string.hpp>
58 CoupledLinearNS::CoupledLinearNS(
72 int expdim =
m_graph->GetMeshDimension();
80 ASSERTL0(
false,
"Last field is defined as pressure but this is not suitable for this solver, please remove this field as it is implicitly defined");
89 ASSERTL0(
m_fields.num_elements() > 2,
"Expect to have three at least three components of velocity variables");
106 for(i =0 ; i <
m_velocity.num_elements(); ++i)
117 ASSERTL0(nz <=2 ,
"For single mode calculation can only have nz <= 2");
118 if(
m_session->DefinesSolverInfo(
"BetaZero"))
137 for(i = 2; i < nz; ++i)
144 else if (expdim == 3)
147 ASSERTL0(
false,
"Setup mapping aray");
151 ASSERTL0(
false,
"Exp dimension not recognised");
157 std::string vExtrapolation =
"Standard";
159 if (
m_session->DefinesSolverInfo(
"Extrapolation"))
161 vExtrapolation =
m_session->GetSolverInfo(
"Extrapolation");
197 ASSERTL1(
m_npointsZ <=2,
"Only expected a maxmimum of two planes in single mode linear NS solver");
228 for(n = 1; n < nz; ++n)
424 for(n = 0; n < nel; ++n)
428 nsize_bndry_p1[n] = nsize_bndry[n]+nz_loc;
429 nsize_int [n] = (nvel*
m_fields[
m_velocity[0]]->GetExp(eid)->GetNcoeffs()*nz_loc - nsize_bndry[n]);
430 nsize_p[n] =
m_pressure->GetExp(eid)->GetNcoeffs()*nz_loc;
431 nsize_p_m1[n] = nsize_p[n]-nz_loc;
461 for(n = 0; n < nel; ++n)
464 nbndry = nsize_bndry[n];
466 k = nsize_bndry_p1[n];
481 locExp->GetBoundaryMap(bmap);
482 locExp->GetInteriorMap(imap);
486 locExp->DetShapeType(),
493 int nbmap = bmap.num_elements();
494 int nimap = imap.num_elements();
498 int psize =
m_pressure->GetExp(eid)->GetNcoeffs();
499 int pqsize =
m_pressure->GetExp(eid)->GetTotPoints();
504 if(AddAdvectionTerms ==
false)
510 CondMat = locExp->GetLocStaticCondMatrix(helmkey);
512 for(k = 0; k < nvel*nz_loc; ++k)
515 rows = SubBlock.GetRows();
516 cols = SubBlock.GetColumns();
517 for(i = 0; i < rows; ++i)
519 for(j = 0; j < cols; ++j)
521 (*Ah)(i+k*rows,j+k*cols) =
m_kinvis*SubBlock(i,j);
526 for(k = 0; k < nvel*nz_loc; ++k)
530 rows = SubBlock.GetRows();
531 cols = SubBlock.GetColumns();
532 for(i = 0; i < rows; ++i)
534 for(j = 0; j < cols; ++j)
536 (*B)(i+k*rows,j+k*cols) = SubBlock(i,j);
537 (*C)(i+k*rows,j+k*cols) =
m_kinvis*SubBlock1(j,i);
542 for(k = 0; k < nvel*nz_loc; ++k)
546 rows = SubBlock.GetRows();
547 cols = SubBlock.GetColumns();
548 for(i = 0; i < rows; ++i)
550 for(j = 0; j < cols; ++j)
552 (*D)(i+k*rows,j+k*cols) = inv_kinvis*SubBlock(i,j);
559 for(i = 0; i < bmap.num_elements(); ++i)
563 coeffs[bmap[i]] = 1.0;
567 for(j = 0; j < nvel; ++j)
569 if( (nz_loc == 2)&&(j == 2))
575 m_pressure->GetExp(eid)->IProductWRTBase(deriv,pcoeffs);
579 ((nz_loc*j+1)*bmap.num_elements()+i)*nsize_p[n],1);
584 ((nz_loc*j)*bmap.num_elements()+i)*nsize_p[n]+psize,1);
592 m_pressure->GetExp(eid)->IProductWRTBase(deriv,pcoeffs);
594 for(k = 0; k < nz_loc; ++k)
598 ((nz_loc*j+k)*bmap.num_elements()+i)*nsize_p[n]+ k*psize,1);
605 for(i = 0; i < imap.num_elements(); ++i)
609 coeffs[imap[i]] = 1.0;
613 for(j = 0; j < nvel; ++j)
615 if( (nz_loc == 2)&&(j == 2))
621 m_pressure->GetExp(eid)->IProductWRTBase(deriv,pcoeffs);
625 ((nz_loc*j+1)*imap.num_elements()+i)*nsize_p[n],1);
630 ((nz_loc*j)*imap.num_elements()+i)*nsize_p[n]+psize,1);
640 m_pressure->GetExp(eid)->IProductWRTBase(deriv,pcoeffs);
643 for(k = 0; k < nz_loc; ++k)
647 ((nz_loc*j+k)*imap.num_elements()+i)*nsize_p[n]+ k*psize,1);
661 ->GetLocMatrix(helmkey));
665 NekDouble HelmMatScale = HelmMat.Scale();
666 int HelmMatRows = HelmMat.GetRows();
671 locExp->DetShapeType(),
674 ->GetLocMatrix(masskey);
683 int npoints = locExp->GetTotPoints();
686 if(IsLinearNSEquation)
691 for(nv = 0; nv < nvel; ++nv)
693 for(nv1 = 0; nv1 < nvel; ++nv1)
695 if(cnt < nvel*nvel-1)
697 AdvDeriv[cnt+1] = AdvDeriv[cnt] + npoints;
714 for(i = 0; i < nbmap; ++i)
719 coeffs[bmap[i]] = 1.0;
720 locExp->BwdTrans(coeffs,phys);
722 for(k = 0; k < nvel*nz_loc; ++k)
724 for(j = 0; j < nbmap; ++j)
727 Ah_data[i+k*nbmap + (j+k*nbmap)*AhRows] +=
m_kinvis*HelmMatScale*HelmMat_data[bmap[i] + HelmMatRows*bmap[j]];
730 for(j = 0; j < nimap; ++j)
732 B_data[i+k*nbmap + (j+k*nimap)*nbndry] +=
m_kinvis*HelmMatScale*HelmMat_data[bmap[i]+HelmMatRows*imap[j]];
738 for(k = 0; k < nvel; ++k)
740 for(j = 0; j < nbmap; ++j)
742 Ah_data[i+2*k*nbmap + (j+(2*k+1)*nbmap)*AhRows] -= lambda_imag*(*MassMat)(bmap[i],bmap[j]);
745 for(j = 0; j < nbmap; ++j)
747 Ah_data[i+(2*k+1)*nbmap + (j+2*k*nbmap)*AhRows] += lambda_imag*(*MassMat)(bmap[i],bmap[j]);
750 for(j = 0; j < nimap; ++j)
752 B_data[i+2*k*nbmap + (j+(2*k+1)*nimap)*nbndry] -= lambda_imag*(*MassMat)(bmap[i],imap[j]);
755 for(j = 0; j < nimap; ++j)
757 B_data[i+(2*k+1)*nbmap + (j+2*k*nimap)*nbndry] += lambda_imag*(*MassMat)(bmap[i],imap[j]);
765 for(k = 0; k < nvel; ++k)
767 if((nz_loc == 2)&&(k == 2))
774 m_pressure->GetExp(eid)->IProductWRTBase(deriv,pcoeffs);
777 ((nz_loc*k+1)*bmap.num_elements()+i)*nsize_p[n],1);
783 ((nz_loc*k)*bmap.num_elements()+i)*nsize_p[n]+psize,1);
787 Advtmp = Advfield[k] + phys_offset,
788 1,deriv,1,tmpphys,1);
790 locExp->IProductWRTBase(tmpphys,coeffs);
794 for(nv = 0; nv < nvel; ++nv)
796 for(j = 0; j < nbmap; ++j)
798 Ah_data[j+2*nv*nbmap + (i+(2*nv+1)*nbmap)*AhRows] +=
802 for(j = 0; j < nimap; ++j)
804 C_data[i+(2*nv+1)*nbmap + (j+2*nv*nimap)*nbndry] +=
811 for(nv = 0; nv < nvel; ++nv)
813 for(j = 0; j < nbmap; ++j)
815 Ah_data[j+(2*nv+1)*nbmap + (i+2*nv*nbmap)*AhRows] +=
819 for(j = 0; j < nimap; ++j)
821 C_data[i+2*nv*nbmap + (j+(2*nv+1)*nimap)*nbndry] +=
832 Advtmp = Advfield[k] + phys_offset,
833 1,deriv,1,tmpphys,1);
834 locExp->IProductWRTBase(tmpphys,coeffs);
837 for(nv = 0; nv < nvel*nz_loc; ++nv)
839 for(j = 0; j < nbmap; ++j)
841 Ah_data[j+nv*nbmap + (i+nv*nbmap)*AhRows] +=
845 for(j = 0; j < nimap; ++j)
847 C_data[i+nv*nbmap + (j+nv*nimap)*nbndry] +=
853 m_pressure->GetExp(eid)->IProductWRTBase(deriv,pcoeffs);
854 for(j = 0; j < nz_loc; ++j)
858 ((nz_loc*k+j)*bmap.num_elements() + i)*nsize_p[n]+ j*psize,1);
863 if(IsLinearNSEquation)
865 for(nv = 0; nv < nvel; ++nv)
871 locExp->IProductWRTBase(tmpphys,coeffs);
873 for(
int n1 = 0; n1 < nz_loc; ++n1)
875 for(j = 0; j < nbmap; ++j)
877 Ah_data[j+(k*nz_loc+n1)*nbmap +
878 (i+(nv*nz_loc+n1)*nbmap)*AhRows] +=
882 for(j = 0; j < nimap; ++j)
884 C_data[i+(nv*nz_loc+n1)*nbmap +
885 (j+(k*nz_loc+n1)*nimap)*nbndry] +=
895 for(i = 0; i < nimap; ++i)
899 coeffs[imap[i]] = 1.0;
900 locExp->BwdTrans(coeffs,phys);
902 for(k = 0; k < nvel*nz_loc; ++k)
904 for(j = 0; j < nbmap; ++j)
906 C_data[j+k*nbmap + (i+k*nimap)*nbndry] +=
m_kinvis*HelmMatScale*HelmMat_data[imap[i]+HelmMatRows*bmap[j]];
909 for(j = 0; j < nimap; ++j)
911 D_data[i+k*nimap + (j+k*nimap)*nint] +=
m_kinvis*HelmMatScale*HelmMat_data[imap[i]+HelmMatRows*imap[j]];
917 for(k = 0; k < nvel; ++k)
919 for(j = 0; j < nbmap; ++j)
921 C_data[j+2*k*nbmap + (i+(2*k+1)*nimap)*nbndry] += lambda_imag*(*MassMat)(bmap[j],imap[i]);
924 for(j = 0; j < nbmap; ++j)
926 C_data[j+(2*k+1)*nbmap + (i+2*k*nimap)*nbndry] -= lambda_imag*(*MassMat)(bmap[j],imap[i]);
929 for(j = 0; j < nimap; ++j)
931 D_data[i+2*k*nimap + (j+(2*k+1)*nimap)*nint] -= lambda_imag*(*MassMat)(imap[i],imap[j]);
934 for(j = 0; j < nimap; ++j)
936 D_data[i+(2*k+1)*nimap + (j+2*k*nimap)*nint] += lambda_imag*(*MassMat)(imap[i],imap[j]);
942 for(k = 0; k < nvel; ++k)
944 if((nz_loc == 2)&&(k == 2))
950 m_pressure->GetExp(eid)->IProductWRTBase(deriv,pcoeffs);
953 ((nz_loc*k+1)*imap.num_elements()+i)*nsize_p[n],1);
958 ((nz_loc*k)*imap.num_elements()+i)*nsize_p[n]+psize,1);
962 Vmath::Vmul(npoints, Advtmp = Advfield[k] + phys_offset,1,deriv,1,tmpphys,1);
963 locExp->IProductWRTBase(tmpphys,coeffs);
966 for(nv = 0; nv < nvel; ++nv)
968 for(j = 0; j < nbmap; ++j)
970 B_data[j+2*nv*nbmap + (i+(2*nv+1)*nimap)*nbndry] +=
974 for(j = 0; j < nimap; ++j)
976 D_data[j+2*nv*nimap + (i+(2*nv+1)*nimap)*nint] +=
982 for(nv = 0; nv < nvel; ++nv)
984 for(j = 0; j < nbmap; ++j)
986 B_data[j+(2*nv+1)*nbmap + (i+2*nv*nimap)*nbndry] +=
990 for(j = 0; j < nimap; ++j)
992 D_data[j+(2*nv+1)*nimap + (i+2*nv*nimap)*nint] +=
1006 Advtmp = Advfield[k] + phys_offset,
1007 1,deriv,1,tmpphys,1);
1008 locExp->IProductWRTBase(tmpphys,coeffs);
1011 for(nv = 0; nv < nvel*nz_loc; ++nv)
1013 for(j = 0; j < nbmap; ++j)
1015 B_data[j+nv*nbmap + (i+nv*nimap)*nbndry] +=
1019 for(j = 0; j < nimap; ++j)
1021 D_data[j+nv*nimap + (i+nv*nimap)*nint] +=
1026 m_pressure->GetExp(eid)->IProductWRTBase(deriv,pcoeffs);
1027 for(j = 0; j < nz_loc; ++j)
1031 ((nz_loc*k+j)*imap.num_elements() + i)*nsize_p[n]+j*psize,1);
1036 if(IsLinearNSEquation)
1039 for(nv = 0; nv < nvel; ++nv)
1043 AdvDeriv[k*nvel+nv],
1045 locExp->IProductWRTBase(tmpphys,coeffs);
1047 for(n1 = 0; n1 < nz_loc; ++n1)
1049 for(j = 0; j < nbmap; ++j)
1051 B_data[j+(k*nz_loc+n1)*nbmap +
1052 (i+(nv*nz_loc+n1)*nimap)*nbndry] +=
1056 for(j = 0; j < nimap; ++j)
1058 D_data[j+(k*nz_loc+n1)*nimap +
1059 (i+(nv*nz_loc+n1)*nimap)*nint] +=
1077 B->GetColumns(), -1.0, B->GetRawPtr(),
1078 B->GetRows(), C->GetRawPtr(),
1080 Ah->GetRawPtr(), Ah->GetRows());
1093 DNekMat DintCinvDTint, BCinvDTint_m_DTbnd, DintCinvBTtilde_m_Dbnd;
1099 DintCinvDTint = (*Dint)*(*Cinv)*
Transpose(*Dint);
1103 DintCinvBTtilde_m_Dbnd = (*Dint)*(*Cinv)*
Transpose(*Btilde) - (*Dbnd);
1113 for(n1 = 0; n1 < nz_loc; ++n1)
1115 for(i = 0; i < psize-1; ++i)
1117 for(n2 = 0; n2 < nz_loc; ++n2)
1119 for(j = 0; j < psize-1; ++j)
1123 Dh_data[(i+n1*(psize-1)) + (j+n2*(psize-1))*Dh->GetRows()] =
1124 -DintCinvDTint(i+1+n1*psize,j+1+n2*psize);
1130 for(n1 = 0; n1 < nz_loc; ++n1)
1132 for(i = 0; i < nsize_bndry_p1[n]-nz_loc; ++i)
1134 (*Ah)(i,nsize_bndry_p1[n]-nz_loc+n1) = BCinvDTint_m_DTbnd(i,n1*psize);
1135 (*Ah)(nsize_bndry_p1[n]-nz_loc+n1,i) = DintCinvBTtilde_m_Dbnd(n1*psize,i);
1139 for(n1 = 0; n1 < nz_loc; ++n1)
1141 for(n2 = 0; n2 < nz_loc; ++n2)
1143 (*Ah)(nsize_bndry_p1[n]-nz_loc+n1,nsize_bndry_p1[n]-nz_loc+n2) =
1144 -DintCinvDTint(n1*psize,n2*psize);
1148 for(n1 = 0; n1 < nz_loc; ++n1)
1150 for(j = 0; j < psize-1; ++j)
1152 for(i = 0; i < nsize_bndry_p1[n]-nz_loc; ++i)
1154 (*Bh)(i,j+n1*(psize-1)) = BCinvDTint_m_DTbnd(i,j+1+n1*psize);
1155 (*Ch)(j+n1*(psize-1),i) = DintCinvBTtilde_m_Dbnd(j+1+n1*psize,i);
1160 for(n1 = 0; n1 < nz_loc; ++n1)
1162 for(n2 = 0; n2 < nz_loc; ++n2)
1164 for(j = 0; j < psize-1; ++j)
1166 (*Bh)(nsize_bndry_p1[n]-nz_loc+n1,j+n2*(psize-1)) = -DintCinvDTint(n1*psize,j+1+n2*psize);
1167 (*Ch)(j+n2*(psize-1),nsize_bndry_p1[n]-nz_loc+n1) = -DintCinvDTint(j+1+n2*psize,n1*psize);
1174 (*Bh) = (*Bh)*(*Dh);
1176 Blas::Dgemm(
'N',
'N', Bh->GetRows(), Ch->GetColumns(), Bh->GetColumns(), -1.0,
1177 Bh->GetRawPtr(), Bh->GetRows(), Ch->GetRawPtr(), Ch->GetRows(),
1178 1.0, Ah->GetRawPtr(), Ah->GetRows());
1188 cout <<
"Matrix Setup Costs: " << timer.
TimePerTest(1) << endl;
1200 cout <<
"Multilevel condensation: " << timer.
TimePerTest(1) << endl;
1248 for(
int i = 0; i <
m_velocity.num_elements(); ++i)
1254 "Advection Velocity section must be defined in "
1257 std::vector<std::string> fieldStr;
1258 for(
int i = 0; i <
m_velocity.num_elements(); ++i)
1262 GetFunction(
"AdvectionVelocity")->Evaluate(fieldStr, AdvField);
1282 "Restart section must be defined in session file.");
1285 for(
int i = 0; i <
m_velocity.num_elements(); ++i)
1289 std::vector<std::string> fieldStr;
1290 for(
int i = 0; i <
m_velocity.num_elements(); ++i)
1294 GetFunction(
"Restart")->Evaluate(fieldStr, Restart);
1296 for(
int i = 0; i <
m_velocity.num_elements(); ++i)
1300 cout <<
"Saving the RESTART file for m_kinvis = "<<
m_kinvis <<
" (<=> Re = " << 1/
m_kinvis <<
")" <<endl;
1319 cout <<
"Saving the Stokes Flow for m_kinvis = "<<
m_kinvis <<
" (<=> Re = " << 1/
m_kinvis <<
")" <<endl;
1328 for(
int i = 0; i <
m_velocity.num_elements(); ++i)
1334 "Advection Velocity section must be defined in "
1337 std::vector<std::string> fieldStr;
1338 for(
int i = 0; i <
m_velocity.num_elements(); ++i)
1342 GetFunction(
"AdvectionVelocity")->Evaluate(fieldStr, AdvField);
1349 ASSERTL0(
false,
"Unknown or undefined equation type for CoupledLinearNS");
1362 x->Apply(
m_fields, outarray, outarray, time);
1377 if(fabs(lambda_store - lambda) > 1e-10)
1379 cout <<
"Setting up Stokes matrix problem [.";
1382 cout <<
"]" << endl;
1383 lambda_store = lambda;
1387 for(i = 0; i <
m_velocity.num_elements(); ++i)
1399 for(i = 0; i <
m_velocity.num_elements(); ++i)
1408 int nfields =
m_fields.num_elements();
1409 for (
int k=0 ; k < nfields; ++k)
1420 int nfields =
m_fields.num_elements();
1421 for (
int k=0 ; k < nfields; ++k)
1449 Generaltimer.
Start();
1457 cout<<
"We execute INITIALLY SolveSteadyNavierStokes for m_kinvis = "<<
m_kinvis<<
" (<=> Re = "<<1/
m_kinvis<<
")"<<endl;
1464 cout<<
"We execute SolveSteadyNavierStokes for m_kinvis = "<<
m_kinvis<<
" (<=> Re = "<<1/
m_kinvis<<
")"<<endl;
1474 cout<<
"We execute SolveSteadyNavierStokes for m_kinvis = "<<
m_kinvis<<
" (<=> Re = "<<1/
m_kinvis<<
")"<<endl;
1482 Generaltimer.
Stop();
1483 cout<<
"\nThe total calculation time is : " << Generaltimer.
TimePerTest(1)/60 <<
" minute(s). \n\n";
1489 ASSERTL0(
false,
"Unknown or undefined equation type for CoupledLinearNS");
1506 const unsigned int ncmpt =
m_velocity.num_elements();
1510 for(
int i = 0; i < ncmpt; ++i)
1519 x->Apply(
m_fields, forcing_phys, forcing_phys, time);
1521 for (
unsigned int i = 0; i < ncmpt; ++i)
1525 m_fields[i]->IProductWRTBase(forcing_phys[i], forcing[i]);
1526 m_fields[i]->SetWaveSpace(waveSpace);
1537 for(
int i = 0; i <
m_velocity.num_elements(); ++i)
1543 if(
m_session->DefinesFunction(
"ForcingTerm"))
1545 std::vector<std::string> fieldStr;
1546 for(
int i = 0; i <
m_velocity.num_elements(); ++i)
1551 for(
int i = 0; i <
m_velocity.num_elements(); ++i)
1558 cout <<
"'ForcingTerm' section has not been defined in the input file => forcing=0" << endl;
1565 Newtontimer.
Start();
1574 for(
int i = 0; i <
m_velocity.num_elements(); ++i)
1582 L2Norm(delta_velocity_Phys, L2_norm);
1585 while(max(L2_norm[0], L2_norm[1]) >
m_tol)
1593 for(
int i = 0; i <
m_velocity.num_elements(); ++i)
1599 for(
int i = 0; i <
m_velocity.num_elements(); ++i)
1621 for(
int i = 0; i <
m_velocity.num_elements(); ++i)
1627 for(
int i = 0; i <
m_velocity.num_elements(); ++i)
1629 Vmath::Vadd(Velocity_Phys[i].num_elements(),Velocity_Phys[i], 1, delta_velocity_Phys[i], 1,
1630 Velocity_Phys[i], 1);
1634 L2Norm(delta_velocity_Phys, L2_norm);
1636 if(max(Inf_norm[0], Inf_norm[1]) > 100)
1638 cout<<
"\nThe Newton method has failed at m_kinvis = "<<
m_kinvis<<
" (<=> Re = " << 1/
m_kinvis <<
")"<< endl;
1639 ASSERTL0(0,
"The Newton method has failed... \n");
1649 for(
int i = 0; i <
m_velocity.num_elements(); ++i)
1656 cout<<
"We have done "<<
m_counter-1 <<
" iteration(s) in " << Newtontimer.
TimePerTest(1)/60 <<
" minute(s). \n\n";
1667 cout <<
"We apply the continuation method: " <<endl;
1669 for(
int i = 0; i <
m_velocity.num_elements(); ++i)
1689 for(
int i = 0; i <
m_velocity.num_elements(); ++i)
1696 Vmath::Vadd(u_star[i].num_elements(), u_star[i], 1, u_N[i], 1, u_star[i], 1);
1708 for(
int i = 0; i <
m_velocity.num_elements(); ++i)
1711 for(
int j = 0; j < inarray[i].num_elements(); ++j)
1713 if(inarray[i][j] > outarray[i])
1715 outarray[i] = inarray[i][j];
1718 cout <<
"InfNorm["<<i<<
"] = "<< outarray[i] <<endl;
1725 for(
int i = 0; i <
m_velocity.num_elements(); ++i)
1728 for(
int j = 0; j < inarray[i].num_elements(); ++j)
1730 outarray[i] += inarray[i][j]*inarray[i][j];
1732 outarray[i]=sqrt(outarray[i]);
1733 cout <<
"L2Norm["<<i<<
"] = "<< outarray[i] <<endl;
1747 for(
int i = 0; i <
m_velocity.num_elements(); ++i)
1764 for(
int i = 0; i <
m_velocity.num_elements(); ++i)
1773 Vmath::Vsub(outarray[i].num_elements(), outarray[i], 1, AdvTerm[i], 1, outarray[i], 1);
1774 Vmath::Vsub(outarray[i].num_elements(), outarray[i], 1, ViscTerm[i], 1, outarray[i], 1);
1776 Vmath::Vadd(outarray[i].num_elements(), outarray[i], 1, Forc[i], 1, outarray[i], 1);
1791 for (
auto &expMapIter : VelExp)
1795 for(i = 0; i < expMapIter.second->m_basisKeyVector.size(); ++i)
1799 ASSERTL0(nummodes > 3,
"Velocity polynomial space not sufficiently high (>= 4)");
1802 BasisVec.push_back(newB);
1808 (*returnval)[expMapIter.first] = expansionElementShPtr;
1812 m_graph->SetExpansions(
"p",returnval);
1893 for(i = 0; i <
m_velocity.num_elements(); ++i)
1897 force[i] = forcing[i] + 2*n*ncoeffsplane;
1902 for(i = 0; i <
m_velocity.num_elements(); ++i)
1910 for(i = 0; i <
m_velocity.num_elements(); ++i)
1914 force[i] = forcing[i];
1922 int i,j,k,n,eid,cnt,cnt1;
1923 int nbnd,nint,offset;
1925 int nel = fields[0]->GetNumElmts();
1934 int nplanecoeffs = fields[
m_velocity[0]]->GetNcoeffs();
1952 for(i = 0; i < fields.num_elements(); ++i)
1963 for(i = 0; i < nel; ++i)
1966 fields[
m_velocity[0]]->GetExp(eid)->GetBoundaryMap(bmap);
1967 fields[
m_velocity[0]]->GetExp(eid)->GetInteriorMap(imap);
1968 nbnd = bmap.num_elements();
1969 nint = imap.num_elements();
1970 offset = fields[
m_velocity[0]]->GetCoeff_Offset(eid);
1972 for(j = 0; j < nvel; ++j)
1974 for(n = 0; n < nz_loc; ++n)
1976 for(k = 0; k < nbnd; ++k)
1978 f_bnd[cnt+k] = forcing[j][n*nplanecoeffs +
1981 for(k = 0; k < nint; ++k)
1983 f_int[cnt1+k] = forcing[j][n*nplanecoeffs +
1997 F_bnd = F_bnd - (*
m_mat[mode].m_BCinv)*F_int;
1998 F_p_tmp = (*
m_mat[mode].m_Cinv)*F_int;
1999 F_p = (*
m_mat[mode].m_D_int) * F_p_tmp;
2011 for(i = 0; i < nel; ++i)
2014 nbnd = nz_loc*fields[0]->GetExp(eid)->NumBndryCoeffs();
2016 for(j = 0; j < nvel; ++j)
2018 for(k = 0; k < nbnd; ++k)
2020 fh_bnd[loctoglomap[offset+j*nbnd+k]] +=
2021 loctoglosign[offset+j*nbnd+k]*f_bnd[cnt+k];
2026 nint =
pressure->GetExp(eid)->GetNcoeffs();
2027 offset += nvel*nbnd + nint*nz_loc;
2031 for(i = 0; i < nel; ++i)
2034 nbnd = nz_loc*fields[0]->GetExp(eid)->NumBndryCoeffs();
2035 nint =
pressure->GetExp(eid)->GetNcoeffs();
2037 for(n = 0; n < nz_loc; ++n)
2039 for(j = 0; j < nint; ++j)
2041 fh_bnd[loctoglomap[offset + nvel*nbnd + n*nint+j]] = f_p[cnt1+j];
2045 offset += nvel*nbnd + nz_loc*nint;
2056 for(k = 0; k < nvel; ++k)
2062 bndCondExp =
m_fields[k]->GetPlane(2*mode)->GetBndCondExpansions();
2066 bndCondExp =
m_fields[k]->GetBndCondExpansions();
2069 for(i = 0; i < bndCondExp.num_elements(); ++i)
2073 for(n = 0; n < nz_loc; ++n)
2075 if(bndConds[i]->GetBoundaryConditionType()
2078 for(j = 0; j < (bndCondExp[i])->
GetNcoeffs(); j++)
2084 bnd[bndmap[bndcnt++]] = 0;
2088 bnd[bndmap[bndcnt++]] = bndCondCoeffs[cnt++];
2092 else if (bndConds[i]->GetBoundaryConditionType()
2095 for(j = 0; j < (bndCondExp[i])->
GetNcoeffs(); j++)
2097 fh_bnd[bndmap[bndcnt++]]
2098 += bndCondCoeffs[cnt++];
2109 int totpcoeffs =
pressure->GetNcoeffs();
2111 for(i = 0; i < nel; ++i)
2114 nbnd = nz_loc*fields[0]->GetExp(eid)->NumBndryCoeffs();
2115 nint =
pressure->GetExp(eid)->GetNcoeffs();
2117 for(j = 0; j < nvel; ++j)
2119 for(k = 0; k < nbnd; ++k)
2121 f_bnd[cnt+k] = loctoglosign[offset+j*nbnd+k]*bnd[loctoglomap[offset + j*nbnd + k]];
2125 offset += nvel*nbnd + nint*nz_loc;
2130 offset = cnt = cnt1 = 0;
2131 for(i = 0; i < nel; ++i)
2134 nint =
pressure->GetExp(eid)->GetNcoeffs();
2135 nbnd = fields[0]->GetExp(eid)->NumBndryCoeffs();
2136 cnt1 =
pressure->GetCoeff_Offset(eid);
2138 for(n = 0; n < nz_loc; ++n)
2140 for(j = 0; j < nint; ++j)
2142 p_coeffs[n*totpcoeffs + cnt1+j] =
2143 f_p[cnt+j] = bnd[loctoglomap[offset +
2144 (nvel*nz_loc)*nbnd +
2149 offset += (nvel*nbnd + nint)*nz_loc;
2156 F_int = (*
m_mat[mode].m_Cinv)*F_int;
2160 for(i = 0; i < nel; ++i)
2163 fields[0]->GetExp(eid)->GetBoundaryMap(bmap);
2164 fields[0]->GetExp(eid)->GetInteriorMap(imap);
2165 nbnd = bmap.num_elements();
2166 nint = imap.num_elements();
2167 offset = fields[0]->GetCoeff_Offset(eid);
2169 for(j = 0; j < nvel; ++j)
2171 for(n = 0; n < nz_loc; ++n)
2173 for(k = 0; k < nbnd; ++k)
2175 fields[j]->SetCoeff(n*nplanecoeffs +
2180 for(k = 0; k < nint; ++k)
2182 fields[j]->SetCoeff(n*nplanecoeffs +
2192 for(j = 0; j < nvel; ++j)
2194 fields[j]->SetPhysState(
false);
2200 std::vector<Array<OneD, NekDouble> > fieldcoeffs(
m_fields.num_elements()+1);
2201 std::vector<std::string> variables(
m_fields.num_elements()+1);
2204 for(i = 0; i <
m_fields.num_elements(); ++i)
2206 fieldcoeffs[i] =
m_fields[i]->UpdateCoeffs();
2217 m_fields[0]->GetPlane(0)->FwdTrans_IterPerExp(
m_pressure->GetPlane(0)->GetPhys(),fieldcoeffs[i]);
2218 m_fields[0]->GetPlane(1)->FwdTrans_IterPerExp(
m_pressure->GetPlane(1)->GetPhys(),tmpfieldcoeffs);
2219 for(
int e=0; e<
m_fields[0]->GetNcoeffs()/2; e++)
2221 fieldcoeffs[i][e+
m_fields[0]->GetNcoeffs()/2] = tmpfieldcoeffs[e];
2238 return m_session->GetVariables().size();
#define ASSERTL0(condition, msg)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
void L2Norm(Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, NekDouble > &outarray)
void EvaluateNewtonRHS(Array< OneD, Array< OneD, NekDouble > > &Velocity, Array< OneD, Array< OneD, NekDouble > > &outarray)
virtual void v_TransPhysToCoeff(void)
Virtual function for transformation to coefficient space.
Array< OneD, CoupledLocalToGlobalC0ContMapSharedPtr > m_locToGloMap
virtual void v_Output(void)
void DefineForcingTerm(void)
void SolveUnsteadyStokesSystem(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time, const NekDouble a_iixDt)
void SolveLinearNS(const Array< OneD, Array< OneD, NekDouble > > &forcing)
void SolveSteadyNavierStokes(void)
virtual void v_DoSolve(void)
Solves an unsteady problem.
void EvaluateAdvection(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
virtual bool v_NegatedOp(void)
void SetUpCoupledMatrix(const NekDouble lambda=0.0, const Array< OneD, Array< OneD, NekDouble > > &Advfield=NullNekDoubleArrayofArray, bool IsLinearNSEquation=true)
virtual int v_GetForceDimension(void)
bool m_zeroMode
Id to identify when single mode is mean mode (i.e. beta=0);.
Array< OneD, Array< OneD, NekDouble > > m_ForcingTerm_Coeffs
virtual void v_InitObject()
Init object for UnsteadySystem class.
Array< OneD, Array< OneD, NekDouble > > m_ForcingTerm
virtual void v_DoInitialise(void)
Sets up initial conditions.
NekDouble m_KinvisPercentage
void InfNorm(Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, NekDouble > &outarray)
Array< OneD, CoupledSolverMatrices > m_mat
virtual void v_TransCoeffToPhys(void)
Virtual function for transformation to physical space.
virtual void v_GenerateSummary(SolverUtils::SummaryList &s)
Print a summary of time stepping parameters.
const SpatialDomains::ExpansionMap & GenPressureExp(const SpatialDomains::ExpansionMap &VelExp)
This class is the base class for Navier Stokes problems.
virtual void v_InitObject()
Init object for UnsteadySystem class.
void EvaluateAdvectionTerms(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray)
MultiRegions::ExpListSharedPtr m_pressure
Pointer to field holding pressure field.
NekDouble m_kinvis
Kinematic viscosity.
ExtrapolateSharedPtr m_extrapolation
Array< OneD, int > m_velocity
int which identifies which components of m_fields contains the velocity (u,v,w);
EquationType m_equationType
equation type;
int m_nConvectiveFields
Number of fields to be convected;.
std::vector< SolverUtils::ForcingSharedPtr > m_forcing
Forcing terms.
Describes the specification for a Basis.
BasisType GetBasisType() const
Return type of expansion basis.
PointsKey GetPointsKey() const
Return distribution of points.
int GetNumModes() const
Returns the order of the basis.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
void DefineOdeRhs(FuncPointerT func, ObjectPointerT obj)
void DefineImplicitSolve(FuncPointerT func, ObjectPointerT obj)
NekDouble TimePerTest(unsigned int n)
Returns amount of seconds per iteration in a test with n iterations.
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
Describe a linear system.
SolverUtils::AdvectionSharedPtr m_advObject
Advection term.
bool m_useFFT
Flag to determine if FFT is used for homogeneous transform.
SpatialDomains::MeshGraphSharedPtr m_graph
Pointer to graph defining mesh.
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array holding all dependent variables.
NekDouble m_lambda
Lambda constant in real system if one required.
int m_npointsZ
number of points in Z direction (if homogeneous)
SOLVER_UTILS_EXPORT void Checkpoint_Output(const int n)
Write checkpoint file of m_fields.
SOLVER_UTILS_EXPORT void WriteFld(const std::string &outname)
Write field data to the given filename.
std::string m_sessionName
Name of the session.
LibUtilities::SessionReaderSharedPtr m_session
The session reader.
bool m_singleMode
Flag to determine if single homogeneous mode is used.
enum HomogeneousType m_HomogeneousType
SOLVER_UTILS_EXPORT int GetNpoints()
bool m_homogen_dealiasing
Flag to determine if dealiasing is used for homogeneous simulations.
SOLVER_UTILS_EXPORT int GetNcoeffs()
SpatialDomains::BoundaryConditionsSharedPtr m_boundaryConditions
Pointer to boundary conditions object.
NekDouble m_LhomZ
physical length in Z direction (if homogeneous)
SOLVER_UTILS_EXPORT void SetInitialConditions(NekDouble initialtime=0.0, bool dumpInitialConditions=true, const int domain=0)
Initialise the data in the dependent fields.
SOLVER_UTILS_EXPORT SessionFunctionSharedPtr GetFunction(std::string name, const MultiRegions::ExpListSharedPtr &field=MultiRegions::NullExpListSharedPtr, bool cache=false)
Get a SessionFunction by name.
SOLVER_UTILS_EXPORT int GetTotPoints()
Base class for unsteady solvers.
LibUtilities::TimeIntegrationSchemeOperators m_ode
The time integration scheme operators to use.
virtual SOLVER_UTILS_EXPORT void v_DoSolve()
Solves an unsteady problem.
static void Dcopy(const int &n, const double *x, const int &incx, double *y, const int &incy)
BLAS level 1: Copy x to y.
static void Dgemm(const char &transa, const char &transb, const int &m, const int &n, const int &k, const double &alpha, const double *a, const int &lda, const double *b, const int &ldb, const double &beta, double *c, const int &ldc)
BLAS level 3: Matrix-matrix multiply C = A x B where A[m x n], B[n x k], C[m x k].
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::vector< BasisKey > BasisKeyVector
Name for a vector of BasisKeys.
MultiRegions::Direction const DirCartesianMap[]
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
static const NekDouble kNekUnsetDouble
std::vector< std::pair< std::string, std::string > > SummaryList
EquationSystemFactory & GetEquationSystemFactory()
void AddSummaryItem(SummaryList &l, const std::string &name, const std::string &value)
Adds a summary item to the summary info list.
std::map< int, ExpansionShPtr > ExpansionMap
std::shared_ptr< ExpansionMap > ExpansionMapShPtr
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
std::shared_ptr< Expansion > ExpansionShPtr
std::shared_ptr< StdExpansion > StdExpansionSharedPtr
@ eLinearAdvectionReaction
std::map< ConstFactorType, NekDouble > ConstFactorMap
static Array< OneD, Array< OneD, NekDouble > > NullNekDoubleArrayofArray
std::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
NekMatrix< InnerMatrixType, BlockMatrixTag > Transpose(NekMatrix< InnerMatrixType, BlockMatrixTag > &rhs)
std::shared_ptr< DNekScalBlkMat > DNekScalBlkMatSharedPtr
ExtrapolateFactory & GetExtrapolateFactory()
std::shared_ptr< CoupledLocalToGlobalC0ContMap > CoupledLocalToGlobalC0ContMapSharedPtr
std::shared_ptr< DNekMat > DNekMatSharedPtr
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
void Neg(int n, T *x, const int incx)
Negate x = -x.
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
void Zero(int n, T *x, const int incx)
Zero vector.
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.
DNekScalBlkMatSharedPtr m_D_int
Inner product of pressure system with divergence of the interior velocity space .
DNekScalBlkMatSharedPtr m_D_bnd
Inner product of pressure system with divergence of the boundary velocity space .
DNekScalBlkMatSharedPtr m_Cinv
Interior-Interior Laplaican plus linearised convective terms inverted, i.e. the inverse of .
DNekScalBlkMatSharedPtr m_Btilde
Interior-boundary Laplacian plus linearised convective terms .
DNekScalBlkMatSharedPtr m_BCinv
Boundary-interior Laplacian plus linearised convective terms pre-multiplying Cinv: .
MultiRegions::GlobalLinSysSharedPtr m_CoupledBndSys