72 Array<OneD, MultiRegions::ExpListSharedPtr> pFields)
79 m_spacedim = pFields[0]->GetGraph()->GetSpaceDimension();
80 m_expdim = pFields[0]->GetGraph()->GetMeshDimension();
92 if(
m_session->DefinesSolverInfo(
"HOMOGENEOUS"))
94 std::string HomoStr =
m_session->GetSolverInfo(
"HOMOGENEOUS");
97 if((HomoStr ==
"HOMOGENEOUS1D")||(HomoStr ==
"Homogeneous1D")||
98 (HomoStr ==
"1D")||(HomoStr ==
"Homo1D"))
106 if(
m_session->DefinesSolverInfo(
"ModeType"))
113 if(
m_session->DefinesSolverInfo(
"ModeType"))
131 ASSERTL0(
false,
"SolverInfo ModeType not valid");
144 if((HomoStr ==
"HOMOGENEOUS2D")||(HomoStr ==
"Homogeneous2D")||
145 (HomoStr ==
"2D")||(HomoStr ==
"Homo2D"))
155 if((HomoStr ==
"HOMOGENEOUS3D")||(HomoStr ==
"Homogeneous3D")||
156 (HomoStr ==
"3D")||(HomoStr ==
"Homo3D"))
168 if(
m_session->DefinesSolverInfo(
"USEFFT"))
178 if(
m_session->DefinesSolverInfo(
"PROJECTION"))
180 std::string ProjectStr
181 =
m_session->GetSolverInfo(
"PROJECTION");
183 if((ProjectStr ==
"Continuous")||(ProjectStr ==
"Galerkin")||
184 (ProjectStr ==
"CONTINUOUS")||(ProjectStr ==
"GALERKIN"))
188 else if(ProjectStr ==
"DisContinuous")
194 ASSERTL0(
false,
"PROJECTION value not recognised");
199 cerr <<
"Projection type not specified in SOLVERINFO,"
200 "defaulting to continuous Galerkin" << endl;
204 int nvar =
m_session->GetVariables().size();
205 m_baseflow = Array<OneD, Array<OneD, NekDouble> >(nvar);
206 for (
int i = 0; i < nvar; ++i)
208 m_baseflow[i] = Array<OneD, NekDouble>(pFields[i]->GetTotPoints(), 0.0);
212 "Base flow must be defined for linearised forms.");
213 string file =
m_session->GetFunctionFilename(
"BaseFlow", 0);
217 if(
m_session->DefinesParameter(
"N_slices"))
226 ASSERTL0(
false,
"Number of slices must be a positive number greater than 1");
244 int nq = pFields[0]->GetNpoints();
245 Array<OneD,NekDouble> x0(nq);
246 Array<OneD,NekDouble> x1(nq);
247 Array<OneD,NekDouble> x2(nq);
251 pFields[0]->GetCoords(x0,x1,x2);
253 for(
unsigned int i = 0 ; i < pFields.num_elements(); i++)
263 if(
m_session->DefinesParameter(
"period"))
282 const int nConvectiveFields,
283 const Array<OneD, MultiRegions::ExpListSharedPtr> &fields,
284 const Array<
OneD, Array<OneD, NekDouble> > &advVel,
285 const Array<
OneD, Array<OneD, NekDouble> > &inarray,
286 Array<
OneD, Array<OneD, NekDouble> > &outarray,
289 int nqtot = fields[0]->GetTotPoints();
290 ASSERTL1(nConvectiveFields == inarray.num_elements(),
"Number of convective fields and Inarray are not compatible");
292 Array<OneD, NekDouble > Deriv = Array<OneD, NekDouble> (nqtot*nConvectiveFields);
294 for(
int n = 0; n < nConvectiveFields; ++n)
296 int ndim = advVel.num_elements();
297 int nPointsTot = fields[0]->GetNpoints();
299 Array<OneD, NekDouble> grad0,grad1,grad2;
303 Array<OneD, NekDouble> grad_base_u0,grad_base_u1,grad_base_u2;
306 Array<OneD, NekDouble> grad_base_v0,grad_base_v1,grad_base_v2;
309 Array<OneD, NekDouble> grad_base_w0,grad_base_w1,grad_base_w2;
311 grad0 = Array<OneD, NekDouble> (nPointsTot);
312 grad_base_u0 = Array<OneD, NekDouble> (nPointsTot);
313 grad_base_v0 = Array<OneD, NekDouble> (nPointsTot);
314 grad_base_w0 = Array<OneD, NekDouble> (nPointsTot);
320 if (
m_session->GetFunctionType(
"BaseFlow", 0)
323 for(
int i=0; i<ndim;++i)
330 ASSERTL0(
false,
"Periodic Base flow requires filename_ files");
340 fields[0]->PhysDeriv(inarray[n],grad0);
341 fields[0]->PhysDeriv(
m_baseflow[0],grad_base_u0);
345 Vmath::Vvtvp(nPointsTot,grad_base_u0,1,advVel[0],1,outarray[n],1,outarray[n],1);
350 grad1 = Array<OneD, NekDouble> (nPointsTot);
351 grad_base_u1 = Array<OneD, NekDouble> (nPointsTot);
352 grad_base_v1 = Array<OneD, NekDouble> (nPointsTot);
353 fields[0]->PhysDeriv(inarray[n],grad0,grad1);
356 fields[0]-> PhysDeriv(
m_baseflow[0], grad_base_u0, grad_base_u1);
357 fields[0]-> PhysDeriv(
m_baseflow[1], grad_base_v0, grad_base_v1);
371 Vmath::Vvtvp(nPointsTot,grad_base_u0,1,advVel[0],1,outarray[n],1,outarray[n],1);
373 Vmath::Vvtvp(nPointsTot,grad_base_u1,1,advVel[1],1,outarray[n],1,outarray[n],1);
383 Vmath::Vvtvp(nPointsTot,grad_base_v0,1,advVel[0],1,outarray[n],1,outarray[n],1);
385 Vmath::Vvtvp(nPointsTot,grad_base_v1,1,advVel[1],1,outarray[n],1,outarray[n],1);
392 grad1 = Array<OneD, NekDouble> (nPointsTot);
393 grad2 = Array<OneD, NekDouble> (nPointsTot);
394 grad_base_u1 = Array<OneD, NekDouble> (nPointsTot);
395 grad_base_v1 = Array<OneD, NekDouble> (nPointsTot);
396 grad_base_w1 = Array<OneD, NekDouble> (nPointsTot);
398 grad_base_u2 = Array<OneD, NekDouble> (nPointsTot);
399 grad_base_v2 = Array<OneD, NekDouble> (nPointsTot);
400 grad_base_w2 = Array<OneD, NekDouble> (nPointsTot);
402 fields[0]->PhysDeriv(
m_baseflow[0], grad_base_u0, grad_base_u1,grad_base_u2);
403 fields[0]->PhysDeriv(
m_baseflow[1], grad_base_v0, grad_base_v1,grad_base_v2);
404 fields[0]->PhysDeriv(
m_baseflow[2], grad_base_w0, grad_base_w1, grad_base_w2);
409 for(
int i=0; i<grad_base_u2.num_elements();++i)
417 fields[0]->PhysDeriv(inarray[n], grad0, grad1, grad2);
435 fields[0]->DealiasedProd(advVel[0],grad_base_u0,grad_base_u0,
m_CoeffState);
437 fields[0]->DealiasedProd(advVel[1],grad_base_u1,grad_base_u1,
m_CoeffState);
439 fields[0]->DealiasedProd(advVel[2],grad_base_u2,grad_base_u2,
m_CoeffState);
441 Vmath::Vadd(nPointsTot,grad0,1,grad1,1,outarray[n],1);
442 Vmath::Vadd(nPointsTot,grad2,1,outarray[n],1,outarray[n],1);
443 Vmath::Vadd(nPointsTot,grad_base_u0,1,outarray[n],1,outarray[n],1);
444 Vmath::Vadd(nPointsTot,grad_base_u1,1,outarray[n],1,outarray[n],1);
445 Vmath::Vadd(nPointsTot,grad_base_u2,1,outarray[n],1,outarray[n],1);
454 Vmath::Vvtvp(nPointsTot,grad_base_u0,1,advVel[0],1,outarray[n],1,outarray[n],1);
456 Vmath::Vvtvp(nPointsTot,grad_base_u1,1,advVel[1],1,outarray[n],1,outarray[n],1);
460 Vmath::Vvtvp(nPointsTot,grad_base_u2,1,advVel[2],1,outarray[n],1,outarray[n],1);
474 fields[0]->DealiasedProd(advVel[0],grad_base_v0,grad_base_v0,
m_CoeffState);
476 fields[0]->DealiasedProd(advVel[1],grad_base_v1,grad_base_v1,
m_CoeffState);
478 fields[0]->DealiasedProd(advVel[2],grad_base_v2,grad_base_v2,
m_CoeffState);
480 Vmath::Vadd(nPointsTot,grad0,1,grad1,1,outarray[n],1);
481 Vmath::Vadd(nPointsTot,grad2,1,outarray[n],1,outarray[n],1);
482 Vmath::Vadd(nPointsTot,grad_base_v0,1,outarray[n],1,outarray[n],1);
483 Vmath::Vadd(nPointsTot,grad_base_v1,1,outarray[n],1,outarray[n],1);
484 Vmath::Vadd(nPointsTot,grad_base_v2,1,outarray[n],1,outarray[n],1);
493 Vmath::Vvtvp(nPointsTot,grad_base_v0,1,advVel[0],1,outarray[n],1,outarray[n],1);
495 Vmath::Vvtvp(nPointsTot,grad_base_v1,1,advVel[1],1,outarray[n],1,outarray[n],1);
499 Vmath::Vvtvp(nPointsTot,grad_base_v2,1,advVel[2],1,outarray[n],1,outarray[n],1);
514 fields[0]->DealiasedProd(advVel[0],grad_base_w0,grad_base_w0,
m_CoeffState);
516 fields[0]->DealiasedProd(advVel[1],grad_base_w1,grad_base_w1,
m_CoeffState);
518 fields[0]->DealiasedProd(advVel[2],grad_base_w2,grad_base_w2,
m_CoeffState);
520 Vmath::Vadd(nPointsTot,grad0,1,grad1,1,outarray[n],1);
521 Vmath::Vadd(nPointsTot,grad2,1,outarray[n],1,outarray[n],1);
522 Vmath::Vadd(nPointsTot,grad_base_w0,1,outarray[n],1,outarray[n],1);
523 Vmath::Vadd(nPointsTot,grad_base_w1,1,outarray[n],1,outarray[n],1);
524 Vmath::Vadd(nPointsTot,grad_base_w2,1,outarray[n],1,outarray[n],1);
533 Vmath::Vvtvp(nPointsTot,grad_base_w0,1,advVel[0],1,outarray[n],1,outarray[n],1);
535 Vmath::Vvtvp(nPointsTot,grad_base_w1,1,advVel[1],1,outarray[n],1,outarray[n],1);
539 Vmath::Vvtvp(nPointsTot,grad_base_w2,1,advVel[2],1,outarray[n],1,outarray[n],1);
545 ASSERTL0(
false,
"dimension unknown");
553 const Array<
OneD, Array<OneD, NekDouble> > &inarray)
555 if (
m_session->GetSolverInfo(
"EqType") ==
"UnsteadyNavierStokes")
560 "Number of base flow variables does not match what is "
566 "Number of base flow variables does not match what is expected.");
569 int npts = inarray[0].num_elements();
571 for (
int i = 0; i < inarray.num_elements(); ++i)
574 "Size of base flow array does not match expected.");
587 Array<OneD, MultiRegions::ExpListSharedPtr>& pFields,
int slice)
589 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
590 std::vector<std::vector<NekDouble> > FieldData;
593 int nvar =
m_session->GetVariables().size();
595 Array<OneD, NekDouble> tmp_coeff(pFields[0]->GetNcoeffs(), 0.0);
601 fld->Import(pInfile, FieldDef, FieldData);
604 if(
m_session->DefinesSolverInfo(
"HOMOGENEOUS"))
606 std::string HomoStr =
m_session->GetSolverInfo(
"HOMOGENEOUS");
610 for(
int j = 0; j < nvar; ++j)
612 for(
int i = 0; i < FieldDef.size(); ++i)
614 if((
m_session->DefinesSolverInfo(
"HOMOGENEOUS") &&
615 (
m_session->GetSolverInfo(
"HOMOGENEOUS")==
"HOMOGENEOUS1D" ||
616 m_session->GetSolverInfo(
"HOMOGENEOUS")==
"1D" ||
617 m_session->GetSolverInfo(
"HOMOGENEOUS")==
"Homo1D")) &&
624 s = (j == nvar - 1) ? 2 : j;
627 pFields[j]->ExtractDataToCoeffs(
630 FieldDef[i]->m_fields[s],
636 int ncplane = (pFields[0]->GetNcoeffs()) /
m_npointsZ;
641 &tmp_coeff[2*ncplane], 1);
647 bool flag = FieldDef[i]->m_fields[j] ==
650 ASSERTL0(flag, (std::string(
"Order of ") + pInfile
651 + std::string(
" data and that defined in "
652 "m_boundaryconditions differs")).c_str());
654 pFields[j]->ExtractDataToCoeffs(FieldDef[i], FieldData[i],
655 FieldDef[i]->m_fields[j],
664 pFields[j]->GetPlane(0)->BwdTrans(tmp_coeff,
m_baseflow[j]);
669 int ncplane=(pFields[0]->GetNpoints())/
m_npointsZ;
675 pFields[j]->BwdTrans(tmp_coeff,
m_baseflow[j]);
680 if(
m_session->DefinesParameter(
"N_slices"))
682 int nConvectiveFields = pFields.num_elements()-1;
684 for(
int i=0; i<nConvectiveFields;++i)
695 const Array<OneD, const NekDouble> &inarray,
696 Array<OneD, NekDouble> &outarray,
704 Array<OneD, NekDouble> auxiliary(npoints);
707 Vmath::Svtvp(npoints, cos(0.5*m_slices*BetaT),&inarray[npoints],1,&outarray[0],1,&outarray[0],1);
709 for (
int i = 2; i <
m_slices; i += 2)
711 phase = (i>>1) * BetaT;
713 Vmath::Svtvp(npoints, cos(phase),&inarray[i*npoints],1,&outarray[0],1,&outarray[0],1);
714 Vmath::Svtvp(npoints, sin(phase), &inarray[(i+1)*npoints], 1, &outarray[0], 1,&outarray[0],1);
727 Array<OneD,unsigned int> nrows(n_exp);
728 Array<OneD,unsigned int> ncols(n_exp);
730 nrows = Array<OneD, unsigned int>(n_exp,
m_slices);
731 ncols = Array<OneD, unsigned int>(n_exp,
m_slices);
749 for(
int i = 0; i < n_exp; ++i)
751 BlkMatrix->SetBlock(i,i,loc_mat);
759 Array<OneD, MultiRegions::ExpListSharedPtr>& pFields,
765 int ConvectedFields=
m_baseflow.num_elements()-1;
767 m_interp= Array<OneD, Array<OneD, NekDouble> > (ConvectedFields);
768 for(
int i=0; i<ConvectedFields;++i)
777 char chkout[16] =
"";
778 sprintf(chkout,
"%d", i);
784 for(
int k=0; k< ConvectedFields;++k)
786 #ifdef NEKTAR_USING_FFTW
789 Array<OneD, NekDouble> fft_in(npoints*m_slices);
790 Array<OneD, NekDouble> fft_out(npoints*m_slices);
792 Array<OneD, NekDouble>
m_tmpIN(m_slices);
793 Array<OneD, NekDouble>
m_tmpOUT(m_slices);
804 for(
int i=0; i<npoints; i++)
806 m_FFT->FFTFwdTrans(m_tmpIN =fft_in + i*m_slices, m_tmpOUT =fft_out + i*m_slices);
824 int nrows = blkmat->GetRows();
825 int ncols = blkmat->GetColumns();
827 Array<OneD, NekDouble> sortedinarray(ncols);
828 Array<OneD, NekDouble> sortedoutarray(nrows);
849 for(
int r=0; r<sortedinarray.num_elements();++r)
859 for (
int i = 2; i <
m_slices; i += 2)