71 Advection::v_InitObject(pSession, 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();
198 for (
int i = 0; i < nvar; ++i)
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();
243 pFields[0]->GetCoords(x0,x1,x2);
244 for(
unsigned int i = 0 ; i <
m_baseflow.num_elements(); i++)
264 const int nConvectiveFields,
271 int nqtot = fields[0]->GetTotPoints();
272 ASSERTL1(nConvectiveFields == inarray.num_elements(),
"Number of convective fields and Inarray are not compatible");
276 for(
int n = 0; n < nConvectiveFields; ++n)
279 int ndim = advVel.num_elements();
280 int nPointsTot = fields[0]->GetNpoints();
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);
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);
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");
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.");
500 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
501 std::vector<std::vector<NekDouble> > FieldData;
503 int nqtot = pFields[0]->GetTotPoints();
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)
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);
657 for(
int i = 0; i < n_exp; ++i)
659 BlkMatrix->SetBlock(i,i,loc_mat);
673 int ConvectedFields=
m_baseflow.num_elements()-1;
676 for(
int i=0; i<ConvectedFields;++i)
684 size_t found = file.find(
"%d");
685 ASSERTL0(found != string::npos && file.find(
"%d", found+1) == string::npos,
686 "Since N_slices is specified, the filename provided for function "
687 "'BaseFlow' must include exactly one instance of the format "
688 "specifier '%d', to index the time-slices.");
689 char*
buffer =
new char[file.length() + 8];
692 sprintf(buffer, file.c_str(), i);
699 for(
int k=0; k< ConvectedFields;++k)
701 #ifdef NEKTAR_USING_FFTW
721 for(
int i=0; i<npoints; i++)
723 m_FFT->FFTFwdTrans(m_tmpIN =fft_in + i*m_slices, m_tmpOUT =fft_out + i*m_slices);
743 int nrows = blkmat->GetRows();
744 int ncols = blkmat->GetColumns();
768 Vmath::Zero(sortedinarray.num_elements(),&sortedinarray[0],1);
769 Vmath::Zero(sortedoutarray.num_elements(),&sortedoutarray[0],1);
775 for (
int i = 2; i <
m_slices; i += 2)
784 if(
m_session->DefinesParameter(
"period"))
Array< OneD, NekDouble > m_tmpOUT
SpatialDomains::BoundaryConditionsSharedPtr m_boundaryConditions
LibUtilities::ShapeType DetShapeType() const
This function returns the shape of the expansion domain.
#define ASSERTL0(condition, msg)
static SolverUtils::AdvectionSharedPtr create(std::string)
Creates an instance of this class.
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.
void ImportFldBase(std::string pInfile, Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, int slice)
Import Base flow.
LibUtilities::SessionReaderSharedPtr m_session
int m_npointsX
number of points in X direction (if homogeneous)
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
bool m_homogen_dealiasing
NekDouble m_LhomY
physical length in Y direction (if homogeneous)
LibUtilities::NektarFFTSharedPtr m_FFT
boost::shared_ptr< DNekMat > DNekMatSharedPtr
NektarFFTFactory & GetNektarFFTFactory()
Array< OneD, Array< OneD, NekDouble > > m_baseflow
Storage for base flow.
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
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.
DNekMatSharedPtr GetStdMatrix(const StdMatrixKey &mkey)
virtual void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Initialises the advection object.
Class representing a segment element in reference space.
Array< OneD, Array< OneD, NekDouble > > m_interp
DNekBlkMatSharedPtr GetFloquetBlockMatrix(FloquetMatType mattype, bool UseContCoeffs=false) const
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 ~AdjointAdvection()
int m_npointsY
number of points in Y direction (if homogeneous)
bool m_HalfMode
flag to determine if use half mode or not
AdvectionFactory & GetAdvectionFactory()
Gets the factory for initialising advection objects.
int m_HomoDirec
number of homogenous directions
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
static std::string className
Name of class.
boost::shared_ptr< Equation > EquationSharedPtr
NekDouble m_LhomX
physical length in X direction (if homogeneous)
void UpdateBase(const NekDouble m_slices, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const NekDouble m_time, const NekDouble m_period)
MultiRegions::CoeffState m_CoeffState
boost::shared_ptr< DNekBlkMat > DNekBlkMatSharedPtr
enum HomogeneousType m_HomogeneousType
void DFT(const string file, Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const NekDouble m_slices)
NekDouble m_LhomZ
physical length in Z direction (if homogeneous)
virtual void v_SetBaseFlow(const Array< OneD, Array< OneD, NekDouble > > &inarray)
Overrides the base flow used during linearised advection.
bool m_SingleMode
flag to determine if use single mode or not
int m_npointsZ
number of points in Z direction (if homogeneous)
Array< OneD, NekDouble > m_tmpIN
MultiRegions::ProjectionType m_projectionType
void Zero(int n, T *x, const int incx)
Zero vector.
bool m_useFFT
flag to determine if use or not the FFT for transformations
#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)
Describes the specification for a Basis.
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.
bool m_MultipleModes
flag to determine if use multiple mode or not
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.