74 Advection::v_InitObject(pSession, 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();
206 for (
int i = 0; i < nvar; ++i)
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();
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,
289 int nqtot = fields[0]->GetTotPoints();
290 ASSERTL1(nConvectiveFields == inarray.num_elements(),
"Number of convective fields and Inarray are not compatible");
294 for(
int n = 0; n < nConvectiveFields; ++n)
296 int ndim = advVel.num_elements();
297 int nPointsTot = fields[0]->GetNpoints();
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);
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);
404 bool oldwavespace = fields[0]->GetWaveSpace();
405 fields[0]->SetWaveSpace(
false);
407 grad_base_u0, grad_base_u1, grad_base_u2);
409 grad_base_v0, grad_base_v1, grad_base_v2);
411 grad_base_w0, grad_base_w1, grad_base_w2);
412 fields[0]->SetWaveSpace(oldwavespace);
417 for(
int i=0; i<grad_base_u2.num_elements();++i)
425 fields[0]->PhysDeriv(inarray[n], grad0, grad1, grad2);
428 fields[0]->HomogeneousBwdTrans(grad0, grad0);
429 fields[0]->HomogeneousBwdTrans(grad1, grad1);
430 fields[0]->HomogeneousBwdTrans(grad2, grad2);
449 fields[0]->DealiasedProd(advVel[0],grad_base_u0,grad_base_u0,
m_CoeffState);
451 fields[0]->DealiasedProd(advVel[1],grad_base_u1,grad_base_u1,
m_CoeffState);
453 fields[0]->DealiasedProd(advVel[2],grad_base_u2,grad_base_u2,
m_CoeffState);
455 Vmath::Vadd(nPointsTot,grad0,1,grad1,1,outarray[n],1);
456 Vmath::Vadd(nPointsTot,grad2,1,outarray[n],1,outarray[n],1);
457 Vmath::Vadd(nPointsTot,grad_base_u0,1,outarray[n],1,outarray[n],1);
458 Vmath::Vadd(nPointsTot,grad_base_u1,1,outarray[n],1,outarray[n],1);
459 Vmath::Vadd(nPointsTot,grad_base_u2,1,outarray[n],1,outarray[n],1);
468 outarray[n], 1, outarray[n], 1);
470 Vmath::Vvtvp(nPointsTot,grad_base_u0,1,advVel[0],1,outarray[n],1,outarray[n],1);
472 Vmath::Vvtvp(nPointsTot,grad_base_u1,1,advVel[1],1,outarray[n],1,outarray[n],1);
475 outarray[n], 1, outarray[n], 1);
477 Vmath::Vvtvp(nPointsTot,grad_base_u2,1,advVel[2],1,outarray[n],1,outarray[n],1);
491 fields[0]->DealiasedProd(advVel[0],grad_base_v0,grad_base_v0,
m_CoeffState);
493 fields[0]->DealiasedProd(advVel[1],grad_base_v1,grad_base_v1,
m_CoeffState);
495 fields[0]->DealiasedProd(advVel[2],grad_base_v2,grad_base_v2,
m_CoeffState);
497 Vmath::Vadd(nPointsTot,grad0,1,grad1,1,outarray[n],1);
498 Vmath::Vadd(nPointsTot,grad2,1,outarray[n],1,outarray[n],1);
499 Vmath::Vadd(nPointsTot,grad_base_v0,1,outarray[n],1,outarray[n],1);
500 Vmath::Vadd(nPointsTot,grad_base_v1,1,outarray[n],1,outarray[n],1);
501 Vmath::Vadd(nPointsTot,grad_base_v2,1,outarray[n],1,outarray[n],1);
510 outarray[n], 1, outarray[n], 1);
512 Vmath::Vvtvp(nPointsTot,grad_base_v0,1,advVel[0],1,outarray[n],1,outarray[n],1);
514 Vmath::Vvtvp(nPointsTot,grad_base_v1,1,advVel[1],1,outarray[n],1,outarray[n],1);
517 outarray[n], 1, outarray[n], 1);
519 Vmath::Vvtvp(nPointsTot,grad_base_v2,1,advVel[2],1,outarray[n],1,outarray[n],1);
534 fields[0]->DealiasedProd(advVel[0],grad_base_w0,grad_base_w0,
m_CoeffState);
536 fields[0]->DealiasedProd(advVel[1],grad_base_w1,grad_base_w1,
m_CoeffState);
538 fields[0]->DealiasedProd(advVel[2],grad_base_w2,grad_base_w2,
m_CoeffState);
540 Vmath::Vadd(nPointsTot,grad0,1,grad1,1,outarray[n],1);
541 Vmath::Vadd(nPointsTot,grad2,1,outarray[n],1,outarray[n],1);
542 Vmath::Vadd(nPointsTot,grad_base_w0,1,outarray[n],1,outarray[n],1);
543 Vmath::Vadd(nPointsTot,grad_base_w1,1,outarray[n],1,outarray[n],1);
544 Vmath::Vadd(nPointsTot,grad_base_w2,1,outarray[n],1,outarray[n],1);
553 outarray[n], 1, outarray[n], 1);
555 Vmath::Vvtvp(nPointsTot,grad_base_w0,1,advVel[0],1,outarray[n],1,outarray[n],1);
557 Vmath::Vvtvp(nPointsTot,grad_base_w1,1,advVel[1],1,outarray[n],1,outarray[n],1);
560 outarray[n], 1, outarray[n], 1);
562 Vmath::Vvtvp(nPointsTot,grad_base_w2,1,advVel[2],1,outarray[n],1,outarray[n],1);
569 fields[0]->HomogeneousFwdTrans(outarray[n],outarray[n]);
574 ASSERTL0(
false,
"dimension unknown");
584 if (
m_session->GetSolverInfo(
"EqType") ==
"UnsteadyNavierStokes")
589 "Number of base flow variables does not match what is "
595 "Number of base flow variables does not match what is expected.");
598 int npts = inarray[0].num_elements();
600 for (
int i = 0; i < inarray.num_elements(); ++i)
603 "Size of base flow array does not match expected.");
618 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
619 std::vector<std::vector<NekDouble> > FieldData;
622 int nvar =
m_session->GetVariables().size();
630 fld->Import(pInfile, FieldDef, FieldData);
633 if(
m_session->DefinesSolverInfo(
"HOMOGENEOUS"))
635 std::string HomoStr =
m_session->GetSolverInfo(
"HOMOGENEOUS");
639 for(
int j = 0; j < nvar; ++j)
641 for(
int i = 0; i < FieldDef.size(); ++i)
643 if((
m_session->DefinesSolverInfo(
"HOMOGENEOUS") &&
644 (
m_session->GetSolverInfo(
"HOMOGENEOUS")==
"HOMOGENEOUS1D" ||
645 m_session->GetSolverInfo(
"HOMOGENEOUS")==
"1D" ||
646 m_session->GetSolverInfo(
"HOMOGENEOUS")==
"Homo1D")) &&
653 s = (j == nvar - 1) ? 2 : j;
656 pFields[j]->ExtractDataToCoeffs(
659 FieldDef[i]->m_fields[s],
665 int ncplane = (pFields[0]->GetNcoeffs()) /
m_npointsZ;
670 &tmp_coeff[2*ncplane], 1);
676 bool flag = FieldDef[i]->m_fields[j] ==
679 ASSERTL0(flag, (std::string(
"Order of ") + pInfile
680 + std::string(
" data and that defined in "
681 "m_boundaryconditions differs")).c_str());
683 pFields[j]->ExtractDataToCoeffs(FieldDef[i], FieldData[i],
684 FieldDef[i]->m_fields[j],
693 pFields[j]->GetPlane(0)->BwdTrans(tmp_coeff,
m_baseflow[j]);
698 int ncplane=(pFields[0]->GetNpoints())/
m_npointsZ;
704 bool oldwavespace = pFields[j]->GetWaveSpace();
705 pFields[j]->SetWaveSpace(
false);
706 pFields[j]->BwdTrans(tmp_coeff,
m_baseflow[j]);
707 pFields[j]->SetWaveSpace(oldwavespace);
711 if(
m_session->DefinesParameter(
"N_slices"))
713 int nConvectiveFields = pFields.num_elements()-1;
715 for(
int i=0; i<nConvectiveFields;++i)
738 Vmath::Svtvp(npoints, cos(0.5*m_slices*BetaT),&inarray[npoints],1,&outarray[0],1,&outarray[0],1);
740 for (
int i = 2; i <
m_slices; i += 2)
742 phase = (i>>1) * BetaT;
744 Vmath::Svtvp(npoints, cos(phase),&inarray[i*npoints],1,&outarray[0],1,&outarray[0],1);
745 Vmath::Svtvp(npoints, sin(phase), &inarray[(i+1)*npoints], 1, &outarray[0], 1,&outarray[0],1);
780 for(
int i = 0; i < n_exp; ++i)
782 BlkMatrix->SetBlock(i,i,loc_mat);
796 int ConvectedFields=
m_baseflow.num_elements()-1;
799 for(
int i=0; i<ConvectedFields;++i)
807 size_t found = file.find(
"%d");
808 ASSERTL0(found != string::npos && file.find(
"%d", found+1) == string::npos,
809 "Since N_slices is specified, the filename provided for function "
810 "'BaseFlow' must include exactly one instance of the format "
811 "specifier '%d', to index the time-slices.");
812 char*
buffer =
new char[file.length() + 8];
815 sprintf(buffer, file.c_str(), i);
822 for(
int k=0; k< ConvectedFields;++k)
824 #ifdef NEKTAR_USING_FFTW
842 for(
int i=0; i<npoints; i++)
844 m_FFT->FFTFwdTrans(m_tmpIN =fft_in + i*m_slices, m_tmpOUT =fft_out + i*m_slices);
862 int nrows = blkmat->GetRows();
863 int ncols = blkmat->GetColumns();
887 for(
int r=0; r<sortedinarray.num_elements();++r)
897 for (
int i = 2; i <
m_slices; i += 2)
enum HomogeneousType m_HomogeneousType
void DFT(const string file, Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const NekDouble m_slices)
virtual ~LinearisedAdvection()
LibUtilities::ShapeType DetShapeType() const
This function returns the shape of the expansion domain.
#define ASSERTL0(condition, msg)
Array< OneD, NekDouble > m_tmpIN
int m_HomoDirec
number of homogenous directions
tBaseSharedPtr CreateInstance(tKey idKey BOOST_PP_COMMA_IF(MAX_PARAM) BOOST_PP_ENUM_BINARY_PARAMS(MAX_PARAM, tParam, x))
Create an instance of the class referred to by idKey.
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
Array< OneD, Array< OneD, NekDouble > > m_baseflow
Storage for base flow.
MultiRegions::ProjectionType m_projectionType
LibUtilities::NektarFFTSharedPtr m_FFT
bool m_homogen_dealiasing
void ImportFldBase(std::string pInfile, Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, int slice)
Import Base flow.
void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
svtvp (scalar times vector plus vector): z = alpha*x + y
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Array< OneD, NekDouble > m_tmpOUT
boost::shared_ptr< DNekMat > DNekMatSharedPtr
NektarFFTFactory & GetNektarFFTFactory()
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
virtual void v_SetBaseFlow(const Array< OneD, Array< OneD, NekDouble > > &inarray)
Overrides the base flow used during linearised advection.
DNekMatSharedPtr GetStdMatrix(const StdMatrixKey &mkey)
Array< OneD, Array< OneD, NekDouble > > m_interp
Class representing a segment element in reference space.
void UpdateBase(const NekDouble m_slices, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const NekDouble m_time, const NekDouble m_period)
1D Evenly-spaced points using Fourier Fit
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
virtual void v_Advect(const int nConvectiveFields, const Array< OneD, MultiRegions::ExpListSharedPtr > &fields, const Array< OneD, Array< OneD, NekDouble > > &advVel, const Array< OneD, Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, const NekDouble &time)
Advects a vector field.
bool m_HalfMode
flag to determine if use half mode or not
int m_npointsZ
number of points in Z direction (if homogeneous)
AdvectionFactory & GetAdvectionFactory()
Gets the factory for initialising advection objects.
Defines a specification for a set of points.
void Neg(int n, T *x, const int incx)
Negate x = -x.
boost::shared_ptr< FieldIO > FieldIOSharedPtr
DNekBlkMatSharedPtr GetFloquetBlockMatrix(FloquetMatType mattype, bool UseContCoeffs=false) const
MultiRegions::CoeffState m_CoeffState
int m_npointsY
number of points in Y direction (if homogeneous)
boost::shared_ptr< Equation > EquationSharedPtr
bool m_SingleMode
flag to determine if use single mode or not
static SolverUtils::AdvectionSharedPtr create(std::string)
Creates an instance of this class.
SpatialDomains::BoundaryConditionsSharedPtr m_boundaryConditions
NekDouble m_LhomY
physical length in Y direction (if homogeneous)
bool m_MultipleModes
flag to determine if use multiple mode or not
LibUtilities::SessionReaderSharedPtr m_session
boost::shared_ptr< DNekBlkMat > DNekBlkMatSharedPtr
int m_npointsX
number of points in X direction (if homogeneous)
NekDouble m_LhomX
physical length in X direction (if homogeneous)
static std::string className
Name of class.
virtual void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Initialises the advection object.
void Zero(int n, T *x, const int incx)
Zero vector.
NekDouble m_LhomZ
physical length in Z direction (if homogeneous)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
bool m_useFFT
flag to determine if use or not the FFT for transformations
Describes the specification for a Basis.
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 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.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.