Nektar++
Loading...
Searching...
No Matches
StdExpansion1D.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: StdExpansion1D.cpp
4//
5// For more information, please see: http://www.nektar.info
6//
7// The MIT License
8//
9// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10// Department of Aeronautics, Imperial College London (UK), and Scientific
11// Computing and Imaging Institute, University of Utah (USA).
12//
13// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description: Daughter of StdExpansion. This class contains routine
32// which are common to 1d expansion. Typically this inolves physiocal
33// space operations.
34//
35///////////////////////////////////////////////////////////////////////////////
36
38
43
44namespace Nektar::StdRegions
45{
46// Declaration of scalar routine
49
51 [[maybe_unused]] int numcoeffs,
52 [[maybe_unused]] const LibUtilities::BasisKey &Ba)
53{
54}
55
56//----------------------------
57// Differentiation Methods
58//-----------------------------
60 const Array<OneD, const NekDouble> &inarray,
61 Array<OneD, NekDouble> &outarray)
62{
63 int nquad = GetTotPoints();
64 NekDouble *D = m_base[0]->GetD()->GetRawPtr();
66
67 // copy inarray data if inarray and outarray are the same.
68 if (inarray.data() == outarray.data())
69 {
70 Array<OneD, NekDouble> wsp(nquad);
71 CopyArray(inarray, wsp);
72 intmp = wsp;
73 }
74 else
75 {
76 intmp = inarray;
77 }
78
79 // Switch statment using boost_pp and macros. This unfolls into a
80 // nested switch statement which runs from SMIN to SMAX for quadratrure
81 // order. If you want to see it unwrapped compile in verbose mode and add
82 // --preprocess to the c++ command. Default case
83#undef PHYSDERIV_Q
84#define PHYSDERIV_Q(r, i) \
85 case NQ1(i): \
86 PhysDerivTensor1DKernel(NQ1(i), (const vec_t *)intmp.data(), \
87 (const vec_t *)D, (vec_t *)outarray.data()); \
88 break;
89
90 // templated cases on standard quadrature
91 // usage where quad order goes from SMIN to SMAX
92 switch (nquad)
93 {
94 BOOST_PP_FOR((SMIN, SMAX), STDLEV1TEST, STDLEV1UPDATE, PHYSDERIV_Q);
95 default:
96 PhysDerivTensor1DKernel(nquad, (const vec_t *)intmp.data(),
97 (const vec_t *)D, (vec_t *)outarray.data());
98 break;
99 }
100}
101
102void StdExpansion1D::v_PhysDeriv([[maybe_unused]] const int dir,
103 const Array<OneD, const NekDouble> &inarray,
104 Array<OneD, NekDouble> &outarray)
105{
106 ASSERTL1(dir == 0, "input dir is out of range");
108}
109
111 const Array<OneD, const NekDouble> &Lcoord,
112 const Array<OneD, const NekDouble> &physvals)
113{
114 ASSERTL2(Lcoord[0] >= -1 - NekConstants::kNekZeroTol, "Lcoord[0] < -1");
115 ASSERTL2(Lcoord[0] <= 1 + NekConstants::kNekZeroTol, "Lcoord[0] > 1");
116
117 return StdExpansion::BaryEvaluate<0>(Lcoord[0], &physvals[0]);
118}
119
120/** \brief Inner product of \a inarray over region with respect to the
121 * expansion basis (this)->m_base[0] and return in \a outarray
122 *
123 * Wrapper call to \a IProductWRTBaseKernel()
124 *
125 * @param inarray - Array of function values evaluated at the physical
126 * collocation points
127 * @param outarray - The values of the inner product with respect to
128 * each basis over region will be stored in the array \a outarray as
129 * output of the function
130 */
132 const Array<OneD, const NekDouble> &inarray,
133 Array<OneD, NekDouble> &outarray)
134{
135 if (m_base[0]->Collocation())
136 {
137 v_MultiplyByStdQuadratureMetric(inarray, outarray);
138 }
139 else
140 {
141 const Array<OneD, const NekDouble> one(1, 1.0);
142 v_IProductWRTBaseKernel(m_base[0]->GetBdata(), inarray, outarray, one,
143 false);
144 }
145}
146
148 const Array<OneD, const NekDouble> &base0,
149 const Array<OneD, const NekDouble> &inarray,
151 const bool Deformed)
152{
153 v_IProductWRTBaseKernel(base0, inarray, outarray, jac, Deformed);
154}
155
156void StdExpansion1D::v_PhysInterp(std::shared_ptr<StdExpansion> fromExp,
157 const Array<OneD, const NekDouble> &fromData,
159 [[maybe_unused]] bool Transpose)
160{
161 LibUtilities::Interp1D(fromExp->GetBasis(0)->GetPointsKey(), fromData,
162 m_base[0]->GetPointsKey(), toData);
163}
164
166 const Array<OneD, const NekDouble> &inarray,
167 Array<OneD, NekDouble> &outarray)
168{
169 int nquad0 = m_base[0]->GetNumPoints();
170
171 for (int j = 0; j < nquad0; ++j)
172 {
173 outarray[j] = inarray[j] * m_weights[0][j];
174 }
175}
176// up to here
177} // namespace Nektar::StdRegions
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
#define ASSERTL2(condition, msg)
Assert Level 2 – Debugging which is used FULLDEBUG compilation mode. This level assert is designed to...
static NEK_FORCE_INLINE void PhysDerivTensor1DKernel(const unsigned int nq0, const simd_type *in, const simd_type *D0, simd_type *out_d0)
#define PHYSDERIV_Q(r, i)
#define STDLEV1UPDATE(r, state)
#define STDLEV1TEST(r, state)
Describes the specification for a Basis.
Definition Basis.h:45
void PhysTensorDeriv(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Evaluate the derivative at the physical quadrature points given by inarray and return in outarray.
void v_PhysInterp(std::shared_ptr< StdExpansion > fromExp, const Array< OneD, const NekDouble > &fromData, Array< OneD, NekDouble > &toData, bool Transpose) override
void IProductWRTBaseKernel(const Array< OneD, const NekDouble > &base0, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const Array< OneD, const NekDouble > &jac, const bool Deformed)
void v_MultiplyByStdQuadratureMetric(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
virtual void v_IProductWRTBaseKernel(const Array< OneD, const NekDouble > &base0, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const Array< OneD, const NekDouble > &jac, const bool Deformed)=0
void v_IProductWRTBase(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
Inner product of inarray over region with respect to the expansion basis (this)->m_base[0] and return...
NekDouble v_StdPhysEvaluate(const Array< OneD, const NekDouble > &coords, const Array< OneD, const NekDouble > &physvals) override
void v_PhysDeriv(const int dir, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray) override
Calculate the derivative of the physical points in a given direction.
int GetTotPoints() const
This function returns the total number of quadrature points used in the element.
Array< OneD, LibUtilities::BasisSharedPtr > m_base
std::vector< Array< OneD, const NekDouble > > m_weights
void Interp1D(const BasisKey &fbasis0, const Array< OneD, const NekDouble > &from, const BasisKey &tbasis0, Array< OneD, NekDouble > &to)
this function interpolates a 1D function evaluated at the quadrature points of the basis fbasis0 to ...
Definition Interp.cpp:47
static const NekDouble kNekZeroTol
static Array< OneD, NekDouble > NullNekDouble1DArray
NekMatrix< InnerMatrixType, BlockMatrixTag > Transpose(NekMatrix< InnerMatrixType, BlockMatrixTag > &rhs)
void CopyArray(const Array< OneD, ConstDataType > &source, Array< OneD, DataType > &dest)