37#include <boost/format.hpp>
46 "Linearised Non-Conservative");
69 m_spacedim = pFields[0]->GetGraph()->GetSpaceDimension();
70 m_expdim = pFields[0]->GetGraph()->GetMeshDimension();
80 if (
m_session->DefinesSolverInfo(
"HOMOGENEOUS"))
82 std::string HomoStr =
m_session->GetSolverInfo(
"HOMOGENEOUS");
85 if ((HomoStr ==
"HOMOGENEOUS1D") || (HomoStr ==
"Homogeneous1D") ||
86 (HomoStr ==
"1D") || (HomoStr ==
"Homo1D"))
93 "Need to specify ModeType as HalfMode,SingleMode or "
100 m_session->MatchSolverInfo(
"ModeType",
"MultipleModes",
117 if ((HomoStr ==
"HOMOGENEOUS2D") || (HomoStr ==
"Homogeneous2D") ||
118 (HomoStr ==
"2D") || (HomoStr ==
"Homo2D"))
128 if ((HomoStr ==
"HOMOGENEOUS3D") || (HomoStr ==
"Homogeneous3D") ||
129 (HomoStr ==
"3D") || (HomoStr ==
"Homo3D"))
141 if (
m_session->DefinesSolverInfo(
"USEFFT"))
152 size_t nvar =
m_session->GetVariables().size();
154 for (
size_t i = 0; i < nvar; ++i)
161 for (
size_t i = 0; i < nvar; ++i)
163 for (
size_t j = 0; j < nBaseDerivs; ++j)
171 "Base flow must be defined for linearised forms.");
172 string file =
m_session->GetFunctionFilename(
"BaseFlow", 0);
175 if (
m_session->DefinesParameter(
"N_slices"))
182 "Base flow should be a sequence of files.");
185 "BaseFlow_interporder should be smaller than or equal to "
194 ASSERTL0(
false,
"Number of slices must be a positive number "
212 size_t nq = pFields[0]->GetNpoints();
219 pFields[0]->GetCoords(x0, x1, x2);
221 for (
size_t i = 0; i < pFields.size(); i++)
231 for (
size_t i = 0; i < nvar; ++i)
236 if (
m_session->DefinesParameter(
"period"))
245 if (
m_session->GetComm()->GetRank() == 0)
247 cout <<
"baseflow info : interpolation order " <<
m_interporder
248 <<
", period " <<
m_period <<
", periodicity ";
257 cout <<
"baseflow info : files from " <<
m_start <<
" to "
260 <<
" time intervals" << endl;
271 const int nConvectiveFields,
279 ASSERTL1(nConvectiveFields == inarray.size(),
280 "Number of convective fields and Inarray are not compatible");
282 size_t nPointsTot = fields[0]->GetNpoints();
283 size_t ndim = advVel.size();
288 for (
size_t i = 0; i < ndim; ++i)
293 fields[i]->HomogeneousBwdTrans(nPointsTot, advVel[i], velocity[i]);
297 velocity[i] = advVel[i];
302 for (
size_t i = 0; i < nDerivs; ++i)
310 for (
size_t i = 0; i < ndim; ++i)
318 for (
size_t i = 0; i < (size_t)nConvectiveFields; ++i)
325 fields[i]->PhysDeriv(inarray[i], grad[0]);
330 fields[i]->PhysDeriv(inarray[i], grad[0], grad[1]);
335 fields[i]->PhysDeriv(inarray[i], grad[0], grad[1], grad[2]);
339 fields[i]->HomogeneousBwdTrans(nPointsTot, grad[0],
341 fields[i]->HomogeneousBwdTrans(nPointsTot, grad[1],
343 fields[i]->HomogeneousBwdTrans(nPointsTot, grad[2],
352 for (
size_t j = 1; j < nDerivs; ++j)
364 for (
size_t j = 0; j < lim; ++j)
367 velocity[j], 1, outarray[i], 1, outarray[i], 1);
372 fields[i]->HomogeneousFwdTrans(nPointsTot, outarray[i],
383 if (
m_session->GetSolverInfo(
"EqType") ==
"UnsteadyNavierStokes")
388 "Number of base flow variables does not match what is "
395 "Number of base flow variables does not match what is expected.");
398 size_t npts = inarray[0].size();
400 for (
size_t i = 0; i < inarray.size(); ++i)
403 "Size of base flow array does not match expected.");
420 std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
421 std::vector<std::vector<NekDouble>> FieldData;
426 size_t numexp = pFields[0]->GetExpSize();
430 for (
size_t i = 0; i < numexp; ++i)
432 ElementGIDs[i] = pFields[0]->GetExp(i)->GetGeom()->GetGlobalID();
438 fld->Import(pInfile, FieldDef, FieldData,
441 size_t nSessionVar =
m_session->GetVariables().size();
442 size_t nSessionConvVar = nSessionVar - 1;
443 size_t nFileVar = FieldDef[0]->m_fields.size();
445 std::unordered_map<int, int> zIdToPlane;
451 for (
size_t j = 0; j < nFileVar; ++j)
454 for (; k < nSessionConvVar; ++k)
456 if (
m_session->GetVariable(k) == FieldDef[0]->m_fields[j])
461 if (k == nSessionConvVar)
465 for (
size_t i = 0; i < FieldDef.size(); ++i)
467 pFields[j]->ExtractDataToCoeffs(FieldDef[i], FieldData[i],
468 FieldDef[i]->m_fields[j], tmp_coeff,
474 pFields[j]->GetPlane(0)->BwdTrans(tmp_coeff,
m_baseflow[k]);
480 int ncplane = (pFields[0]->GetNpoints()) /
m_npointsZ;
487 bool oldwavespace = pFields[j]->GetWaveSpace();
488 pFields[j]->SetWaveSpace(
false);
489 pFields[j]->BwdTrans(tmp_coeff,
m_baseflow[k]);
490 pFields[j]->SetWaveSpace(oldwavespace);
497 for (
size_t i = 0; i < nSessionConvVar; ++i)
518 &outarray[0], 1, &outarray[0], 1);
520 for (
int i = 2; i <
m_slices; i += 2)
522 phase = (i >> 1) * BetaT;
524 Vmath::Svtvp(npoints, cos(phase), &inarray[i * npoints], 1,
525 &outarray[0], 1, &outarray[0], 1);
526 Vmath::Svtvp(npoints, -sin(phase), &inarray[(i + 1) * npoints], 1,
527 &outarray[0], 1, &outarray[0], 1);
561 coeff[i] *= (x - ix + padleft - (
NekDouble)j) /
567 for (
int i = ix - padleft; i < ix + padright + 1; ++i)
570 &inarray[i * npoints], 1, &outarray[0], 1,
614 bool oldwavespace =
field->GetWaveSpace();
615 field->SetWaveSpace(
false);
620 field->SetWaveSpace(oldwavespace);
629 [[maybe_unused]]
bool UseContCoeffs)
const
658 for (
size_t i = 0; i < n_exp; ++i)
660 BlkMatrix->SetBlock(i, i, loc_mat);
670 size_t ConvectedFields =
m_baseflow.size() - 1;
674 for (
size_t i = 0; i < ConvectedFields; ++i)
682 size_t found = file.find(
"%d");
684 file.find(
"%d", found + 1) == string::npos,
685 "Since N_slices is specified, the filename provided for function "
686 "'BaseFlow' must include exactly one instance of the format "
687 "specifier '%d', to index the time-slices.");
694 if (
m_session->GetComm()->GetRank() == 0)
696 cout <<
"read base flow file " << filename.str() << endl;
705 for (
size_t k = 0; k < ConvectedFields; ++k)
707#ifdef NEKTAR_USING_FFTW
727 for (
size_t i = 0; i < npoints; i++)
747 int nrows = blkmat->GetRows();
748 int ncols = blkmat->GetColumns();
765 out = (*blkmat) * in;
774 for (
size_t r = 0; r < sortedinarray.size(); ++r)
776 sortedinarray[0] = 0;
777 sortedoutarray[0] = 0;
#define ASSERTL0(condition, msg)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Describes the specification for a Basis.
static std::shared_ptr< FieldIO > CreateForFile(const LibUtilities::SessionReaderSharedPtr session, const std::string &filename)
Construct a FieldIO object for a given input filename.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
Defines a specification for a set of points.
SpatialDomains::BoundaryConditionsSharedPtr m_boundaryConditions
int m_npointsZ
number of points in Z direction (if homogeneous)
NekDouble m_LhomZ
physical length in Z direction (if homogeneous)
void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields) override
Initialises the advection object.
enum HomogeneousType m_HomogeneousType
void UpdateBase(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const NekDouble time)
NekDouble m_period
period length
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) override
Advects a vector field.
int m_npointsX
number of points in X direction (if homogeneous)
~LinearisedAdvection() override
int m_npointsY
number of points in Y direction (if homogeneous)
int m_HomoDirec
number of homogenous directions
static SolverUtils::AdvectionSharedPtr create(std::string)
Creates an instance of this class.
bool m_useFFT
flag to determine if use or not the FFT for transformations
void v_SetBaseFlow(const Array< OneD, Array< OneD, NekDouble > > &inarray, const Array< OneD, MultiRegions::ExpListSharedPtr > &fields) override
Overrides the base flow used during linearised advection.
LibUtilities::SessionReaderSharedPtr m_session
Array< OneD, NekDouble > m_tmpIN
int m_start
number of slices
void UpdateGradBase(const int var, const MultiRegions::ExpListSharedPtr &field)
DNekBlkMatSharedPtr GetFloquetBlockMatrix(FloquetMatType mattype, bool UseContCoeffs=false) const
bool m_singleMode
flag to determine if use single mode or not
Array< OneD, Array< OneD, NekDouble > > m_baseflow
Storage for base flow.
Array< OneD, NekDouble > m_tmpOUT
Array< OneD, Array< OneD, NekDouble > > m_gradBase
bool m_multipleModes
flag to determine if use multiple mode or not
void DFT(const std::string file, Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
LibUtilities::NektarFFTSharedPtr m_FFT
auxiliary variables
bool m_halfMode
flag to determine if use half mode or not
NekDouble m_LhomY
physical length in Y direction (if homogeneous)
void ImportFldBase(std::string pInfile, Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, int slice)
Import Base flow.
NekDouble m_LhomX
physical length in X direction (if homogeneous)
Array< OneD, Array< OneD, NekDouble > > m_interp
interpolation vector
static std::string className
Name of class.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
An abstract base class encapsulating the concept of advection of a vector field.
virtual SOLVER_UTILS_EXPORT void v_InitObject(LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields)
Initialises the advection object.
DNekMatSharedPtr GetStdMatrix(const StdMatrixKey &mkey)
LibUtilities::ShapeType DetShapeType() const
This function returns the shape of the expansion domain.
Class representing a segment element in reference space All interface of this class sits in StdExpans...
NektarFFTFactory & GetNektarFFTFactory()
std::shared_ptr< FieldIO > FieldIOSharedPtr
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Equation > EquationSharedPtr
static FieldMetaDataMap NullFieldMetaDataMap
@ eFourierEvenlySpaced
1D Evenly-spaced points using Fourier Fit
@ eFourier
Fourier Expansion .
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
AdvectionFactory & GetAdvectionFactory()
Gets the factory for initialising advection objects.
std::shared_ptr< DNekBlkMat > DNekBlkMatSharedPtr
std::shared_ptr< DNekMat > DNekMatSharedPtr
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.
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 Neg(int n, T *x, const int incx)
Negate x = -x.
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
void Zero(int n, T *x, const int incx)
Zero vector.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)