43 string LinearisedAdvection::className
46 LinearisedAdvection::create);
55 LinearisedAdvection::LinearisedAdvection():
70 m_spacedim = pFields[0]->GetGraph()->GetSpaceDimension();
71 m_expdim = pFields[0]->GetGraph()->GetMeshDimension();
81 if(
m_session->DefinesSolverInfo(
"HOMOGENEOUS"))
83 std::string HomoStr =
m_session->GetSolverInfo(
"HOMOGENEOUS");
86 if((HomoStr ==
"HOMOGENEOUS1D")||(HomoStr ==
"Homogeneous1D")||
87 (HomoStr ==
"1D")||(HomoStr ==
"Homo1D"))
94 "Need to specify ModeType as HalfMode,SingleMode or "
97 m_session->MatchSolverInfo(
"ModeType",
"SingleMode",
99 m_session->MatchSolverInfo(
"ModeType",
"HalfMode",
101 m_session->MatchSolverInfo(
"ModeType",
"MultipleModes",
118 if((HomoStr ==
"HOMOGENEOUS2D")||(HomoStr ==
"Homogeneous2D")||
119 (HomoStr ==
"2D")||(HomoStr ==
"Homo2D"))
129 if((HomoStr ==
"HOMOGENEOUS3D")||(HomoStr ==
"Homogeneous3D")||
130 (HomoStr ==
"3D")||(HomoStr ==
"Homo3D"))
142 if(
m_session->DefinesSolverInfo(
"USEFFT"))
152 int nvar =
m_session->GetVariables().size();
154 for (
int i = 0; i < nvar; ++i)
161 for (
int i = 0; i < nvar; ++i)
163 for (
int j = 0; j < nBaseDerivs; ++j)
166 (pFields[i]->GetTotPoints(), 0.0);
171 "Base flow must be defined for linearised forms.");
172 string file =
m_session->GetFunctionFilename(
"BaseFlow", 0);
176 if(
m_session->DefinesParameter(
"N_slices"))
183 "Base flow should be a sequence of files.");
188 ASSERTL0(
false,
"Number of slices must be a positive number "
207 int nq = pFields[0]->GetNpoints();
214 pFields[0]->GetCoords(x0,x1,x2);
216 for(
unsigned int i = 0 ; i < pFields.num_elements(); i++)
226 for (
int i = 0; i < nvar; ++i)
231 if(
m_session->DefinesParameter(
"period"))
250 const int nConvectiveFields,
259 ASSERTL1(nConvectiveFields == inarray.num_elements(),
260 "Number of convective fields and Inarray are not compatible");
262 int nPointsTot = fields[0]->GetNpoints();
263 int ndim = advVel.num_elements();
268 for(
int i = 0; i < ndim; ++i)
273 fields[i]->HomogeneousBwdTrans(advVel[i],velocity[i]);
277 velocity[i] = advVel[i];
282 for(
int i = 0; i < nDerivs; ++i)
290 for (
int i = 0; i < ndim; ++i)
299 for(
int i = 0; i < ndim; ++i)
306 fields[i]->PhysDeriv(inarray[i], grad[0]);
311 fields[i]->PhysDeriv(inarray[i], grad[0], grad[1]);
316 fields[i]->PhysDeriv(inarray[i], grad[0], grad[1], grad[2]);
320 fields[i]->HomogeneousBwdTrans(grad[0], grad[0]);
321 fields[i]->HomogeneousBwdTrans(grad[1], grad[1]);
322 fields[i]->HomogeneousBwdTrans(grad[2], grad[2]);
330 for(
int j = 1; j < nDerivs; ++j)
344 for(
int j = 0; j < lim; ++j)
354 fields[i]->HomogeneousFwdTrans(outarray[i],outarray[i]);
364 if (
m_session->GetSolverInfo(
"EqType") ==
"UnsteadyNavierStokes")
369 "Number of base flow variables does not match what is "
375 "Number of base flow variables does not match what is expected.");
378 int npts = inarray[0].num_elements();
380 for (
int i = 0; i < inarray.num_elements(); ++i)
383 "Size of base flow array does not match expected.");
402 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
403 std::vector<std::vector<NekDouble> > FieldData;
408 int numexp = pFields[0]->GetExpSize();
412 for(
int i = 0; i < numexp; ++i)
414 ElementGIDs[i] = pFields[0]->GetExp(i)->GetGeom()->GetGlobalID();
420 fld->Import(pInfile, FieldDef, FieldData,
424 int nSessionVar =
m_session->GetVariables().size();
425 int nSessionConvVar = nSessionVar - 1;
426 int nFileVar = FieldDef[0]->m_fields.size();
427 int nFileConvVar = nFileVar - 1;
430 ASSERTL0(nFileVar == 3,
"For half mode, expect 2D2C base flow.");
434 for(
int j = 0; j < nFileConvVar; ++j)
436 for(
int i = 0; i < FieldDef.size(); ++i)
438 bool flag = FieldDef[i]->m_fields[j] ==
441 ASSERTL0(flag, (std::string(
"Order of ") + pInfile
442 + std::string(
" data and that defined in "
443 "the session file differs")).c_str());
445 pFields[j]->ExtractDataToCoeffs(
448 FieldDef[i]->m_fields[j],
454 pFields[j]->GetPlane(0)->BwdTrans(tmp_coeff,
m_baseflow[j]);
460 int ncplane=(pFields[0]->GetNpoints())/
m_npointsZ;
466 bool oldwavespace = pFields[j]->GetWaveSpace();
467 pFields[j]->SetWaveSpace(
false);
468 pFields[j]->BwdTrans(tmp_coeff,
m_baseflow[j]);
469 pFields[j]->SetWaveSpace(oldwavespace);
474 for (
int j = nFileConvVar; j < nSessionConvVar; ++j)
480 if(
m_session->DefinesParameter(
"N_slices"))
482 for(
int i = 0; i < nSessionConvVar; ++i)
503 Vmath::Svtvp(npoints, cos(0.5*m_slices*BetaT),&inarray[npoints],1,&outarray[0],1,&outarray[0],1);
505 for (
int i = 2; i <
m_slices; i += 2)
507 phase = (i>>1) * BetaT;
509 Vmath::Svtvp(npoints, cos(phase),&inarray[i*npoints],1,&outarray[0],1,&outarray[0],1);
510 Vmath::Svtvp(npoints, -sin(phase), &inarray[(i+1)*npoints], 1, &outarray[0], 1,&outarray[0],1);
552 bool oldwavespace = field->GetWaveSpace();
553 field->SetWaveSpace(
false);
557 field->SetWaveSpace(oldwavespace);
594 for(
int i = 0; i < n_exp; ++i)
596 BlkMatrix->SetBlock(i,i,loc_mat);
607 int ConvectedFields =
m_baseflow.num_elements()-1;
611 for (
int i = 0; i < ConvectedFields; ++i)
619 size_t found = file.find(
"%d");
620 ASSERTL0(found != string::npos && file.find(
"%d", found+1) == string::npos,
621 "Since N_slices is specified, the filename provided for function "
622 "'BaseFlow' must include exactly one instance of the format "
623 "specifier '%d', to index the time-slices.");
624 char*
buffer =
new char[file.length() + 8];
627 sprintf(buffer, file.c_str(), i);
634 for(
int k=0; k< ConvectedFields;++k)
636 #ifdef NEKTAR_USING_FFTW
654 for(
int i=0; i<npoints; i++)
656 m_FFT->FFTFwdTrans(m_tmpIN =fft_in + i*m_slices, m_tmpOUT =fft_out + i*m_slices);
674 int nrows = blkmat->GetRows();
675 int ncols = blkmat->GetColumns();
699 for(
int r=0; r<sortedinarray.num_elements();++r)
709 for (
int i = 2; i <
m_slices; i += 2)
enum HomogeneousType m_HomogeneousType
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.
virtual void v_SetBaseFlow(const Array< OneD, Array< OneD, NekDouble > > &inarray, const Array< OneD, MultiRegions::ExpListSharedPtr > &fields)
Overrides the base flow used during linearised advection.
LibUtilities::NektarFFTSharedPtr m_FFT
auxiliary variables
void Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
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
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 DFT(const std::string file, Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const NekDouble m_slices)
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*y.
int m_npointsZ
number of points in Z direction (if homogeneous)
boost::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
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)
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, const Array< OneD, Array< OneD, NekDouble > > &pFwd=NullNekDoubleArrayofArray, const Array< OneD, Array< OneD, NekDouble > > &pBwd=NullNekDoubleArrayofArray)
Advects a vector field.
boost::shared_ptr< Equation > EquationSharedPtr
bool m_multipleModes
flag to determine if use multiple mode or not
SpatialDomains::BoundaryConditionsSharedPtr m_boundaryConditions
NekDouble m_LhomY
physical length in Y direction (if homogeneous)
LibUtilities::SessionReaderSharedPtr m_session
boost::shared_ptr< DNekBlkMat > DNekBlkMatSharedPtr
static boost::shared_ptr< FieldIO > CreateForFile(const LibUtilities::SessionReaderSharedPtr session, const std::string &filename)
Construct a FieldIO object for a given input filename.
int m_npointsX
number of points in X direction (if homogeneous)
NekDouble m_LhomX
physical length in X direction (if homogeneous)
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 UpdateGradBase(const int var, const MultiRegions::ExpListSharedPtr &field)
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.
Array< OneD, Array< OneD, NekDouble > > m_gradBase
virtual SOLVER_UTILS_EXPORT void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Initialises the advection object.
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.
Defines a callback function which evaluates the flux vector.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.