74 Advection::v_InitObject(pSession, pFields);
79 m_spacedim = pFields[0]->GetGraph()->GetSpaceDimension();
80 m_expdim = pFields[0]->GetGraph()->GetMeshDimension();
90 if(
m_session->DefinesSolverInfo(
"HOMOGENEOUS"))
92 std::string HomoStr =
m_session->GetSolverInfo(
"HOMOGENEOUS");
95 if((HomoStr ==
"HOMOGENEOUS1D")||(HomoStr ==
"Homogeneous1D")||
96 (HomoStr ==
"1D")||(HomoStr ==
"Homo1D"))
103 "Need to specify ModeType as HalfMode,SingleMode or "
106 m_session->MatchSolverInfo(
"ModeType",
"SingleMode",
108 m_session->MatchSolverInfo(
"ModeType",
"HalfMode",
110 m_session->MatchSolverInfo(
"ModeType",
"MultipleModes",
127 if((HomoStr ==
"HOMOGENEOUS2D")||(HomoStr ==
"Homogeneous2D")||
128 (HomoStr ==
"2D")||(HomoStr ==
"Homo2D"))
138 if((HomoStr ==
"HOMOGENEOUS3D")||(HomoStr ==
"Homogeneous3D")||
139 (HomoStr ==
"3D")||(HomoStr ==
"Homo3D"))
151 if(
m_session->DefinesSolverInfo(
"USEFFT"))
161 int nvar =
m_session->GetVariables().size();
163 for (
int i = 0; i < nvar; ++i)
169 "Base flow must be defined for linearised forms.");
170 string file =
m_session->GetFunctionFilename(
"BaseFlow", 0);
174 if(
m_session->DefinesParameter(
"N_slices"))
183 ASSERTL0(
false,
"Number of slices must be a positive number "
202 int nq = pFields[0]->GetNpoints();
209 pFields[0]->GetCoords(x0,x1,x2);
211 for(
unsigned int i = 0 ; i < pFields.num_elements(); i++)
221 if(
m_session->DefinesParameter(
"period"))
240 const int nConvectiveFields,
247 ASSERTL1(nConvectiveFields == inarray.num_elements(),
248 "Number of convective fields and Inarray are not compatible");
250 int nPointsTot = fields[0]->GetNpoints();
251 int ndim = advVel.num_elements();
278 "Base flow should be a sequence of files.");
280 for (
int i = 0; i < ndim; ++i)
292 ASSERTL0(
false,
"Not set up for 1D");
301 fields[0]-> PhysDeriv(
m_baseflow[0], grad_base_u0, grad_base_u1);
302 fields[0]-> PhysDeriv(
m_baseflow[1], grad_base_v0, grad_base_v1);
305 fields[0]->PhysDeriv(inarray[0],grad0,grad1);
312 Vmath::Vvtvp(nPointsTot,grad_base_u0,1,advVel[0],1,outarray[0],1,
315 Vmath::Vvtvp(nPointsTot,grad_base_u1,1,advVel[1],1,outarray[0],1,
320 fields[0]->PhysDeriv(inarray[1],grad0,grad1);
327 Vmath::Vvtvp(nPointsTot,grad_base_v0,1,advVel[0],1,outarray[1],1,
330 Vmath::Vvtvp(nPointsTot,grad_base_v1,1,advVel[1],1,outarray[1],1,
353 grad_base_u0, grad_base_u1);
355 grad_base_v0, grad_base_v1);
362 bool oldwavespace = fields[0]->GetWaveSpace();
363 fields[0]->SetWaveSpace(
false);
364 fields[0]->PhysDeriv(
m_baseflow[0], grad_base_u0,
365 grad_base_u1, grad_base_u2);
366 fields[0]->PhysDeriv(
m_baseflow[1], grad_base_v0,
367 grad_base_v1, grad_base_v2);
368 fields[0]->PhysDeriv(
m_baseflow[2], grad_base_w0,
369 grad_base_w1, grad_base_w2);
370 fields[0]->SetWaveSpace(oldwavespace);
376 fields[0]->PhysDeriv(
m_baseflow[0], grad_base_u0,
378 fields[0]->PhysDeriv(
m_baseflow[1], grad_base_v0,
380 fields[0]->PhysDeriv(
m_baseflow[2], grad_base_w0,
391 fields[0]->PhysDeriv(inarray[0], grad0, grad1, grad2);
393 fields[0]->HomogeneousBwdTrans(grad0, grad0);
394 fields[0]->HomogeneousBwdTrans(grad1, grad1);
395 fields[0]->HomogeneousBwdTrans(grad2, grad2);
401 fields[0]->PhysDeriv(inarray[0], grad0, grad1);
405 fields[0]->PhysDeriv(inarray[0], grad0, grad1, grad2);
413 outarray[0], 1, outarray[0], 1);
416 outarray[0],1,outarray[0],1);
419 outarray[0],1,outarray[0],1);
425 1,outarray[0], 1, outarray[0], 1);
432 advVel[2],1,outarray[0],1,outarray[0],1);
433 fields[0]->HomogeneousFwdTrans(outarray[0],outarray[0]);
440 fields[0]->PhysDeriv(inarray[1], grad0, grad1, grad2);
442 fields[0]->HomogeneousBwdTrans(grad0, grad0);
443 fields[0]->HomogeneousBwdTrans(grad1, grad1);
444 fields[0]->HomogeneousBwdTrans(grad2, grad2);
450 fields[0]->PhysDeriv(inarray[1], grad0, grad1);
454 fields[0]->PhysDeriv(inarray[1], grad0, grad1, grad2);
463 outarray[1], 1, outarray[1], 1);
466 ,outarray[1],1,outarray[1],1);
469 outarray[1],1,outarray[1],1);
475 outarray[1], 1, outarray[1], 1);
482 outarray[1],1,outarray[1],1);
483 fields[0]->HomogeneousFwdTrans(outarray[1],outarray[1]);
491 fields[0]->PhysDeriv(inarray[2], grad0, grad1, grad2);
493 fields[0]->HomogeneousBwdTrans(grad0, grad0);
494 fields[0]->HomogeneousBwdTrans(grad1, grad1);
495 fields[0]->HomogeneousBwdTrans(grad2, grad2);
501 fields[0]->PhysDeriv(inarray[2], grad0, grad1);
505 fields[0]->PhysDeriv(inarray[2], grad0, grad1, grad2);
514 outarray[2], 1, outarray[2], 1);
520 outarray[2],1,outarray[2],1);
523 outarray[2],1,outarray[2],1);
527 outarray[2], 1, outarray[2], 1);
534 outarray[2],1,outarray[2],1);
535 fields[0]->HomogeneousFwdTrans(outarray[2],outarray[2]);
545 if (
m_session->GetSolverInfo(
"EqType") ==
"UnsteadyNavierStokes")
550 "Number of base flow variables does not match what is "
556 "Number of base flow variables does not match what is expected.");
559 int npts = inarray[0].num_elements();
561 for (
int i = 0; i < inarray.num_elements(); ++i)
564 "Size of base flow array does not match expected.");
579 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
580 std::vector<std::vector<NekDouble> > FieldData;
583 int nvar =
m_session->GetVariables().size();
587 int numexp = pFields[0]->GetExpSize();
591 for(
int i = 0; i < numexp; ++i)
593 ElementGIDs[i] = pFields[0]->GetExp(i)->GetGeom()->GetGlobalID();
600 fld->Import(pInfile, FieldDef, FieldData,
605 if(
m_session->DefinesSolverInfo(
"HOMOGENEOUS"))
607 std::string HomoStr =
m_session->GetSolverInfo(
"HOMOGENEOUS");
611 for(
int j = 0; j < nvar; ++j)
613 for(
int i = 0; i < FieldDef.size(); ++i)
615 if((
m_session->DefinesSolverInfo(
"HOMOGENEOUS") &&
616 (
m_session->GetSolverInfo(
"HOMOGENEOUS")==
"HOMOGENEOUS1D" ||
617 m_session->GetSolverInfo(
"HOMOGENEOUS")==
"1D" ||
618 m_session->GetSolverInfo(
"HOMOGENEOUS")==
"Homo1D")) &&
627 s = (j == nvar - 1) ? 2 : j;
630 pFields[j]->ExtractDataToCoeffs(
633 FieldDef[i]->m_fields[s],
645 int ncplane = (pFields[0]->GetNcoeffs()) /
m_npointsZ;
647 &tmp_coeff[2*ncplane], 1);
653 bool flag = FieldDef[i]->m_fields[j] ==
656 ASSERTL0(flag, (std::string(
"Order of ") + pInfile
657 + std::string(
" data and that defined in "
658 "m_boundaryconditions differs")).c_str());
660 pFields[j]->ExtractDataToCoeffs(FieldDef[i], FieldData[i],
661 FieldDef[i]->m_fields[j],
670 pFields[j]->GetPlane(0)->BwdTrans(tmp_coeff,
m_baseflow[j]);
676 int ncplane=(pFields[0]->GetNpoints())/
m_npointsZ;
682 bool oldwavespace = pFields[j]->GetWaveSpace();
683 pFields[j]->SetWaveSpace(
false);
684 pFields[j]->BwdTrans(tmp_coeff,
m_baseflow[j]);
685 pFields[j]->SetWaveSpace(oldwavespace);
689 if(
m_session->DefinesParameter(
"N_slices"))
691 int nConvectiveFields = pFields.num_elements()-1;
693 for(
int i=0; i<nConvectiveFields;++i)
716 Vmath::Svtvp(npoints, cos(0.5*m_slices*BetaT),&inarray[npoints],1,&outarray[0],1,&outarray[0],1);
718 for (
int i = 2; i <
m_slices; i += 2)
720 phase = (i>>1) * BetaT;
722 Vmath::Svtvp(npoints, cos(phase),&inarray[i*npoints],1,&outarray[0],1,&outarray[0],1);
723 Vmath::Svtvp(npoints, -sin(phase), &inarray[(i+1)*npoints], 1, &outarray[0], 1,&outarray[0],1);
758 for(
int i = 0; i < n_exp; ++i)
760 BlkMatrix->SetBlock(i,i,loc_mat);
771 int ConvectedFields =
m_baseflow.num_elements()-1;
775 for (
int i = 0; i < ConvectedFields; ++i)
783 size_t found = file.find(
"%d");
784 ASSERTL0(found != string::npos && file.find(
"%d", found+1) == string::npos,
785 "Since N_slices is specified, the filename provided for function "
786 "'BaseFlow' must include exactly one instance of the format "
787 "specifier '%d', to index the time-slices.");
788 char*
buffer =
new char[file.length() + 8];
791 sprintf(buffer, file.c_str(), i);
798 for(
int k=0; k< ConvectedFields;++k)
800 #ifdef NEKTAR_USING_FFTW
818 for(
int i=0; i<npoints; i++)
820 m_FFT->FFTFwdTrans(m_tmpIN =fft_in + i*m_slices, m_tmpOUT =fft_out + i*m_slices);
838 int nrows = blkmat->GetRows();
839 int ncols = blkmat->GetColumns();
863 for(
int r=0; r<sortedinarray.num_elements();++r)
873 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.
bool m_singleMode
flag to determine if use single mode or not
Array< OneD, Array< OneD, NekDouble > > m_baseflow
Storage for base flow.
LibUtilities::NektarFFTSharedPtr m_FFT
auxiliary variables
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
int m_slices
number of slices
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
interpolation vector
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.
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
NekDouble m_period
period length
DNekBlkMatSharedPtr GetFloquetBlockMatrix(FloquetMatType mattype, bool UseContCoeffs=false) const
int m_npointsY
number of points in Y direction (if homogeneous)
boost::shared_ptr< Equation > EquationSharedPtr
bool m_multipleModes
flag to determine if use multiple 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)
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.
bool m_halfMode
flag to determine if use half mode or not
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)
static FieldMetaDataMap NullFieldMetaDataMap
bool m_useFFT
flag to determine if use or not the FFT for transformations
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.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.