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

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) 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

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

Constructor & Destructor Documentation

◆ ~PhysDeriv_StdMat()

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

Definition at line 64 of file PhysDeriv.cpp.

65  {
66  }

◆ PhysDeriv_StdMat()

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

Definition at line 200 of file PhysDeriv.cpp.

204  : Operator(pCollExp, pGeomData, factors)
205  {
206  int nqtot = 1;
207  LibUtilities::PointsKeyVector PtsKey = m_stdExp->GetPointsKeys();
208  m_dim = PtsKey.size();
209  m_coordim = pCollExp[0]->GetCoordim();
210 
211  for(int i = 0; i < m_dim; ++i)
212  {
213  nqtot *= PtsKey[i].GetNumPoints();
214  }
215  // set up a PhysDeriv StdMat.
216  m_derivMat = Array<OneD, DNekMatSharedPtr>(m_dim);
217  for(int i = 0; i < m_dim; ++i)
218  {
219  Array<OneD, NekDouble> tmp(nqtot),tmp1(nqtot);
221  ::AllocateSharedPtr(nqtot,nqtot);
222  for(int j = 0; j < nqtot; ++j)
223  {
224  Vmath::Zero(nqtot,tmp,1);
225  tmp[j] = 1.0;
226  m_stdExp->PhysDeriv(i,tmp,tmp1);
227  Vmath::Vcopy(nqtot, &tmp1[0], 1,
228  &(m_derivMat[i]->GetPtr())[0] + j*nqtot, 1);
229  }
230  }
231  m_derivFac = pGeomData->GetDerivFactors(pCollExp);
232  m_wspSize = 3*nqtot*m_numElmt;
233  }
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:195
Array< OneD, DNekMatSharedPtr > m_derivMat
Definition: PhysDeriv.cpp:194
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::vector< PointsKey > PointsKeyVector
Definition: Points.h:246
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.cpp:436
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1199

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

Member Function Documentation

◆ CheckFactors()

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

Check the validity of the supplied factor map.

Implements Nektar::Collections::Operator.

Definition at line 186 of file PhysDeriv.cpp.

188  {
189  boost::ignore_unused(factors, coll_phys_offset);
190  ASSERTL0(false, "Not valid for this operator.");
191  }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216

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 
)
inlinefinalvirtual

Perform operation.

Implements Nektar::Collections::Operator.

Definition at line 68 of file PhysDeriv.cpp.

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

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 
)
inlinefinalvirtual

Implements Nektar::Collections::Operator.

Definition at line 133 of file PhysDeriv.cpp.

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

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

◆ m_derivFac

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

Definition at line 195 of file PhysDeriv.cpp.

◆ m_derivMat

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

Definition at line 194 of file PhysDeriv.cpp.

◆ m_dim

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

Definition at line 196 of file PhysDeriv.cpp.