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
 
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 ~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 CheckFactors (StdRegions::FactorMap factors, int coll_phys_offset)=0
 Check the validity of the supplied factor map. 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 ()
 
unsigned int GetOutputSize ()
 

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

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

Additional Inherited Members

- Protected Member Functions inherited from Nektar::Collections::Operator
virtual int v_GetInputSize ()
 This purely virtual function needs to be set-up for every operator inside Collections. It is responsible for returning the size of input collection, that the operator is applied on either in physical or coefficient space. More...
 
virtual int v_GetOutputSize ()
 This purely virtual function needs to be set-up for every operator inside Collections. It is responsible for returning the output size either in physical or coefficient space of an operator inside Collections. More...
 

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 200 of file IProductWRTDerivBase.cpp.

203 : Operator(pCollExp, pGeomData, factors), IProductWRTDerivBase_Helper()
204 {
205 m_dim = pCollExp[0]->GetShapeDimension();
206 m_coordim = pCollExp[0]->GetCoordim();
207
208 m_nqe = m_stdExp->GetTotPoints();
209 int nmodes = m_stdExp->GetNcoeffs();
210
211 // set up a IProductWRTDerivBase StdMat.
212 m_iProdWRTStdDBase = Array<OneD, DNekMatSharedPtr>(m_dim);
213 for (int i = 0; i < m_dim; ++i)
214 {
215 Array<OneD, NekDouble> tmp(m_nqe), tmp1(nmodes);
218 for (int j = 0; j < m_nqe; ++j)
219 {
220 Vmath::Zero(m_nqe, tmp, 1);
221 tmp[j] = 1.0;
222 m_stdExp->IProductWRTDerivBase(i, tmp, tmp1);
223 Vmath::Vcopy(nmodes, &tmp1[0], 1,
224 &(m_iProdWRTStdDBase[i]->GetPtr())[0] + j * nmodes,
225 1);
226 }
227 }
228 m_derivFac = pGeomData->GetDerivFactors(pCollExp);
229 m_jac = pGeomData->GetJac(pCollExp);
231 }
StdRegions::StdExpansionSharedPtr m_stdExp
Definition: Operator.h:188
unsigned int m_numElmt
number of elements that the operator is applied on
Definition: Operator.h:190
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

◆ CheckFactors()

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

188 {
189 ASSERTL0(false, "Not valid for this operator.");
190 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208

References ASSERTL0.

◆ 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].get(), nPhys, 0.0,
152 output.get(), 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].get(), nPhys,
174 1.0, output.get(), 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 197 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 194 of file IProductWRTDerivBase.cpp.

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

◆ m_dim

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

Definition at line 196 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 193 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 195 of file IProductWRTDerivBase.cpp.

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