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

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

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

Public Member Functions

 ~PhysDeriv_SumFac_Tri () final
 
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
 
virtual void CheckFactors (StdRegions::FactorMap factors, int coll_phys_offset)
 Check the validity of the supplied factor map. More...
 
- 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 COLLECTIONS_EXPORT ~Operator ()
 
unsigned int GetWspSize ()
 Get the size of the required workspace. More...
 
unsigned int GetNumElmt ()
 Get expansion pointer. More...
 
StdRegions::StdExpansionSharedPtr GetExpSharedPtr ()
 Get expansion pointer. More...
 

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
 
unsigned int m_nqe
 
unsigned int m_wspSize
 

Private Member Functions

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

Detailed Description

Phys deriv operator using sum-factorisation (Tri)

Definition at line 1113 of file PhysDeriv.cpp.

Constructor & Destructor Documentation

◆ ~PhysDeriv_SumFac_Tri()

Nektar::Collections::PhysDeriv_SumFac_Tri::~PhysDeriv_SumFac_Tri ( )
inlinefinal

Definition at line 1118 of file PhysDeriv.cpp.

1119  {
1120  }

◆ PhysDeriv_SumFac_Tri()

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

Definition at line 1285 of file PhysDeriv.cpp.

1289  : Operator(pCollExp, pGeomData, factors),
1290  m_nquad0 (m_stdExp->GetNumPoints(0)),
1291  m_nquad1 (m_stdExp->GetNumPoints(1))
1292  {
1293  LibUtilities::PointsKeyVector PtsKey = m_stdExp->GetPointsKeys();
1294  m_coordim = pCollExp[0]->GetCoordim();
1295 
1296  m_derivFac = pGeomData->GetDerivFactors(pCollExp);
1297 
1298  const Array<OneD, const NekDouble>& z0
1299  = m_stdExp->GetBasis(0)->GetZ();
1300  const Array<OneD, const NekDouble>& z1
1301  = m_stdExp->GetBasis(1)->GetZ();
1302  m_fac0 = Array<OneD, NekDouble>(m_nquad0*m_nquad1);
1303  // set up geometric factor: 0.5*(1+z0)
1304  for (int i = 0; i < m_nquad0; ++i)
1305  {
1306  for(int j = 0; j < m_nquad1; ++j)
1307  {
1308  m_fac0[i+j*m_nquad0] = 0.5*(1+z0[i]);
1309  }
1310  }
1311 
1312  m_fac1 = Array<OneD, NekDouble>(m_nquad0*m_nquad1);
1313  // set up geometric factor: 2/(1-z1)
1314  for (int i = 0; i < m_nquad0; ++i)
1315  {
1316  for(int j = 0; j < m_nquad1; ++j)
1317  {
1318  m_fac1[i+j*m_nquad0] = 2.0/(1-z1[j]);
1319  }
1320  }
1321 
1322 
1323  m_Deriv0 = &((m_stdExp->GetBasis(0)->GetD())->GetPtr())[0];
1324  m_Deriv1 = &((m_stdExp->GetBasis(1)->GetD())->GetPtr())[0];
1326  }
StdRegions::StdExpansionSharedPtr m_stdExp
Definition: Operator.h:167
Operator(std::vector< StdRegions::StdExpansionSharedPtr > pCollExp, std::shared_ptr< CoalescedGeomData > GeomData, StdRegions::FactorMap factors)
Constructor.
Definition: Operator.cpp:41
Array< TwoD, const NekDouble > m_derivFac
Definition: PhysDeriv.cpp:1278
std::vector< PointsKey > PointsKeyVector
Definition: Points.h:246

Member Function Documentation

◆ CheckFactors()

virtual void Nektar::Collections::PhysDeriv_SumFac_Tri::CheckFactors ( StdRegions::FactorMap  factors,
int  coll_phys_offset 
)
inlinevirtual

Check the validity of the supplied factor map.

Implements Nektar::Collections::Operator.

Definition at line 1267 of file PhysDeriv.cpp.

1269  {
1270  boost::ignore_unused(factors, coll_phys_offset);
1271  ASSERTL0(false, "Not valid for this operator.");
1272  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216

References ASSERTL0.

◆ 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 1122 of file PhysDeriv.cpp.

1128  {
1129 
1130  const int nqtot = m_nquad0 * m_nquad1;
1131  const int nqcol = nqtot*m_numElmt;
1132 
1133  ASSERTL1(wsp.size() == m_wspSize,
1134  "Incorrect workspace size");
1135  ASSERTL1(input.size() >= nqcol,
1136  "Incorrect input size");
1137 
1138  Array<OneD, NekDouble> diff0(nqcol, wsp );
1139  Array<OneD, NekDouble> diff1(nqcol, wsp + nqcol);
1140 
1141  // Tensor Product Derivative
1143  m_nquad0, 1.0, m_Deriv0, m_nquad0,
1144  input.get(), m_nquad0, 0.0,
1145  diff0.get(), m_nquad0);
1146 
1147  int cnt = 0;
1148  for (int i = 0; i < m_numElmt; ++i, cnt += nqtot)
1149  {
1150  // scale diff0 by geometric factor: 2/(1-z1)
1151  Vmath::Vmul(nqtot,&m_fac1[0],1,diff0.get()+cnt,1,
1152  diff0.get()+cnt,1);
1153 
1154  Blas::Dgemm('N', 'T', m_nquad0, m_nquad1, m_nquad1, 1.0,
1155  input.get() + cnt, m_nquad0,
1156  m_Deriv1, m_nquad1, 0.0,
1157  diff1.get() + cnt, m_nquad0);
1158 
1159  // add to diff1 by diff0 scaled by: (1_z0)/(1-z1)
1160  Vmath::Vvtvp(nqtot,m_fac0.get(),1,diff0.get()+cnt,1,
1161  diff1.get()+cnt,1,diff1.get()+cnt,1);
1162  }
1163 
1164  if(m_isDeformed)
1165  {
1166  Vmath::Vmul (nqcol, m_derivFac[0], 1, diff0, 1, output0, 1);
1167  Vmath::Vvtvp (nqcol, m_derivFac[1], 1, diff1, 1, output0, 1,
1168  output0, 1);
1169  Vmath::Vmul (nqcol, m_derivFac[2], 1, diff0, 1, output1, 1);
1170  Vmath::Vvtvp (nqcol, m_derivFac[3], 1, diff1, 1, output1, 1,
1171  output1, 1);
1172 
1173  if (m_coordim == 3)
1174  {
1175  Vmath::Vmul (nqcol, m_derivFac[4], 1, diff0, 1, output2, 1);
1176  Vmath::Vvtvp (nqcol, m_derivFac[5], 1, diff1, 1, output2, 1,
1177  output2, 1);
1178  }
1179  }
1180  else
1181  {
1182  Array<OneD, NekDouble> t;
1183  for(int e = 0; e < m_numElmt; ++e)
1184  {
1185  Vmath::Smul (m_nqe, m_derivFac[0][e], diff0 + e*m_nqe, 1,
1186  t = output0 + e*m_nqe, 1);
1187  Vmath::Svtvp (m_nqe, m_derivFac[1][e], diff1 + e*m_nqe, 1,
1188  output0 + e*m_nqe, 1, t = output0 + e*m_nqe, 1);
1189 
1190  Vmath::Smul (m_nqe, m_derivFac[2][e], diff0 + e*m_nqe, 1,
1191  t = output1 + e*m_nqe, 1);
1192  Vmath::Svtvp (m_nqe, m_derivFac[3][e], diff1 + e*m_nqe, 1,
1193  output1 + e*m_nqe, 1, t = output1 + e*m_nqe, 1);
1194  }
1195 
1196  if (m_coordim == 3)
1197  {
1198  for(int e = 0; e < m_numElmt; ++e)
1199  {
1200  Vmath::Smul (m_nqe, m_derivFac[4][e], diff0 + e*m_nqe, 1,
1201  t = output2 + e*m_nqe, 1);
1202  Vmath::Svtvp (m_nqe, m_derivFac[5][e], diff1 + e*m_nqe, 1,
1203  output2 + e*m_nqe, 1, t = output2 + e*m_nqe, 1);
1204  }
1205  }
1206  }
1207  }
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:250
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:394
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.cpp:192
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.cpp:565
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.cpp:513
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.cpp:225

References ASSERTL1, Blas::Dgemm(), 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 1209 of file PhysDeriv.cpp.

1213  {
1214  const int nqtot = m_nquad0 * m_nquad1;
1215  const int nqcol = nqtot*m_numElmt;
1216 
1217  ASSERTL1(wsp.size() == m_wspSize,
1218  "Incorrect workspace size");
1219  ASSERTL1(input.size() >= nqcol,
1220  "Incorrect input size");
1221 
1222  Array<OneD, NekDouble> diff0(nqcol, wsp );
1223  Array<OneD, NekDouble> diff1(nqcol, wsp + nqcol);
1224 
1225  // Tensor Product Derivative
1227  m_nquad0, 1.0, m_Deriv0, m_nquad0,
1228  input.get(), m_nquad0, 0.0,
1229  diff0.get(), m_nquad0);
1230 
1231  int cnt = 0;
1232  for (int i = 0; i < m_numElmt; ++i, cnt += nqtot)
1233  {
1234  // scale diff0 by geometric factor: 2/(1-z1)
1235  Vmath::Vmul(nqtot,&m_fac1[0],1,diff0.get()+cnt,1,
1236  diff0.get()+cnt,1);
1237 
1238  Blas::Dgemm('N', 'T', m_nquad0, m_nquad1, m_nquad1, 1.0,
1239  input.get() + cnt, m_nquad0,
1240  m_Deriv1, m_nquad1, 0.0,
1241  diff1.get() + cnt, m_nquad0);
1242 
1243  // add to diff1 by diff0 scaled by: (1_z0)/(1-z1)
1244  Vmath::Vvtvp(nqtot,m_fac0.get(),1,diff0.get()+cnt,1,
1245  diff1.get()+cnt,1,diff1.get()+cnt,1);
1246  }
1247 
1248  if(m_isDeformed)
1249  {
1250  Vmath::Vmul (nqcol, m_derivFac[2*dir] , 1, diff0, 1, output, 1);
1251  Vmath::Vvtvp (nqcol, m_derivFac[2*dir+1], 1, diff1, 1, output, 1,
1252  output, 1);
1253  }
1254  else
1255  {
1256  Array<OneD, NekDouble> t;
1257  for(int e = 0; e < m_numElmt; ++e)
1258  {
1259  Vmath::Smul (m_nqe, m_derivFac[2*dir][e], diff0 + e*m_nqe, 1,
1260  t = output + e*m_nqe, 1);
1261  Vmath::Svtvp (m_nqe, m_derivFac[2*dir+1][e], diff1 + e*m_nqe, 1,
1262  output + e*m_nqe, 1, t = output + e*m_nqe, 1);
1263  }
1264  }
1265  }

References ASSERTL1, Blas::Dgemm(), 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 1275 of file PhysDeriv.cpp.

◆ m_Deriv0

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

Definition at line 1279 of file PhysDeriv.cpp.

◆ m_Deriv1

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

Definition at line 1280 of file PhysDeriv.cpp.

◆ m_derivFac

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

Definition at line 1278 of file PhysDeriv.cpp.

◆ m_fac0

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

Definition at line 1281 of file PhysDeriv.cpp.

◆ m_fac1

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

Definition at line 1282 of file PhysDeriv.cpp.

◆ m_nquad0

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

Definition at line 1276 of file PhysDeriv.cpp.

◆ m_nquad1

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

Definition at line 1277 of file PhysDeriv.cpp.