68 Array<OneD, MultiRegions::ExpListSharedPtr> pFields)
76 m_spacedim = pFields[0]->GetGraph()->GetSpaceDimension();
77 m_expdim = pFields[0]->GetGraph()->GetMeshDimension();
89 if(
m_session->DefinesSolverInfo(
"HOMOGENEOUS"))
91 std::string HomoStr =
m_session->GetSolverInfo(
"HOMOGENEOUS");
94 if((HomoStr ==
"HOMOGENEOUS1D")||(HomoStr ==
"Homogeneous1D")||
95 (HomoStr ==
"1D")||(HomoStr ==
"Homo1D"))
103 if(
m_session->DefinesSolverInfo(
"ModeType"))
109 if(
m_session->DefinesSolverInfo(
"ModeType"))
125 ASSERTL0(
false,
"SolverInfo ModeType not valid");
136 if((HomoStr ==
"HOMOGENEOUS2D")||(HomoStr ==
"Homogeneous2D")||
137 (HomoStr ==
"2D")||(HomoStr ==
"Homo2D"))
147 if((HomoStr ==
"HOMOGENEOUS3D")||(HomoStr ==
"Homogeneous3D")||
148 (HomoStr ==
"3D")||(HomoStr ==
"Homo3D"))
160 if(
m_session->DefinesSolverInfo(
"USEFFT"))
170 if(
m_session->DefinesSolverInfo(
"PROJECTION"))
172 std::string ProjectStr
173 =
m_session->GetSolverInfo(
"PROJECTION");
175 if((ProjectStr ==
"Continuous")||(ProjectStr ==
"Galerkin")||
176 (ProjectStr ==
"CONTINUOUS")||(ProjectStr ==
"GALERKIN"))
180 else if(ProjectStr ==
"DisContinuous")
186 ASSERTL0(
false,
"PROJECTION value not recognised");
191 cerr <<
"Projection type not specified in SOLVERINFO,"
192 "defaulting to continuous Galerkin" << endl;
196 int nvar =
m_session->GetVariables().size();
197 m_baseflow = Array<OneD, Array<OneD, NekDouble> >(nvar);
198 for (
int i = 0; i < nvar; ++i)
200 m_baseflow[i] = Array<OneD, NekDouble>(pFields[i]->GetTotPoints(), 0.0);
204 "Base flow must be defined for linearised forms.");
205 string file =
m_session->GetFunctionFilename(
"BaseFlow", 0);
209 if(
m_session->DefinesParameter(
"N_slices"))
218 ASSERTL0(
false,
"Number of slices must be a positive number greater than 1");
236 int nq = pFields[0]->GetNpoints();
237 Array<OneD,NekDouble> x0(nq);
238 Array<OneD,NekDouble> x1(nq);
239 Array<OneD,NekDouble> x2(nq);
243 pFields[0]->GetCoords(x0,x1,x2);
244 for(
unsigned int i = 0 ; i <
m_baseflow.num_elements(); i++)
264 const int nConvectiveFields,
265 const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
266 const Array<
OneD, Array<OneD, NekDouble> > &advVel,
267 const Array<
OneD, Array<OneD, NekDouble> > &inarray,
268 Array<
OneD, Array<OneD, NekDouble> > &outarray,
271 int nqtot = fields[0]->GetTotPoints();
272 ASSERTL1(nConvectiveFields == inarray.num_elements(),
"Number of convective fields and Inarray are not compatible");
274 Array<OneD, NekDouble > Deriv = Array<OneD, NekDouble> (nqtot*nConvectiveFields);
276 for(
int n = 0; n < nConvectiveFields; ++n)
279 int ndim = advVel.num_elements();
280 int nPointsTot = fields[0]->GetNpoints();
281 Array<OneD, NekDouble> grad0,grad1,grad2;
285 Array<OneD, NekDouble> grad_base_u0,grad_base_u1,grad_base_u2;
287 Array<OneD, NekDouble> grad_base_v0,grad_base_v1,grad_base_v2;
289 Array<OneD, NekDouble> grad_base_w0,grad_base_w1,grad_base_w2;
292 grad0 = Array<OneD, NekDouble> (nPointsTot);
293 grad_base_u0 = Array<OneD, NekDouble> (nPointsTot);
294 grad_base_v0 = Array<OneD, NekDouble> (nPointsTot);
295 grad_base_w0 = Array<OneD, NekDouble> (nPointsTot);
302 if (
m_session->GetFunctionType(
"BaseFlow", 0)
305 for(
int i=0; i<ndim;++i)
312 ASSERTL0(
false,
"Periodic Base flow requires .fld files");
321 fields[0]->PhysDeriv(inarray[n],grad0);
322 fields[0]->PhysDeriv(
m_baseflow[0],grad_base_u0);
326 Vmath::Vvtvp(nPointsTot,grad_base_u0,1,advVel[0],1,outarray[n],1,outarray[n],1);
332 grad1 = Array<OneD, NekDouble> (nPointsTot);
333 grad_base_u1 = Array<OneD, NekDouble> (nPointsTot);
334 grad_base_v1 = Array<OneD, NekDouble> (nPointsTot);
336 fields[0]->PhysDeriv(inarray[n],grad0,grad1);
339 fields[0]-> PhysDeriv(
m_baseflow[0], grad_base_u0, grad_base_u1);
340 fields[0]-> PhysDeriv(
m_baseflow[1], grad_base_v0, grad_base_v1);
355 Vmath::Vvtvp(nPointsTot,grad_base_u0,1,advVel[0],1,outarray[n],1,outarray[n],1);
357 Vmath::Vvtvp(nPointsTot,grad_base_v0,1,advVel[1],1,outarray[n],1,outarray[n],1);
369 Vmath::Vvtvp(nPointsTot,grad_base_u1,1,advVel[0],1,outarray[n],1,outarray[n],1);
371 Vmath::Vvtvp(nPointsTot,grad_base_v1,1,advVel[1],1,outarray[n],1,outarray[n],1);
380 grad1 = Array<OneD, NekDouble> (nPointsTot);
381 grad2 = Array<OneD, NekDouble> (nPointsTot);
382 grad_base_u1 = Array<OneD, NekDouble> (nPointsTot);
383 grad_base_v1 = Array<OneD, NekDouble> (nPointsTot);
384 grad_base_w1 = Array<OneD, NekDouble> (nPointsTot);
386 grad_base_u2 = Array<OneD, NekDouble> (nPointsTot);
387 grad_base_v2 = Array<OneD, NekDouble> (nPointsTot);
388 grad_base_w2 = Array<OneD, NekDouble> (nPointsTot);
390 fields[0]->PhysDeriv(
m_baseflow[0], grad_base_u0, grad_base_u1,grad_base_u2);
391 fields[0]->PhysDeriv(
m_baseflow[1], grad_base_v0, grad_base_v1,grad_base_v2);
392 fields[0]->PhysDeriv(
m_baseflow[2], grad_base_w0, grad_base_w1, grad_base_w2);
397 for(
int i=0; i<grad_base_u2.num_elements();++i)
406 fields[0]->PhysDeriv(inarray[n], grad0, grad1, grad2);
421 Vmath::Vvtvp(nPointsTot,grad_base_u0,1,advVel[0],1,outarray[n],1,outarray[n],1);
423 Vmath::Vvtvp(nPointsTot,grad_base_v0,1,advVel[1],1,outarray[n],1,outarray[n],1);
425 Vmath::Vvtvp(nPointsTot,grad_base_w0,1,advVel[2],1,outarray[n],1,outarray[n],1);
438 Vmath::Vvtvp(nPointsTot,grad_base_u1,1,advVel[0],1,outarray[n],1,outarray[n],1);
440 Vmath::Vvtvp(nPointsTot,grad_base_v1,1,advVel[1],1,outarray[n],1,outarray[n],1);
442 Vmath::Vvtvp(nPointsTot,grad_base_w1,1,advVel[2],1,outarray[n],1,outarray[n],1);
456 Vmath::Vvtvp(nPointsTot,grad_base_u2,1,advVel[0],1,outarray[n],1,outarray[n],1);
458 Vmath::Vvtvp(nPointsTot,grad_base_v2,1,advVel[1],1,outarray[n],1,outarray[n],1);
460 Vmath::Vvtvp(nPointsTot,grad_base_w2,1,advVel[2],1,outarray[n],1,outarray[n],1);
465 ASSERTL0(
false,
"dimension unknown");
475 const Array<
OneD, Array<OneD, NekDouble> > &inarray)
478 "Number of base flow variables does not match what is"
481 int npts = inarray[0].num_elements();
482 for (
int i = 0; i < inarray.num_elements(); ++i)
485 "Size of base flow array does not match expected.");
498 Array<OneD, MultiRegions::ExpListSharedPtr>& pFields,
int slice)
500 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
501 std::vector<std::vector<NekDouble> > FieldData;
503 int nqtot = pFields[0]->GetTotPoints();
504 Array<OneD, NekDouble> tmp_coeff(pFields[0]->GetNcoeffs(), 0.0);
510 fld->Import(pInfile, FieldDef, FieldData);
512 int nvar =
m_session->GetVariables().size();
515 if(
m_session->DefinesSolverInfo(
"HOMOGENEOUS"))
517 std::string HomoStr =
m_session->GetSolverInfo(
"HOMOGENEOUS");
521 for(
int j = 0; j < nvar; ++j)
523 for(
int i = 0; i < FieldDef.size(); ++i)
525 if ((
m_session->DefinesSolverInfo(
"HOMOGENEOUS") &&
526 (
m_session->GetSolverInfo(
"HOMOGENEOUS")==
"HOMOGENEOUS1D" ||
527 m_session->GetSolverInfo(
"HOMOGENEOUS")==
"1D" ||
528 m_session->GetSolverInfo(
"HOMOGENEOUS")==
"Homo1D")) &&
535 s = (j == nvar - 1) ? 2 : j;
538 pFields[j]->ExtractDataToCoeffs(
541 FieldDef[i]->m_fields[s],
546 int ncplane = (pFields[0]->GetNcoeffs()) /
m_npointsZ;
551 &tmp_coeff[2*ncplane],1);
557 bool flag = FieldDef[i]->m_fields[j] ==
560 ASSERTL0(flag, (std::string(
"Order of ") + pInfile
561 + std::string(
" data and that defined in "
562 "m_boundaryconditions differs")).c_str());
564 pFields[j]->ExtractDataToCoeffs(FieldDef[i], FieldData[i],
565 FieldDef[i]->m_fields[j],
572 pFields[j]->GetPlane(0)->BwdTrans(tmp_coeff,
m_baseflow[j]);
577 int ncplane=(pFields[0]->GetNpoints())/
m_npointsZ;
583 pFields[j]->BwdTrans(tmp_coeff,
m_baseflow[j]);
587 if(
m_session->DefinesParameter(
"N_slices"))
589 int n = pFields.num_elements()-1;
591 for(
int i=0; i<n;++i)
602 const Array<OneD, const NekDouble> &inarray,
603 Array<OneD, NekDouble> &outarray,
612 Array<OneD, NekDouble> auxiliary(npoints);
615 Vmath::Svtvp(npoints, cos(0.5*m_slices*BetaT),&inarray[npoints],1,&outarray[0],1,&outarray[0],1);
617 for (
int i = 2; i <
m_slices; i += 2)
619 phase = (i>>1) * BetaT;
621 Vmath::Svtvp(npoints, cos(phase),&inarray[i*npoints],1,&outarray[0],1,&outarray[0],1);
622 Vmath::Svtvp(npoints, sin(phase), &inarray[(i+1)*npoints], 1, &outarray[0], 1,&outarray[0],1);
635 Array<OneD,unsigned int> nrows(n_exp);
636 Array<OneD,unsigned int> ncols(n_exp);
638 nrows = Array<OneD, unsigned int>(n_exp,
m_slices);
639 ncols = Array<OneD, unsigned int>(n_exp,
m_slices);
657 for(
int i = 0; i < n_exp; ++i)
659 BlkMatrix->SetBlock(i,i,loc_mat);
667 Array<OneD, MultiRegions::ExpListSharedPtr>& pFields,
673 int ConvectedFields=
m_baseflow.num_elements()-1;
675 m_interp= Array<OneD, Array<OneD, NekDouble> > (ConvectedFields);
676 for(
int i=0; i<ConvectedFields;++i)
685 char chkout[16] =
"";
686 sprintf(chkout,
"%d", i);
692 for(
int k=0; k< ConvectedFields;++k)
694 #ifdef NEKTAR_USING_FFTW
699 Array<OneD, NekDouble> fft_in(npoints*m_slices);
700 Array<OneD, NekDouble> fft_out(npoints*m_slices);
702 Array<OneD, NekDouble>
m_tmpIN(m_slices);
703 Array<OneD, NekDouble>
m_tmpOUT(m_slices);
714 for(
int i=0; i<npoints; i++)
716 m_FFT->FFTFwdTrans(m_tmpIN =fft_in + i*m_slices, m_tmpOUT =fft_out + i*m_slices);
736 int nrows = blkmat->GetRows();
737 int ncols = blkmat->GetColumns();
739 Array<OneD, NekDouble> sortedinarray(ncols);
740 Array<OneD, NekDouble> sortedoutarray(nrows);
761 Vmath::Zero(sortedinarray.num_elements(),&sortedinarray[0],1);
762 Vmath::Zero(sortedoutarray.num_elements(),&sortedoutarray[0],1);
768 for (
int i = 2; i <
m_slices; i += 2)
777 if(
m_session->DefinesParameter(
"period"))