39#include <MatrixFreeOps/Operator.hpp>
95 unsigned int nmodes =
m_expList[0]->GetNcoeffs();
96 unsigned int nphys =
m_expList[0]->GetTotPoints();
113 m_expList[n]->GeneralMatrixOp(entry0 + n * nmodes,
114 tmp = entry1 + n * nmodes, mkey);
151 vector<LocalRegions::ExpansionSharedPtr> pCollExp,
153 :
Operator(pCollExp, pGeomData, factors),
157 m_dim = pCollExp[0]->GetNumBases();
167OperatorKey LinearAdvectionDiffusionReaction_NoCollection::m_typeArr[] = {
171 LinearAdvectionDiffusionReaction_NoCollection::create,
172 "LinearAdvectionDiffusionReaction_NoCollection_Seg"),
176 LinearAdvectionDiffusionReaction_NoCollection::create,
177 "LinearAdvectionDiffusionReaction_NoCollection_Tri"),
181 LinearAdvectionDiffusionReaction_NoCollection::create,
182 "LinearAdvectionDiffusionReaction_NoCollection_NodalTri"),
186 LinearAdvectionDiffusionReaction_NoCollection::create,
187 "LinearAdvectionDiffusionReaction_NoCollection_Quad"),
191 LinearAdvectionDiffusionReaction_NoCollection::create,
192 "LinearAdvectionDiffusionReaction_NoCollection_Tet"),
196 LinearAdvectionDiffusionReaction_NoCollection::create,
197 "LinearAdvectionDiffusionReaction_NoCollection_NodalTet"),
201 LinearAdvectionDiffusionReaction_NoCollection::create,
202 "LinearAdvectionDiffusionReaction_NoCollection_Pyr"),
206 LinearAdvectionDiffusionReaction_NoCollection::create,
207 "LinearAdvectionDiffusionReaction_NoCollection_Prism"),
211 LinearAdvectionDiffusionReaction_NoCollection::create,
212 "LinearAdvectionDiffusionReaction_NoCollection_NodalPrism"),
216 LinearAdvectionDiffusionReaction_NoCollection::create,
217 "LinearAdvectionDiffusionReaction_NoCollection_Hex")};
238 const int nCoeffs =
m_stdExp->GetNcoeffs();
239 const int nPhys =
m_stdExp->GetTotPoints();
242 "input array size is insufficient");
244 "output array size is insufficient");
253 dtmp[i - 1] = wsp + i * nPhys;
254 tmp[i - 1] = wsp + (i +
m_coordim) * nPhys;
260 m_stdExp->BwdTrans(input + i * nCoeffs, tmpphys);
263 m_stdExp->PhysDeriv(tmpphys, dtmp[0], dtmp[1], dtmp[2]);
274 &dtmp[0][0], 1, &tmp[j][0], 1);
276 for (
int k = 1; k <
m_dim; ++k)
281 &dtmp[k][0], 1, &tmp[j][0], 1, &tmp[j][0], 1);
292 for (
int k = 1; k <
m_dim; ++k)
295 &dtmp[k][0], 1, &tmp[j][0], 1, &tmp[j][0],
310 tmpphys, 1, tmpphys, 1);
325 m_stdExp->IProductWRTBase(tmpphys, t1 = output + i * nCoeffs);
333 for (
int j = 0; j <
m_dim; ++j)
336 &tmp[0][0], 1, &dtmp[j][0], 1);
343 &tmp[k][0], 1, &dtmp[j][0], 1, &dtmp[j][0], 1);
348 for (
int j = 0; j <
m_dim; ++j)
355 m_stdExp->IProductWRTDerivBase(j, dtmp[j], tmp[0]);
356 Vmath::Vadd(nCoeffs, tmp[0], 1, output + i * nCoeffs, 1,
357 t1 = output + i * nCoeffs, 1);
362 for (
int j = 0; j <
m_dim; ++j)
370 &tmp[k][0], 1, &dtmp[j][0], 1, &dtmp[j][0],
376 for (
int j = 0; j <
m_dim; ++j)
381 m_stdExp->IProductWRTDerivBase(j, dtmp[j], tmp[0]);
382 Vmath::Vadd(nCoeffs, tmp[0], 1, output + i * nCoeffs, 1,
383 t1 = output + i * nCoeffs, 1);
410 "Constant factor not defined: " +
425 if (varcoeffs.empty())
434 if (varcoeffs.count(x))
439 ASSERTL0(ndir,
"Must define at least one advection velocity");
441 "Number of constants is larger than coordinate dimensions");
469 vector<LocalRegions::ExpansionSharedPtr> pCollExp,
471 :
Operator(pCollExp, pGeomData, factors),
474 m_dim = pCollExp[0]->GetShapeDimension();
476 int nqtot =
m_stdExp->GetTotPoints();
478 m_derivFac = pGeomData->GetDerivFactors(pCollExp);
479 m_jac = pGeomData->GetJac(pCollExp);
492OperatorKey LinearAdvectionDiffusionReaction_IterPerExp::m_typeArr[] = {
496 LinearAdvectionDiffusionReaction_IterPerExp::create,
497 "LinearAdvectionDiffusionReaction_IterPerExp_Seg"),
501 LinearAdvectionDiffusionReaction_IterPerExp::create,
502 "LinearAdvectionDiffusionReaction_IterPerExp_Tri"),
506 LinearAdvectionDiffusionReaction_IterPerExp::create,
507 "LinearAdvectionDiffusionReaction_IterPerExp_NodalTri"),
511 LinearAdvectionDiffusionReaction_IterPerExp::create,
512 "LinearAdvectionDiffusionReaction_IterPerExp_Quad"),
516 LinearAdvectionDiffusionReaction_IterPerExp::create,
517 "LinearAdvectionDiffusionReaction_IterPerExp_Tet"),
521 LinearAdvectionDiffusionReaction_IterPerExp::create,
522 "LinearAdvectionDiffusionReaction_IterPerExp_NodalTet"),
526 LinearAdvectionDiffusionReaction_IterPerExp::create,
527 "LinearAdvectionDiffusionReaction_IterPerExp_Pyr"),
531 LinearAdvectionDiffusionReaction_IterPerExp::create,
532 "LinearAdvectionDiffusionReaction_IterPerExp_Prism"),
536 LinearAdvectionDiffusionReaction_IterPerExp::create,
537 "LinearAdvectionDiffusionReaction_IterPerExp_NodalPrism"),
541 LinearAdvectionDiffusionReaction_IterPerExp::create,
542 "LinearAdvectionDiffusionReaction_IterPerExp_Hex")};
564 (*m_oper)(input, output0);
586 "Constant factor not defined: " +
589 m_oper->SetLambda(-1 * x->second);
601 if (varcoeffs.empty())
621 StdRegions::VarCoeffMap::const_iterator x, y;
622 for (x =
m_varcoeffs.begin(), y = varcoeffs.begin();
625 if (x->second.GetHash() < y->second.GetHash())
630 if (x->second.GetHash() > y->second.GetHash())
654 ASSERTL0(ndir,
"Must define at least one advection velocity");
656 "Number of coordingates is larger than number of constants "
657 "provided (ndir = " +
658 std::to_string(ndir) +
659 ", m_coordim = " + std::to_string(
m_coordim) +
")");
670 Vmath::Smul(advVel[i].size(), -1 / lambda->second, advVel[i], 1,
677 typedef std::vector<vec_t, tinysimd::allocator<vec_t>>
VecVec_t;
683 "Number of elements not divisible by vector "
684 "width, padding not yet implemented.");
686 int nBlocks = nElmt / vec_t::width;
689 alignas(vec_t::alignment)
NekDouble vec[vec_t::width];
697 newAdvVel.resize(nBlocks * n_vel * nq);
698 auto *advVel_ptr = &newAdvVel[0];
699 for (
int e = 0; e < nBlocks; ++e)
701 for (
int q = 0; q < nq; q++)
703 for (
int dir = 0; dir < n_vel; ++dir, ++advVel_ptr)
705 for (
int j = 0; j < vec_t::width; ++j)
707 if ((vec_t::width * e + j) * nq + q < totalsize)
710 advVel[dir][(vec_t::width * e + j) * nq + q];
717 (*advVel_ptr).load(&vec[0]);
722 m_oper->SetAdvectionVelocities(
727 std::shared_ptr<MatrixFree::LinearAdvectionDiffusionReaction>
m_oper;
738 vector<LocalRegions::ExpansionSharedPtr> pCollExp,
740 :
Operator(pCollExp, pGeomData, factors),
741 MatrixFreeBase(pCollExp[0]->GetNcoeffs(), pCollExp[0]->GetNcoeffs(),
747 const auto dim = pCollExp[0]->GetShapeDimension();
751 std::vector<LibUtilities::BasisSharedPtr> basis(dim);
752 for (
auto i = 0; i < dim; ++i)
754 basis[i] = pCollExp[0]->GetBasis(i);
758 auto shapeType = pCollExp[0]->DetShapeType();
761 std::string op_string =
"LinearAdvectionDiffusionReaction";
762 op_string += MatrixFree::GetOpstring(shapeType,
m_isDeformed);
763 auto oper = MatrixFree::GetOperatorFactory().CreateInstance(
764 op_string, basis, pCollExp.size());
770 oper->SetUpBdata(basis);
771 oper->SetUpDBdata(basis);
773 oper->SetUpZW(basis);
776 oper->SetJac(pGeomData->GetJacInterLeave(pCollExp,
m_nElmtPad));
779 oper->SetDF(pGeomData->GetDerivFactorsInterLeave(pCollExp,
m_nElmtPad));
781 m_oper = std::dynamic_pointer_cast<
782 MatrixFree::LinearAdvectionDiffusionReaction>(oper);
794OperatorKey LinearAdvectionDiffusionReaction_MatrixFree::m_typeArr[] = {
798 LinearAdvectionDiffusionReaction_MatrixFree::create,
799 "LinearAdvectionDiffusionReaction_MatrixFree_Quad"),
803 LinearAdvectionDiffusionReaction_MatrixFree::create,
804 "LinearAdvectionDiffusionReaction_MatrixFree_Tri"),
808 LinearAdvectionDiffusionReaction_MatrixFree::create,
809 "LinearAdvectionDiffusionReaction_MatrixFree_Hex"),
813 LinearAdvectionDiffusionReaction_MatrixFree::create,
814 "LinearAdvectionDiffusionReaction_MatrixFree_Prism"),
818 LinearAdvectionDiffusionReaction_MatrixFree::create,
819 "LinearAdvectionDiffusionReaction_MatrixFree_Pyr"),
823 LinearAdvectionDiffusionReaction_MatrixFree::create,
824 "LinearAdvectionDiffusionReaction_MatrixFree_Tet"),
#define ASSERTL0(condition, msg)
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
#define OPERATOR_CREATE(cname)
LinearAdvectionDiffusionReaction help class to calculate the size of the collection that is given as ...
LinearAdvectionDiffusionReaction_Helper()
LinearAdvectionDiffusionReaction operator using LocalRegions implementation.
void UpdateFactors(StdRegions::FactorMap factors) override
Check the validity of supplied constant factors.
LinearAdvectionDiffusionReaction_IterPerExp(vector< LocalRegions::ExpansionSharedPtr > pCollExp, CoalescedGeomDataSharedPtr pGeomData, StdRegions::FactorMap factors)
Array< OneD, Array< OneD, NekDouble > > m_advVel
StdRegions::VarCoeffMap m_varcoeffs
void UpdateVarcoeffs(StdRegions::VarCoeffMap &varcoeffs) override
Check whether necessary advection velocities are supplied and copy into local array for operator.
const StdRegions::VarCoeffType advVelTypes[3]
Array< OneD, const NekDouble > m_jac
StdRegions::FactorMap m_factors
Array< TwoD, const NekDouble > m_derivFac
~LinearAdvectionDiffusionReaction_IterPerExp() final=default
void operator()(int dir, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp) final
void operator()(int dir, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp) final
LinearAdvectionDiffusionReaction_MatrixFree(vector< LocalRegions::ExpansionSharedPtr > pCollExp, CoalescedGeomDataSharedPtr pGeomData, StdRegions::FactorMap factors)
void UpdateVarcoeffs(StdRegions::VarCoeffMap &varcoeffs) override
Check whether necessary advection velocities are supplied, interleave and copy into vectorised contai...
const StdRegions::VarCoeffType advVelTypes[3]
StdRegions::FactorMap m_factors
StdRegions::VarCoeffMap m_varcoeffs
std::shared_ptr< MatrixFree::LinearAdvectionDiffusionReaction > m_oper
void UpdateFactors(StdRegions::FactorMap factors) override
Update the supplied factor map.
~LinearAdvectionDiffusionReaction_MatrixFree() final=default
LinearAdvectionDiffusionReaction operator using LocalRegions implementation.
void UpdateVarcoeffs(StdRegions::VarCoeffMap &varcoeffs) override
Check whether necessary advection velocities are supplied and copy into local member for varcoeff map...
StdRegions::VarCoeffMap m_varcoeffs
~LinearAdvectionDiffusionReaction_NoCollection() final=default
void UpdateFactors(StdRegions::FactorMap factors) override
Update the supplied factor map.
vector< LocalRegions::ExpansionSharedPtr > m_expList
void operator()(int dir, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp) final
StdRegions::FactorMap m_factors
LinearAdvectionDiffusionReaction_NoCollection(vector< LocalRegions::ExpansionSharedPtr > pCollExp, CoalescedGeomDataSharedPtr pGeomData, StdRegions::FactorMap factors)
unsigned int m_nElmtPad
size after padding
Base class for operators on a collection of elements.
StdRegions::StdExpansionSharedPtr m_stdExp
unsigned int m_numElmt
number of elements that the operator is applied on
unsigned int m_outputSize
number of modes or quadrature points that are taken as output from an operator
unsigned int m_inputSize
number of modes or quadrature points that are passed as input to an operator
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
std::vector< vec_t, tinysimd::allocator< vec_t > > VecVec_t
@ eLinearAdvectionDiffusionReaction
std::tuple< LibUtilities::ShapeType, OperatorType, ImplementationType, ExpansionIsNodal > OperatorKey
Key for describing an Operator.
std::shared_ptr< CoalescedGeomData > CoalescedGeomDataSharedPtr
OperatorFactory & GetOperatorFactory()
Returns the singleton Operator factory object.
static FactorMap NullFactorMap
const char *const ConstFactorTypeMap[]
@ eLinearAdvectionDiffusionReaction
VarCoeffMap RestrictCoeffMap(const VarCoeffMap &m, size_t offset, size_t cnt)
static VarCoeffMap NullVarCoeffMap
std::map< StdRegions::VarCoeffType, VarCoeffEntry > VarCoeffMap
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 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 Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*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.
typename abi< ScalarType, width >::type simd