84 if(
m_session->DefinesSolverInfo(
"HOMOGENEOUS"))
86 std::string HomoStr =
m_session->GetSolverInfo(
"HOMOGENEOUS");
89 if((HomoStr ==
"HOMOGENEOUS1D")||(HomoStr ==
"Homogeneous1D")||
90 (HomoStr ==
"1D")||(HomoStr ==
"Homo1D"))
96 if(
m_session->DefinesSolverInfo(
"ModeType"))
103 if(
m_session->DefinesSolverInfo(
"ModeType"))
121 ASSERTL0(
false,
"SolverInfo ModeType not valid");
134 if((HomoStr ==
"HOMOGENEOUS2D")||(HomoStr ==
"Homogeneous2D")||
135 (HomoStr ==
"2D")||(HomoStr ==
"Homo2D"))
145 if((HomoStr ==
"HOMOGENEOUS3D")||(HomoStr ==
"Homogeneous3D")||
146 (HomoStr ==
"3D")||(HomoStr ==
"Homo3D"))
158 if(
m_session->DefinesSolverInfo(
"USEFFT"))
168 if(
m_session->DefinesSolverInfo(
"PROJECTION"))
170 std::string ProjectStr
171 =
m_session->GetSolverInfo(
"PROJECTION");
173 if((ProjectStr ==
"Continuous")||(ProjectStr ==
"Galerkin")||
174 (ProjectStr ==
"CONTINUOUS")||(ProjectStr ==
"GALERKIN"))
178 else if(ProjectStr ==
"DisContinuous")
184 ASSERTL0(
false,
"PROJECTION value not recognised");
189 cerr <<
"Projection type not specified in SOLVERINFO,"
190 "defaulting to continuous Galerkin" << endl;
196 "Base flow must be defined for linearised forms.");
197 string file =
m_session->GetFunctionFilename(
"BaseFlow", 0);
201 if(
m_session->DefinesParameter(
"N_slices"))
210 ASSERTL0(
false,
"Number of slices must be a positive number greater than 1");
228 int nq =
m_base[0]->GetNpoints();
229 Array<OneD,NekDouble> x0(nq);
230 Array<OneD,NekDouble> x1(nq);
231 Array<OneD,NekDouble> x2(nq);
235 m_base[0]->GetCoords(x0,x1,x2);
236 for(
unsigned int i = 0 ; i <
m_base.num_elements(); i++)
241 ifunc->Evaluate(x0,x1,x2,
m_base[i]->UpdatePhys());
243 m_base[i]->SetPhysState(
true);
245 m_base[i]->UpdateCoeffs());
273 for(i = 0 ; i <
m_base.num_elements(); i++)
282 for(i = 0 ; i <
m_base.num_elements(); i++)
301 for(i = 0 ; i <
m_base.num_elements(); i++)
305 m_base[i]->SetWaveSpace(
true);
316 for(i = 0 ; i <
m_base.num_elements(); i++)
320 m_base[i]->SetWaveSpace(
true);
331 for(i = 0 ; i <
m_base.num_elements(); i++)
335 m_base[i]->SetWaveSpace(
false);
349 for(i = 1 ; i < m_base.num_elements(); i++)
362 ASSERTL0(
false,
"3D fully periodic problems not implemented yet");
372 for(i = 1 ; i < m_base.num_elements(); i++)
382 ASSERTL0(
false,
"Expansion dimension not recognised");
399 for(i = 0 ; i <
m_base.num_elements(); i++)
407 for(i = 0 ; i <
m_base.num_elements(); i++)
424 for(i = 0 ; i <
m_base.num_elements(); i++)
435 for(i = 0 ; i <
m_base.num_elements(); i++)
448 ASSERTL0(
false,
"Expansion dimension not recognised");
464 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
465 std::vector<std::vector<NekDouble> > FieldData;
466 int nqtot =
m_base[0]->GetTotPoints();
472 fld->Import(pInfile, FieldDef, FieldData);
474 int nvar =
m_session->GetVariables().size();
477 if(
m_session->DefinesSolverInfo(
"HOMOGENEOUS"))
479 std::string HomoStr =
m_session->GetSolverInfo(
"HOMOGENEOUS");
483 for(
int j = 0; j < nvar; ++j)
485 for(
int i = 0; i < FieldDef.size(); ++i)
487 if((
m_session->DefinesSolverInfo(
"HOMOGENEOUS") &&
488 (
m_session->GetSolverInfo(
"HOMOGENEOUS")==
"HOMOGENEOUS1D" ||
489 m_session->GetSolverInfo(
"HOMOGENEOUS")==
"1D" ||
490 m_session->GetSolverInfo(
"HOMOGENEOUS")==
"Homo1D")) &&
497 s = (j == nvar - 1) ? 2 : j;
500 m_base[j]->ExtractDataToCoeffs(
503 FieldDef[i]->m_fields[s],
504 m_base[j]->UpdateCoeffs());
514 &
m_base[j]->UpdateCoeffs()[2*ncplane], 1);
520 bool flag = FieldDef[i]->m_fields[j] ==
523 ASSERTL1(flag, (std::string(
"Order of ") + pInfile
524 + std::string(
" data and that defined in "
525 "m_boundaryconditions differs")).c_str());
527 m_base[j]->ExtractDataToCoeffs(FieldDef[i], FieldData[i],
528 FieldDef[i]->m_fields[j],
529 m_base[j]->UpdateCoeffs());
535 m_base[j]->SetWaveSpace(
true);
559 if(
m_session->DefinesParameter(
"N_slices"))
575 Array<OneD, MultiRegions::ExpListSharedPtr > &pFields,
576 const Array<
OneD, Array<OneD, NekDouble> > &pVelocity,
577 const Array<OneD, const NekDouble> &pU,
578 Array<OneD, NekDouble> &pOutarray,
579 int pVelocityComponent,
581 Array<OneD, NekDouble> &pWk)
584 int nPointsTot = pFields[0]->GetNpoints();
586 Array<OneD, NekDouble> grad0,grad1,grad2;
590 Array<OneD, NekDouble> grad_base_u0,grad_base_u1,grad_base_u2;
593 Array<OneD, NekDouble> grad_base_v0,grad_base_v1,grad_base_v2;
596 Array<OneD, NekDouble> grad_base_w0,grad_base_w1,grad_base_w2;
598 grad0 = Array<OneD, NekDouble> (nPointsTot);
599 grad_base_u0 = Array<OneD, NekDouble> (nPointsTot);
600 grad_base_v0 = Array<OneD, NekDouble> (nPointsTot);
601 grad_base_w0 = Array<OneD, NekDouble> (nPointsTot);
607 if (
m_session->GetFunctionType(
"BaseFlow", 0)
617 ASSERTL0(
false,
"Periodic Base flow requires filename_ files");
627 pFields[0]->PhysDeriv(pU,grad0);
628 pFields[0]->PhysDeriv(
m_base[0]->GetPhys(),grad_base_u0);
632 Vmath::Vvtvp(nPointsTot,grad_base_u0,1,pVelocity[0],1,pOutarray,1,pOutarray,1);
637 grad1 = Array<OneD, NekDouble> (nPointsTot);
638 grad_base_u1 = Array<OneD, NekDouble> (nPointsTot);
639 grad_base_v1 = Array<OneD, NekDouble> (nPointsTot);
641 pFields[0]->PhysDeriv(pU,grad0,grad1);
644 pFields[0]-> PhysDeriv(
m_base[0]->GetPhys(), grad_base_u0, grad_base_u1);
645 pFields[0]-> PhysDeriv(
m_base[1]->GetPhys(), grad_base_v0, grad_base_v1);
650 switch (pVelocityComponent)
659 Vmath::Vvtvp(nPointsTot,grad_base_u0,1,pVelocity[0],1,pOutarray,1,pOutarray,1);
661 Vmath::Vvtvp(nPointsTot,grad_base_u1,1,pVelocity[1],1,pOutarray,1,pOutarray,1);
671 Vmath::Vvtvp(nPointsTot,grad_base_v0,1,pVelocity[0],1,pOutarray,1,pOutarray,1);
673 Vmath::Vvtvp(nPointsTot,grad_base_v1,1,pVelocity[1],1,pOutarray,1,pOutarray,1);
680 grad1 = Array<OneD, NekDouble> (nPointsTot);
681 grad2 = Array<OneD, NekDouble> (nPointsTot);
682 grad_base_u1 = Array<OneD, NekDouble> (nPointsTot);
683 grad_base_v1 = Array<OneD, NekDouble> (nPointsTot);
684 grad_base_w1 = Array<OneD, NekDouble> (nPointsTot);
686 grad_base_u2 = Array<OneD, NekDouble> (nPointsTot);
687 grad_base_v2 = Array<OneD, NekDouble> (nPointsTot);
688 grad_base_w2 = Array<OneD, NekDouble> (nPointsTot);
690 m_base[0]->PhysDeriv(
m_base[0]->GetPhys(), grad_base_u0, grad_base_u1,grad_base_u2);
691 m_base[0]->PhysDeriv(
m_base[1]->GetPhys(), grad_base_v0, grad_base_v1,grad_base_v2);
692 m_base[0]->PhysDeriv(
m_base[2]->GetPhys(), grad_base_w0, grad_base_w1, grad_base_w2);
697 for(
int i=0; i<grad_base_u2.num_elements();++i)
705 pFields[0]->PhysDeriv(pU, grad0, grad1, grad2);
707 switch (pVelocityComponent)
723 pFields[0]->DealiasedProd(pVelocity[0],grad_base_u0,grad_base_u0,
m_CoeffState);
725 pFields[0]->DealiasedProd(pVelocity[1],grad_base_u1,grad_base_u1,
m_CoeffState);
727 pFields[0]->DealiasedProd(pVelocity[2],grad_base_u2,grad_base_u2,
m_CoeffState);
729 Vmath::Vadd(nPointsTot,grad0,1,grad1,1,pOutarray,1);
730 Vmath::Vadd(nPointsTot,grad2,1,pOutarray,1,pOutarray,1);
731 Vmath::Vadd(nPointsTot,grad_base_u0,1,pOutarray,1,pOutarray,1);
732 Vmath::Vadd(nPointsTot,grad_base_u1,1,pOutarray,1,pOutarray,1);
733 Vmath::Vadd(nPointsTot,grad_base_u2,1,pOutarray,1,pOutarray,1);
742 Vmath::Vvtvp(nPointsTot,grad_base_u0,1,pVelocity[0],1,pOutarray,1,pOutarray,1);
744 Vmath::Vvtvp(nPointsTot,grad_base_u1,1,pVelocity[1],1,pOutarray,1,pOutarray,1);
748 Vmath::Vvtvp(nPointsTot,grad_base_u2,1,pVelocity[2],1,pOutarray,1,pOutarray,1);
762 pFields[0]->DealiasedProd(pVelocity[0],grad_base_v0,grad_base_v0,
m_CoeffState);
764 pFields[0]->DealiasedProd(pVelocity[1],grad_base_v1,grad_base_v1,
m_CoeffState);
766 pFields[0]->DealiasedProd(pVelocity[2],grad_base_v2,grad_base_v2,
m_CoeffState);
768 Vmath::Vadd(nPointsTot,grad0,1,grad1,1,pOutarray,1);
769 Vmath::Vadd(nPointsTot,grad2,1,pOutarray,1,pOutarray,1);
770 Vmath::Vadd(nPointsTot,grad_base_v0,1,pOutarray,1,pOutarray,1);
771 Vmath::Vadd(nPointsTot,grad_base_v1,1,pOutarray,1,pOutarray,1);
772 Vmath::Vadd(nPointsTot,grad_base_v2,1,pOutarray,1,pOutarray,1);
781 Vmath::Vvtvp(nPointsTot,grad_base_v0,1,pVelocity[0],1,pOutarray,1,pOutarray,1);
783 Vmath::Vvtvp(nPointsTot,grad_base_v1,1,pVelocity[1],1,pOutarray,1,pOutarray,1);
787 Vmath::Vvtvp(nPointsTot,grad_base_v2,1,pVelocity[2],1,pOutarray,1,pOutarray,1);
802 pFields[0]->DealiasedProd(pVelocity[0],grad_base_w0,grad_base_w0,
m_CoeffState);
804 pFields[0]->DealiasedProd(pVelocity[1],grad_base_w1,grad_base_w1,
m_CoeffState);
806 pFields[0]->DealiasedProd(pVelocity[2],grad_base_w2,grad_base_w2,
m_CoeffState);
808 Vmath::Vadd(nPointsTot,grad0,1,grad1,1,pOutarray,1);
809 Vmath::Vadd(nPointsTot,grad2,1,pOutarray,1,pOutarray,1);
810 Vmath::Vadd(nPointsTot,grad_base_w0,1,pOutarray,1,pOutarray,1);
811 Vmath::Vadd(nPointsTot,grad_base_w1,1,pOutarray,1,pOutarray,1);
812 Vmath::Vadd(nPointsTot,grad_base_w2,1,pOutarray,1,pOutarray,1);
821 Vmath::Vvtvp(nPointsTot,grad_base_w0,1,pVelocity[0],1,pOutarray,1,pOutarray,1);
823 Vmath::Vvtvp(nPointsTot,grad_base_w1,1,pVelocity[1],1,pOutarray,1,pOutarray,1);
827 Vmath::Vvtvp(nPointsTot,grad_base_w2,1,pVelocity[2],1,pOutarray,1,pOutarray,1);
833 ASSERTL0(
false,
"dimension unknown");
838 Array<OneD, const NekDouble> &inarray,
839 Array<OneD, NekDouble> &outarray,
844 int npoints=
m_base[0]->GetTotPoints();
848 Array<OneD, NekDouble> auxiliary(npoints);
851 Vmath::Svtvp(npoints, cos(0.5*m_slices*BetaT),&inarray[npoints],1,&outarray[0],1,&outarray[0],1);
853 for (
int i = 2; i <
m_slices; i += 2)
855 phase = (i>>1) * BetaT;
857 Vmath::Svtvp(npoints, cos(phase),&inarray[i*npoints],1,&outarray[0],1,&outarray[0],1);
858 Vmath::Svtvp(npoints, sin(phase), &inarray[(i+1)*npoints], 1, &outarray[0], 1,&outarray[0],1);
866 Array<OneD, Array<OneD, NekDouble> > fieldcoeffs(
m_base.num_elements());
867 Array<OneD, std::string> variables(
m_base.num_elements());
869 for(
int i = 0; i <
m_base.num_elements(); ++i)
871 fieldcoeffs[i] =
m_base[i]->UpdateCoeffs();
889 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef= field->GetFieldDefinitions();
890 std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
893 for(
int j = 0; j < fieldcoeffs.num_elements(); ++j)
895 for(
int i = 0; i < FieldDef.size(); ++i)
898 FieldDef[i]->m_fields.push_back(variables[j]);
900 field->AppendFieldData(FieldDef[i], FieldData[i], fieldcoeffs[j]);
913 n_exp =
m_base[0]->GetTotPoints();
915 Array<OneD,unsigned int> nrows(n_exp);
916 Array<OneD,unsigned int> ncols(n_exp);
918 nrows = Array<OneD, unsigned int>(n_exp,
m_slices);
919 ncols = Array<OneD, unsigned int>(n_exp,
m_slices);
937 for(
int i = 0; i < n_exp; ++i)
939 BlkMatrix->SetBlock(i,i,loc_mat);
948 int npoints=
m_base[0]->GetTotPoints();
951 int ConvectedFields=
m_base.num_elements()-1;
953 m_interp= Array<OneD, Array<OneD, NekDouble> > (ConvectedFields);
954 for(
int i=0; i<ConvectedFields;++i)
963 char chkout[16] =
"";
964 sprintf(chkout,
"%d", i);
970 for(
int k=0; k< ConvectedFields;++k)
972 #ifdef NEKTAR_USING_FFTW
975 Array<OneD, NekDouble> fft_in(npoints*m_slices);
976 Array<OneD, NekDouble> fft_out(npoints*m_slices);
978 Array<OneD, NekDouble>
m_tmpIN(m_slices);
979 Array<OneD, NekDouble>
m_tmpOUT(m_slices);
990 for(
int i=0; i<npoints; i++)
992 m_FFT->FFTFwdTrans(m_tmpIN =fft_in + i*m_slices, m_tmpOUT =fft_out + i*m_slices);
1004 Vmath::Zero(fft_out.num_elements(),&fft_out[0],1);
1010 int nrows = blkmat->GetRows();
1011 int ncols = blkmat->GetColumns();
1013 Array<OneD, NekDouble> sortedinarray(ncols);
1014 Array<OneD, NekDouble> sortedoutarray(nrows);
1035 for(
int r=0; r<sortedinarray.num_elements();++r)
1038 sortedoutarray[0]=0;
1045 for (
int i = 2; i <
m_slices; i += 2)
1054 if(
m_session->DefinesParameter(
"period"))