Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Expansion.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File Expansion.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 // 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: File for Expansion routines
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
37 #include <LocalRegions/Expansion.h>
38 #include <LocalRegions/MatrixKey.h>
39 
41 
42 using namespace std;
43 
44 namespace Nektar
45 {
46  namespace LocalRegions
47  {
48  Expansion::Expansion(SpatialDomains::GeometrySharedPtr pGeom) :
49  m_geom(pGeom),
50  m_metricinfo(m_geom->GetGeomFactors())
51  {
52  if (!m_metricinfo)
53  {
54  return;
55  }
56 
57  if (!m_metricinfo->IsValid())
58  {
59  int nDim = m_base.num_elements();
60  string type = "regular";
61  if (m_metricinfo->GetGtype() == SpatialDomains::eDeformed)
62  {
63  type = "deformed";
64  }
65 
66  stringstream err;
67  err << nDim << "D " << type << " Jacobian not positive "
68  << "(element ID = " << m_geom->GetGlobalID() << ") "
69  << "(first vertex ID = " << m_geom->GetVid(0) << ")";
70  NEKERROR(ErrorUtil::ewarning, err.str());
71  }
72  }
73 
75  m_geom(pSrc.m_geom),
76  m_metricinfo(pSrc.m_metricinfo)
77  {
78 
79  }
80 
82  {
83  }
84 
86  {
87  return v_GetLocMatrix(mkey);
88  }
89 
91  const DNekScalMatSharedPtr &r_bnd,
92  const StdRegions::MatrixType matrixType)
93  {
94  return v_BuildTransformationMatrix(r_bnd,matrixType);
95  }
96 
97 
99  const DNekScalMatSharedPtr &r_bnd)
100  {
101  return v_BuildVertexMatrix(r_bnd);
102  }
103 
104 
106  const NekDouble *data,
107  const std::vector<unsigned int > &nummodes,
108  const int nmodes_offset,
109  NekDouble *coeffs,
110  std::vector<LibUtilities::BasisType> &fromType)
111  {
112  v_ExtractDataToCoeffs(data,nummodes,nmodes_offset,coeffs,fromType);
113  }
114 
116  const int edge,
117  const boost::shared_ptr<Expansion> &EdgeExp,
120  Array<OneD, NekDouble> &outarray)
121  {
122  v_AddEdgeNormBoundaryInt(edge, EdgeExp, Fx, Fy, outarray);
123  }
124 
126  const int edge,
127  const boost::shared_ptr<Expansion> &EdgeExp,
129  Array<OneD, NekDouble> &outarray)
130  {
131  v_AddEdgeNormBoundaryInt(edge, EdgeExp, Fn, outarray);
132  }
133 
135  const int face,
136  const boost::shared_ptr<Expansion> &FaceExp,
138  Array<OneD, NekDouble> &outarray)
139  {
140  v_AddFaceNormBoundaryInt(face, FaceExp, Fn, outarray);
141  }
142 
144  const int dir,
145  const Array<OneD, const NekDouble>& inarray,
147  Array<OneD, Array<OneD, NekDouble> > &coeffs,
148  Array<OneD, NekDouble> &outarray)
149  {
150  v_DGDeriv(dir, inarray, EdgeExp, coeffs, outarray);
151  }
152 
154  const StdRegions::ConstFactorMap &factors,
155  const StdRegions::VarCoeffMap &varcoeffs)
156  {
157  MatrixKey mkey(mtype, DetShapeType(), *this, factors, varcoeffs);
158  return GetLocMatrix(mkey);
159  }
160 
162  {
163  return m_geom;
164  }
165 
167  {
168  // Clear metrics
169  m_metrics.clear();
170 
171  // Regenerate geometry factors
172  m_metricinfo = m_geom->GetGeomFactors();
173  }
174 
176  {
177  return m_metricinfo;
178  }
179 
180 
182  {
183  NEKERROR(ErrorUtil::efatal, "This function is only valid for LocalRegions");
185  }
186 
188  Array<OneD, NekDouble> &outarray)
189  {
190  const int nqtot = GetTotPoints();
191 
192  if (m_metrics.count(eMetricQuadrature) == 0)
193  {
195  }
196 
197  Vmath::Vmul(nqtot, m_metrics[eMetricQuadrature], 1, inarray, 1, outarray, 1);
198  }
199 
201  {
203  }
204 
206  {
207  unsigned int nqtot = GetTotPoints();
208  SpatialDomains::GeomType type = m_metricinfo->GetGtype();
210  if (type == SpatialDomains::eRegular ||
212  {
214  }
215  else
216  {
218  }
219 
221  m_metrics[eMetricQuadrature]);
222  }
223 
225  Array<OneD, NekDouble> &coords_0,
226  Array<OneD, NekDouble> &coords_1,
227  Array<OneD, NekDouble> &coords_2)
228  {
229  ASSERTL1(m_geom, "m_geom not defined");
230 
231  // get physical points defined in Geom
232  m_geom->FillGeom();
233 
234  const int expDim = m_base.num_elements();
235  int nqGeom = 1;
236  bool doCopy = true;
237 
240 
241  for (int i = 0; i < expDim; ++i)
242  {
243  CBasis[i] = m_geom->GetBasis(i);
244  nqGeom *= CBasis[i]->GetNumPoints();
245  doCopy = doCopy && m_base[i]->GetBasisKey().SamePoints(
246  CBasis[i]->GetBasisKey());
247  }
248 
249  tmp[0] = coords_0;
250  tmp[1] = coords_1;
251  tmp[2] = coords_2;
252 
253  if (doCopy)
254  {
255  for (int i = 0; i < m_geom->GetCoordim(); ++i)
256  {
257  m_geom->GetXmap()->BwdTrans(m_geom->GetCoeffs(i), tmp[i]);
258  }
259  }
260  else
261  {
262  for (int i = 0; i < m_geom->GetCoordim(); ++i)
263  {
264  Array<OneD, NekDouble> tmpGeom(nqGeom);
265  m_geom->GetXmap()->BwdTrans(m_geom->GetCoeffs(i), tmpGeom);
266 
267  switch (expDim)
268  {
269  case 1:
270  {
272  CBasis[0]->GetPointsKey(), &tmpGeom[0],
273  m_base[0]->GetPointsKey(), &tmp[i][0]);
274  break;
275  }
276  case 2:
277  {
279  CBasis[0]->GetPointsKey(),
280  CBasis[1]->GetPointsKey(),
281  &tmpGeom[0],
282  m_base[0]->GetPointsKey(),
283  m_base[1]->GetPointsKey(),
284  &tmp[i][0]);
285  break;
286  }
287  case 3:
288  {
290  CBasis[0]->GetPointsKey(),
291  CBasis[1]->GetPointsKey(),
292  CBasis[2]->GetPointsKey(),
293  &tmpGeom[0],
294  m_base[0]->GetPointsKey(),
295  m_base[1]->GetPointsKey(),
296  m_base[2]->GetPointsKey(),
297  &tmp[i][0]);
298  break;
299  }
300  }
301  }
302  }
303  }
304 
306  const DNekScalMatSharedPtr &r_bnd,
307  const StdRegions::MatrixType matrixType)
308  {
309  NEKERROR(ErrorUtil::efatal, "This function is only valid for LocalRegions");
310  return NullDNekMatSharedPtr;
311  }
312 
314  const DNekScalMatSharedPtr &r_bnd)
315  {
316  NEKERROR(ErrorUtil::efatal, "This function is only valid for LocalRegions");
317  return NullDNekMatSharedPtr;
318  }
319 
321  const NekDouble *data,
322  const std::vector<unsigned int > &nummodes,
323  const int nmodes_offset,
324  NekDouble *coeffs,
325  std::vector<LibUtilities::BasisType> &fromType)
326  {
327  NEKERROR(ErrorUtil::efatal, "This function is only valid for LocalRegions");
328  }
329 
331  const int edge,
332  const boost::shared_ptr<Expansion> &EdgeExp,
335  Array<OneD, NekDouble> &outarray)
336  {
337  NEKERROR(ErrorUtil::efatal, "This function is only valid for LocalRegions");
338  }
339 
341  const int edge,
342  const boost::shared_ptr<Expansion> &EdgeExp,
344  Array<OneD, NekDouble> &outarray)
345  {
346  NEKERROR(ErrorUtil::efatal, "This function is only valid for LocalRegions");
347  }
348 
350  const int face,
351  const boost::shared_ptr<Expansion> &FaceExp,
353  Array<OneD, NekDouble> &outarray)
354  {
355  NEKERROR(ErrorUtil::efatal, "This function is only valid for LocalRegions");
356  }
357 
359  const int dir,
360  const Array<OneD, const NekDouble>& inarray,
362  Array<OneD, Array<OneD, NekDouble> > &coeffs,
363  Array<OneD, NekDouble> &outarray)
364  {
365  NEKERROR(ErrorUtil::efatal, "This function is only valid for LocalRegions");
366  }
367  } //end of namespace
368 } //end of namespace
369 
const LibUtilities::PointsKeyVector GetPointsKeys() const
LibUtilities::ShapeType DetShapeType() const
This function returns the shape of the expansion domain.
Definition: StdExpansion.h:470
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
Definition: ErrorUtil.hpp:191
std::vector< PointsKey > PointsKeyVector
Definition: Points.h:242
DNekMatSharedPtr BuildTransformationMatrix(const DNekScalMatSharedPtr &r_bnd, const StdRegions::MatrixType matrixType)
Definition: Expansion.cpp:90
void ExtractDataToCoeffs(const NekDouble *data, const std::vector< unsigned int > &nummodes, const int nmodes_offset, NekDouble *coeffs, std::vector< LibUtilities::BasisType > &fromType)
Definition: Expansion.cpp:105
void MultiplyByStdQuadratureMetric(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Definition: StdExpansion.h:954
virtual void v_MultiplyByQuadratureMetric(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Definition: Expansion.cpp:187
SpatialDomains::GeomFactorsSharedPtr m_metricinfo
Definition: Expansion.h:131
STL namespace.
static DNekScalMatSharedPtr NullDNekScalMatSharedPtr
Definition: NekTypeDefs.hpp:80
DNekMatSharedPtr BuildVertexMatrix(const DNekScalMatSharedPtr &r_bnd)
Definition: Expansion.cpp:98
std::map< ConstFactorType, NekDouble > ConstFactorMap
Definition: StdRegions.hpp:252
SpatialDomains::GeometrySharedPtr m_geom
Definition: Expansion.h:130
boost::shared_ptr< DNekMat > DNekMatSharedPtr
Definition: NekTypeDefs.hpp:70
boost::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
virtual DNekMatSharedPtr v_BuildTransformationMatrix(const DNekScalMatSharedPtr &r_bnd, const StdRegions::MatrixType matrixType)
Definition: Expansion.cpp:305
virtual DNekMatSharedPtr v_BuildVertexMatrix(const DNekScalMatSharedPtr &r_bnd)
Definition: Expansion.cpp:313
virtual void v_ExtractDataToCoeffs(const NekDouble *data, const std::vector< unsigned int > &nummodes, const int nmodes_offset, NekDouble *coeffs, std::vector< LibUtilities::BasisType > &fromType)
Definition: Expansion.cpp:320
static DNekMatSharedPtr NullDNekMatSharedPtr
Definition: NekTypeDefs.hpp:79
int GetTotPoints() const
This function returns the total number of quadrature points used in the element.
Definition: StdExpansion.h:141
void Interp2D(const BasisKey &fbasis0, const BasisKey &fbasis1, const Array< OneD, const NekDouble > &from, const BasisKey &tbasis0, const BasisKey &tbasis1, Array< OneD, NekDouble > &to)
this function interpolates a 2D function evaluated at the quadrature points of the 2D basis...
Definition: Interp.cpp:116
void AddFaceNormBoundaryInt(const int face, const boost::shared_ptr< Expansion > &FaceExp, const Array< OneD, const NekDouble > &Fn, Array< OneD, NekDouble > &outarray)
Definition: Expansion.cpp:134
Expansion(SpatialDomains::GeometrySharedPtr pGeom)
Definition: Expansion.cpp:48
virtual void v_ComputeLaplacianMetric()
Definition: Expansion.h:141
std::map< StdRegions::VarCoeffType, Array< OneD, NekDouble > > VarCoeffMap
Definition: StdRegions.hpp:227
virtual void v_GetCoords(Array< OneD, NekDouble > &coords_1, Array< OneD, NekDouble > &coords_2, Array< OneD, NekDouble > &coords_3)
Definition: Expansion.cpp:224
virtual DNekScalMatSharedPtr v_GetLocMatrix(const LocalRegions::MatrixKey &mkey)
Definition: Expansion.cpp:181
void DGDeriv(const int dir, const Array< OneD, const NekDouble > &inarray, Array< OneD, ExpansionSharedPtr > &EdgeExp, Array< OneD, Array< OneD, NekDouble > > &coeffs, Array< OneD, NekDouble > &outarray)
Definition: Expansion.cpp:143
double NekDouble
virtual const SpatialDomains::GeomFactorsSharedPtr & v_GetMetricInfo() const
Definition: Expansion.cpp:175
virtual void v_AddFaceNormBoundaryInt(const int face, const boost::shared_ptr< Expansion > &FaceExp, const Array< OneD, const NekDouble > &Fn, Array< OneD, NekDouble > &outarray)
Definition: Expansion.cpp:349
DNekScalMatSharedPtr GetLocMatrix(const LocalRegions::MatrixKey &mkey)
Definition: Expansion.cpp:85
void Interp3D(const BasisKey &fbasis0, const BasisKey &fbasis1, const BasisKey &fbasis2, const Array< OneD, const NekDouble > &from, const BasisKey &tbasis0, const BasisKey &tbasis1, const BasisKey &tbasis2, Array< OneD, NekDouble > &to)
this function interpolates a 3D function evaluated at the quadrature points of the 3D basis...
Definition: Interp.cpp:186
SpatialDomains::GeometrySharedPtr GetGeom() const
Definition: Expansion.cpp:161
boost::shared_ptr< GeomFactors > GeomFactorsSharedPtr
Pointer to a GeomFactors object.
Definition: GeomFactors.h:62
virtual void v_DGDeriv(const int dir, const Array< OneD, const NekDouble > &inarray, Array< OneD, ExpansionSharedPtr > &EdgeExp, Array< OneD, Array< OneD, NekDouble > > &coeffs, Array< OneD, NekDouble > &outarray)
Definition: Expansion.cpp:358
Geometry is straight-sided with constant geometric factors.
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:54
GeomType
Indicates the type of element geometry.
#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 AddEdgeNormBoundaryInt(const int edge, const boost::shared_ptr< Expansion > &EdgeExp, const Array< OneD, const NekDouble > &Fx, const Array< OneD, const NekDouble > &Fy, Array< OneD, NekDouble > &outarray)
Definition: Expansion.cpp:115
Geometry is curved or has non-constant factors.
boost::shared_ptr< Geometry > GeometrySharedPtr
Definition: Geometry.h:53
virtual void v_AddEdgeNormBoundaryInt(const int edge, const boost::shared_ptr< Expansion > &EdgeExp, const Array< OneD, const NekDouble > &Fx, const Array< OneD, const NekDouble > &Fy, Array< OneD, NekDouble > &outarray)
Definition: Expansion.cpp:330
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