Nektar++
BLPoints.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: BLPoints.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: 1D boundary layer points
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #include <boost/core/ignore_unused.hpp>
36 
41 
42 namespace Nektar
43 {
44 namespace LibUtilities
45 {
51 
53 {
54  // Allocate the storage for points.
56  unsigned int npts = m_pointsKey.GetNumPoints();
57 
58  // Derived power coefficient.
61  "Must set factor in BLPoints key");
62 
63  if (fabs(r - 1.0) < 1e-6)
64  {
65  NekDouble tmp = 2.0 / (npts - 1.0);
66  for (unsigned int i = 0; i < npts; ++i)
67  {
68  m_points[0][i] = -1.0 + i * tmp;
69  }
70  }
71  else
72  {
73  NekDouble a = 2.0 * (1.0 - r) / (1.0 - pow(r, (double)(npts - 1)));
74  m_points[0][0] = -1.0;
75 
76  for (unsigned int i = 1; i < npts; ++i)
77  {
78  m_points[0][i] = m_points[0][i - 1] + a * pow(r, (double)(i - 1));
79  }
80 
81  m_points[0][npts - 1] = 1.0;
82  }
83 
85  {
86  std::vector<NekDouble> tmp(npts);
87  for (unsigned int i = 0; i < npts; ++i)
88  {
89  tmp[i] = -m_points[0][npts - 1 - i];
90  }
91 
92  for (unsigned int i = 0; i < npts; ++i)
93  {
94  m_points[0][i] = tmp[i];
95  }
96  }
97 }
98 
100 {
101 }
102 
104 {
105  //// Allocate the derivative matrix.
107 }
108 
109 std::shared_ptr<Points<NekDouble>> BLPoints::Create(const PointsKey &key)
110 {
111  std::shared_ptr<Points<NekDouble>> returnval(
113 
114  returnval->Initialize();
115 
116  return returnval;
117 }
118 
119 std::shared_ptr<NekMatrix<NekDouble>> BLPoints::CreateMatrix(
120  const PointsKey &pkey)
121 {
122  int numpoints = pkey.GetNumPoints();
124 
125  PointsManager()[pkey]->GetPoints(xpoints);
126 
127  /// Delegate to function below.
128  return GetI(numpoints, xpoints);
129 }
130 
131 const std::shared_ptr<NekMatrix<NekDouble>> BLPoints::v_GetI(
132  const PointsKey &pkey)
133 {
134  ASSERTL0(pkey.GetPointsDim() == 1,
135  "Fourier Points can only interp to other 1d point distributions");
136 
137  return m_InterpManager[pkey];
138 }
139 
140 const std::shared_ptr<NekMatrix<NekDouble>> BLPoints::v_GetI(
142 {
143  int numpoints = 1;
144 
145  /// Delegate to function below.
146  return GetI(numpoints, x);
147 }
148 
149 const std::shared_ptr<NekMatrix<NekDouble>> BLPoints::v_GetI(
150  unsigned int numpoints, const Array<OneD, const NekDouble> &x)
151 {
152  Array<OneD, NekDouble> interp(GetNumPoints() * numpoints);
153 
154  CalculateInterpMatrix(numpoints, x, interp);
155 
156  NekDouble *t = interp.data();
157  unsigned int np = GetNumPoints();
158  std::shared_ptr<NekMatrix<NekDouble>> returnval(
159  MemoryManager<NekMatrix<NekDouble>>::AllocateSharedPtr(numpoints, np,
160  t));
161 
162  return returnval;
163 }
164 
166  unsigned int npts, const Array<OneD, const NekDouble> &xpoints,
167  Array<OneD, NekDouble> &interp)
168 {
169  boost::ignore_unused(npts, xpoints, interp);
170 }
171 } // end of namespace LibUtilities
172 } // end of namespace Nektar
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215
virtual void v_CalculatePoints() override
Definition: BLPoints.cpp:52
void CalculateInterpMatrix(unsigned int npts, const Array< OneD, const NekDouble > &xpoints, Array< OneD, NekDouble > &interp)
Definition: BLPoints.cpp:165
static std::shared_ptr< PointsBaseType > Create(const PointsKey &key)
Definition: BLPoints.cpp:109
virtual void v_CalculateDerivMatrix() override
Definition: BLPoints.cpp:103
std::shared_ptr< NekMatrix< NekDouble > > CreateMatrix(const PointsKey &pkey)
Definition: BLPoints.cpp:119
virtual void v_CalculateWeights() override
Definition: BLPoints.cpp:99
static bool initPointsManager[]
Definition: BLPoints.h:120
virtual const MatrixSharedPtrType v_GetI(const PointsKey &pkey) override
Definition: BLPoints.cpp:131
bool RegisterCreator(const KeyType &key, const CreateFuncType &createFunc)
Register the given function and associate it with the key. The return value is just to facilitate cal...
Definition: NekManager.hpp:170
Array< OneD, DataType > m_points[3]
Storage for the point locations, allowing for up to a 3D points storage.
Definition: Points.h:375
NekManager< PointsKey, NekMatrix< DataType >, PointsKey::opLess > m_InterpManager
Definition: Points.h:383
PointsKey m_pointsKey
Points type for this points distributions.
Definition: Points.h:372
unsigned int GetNumPoints() const
Definition: Points.h:273
virtual void v_CalculateDerivMatrix()
Definition: Points.h:445
const MatrixSharedPtrType GetI(const PointsKey &key)
Definition: Points.h:336
Defines a specification for a set of points.
Definition: Points.h:59
PointsType GetPointsType() const
Definition: Points.h:109
unsigned int GetPointsDim() const
Definition: Points.h:147
NekDouble GetFactor() const
Definition: Points.h:114
unsigned int GetNumPoints() const
Definition: Points.h:104
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
PointsManagerT & PointsManager(void)
@ eBoundaryLayerPoints
1D power law distribution for boundary layer points
Definition: PointsType.h:79
@ eBoundaryLayerPointsRev
1D power law distribution for boundary layer points
Definition: PointsType.h:81
static const NekDouble kNekUnsetDouble
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
double NekDouble