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

Inner product WRT deriv base operator using standard matrix approach. More...

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

Public Member Functions

 ~IProductWRTDerivBase_StdMat () final=default
 
void operator() (const Array< OneD, const NekDouble > &entry0, Array< OneD, NekDouble > &entry1, Array< OneD, NekDouble > &entry2, Array< OneD, NekDouble > &entry3, 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

Array< OneD, DNekMatSharedPtrm_iProdWRTStdDBase
 
Array< TwoD, const NekDoublem_derivFac
 
Array< OneD, const NekDoublem_jac
 
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 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

 IProductWRTDerivBase_StdMat (vector< StdRegions::StdExpansionSharedPtr > pCollExp, CoalescedGeomDataSharedPtr pGeomData, StdRegions::FactorMap factors)
 
- Private Member Functions inherited from Nektar::Collections::IProductWRTDerivBase_Helper
 IProductWRTDerivBase_Helper ()
 

Detailed Description

Inner product WRT deriv base operator using standard matrix approach.

Definition at line 75 of file IProductWRTDerivBase.cpp.

Constructor & Destructor Documentation

◆ ~IProductWRTDerivBase_StdMat()

Nektar::Collections::IProductWRTDerivBase_StdMat::~IProductWRTDerivBase_StdMat ( )
finaldefault

◆ IProductWRTDerivBase_StdMat()

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

Definition at line 194 of file IProductWRTDerivBase.cpp.

197 : Operator(pCollExp, pGeomData, factors), IProductWRTDerivBase_Helper()
198 {
199 m_dim = pCollExp[0]->GetShapeDimension();
200 m_coordim = pCollExp[0]->GetCoordim();
201
202 m_nqe = m_stdExp->GetTotPoints();
203 int nmodes = m_stdExp->GetNcoeffs();
204
205 // set up a IProductWRTDerivBase StdMat.
206 m_iProdWRTStdDBase = Array<OneD, DNekMatSharedPtr>(m_dim);
207 for (int i = 0; i < m_dim; ++i)
208 {
209 Array<OneD, NekDouble> tmp(m_nqe), tmp1(nmodes);
212 for (int j = 0; j < m_nqe; ++j)
213 {
214 Vmath::Zero(m_nqe, tmp, 1);
215 tmp[j] = 1.0;
216 m_stdExp->IProductWRTDerivBase(i, tmp, tmp1);
217 Vmath::Vcopy(nmodes, &tmp1[0], 1,
218 &(m_iProdWRTStdDBase[i]->GetPtr())[0] + j * nmodes,
219 1);
220 }
221 }
222 m_derivFac = pGeomData->GetDerivFactors(pCollExp);
223 m_jac = pGeomData->GetJac(pCollExp);
225 }
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
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
StdRegions::ConstFactorMap factors
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_dim, m_iProdWRTStdDBase, m_jac, Nektar::Collections::Operator::m_nqe, 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::IProductWRTDerivBase_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 83 of file IProductWRTDerivBase.cpp.

88 {
89 int nPhys = m_stdExp->GetTotPoints();
90 int ntot = m_numElmt * nPhys;
91 int nmodes = m_stdExp->GetNcoeffs();
92 Array<OneD, Array<OneD, const NekDouble>> in(3);
93 Array<OneD, NekDouble> output;
94 Array<OneD, Array<OneD, NekDouble>> tmp(3);
95
96 in[0] = entry0;
97 in[1] = entry1;
98 in[2] = entry2;
99
100 output = (m_coordim == 3) ? entry3 : (m_coordim == 2) ? entry2 : entry1;
101
102 for (int i = 0; i < m_dim; ++i)
103 {
104 tmp[i] = wsp + i * ntot;
105 }
106
107 // calculate Iproduct WRT Std Deriv
108
109 // First component
110 if (m_isDeformed)
111 {
112 // calculate dx/dxi in[0] + dy/dxi in[1] + dz/dxi in[2]
113 for (int i = 0; i < m_dim; ++i)
114 {
115 Vmath::Vmul(ntot, m_derivFac[i], 1, in[0], 1, tmp[i], 1);
116 for (int j = 1; j < m_coordim; ++j)
117 {
118 Vmath::Vvtvp(ntot, m_derivFac[i + j * m_dim], 1, in[j], 1,
119 tmp[i], 1, tmp[i], 1);
120 }
121 }
122
123 Vmath::Vmul(ntot, m_jac, 1, tmp[0], 1, tmp[0], 1);
124 }
125 else
126 {
127 Array<OneD, NekDouble> t;
128 for (int e = 0; e < m_numElmt; ++e)
129 {
130 // calculate dx/dxi in[0] + dy/dxi in[1] + dz/dxi in[2]
131 for (int i = 0; i < m_dim; ++i)
132 {
133 Vmath::Smul(m_nqe, m_derivFac[i][e], in[0] + e * m_nqe, 1,
134 t = tmp[i] + e * m_nqe, 1);
135 for (int j = 1; j < m_coordim; ++j)
136 {
137 Vmath::Svtvp(m_nqe, m_derivFac[i + j * m_dim][e],
138 in[j] + e * m_nqe, 1, tmp[i] + e * m_nqe,
139 1, t = tmp[i] + e * m_nqe, 1);
140 }
141 }
142
143 Vmath::Smul(m_nqe, m_jac[e], tmp[0] + e * m_nqe, 1,
144 t = tmp[0] + e * m_nqe, 1);
145 }
146 }
147
148 Blas::Dgemm('N', 'N', m_iProdWRTStdDBase[0]->GetRows(), m_numElmt,
149 m_iProdWRTStdDBase[0]->GetColumns(), 1.0,
150 m_iProdWRTStdDBase[0]->GetRawPtr(),
151 m_iProdWRTStdDBase[0]->GetRows(), tmp[0].data(), nPhys, 0.0,
152 output.data(), nmodes);
153
154 // Other components
155 for (int i = 1; i < m_dim; ++i)
156 {
157 if (m_isDeformed)
158 {
159 Vmath::Vmul(ntot, m_jac, 1, tmp[i], 1, tmp[i], 1);
160 }
161 else
162 {
163 Array<OneD, NekDouble> t;
164 for (int e = 0; e < m_numElmt; ++e)
165 {
166 Vmath::Smul(m_nqe, m_jac[e], tmp[i] + e * m_nqe, 1,
167 t = tmp[i] + e * m_nqe, 1);
168 }
169 }
170 Blas::Dgemm('N', 'N', m_iProdWRTStdDBase[i]->GetRows(), m_numElmt,
171 m_iProdWRTStdDBase[i]->GetColumns(), 1.0,
172 m_iProdWRTStdDBase[i]->GetRawPtr(),
173 m_iProdWRTStdDBase[i]->GetRows(), tmp[i].data(), nPhys,
174 1.0, output.data(), nmodes);
175 }
176 }
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 Blas::Dgemm(), m_coordim, m_derivFac, m_dim, m_iProdWRTStdDBase, Nektar::Collections::Operator::m_isDeformed, m_jac, Nektar::Collections::Operator::m_nqe, Nektar::Collections::Operator::m_numElmt, Nektar::Collections::Operator::m_stdExp, Vmath::Smul(), Vmath::Svtvp(), Vmath::Vmul(), and Vmath::Vvtvp().

◆ operator()() [2/2]

void Nektar::Collections::IProductWRTDerivBase_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 178 of file IProductWRTDerivBase.cpp.

182 {
183 NEKERROR(ErrorUtil::efatal, "Not valid for this operator.");
184 }
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Definition: ErrorUtil.hpp:202

References Nektar::ErrorUtil::efatal, and NEKERROR.

Member Data Documentation

◆ m_coordim

int Nektar::Collections::IProductWRTDerivBase_StdMat::m_coordim
protected

Definition at line 191 of file IProductWRTDerivBase.cpp.

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

◆ m_derivFac

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

Definition at line 188 of file IProductWRTDerivBase.cpp.

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

◆ m_dim

int Nektar::Collections::IProductWRTDerivBase_StdMat::m_dim
protected

Definition at line 190 of file IProductWRTDerivBase.cpp.

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

◆ m_iProdWRTStdDBase

Array<OneD, DNekMatSharedPtr> Nektar::Collections::IProductWRTDerivBase_StdMat::m_iProdWRTStdDBase
protected

Definition at line 187 of file IProductWRTDerivBase.cpp.

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

◆ m_jac

Array<OneD, const NekDouble> Nektar::Collections::IProductWRTDerivBase_StdMat::m_jac
protected

Definition at line 189 of file IProductWRTDerivBase.cpp.

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