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

Phys deriv operator using standard matrix approach. More...

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

Public Member Functions

 ~PhysDeriv_StdMat () 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) override final
 Perform operation. More...
 
void operator() (int dir, const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output, Array< OneD, NekDouble > &wsp) override final
 
virtual void CheckFactors (StdRegions::FactorMap factors, int coll_phys_offset) override
 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

Array< OneD, DNekMatSharedPtrm_derivMat
 
Array< TwoD, const NekDoublem_derivFac
 
int m_dim
 
int m_coordim
 
- 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_StdMat (vector< StdRegions::StdExpansionSharedPtr > pCollExp, CoalescedGeomDataSharedPtr pGeomData, StdRegions::FactorMap factors)
 

Detailed Description

Phys deriv operator using standard matrix approach.

Definition at line 61 of file PhysDeriv.cpp.

Constructor & Destructor Documentation

◆ ~PhysDeriv_StdMat()

Nektar::Collections::PhysDeriv_StdMat::~PhysDeriv_StdMat ( )
inlinefinal

Definition at line 66 of file PhysDeriv.cpp.

67  {
68  }

◆ PhysDeriv_StdMat()

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

Definition at line 194 of file PhysDeriv.cpp.

197  : Operator(pCollExp, pGeomData, factors)
198  {
199  int nqtot = 1;
200  LibUtilities::PointsKeyVector PtsKey = m_stdExp->GetPointsKeys();
201  m_dim = PtsKey.size();
202  m_coordim = pCollExp[0]->GetCoordim();
203 
204  for (int i = 0; i < m_dim; ++i)
205  {
206  nqtot *= PtsKey[i].GetNumPoints();
207  }
208  // set up a PhysDeriv StdMat.
209  m_derivMat = Array<OneD, DNekMatSharedPtr>(m_dim);
210  for (int i = 0; i < m_dim; ++i)
211  {
212  Array<OneD, NekDouble> tmp(nqtot), tmp1(nqtot);
213  m_derivMat[i] =
215  for (int j = 0; j < nqtot; ++j)
216  {
217  Vmath::Zero(nqtot, tmp, 1);
218  tmp[j] = 1.0;
219  m_stdExp->PhysDeriv(i, tmp, tmp1);
220  Vmath::Vcopy(nqtot, &tmp1[0], 1,
221  &(m_derivMat[i]->GetPtr())[0] + j * nqtot, 1);
222  }
223  }
224  m_derivFac = pGeomData->GetDerivFactors(pCollExp);
225  m_wspSize = 3 * nqtot * m_numElmt;
226  }
StdRegions::StdExpansionSharedPtr m_stdExp
Definition: Operator.h:165
Operator(std::vector< StdRegions::StdExpansionSharedPtr > pCollExp, std::shared_ptr< CoalescedGeomData > GeomData, StdRegions::FactorMap factors)
Constructor.
Definition: Operator.cpp:43
Array< TwoD, const NekDouble > m_derivFac
Definition: PhysDeriv.cpp:189
Array< OneD, DNekMatSharedPtr > m_derivMat
Definition: PhysDeriv.cpp:188
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::vector< PointsKey > PointsKeyVector
Definition: Points.h:250
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.cpp:492
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1255

References Vmath::Vcopy(), and Vmath::Zero().

Member Function Documentation

◆ CheckFactors()

virtual void Nektar::Collections::PhysDeriv_StdMat::CheckFactors ( StdRegions::FactorMap  factors,
int  coll_phys_offset 
)
inlineoverridevirtual

Check the validity of the supplied factor map.

Implements Nektar::Collections::Operator.

Definition at line 180 of file PhysDeriv.cpp.

182  {
183  boost::ignore_unused(factors, coll_phys_offset);
184  ASSERTL0(false, "Not valid for this operator.");
185  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215

References ASSERTL0.

◆ operator()() [1/2]

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

Perform operation.

Implements Nektar::Collections::Operator.

Definition at line 70 of file PhysDeriv.cpp.

75  {
76 
77  int nPhys = m_stdExp->GetTotPoints();
78  int ntot = m_numElmt * nPhys;
79  Array<OneD, NekDouble> tmp0, tmp1, tmp2;
80  Array<OneD, Array<OneD, NekDouble>> Diff(3);
81  Array<OneD, Array<OneD, NekDouble>> out(3);
82  out[0] = output0;
83  out[1] = output1;
84  out[2] = output2;
85 
86  for (int i = 0; i < m_dim; ++i)
87  {
88  Diff[i] = wsp + i * ntot;
89  }
90 
91  // calculate local derivatives
92  for (int i = 0; i < m_dim; ++i)
93  {
94  Blas::Dgemm('N', 'N', m_derivMat[i]->GetRows(), m_numElmt,
95  m_derivMat[i]->GetColumns(), 1.0,
96  m_derivMat[i]->GetRawPtr(), m_derivMat[i]->GetRows(),
97  input.get(), nPhys, 0.0, &Diff[i][0], nPhys);
98  }
99 
100  // calculate full derivative
101  if (m_isDeformed)
102  {
103  for (int i = 0; i < m_coordim; ++i)
104  {
105  Vmath::Zero(ntot, out[i], 1);
106  for (int j = 0; j < m_dim; ++j)
107  {
108  Vmath::Vvtvp(ntot, m_derivFac[i * m_dim + j], 1, Diff[j], 1,
109  out[i], 1, out[i], 1);
110  }
111  }
112  }
113  else
114  {
115  Array<OneD, NekDouble> t;
116  for (int i = 0; i < m_coordim; ++i)
117  {
118  Vmath::Zero(ntot, out[i], 1);
119  for (int e = 0; e < m_numElmt; ++e)
120  {
121  for (int j = 0; j < m_dim; ++j)
122  {
123  Vmath::Svtvp(m_nqe, m_derivFac[i * m_dim + j][e],
124  Diff[j] + e * m_nqe, 1, out[i] + e * m_nqe,
125  1, t = out[i] + e * m_nqe, 1);
126  }
127  }
128  }
129  }
130  }
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:368
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:622
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:574

References Blas::Dgemm(), Vmath::Svtvp(), Vmath::Vvtvp(), and Vmath::Zero().

◆ operator()() [2/2]

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

Implements Nektar::Collections::Operator.

Definition at line 132 of file PhysDeriv.cpp.

135  {
136  int nPhys = m_stdExp->GetTotPoints();
137  int ntot = m_numElmt * nPhys;
138  Array<OneD, NekDouble> tmp0, tmp1, tmp2;
139  Array<OneD, Array<OneD, NekDouble>> Diff(3);
140 
141  for (int i = 0; i < m_dim; ++i)
142  {
143  Diff[i] = wsp + i * ntot;
144  }
145 
146  // calculate local derivatives
147  for (int i = 0; i < m_dim; ++i)
148  {
149  Blas::Dgemm('N', 'N', m_derivMat[i]->GetRows(), m_numElmt,
150  m_derivMat[i]->GetColumns(), 1.0,
151  m_derivMat[i]->GetRawPtr(), m_derivMat[i]->GetRows(),
152  input.get(), nPhys, 0.0, &Diff[i][0], nPhys);
153  }
154 
155  // calculate full derivative
156  Vmath::Zero(ntot, output, 1);
157  if (m_isDeformed)
158  {
159  for (int j = 0; j < m_dim; ++j)
160  {
161  Vmath::Vvtvp(ntot, m_derivFac[dir * m_dim + j], 1, Diff[j], 1,
162  output, 1, output, 1);
163  }
164  }
165  else
166  {
167  Array<OneD, NekDouble> t;
168  for (int e = 0; e < m_numElmt; ++e)
169  {
170  for (int j = 0; j < m_dim; ++j)
171  {
172  Vmath::Svtvp(m_nqe, m_derivFac[dir * m_dim + j][e],
173  Diff[j] + e * m_nqe, 1, output + e * m_nqe, 1,
174  t = output + e * m_nqe, 1);
175  }
176  }
177  }
178  }

References Blas::Dgemm(), Vmath::Svtvp(), Vmath::Vvtvp(), and Vmath::Zero().

Member Data Documentation

◆ m_coordim

int Nektar::Collections::PhysDeriv_StdMat::m_coordim
protected

Definition at line 191 of file PhysDeriv.cpp.

◆ m_derivFac

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

Definition at line 189 of file PhysDeriv.cpp.

◆ m_derivMat

Array<OneD, DNekMatSharedPtr> Nektar::Collections::PhysDeriv_StdMat::m_derivMat
protected

Definition at line 188 of file PhysDeriv.cpp.

◆ m_dim

int Nektar::Collections::PhysDeriv_StdMat::m_dim
protected

Definition at line 190 of file PhysDeriv.cpp.