Nektar++
Loading...
Searching...
No Matches
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=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.
 
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< LocalRegions::ExpansionSharedPtr > pCollExp, std::shared_ptr< CoalescedGeomData > GeomData, StdRegions::FactorMap factors)
 Constructor.
 
virtual ~Operator ()=default
 
virtual COLLECTIONS_EXPORT void UpdateFactors (StdRegions::FactorMap factors)
 Update the supplied factor map.
 
virtual COLLECTIONS_EXPORT void UpdateVarcoeffs (StdRegions::VarCoeffMap &varcoeffs)
 Update the supplied variable coefficients.
 
unsigned int GetWspSize ()
 Get the size of the required workspace.
 
unsigned int GetNumElmt ()
 Get number of elements.
 
StdRegions::StdExpansionSharedPtr GetExpSharedPtr ()
 Get expansion pointer.
 
unsigned int GetInputSize (void)
 
unsigned int GetOutputSize (void)
 
unsigned int GetPhysSize (void)
 
unsigned int GetCoeffSize (void)
 

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
 number of elements that the operator is applied on
 
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
 
unsigned int m_outputSize
 number of modes or quadrature points that are taken as output from an operator
 

Private Member Functions

 PhysDeriv_StdMat (vector< LocalRegions::ExpansionSharedPtr > 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 standard matrix approach.

Definition at line 79 of file PhysDeriv.cpp.

Constructor & Destructor Documentation

◆ ~PhysDeriv_StdMat()

Nektar::Collections::PhysDeriv_StdMat::~PhysDeriv_StdMat ( )
finaldefault

◆ PhysDeriv_StdMat()

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

Definition at line 203 of file PhysDeriv.cpp.

206 : Operator(pCollExp, pGeomData, factors), PhysDeriv_Helper()
207 {
208 int nqtot = pCollExp[0]->GetTotPoints();
209 m_dim = pCollExp[0]->GetShapeDimension();
210 m_coordim = pCollExp[0]->GetCoordim();
211
212 // set up a PhysDeriv StdMat.
213 m_derivMat = Array<OneD, DNekMatSharedPtr>(m_dim);
214 for (int i = 0; i < m_dim; ++i)
215 {
216 Array<OneD, NekDouble> tmp(nqtot), tmp1(nqtot);
217 m_derivMat[i] =
219 for (int j = 0; j < nqtot; ++j)
220 {
221 Vmath::Zero(nqtot, tmp, 1);
222 tmp[j] = 1.0;
223 m_stdExp->PhysDeriv(i, tmp, tmp1);
224 Vmath::Vcopy(nqtot, &tmp1[0], 1,
225 &(m_derivMat[i]->GetPtr())[0] + j * nqtot, 1);
226 }
227 }
228 m_derivFac = pGeomData->GetDerivFactors(pCollExp);
229 m_wspSize = 3 * nqtot * m_numElmt;
230 }
StdRegions::StdExpansionSharedPtr m_stdExp
Definition Operator.h:230
unsigned int m_numElmt
number of elements that the operator is applied on
Definition Operator.h:232
Operator(std::vector< LocalRegions::ExpansionSharedPtr > pCollExp, std::shared_ptr< CoalescedGeomData > GeomData, StdRegions::FactorMap factors)
Constructor.
Definition Operator.cpp:66
Array< TwoD, const NekDouble > m_derivFac
Array< OneD, DNekMatSharedPtr > m_derivMat
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
void Zero(int n, T *x, const int incx)
Zero vector.
Definition Vmath.hpp:273
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition Vmath.hpp:825

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), m_coordim, m_derivFac, m_derivMat, m_dim, Nektar::Collections::Operator::m_numElmt, Nektar::Collections::Operator::m_stdExp, Nektar::Collections::Operator::m_wspSize, Vmath::Vcopy(), and Vmath::Zero().

Member Function Documentation

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

92 {
93 int nPhys = m_stdExp->GetTotPoints();
94 int ntot = m_numElmt * nPhys;
95 Array<OneD, NekDouble> tmp0, tmp1, tmp2;
96 Array<OneD, Array<OneD, NekDouble>> Diff(3);
97 Array<OneD, Array<OneD, NekDouble>> out(3);
98 out[0] = output0;
99 out[1] = output1;
100 out[2] = output2;
101
102 for (int i = 0; i < m_dim; ++i)
103 {
104 Diff[i] = wsp + i * ntot;
105 }
106
107 // calculate local derivatives
108 for (int i = 0; i < m_dim; ++i)
109 {
110 Blas::Dgemm('N', 'N', m_derivMat[i]->GetRows(), m_numElmt,
111 m_derivMat[i]->GetColumns(), 1.0,
112 m_derivMat[i]->GetRawPtr(), m_derivMat[i]->GetRows(),
113 input.data(), nPhys, 0.0, &Diff[i][0], nPhys);
114 }
115
116 // calculate full derivative
117 if (m_isDeformed)
118 {
119 for (int i = 0; i < m_coordim; ++i)
120 {
121 Vmath::Zero(ntot, out[i], 1);
122 for (int j = 0; j < m_dim; ++j)
123 {
124 Vmath::Vvtvp(ntot, m_derivFac[i * m_dim + j], 1, Diff[j], 1,
125 out[i], 1, out[i], 1);
126 }
127 }
128 }
129 else
130 {
131 Array<OneD, NekDouble> t;
132 for (int i = 0; i < m_coordim; ++i)
133 {
134 Vmath::Zero(ntot, out[i], 1);
135 for (int e = 0; e < m_numElmt; ++e)
136 {
137 for (int j = 0; j < m_dim; ++j)
138 {
139 Vmath::Svtvp(m_nqe, m_derivFac[i * m_dim + j][e],
140 Diff[j] + e * m_nqe, 1, out[i] + e * m_nqe,
141 1, t = out[i] + e * m_nqe, 1);
142 }
143 }
144 }
145 }
146 }
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:324
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

References Blas::Dgemm(), m_coordim, m_derivFac, m_derivMat, m_dim, Nektar::Collections::Operator::m_isDeformed, Nektar::Collections::Operator::m_nqe, Nektar::Collections::Operator::m_numElmt, Nektar::Collections::Operator::m_stdExp, 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 148 of file PhysDeriv.cpp.

151 {
152 int nPhys = m_stdExp->GetTotPoints();
153 int ntot = m_numElmt * nPhys;
154 Array<OneD, NekDouble> tmp0, tmp1, tmp2;
155 Array<OneD, Array<OneD, NekDouble>> Diff(3);
156
157 for (int i = 0; i < m_dim; ++i)
158 {
159 Diff[i] = wsp + i * ntot;
160 }
161
162 // calculate local derivatives
163 for (int i = 0; i < m_dim; ++i)
164 {
165 Blas::Dgemm('N', 'N', m_derivMat[i]->GetRows(), m_numElmt,
166 m_derivMat[i]->GetColumns(), 1.0,
167 m_derivMat[i]->GetRawPtr(), m_derivMat[i]->GetRows(),
168 input.data(), nPhys, 0.0, &Diff[i][0], nPhys);
169 }
170
171 // calculate full derivative
172 Vmath::Zero(ntot, output, 1);
173 if (m_isDeformed)
174 {
175 for (int j = 0; j < m_dim; ++j)
176 {
177 Vmath::Vvtvp(ntot, m_derivFac[dir * m_dim + j], 1, Diff[j], 1,
178 output, 1, output, 1);
179 }
180 }
181 else
182 {
183 Array<OneD, NekDouble> t;
184 for (int e = 0; e < m_numElmt; ++e)
185 {
186 for (int j = 0; j < m_dim; ++j)
187 {
188 Vmath::Svtvp(m_nqe, m_derivFac[dir * m_dim + j][e],
189 Diff[j] + e * m_nqe, 1, output + e * m_nqe, 1,
190 t = output + e * m_nqe, 1);
191 }
192 }
193 }
194 }

References Blas::Dgemm(), m_derivFac, m_derivMat, m_dim, Nektar::Collections::Operator::m_isDeformed, Nektar::Collections::Operator::m_nqe, Nektar::Collections::Operator::m_numElmt, Nektar::Collections::Operator::m_stdExp, Vmath::Svtvp(), Vmath::Vvtvp(), and Vmath::Zero().

Member Data Documentation

◆ m_coordim

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

Definition at line 200 of file PhysDeriv.cpp.

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

◆ m_derivFac

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

Definition at line 198 of file PhysDeriv.cpp.

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

◆ m_derivMat

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

Definition at line 197 of file PhysDeriv.cpp.

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

◆ m_dim

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

Definition at line 199 of file PhysDeriv.cpp.

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