51 "Block Relaxed Jacobi Preconditioner for CFS.");
62 size_t nvariables = pFields.size();
66 for (
size_t i = 0; i < nvariables; i++)
88 [[maybe_unused]]
const bool &flag)
98 const NekDouble OmBRJParam = 1.0 - BRJParam;
100 size_t nvariables = pFields.size();
101 size_t npoints = pFields[0]->GetNcoeffs();
102 size_t ntotpnt = inarray.size();
104 ASSERTL0(nvariables * npoints == ntotpnt,
105 "nvariables*npoints!=ntotpnt in PreconCoeff");
114 for (
size_t m = 0; m < nvariables; m++)
116 size_t moffset = m * npoints;
117 rhs2d[m] = rhs + moffset;
118 out_2d[m] = outarray + moffset;
119 outTmp_2d[m] = outTmp + moffset;
120 pFields[m]->MultiplyByMassMatrix(inarray + moffset, rhs2d[m]);
123 size_t nphysic = pFields[0]->GetNpoints();
124 size_t nTracePts = pFields[0]->GetTrace()->GetNpoints();
129 for (
size_t j = 0; j < nvariables; j++)
136 for (
size_t i = 0; i < ntmpTrace; i++)
139 for (
size_t j = 0; j < nvariables; j++)
146 for (
size_t j = 0; j < nvariables; j++)
152 const size_t nwspTraceDataType = nvariables + 1;
154 for (
size_t m = 0; m < nwspTraceDataType; m++)
165 for (
size_t nrelax = 0; nrelax < nBRJIterTot - 1; nrelax++)
167 Vmath::Smul(ntotpnt, OmBRJParam, outarray, 1, outN, 1);
180 Vmath::Svtvp(ntotpnt, BRJParam, outTmp, 1, outN, 1, outarray, 1);
197 int nvariables = pFields.size();
198 int nelmts = pFields[0]->GetNumElmts();
200 for (
int i = 0; i < nelmts; i++)
202 matdim[i] = pFields[0]->GetExp(i)->GetNcoeffs() * nvariables;
214 cout <<
" ## CalcuPreconMat " << endl;
220 const auto vecwidth = vec_t::width;
222 alignas(vec_t::alignment) std::array<NekSingle, vec_t::width> tmp;
224 for (
int ne = 0; ne < nelmts; ne++)
226 const auto nElmtDof = matdim[ne];
227 const auto nblocks = nElmtDof / vecwidth;
230 PreconMatSingle->GetBlockPtr(ne, ne)->GetRawPtr();
232 for (
int i1 = 0; i1 < nblocks; ++i1)
234 for (
int j = 0; j < nElmtDof; ++j)
236 for (
int i = 0; i < vecwidth; ++i)
238 tmp[i] = mmat[j + (i1 * vecwidth + i) * nElmtDof];
245 const auto endwidth = nElmtDof - nblocks * vecwidth;
250 for (
int j = 0; j < nElmtDof; ++j)
252 for (
int i = 0; i < endwidth; ++i)
254 tmp[i] = mmat[j + (nblocks * vecwidth + i) * nElmtDof];
257 for (
int i = endwidth; i < vecwidth; ++i)
290 [[maybe_unused]]
const bool &flag)
302 unsigned int nvariables = pFields.size();
304 int nTotElmt = pFields[0]->GetNumElmts();
307 const auto vecwidth = vec_t::width;
310 std::vector<vec_t, tinysimd::allocator<vec_t>> Sinarray(
m_max_nblocks);
311 std::vector<vec_t, tinysimd::allocator<vec_t>> Soutarray(
m_max_nElmtDof);
313 alignas(vec_t::alignment) std::array<NekSingle, vec_t::width> tmp;
315 for (
int ne = 0, cnt = 0, icnt = 0, icnt1 = 0; ne < nTotElmt; ne++)
317 const auto nElmtCoef = pFields[0]->GetNcoeffs(ne);
318 const auto nElmtDof = nElmtCoef * nvariables;
319 const auto nblocks = (nElmtDof % vecwidth) ? nElmtDof / vecwidth + 1
320 : nElmtDof / vecwidth;
324 for (
int j = 0; j < nblocks; ++j, icnt += vecwidth)
326 for (
int i = 0; i < vecwidth; ++i)
331 Sinarray[j].load(tmp.data());
336 vec_t in = Sinarray[0];
337 for (
int i = 0; i < nElmtDof; ++i)
343 for (
int n = 1; n < nblocks; ++n)
346 for (
int i = 0; i < nElmtDof; ++i)
354 for (
int i = 0; i < nElmtDof; ++i)
357 Soutarray[i].store(tmp.data());
361 for (
int j = 1; j < vecwidth; ++j)
369 icnt1 += nblocks * vecwidth;
376template <
typename DataType>
379 const size_t nvariables,
const size_t nCoeffs,
386 size_t nTracePts = pFields[0]->GetTrace()->GetNpoints();
387 size_t npoints = pFields[0]->GetNpoints();
391 for (
size_t i = 0; i < nvariables; i++)
394 pFields[i]->BwdTrans(outarray[i], outpnts[i]);
404 size_t indexwspTrace = 0;
405 Fwd = wspTrace[indexwspTrace], indexwspTrace++;
406 Bwd = wspTrace[indexwspTrace], indexwspTrace++;
407 FwdFlux = wspTrace[indexwspTrace], indexwspTrace++;
408 BwdFlux = wspTrace[indexwspTrace], indexwspTrace++;
411 for (
size_t i = 0; i < nvariables; ++i)
414 pFields[i]->GetFwdBwdTracePhys(outpnts[i], Fwd[i], Bwd[i]);
419 size_t indexwspTraceDataType = 0;
421 for (
size_t m = 0; m < nvariables; ++m)
423 Fwdarray[m] = wspTraceDataType[indexwspTraceDataType],
424 indexwspTraceDataType++;
427 Fwdreslt = wspTraceDataType[indexwspTraceDataType], indexwspTraceDataType++;
429 for (
size_t m = 0; m < nvariables; ++m)
431 for (
size_t i = 0; i < nTracePts; ++i)
433 Fwdarray[m][i] = DataType(Fwd[m][i]);
436 for (
size_t m = 0; m < nvariables; ++m)
439 for (
size_t n = 0; n < nvariables; ++n)
441 for (
size_t p = 0;
p < nTracePts; ++
p)
443 Fwdreslt[
p] += TraceJacArray[0][m][n][
p] * Fwdarray[n][
p];
446 for (
size_t i = 0; i < nTracePts; ++i)
452 for (
size_t m = 0; m < nvariables; ++m)
454 for (
size_t i = 0; i < nTracePts; ++i)
456 Fwdarray[m][i] = DataType(Bwd[m][i]);
459 for (
size_t m = 0; m < nvariables; ++m)
462 for (
size_t n = 0; n < nvariables; ++n)
464 for (
size_t p = 0;
p < nTracePts; ++
p)
466 Fwdreslt[
p] += TraceJacArray[1][m][n][
p] * Fwdarray[n][
p];
469 for (
size_t i = 0; i < nTracePts; ++i)
475 for (
size_t i = 0; i < nvariables; ++i)
479 pFields[i]->AddTraceIntegralToOffDiag(FwdFlux[i], BwdFlux[i],
485 for (
size_t i = 0; i < nvariables; ++i)
487 for (
size_t p = 0;
p < nCoeffs; ++
p)
498template <
typename TypeNekBlkMatSharedPtr>
505 size_t nvars = pFields.size();
506 size_t nelmts = pFields[0]->GetNumElmts();
509 for (
size_t i = 0; i < nelmts; i++)
511 nelmtcoef = pFields[0]->GetExp(i)->GetNcoeffs();
512 nelmtmatdim[i] = nelmtcoef * nscale;
515 for (
size_t i = 0; i < nvars; i++)
517 for (
size_t j = 0; j < nvars; j++)
#define ASSERTL0(condition, msg)
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
void AccumulateRegion(std::string, int iolevel=0)
Accumulate elapsed time for a region.
void DoCalcPreconMatBRJCoeff(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, SNekBlkMatSharedPtr > > &gmtxarray, SNekBlkMatSharedPtr &gmtVar, Array< OneD, SNekBlkMatSharedPtr > &TraceJac, Array< OneD, SNekBlkMatSharedPtr > &TraceJacDeriv, Array< OneD, Array< OneD, NekSingle > > &TraceJacDerivSign, TensorOfArray4D< NekSingle > &TraceJacArray, TensorOfArray4D< NekSingle > &TraceJacDerivArray, TensorOfArray5D< NekSingle > &TraceIPSymJacArray)
Array< OneD, SNekBlkMatSharedPtr > m_TraceJacSingle
void v_BuildPreconCfs(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const Array< OneD, const Array< OneD, NekDouble > > &intmp, const NekDouble time, const NekDouble lambda) override
void v_DoPreconCfs(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const bool &flag) override
TensorOfArray4D< NekSingle > m_TraceJacArraySingle
void MinusOffDiag2Rhs(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const size_t nvariables, const size_t nCoeffs, const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &outarray, TensorOfArray3D< NekDouble > &wspTrace, Array< OneD, Array< OneD, DataType > > &wspTraceDataType, const TensorOfArray4D< DataType > &TraceJacArray)
Array< OneD, Array< OneD, SNekBlkMatSharedPtr > > m_PreconMatVarsSingle
static std::string className
Name of the class.
Array< OneD, SNekBlkMatSharedPtr > m_TraceJacDerivSingle
unsigned int m_max_nblocks
Array< OneD, Array< OneD, NekSingle > > m_TraceJacDerivSignSingle
static PreconCfsSharedPtr create(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const LibUtilities::SessionReaderSharedPtr &pSession, const LibUtilities::CommSharedPtr &vComm)
Creates an instance of this class.
void v_InitObject() override
TensorOfArray4D< NekSingle > m_TraceJacDerivArraySingle
PreconCfsBRJ(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const LibUtilities::SessionReaderSharedPtr &pSession, const LibUtilities::CommSharedPtr &vComm)
unsigned int m_max_nElmtDof
void AllocatePreconBlkDiagCoeff(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, Array< OneD, Array< OneD, TypeNekBlkMatSharedPtr > > &gmtxarray, const int &nscale=1)
TensorOfArray5D< NekSingle > m_TraceIPSymJacArraySingle
std::vector< int > m_inputIdx
void AllocateNekBlkMatDig(SNekBlkMatSharedPtr &mat, const Array< OneD, unsigned int > nrow, const Array< OneD, unsigned int > ncol)
void AllocateSIMDPreconBlkMatDiag(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields)
This function creates the matrix structure for the block diagonal operator. It organizes the way that...
void PreconBlkDiag(const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const Array< OneD, NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
bool v_UpdatePreconMatCheck(const Array< OneD, const NekDouble > &res, const NekDouble dtLambda) override
std::vector< simd< NekSingle >, tinysimd::allocator< simd< NekSingle > > > m_sBlkDiagMat
void DoNullPrecon(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const bool &flag)
NekPreconCfsOperators m_operator
NekDouble m_DtLambdaPreconMat
LibUtilities::CommSharedPtr m_Comm
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
PreconCfsFactory & GetPreconCfsFactory()
Declaration of the boundary condition factory singleton.
std::shared_ptr< SNekBlkMat > SNekBlkMatSharedPtr
tinysimd::simd< NekDouble > vec_t
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 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 Fill(int n, const T alpha, T *x, const int incx)
Fill a vector with a constant value.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
typename abi< ScalarType, width >::type simd