Nektar++
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
Nektar::Collections::PhysDeriv_SumFac_Tri Class Referencefinal

Phys deriv operator using sum-factorisation (Tri) More...

Inheritance diagram for Nektar::Collections::PhysDeriv_SumFac_Tri:
[legend]

Public Member Functions

 ~PhysDeriv_SumFac_Tri () final=default
 
void operator() (const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output0, Array< OneD, NekDouble > &output1, Array< OneD, NekDouble > &output2, Array< OneD, NekDouble > &wsp) final
 Perform operation. More...
 
void operator() (int dir, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp) final
 
- Public Member Functions inherited from Nektar::Collections::Operator
 Operator (std::vector< StdRegions::StdExpansionSharedPtr > pCollExp, std::shared_ptr< CoalescedGeomData > GeomData, StdRegions::FactorMap factors)
 Constructor. More...
 
virtual ~Operator ()=default
 
virtual COLLECTIONS_EXPORT void operator() (const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output0, Array< OneD, NekDouble > &output1, Array< OneD, NekDouble > &output2, Array< OneD, NekDouble > &wsp=NullNekDouble1DArray)=0
 Perform operation. More...
 
virtual COLLECTIONS_EXPORT void operator() (int dir, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp=NullNekDouble1DArray)=0
 
virtual COLLECTIONS_EXPORT void UpdateFactors (StdRegions::FactorMap factors)
 Update the supplied factor map. More...
 
virtual COLLECTIONS_EXPORT void UpdateVarcoeffs (StdRegions::VarCoeffMap &varcoeffs)
 Update the supplied variable coefficients. More...
 
unsigned int GetWspSize ()
 Get the size of the required workspace. More...
 
unsigned int GetNumElmt ()
 Get number of elements. More...
 
StdRegions::StdExpansionSharedPtr GetExpSharedPtr ()
 Get expansion pointer. More...
 
unsigned int GetInputSize (bool defaultIn=true)
 
unsigned int GetOutputSize (bool defaultOut=true)
 

Protected Attributes

int m_coordim
 
const int m_nquad0
 
const int m_nquad1
 
Array< TwoD, const NekDoublem_derivFac
 
NekDoublem_Deriv0
 
NekDoublem_Deriv1
 
Array< OneD, NekDoublem_fac0
 
Array< OneD, NekDoublem_fac1
 
- Protected Attributes inherited from Nektar::Collections::Operator
bool m_isDeformed
 
StdRegions::StdExpansionSharedPtr m_stdExp
 
unsigned int m_numElmt
 number of elements that the operator is applied on More...
 
unsigned int m_nqe
 
unsigned int m_wspSize
 
unsigned int m_inputSize
 number of modes or quadrature points that are passed as input to an operator More...
 
unsigned int m_outputSize
 number of modes or quadrature points that are taken as output from an operator More...
 
unsigned int m_inputSizeOther
 Number of modes or quadrature points, opposite to m_inputSize. More...
 
unsigned int m_outputSizeOther
 Number of modes or quadrature points, opposite to m_outputSize. More...
 

Private Member Functions

 PhysDeriv_SumFac_Tri (vector< StdRegions::StdExpansionSharedPtr > pCollExp, CoalescedGeomDataSharedPtr pGeomData, StdRegions::FactorMap factors)
 

Additional Inherited Members

- Protected Member Functions inherited from Nektar::Collections::PhysDeriv_Helper
 PhysDeriv_Helper ()
 

Detailed Description

Phys deriv operator using sum-factorisation (Tri)

Definition at line 989 of file PhysDeriv.cpp.

Constructor & Destructor Documentation

◆ ~PhysDeriv_SumFac_Tri()

Nektar::Collections::PhysDeriv_SumFac_Tri::~PhysDeriv_SumFac_Tri ( )
finaldefault

◆ PhysDeriv_SumFac_Tri()

Nektar::Collections::PhysDeriv_SumFac_Tri::PhysDeriv_SumFac_Tri ( vector< StdRegions::StdExpansionSharedPtr pCollExp,
CoalescedGeomDataSharedPtr  pGeomData,
StdRegions::FactorMap  factors 
)
inlineprivate

Definition at line 1146 of file PhysDeriv.cpp.

1149 : Operator(pCollExp, pGeomData, factors), PhysDeriv_Helper(),
1150 m_nquad0(m_stdExp->GetNumPoints(0)),
1151 m_nquad1(m_stdExp->GetNumPoints(1))
1152 {
1153 m_coordim = pCollExp[0]->GetCoordim();
1154
1155 m_derivFac = pGeomData->GetDerivFactors(pCollExp);
1156
1157 const Array<OneD, const NekDouble> &z0 = m_stdExp->GetBasis(0)->GetZ();
1158 const Array<OneD, const NekDouble> &z1 = m_stdExp->GetBasis(1)->GetZ();
1159 m_fac0 = Array<OneD, NekDouble>(m_nquad0 * m_nquad1);
1160 // set up geometric factor: 0.5*(1+z0)
1161 for (int i = 0; i < m_nquad0; ++i)
1162 {
1163 for (int j = 0; j < m_nquad1; ++j)
1164 {
1165 m_fac0[i + j * m_nquad0] = 0.5 * (1 + z0[i]);
1166 }
1167 }
1168
1169 m_fac1 = Array<OneD, NekDouble>(m_nquad0 * m_nquad1);
1170 // set up geometric factor: 2/(1-z1)
1171 for (int i = 0; i < m_nquad0; ++i)
1172 {
1173 for (int j = 0; j < m_nquad1; ++j)
1174 {
1175 m_fac1[i + j * m_nquad0] = 2.0 / (1 - z1[j]);
1176 }
1177 }
1178
1179 m_Deriv0 = &((m_stdExp->GetBasis(0)->GetD())->GetPtr())[0];
1180 m_Deriv1 = &((m_stdExp->GetBasis(1)->GetD())->GetPtr())[0];
1182 }
StdRegions::StdExpansionSharedPtr m_stdExp
Definition: Operator.h:217
unsigned int m_numElmt
number of elements that the operator is applied on
Definition: Operator.h:219
Operator(std::vector< StdRegions::StdExpansionSharedPtr > pCollExp, std::shared_ptr< CoalescedGeomData > GeomData, StdRegions::FactorMap factors)
Constructor.
Definition: Operator.cpp:66
Array< TwoD, const NekDouble > m_derivFac
Definition: PhysDeriv.cpp:1139
StdRegions::ConstFactorMap factors

References m_coordim, m_Deriv0, m_Deriv1, m_derivFac, m_fac0, m_fac1, m_nquad0, m_nquad1, Nektar::Collections::Operator::m_numElmt, Nektar::Collections::Operator::m_stdExp, and Nektar::Collections::Operator::m_wspSize.

Member Function Documentation

◆ operator()() [1/2]

void Nektar::Collections::PhysDeriv_SumFac_Tri::operator() ( const Array< OneD, const NekDouble > &  input,
Array< OneD, NekDouble > &  output0,
Array< OneD, NekDouble > &  output1,
Array< OneD, NekDouble > &  output2,
Array< OneD, NekDouble > &  wsp 
)
inlinefinalvirtual

Perform operation.

Implements Nektar::Collections::Operator.

Definition at line 997 of file PhysDeriv.cpp.

1002 {
1003 const int nqtot = m_nquad0 * m_nquad1;
1004 const int nqcol = nqtot * m_numElmt;
1005
1006 ASSERTL1(wsp.size() == m_wspSize, "Incorrect workspace size");
1007 ASSERTL1(input.size() >= nqcol, "Incorrect input size");
1008
1009 Array<OneD, NekDouble> diff0(nqcol, wsp);
1010 Array<OneD, NekDouble> diff1(nqcol, wsp + nqcol);
1011
1012 // Tensor Product Derivative
1013 Blas::Dgemm('N', 'N', m_nquad0, m_nquad1 * m_numElmt, m_nquad0, 1.0,
1014 m_Deriv0, m_nquad0, input.get(), m_nquad0, 0.0, diff0.get(),
1015 m_nquad0);
1016
1017 int cnt = 0;
1018 for (int i = 0; i < m_numElmt; ++i, cnt += nqtot)
1019 {
1020 // scale diff0 by geometric factor: 2/(1-z1)
1021 Vmath::Vmul(nqtot, &m_fac1[0], 1, diff0.get() + cnt, 1,
1022 diff0.get() + cnt, 1);
1023
1024 Blas::Dgemm('N', 'T', m_nquad0, m_nquad1, m_nquad1, 1.0,
1025 input.get() + cnt, m_nquad0, m_Deriv1, m_nquad1, 0.0,
1026 diff1.get() + cnt, m_nquad0);
1027
1028 // add to diff1 by diff0 scaled by: (1_z0)/(1-z1)
1029 Vmath::Vvtvp(nqtot, m_fac0.get(), 1, diff0.get() + cnt, 1,
1030 diff1.get() + cnt, 1, diff1.get() + cnt, 1);
1031 }
1032
1033 if (m_isDeformed)
1034 {
1035 Vmath::Vmul(nqcol, m_derivFac[0], 1, diff0, 1, output0, 1);
1036 Vmath::Vvtvp(nqcol, m_derivFac[1], 1, diff1, 1, output0, 1, output0,
1037 1);
1038 Vmath::Vmul(nqcol, m_derivFac[2], 1, diff0, 1, output1, 1);
1039 Vmath::Vvtvp(nqcol, m_derivFac[3], 1, diff1, 1, output1, 1, output1,
1040 1);
1041
1042 if (m_coordim == 3)
1043 {
1044 Vmath::Vmul(nqcol, m_derivFac[4], 1, diff0, 1, output2, 1);
1045 Vmath::Vvtvp(nqcol, m_derivFac[5], 1, diff1, 1, output2, 1,
1046 output2, 1);
1047 }
1048 }
1049 else
1050 {
1051 Array<OneD, NekDouble> t;
1052 for (int e = 0; e < m_numElmt; ++e)
1053 {
1054 Vmath::Smul(m_nqe, m_derivFac[0][e], diff0 + e * m_nqe, 1,
1055 t = output0 + e * m_nqe, 1);
1056 Vmath::Svtvp(m_nqe, m_derivFac[1][e], diff1 + e * m_nqe, 1,
1057 output0 + e * m_nqe, 1, t = output0 + e * m_nqe,
1058 1);
1059
1060 Vmath::Smul(m_nqe, m_derivFac[2][e], diff0 + e * m_nqe, 1,
1061 t = output1 + e * m_nqe, 1);
1062 Vmath::Svtvp(m_nqe, m_derivFac[3][e], diff1 + e * m_nqe, 1,
1063 output1 + e * m_nqe, 1, t = output1 + e * m_nqe,
1064 1);
1065 }
1066
1067 if (m_coordim == 3)
1068 {
1069 for (int e = 0; e < m_numElmt; ++e)
1070 {
1071 Vmath::Smul(m_nqe, m_derivFac[4][e], diff0 + e * m_nqe, 1,
1072 t = output2 + e * m_nqe, 1);
1073 Vmath::Svtvp(m_nqe, m_derivFac[5][e], diff1 + e * m_nqe, 1,
1074 output2 + e * m_nqe, 1,
1075 t = output2 + e * m_nqe, 1);
1076 }
1077 }
1078 }
1079 }
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:242
static void Dgemm(const char &transa, const char &transb, const int &m, const int &n, const int &k, const double &alpha, const double *a, const int &lda, const double *b, const int &ldb, const double &beta, double *c, const int &ldc)
BLAS level 3: Matrix-matrix multiply C = A x B where op(A)[m x k], op(B)[k x n], C[m x n] DGEMM perfo...
Definition: Blas.hpp:383
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.
Definition: Vmath.hpp:72
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.
Definition: Vmath.hpp:396
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
Definition: Vmath.hpp:366
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
Definition: Vmath.hpp:100

References ASSERTL1, Blas::Dgemm(), m_coordim, m_Deriv0, m_Deriv1, m_derivFac, m_fac0, m_fac1, Nektar::Collections::Operator::m_isDeformed, Nektar::Collections::Operator::m_nqe, m_nquad0, m_nquad1, Nektar::Collections::Operator::m_numElmt, Nektar::Collections::Operator::m_wspSize, Vmath::Smul(), Vmath::Svtvp(), Vmath::Vmul(), and Vmath::Vvtvp().

◆ operator()() [2/2]

void Nektar::Collections::PhysDeriv_SumFac_Tri::operator() ( int  dir,
const Array< OneD, const NekDouble > &  input,
Array< OneD, NekDouble > &  output,
Array< OneD, NekDouble > &  wsp 
)
inlinefinalvirtual

Implements Nektar::Collections::Operator.

Definition at line 1081 of file PhysDeriv.cpp.

1084 {
1085 const int nqtot = m_nquad0 * m_nquad1;
1086 const int nqcol = nqtot * m_numElmt;
1087
1088 ASSERTL1(wsp.size() == m_wspSize, "Incorrect workspace size");
1089 ASSERTL1(input.size() >= nqcol, "Incorrect input size");
1090
1091 Array<OneD, NekDouble> diff0(nqcol, wsp);
1092 Array<OneD, NekDouble> diff1(nqcol, wsp + nqcol);
1093
1094 // Tensor Product Derivative
1095 Blas::Dgemm('N', 'N', m_nquad0, m_nquad1 * m_numElmt, m_nquad0, 1.0,
1096 m_Deriv0, m_nquad0, input.get(), m_nquad0, 0.0, diff0.get(),
1097 m_nquad0);
1098
1099 int cnt = 0;
1100 for (int i = 0; i < m_numElmt; ++i, cnt += nqtot)
1101 {
1102 // scale diff0 by geometric factor: 2/(1-z1)
1103 Vmath::Vmul(nqtot, &m_fac1[0], 1, diff0.get() + cnt, 1,
1104 diff0.get() + cnt, 1);
1105
1106 Blas::Dgemm('N', 'T', m_nquad0, m_nquad1, m_nquad1, 1.0,
1107 input.get() + cnt, m_nquad0, m_Deriv1, m_nquad1, 0.0,
1108 diff1.get() + cnt, m_nquad0);
1109
1110 // add to diff1 by diff0 scaled by: (1_z0)/(1-z1)
1111 Vmath::Vvtvp(nqtot, m_fac0.get(), 1, diff0.get() + cnt, 1,
1112 diff1.get() + cnt, 1, diff1.get() + cnt, 1);
1113 }
1114
1115 if (m_isDeformed)
1116 {
1117 Vmath::Vmul(nqcol, m_derivFac[2 * dir], 1, diff0, 1, output, 1);
1118 Vmath::Vvtvp(nqcol, m_derivFac[2 * dir + 1], 1, diff1, 1, output, 1,
1119 output, 1);
1120 }
1121 else
1122 {
1123 Array<OneD, NekDouble> t;
1124 for (int e = 0; e < m_numElmt; ++e)
1125 {
1126 Vmath::Smul(m_nqe, m_derivFac[2 * dir][e], diff0 + e * m_nqe, 1,
1127 t = output + e * m_nqe, 1);
1128 Vmath::Svtvp(m_nqe, m_derivFac[2 * dir + 1][e],
1129 diff1 + e * m_nqe, 1, output + e * m_nqe, 1,
1130 t = output + e * m_nqe, 1);
1131 }
1132 }
1133 }

References ASSERTL1, Blas::Dgemm(), m_Deriv0, m_Deriv1, m_derivFac, m_fac0, m_fac1, Nektar::Collections::Operator::m_isDeformed, Nektar::Collections::Operator::m_nqe, m_nquad0, m_nquad1, Nektar::Collections::Operator::m_numElmt, Nektar::Collections::Operator::m_wspSize, Vmath::Smul(), Vmath::Svtvp(), Vmath::Vmul(), and Vmath::Vvtvp().

Member Data Documentation

◆ m_coordim

int Nektar::Collections::PhysDeriv_SumFac_Tri::m_coordim
protected

Definition at line 1136 of file PhysDeriv.cpp.

Referenced by operator()(), and PhysDeriv_SumFac_Tri().

◆ m_Deriv0

NekDouble* Nektar::Collections::PhysDeriv_SumFac_Tri::m_Deriv0
protected

Definition at line 1140 of file PhysDeriv.cpp.

Referenced by operator()(), and PhysDeriv_SumFac_Tri().

◆ m_Deriv1

NekDouble* Nektar::Collections::PhysDeriv_SumFac_Tri::m_Deriv1
protected

Definition at line 1141 of file PhysDeriv.cpp.

Referenced by operator()(), and PhysDeriv_SumFac_Tri().

◆ m_derivFac

Array<TwoD, const NekDouble> Nektar::Collections::PhysDeriv_SumFac_Tri::m_derivFac
protected

Definition at line 1139 of file PhysDeriv.cpp.

Referenced by operator()(), and PhysDeriv_SumFac_Tri().

◆ m_fac0

Array<OneD, NekDouble> Nektar::Collections::PhysDeriv_SumFac_Tri::m_fac0
protected

Definition at line 1142 of file PhysDeriv.cpp.

Referenced by operator()(), and PhysDeriv_SumFac_Tri().

◆ m_fac1

Array<OneD, NekDouble> Nektar::Collections::PhysDeriv_SumFac_Tri::m_fac1
protected

Definition at line 1143 of file PhysDeriv.cpp.

Referenced by operator()(), and PhysDeriv_SumFac_Tri().

◆ m_nquad0

const int Nektar::Collections::PhysDeriv_SumFac_Tri::m_nquad0
protected

Definition at line 1137 of file PhysDeriv.cpp.

Referenced by operator()(), and PhysDeriv_SumFac_Tri().

◆ m_nquad1

const int Nektar::Collections::PhysDeriv_SumFac_Tri::m_nquad1
protected

Definition at line 1138 of file PhysDeriv.cpp.

Referenced by operator()(), and PhysDeriv_SumFac_Tri().