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  {
49  };
50 
52  {
53  // Allocate the storage for points.
55  unsigned int npts = m_pointsKey.GetNumPoints();
56 
57  // Derived power coefficient.
60  "Must set factor in BLPoints key");
61 
62  if (fabs(r-1.0) < 1e-6)
63  {
64  NekDouble tmp = 2.0/(npts-1.0);
65  for (unsigned int i = 0; i < npts; ++i)
66  {
67  m_points[0][i] = -1.0 + i * tmp;
68  }
69  }
70  else
71  {
72  NekDouble a = 2.0 * (1.0-r) / (1.0 - pow(r,(double)(npts-1)));
73  m_points[0][0] = -1.0;
74 
75  for (unsigned int i = 1; i < npts; ++i)
76  {
77  m_points[0][i] = m_points[0][i-1] + a*pow(r,(double)(i-1));
78  }
79 
80  m_points[0][npts-1] = 1.0;
81  }
82 
84  {
85  std::vector<NekDouble> tmp(npts);
86  for (unsigned int i = 0; i < npts; ++i)
87  {
88  tmp[i] = - m_points[0][npts-1-i];
89  }
90 
91  for (unsigned int i = 0; i < npts; ++i)
92  {
93  m_points[0][i] = tmp[i];
94  }
95  }
96  }
97 
99  {
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(MemoryManager<BLPoints>::AllocateSharedPtr(key));
112 
113  returnval->Initialize();
114 
115  return returnval;
116  }
117 
118 
119  std::shared_ptr< NekMatrix<NekDouble> > BLPoints::CreateMatrix(const PointsKey &pkey)
120  {
121  int numpoints = pkey.GetNumPoints();
123 
124  PointsManager()[pkey]->GetPoints(xpoints);
125 
126  /// Delegate to function below.
127  return GetI(numpoints, xpoints);
128  }
129 
130  const std::shared_ptr<NekMatrix<NekDouble> > BLPoints::GetI(const PointsKey& pkey)
131  {
132  ASSERTL0(pkey.GetPointsDim()==1, "Fourier Points can only interp to other 1d point distributions");
133 
134  return m_InterpManager[pkey];
135  }
136 
137  const std::shared_ptr<NekMatrix<NekDouble> > BLPoints::GetI(const Array<OneD, const NekDouble>& x)
138  {
139  int numpoints = 1;
140 
141  /// Delegate to function below.
142  return GetI(numpoints, x);
143  }
144 
145  const std::shared_ptr<NekMatrix<NekDouble> > BLPoints::GetI(unsigned int numpoints, const Array<OneD, const NekDouble>& x)
146  {
147  Array<OneD, NekDouble> interp(GetNumPoints()*numpoints);
148 
149  CalculateInterpMatrix(numpoints, x, interp);
150 
151  NekDouble* t = interp.data();
152  unsigned int np = GetNumPoints();
153  std::shared_ptr< NekMatrix<NekDouble> > returnval(MemoryManager<NekMatrix<NekDouble> >::AllocateSharedPtr(numpoints,np,t));
154 
155  return returnval;
156  }
157 
159  {
160  boost::ignore_unused(npts, xpoints, interp);
161  }
162  } // end of namespace LibUtilities
163 } // end of namespace Nektar
164 
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
PointsType GetPointsType() const
Definition: Points.h:112
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
NekDouble GetFactor() const
Definition: Points.h:117
std::shared_ptr< NekMatrix< NekDouble > > CreateMatrix(const PointsKey &pkey)
Definition: BLPoints.cpp:119
unsigned int GetPointsDim() const
Definition: Points.h:150
NekManager< PointsKey, NekMatrix< DataType >, PointsKey::opLess > m_InterpManager
Definition: Points.h:384
PointsManagerT & PointsManager(void)
Defines a specification for a set of points.
Definition: Points.h:59
double NekDouble
static const NekDouble kNekUnsetDouble
virtual void CalculateDerivMatrix()
Definition: Points.h:403
1D power law distribution for boundary layer points
Definition: PointsType.h:68
const MatrixSharedPtrType GetI(const PointsKey &pkey)
Definition: BLPoints.cpp:130
void CalculateInterpMatrix(unsigned int npts, const Array< OneD, const NekDouble > &xpoints, Array< OneD, NekDouble > &interp)
Definition: BLPoints.cpp:158
Array< OneD, DataType > m_points[3]
Definition: Points.h:381
1D power law distribution for boundary layer points
Definition: PointsType.h:67
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:166
static bool initPointsManager[]
Definition: BLPoints.h:120
unsigned int GetNumPoints() const
Definition: Points.h:107
unsigned int GetNumPoints() const
Definition: Points.h:272
static std::shared_ptr< PointsBaseType > Create(const PointsKey &key)
Definition: BLPoints.cpp:109