49 m_lhom_z(1), m_homogeneous2DBlockMat(
59 const NekDouble lhom_z,
const bool useFFT,
const bool dealiasing)
60 :
ExpList(type), m_useFFT(useFFT), m_lhom_y(lhom_y), m_lhom_z(lhom_z),
61 m_homogeneous2DBlockMat(
63 m_dealiasing(dealiasing)
66 m_comm = pSession->GetComm();
69 "Homogeneous Basis in y direction is a null basis");
71 "Homogeneous Basis in z direction is a null basis");
78 HomoBasis_y, HomoBasis_z,
m_comm->GetColumnComm());
99 "Remove dealiasing if you want to run in parallel");
108 :
ExpList(In, false), m_useFFT(In.m_useFFT), m_FFT_y(In.m_FFT_y),
109 m_FFT_z(In.m_FFT_z), m_transposition(In.m_transposition),
110 m_Ycomm(In.m_Ycomm), m_Zcomm(In.m_Ycomm),
111 m_homogeneousBasis_y(In.m_homogeneousBasis_y),
112 m_homogeneousBasis_z(In.m_homogeneousBasis_z), m_lhom_y(In.m_lhom_y),
113 m_lhom_z(In.m_lhom_z),
114 m_homogeneous2DBlockMat(In.m_homogeneous2DBlockMat), m_ny(In.m_ny),
115 m_nz(In.m_nz), m_dealiasing(In.m_dealiasing), m_padsize_y(In.m_padsize_y),
116 m_padsize_z(In.m_padsize_z), MatFwdPAD(In.MatFwdPAD),
117 MatBwdPAD(In.MatBwdPAD)
124 :
ExpList(In, eIDs, false), m_useFFT(In.m_useFFT), m_FFT_y(In.m_FFT_y),
125 m_FFT_z(In.m_FFT_z), m_transposition(In.m_transposition),
126 m_Ycomm(In.m_Ycomm), m_Zcomm(In.m_Ycomm),
127 m_homogeneousBasis_y(In.m_homogeneousBasis_y),
128 m_homogeneousBasis_z(In.m_homogeneousBasis_z), m_lhom_y(In.m_lhom_y),
129 m_lhom_z(In.m_lhom_z),
130 m_homogeneous2DBlockMat(
132 m_ny(In.m_ny), m_nz(In.m_nz), m_dealiasing(In.m_dealiasing),
133 m_padsize_y(In.m_padsize_y), m_padsize_z(In.m_padsize_z),
134 MatFwdPAD(In.MatFwdPAD), MatBwdPAD(In.MatBwdPAD)
170 int nslabs = npoints /
220 for (
int j = 0; j < nslabs; j++)
224 for (
int i = 0; i <
m_nz; i++)
227 &(PadV1_slab_coeff[i * 2 *
m_ny]), 1);
229 &(PadV2_slab_coeff[i * 2 *
m_ny]), 1);
233 PadOUT_V1 = (*MatBwdPAD) * PadIN_V1;
234 PadOUT_V2 = (*MatBwdPAD) * PadIN_V2;
239 PadV2_slab_phys, 1, PadRe_slab_phys, 1);
243 PadOUT_Re = (*MatFwdPAD) * PadIN_Re;
247 for (
int i = 0; i <
m_nz; i++)
250 &(ShufV1V2[i *
m_ny + j * nlines]), 1);
275 size_t ndim = inarray1.size();
276 ASSERTL1(inarray2.size() % ndim == 0,
277 "Wrong dimensions for DealiasedDotProd.");
279 size_t nvec = inarray2.size() % ndim;
282 for (
size_t i = 0; i < nvec; i++)
285 for (
size_t j = 0; j < ndim; j++)
287 DealiasedProd(npts, inarray1[j], inarray2[i * ndim + j], out);
288 Vmath::Vadd(npts, outarray[i], 1, out, 1, outarray[i], 1);
297 size_t cnt = 0, cnt1 = 0;
299 size_t nlines =
m_lines.size();
301 for (
size_t n = 0; n < nlines; ++n)
303 m_lines[n]->FwdTrans(inarray + cnt, tmparray = outarray + cnt1);
304 cnt +=
m_lines[n]->GetTotPoints();
305 cnt1 +=
m_lines[n]->GetNcoeffs();
317 size_t cnt = 0, cnt1 = 0;
319 size_t nlines =
m_lines.size();
321 for (
size_t n = 0; n < nlines; ++n)
323 m_lines[n]->FwdTransLocalElmt(inarray + cnt,
324 tmparray = outarray + cnt1);
326 cnt +=
m_lines[n]->GetTotPoints();
327 cnt1 +=
m_lines[n]->GetNcoeffs();
339 int cnt = 0, cnt1 = 0;
343 for (
int n = 0; n < nlines; ++n)
345 m_lines[n]->FwdTransBndConstrained(inarray + cnt,
346 tmparray = outarray + cnt1);
348 cnt +=
m_lines[n]->GetTotPoints();
349 cnt1 +=
m_lines[n]->GetNcoeffs();
361 size_t cnt = 0, cnt1 = 0;
363 size_t nlines =
m_lines.size();
365 for (
size_t n = 0; n < nlines; ++n)
367 m_lines[n]->BwdTrans(inarray + cnt, tmparray = outarray + cnt1);
368 cnt +=
m_lines[n]->GetNcoeffs();
369 cnt1 +=
m_lines[n]->GetTotPoints();
381 size_t cnt = 0, cnt1 = 0;
383 size_t nlines =
m_lines.size();
385 for (
size_t n = 0; n < nlines; ++n)
387 m_lines[n]->IProductWRTBase(inarray + cnt, tmparray = outarray + cnt1);
389 cnt +=
m_lines[n]->GetNcoeffs();
390 cnt1 +=
m_lines[n]->GetTotPoints();
397 [[maybe_unused]]
bool Shuff, [[maybe_unused]]
bool UnShuff)
416 for (
int i = 0; i < (
p *
m_nz); i++)
424 for (
int i = 0; i < (
p *
m_nz); i++)
436 for (
int i = 0; i < (
p *
m_ny); i++)
444 for (
int i = 0; i < (
p *
m_ny); i++)
490 int nrowsY = blkmatY->GetRows();
491 int ncolsY = blkmatY->GetColumns();
496 int nrowsZ = blkmatZ->GetRows();
497 int ncolsZ = blkmatZ->GetColumns();
511 outY = (*blkmatY) * inY;
514 sortedinarrayZ,
false,
517 outZ = (*blkmatZ) * inZ;
520 sortedoutarrayY,
false,
540 return matrixIter->second;
582 n_exp =
m_lines[0]->GetNcoeffs();
586 n_exp =
m_lines[0]->GetTotPoints();
631 for (i = 0; i < (n_exp * NumPencils); ++i)
633 BlkMatrix->SetBlock(i, i, loc_mat);
642 std::vector<LibUtilities::FieldDefinitionsSharedPtr> returnval;
648 std::vector<NekDouble> HomoLen(2);
657 std::vector<unsigned int> yIDs;
658 std::vector<unsigned int> zIDs;
660 for (
int n = 0; n < nhom_modes_z; ++n)
662 for (
int m = 0; m < nhom_modes_y; ++m)
669 m_lines[0]->GeneralGetFieldDefinitions(returnval, 2, HomoBasis, HomoLen,
670 false, sIDs, zIDs, yIDs);
675 std::vector<LibUtilities::FieldDefinitionsSharedPtr> &fielddef)
681 std::vector<NekDouble> HomoLen(2);
690 std::vector<unsigned int> yIDs;
691 std::vector<unsigned int> zIDs;
693 for (
int n = 0; n < nhom_modes_z; ++n)
695 for (
int m = 0; m < nhom_modes_y; ++m)
703 m_lines[0]->GeneralGetFieldDefinitions(fielddef, 2, HomoBasis, HomoLen,
704 false, sIDs, zIDs, yIDs);
716 int ncoeffs_per_line =
m_lines[0]->GetNcoeffs();
720 map<int, int> ElmtID_to_ExpID;
721 for (i = 0; i <
m_lines[0]->GetExpSize(); ++i)
723 ElmtID_to_ExpID[(*m_exp)[i]->GetGeom()->GetGlobalID()] = i;
726 for (i = 0; i < fielddef->m_elementIDs.size(); ++i)
728 int eid = ElmtID_to_ExpID[fielddef->m_elementIDs[i]];
729 int datalen = (*m_exp)[eid]->GetNcoeffs();
731 for (k = 0; k < (NumMod_y * NumMod_z); ++k)
743 std::vector<NekDouble> &fielddata)
750 std::vector<NekDouble> &fielddata, std::string &
field,
752 [[maybe_unused]] std::unordered_map<int, int> zIdToPlane)
756 int datalen = fielddata.size() / fielddef->m_fields.size();
757 int ncoeffs_per_line =
m_lines[0]->GetNcoeffs();
761 for (i = 0; i < fielddef->m_fields.size(); ++i)
763 if (fielddef->m_fields[i] ==
field)
769 ASSERTL0(i != fielddef->m_fields.size(),
"Field not found in data file");
772 map<int, int> ElmtID_to_ExpID;
773 for (i = 0; i <
m_lines[0]->GetExpSize(); ++i)
775 ElmtID_to_ExpID[(*m_exp)[i]->GetGeom()->GetGlobalID()] = i;
777 for (i = 0; i < fielddef->m_elementIDs.size(); ++i)
779 int eid = ElmtID_to_ExpID[fielddef->m_elementIDs[i]];
780 int datalen = (*m_exp)[eid]->GetNcoeffs();
781 for (k = 0; k < (NumMod_y * NumMod_z); ++k)
791 int expansion, std::string var)
794 int nq = (*m_exp)[expansion]->GetTotPoints();
795 int npoints_per_line =
m_lines[0]->GetTotPoints();
798 outfile << R
"( <DataArray type="Float64" Name=")" << var << "\">"
801 for (
int n = 0; n <
m_lines.size(); ++n)
806 for (i = 0; i < nq; ++i)
813 outfile <<
" </DataArray>" << endl;
823 int n_points_line =
m_npoints / nyzlines;
832 for (
int i = 0; i < nyzlines; i++)
834 m_lines[i]->PhysDeriv(tmp1 = inarray + i * n_points_line,
835 tmp2 = out_d0 + i * n_points_line);
853 for (
int i = 0; i <
m_ny; i++)
857 for (
int j = 0; j <
m_nz; j++)
860 tmp1 = temparray + n_points_line * (i + j *
m_ny),
863 n_points_line * ((i -
int(
sign)) + j *
m_ny),
872 for (
int i = 0; i <
m_nz; i++)
877 tmp1 = temparray + i *
m_ny * n_points_line, 1,
878 tmp2 = temparray2 + (i -
int(
sign)) *
m_ny * n_points_line, 1);
896 ASSERTL0(
false,
"Semi-phyisical time-stepping not implemented yet "
897 "for non-Fourier basis")
907 for (
int i = 0; i < n_points_line; i++)
909 StdQuad.
PhysDeriv(tmp1 = temparray + i * nyzlines,
910 tmp2 = temparray1 + i * nyzlines,
911 tmp3 = temparray2 + i * nyzlines);
931 int n_points_line =
m_npoints / nyzlines;
944 for (
int i = 0; i < nyzlines; i++)
946 m_lines[i]->PhysDeriv(tmp1 = inarray + i * n_points_line,
947 tmp2 = out_d + i * n_points_line);
969 for (
int i = 0; i <
m_ny; i++)
973 for (
int j = 0; j <
m_nz; j++)
977 tmp1 = temparray + n_points_line * (i + j *
m_ny),
980 n_points_line * ((i -
int(
sign)) + j *
m_ny),
997 for (
int i = 0; i <
m_nz; i++)
1001 tmp1 = temparray + i *
m_ny * n_points_line, 1,
1003 (i -
int(
sign)) *
m_ny * n_points_line,
1021 ASSERTL0(
false,
"Semi-phyisical time-stepping not implemented "
1022 "yet for non-Fourier basis")
1033 for (
int i = 0; i < n_points_line; i++)
1035 StdQuad.
PhysDeriv(tmp1 = temparray + i * nyzlines,
1036 tmp2 = temparray1 + i * nyzlines,
1037 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...
void v_DealiasedProd(const int num_dofs, const Array< OneD, NekDouble > &inarray1, const Array< OneD, NekDouble > &inarray2, Array< OneD, NekDouble > &outarray) override
void v_FwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
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
void v_FwdTransLocalElmt(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
std::vector< LibUtilities::FieldDefinitionsSharedPtr > v_GetFieldDefinitions(void) override
~ExpListHomogeneous2D() override
Destructor.
DNekBlkMatSharedPtr GenHomogeneous2DBlockMatrix(Homogeneous2DMatType mattype) const
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
void v_HomogeneousFwdTrans(const int npts, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, bool Shuff=true, bool UnShuff=true) override
void v_IProductWRTBase(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
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)
void v_AppendFieldData(LibUtilities::FieldDefinitionsSharedPtr &fielddef, std::vector< NekDouble > &fielddata) override
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
void v_BwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
LibUtilities::BasisSharedPtr m_paddingBasis_y
Base expansion in y direction.
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.
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
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)