35 #include <boost/algorithm/string.hpp>
58 CoupledLinearNS::CoupledLinearNS(
72 int expdim =
m_graph->GetMeshDimension();
81 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");
90 ASSERTL0(
m_fields.size() > 2,
"Expect to have three at least three components of velocity variables");
118 ASSERTL0(nz <=2 ,
"For single mode calculation can only have nz <= 2");
119 if(
m_session->DefinesSolverInfo(
"BetaZero"))
138 for(i = 2; i < nz; ++i)
145 else if (expdim == 3)
148 ASSERTL0(
false,
"Setup mapping aray");
152 ASSERTL0(
false,
"Exp dimension not recognised");
158 std::string vExtrapolation =
"Standard";
160 if (
m_session->DefinesSolverInfo(
"Extrapolation"))
162 vExtrapolation =
m_session->GetSolverInfo(
"Extrapolation");
198 ASSERTL1(
m_npointsZ <=2,
"Only expected a maxmimum of two planes in single mode linear NS solver");
229 for(n = 1; n < nz; ++n)
425 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(n)->GetNcoeffs()*nz_loc - nsize_bndry[n]);
430 nsize_p[n] =
m_pressure->GetExp(n)->GetNcoeffs()*nz_loc;
431 nsize_p_m1[n] = nsize_p[n]-nz_loc;
461 for(n = 0; n < nel; ++n)
463 nbndry = nsize_bndry[n];
465 k = nsize_bndry_p1[n];
480 locExp->GetBoundaryMap(bmap);
481 locExp->GetInteriorMap(imap);
485 locExp->DetShapeType(),
492 int nbmap = bmap.size();
493 int nimap = imap.size();
497 int psize =
m_pressure->GetExp(n)->GetNcoeffs();
498 int pqsize =
m_pressure->GetExp(n)->GetTotPoints();
503 if(AddAdvectionTerms ==
false)
509 CondMat = locExp->GetLocStaticCondMatrix(helmkey);
511 for(k = 0; k < nvel*nz_loc; ++k)
514 rows = SubBlock.GetRows();
515 cols = SubBlock.GetColumns();
516 for(i = 0; i < rows; ++i)
518 for(j = 0; j < cols; ++j)
520 (*Ah)(i+k*rows,j+k*cols) =
m_kinvis*SubBlock(i,j);
525 for(k = 0; k < nvel*nz_loc; ++k)
529 rows = SubBlock.GetRows();
530 cols = SubBlock.GetColumns();
531 for(i = 0; i < rows; ++i)
533 for(j = 0; j < cols; ++j)
535 (*B)(i+k*rows,j+k*cols) = SubBlock(i,j);
536 (*C)(i+k*rows,j+k*cols) =
m_kinvis*SubBlock1(j,i);
541 for(k = 0; k < nvel*nz_loc; ++k)
545 rows = SubBlock.GetRows();
546 cols = SubBlock.GetColumns();
547 for(i = 0; i < rows; ++i)
549 for(j = 0; j < cols; ++j)
551 (*D)(i+k*rows,j+k*cols) = inv_kinvis*SubBlock(i,j);
558 for(i = 0; i < bmap.size(); ++i)
562 coeffs[bmap[i]] = 1.0;
566 for(j = 0; j < nvel; ++j)
568 if( (nz_loc == 2)&&(j == 2))
574 m_pressure->GetExp(n)->IProductWRTBase(deriv,pcoeffs);
578 ((nz_loc*j+1)*bmap.size()+i)*nsize_p[n],1);
583 ((nz_loc*j)*bmap.size()+i)*nsize_p[n]+psize,1);
591 m_pressure->GetExp(n)->IProductWRTBase(deriv,pcoeffs);
593 for(k = 0; k < nz_loc; ++k)
597 ((nz_loc*j+k)*bmap.size()+i)*nsize_p[n]+ k*psize,1);
604 for(i = 0; i < imap.size(); ++i)
608 coeffs[imap[i]] = 1.0;
612 for(j = 0; j < nvel; ++j)
614 if( (nz_loc == 2)&&(j == 2))
620 m_pressure->GetExp(n)->IProductWRTBase(deriv,pcoeffs);
624 ((nz_loc*j+1)*imap.size()+i)*nsize_p[n],1);
629 ((nz_loc*j)*imap.size()+i)*nsize_p[n]+psize,1);
639 m_pressure->GetExp(n)->IProductWRTBase(deriv,pcoeffs);
642 for(k = 0; k < nz_loc; ++k)
646 ((nz_loc*j+k)*imap.size()+i)*nsize_p[n]+ k*psize,1);
660 ->GetLocMatrix(helmkey));
664 NekDouble HelmMatScale = HelmMat.Scale();
665 int HelmMatRows = HelmMat.GetRows();
670 locExp->DetShapeType(),
673 ->GetLocMatrix(masskey);
682 int npoints = locExp->GetTotPoints();
685 if(IsLinearNSEquation)
690 for(nv = 0; nv < nvel; ++nv)
692 for(nv1 = 0; nv1 < nvel; ++nv1)
694 if(cnt < nvel*nvel-1)
696 AdvDeriv[cnt+1] = AdvDeriv[cnt] + npoints;
713 for(i = 0; i < nbmap; ++i)
718 coeffs[bmap[i]] = 1.0;
719 locExp->BwdTrans(coeffs,phys);
721 for(k = 0; k < nvel*nz_loc; ++k)
723 for(j = 0; j < nbmap; ++j)
726 Ah_data[i+k*nbmap + (j+k*nbmap)*AhRows] +=
m_kinvis*HelmMatScale*HelmMat_data[bmap[i] + HelmMatRows*bmap[j]];
729 for(j = 0; j < nimap; ++j)
731 B_data[i+k*nbmap + (j+k*nimap)*nbndry] +=
m_kinvis*HelmMatScale*HelmMat_data[bmap[i]+HelmMatRows*imap[j]];
737 for(k = 0; k < nvel; ++k)
739 for(j = 0; j < nbmap; ++j)
741 Ah_data[i+2*k*nbmap + (j+(2*k+1)*nbmap)*AhRows] -= lambda_imag*(*MassMat)(bmap[i],bmap[j]);
744 for(j = 0; j < nbmap; ++j)
746 Ah_data[i+(2*k+1)*nbmap + (j+2*k*nbmap)*AhRows] += lambda_imag*(*MassMat)(bmap[i],bmap[j]);
749 for(j = 0; j < nimap; ++j)
751 B_data[i+2*k*nbmap + (j+(2*k+1)*nimap)*nbndry] -= lambda_imag*(*MassMat)(bmap[i],imap[j]);
754 for(j = 0; j < nimap; ++j)
756 B_data[i+(2*k+1)*nbmap + (j+2*k*nimap)*nbndry] += lambda_imag*(*MassMat)(bmap[i],imap[j]);
764 for(k = 0; k < nvel; ++k)
766 if((nz_loc == 2)&&(k == 2))
773 m_pressure->GetExp(n)->IProductWRTBase(deriv,pcoeffs);
776 ((nz_loc*k+1)*bmap.size()+i)*nsize_p[n],1);
782 ((nz_loc*k)*bmap.size()+i)*nsize_p[n]+psize,1);
786 Advtmp = Advfield[k] + phys_offset,
787 1,deriv,1,tmpphys,1);
789 locExp->IProductWRTBase(tmpphys,coeffs);
793 for(nv = 0; nv < nvel; ++nv)
795 for(j = 0; j < nbmap; ++j)
797 Ah_data[j+2*nv*nbmap + (i+(2*nv+1)*nbmap)*AhRows] +=
801 for(j = 0; j < nimap; ++j)
803 C_data[i+(2*nv+1)*nbmap + (j+2*nv*nimap)*nbndry] +=
810 for(nv = 0; nv < nvel; ++nv)
812 for(j = 0; j < nbmap; ++j)
814 Ah_data[j+(2*nv+1)*nbmap + (i+2*nv*nbmap)*AhRows] +=
818 for(j = 0; j < nimap; ++j)
820 C_data[i+2*nv*nbmap + (j+(2*nv+1)*nimap)*nbndry] +=
831 Advtmp = Advfield[k] + phys_offset,
832 1,deriv,1,tmpphys,1);
833 locExp->IProductWRTBase(tmpphys,coeffs);
836 for(nv = 0; nv < nvel*nz_loc; ++nv)
838 for(j = 0; j < nbmap; ++j)
840 Ah_data[j+nv*nbmap + (i+nv*nbmap)*AhRows] +=
844 for(j = 0; j < nimap; ++j)
846 C_data[i+nv*nbmap + (j+nv*nimap)*nbndry] +=
852 m_pressure->GetExp(n)->IProductWRTBase(deriv,pcoeffs);
853 for(j = 0; j < nz_loc; ++j)
857 ((nz_loc*k+j)*bmap.size() + i)*nsize_p[n]+ j*psize,1);
862 if(IsLinearNSEquation)
864 for(nv = 0; nv < nvel; ++nv)
870 locExp->IProductWRTBase(tmpphys,coeffs);
872 for(
int n1 = 0; n1 < nz_loc; ++n1)
874 for(j = 0; j < nbmap; ++j)
876 Ah_data[j+(k*nz_loc+n1)*nbmap +
877 (i+(nv*nz_loc+n1)*nbmap)*AhRows] +=
881 for(j = 0; j < nimap; ++j)
883 C_data[i+(nv*nz_loc+n1)*nbmap +
884 (j+(k*nz_loc+n1)*nimap)*nbndry] +=
894 for(i = 0; i < nimap; ++i)
898 coeffs[imap[i]] = 1.0;
899 locExp->BwdTrans(coeffs,phys);
901 for(k = 0; k < nvel*nz_loc; ++k)
903 for(j = 0; j < nbmap; ++j)
905 C_data[j+k*nbmap + (i+k*nimap)*nbndry] +=
m_kinvis*HelmMatScale*HelmMat_data[imap[i]+HelmMatRows*bmap[j]];
908 for(j = 0; j < nimap; ++j)
910 D_data[i+k*nimap + (j+k*nimap)*nint] +=
m_kinvis*HelmMatScale*HelmMat_data[imap[i]+HelmMatRows*imap[j]];
916 for(k = 0; k < nvel; ++k)
918 for(j = 0; j < nbmap; ++j)
920 C_data[j+2*k*nbmap + (i+(2*k+1)*nimap)*nbndry] += lambda_imag*(*MassMat)(bmap[j],imap[i]);
923 for(j = 0; j < nbmap; ++j)
925 C_data[j+(2*k+1)*nbmap + (i+2*k*nimap)*nbndry] -= lambda_imag*(*MassMat)(bmap[j],imap[i]);
928 for(j = 0; j < nimap; ++j)
930 D_data[i+2*k*nimap + (j+(2*k+1)*nimap)*nint] -= lambda_imag*(*MassMat)(imap[i],imap[j]);
933 for(j = 0; j < nimap; ++j)
935 D_data[i+(2*k+1)*nimap + (j+2*k*nimap)*nint] += lambda_imag*(*MassMat)(imap[i],imap[j]);
941 for(k = 0; k < nvel; ++k)
943 if((nz_loc == 2)&&(k == 2))
949 m_pressure->GetExp(n)->IProductWRTBase(deriv,pcoeffs);
952 ((nz_loc*k+1)*imap.size()+i)*nsize_p[n],1);
957 ((nz_loc*k)*imap.size()+i)*nsize_p[n]+psize,1);
961 Vmath::Vmul(npoints, Advtmp = Advfield[k] + phys_offset,1,deriv,1,tmpphys,1);
962 locExp->IProductWRTBase(tmpphys,coeffs);
965 for(nv = 0; nv < nvel; ++nv)
967 for(j = 0; j < nbmap; ++j)
969 B_data[j+2*nv*nbmap + (i+(2*nv+1)*nimap)*nbndry] +=
973 for(j = 0; j < nimap; ++j)
975 D_data[j+2*nv*nimap + (i+(2*nv+1)*nimap)*nint] +=
981 for(nv = 0; nv < nvel; ++nv)
983 for(j = 0; j < nbmap; ++j)
985 B_data[j+(2*nv+1)*nbmap + (i+2*nv*nimap)*nbndry] +=
989 for(j = 0; j < nimap; ++j)
991 D_data[j+(2*nv+1)*nimap + (i+2*nv*nimap)*nint] +=
1005 Advtmp = Advfield[k] + phys_offset,
1006 1,deriv,1,tmpphys,1);
1007 locExp->IProductWRTBase(tmpphys,coeffs);
1010 for(nv = 0; nv < nvel*nz_loc; ++nv)
1012 for(j = 0; j < nbmap; ++j)
1014 B_data[j+nv*nbmap + (i+nv*nimap)*nbndry] +=
1018 for(j = 0; j < nimap; ++j)
1020 D_data[j+nv*nimap + (i+nv*nimap)*nint] +=
1025 m_pressure->GetExp(n)->IProductWRTBase(deriv,pcoeffs);
1026 for(j = 0; j < nz_loc; ++j)
1030 ((nz_loc*k+j)*imap.size() + i)*nsize_p[n]+j*psize,1);
1035 if(IsLinearNSEquation)
1038 for(nv = 0; nv < nvel; ++nv)
1042 AdvDeriv[k*nvel+nv],
1044 locExp->IProductWRTBase(tmpphys,coeffs);
1046 for(n1 = 0; n1 < nz_loc; ++n1)
1048 for(j = 0; j < nbmap; ++j)
1050 B_data[j+(k*nz_loc+n1)*nbmap +
1051 (i+(nv*nz_loc+n1)*nimap)*nbndry] +=
1055 for(j = 0; j < nimap; ++j)
1057 D_data[j+(k*nz_loc+n1)*nimap +
1058 (i+(nv*nz_loc+n1)*nimap)*nint] +=
1076 B->GetColumns(), -1.0, B->GetRawPtr(),
1077 B->GetRows(), C->GetRawPtr(),
1079 Ah->GetRawPtr(), Ah->GetRows());
1092 DNekMat DintCinvDTint, BCinvDTint_m_DTbnd, DintCinvBTtilde_m_Dbnd;
1098 DintCinvDTint = (*Dint)*(*Cinv)*
Transpose(*Dint);
1102 DintCinvBTtilde_m_Dbnd = (*Dint)*(*Cinv)*
Transpose(*Btilde) - (*Dbnd);
1112 for(n1 = 0; n1 < nz_loc; ++n1)
1114 for(i = 0; i < psize-1; ++i)
1116 for(n2 = 0; n2 < nz_loc; ++n2)
1118 for(j = 0; j < psize-1; ++j)
1122 Dh_data[(i+n1*(psize-1)) + (j+n2*(psize-1))*Dh->GetRows()] =
1123 -DintCinvDTint(i+1+n1*psize,j+1+n2*psize);
1129 for(n1 = 0; n1 < nz_loc; ++n1)
1131 for(i = 0; i < nsize_bndry_p1[n]-nz_loc; ++i)
1133 (*Ah)(i,nsize_bndry_p1[n]-nz_loc+n1) = BCinvDTint_m_DTbnd(i,n1*psize);
1134 (*Ah)(nsize_bndry_p1[n]-nz_loc+n1,i) = DintCinvBTtilde_m_Dbnd(n1*psize,i);
1138 for(n1 = 0; n1 < nz_loc; ++n1)
1140 for(n2 = 0; n2 < nz_loc; ++n2)
1142 (*Ah)(nsize_bndry_p1[n]-nz_loc+n1,nsize_bndry_p1[n]-nz_loc+n2) =
1143 -DintCinvDTint(n1*psize,n2*psize);
1147 for(n1 = 0; n1 < nz_loc; ++n1)
1149 for(j = 0; j < psize-1; ++j)
1151 for(i = 0; i < nsize_bndry_p1[n]-nz_loc; ++i)
1153 (*Bh)(i,j+n1*(psize-1)) = BCinvDTint_m_DTbnd(i,j+1+n1*psize);
1154 (*Ch)(j+n1*(psize-1),i) = DintCinvBTtilde_m_Dbnd(j+1+n1*psize,i);
1159 for(n1 = 0; n1 < nz_loc; ++n1)
1161 for(n2 = 0; n2 < nz_loc; ++n2)
1163 for(j = 0; j < psize-1; ++j)
1165 (*Bh)(nsize_bndry_p1[n]-nz_loc+n1,j+n2*(psize-1)) = -DintCinvDTint(n1*psize,j+1+n2*psize);
1166 (*Ch)(j+n2*(psize-1),nsize_bndry_p1[n]-nz_loc+n1) = -DintCinvDTint(j+1+n2*psize,n1*psize);
1173 (*Bh) = (*Bh)*(*Dh);
1175 Blas::Dgemm(
'N',
'N', Bh->GetRows(), Ch->GetColumns(), Bh->GetColumns(), -1.0,
1176 Bh->GetRawPtr(), Bh->GetRows(), Ch->GetRawPtr(), Ch->GetRows(),
1177 1.0, Ah->GetRawPtr(), Ah->GetRows());
1187 cout <<
"Matrix Setup Costs: " << timer.
TimePerTest(1) << endl;
1250 "Advection Velocity section must be defined in "
1253 std::vector<std::string> fieldStr;
1258 GetFunction(
"AdvectionVelocity")->Evaluate(fieldStr, AdvField);
1278 "Restart section must be defined in session file.");
1285 std::vector<std::string> fieldStr;
1290 GetFunction(
"Restart")->Evaluate(fieldStr, Restart);
1296 cout <<
"Saving the RESTART file for m_kinvis = "<<
m_kinvis <<
" (<=> Re = " << 1/
m_kinvis <<
")" <<endl;
1307 cout <<
"Saving the Stokes Flow for m_kinvis = "<<
m_kinvis <<
" (<=> Re = " << 1/
m_kinvis <<
")" <<endl;
1322 "Advection Velocity section must be defined in "
1325 std::vector<std::string> fieldStr;
1330 GetFunction(
"AdvectionVelocity")->Evaluate(fieldStr, AdvField);
1337 ASSERTL0(
false,
"Unknown or undefined equation type for CoupledLinearNS");
1350 x->Apply(
m_fields, outarray, outarray, time);
1365 if(fabs(lambda_store - lambda) > 1e-10)
1368 lambda_store = lambda;
1394 for (
int k=0 ; k < nfields; ++k)
1406 for (
int k=0 ; k < nfields; ++k)
1434 Generaltimer.
Start();
1442 cout<<
"We execute INITIALLY SolveSteadyNavierStokes for m_kinvis = "<<
m_kinvis<<
" (<=> Re = "<<1/
m_kinvis<<
")"<<endl;
1449 cout<<
"We execute SolveSteadyNavierStokes for m_kinvis = "<<
m_kinvis<<
" (<=> Re = "<<1/
m_kinvis<<
")"<<endl;
1459 cout<<
"We execute SolveSteadyNavierStokes for m_kinvis = "<<
m_kinvis<<
" (<=> Re = "<<1/
m_kinvis<<
")"<<endl;
1467 Generaltimer.
Stop();
1468 cout<<
"\nThe total calculation time is : " << Generaltimer.
TimePerTest(1)/60 <<
" minute(s). \n\n";
1474 ASSERTL0(
false,
"Unknown or undefined equation type for CoupledLinearNS");
1491 const unsigned int ncmpt =
m_velocity.size();
1495 for(
int i = 0; i < ncmpt; ++i)
1504 x->Apply(
m_fields, forcing_phys, forcing_phys, time);
1506 for (
unsigned int i = 0; i < ncmpt; ++i)
1510 m_fields[i]->IProductWRTBase(forcing_phys[i], forcing[i]);
1511 m_fields[i]->SetWaveSpace(waveSpace);
1528 if(
m_session->DefinesFunction(
"ForcingTerm"))
1530 std::vector<std::string> fieldStr;
1543 cout <<
"'ForcingTerm' section has not been defined in the input file => forcing=0" << endl;
1550 Newtontimer.
Start();
1567 L2Norm(delta_velocity_Phys, L2_norm);
1570 while(max(L2_norm[0], L2_norm[1]) >
m_tol)
1614 Vmath::Vadd(Velocity_Phys[i].size(),Velocity_Phys[i], 1, delta_velocity_Phys[i], 1,
1615 Velocity_Phys[i], 1);
1619 L2Norm(delta_velocity_Phys, L2_norm);
1621 if(max(Inf_norm[0], Inf_norm[1]) > 100)
1623 cout<<
"\nThe Newton method has failed at m_kinvis = "<<
m_kinvis<<
" (<=> Re = " << 1/
m_kinvis <<
")"<< endl;
1624 ASSERTL0(0,
"The Newton method has failed... \n");
1641 cout<<
"We have done "<<
m_counter-1 <<
" iteration(s) in " << Newtontimer.
TimePerTest(1)/60 <<
" minute(s). \n\n";
1652 cout <<
"We apply the continuation method: " <<endl;
1681 Vmath::Vadd(u_star[i].size(), u_star[i], 1, u_N[i], 1, u_star[i], 1);
1696 for(
int j = 0; j < inarray[i].size(); ++j)
1698 if(inarray[i][j] > outarray[i])
1700 outarray[i] = inarray[i][j];
1703 cout <<
"InfNorm["<<i<<
"] = "<< outarray[i] <<endl;
1713 for(
int j = 0; j < inarray[i].size(); ++j)
1715 outarray[i] += inarray[i][j]*inarray[i][j];
1717 outarray[i]=
sqrt(outarray[i]);
1718 cout <<
"L2Norm["<<i<<
"] = "<< outarray[i] <<endl;
1758 Vmath::Vsub(outarray[i].size(), outarray[i], 1, AdvTerm[i], 1, outarray[i], 1);
1759 Vmath::Vsub(outarray[i].size(), outarray[i], 1, ViscTerm[i], 1, outarray[i], 1);
1761 Vmath::Vadd(outarray[i].size(), outarray[i], 1, Forc[i], 1, outarray[i], 1);
1775 for (
auto &expMapIter : VelExp)
1779 for(i = 0; i < expMapIter.second->m_basisKeyVector.size(); ++i)
1783 ASSERTL0(nummodes > 3,
"Velocity polynomial space not sufficiently high (>= 4)");
1786 BasisVec.push_back(newB);
1793 (*returnval)[expMapIter.first] = expansionElementShPtr;
1797 m_graph->SetExpansionInfo(
"p",returnval);
1889 force[i] = forcing[i] + 2*n*ncoeffsplane;
1906 force[i] = forcing[i];
1916 int i,j,k,n,cnt,cnt1;
1917 int nbnd,nint,offset;
1919 int nel = fields[0]->GetNumElmts();
1928 int nplanecoeffs = fields[
m_velocity[0]]->GetNcoeffs();
1947 for(i = 0; i < fields.size(); ++i)
1949 Vmath::Zero(nplanecoeffs,tmp = fields[i]->UpdateCoeffs()+nplanecoeffs,1);
1956 for(k = 0; k < nvel; ++k)
1959 std::dynamic_pointer_cast<MultiRegions::ContField>(fields[k]);
1962 GetBndCondCoeffsToLocalCoeffsSign();
1964 GetBndCondCoeffsToLocalCoeffsMap();
1968 bndConds = fields[k]->GetBndConditions();
1973 bndCondExp =
m_fields[k]->GetPlane(2*mode)->GetBndCondExpansions();
1977 bndCondExp =
m_fields[k]->GetBndCondExpansions();
1980 for(n = 0; n < nz_loc; ++n)
1983 for(i = 0; i < bndCondExp.size(); ++i)
1986 bndCondExp[i]->GetCoeffs();
1989 if(bndConds[i]->GetBoundaryConditionType() ==
1991 bndConds[i]->GetBoundaryConditionType() ==
1996 for(j = 0; j < (bndCondExp[i])->
GetNcoeffs(); j++)
1998 forcing[k][n*nplanecoeffs + map[bndcnt+j]] +=
sign[bndcnt+j] *
2004 for(j = 0; j < (bndCondExp[i])->
GetNcoeffs(); j++)
2006 forcing[k][n*nplanecoeffs + map[bndcnt+j]] += bndcoeffs[j];
2011 bndcnt += bndCondExp[i]->GetNcoeffs();
2022 for(i = 0; i < nel; ++i)
2024 fields[
m_velocity[0]]->GetExp(i)->GetBoundaryMap(bmap);
2025 fields[
m_velocity[0]]->GetExp(i)->GetInteriorMap(imap);
2028 offset = fields[
m_velocity[0]]->GetCoeff_Offset(i);
2030 for(j = 0; j < nvel; ++j)
2034 for(n = 0; n < nz_loc; ++n)
2036 for(k = 0; k < nbnd; ++k)
2038 f_bnd[cnt+k] = forcing[j][n*nplanecoeffs +
2041 bnd[bndoffset + (n + j*nz_loc)*nbnd + k] =
2042 incoeffs[n*nplanecoeffs + offset + bmap[k]];
2044 for(k = 0; k < nint; ++k)
2046 f_int[cnt1+k] = forcing[j][n*nplanecoeffs +
2054 bndoffset += nvel*nz_loc*nbnd + nz_loc*(
pressure->GetExp(i)->GetNcoeffs());
2062 F_bnd = F_bnd - (*
m_mat[mode].m_BCinv)*F_int;
2063 F_p_tmp = (*
m_mat[mode].m_Cinv)*F_int;
2064 F_p = (*
m_mat[mode].m_D_int) * F_p_tmp;
2070 for(i = 0; i < nel; ++i)
2072 nbnd = nz_loc*fields[0]->GetExp(i)->NumBndryCoeffs();
2074 for(j = 0; j < nvel; ++j)
2076 for(k = 0; k < nbnd; ++k)
2078 fh_bnd[offset + j*nbnd + k] =
2084 nint =
pressure->GetExp(i)->GetNcoeffs();
2085 offset += nvel*nbnd + nint*nz_loc;
2089 for(i = 0; i < nel; ++i)
2091 nbnd = nz_loc*fields[0]->GetExp(i)->NumBndryCoeffs();
2092 nint =
pressure->GetExp(i)->GetNcoeffs();
2094 for(n = 0; n < nz_loc; ++n)
2096 for(j = 0; j < nint; ++j)
2098 fh_bnd[offset + nvel*nbnd + n*nint+j] = f_p[cnt1+j];
2102 offset += nvel*nbnd + nz_loc*nint;
2108 int totpcoeffs =
pressure->GetNcoeffs();
2110 for(i = 0; i < nel; ++i)
2112 nbnd = nz_loc*fields[0]->GetExp(i)->NumBndryCoeffs();
2113 nint =
pressure->GetExp(i)->GetNcoeffs();
2114 for(j = 0; j < nvel; ++j)
2116 for(k = 0; k < nbnd; ++k)
2118 f_bnd[cnt+k] = bnd[offset + j*nbnd + k];
2122 offset += nvel*nbnd + nint*nz_loc;
2127 offset = cnt = cnt1 = 0;
2128 for(i = 0; i < nel; ++i)
2130 nint =
pressure->GetExp(i)->GetNcoeffs();
2131 nbnd = fields[0]->GetExp(i)->NumBndryCoeffs();
2132 cnt1 =
pressure->GetCoeff_Offset(i);
2134 for(n = 0; n < nz_loc; ++n)
2136 for(j = 0; j < nint; ++j)
2138 p_coeffs[n*totpcoeffs + cnt1+j] =
2139 f_p[cnt+j] = bnd[offset +
2145 offset += (nvel*nbnd + nint)*nz_loc;
2152 F_int = (*
m_mat[mode].m_Cinv)*F_int;
2156 for(i = 0; i < nel; ++i)
2158 fields[0]->GetExp(i)->GetBoundaryMap(bmap);
2159 fields[0]->GetExp(i)->GetInteriorMap(imap);
2162 offset = fields[0]->GetCoeff_Offset(i);
2164 for(j = 0; j < nvel; ++j)
2166 for(n = 0; n < nz_loc; ++n)
2168 for(k = 0; k < nbnd; ++k)
2170 fields[j]->SetCoeff(n*nplanecoeffs +
2175 for(k = 0; k < nint; ++k)
2177 fields[j]->SetCoeff(n*nplanecoeffs +
2187 for(j = 0; j < nvel; ++j)
2189 fields[j]->SetPhysState(
false);
2195 std::vector<Array<OneD, NekDouble> > fieldcoeffs(
m_fields.size()+1);
2196 std::vector<std::string> variables(
m_fields.size()+1);
2199 for(i = 0; i <
m_fields.size(); ++i)
2201 fieldcoeffs[i] =
m_fields[i]->UpdateCoeffs();
2212 m_fields[0]->GetPlane(0)->FwdTrans_IterPerExp(
m_pressure->GetPlane(0)->GetPhys(),fieldcoeffs[i]);
2213 m_fields[0]->GetPlane(1)->FwdTrans_IterPerExp(
m_pressure->GetPlane(1)->GetPhys(),tmpfieldcoeffs);
2214 for(
int e=0; e<
m_fields[0]->GetNcoeffs()/2; e++)
2216 fieldcoeffs[i][e+
m_fields[0]->GetNcoeffs()/2] = tmpfieldcoeffs[e];
2233 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....
#define sign(a, b)
return the sign(b)*a
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)
const SpatialDomains::ExpansionInfoMap & GenPressureExp(const SpatialDomains::ExpansionInfoMap &VelExp)
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)
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
void SetUpCoupledMatrix(const NekDouble lambda=0.0, const Array< OneD, Array< OneD, NekDouble > > &Advfield=NullNekDoubleArrayOfArray, bool IsLinearNSEquation=true)
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.
This class is the base class for Navier Stokes problems.
virtual void v_InitObject()
Init object for UnsteadySystem class.
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.
void EvaluateAdvectionTerms(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble time)
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.
NekDouble m_time
Current time of simulation.
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 op(A)[m x k], op(B)[k x n], C[m x n] DGEMM perfo...
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.
std::shared_ptr< ContField > ContFieldSharedPtr
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::shared_ptr< ExpansionInfoMap > ExpansionInfoMapShPtr
std::shared_ptr< ExpansionInfo > ExpansionInfoShPtr
std::shared_ptr< MeshGraph > MeshGraphSharedPtr
std::map< int, ExpansionInfoShPtr > ExpansionInfoMap
std::shared_ptr< StdExpansion > StdExpansionSharedPtr
@ eLinearAdvectionReaction
std::map< ConstFactorType, NekDouble > ConstFactorMap
The above copyright notice and this permission notice shall be included.
std::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
NekMatrix< InnerMatrixType, BlockMatrixTag > Transpose(NekMatrix< InnerMatrixType, BlockMatrixTag > &rhs)
static Array< OneD, Array< OneD, NekDouble > > NullNekDoubleArrayOfArray
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*x.
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.
scalarT< T > sqrt(scalarT< T > in)
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