44 namespace MultiRegions
63 const bool dealiasing):
69 m_dealiasing(dealiasing)
72 "Homogeneous Basis in y direction is a null basis");
74 "Homogeneous Basis in z direction is a null basis");
97 ASSERTL0(
m_comm->GetColumnComm()->GetSize() == 1,
"Remove dealiasing if you want to run in parallel");
108 m_useFFT(In.m_useFFT),
111 m_transposition(In.m_transposition),
114 m_homogeneousBasis_y(In.m_homogeneousBasis_y),
115 m_homogeneousBasis_z(In.m_homogeneousBasis_z),
116 m_lhom_y(In.m_lhom_y),
117 m_lhom_z(In.m_lhom_z),
118 m_homogeneous2DBlockMat(In.m_homogeneous2DBlockMat),
121 m_dealiasing(In.m_dealiasing),
122 m_padsize_y(In.m_padsize_y),
123 m_padsize_z(In.m_padsize_z),
124 MatFwdPAD(In.MatFwdPAD),
125 MatBwdPAD(In.MatBwdPAD)
127 m_lines = Array<OneD, ExpListSharedPtr>(In.
m_lines.num_elements());
138 Array<OneD, NekDouble> &outarray,
148 Array<OneD, NekDouble> &outarray,
158 const Array<OneD, NekDouble> &inarray2,
159 Array<OneD, NekDouble> &outarray,
162 int npoints = outarray.num_elements();
163 int nlines =
m_lines.num_elements();
164 int nslabs = npoints/nlines;
166 Array<OneD, NekDouble> V1(npoints);
167 Array<OneD, NekDouble> V2(npoints);
168 Array<OneD, NekDouble> V1V2(npoints);
169 Array<OneD, NekDouble> ShufV1(npoints);
170 Array<OneD, NekDouble> ShufV2(npoints);
171 Array<OneD, NekDouble> ShufV1V2(npoints);
188 Array<OneD, NekDouble> PadV2_slab_coeff(
m_padsize_y*m_padsize_z,0.0);
189 Array<OneD, NekDouble> PadRe_slab_coeff(
m_padsize_y*m_padsize_z,0.0);
191 Array<OneD, NekDouble> PadV1_slab_phys(
m_padsize_y*m_padsize_z,0.0);
192 Array<OneD, NekDouble> PadV2_slab_phys(
m_padsize_y*m_padsize_z,0.0);
193 Array<OneD, NekDouble> PadRe_slab_phys(
m_padsize_y*m_padsize_z,0.0);
205 for(
int j = 0 ; j< nslabs ; j++)
209 for(
int i = 0 ; i<
m_nz ; i++)
212 Vmath::Vcopy(m_ny,&(ShufV2[i*m_ny + j*nlines]),1,&(PadV2_slab_coeff[i*2*m_ny]),1);
216 PadOUT_V1 = (*MatBwdPAD)*PadIN_V1;
217 PadOUT_V2 = (*MatBwdPAD)*PadIN_V2;
225 PadOUT_Re = (*MatFwdPAD)*PadIN_Re;
229 for (
int i = 0; i <
m_nz; i++)
250 int cnt = 0, cnt1 = 0;
251 Array<OneD, NekDouble> tmparray;
252 int nlines =
m_lines.num_elements();
254 for(
int n = 0; n < nlines; ++n)
256 m_lines[n]->FwdTrans(inarray+cnt, tmparray = outarray + cnt1,
258 cnt +=
m_lines[n]->GetTotPoints();
259 cnt1 +=
m_lines[n]->GetNcoeffs();
269 int cnt = 0, cnt1 = 0;
270 Array<OneD, NekDouble> tmparray;
271 int nlines =
m_lines.num_elements();
273 for(
int n = 0; n < nlines; ++n)
275 m_lines[n]->FwdTrans_IterPerExp(inarray+cnt, tmparray = outarray + cnt1);
277 cnt +=
m_lines[n]->GetTotPoints();
278 cnt1 +=
m_lines[n]->GetNcoeffs();
288 int cnt = 0, cnt1 = 0;
289 Array<OneD, NekDouble> tmparray;
290 int nlines =
m_lines.num_elements();
292 for(
int n = 0; n < nlines; ++n)
294 m_lines[n]->BwdTrans(inarray+cnt, tmparray = outarray + cnt1,
296 cnt +=
m_lines[n]->GetNcoeffs();
297 cnt1 +=
m_lines[n]->GetTotPoints();
307 int cnt = 0, cnt1 = 0;
308 Array<OneD, NekDouble> tmparray;
309 int nlines =
m_lines.num_elements();
311 for(
int n = 0; n < nlines; ++n)
313 m_lines[n]->BwdTrans_IterPerExp(inarray+cnt, tmparray = outarray + cnt1);
315 cnt +=
m_lines[n]->GetNcoeffs();
316 cnt1 +=
m_lines[n]->GetTotPoints();
327 int cnt = 0, cnt1 = 0;
328 Array<OneD, NekDouble> tmparray;
329 int nlines =
m_lines.num_elements();
331 for(
int n = 0; n < nlines; ++n)
333 m_lines[n]->IProductWRTBase(inarray+cnt, tmparray = outarray + cnt1,coeffstate);
335 cnt +=
m_lines[n]->GetNcoeffs();
336 cnt1 +=
m_lines[n]->GetTotPoints();
342 int cnt = 0, cnt1 = 0;
343 Array<OneD, NekDouble> tmparray;
344 int nlines =
m_lines.num_elements();
346 for(
int n = 0; n < nlines; ++n)
348 m_lines[n]->IProductWRTBase_IterPerExp(inarray+cnt, tmparray = outarray + cnt1);
350 cnt +=
m_lines[n]->GetNcoeffs();
351 cnt1 +=
m_lines[n]->GetTotPoints();
356 Array<OneD, NekDouble> &outarray,
365 int n =
m_lines.num_elements();
366 int s = inarray.num_elements();
369 Array<OneD, NekDouble> fft_in(s);
370 Array<OneD, NekDouble> fft_out(s);
376 for(
int i=0;i<(p*
m_nz);i++)
384 for(
int i=0;i<(p*
m_nz);i++)
394 for(
int i=0;i<(p*
m_ny);i++)
402 for(
int i=0;i<(p*
m_ny);i++)
446 int nrowsY = blkmatY->GetRows();
447 int ncolsY = blkmatY->GetColumns();
449 Array<OneD, NekDouble> sortedinarrayY(ncolsY);
450 Array<OneD, NekDouble> sortedoutarrayY(nrowsY);
452 int nrowsZ = blkmatZ->GetRows();
453 int ncolsZ = blkmatZ->GetColumns();
455 Array<OneD, NekDouble> sortedinarrayZ(ncolsZ);
456 Array<OneD, NekDouble> sortedoutarrayZ(nrowsZ);
466 outY = (*blkmatY)*inY;
470 outZ = (*blkmatZ)*inZ;
489 return matrixIter->second;
526 n_exp =
m_lines[0]->GetNcoeffs();
530 n_exp =
m_lines[0]->GetTotPoints();
533 Array<OneD,unsigned int> nrows(n_exp);
534 Array<OneD,unsigned int> ncols(n_exp);
539 nrows = Array<OneD, unsigned int>(n_exp*NumPencils,NumModes);
540 ncols = Array<OneD, unsigned int>(n_exp*NumPencils,NumPoints);
544 nrows = Array<OneD, unsigned int>(n_exp*NumPencils,NumPoints);
545 ncols = Array<OneD, unsigned int>(n_exp*NumPencils,NumModes);
557 StdSeg.DetShapeType(),
560 loc_mat = StdSeg.GetStdMatrix(matkey);
565 StdSeg.DetShapeType(),
568 loc_mat = StdSeg.GetStdMatrix(matkey);
572 for(i = 0; i < (n_exp*NumPencils); ++i)
574 BlkMatrix->SetBlock(i,i,loc_mat);
582 std::vector<LibUtilities::FieldDefinitionsSharedPtr> returnval;
584 Array<OneD,LibUtilities::BasisSharedPtr> HomoBasis(2);
588 std::vector<NekDouble> HomoLen(2);
592 m_lines[0]->GeneralGetFieldDefinitions(returnval, 2, HomoBasis, HomoLen);
599 Array<OneD,LibUtilities::BasisSharedPtr> HomoBasis(2);
602 std::vector<NekDouble> HomoLen(2);
607 m_lines[0]->GeneralGetFieldDefinitions(fielddef,2, HomoBasis,HomoLen);
617 int ncoeffs_per_line =
m_lines[0]->GetNcoeffs();
621 map<int, int> ElmtID_to_ExpID;
622 for(i = 0; i <
m_lines[0]->GetExpSize(); ++i)
624 ElmtID_to_ExpID[(*m_exp)[i]->GetGeom()->GetGlobalID()] = i;
627 for(i = 0; i < fielddef->m_elementIDs.size(); ++i)
629 int eid = ElmtID_to_ExpID[fielddef->m_elementIDs[i]];
630 int datalen = (*m_exp)[eid]->GetNcoeffs();
632 for(k = 0; k < (NumMod_y*NumMod_z); ++k)
634 fielddata.insert(fielddata.end(),&coeffs[
m_coeff_offset[eid]+k*ncoeffs_per_line],&coeffs[m_coeff_offset[eid]+k*ncoeffs_per_line]+datalen);
649 int datalen = fielddata.size()/fielddef->m_fields.size();
650 int ncoeffs_per_line =
m_lines[0]->GetNcoeffs();
655 for(i = 0; i < fielddef->m_fields.size(); ++i)
657 if(fielddef->m_fields[i] == field)
664 ASSERTL0(i!= fielddef->m_fields.size(),
"Field not found in data file");
668 map<int, int> ElmtID_to_ExpID;
669 for(i = 0; i <
m_lines[0]->GetExpSize(); ++i)
671 ElmtID_to_ExpID[(*m_exp)[i]->GetGeom()->GetGlobalID()] = i;
674 for(i = 0; i < fielddef->m_elementIDs.size(); ++i)
676 int eid = ElmtID_to_ExpID[fielddef->m_elementIDs[i]];
677 int datalen = (*m_exp)[eid]->GetNcoeffs();
679 for(k = 0; k < (NumMod_y*NumMod_z); ++k)
688 Array<OneD, NekDouble> &out_d0,
689 Array<OneD, NekDouble> &out_d1,
690 Array<OneD, NekDouble> &out_d2)
693 int nyzlines =
m_lines.num_elements();
694 int npoints = inarray.num_elements();
695 int n_points_line = npoints/nyzlines;
697 Array<OneD, NekDouble> temparray(npoints);
698 Array<OneD, NekDouble> temparray1(npoints);
699 Array<OneD, NekDouble> temparray2(npoints);
700 Array<OneD, NekDouble> tmp1;
701 Array<OneD, NekDouble> tmp2;
702 Array<OneD, NekDouble> tmp3;
704 for(
int i=0 ; i<nyzlines ; i++ )
706 m_lines[i]->PhysDeriv( tmp1 = inarray + i*n_points_line ,tmp2 = out_d0 + i*n_points_line);
723 for(
int i = 0; i <
m_ny; i++)
727 for(
int j = 0; j <
m_nz; j++)
729 Vmath::Smul(n_points_line,beta,tmp1 = temparray + n_points_line*(i+j*m_ny),1, tmp2 = temparray1 + n_points_line*((i-
int(sign))+j*m_ny),1);
737 for(
int i = 0; i <
m_nz; i++)
740 Vmath::Smul(m_ny*n_points_line,beta,tmp1 = temparray + i*m_ny*n_points_line,1,tmp2 = temparray2 + (i-
int(sign))*m_ny*n_points_line,1);
758 ASSERTL0(
false,
"Semi-phyisical time-stepping not implemented yet for non-Fourier basis")
766 for(
int i = 0; i < n_points_line; i++)
768 StdQuad.PhysDeriv(tmp1 = temparray + i*nyzlines, tmp2 = temparray1 + i*nyzlines, tmp3 = temparray2 + i*nyzlines);
780 const Array<OneD, const NekDouble> &inarray,
781 Array<OneD, NekDouble> &out_d)
784 int nyzlines =
m_lines.num_elements();
785 int npoints = inarray.num_elements();
786 int n_points_line = npoints/nyzlines;
790 Array<OneD, NekDouble> temparray(npoints);
791 Array<OneD, NekDouble> temparray1(npoints);
792 Array<OneD, NekDouble> temparray2(npoints);
793 Array<OneD, NekDouble> tmp1;
794 Array<OneD, NekDouble> tmp2;
795 Array<OneD, NekDouble> tmp3;
799 for(
int i=0 ; i<nyzlines ; i++)
801 m_lines[i]->PhysDeriv( tmp1 = inarray + i*n_points_line ,tmp2 = out_d + i*n_points_line);
822 for(
int i = 0; i <
m_ny; i++)
826 for(
int j = 0; j <
m_nz; j++)
828 Vmath::Smul(n_points_line,beta,tmp1 = temparray + n_points_line*(i+j*m_ny),1, tmp2 = temparray1 + n_points_line*((i-
int(sign))+j*m_ny),1);
844 for(
int i = 0; i <
m_nz; i++)
847 Vmath::Smul(
m_ny*n_points_line,beta,tmp1 = temparray + i*
m_ny*n_points_line,1,tmp2 = temparray2 + (i-
int(sign))*
m_ny*n_points_line,1);
864 ASSERTL0(
false,
"Semi-phyisical time-stepping not implemented yet for non-Fourier basis")
872 for(
int i = 0; i < n_points_line; i++)
874 StdQuad.PhysDeriv(tmp1 = temparray + i*nyzlines, tmp2 = temparray1 + i*nyzlines, tmp3 = temparray2 + i*nyzlines);
893 Array<OneD, NekDouble> &out_d0,
894 Array<OneD, NekDouble> &out_d1,
895 Array<OneD, NekDouble> &out_d2)
902 const Array<OneD, const NekDouble> &inarray,
903 Array<OneD, NekDouble> &out_d)
930 MatFwdPAD = StdQuad.GetStdMatrix(matkey1);
931 MatBwdPAD = StdQuad.GetStdMatrix(matkey2);