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

Phys deriv operator using sum-factorisation (Pyramid) More...

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

Public Member Functions

 ~PhysDeriv_SumFac_Pyr () 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. 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< TwoD, const NekDoublem_derivFac
 
int m_coordim
 
const int m_nquad0
 
const int m_nquad1
 
const int m_nquad2
 
NekDoublem_Deriv0
 
NekDoublem_Deriv1
 
NekDoublem_Deriv2
 
Array< OneD, NekDoublem_fac0
 
Array< OneD, NekDoublem_fac1
 
Array< OneD, NekDoublem_fac2
 
- 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

 PhysDeriv_SumFac_Pyr (vector< StdRegions::StdExpansionSharedPtr > 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 sum-factorisation (Pyramid)

Definition at line 1895 of file PhysDeriv.cpp.

Constructor & Destructor Documentation

◆ ~PhysDeriv_SumFac_Pyr()

Nektar::Collections::PhysDeriv_SumFac_Pyr::~PhysDeriv_SumFac_Pyr ( )
finaldefault

◆ PhysDeriv_SumFac_Pyr()

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

Definition at line 2099 of file PhysDeriv.cpp.

2102 : Operator(pCollExp, pGeomData, factors), PhysDeriv_Helper(),
2103 m_nquad0(m_stdExp->GetNumPoints(0)),
2104 m_nquad1(m_stdExp->GetNumPoints(1)),
2105 m_nquad2(m_stdExp->GetNumPoints(2))
2106 {
2107 m_coordim = pCollExp[0]->GetCoordim();
2108
2109 m_derivFac = pGeomData->GetDerivFactors(pCollExp);
2110
2111 const Array<OneD, const NekDouble> &z0 = m_stdExp->GetBasis(0)->GetZ();
2112 const Array<OneD, const NekDouble> &z1 = m_stdExp->GetBasis(1)->GetZ();
2113 const Array<OneD, const NekDouble> &z2 = m_stdExp->GetBasis(2)->GetZ();
2114 m_fac0 = Array<OneD, NekDouble>(m_nquad0 * m_nquad1 * m_nquad2);
2115 m_fac1 = Array<OneD, NekDouble>(m_nquad0 * m_nquad1 * m_nquad2);
2116 m_fac2 = Array<OneD, NekDouble>(m_nquad0 * m_nquad1 * m_nquad2);
2117
2118 int nq0_nq1 = m_nquad0 * m_nquad1;
2119 for (int i = 0; i < m_nquad0; ++i)
2120 {
2121 for (int j = 0; j < m_nquad1; ++j)
2122 {
2123 int ifac = i + j * m_nquad0;
2124 for (int k = 0; k < m_nquad2; ++k)
2125 {
2126 m_fac0[ifac + k * nq0_nq1] = 2.0 / (1 - z2[k]);
2127 m_fac1[ifac + k * nq0_nq1] = 0.5 * (1 + z0[i]);
2128 m_fac2[ifac + k * nq0_nq1] = 0.5 * (1 + z1[j]);
2129 }
2130 }
2131 }
2132
2133 m_Deriv0 = &((m_stdExp->GetBasis(0)->GetD())->GetPtr())[0];
2134 m_Deriv1 = &((m_stdExp->GetBasis(1)->GetD())->GetPtr())[0];
2135 m_Deriv2 = &((m_stdExp->GetBasis(2)->GetD())->GetPtr())[0];
2136
2138 }
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
Array< TwoD, const NekDouble > m_derivFac
Definition: PhysDeriv.cpp:2086
StdRegions::ConstFactorMap factors

References m_coordim, m_Deriv0, m_Deriv1, m_Deriv2, m_derivFac, m_fac0, m_fac1, m_fac2, m_nquad0, m_nquad1, m_nquad2, Nektar::Collections::Operator::m_numElmt, Nektar::Collections::Operator::m_stdExp, and Nektar::Collections::Operator::m_wspSize.

Member Function Documentation

◆ operator()() [1/2]

void Nektar::Collections::PhysDeriv_SumFac_Pyr::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 1903 of file PhysDeriv.cpp.

1908 {
1909 int nPhys = m_stdExp->GetTotPoints();
1910 int ntot = m_numElmt * nPhys;
1911 Array<OneD, NekDouble> tmp0, tmp1, tmp2;
1912 Array<OneD, Array<OneD, NekDouble>> Diff(3);
1913 Array<OneD, Array<OneD, NekDouble>> out(3);
1914 out[0] = output0;
1915 out[1] = output1;
1916 out[2] = output2;
1917
1918 for (int i = 0; i < 3; ++i)
1919 {
1920 Diff[i] = wsp + i * ntot;
1921 }
1922
1923 // dEta0
1925 m_nquad0, 1.0, m_Deriv0, m_nquad0, &input[0], m_nquad0, 0.0,
1926 &Diff[0][0], m_nquad0);
1927
1928 int cnt = 0;
1929 for (int i = 0; i < m_numElmt; ++i)
1930 {
1931 // dEta 1
1932 for (int j = 0; j < m_nquad2; ++j)
1933 {
1934 Blas::Dgemm('N', 'T', m_nquad0, m_nquad1, m_nquad1, 1.0,
1935 &input[i * nPhys + j * m_nquad0 * m_nquad1],
1936 m_nquad0, m_Deriv1, m_nquad1, 0.0,
1937 &Diff[1][i * nPhys + j * m_nquad0 * m_nquad1],
1938 m_nquad0);
1939 }
1940
1941 // dEta 2
1942 Blas::Dgemm('N', 'T', m_nquad0 * m_nquad1, m_nquad2, m_nquad2, 1.0,
1943 &input[i * nPhys], m_nquad0 * m_nquad1, m_Deriv2,
1944 m_nquad2, 0.0, &Diff[2][i * nPhys],
1945 m_nquad0 * m_nquad1);
1946
1947 // dxi0 = 2/(1-eta_2) d Eta_0
1948 Vmath::Vmul(nPhys, &m_fac0[0], 1, Diff[0].get() + cnt, 1,
1949 Diff[0].get() + cnt, 1);
1950
1951 // dxi1 = 2/(1-eta_2) d Eta_1
1952 Vmath::Vmul(nPhys, &m_fac0[0], 1, Diff[1].get() + cnt, 1,
1953 Diff[1].get() + cnt, 1);
1954
1955 // dxi2 = (1+eta0)/(1-eta_2) d Eta_0 + d/dEta2;
1956 Vmath::Vvtvp(nPhys, &m_fac1[0], 1, Diff[0].get() + cnt, 1,
1957 Diff[2].get() + cnt, 1, Diff[2].get() + cnt, 1);
1958
1959 // dxi2 += (1+eta1)/(1-eta_2) d Eta_1
1960 Vmath::Vvtvp(nPhys, &m_fac2[0], 1, Diff[1].get() + cnt, 1,
1961 Diff[2].get() + cnt, 1, Diff[2].get() + cnt, 1);
1962 cnt += nPhys;
1963 }
1964
1965 // calculate full derivative
1966 if (m_isDeformed)
1967 {
1968 for (int i = 0; i < m_coordim; ++i)
1969 {
1970 Vmath::Vmul(ntot, m_derivFac[i * 3], 1, Diff[0], 1, out[i], 1);
1971 for (int j = 1; j < 3; ++j)
1972 {
1973 Vmath::Vvtvp(ntot, m_derivFac[i * 3 + j], 1, Diff[j], 1,
1974 out[i], 1, out[i], 1);
1975 }
1976 }
1977 }
1978 else
1979 {
1980 Array<OneD, NekDouble> t;
1981 for (int e = 0; e < m_numElmt; ++e)
1982 {
1983 for (int i = 0; i < m_coordim; ++i)
1984 {
1985 Vmath::Smul(m_nqe, m_derivFac[i * 3][e],
1986 Diff[0] + e * m_nqe, 1, t = out[i] + e * m_nqe,
1987 1);
1988
1989 for (int j = 1; j < 3; ++j)
1990 {
1991 Vmath::Svtvp(m_nqe, m_derivFac[i * 3 + j][e],
1992 Diff[j] + e * m_nqe, 1, out[i] + e * m_nqe,
1993 1, t = out[i] + e * m_nqe, 1);
1994 }
1995 }
1996 }
1997 }
1998 }
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_Deriv0, m_Deriv1, m_Deriv2, m_derivFac, m_fac0, m_fac1, m_fac2, Nektar::Collections::Operator::m_isDeformed, Nektar::Collections::Operator::m_nqe, m_nquad0, m_nquad1, m_nquad2, 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::PhysDeriv_SumFac_Pyr::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 2000 of file PhysDeriv.cpp.

2003 {
2004 int nPhys = m_stdExp->GetTotPoints();
2005 int ntot = m_numElmt * nPhys;
2006 Array<OneD, NekDouble> tmp0, tmp1, tmp2;
2007 Array<OneD, Array<OneD, NekDouble>> Diff(3);
2008
2009 for (int i = 0; i < 3; ++i)
2010 {
2011 Diff[i] = wsp + i * ntot;
2012 }
2013
2014 // dEta0
2016 m_nquad0, 1.0, m_Deriv0, m_nquad0, &input[0], m_nquad0, 0.0,
2017 &Diff[0][0], m_nquad0);
2018
2019 int cnt = 0;
2020 for (int i = 0; i < m_numElmt; ++i)
2021 {
2022 // dEta 1
2023 for (int j = 0; j < m_nquad2; ++j)
2024 {
2025 Blas::Dgemm('N', 'T', m_nquad0, m_nquad1, m_nquad1, 1.0,
2026 &input[i * nPhys + j * m_nquad0 * m_nquad1],
2027 m_nquad0, m_Deriv1, m_nquad1, 0.0,
2028 &Diff[1][i * nPhys + j * m_nquad0 * m_nquad1],
2029 m_nquad0);
2030 }
2031
2032 // dEta 2
2033 Blas::Dgemm('N', 'T', m_nquad0 * m_nquad1, m_nquad2, m_nquad2, 1.0,
2034 &input[i * nPhys], m_nquad0 * m_nquad1, m_Deriv2,
2035 m_nquad2, 0.0, &Diff[2][i * nPhys],
2036 m_nquad0 * m_nquad1);
2037
2038 // dxi0 = 2/(1-eta_2) d Eta_0
2039 Vmath::Vmul(nPhys, &m_fac0[0], 1, Diff[0].get() + cnt, 1,
2040 Diff[0].get() + cnt, 1);
2041
2042 // dxi1 = 2/(1-eta_2) d Eta_1
2043 Vmath::Vmul(nPhys, &m_fac0[0], 1, Diff[1].get() + cnt, 1,
2044 Diff[1].get() + cnt, 1);
2045
2046 // dxi2 = (1+eta0)/(1-eta_2) d Eta_0 + d/dEta2;
2047 Vmath::Vvtvp(nPhys, &m_fac1[0], 1, Diff[0].get() + cnt, 1,
2048 Diff[2].get() + cnt, 1, Diff[2].get() + cnt, 1);
2049
2050 // dxi2 = (1+eta1)/(1-eta_2) d Eta_1 + d/dEta2;
2051 Vmath::Vvtvp(nPhys, &m_fac2[0], 1, Diff[1].get() + cnt, 1,
2052 Diff[2].get() + cnt, 1, Diff[2].get() + cnt, 1);
2053 cnt += nPhys;
2054 }
2055
2056 // calculate full derivative
2057 if (m_isDeformed)
2058 {
2059 // calculate full derivative
2060 Vmath::Vmul(ntot, m_derivFac[dir * 3], 1, Diff[0], 1, output, 1);
2061 for (int j = 1; j < 3; ++j)
2062 {
2063 Vmath::Vvtvp(ntot, m_derivFac[dir * 3 + j], 1, Diff[j], 1,
2064 output, 1, output, 1);
2065 }
2066 }
2067 else
2068 {
2069 Array<OneD, NekDouble> t;
2070 for (int e = 0; e < m_numElmt; ++e)
2071 {
2072 Vmath::Smul(m_nqe, m_derivFac[dir * 3][e], Diff[0] + e * m_nqe,
2073 1, t = output + e * m_nqe, 1);
2074
2075 for (int j = 1; j < 3; ++j)
2076 {
2077 Vmath::Svtvp(m_nqe, m_derivFac[dir * 3 + j][e],
2078 Diff[j] + e * m_nqe, 1, output + e * m_nqe, 1,
2079 t = output + e * m_nqe, 1);
2080 }
2081 }
2082 }
2083 }

References Blas::Dgemm(), m_Deriv0, m_Deriv1, m_Deriv2, m_derivFac, m_fac0, m_fac1, m_fac2, Nektar::Collections::Operator::m_isDeformed, Nektar::Collections::Operator::m_nqe, m_nquad0, m_nquad1, m_nquad2, Nektar::Collections::Operator::m_numElmt, Nektar::Collections::Operator::m_stdExp, Vmath::Smul(), Vmath::Svtvp(), Vmath::Vmul(), and Vmath::Vvtvp().

Member Data Documentation

◆ m_coordim

int Nektar::Collections::PhysDeriv_SumFac_Pyr::m_coordim
protected

Definition at line 2087 of file PhysDeriv.cpp.

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

◆ m_Deriv0

NekDouble* Nektar::Collections::PhysDeriv_SumFac_Pyr::m_Deriv0
protected

Definition at line 2091 of file PhysDeriv.cpp.

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

◆ m_Deriv1

NekDouble* Nektar::Collections::PhysDeriv_SumFac_Pyr::m_Deriv1
protected

Definition at line 2092 of file PhysDeriv.cpp.

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

◆ m_Deriv2

NekDouble* Nektar::Collections::PhysDeriv_SumFac_Pyr::m_Deriv2
protected

Definition at line 2093 of file PhysDeriv.cpp.

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

◆ m_derivFac

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

Definition at line 2086 of file PhysDeriv.cpp.

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

◆ m_fac0

Array<OneD, NekDouble> Nektar::Collections::PhysDeriv_SumFac_Pyr::m_fac0
protected

Definition at line 2094 of file PhysDeriv.cpp.

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

◆ m_fac1

Array<OneD, NekDouble> Nektar::Collections::PhysDeriv_SumFac_Pyr::m_fac1
protected

Definition at line 2095 of file PhysDeriv.cpp.

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

◆ m_fac2

Array<OneD, NekDouble> Nektar::Collections::PhysDeriv_SumFac_Pyr::m_fac2
protected

Definition at line 2096 of file PhysDeriv.cpp.

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

◆ m_nquad0

const int Nektar::Collections::PhysDeriv_SumFac_Pyr::m_nquad0
protected

Definition at line 2088 of file PhysDeriv.cpp.

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

◆ m_nquad1

const int Nektar::Collections::PhysDeriv_SumFac_Pyr::m_nquad1
protected

Definition at line 2089 of file PhysDeriv.cpp.

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

◆ m_nquad2

const int Nektar::Collections::PhysDeriv_SumFac_Pyr::m_nquad2
protected

Definition at line 2090 of file PhysDeriv.cpp.

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