Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
StdPointExp.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File $Source: /usr/sci/projects/Nektar/cvs/Nektar++/library/LocalRegions/PointExp.cpp,v $
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 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: Definition of a Point expansion
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #include <StdRegions/StdPointExp.h>
37 
38 using namespace std;
39 
40 namespace Nektar
41 {
42  namespace StdRegions
43  {
44 
45  StdPointExp::StdPointExp()
46  {
47  }
48 
49 
50  StdPointExp::StdPointExp(const LibUtilities::BasisKey &Ba):
51  StdExpansion(Ba.GetNumModes(), 1, Ba),
52  StdExpansion0D(Ba.GetNumModes(),Ba)
53  {
54  }
55 
56 
57  /** \brief Copy Constructor */
58 
60  StdExpansion(T),
62  {
63  }
64 
65 
66 
68  {
69  }
70 
71 
73  {
74  return LibUtilities::ePoint;
75  }
76 
77 
79  Array<OneD, NekDouble> &coords_0,
80  Array<OneD, NekDouble> &coords_1,
81  Array<OneD, NekDouble> &coords_2)
82  {
83  Blas::Dcopy(GetNumPoints(0),(m_base[0]->GetZ()).get(),
84  1,&coords_0[0],1);
85  }
86 
87 
89  const Array<OneD, const NekDouble>& inarray,
90  Array<OneD, NekDouble> &outarray)
91  {
92  int nquad = m_base[0]->GetNumPoints();
93 
94  if(m_base[0]->Collocation())
95  {
96  Vmath::Vcopy(nquad, inarray, 1, outarray, 1);
97  }
98  else
99  {
100 
101 #ifdef NEKTAR_USING_DIRECT_BLAS_CALLS
102 
103  Blas::Dgemv('N',nquad,m_base[0]->GetNumModes(),1.0, (m_base[0]->GetBdata()).get(),
104  nquad,&inarray[0],1,0.0,&outarray[0],1);
105 
106 #else //NEKTAR_USING_DIRECT_BLAS_CALLS
107 
109  NekVector<NekDouble> out(nquad,outarray,eWrapper);
110  NekMatrix<NekDouble> B(nquad,m_ncoeffs,m_base[0]->GetBdata(),eWrapper);
111  out = B * in;
112 
113 #endif //NEKTAR_USING_DIRECT_BLAS_CALLS
114 
115  }
116  }
117 
118 
120  Array<OneD, NekDouble> &outarray)
121  {
122  if(m_base[0]->Collocation())
123  {
124  Vmath::Vcopy(m_ncoeffs, inarray, 1, outarray, 1);
125  }
126  else
127  {
128  v_IProductWRTBase(inarray,outarray);
129 
130  // get Mass matrix inverse
131  StdMatrixKey masskey(eInvMass,v_DetShapeType(),*this);
132  DNekMatSharedPtr matsys = GetStdMatrix(masskey);
133 
134  NekVector<NekDouble> in(m_ncoeffs,outarray,eCopy);
136 
137  out = (*matsys)*in;
138  }
139  }
140 
142  const Array<OneD, const NekDouble>& inarray,
143  Array<OneD, NekDouble> &outarray)
144  {
145  if(m_base[0]->Collocation())
146  {
147  Vmath::Vcopy(m_ncoeffs, inarray, 1, outarray, 1);
148  }
149  else
150  {
151  int nInteriorDofs = m_ncoeffs-2;
152  int offset;
153 
154  switch(m_base[0]->GetBasisType())
155  {
157  {
158  offset = 1;
159  }
160  break;
163  {
164  offset = 2;
165  }
166  break;
167  default:
168  ASSERTL0(false,"This type of FwdTrans is not defined for this shapex type");
169  }
170 
171  fill(outarray.get(), outarray.get()+m_ncoeffs, 0.0 );
172 
173  outarray[GetVertexMap(0)] = inarray[0];
174  outarray[GetVertexMap(1)] = inarray[m_base[0]->GetNumPoints()-1];
175 
176  if(m_ncoeffs>2)
177  {
178  // ideally, we would like to have tmp0 to be replaced by
179  // outarray (currently MassMatrixOp does not allow aliasing)
182 
183  StdMatrixKey masskey(eMass,v_DetShapeType(),*this);
184  MassMatrixOp(outarray,tmp0,masskey);
185  v_IProductWRTBase(inarray,tmp1);
186 
187  Vmath::Vsub(m_ncoeffs, tmp1, 1, tmp0, 1, tmp1, 1);
188 
189  // get Mass matrix inverse (only of interior DOF)
190  DNekMatSharedPtr matsys = (m_stdStaticCondMatrixManager[masskey])->GetBlock(1,1);
191 
192  Blas::Dgemv('N',nInteriorDofs,nInteriorDofs,1.0, &(matsys->GetPtr())[0],
193  nInteriorDofs,tmp1.get()+offset,1,0.0,outarray.get()+offset,1);
194  }
195  }
196 
197  }
198 
199 
201  Array<OneD, NekDouble> &outarray)
202  {
203  v_BwdTrans(inarray, outarray);
204  }
205 
206 //Inner product
208  const Array<OneD, const NekDouble>& inarray,
209  Array<OneD, NekDouble> &outarray,
210  int coll_check)
211  {
212  int nquad = m_base[0]->GetNumPoints();
213  Array<OneD, NekDouble> tmp(nquad);
214  Array<OneD, const NekDouble> z = m_base[0]->GetZ();
215  Array<OneD, const NekDouble> w = m_base[0]->GetW();
216 
217  Vmath::Vmul(nquad, inarray, 1, w, 1, tmp, 1);
218 
219  if(coll_check&&m_base[0]->Collocation())
220  {
221  Vmath::Vcopy(nquad, tmp, 1, outarray, 1);
222  }
223  else
224  {
225  Blas::Dgemv('T',nquad,m_ncoeffs,1.0,base.get(),nquad,
226  &tmp[0],1,0.0,outarray.get(),1);
227  }
228  }
229 
231  Array<OneD, NekDouble> &outarray)
232  {
233  v_IProductWRTBase(m_base[0]->GetBdata(),inarray,outarray,1);
234  }
235 
237  const int dir,
238  const Array<OneD, const NekDouble>& inarray,
239  Array<OneD, NekDouble> & outarray)
240  {
241  ASSERTL1(dir >= 0 && dir < 1,"input dir is out of range");
242  v_IProductWRTBase(m_base[0]->GetDbdata(),inarray,outarray,1);
243  }
244 
246  const Array<OneD, const NekDouble>& inarray,
247  Array<OneD, NekDouble> &outarray,
248  bool multiplybyweights)
249  {
250  v_IProductWRTBase(m_base[0]->GetBdata(),inarray,outarray,1);
251  }
252 
253 
255  {
256  DNekMatSharedPtr Mat;
257  MatrixType mattype;
258 
259  switch(mattype = mkey.GetMatrixType())
260  {
261  case eFwdTrans:
262  {
264  StdMatrixKey iprodkey(eIProductWRTBase,v_DetShapeType(),*this);
265  DNekMat &Iprod = *GetStdMatrix(iprodkey);
266  StdMatrixKey imasskey(eInvMass,v_DetShapeType(),*this);
267  DNekMat &Imass = *GetStdMatrix(imasskey);
268 
269  (*Mat) = Imass*Iprod;
270 
271  }
272  break;
273  default:
274  {
276  }
277  break;
278  }
279 
280  return Mat;
281  }
282 
283 
285  {
286  return v_GenMatrix(mkey);
287  }
288 
289 
290  }
291 }
virtual LibUtilities::ShapeType v_DetShapeType() const
Definition: StdPointExp.cpp:72
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
MatrixType GetMatrixType() const
Definition: StdMatrixKey.h:82
void MassMatrixOp(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, const StdMatrixKey &mkey)
Definition: StdExpansion.h:976
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
virtual void v_BwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Definition: StdPointExp.cpp:88
int GetNumPoints(const int dir) const
This function returns the number of quadrature points in the dir direction.
Definition: StdExpansion.h:229
Principle Modified Functions .
Definition: BasisType.h:49
STL namespace.
virtual void v_IProductWRTBase(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Calculates the inner product of a given function f with the different modes of the expansion...
virtual void v_GetCoords(Array< OneD, NekDouble > &coords_0, Array< OneD, NekDouble > &coords_1, Array< OneD, NekDouble > &coords_2)
Definition: StdPointExp.cpp:78
LibUtilities::NekManager< StdMatrixKey, DNekBlkMat, StdMatrixKey::opLess > m_stdStaticCondMatrixManager
boost::shared_ptr< DNekMat > DNekMatSharedPtr
Definition: NekTypeDefs.hpp:70
DNekMatSharedPtr GetStdMatrix(const StdMatrixKey &mkey)
Definition: StdExpansion.h:706
virtual void v_FwdTrans(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Transform a given function from physical quadrature space to coefficient space.
virtual void v_BwdTrans_SumFac(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
virtual void v_FwdTrans_BndConstrained(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
The base class for all shapes.
Definition: StdExpansion.h:69
int GetVertexMap(const int localVertexId, bool useCoeffPacking=false)
Definition: StdExpansion.h:824
Principle Modified Functions .
Definition: BasisType.h:50
DNekMatSharedPtr CreateGeneralMatrix(const StdMatrixKey &mkey)
this function generates the mass matrix
virtual void v_IProductWRTBase_SumFac(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray, bool multiplybyweights=true)
virtual DNekMatSharedPtr v_CreateStdMatrix(const StdMatrixKey &mkey)
LibUtilities::BasisType GetBasisType(const int dir) const
This function returns the type of basis used in the dir direction.
Definition: StdExpansion.h:165
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.
Definition: Vmath.cpp:343
virtual void v_IProductWRTDerivBase(const int dir, const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Lagrange for SEM basis .
Definition: BasisType.h:53
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
Definition: ErrorUtil.hpp:228
Array< OneD, LibUtilities::BasisSharedPtr > m_base
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1061
Describes the specification for a Basis.
Definition: Basis.h:50
virtual DNekMatSharedPtr v_GenMatrix(const StdMatrixKey &mkey)
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.cpp:183