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")};
574 (*m_oper)(input, output0);
597 "Constant factor not defined: " +
600 m_oper->SetLambda(-1 * x->second);
612 if (varcoeffs.empty())
632 StdRegions::VarCoeffMap::const_iterator x, y;
633 for (x =
m_varcoeffs.begin(), y = varcoeffs.begin();
636 if (x->second.GetHash() < y->second.GetHash())
641 if (x->second.GetHash() > y->second.GetHash())
665 ASSERTL0(ndir,
"Must define at least one advection velocity");
667 "Number of constants is larger than coordinate dimensions");
678 Vmath::Smul(advVel[i].size(), -1 / lambda->second, advVel[i], 1,
685 typedef std::vector<vec_t, tinysimd::allocator<vec_t>>
VecVec_t;
691 "Number of elements not divisible by vector "
692 "width, padding not yet implemented.");
694 int nBlocks = nElmt / vec_t::width;
697 alignas(vec_t::alignment)
NekDouble vec[vec_t::width];
705 newAdvVel.resize(nBlocks * n_vel * nq);
706 auto *advVel_ptr = &newAdvVel[0];
707 for (
int e = 0; e < nBlocks; ++e)
709 for (
int q = 0;
q < nq;
q++)
711 for (
int dir = 0; dir < n_vel; ++dir, ++advVel_ptr)
713 for (
int j = 0; j < vec_t::width; ++j)
715 if ((vec_t::width * e + j) * nq +
q < totalsize)
718 advVel[dir][(vec_t::width * e + j) * nq +
q];
725 (*advVel_ptr).load(&vec[0]);
730 m_oper->SetAdvectionVelocities(
735 std::shared_ptr<MatrixFree::LinearAdvectionDiffusionReaction>
m_oper;
746 vector<StdRegions::StdExpansionSharedPtr> pCollExp,
750 pCollExp[0]->GetStdExp()->GetNcoeffs(),
756 const auto dim = pCollExp[0]->GetStdExp()->GetShapeDimension();
760 std::vector<LibUtilities::BasisSharedPtr> basis(dim);
761 for (
auto i = 0; i < dim; ++i)
763 basis[i] = pCollExp[0]->GetBasis(i);
767 auto shapeType = pCollExp[0]->GetStdExp()->DetShapeType();
770 std::string op_string =
"LinearAdvectionDiffusionReaction";
771 op_string += MatrixFree::GetOpstring(shapeType,
m_isDeformed);
779 oper->SetJac(pGeomData->GetJacInterLeave(pCollExp,
m_nElmtPad));
782 oper->SetDF(pGeomData->GetDerivFactorsInterLeave(pCollExp,
m_nElmtPad));
784 m_oper = std::dynamic_pointer_cast<
785 MatrixFree::LinearAdvectionDiffusionReaction>(oper);
797OperatorKey LinearAdvectionDiffusionReaction_MatrixFree::m_typeArr[] = {
801 LinearAdvectionDiffusionReaction_MatrixFree::create,
802 "LinearAdvectionDiffusionReaction_MatrixFree_Quad"),
806 LinearAdvectionDiffusionReaction_MatrixFree::create,
807 "LinearAdvectionDiffusionReaction_MatrixFree_Tri"),
811 LinearAdvectionDiffusionReaction_MatrixFree::create,
812 "LinearAdvectionDiffusionReaction_MatrixFree_Hex"),
816 LinearAdvectionDiffusionReaction_MatrixFree::create,
817 "LinearAdvectionDiffusionReaction_MatrixFree_Prism"),
821 LinearAdvectionDiffusionReaction_MatrixFree::create,
822 "LinearAdvectionDiffusionReaction_MatrixFree_Pyr"),
826 LinearAdvectionDiffusionReaction_MatrixFree::create,
827 "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)
bool m_isPadded
flag for padding
unsigned int m_nElmtPad
size after padding
Array< OneD, NekDouble > m_output
Array< OneD, NekDouble > m_input
padded input/output vectors
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.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
typename abi< ScalarType, width >::type simd