45 namespace MultiRegions
62 m_dealiasing(dealiasing)
88 ASSERTL0(
false,
"Dealiasing available just in combination "
100 m_transposition(In.m_transposition),
101 m_useFFT(In.m_useFFT),
104 m_tmpOUT(In.m_tmpOUT),
105 m_homogeneousBasis(In.m_homogeneousBasis),
107 m_homogeneous1DBlockMat(In.m_homogeneous1DBlockMat),
108 m_dealiasing(In.m_dealiasing),
109 m_padsize(In.m_padsize)
122 Array<OneD, NekDouble> &outarray,
132 Array<OneD, NekDouble> &outarray,
145 const Array<OneD, NekDouble> &inarray2,
146 Array<OneD, NekDouble> &outarray,
153 int num_dofs = inarray1.num_elements();
157 Array<OneD, NekDouble> V1(num_dofs);
158 Array<OneD, NekDouble> V2(num_dofs);
159 Array<OneD, NekDouble> V1V2(num_dofs);
164 int num_points_per_plane = num_dofs/
m_planes.num_elements();
165 int num_proc =
m_comm->GetColumnComm()->GetSize();
166 int num_dfts_per_proc = num_points_per_plane / num_proc
167 + (num_points_per_plane % num_proc > 0);
169 Array<OneD, NekDouble> ShufV1(num_dfts_per_proc*N,0.0);
170 Array<OneD, NekDouble> ShufV2(num_dfts_per_proc*N,0.0);
171 Array<OneD, NekDouble> ShufV1V2(num_dfts_per_proc*N,0.0);
173 Array<OneD, NekDouble> ShufV1_PAD_coef(
m_padsize,0.0);
174 Array<OneD, NekDouble> ShufV2_PAD_coef(
m_padsize,0.0);
175 Array<OneD, NekDouble> ShufV1_PAD_phys(
m_padsize,0.0);
176 Array<OneD, NekDouble> ShufV2_PAD_phys(
m_padsize,0.0);
178 Array<OneD, NekDouble> ShufV1V2_PAD_coef(
m_padsize,0.0);
179 Array<OneD, NekDouble> ShufV1V2_PAD_phys(
m_padsize,0.0);
185 for(
int i = 0 ; i < num_dfts_per_proc ; i++)
189 Vmath::Vcopy(N, &(ShufV1[i*N]), 1, &(ShufV1_PAD_coef[0]), 1);
190 Vmath::Vcopy(N, &(ShufV2[i*N]), 1, &(ShufV2_PAD_coef[0]), 1);
193 m_FFT_deal->FFTBwdTrans(ShufV1_PAD_coef, ShufV1_PAD_phys);
194 m_FFT_deal->FFTBwdTrans(ShufV2_PAD_coef, ShufV2_PAD_phys);
200 ShufV1V2_PAD_phys, 1);
204 m_FFT_deal->FFTFwdTrans(ShufV1V2_PAD_phys, ShufV1V2_PAD_coef);
209 &(ShufV1V2[i*N]), 1);
224 int cnt = 0, cnt1 = 0;
225 Array<OneD, NekDouble> tmparray;
227 for(
int n = 0; n <
m_planes.num_elements(); ++n)
229 m_planes[n]->FwdTrans(inarray+cnt, tmparray = outarray + cnt1,
246 int cnt = 0, cnt1 = 0;
247 Array<OneD, NekDouble> tmparray;
250 for(
int n = 0; n <
m_planes.num_elements(); ++n)
252 m_planes[n]->FwdTrans_IterPerExp(inarray+cnt, tmparray = outarray + cnt1);
267 int cnt = 0, cnt1 = 0;
268 Array<OneD, NekDouble> tmparray;
270 for(
int n = 0; n <
m_planes.num_elements(); ++n)
272 m_planes[n]->BwdTrans(inarray+cnt, tmparray = outarray + cnt1,
275 cnt1 +=
m_planes[n]->GetTotPoints();
288 int cnt = 0, cnt1 = 0;
289 Array<OneD, NekDouble> tmparray;
291 for(
int n = 0; n <
m_planes.num_elements(); ++n)
293 m_planes[n]->BwdTrans_IterPerExp(inarray+cnt, tmparray = outarray + cnt1);
296 cnt1 +=
m_planes[n]->GetTotPoints();
309 int cnt = 0, cnt1 = 0;
310 Array<OneD, NekDouble> tmparray;
312 for(
int n = 0; n <
m_planes.num_elements(); ++n)
314 m_planes[n]->IProductWRTBase(inarray+cnt, tmparray = outarray + cnt1,coeffstate);
326 int cnt = 0, cnt1 = 0;
327 Array<OneD, NekDouble> tmparray;
329 for(
int n = 0; n <
m_planes.num_elements(); ++n)
331 m_planes[n]->IProductWRTBase_IterPerExp(inarray+cnt, tmparray = outarray + cnt1);
351 num_dofs = inarray.num_elements();
355 num_dofs = outarray.num_elements();
361 int num_points_per_plane = num_dofs/
m_planes.num_elements();
362 int num_dfts_per_proc = num_points_per_plane/
m_comm->GetColumnComm()->GetSize() + (num_points_per_plane%
m_comm->GetColumnComm()->GetSize() > 0);
364 Array<OneD, NekDouble> fft_in (num_dfts_per_proc*
m_homogeneousBasis->GetNumPoints(),0.0);
365 Array<OneD, NekDouble> fft_out(num_dfts_per_proc*
m_homogeneousBasis->GetNumPoints(),0.0);
379 for(
int i = 0 ; i < num_dfts_per_proc ; i++)
386 for(
int i = 0 ; i < num_dfts_per_proc ; i++)
399 fft_out,1,outarray,1);
429 int nrows = blkmat->GetRows();
430 int ncols = blkmat->GetColumns();
432 Array<OneD, NekDouble> sortedinarray(ncols,0.0);
433 Array<OneD, NekDouble> sortedoutarray(nrows,0.0);
474 return matrixIter->second;
484 int num_trans_per_proc = 0;
494 n_exp =
m_planes[0]->GetTotPoints();
497 num_trans_per_proc = n_exp/
m_comm->GetColumnComm()->GetSize() + (n_exp%
m_comm->GetColumnComm()->GetSize() > 0);
499 Array<OneD,unsigned int> nrows(num_trans_per_proc);
500 Array<OneD,unsigned int> ncols(num_trans_per_proc);
504 nrows = Array<OneD, unsigned int>(num_trans_per_proc,
m_homogeneousBasis->GetNumModes());
505 ncols = Array<OneD, unsigned int>(num_trans_per_proc,
m_homogeneousBasis->GetNumPoints());
509 nrows = Array<OneD, unsigned int>(num_trans_per_proc,
m_homogeneousBasis->GetNumPoints());
510 ncols = Array<OneD, unsigned int>(num_trans_per_proc,
m_homogeneousBasis->GetNumModes());
525 StdPoint.DetShapeType(),
528 loc_mat = StdPoint.GetStdMatrix(matkey);
533 StdPoint.DetShapeType(),
536 loc_mat = StdPoint.GetStdMatrix(matkey);
547 StdSeg.DetShapeType(),
550 loc_mat = StdSeg.GetStdMatrix(matkey);
555 StdSeg.DetShapeType(),
558 loc_mat = StdSeg.GetStdMatrix(matkey);
564 for(
int i = 0; i < num_trans_per_proc; ++i)
566 BlkMatrix->SetBlock(i,i,loc_mat);
574 std::vector<LibUtilities::FieldDefinitionsSharedPtr> returnval;
579 std::vector<NekDouble> HomoLen;
580 HomoLen.push_back(
m_lhom);
582 std::vector<unsigned int> PlanesIDs;
584 for(
int i = 0; i <
m_planes.num_elements(); i++)
589 m_planes[0]->GeneralGetFieldDefinitions(returnval, 1, HomoBasis, HomoLen, PlanesIDs);
599 std::vector<NekDouble> HomoLen;
600 HomoLen.push_back(
m_lhom);
602 std::vector<unsigned int> PlanesIDs;
604 for(
int i = 0; i <
m_planes.num_elements(); i++)
610 m_planes[0]->GeneralGetFieldDefinitions(fielddef,1, HomoBasis,HomoLen,PlanesIDs);
623 int ncoeffs_per_plane =
m_planes[0]->GetNcoeffs();
627 map<int, int> ElmtID_to_ExpID;
628 for(i = 0; i <
m_planes[0]->GetExpSize(); ++i)
630 ElmtID_to_ExpID[(*m_exp)[i]->GetGeom()->GetGlobalID()] = i;
633 for(i = 0; i < fielddef->m_elementIDs.size(); ++i)
635 int eid = ElmtID_to_ExpID[fielddef->m_elementIDs[i]];
636 int datalen = (*m_exp)[eid]->GetNcoeffs();
638 for(n = 0; n <
m_planes.num_elements(); ++n)
640 fielddata.insert(fielddata.end(),&coeffs[
m_coeff_offset[eid]+n*ncoeffs_per_plane],&coeffs[m_coeff_offset[eid]+n*ncoeffs_per_plane]+datalen);
653 std::vector<NekDouble> &fielddata,
655 Array<OneD, NekDouble> &coeffs)
660 int datalen = fielddata.size()/fielddef->m_fields.size();
661 std::vector<unsigned int> fieldDefHomoZids;
665 for(i = 0; i < fielddef->m_fields.size(); ++i)
667 if(fielddef->m_fields[i] == field)
674 if(i == fielddef->m_fields.size())
676 cout <<
"Field "<< field<<
"not found in data file. " << endl;
681 int modes_offset = 0;
682 int planes_offset = 0;
683 Array<OneD, NekDouble> coeff_tmp;
688 std::map<int,int> homoZids;
689 for (i = 0; i <
m_planes.num_elements(); ++i)
694 if(fielddef->m_numHomogeneousDir)
696 for(i = 0; i < fielddef->m_basis.size(); ++i)
700 nzmodes = fielddef->m_homogeneousZIDs.size();
704 ASSERTL1(i != fielddef->m_basis.size(),
"Failed to determine number of Homogeneous modes");
706 fieldDefHomoZids = fielddef->m_homogeneousZIDs;
711 fieldDefHomoZids.push_back(0);
715 map<int, int> ElmtID_to_ExpID;
716 for(i = 0; i <
m_planes[0]->GetExpSize(); ++i)
718 ElmtID_to_ExpID[(*m_exp)[i]->GetGeom()->GetGlobalID()] = i;
723 int ncoeffs_per_plane =
m_planes[0]->GetNcoeffs();
725 for(i = 0; i < fielddef->m_elementIDs.size(); ++i)
727 if(fielddef->m_uniOrder ==
true)
733 fielddef->m_numModes,
736 it = ElmtID_to_ExpID.find(fielddef->m_elementIDs[i]);
739 if(it == ElmtID_to_ExpID.end())
742 offset += datalen*nzmodes;
746 int eid = it->second;
749 for(n = 0; n < nzmodes; ++n, offset += datalen)
752 it = homoZids.find(fieldDefHomoZids[n]);
755 if (it == homoZids.end())
760 planes_offset = it->second;
761 if(datalen == (*
m_exp)[eid]->GetNcoeffs())
767 (*m_exp)[eid]->ExtractDataToCoeffs(&fielddata[offset], fielddef->m_numModes,modes_offset,&coeffs[
m_coeff_offset[eid] + planes_offset*ncoeffs_per_plane]);
770 modes_offset += (*m_exp)[0]->GetNumBases();
777 const boost::shared_ptr<ExpList> &fromExpList,
const Array<OneD, const NekDouble> &fromCoeffs, Array<OneD, NekDouble> &toCoeffs)
780 int fromNcoeffs_per_plane = fromExpList->GetPlane(0)->GetNcoeffs();
781 Array<OneD, NekDouble> tocoeffs_tmp, fromcoeffs_tmp;
783 for(i = 0; i <
m_planes.num_elements(); ++i)
785 m_planes[i]->ExtractCoeffsToCoeffs(fromExpList->GetPlane(i),fromcoeffs_tmp = fromCoeffs + fromNcoeffs_per_plane*i, tocoeffs_tmp = toCoeffs +
m_ncoeffs*i);
793 int nq = (*m_exp)[expansion]->GetTotPoints();
794 int npoints_per_plane =
m_planes[0]->GetTotPoints();
797 outfile <<
" <DataArray type=\"Float32\" Name=\""
798 << var <<
"\">" << endl;
800 for (
int n = 0; n <
m_planes.num_elements(); ++n)
802 const Array<OneD, NekDouble> phys =
m_phys +
m_phys_offset[expansion] + n*npoints_per_plane;
803 for(i = 0; i < nq; ++i)
809 outfile <<
" </DataArray>" << endl;
815 Array<OneD, NekDouble> tmparray;
817 cnt1 =
m_planes[0]->Get1DScaledTotPoints(scale);
819 ASSERTL1(
m_planes.num_elements()*cnt1 <= outarray.num_elements(),
"size of outarray does not match internal estimage");
822 for(
int i = 0; i <
m_planes.num_elements(); i++)
825 m_planes[i]->PhysInterp1DScaled(scale,inarray+i*cnt,
826 tmparray = outarray+i*cnt1);
834 Array<OneD, NekDouble> tmparray;
835 cnt =
m_planes[0]->Get1DScaledTotPoints(scale);
838 ASSERTL1(
m_planes.num_elements()*cnt <= inarray.num_elements(),
"size of outarray does not match internal estimage");
841 for(
int i = 0; i <
m_planes.num_elements(); i++)
843 m_planes[i]->PhysGalerkinProjection1DScaled(scale,inarray+i*cnt,
844 tmparray = outarray+i*cnt1);
849 Array<OneD, NekDouble> &out_d0,
850 Array<OneD, NekDouble> &out_d1,
851 Array<OneD, NekDouble> &out_d2)
853 int nT_pts = inarray.num_elements();
854 int nP_pts = nT_pts/
m_planes.num_elements();
856 Array<OneD, NekDouble> temparray(nT_pts);
857 Array<OneD, NekDouble> outarray(nT_pts);
858 Array<OneD, NekDouble> tmp1;
859 Array<OneD, NekDouble> tmp2;
860 Array<OneD, NekDouble> tmp3;
862 for(
int i = 0; i <
m_planes.num_elements(); i++)
864 m_planes[i]->PhysDeriv(inarray + i*nP_pts ,tmp2 = out_d0 + i*nP_pts , tmp3 = out_d1 + i*nP_pts );
901 for(
int i = 0; i <
m_planes.num_elements(); i++)
905 Vmath::Smul(nP_pts,beta,tmp1 = temparray + i*nP_pts,1,tmp2 = outarray + (i-
int(sign))*nP_pts,1);
922 ASSERTL0(
m_comm->GetColumnComm()->GetSize() == 1,
"Parallelisation in the homogeneous direction implemented just for Fourier basis");
927 ASSERTL0(
false,
"Semi-phyisical time-stepping not implemented yet for non-Fourier basis");
935 for(
int i = 0; i < nP_pts; i++)
937 StdSeg.PhysDeriv(temparray + i*
m_planes.num_elements(), tmp2 = outarray + i*
m_planes.num_elements());
949 const Array<OneD, const NekDouble> &inarray, Array<OneD, NekDouble> &out_d)
952 int nT_pts = inarray.num_elements();
953 int nP_pts = nT_pts/
m_planes.num_elements();
957 Array<OneD, NekDouble> temparray(nT_pts);
958 Array<OneD, NekDouble> outarray(nT_pts);
959 Array<OneD, NekDouble> tmp1;
960 Array<OneD, NekDouble> tmp2;
964 for(
int i=0; i <
m_planes.num_elements(); i++)
966 m_planes[i]->PhysDeriv(edir, inarray + i*nP_pts ,tmp2 = out_d + i*nP_pts);
1002 for(
int i = 0; i <
m_planes.num_elements(); i++)
1006 Vmath::Smul(nP_pts,beta,tmp1 = temparray + i*nP_pts,1,tmp2 = outarray + (i-
int(sign))*nP_pts,1);
1022 ASSERTL0(
m_comm->GetColumnComm()->GetSize() == 1,
"Parallelisation in the homogeneous direction implemented just for Fourier basis");
1026 ASSERTL0(
false,
"Semi-phyisical time-stepping not implemented yet for non-Fourier basis");
1034 for(
int i = 0; i < nP_pts; i++)
1036 StdSeg.PhysDeriv(temparray + i*
m_planes.num_elements(), tmp2 = outarray + i*
m_planes.num_elements());
1048 Array<OneD, NekDouble> &out_d0,
1049 Array<OneD, NekDouble> &out_d1,
1050 Array<OneD, NekDouble> &out_d2)
1057 const Array<OneD, const NekDouble> &inarray,
1058 Array<OneD, NekDouble> &out_d)