35#include <boost/core/ignore_unused.hpp>
53 m_lhom_z(1), m_homogeneous2DBlockMat(
63 const NekDouble lhom_z,
const bool useFFT,
const bool dealiasing)
64 :
ExpList(type), m_useFFT(useFFT), m_lhom_y(lhom_y), m_lhom_z(lhom_z),
65 m_homogeneous2DBlockMat(
67 m_dealiasing(dealiasing)
70 m_comm = pSession->GetComm();
73 "Homogeneous Basis in y direction is a null basis");
75 "Homogeneous Basis in z direction is a null basis");
82 HomoBasis_y, HomoBasis_z,
m_comm->GetColumnComm());
103 "Remove dealiasing if you want to run in parallel");
112 :
ExpList(In, false), m_useFFT(In.m_useFFT), m_FFT_y(In.m_FFT_y),
113 m_FFT_z(In.m_FFT_z), m_transposition(In.m_transposition),
114 m_Ycomm(In.m_Ycomm), m_Zcomm(In.m_Ycomm),
115 m_homogeneousBasis_y(In.m_homogeneousBasis_y),
116 m_homogeneousBasis_z(In.m_homogeneousBasis_z), m_lhom_y(In.m_lhom_y),
117 m_lhom_z(In.m_lhom_z),
118 m_homogeneous2DBlockMat(In.m_homogeneous2DBlockMat), m_ny(In.m_ny),
119 m_nz(In.m_nz), m_dealiasing(In.m_dealiasing), m_padsize_y(In.m_padsize_y),
120 m_padsize_z(In.m_padsize_z), MatFwdPAD(In.MatFwdPAD),
121 MatBwdPAD(In.MatBwdPAD)
128 :
ExpList(In, eIDs, false), m_useFFT(In.m_useFFT), m_FFT_y(In.m_FFT_y),
129 m_FFT_z(In.m_FFT_z), m_transposition(In.m_transposition),
130 m_Ycomm(In.m_Ycomm), m_Zcomm(In.m_Ycomm),
131 m_homogeneousBasis_y(In.m_homogeneousBasis_y),
132 m_homogeneousBasis_z(In.m_homogeneousBasis_z), m_lhom_y(In.m_lhom_y),
133 m_lhom_z(In.m_lhom_z),
134 m_homogeneous2DBlockMat(
136 m_ny(In.m_ny), m_nz(In.m_nz), m_dealiasing(In.m_dealiasing),
137 m_padsize_y(In.m_padsize_y), m_padsize_z(In.m_padsize_z),
138 MatFwdPAD(In.MatFwdPAD), MatBwdPAD(In.MatBwdPAD)
174 int nslabs = npoints /
224 for (
int j = 0; j < nslabs; j++)
228 for (
int i = 0; i <
m_nz; i++)
231 &(PadV1_slab_coeff[i * 2 *
m_ny]), 1);
233 &(PadV2_slab_coeff[i * 2 *
m_ny]), 1);
237 PadOUT_V1 = (*MatBwdPAD) * PadIN_V1;
238 PadOUT_V2 = (*MatBwdPAD) * PadIN_V2;
243 PadV2_slab_phys, 1, PadRe_slab_phys, 1);
247 PadOUT_Re = (*MatFwdPAD) * PadIN_Re;
251 for (
int i = 0; i <
m_nz; i++)
254 &(ShufV1V2[i *
m_ny + j * nlines]), 1);
279 size_t ndim = inarray1.size();
280 ASSERTL1(inarray2.size() % ndim == 0,
281 "Wrong dimensions for DealiasedDotProd.");
283 size_t nvec = inarray2.size() % ndim;
286 for (
size_t i = 0; i < nvec; i++)
289 for (
size_t j = 0; j < ndim; j++)
291 DealiasedProd(npts, inarray1[j], inarray2[i * ndim + j], out);
292 Vmath::Vadd(npts, outarray[i], 1, out, 1, outarray[i], 1);
301 size_t cnt = 0, cnt1 = 0;
303 size_t nlines =
m_lines.size();
305 for (
size_t n = 0; n < nlines; ++n)
307 m_lines[n]->FwdTrans(inarray + cnt, tmparray = outarray + cnt1);
308 cnt +=
m_lines[n]->GetTotPoints();
309 cnt1 +=
m_lines[n]->GetNcoeffs();
321 size_t cnt = 0, cnt1 = 0;
323 size_t nlines =
m_lines.size();
325 for (
size_t n = 0; n < nlines; ++n)
327 m_lines[n]->FwdTransLocalElmt(inarray + cnt,
328 tmparray = outarray + cnt1);
330 cnt +=
m_lines[n]->GetTotPoints();
331 cnt1 +=
m_lines[n]->GetNcoeffs();
343 int cnt = 0, cnt1 = 0;
347 for (
int n = 0; n < nlines; ++n)
349 m_lines[n]->FwdTransBndConstrained(inarray + cnt,
350 tmparray = outarray + cnt1);
352 cnt +=
m_lines[n]->GetTotPoints();
353 cnt1 +=
m_lines[n]->GetNcoeffs();
365 size_t cnt = 0, cnt1 = 0;
367 size_t nlines =
m_lines.size();
369 for (
size_t n = 0; n < nlines; ++n)
371 m_lines[n]->BwdTrans(inarray + cnt, tmparray = outarray + cnt1);
372 cnt +=
m_lines[n]->GetNcoeffs();
373 cnt1 +=
m_lines[n]->GetTotPoints();
385 size_t cnt = 0, cnt1 = 0;
387 size_t nlines =
m_lines.size();
389 for (
size_t n = 0; n < nlines; ++n)
391 m_lines[n]->IProductWRTBase(inarray + cnt, tmparray = outarray + cnt1);
393 cnt +=
m_lines[n]->GetNcoeffs();
394 cnt1 +=
m_lines[n]->GetTotPoints();
402 boost::ignore_unused(Shuff, UnShuff);
421 for (
int i = 0; i < (
p *
m_nz); i++)
429 for (
int i = 0; i < (
p *
m_nz); i++)
441 for (
int i = 0; i < (
p *
m_ny); i++)
449 for (
int i = 0; i < (
p *
m_ny); i++)
495 int nrowsY = blkmatY->GetRows();
496 int ncolsY = blkmatY->GetColumns();
501 int nrowsZ = blkmatZ->GetRows();
502 int ncolsZ = blkmatZ->GetColumns();
516 outY = (*blkmatY) * inY;
519 sortedinarrayZ,
false,
522 outZ = (*blkmatZ) * inZ;
525 sortedoutarrayY,
false,
545 return matrixIter->second;
587 n_exp =
m_lines[0]->GetNcoeffs();
591 n_exp =
m_lines[0]->GetTotPoints();
636 for (i = 0; i < (n_exp * NumPencils); ++i)
638 BlkMatrix->SetBlock(i, i, loc_mat);
647 std::vector<LibUtilities::FieldDefinitionsSharedPtr> returnval;
653 std::vector<NekDouble> HomoLen(2);
662 std::vector<unsigned int> yIDs;
663 std::vector<unsigned int> zIDs;
665 for (
int n = 0; n < nhom_modes_z; ++n)
667 for (
int m = 0; m < nhom_modes_y; ++m)
674 m_lines[0]->GeneralGetFieldDefinitions(returnval, 2, HomoBasis, HomoLen,
675 false, sIDs, zIDs, yIDs);
680 std::vector<LibUtilities::FieldDefinitionsSharedPtr> &fielddef)
686 std::vector<NekDouble> HomoLen(2);
695 std::vector<unsigned int> yIDs;
696 std::vector<unsigned int> zIDs;
698 for (
int n = 0; n < nhom_modes_z; ++n)
700 for (
int m = 0; m < nhom_modes_y; ++m)
708 m_lines[0]->GeneralGetFieldDefinitions(fielddef, 2, HomoBasis, HomoLen,
709 false, sIDs, zIDs, yIDs);
721 int ncoeffs_per_line =
m_lines[0]->GetNcoeffs();
725 map<int, int> ElmtID_to_ExpID;
726 for (i = 0; i <
m_lines[0]->GetExpSize(); ++i)
728 ElmtID_to_ExpID[(*m_exp)[i]->GetGeom()->GetGlobalID()] = i;
731 for (i = 0; i < fielddef->m_elementIDs.size(); ++i)
733 int eid = ElmtID_to_ExpID[fielddef->m_elementIDs[i]];
734 int datalen = (*m_exp)[eid]->GetNcoeffs();
736 for (k = 0; k < (NumMod_y * NumMod_z); ++k)
748 std::vector<NekDouble> &fielddata)
755 std::vector<NekDouble> &fielddata, std::string &field,
758 boost::ignore_unused(zIdToPlane);
761 int datalen = fielddata.size() / fielddef->m_fields.size();
762 int ncoeffs_per_line =
m_lines[0]->GetNcoeffs();
766 for (i = 0; i < fielddef->m_fields.size(); ++i)
768 if (fielddef->m_fields[i] == field)
774 ASSERTL0(i != fielddef->m_fields.size(),
"Field not found in data file");
777 map<int, int> ElmtID_to_ExpID;
778 for (i = 0; i <
m_lines[0]->GetExpSize(); ++i)
780 ElmtID_to_ExpID[(*m_exp)[i]->GetGeom()->GetGlobalID()] = i;
782 for (i = 0; i < fielddef->m_elementIDs.size(); ++i)
784 int eid = ElmtID_to_ExpID[fielddef->m_elementIDs[i]];
785 int datalen = (*m_exp)[eid]->GetNcoeffs();
786 for (k = 0; k < (NumMod_y * NumMod_z); ++k)
796 int expansion, std::string var)
799 int nq = (*m_exp)[expansion]->GetTotPoints();
800 int npoints_per_line =
m_lines[0]->GetTotPoints();
803 outfile <<
" <DataArray type=\"Float64\" Name=\"" << var <<
"\">"
806 for (
int n = 0; n <
m_lines.size(); ++n)
811 for (i = 0; i < nq; ++i)
818 outfile <<
" </DataArray>" << endl;
828 int n_points_line =
m_npoints / nyzlines;
837 for (
int i = 0; i < nyzlines; i++)
839 m_lines[i]->PhysDeriv(tmp1 = inarray + i * n_points_line,
840 tmp2 = out_d0 + i * n_points_line);
858 for (
int i = 0; i <
m_ny; i++)
862 for (
int j = 0; j <
m_nz; j++)
865 tmp1 = temparray + n_points_line * (i + j *
m_ny),
868 n_points_line * ((i -
int(
sign)) + j *
m_ny),
877 for (
int i = 0; i <
m_nz; i++)
882 tmp1 = temparray + i *
m_ny * n_points_line, 1,
883 tmp2 = temparray2 + (i -
int(
sign)) *
m_ny * n_points_line, 1);
901 ASSERTL0(
false,
"Semi-phyisical time-stepping not implemented yet "
902 "for non-Fourier basis")
912 for (
int i = 0; i < n_points_line; i++)
914 StdQuad.
PhysDeriv(tmp1 = temparray + i * nyzlines,
915 tmp2 = temparray1 + i * nyzlines,
916 tmp3 = temparray2 + i * nyzlines);
936 int n_points_line =
m_npoints / nyzlines;
949 for (
int i = 0; i < nyzlines; i++)
951 m_lines[i]->PhysDeriv(tmp1 = inarray + i * n_points_line,
952 tmp2 = out_d + i * n_points_line);
974 for (
int i = 0; i <
m_ny; i++)
978 for (
int j = 0; j <
m_nz; j++)
982 tmp1 = temparray + n_points_line * (i + j *
m_ny),
985 n_points_line * ((i -
int(
sign)) + j *
m_ny),
1002 for (
int i = 0; i <
m_nz; i++)
1006 tmp1 = temparray + i *
m_ny * n_points_line, 1,
1008 (i -
int(
sign)) *
m_ny * n_points_line,
1026 ASSERTL0(
false,
"Semi-phyisical time-stepping not implemented "
1027 "yet for non-Fourier basis")
1038 for (
int i = 0; i < n_points_line; i++)
1040 StdQuad.
PhysDeriv(tmp1 = temparray + i * nyzlines,
1041 tmp2 = temparray1 + i * nyzlines,
1042 tmp3 = temparray2 + i * nyzlines);
#define ASSERTL0(condition, msg)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
#define ASSERTL2(condition, msg)
Assert Level 2 – Debugging which is used FULLDEBUG compilation mode. This level assert is designed to...
#define sign(a, b)
return the sign(b)*a
Represents a basis of a given type.
const BasisKey GetBasisKey() const
Returns the specification for the Basis.
Describes the specification for a Basis.
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
Defines a specification for a set of points.
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
Abstraction of a two-dimensional multi-elemental expansion which is merely a collection of local expa...
virtual void v_DealiasedProd(const int num_dofs, const Array< OneD, NekDouble > &inarray1, const Array< OneD, NekDouble > &inarray2, Array< OneD, NekDouble > &outarray) override
virtual void v_FwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
virtual void v_DealiasedDotProd(const int num_dofs, const Array< OneD, Array< OneD, NekDouble > > &inarray1, const Array< OneD, Array< OneD, NekDouble > > &inarray2, Array< OneD, Array< OneD, NekDouble > > &outarray) override
virtual void v_FwdTransLocalElmt(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
virtual std::vector< LibUtilities::FieldDefinitionsSharedPtr > v_GetFieldDefinitions(void) override
DNekBlkMatSharedPtr GenHomogeneous2DBlockMatrix(Homogeneous2DMatType mattype) const
virtual void v_FwdTransBndConstrained(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
DNekMatSharedPtr MatFwdPAD
LibUtilities::NektarFFTSharedPtr m_FFT_y
ExpListHomogeneous2D(const ExpansionType type)
Default constructor.
int m_nz
Number of modes = number of poitns in z direction.
Homo2DBlockMatrixMapShPtr m_homogeneous2DBlockMat
Array< OneD, NekDouble > m_tmpOUT
LibUtilities::NektarFFTSharedPtr m_FFT_z
LibUtilities::BasisSharedPtr m_homogeneousBasis_y
Definition of the total number of degrees of freedom and quadrature points. Sets up the storage for m...
NekDouble m_lhom_z
Width of homogeneous direction z.
DNekMatSharedPtr MatBwdPAD
Array< OneD, NekDouble > m_tmpIN
int m_ny
Number of modes = number of poitns in y direction.
void PhysDeriv(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &out_d0, Array< OneD, NekDouble > &out_d1, Array< OneD, NekDouble > &out_d2)
LibUtilities::CommSharedPtr m_Ycomm
LibUtilities::CommSharedPtr m_Zcomm
virtual void v_HomogeneousFwdTrans(const int npts, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, bool Shuff=true, bool UnShuff=true) override
virtual void v_IProductWRTBase(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
virtual void v_WriteVtkPieceData(std::ostream &outfile, int expansion, std::string var) override
bool m_useFFT
FFT variables.
LibUtilities::TranspositionSharedPtr m_transposition
Array< OneD, ExpListSharedPtr > m_lines
Vector of ExpList, will be filled with ExpList1D.
LibUtilities::BasisSharedPtr m_homogeneousBasis_z
Base expansion in z direction.
LibUtilities::BasisSharedPtr m_paddingBasis_z
Base expansion in z direction.
void SetPaddingBase(void)
virtual void v_AppendFieldData(LibUtilities::FieldDefinitionsSharedPtr &fielddef, std::vector< NekDouble > &fielddata) override
virtual void v_ExtractDataToCoeffs(LibUtilities::FieldDefinitionsSharedPtr &fielddef, std::vector< NekDouble > &fielddata, std::string &field, Array< OneD, NekDouble > &coeffs, std::unordered_map< int, int > zIdToPlane) override
Extract data from raw field data into expansion list.
void Homogeneous2DTrans(const int npts, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, bool IsForwards, bool Shuff=true, bool UnShuff=true)
DNekBlkMatSharedPtr GetHomogeneous2DBlockMatrix(Homogeneous2DMatType mattype) const
virtual void v_BwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
LibUtilities::BasisSharedPtr m_paddingBasis_y
Base expansion in y direction.
virtual void v_PhysDeriv(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &out_d0, Array< OneD, NekDouble > &out_d1, Array< OneD, NekDouble > &out_d2) override
NekDouble m_lhom_y
Width of homogeneous direction y.
virtual ~ExpListHomogeneous2D()
Destructor.
virtual void v_HomogeneousBwdTrans(const int npts, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, bool Shuff=true, bool UnShuff=true) override
Base class for all multi-elemental spectral/hp expansions.
Array< OneD, NekDouble > m_coeffs
Concatenation of all local expansion coefficients.
Array< OneD, int > m_coeff_offset
Offset of elemental data into the array m_coeffs.
void DealiasedProd(const int num_dofs, const Array< OneD, NekDouble > &inarray1, const Array< OneD, NekDouble > &inarray2, Array< OneD, NekDouble > &outarray)
LibUtilities::CommSharedPtr m_comm
Communicator.
void HomogeneousBwdTrans(const int npts, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, bool Shuff=true, bool UnShuff=true)
LibUtilities::SessionReaderSharedPtr m_session
Session.
Array< OneD, int > m_phys_offset
Offset of elemental data into the array m_phys.
Array< OneD, NekDouble > m_phys
The global expansion evaluated at the quadrature points.
void HomogeneousFwdTrans(const int npts, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, bool Shuff=true, bool UnShuff=true)
DNekMatSharedPtr GetStdMatrix(const StdMatrixKey &mkey)
LibUtilities::ShapeType DetShapeType() const
This function returns the shape of the expansion domain.
void PhysDeriv(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &out_d0, Array< OneD, NekDouble > &out_d1=NullNekDouble1DArray, Array< OneD, NekDouble > &out_d2=NullNekDouble1DArray)
Class representing a segment element in reference space All interface of this class sits in StdExpans...
static BasisSharedPtr NullBasisSharedPtr
static std::vector< unsigned int > NullUnsignedIntVector
BasisManagerT & BasisManager(void)
std::shared_ptr< Basis > BasisSharedPtr
NektarFFTFactory & GetNektarFFTFactory()
static const BasisKey NullBasisKey(eNoBasisType, 0, NullPointsKey)
Defines a null basis with no type or points.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< FieldDefinitions > FieldDefinitionsSharedPtr
@ beta
Gauss Radau pinned at x=-1,.
@ eFourierEvenlySpaced
1D Evenly-spaced points using Fourier Fit
@ eFourier
Fourier Expansion .
std::map< Homogeneous2DMatType, DNekBlkMatSharedPtr > Homo2DBlockMatrixMap
A map between homo matrix keys and their associated block matrices.
@ eBackwardsCoeffSpaceY1D
@ eBackwardsCoeffSpaceZ1D
static const NekDouble kNekZeroTol
The above copyright notice and this permission notice shall be included.
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 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 Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
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)