39#include <MatrixFreeOps/Operator.hpp>
96 unsigned int nmodes =
m_expList[0]->GetNcoeffs();
97 unsigned int nphys =
m_expList[0]->GetTotPoints();
114 m_expList[n]->GeneralMatrixOp(entry0 + n * nmodes,
115 tmp = entry1 + n * nmodes, mkey);
152 vector<StdRegions::StdExpansionSharedPtr> pCollExp,
158 m_dim = pCollExp[0]->GetNumBases();
168OperatorKey LinearAdvectionDiffusionReaction_NoCollection::m_typeArr[] = {
172 LinearAdvectionDiffusionReaction_NoCollection::create,
173 "LinearAdvectionDiffusionReaction_NoCollection_Seg"),
177 LinearAdvectionDiffusionReaction_NoCollection::create,
178 "LinearAdvectionDiffusionReaction_NoCollection_Tri"),
182 LinearAdvectionDiffusionReaction_NoCollection::create,
183 "LinearAdvectionDiffusionReaction_NoCollection_NodalTri"),
187 LinearAdvectionDiffusionReaction_NoCollection::create,
188 "LinearAdvectionDiffusionReaction_NoCollection_Quad"),
192 LinearAdvectionDiffusionReaction_NoCollection::create,
193 "LinearAdvectionDiffusionReaction_NoCollection_Tet"),
197 LinearAdvectionDiffusionReaction_NoCollection::create,
198 "LinearAdvectionDiffusionReaction_NoCollection_NodalTet"),
202 LinearAdvectionDiffusionReaction_NoCollection::create,
203 "LinearAdvectionDiffusionReaction_NoCollection_Pyr"),
207 LinearAdvectionDiffusionReaction_NoCollection::create,
208 "LinearAdvectionDiffusionReaction_NoCollection_Prism"),
212 LinearAdvectionDiffusionReaction_NoCollection::create,
213 "LinearAdvectionDiffusionReaction_NoCollection_NodalPrism"),
217 LinearAdvectionDiffusionReaction_NoCollection::create,
218 "LinearAdvectionDiffusionReaction_NoCollection_Hex")};
239 const int nCoeffs =
m_stdExp->GetNcoeffs();
240 const int nPhys =
m_stdExp->GetTotPoints();
243 "input array size is insufficient");
245 "output array size is insufficient");
254 dtmp[i - 1] = wsp + i * nPhys;
255 tmp[i - 1] = wsp + (i +
m_coordim) * nPhys;
261 m_stdExp->BwdTrans(input + i * nCoeffs, tmpphys);
264 m_stdExp->PhysDeriv(tmpphys, dtmp[0], dtmp[1], dtmp[2]);
275 &dtmp[0][0], 1, &tmp[j][0], 1);
277 for (
int k = 1; k <
m_dim; ++k)
282 &dtmp[k][0], 1, &tmp[j][0], 1, &tmp[j][0], 1);
293 for (
int k = 1; k <
m_dim; ++k)
296 &dtmp[k][0], 1, &tmp[j][0], 1, &tmp[j][0],
311 tmpphys, 1, tmpphys, 1);
326 m_stdExp->IProductWRTBase(tmpphys, t1 = output + i * nCoeffs);
334 for (
int j = 0; j <
m_dim; ++j)
337 &tmp[0][0], 1, &dtmp[j][0], 1);
344 &tmp[k][0], 1, &dtmp[j][0], 1, &dtmp[j][0], 1);
349 for (
int j = 0; j <
m_dim; ++j)
356 m_stdExp->IProductWRTDerivBase(j, dtmp[j], tmp[0]);
357 Vmath::Vadd(nCoeffs, tmp[0], 1, output + i * nCoeffs, 1,
358 t1 = output + i * nCoeffs, 1);
363 for (
int j = 0; j <
m_dim; ++j)
371 &tmp[k][0], 1, &dtmp[j][0], 1, &dtmp[j][0],
377 for (
int j = 0; j <
m_dim; ++j)
382 m_stdExp->IProductWRTDerivBase(j, dtmp[j], tmp[0]);
383 Vmath::Vadd(nCoeffs, tmp[0], 1, output + i * nCoeffs, 1,
384 t1 = output + i * nCoeffs, 1);
411 "Constant factor not defined: " +
426 if (varcoeffs.empty())
435 if (varcoeffs.count(x))
440 ASSERTL0(ndir,
"Must define at least one advection velocity");
442 "Number of constants is larger than coordinate dimensions");
470 vector<StdRegions::StdExpansionSharedPtr> pCollExp,
475 m_dim = pCollExp[0]->GetShapeDimension();
477 int nqtot =
m_stdExp->GetTotPoints();
479 m_derivFac = pGeomData->GetDerivFactors(pCollExp);
480 m_jac = pGeomData->GetJac(pCollExp);
493OperatorKey LinearAdvectionDiffusionReaction_IterPerExp::m_typeArr[] = {
497 LinearAdvectionDiffusionReaction_IterPerExp::create,
498 "LinearAdvectionDiffusionReaction_IterPerExp_Seg"),
502 LinearAdvectionDiffusionReaction_IterPerExp::create,
503 "LinearAdvectionDiffusionReaction_IterPerExp_Tri"),
507 LinearAdvectionDiffusionReaction_IterPerExp::create,
508 "LinearAdvectionDiffusionReaction_IterPerExp_NodalTri"),
512 LinearAdvectionDiffusionReaction_IterPerExp::create,
513 "LinearAdvectionDiffusionReaction_IterPerExp_Quad"),
517 LinearAdvectionDiffusionReaction_IterPerExp::create,
518 "LinearAdvectionDiffusionReaction_IterPerExp_Tet"),
522 LinearAdvectionDiffusionReaction_IterPerExp::create,
523 "LinearAdvectionDiffusionReaction_IterPerExp_NodalTet"),
527 LinearAdvectionDiffusionReaction_IterPerExp::create,
528 "LinearAdvectionDiffusionReaction_IterPerExp_Pyr"),
532 LinearAdvectionDiffusionReaction_IterPerExp::create,
533 "LinearAdvectionDiffusionReaction_IterPerExp_Prism"),
537 LinearAdvectionDiffusionReaction_IterPerExp::create,
538 "LinearAdvectionDiffusionReaction_IterPerExp_NodalPrism"),
542 LinearAdvectionDiffusionReaction_IterPerExp::create,
543 "LinearAdvectionDiffusionReaction_IterPerExp_Hex")};
565 (*m_oper)(input, output0);
587 "Constant factor not defined: " +
590 m_oper->SetLambda(-1 * x->second);
602 if (varcoeffs.empty())
622 StdRegions::VarCoeffMap::const_iterator x, y;
623 for (x =
m_varcoeffs.begin(), y = varcoeffs.begin();
626 if (x->second.GetHash() < y->second.GetHash())
631 if (x->second.GetHash() > y->second.GetHash())
655 ASSERTL0(ndir,
"Must define at least one advection velocity");
657 "Number of constants is larger than coordinate dimensions");
668 Vmath::Smul(advVel[i].size(), -1 / lambda->second, advVel[i], 1,
675 typedef std::vector<vec_t, tinysimd::allocator<vec_t>>
VecVec_t;
681 "Number of elements not divisible by vector "
682 "width, padding not yet implemented.");
684 int nBlocks = nElmt / vec_t::width;
687 alignas(vec_t::alignment)
NekDouble vec[vec_t::width];
695 newAdvVel.resize(nBlocks * n_vel * nq);
696 auto *advVel_ptr = &newAdvVel[0];
697 for (
int e = 0; e < nBlocks; ++e)
699 for (
int q = 0;
q < nq;
q++)
701 for (
int dir = 0; dir < n_vel; ++dir, ++advVel_ptr)
703 for (
int j = 0; j < vec_t::width; ++j)
705 if ((vec_t::width * e + j) * nq +
q < totalsize)
708 advVel[dir][(vec_t::width * e + j) * nq +
q];
715 (*advVel_ptr).load(&vec[0]);
720 m_oper->SetAdvectionVelocities(
725 std::shared_ptr<MatrixFree::LinearAdvectionDiffusionReaction>
m_oper;
736 vector<StdRegions::StdExpansionSharedPtr> pCollExp,
740 pCollExp[0]->GetStdExp()->GetNcoeffs(),
746 const auto dim = pCollExp[0]->GetStdExp()->GetShapeDimension();
750 std::vector<LibUtilities::BasisSharedPtr> basis(dim);
751 for (
auto i = 0; i < dim; ++i)
753 basis[i] = pCollExp[0]->GetBasis(i);
757 auto shapeType = pCollExp[0]->GetStdExp()->DetShapeType();
760 std::string op_string =
"LinearAdvectionDiffusionReaction";
761 op_string += MatrixFree::GetOpstring(shapeType,
m_isDeformed);
763 op_string, basis, pCollExp.size());
769 oper->SetUpBdata(basis);
770 oper->SetUpDBdata(basis);
772 oper->SetUpZW(basis);
775 oper->SetJac(pGeomData->GetJacInterLeave(pCollExp,
m_nElmtPad));
778 oper->SetDF(pGeomData->GetDerivFactorsInterLeave(pCollExp,
m_nElmtPad));
780 m_oper = std::dynamic_pointer_cast<
781 MatrixFree::LinearAdvectionDiffusionReaction>(oper);
793OperatorKey LinearAdvectionDiffusionReaction_MatrixFree::m_typeArr[] = {
797 LinearAdvectionDiffusionReaction_MatrixFree::create,
798 "LinearAdvectionDiffusionReaction_MatrixFree_Quad"),
802 LinearAdvectionDiffusionReaction_MatrixFree::create,
803 "LinearAdvectionDiffusionReaction_MatrixFree_Tri"),
807 LinearAdvectionDiffusionReaction_MatrixFree::create,
808 "LinearAdvectionDiffusionReaction_MatrixFree_Hex"),
812 LinearAdvectionDiffusionReaction_MatrixFree::create,
813 "LinearAdvectionDiffusionReaction_MatrixFree_Prism"),
817 LinearAdvectionDiffusionReaction_MatrixFree::create,
818 "LinearAdvectionDiffusionReaction_MatrixFree_Pyr"),
822 LinearAdvectionDiffusionReaction_MatrixFree::create,
823 "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< StdRegions::StdExpansionSharedPtr > 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
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_MatrixFree(vector< StdRegions::StdExpansionSharedPtr > pCollExp, CoalescedGeomDataSharedPtr pGeomData, StdRegions::FactorMap factors)
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...
vector< StdRegions::StdExpansionSharedPtr > m_expList
StdRegions::VarCoeffMap m_varcoeffs
~LinearAdvectionDiffusionReaction_NoCollection() final=default
void UpdateFactors(StdRegions::FactorMap factors) override
Update the supplied factor map.
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< StdRegions::StdExpansionSharedPtr > 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_outputSizeOther
Number of modes or quadrature points, opposite to m_outputSize.
unsigned int m_numElmt
number of elements that the operator is applied on
unsigned int m_inputSizeOther
Number of modes or quadrature points, opposite to m_inputSize.
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.
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
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.
const NekPoint< NekDouble > origin
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
std::vector< double > q(NPUPPER *NPUPPER)
StdRegions::ConstFactorMap factors
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