Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 namespace Nektar
43 {
44  namespace LocalRegions
45  {
47  m_geom(pGeom),
48  m_metricinfo(m_geom->GetGeomFactors())
49  {
50  if (!m_metricinfo)
51  {
52  return;
53  }
54 
55  if (!m_metricinfo->IsValid())
56  {
57  int nDim = m_base.num_elements();
58  string type = "regular";
59  if (m_metricinfo->GetGtype() == SpatialDomains::eDeformed)
60  {
61  type = "deformed";
62  }
63 
64  stringstream err;
65  err << nDim << "D " << type << " Jacobian not positive "
66  << "(element ID = " << m_geom->GetGlobalID() << ") "
67  << "(first vertex ID = " << m_geom->GetVid(0) << ")";
68  NEKERROR(ErrorUtil::ewarning, err.str());
69  }
70  }
71 
73  m_geom(pSrc.m_geom),
74  m_metricinfo(pSrc.m_metricinfo)
75  {
76 
77  }
78 
80  {
81  }
82 
84  {
85  return v_GetLocMatrix(mkey);
86  }
87 
89  const DNekScalMatSharedPtr &r_bnd,
90  const StdRegions::MatrixType matrixType)
91  {
92  return v_BuildTransformationMatrix(r_bnd,matrixType);
93  }
94 
95 
97  const DNekScalMatSharedPtr &r_bnd)
98  {
99  return v_BuildVertexMatrix(r_bnd);
100  }
101 
103  const int edge,
104  const boost::shared_ptr<Expansion> &EdgeExp,
107  Array<OneD, NekDouble> &outarray)
108  {
109  v_AddEdgeNormBoundaryInt(edge, EdgeExp, Fx, Fy, outarray);
110  }
111 
113  const int edge,
114  const boost::shared_ptr<Expansion> &EdgeExp,
116  Array<OneD, NekDouble> &outarray)
117  {
118  v_AddEdgeNormBoundaryInt(edge, EdgeExp, Fn, outarray);
119  }
120 
122  const int face,
123  const boost::shared_ptr<Expansion> &FaceExp,
125  Array<OneD, NekDouble> &outarray)
126  {
127  v_AddFaceNormBoundaryInt(face, FaceExp, Fn, outarray);
128  }
129 
131  const int dir,
132  const Array<OneD, const NekDouble>& inarray,
134  Array<OneD, Array<OneD, NekDouble> > &coeffs,
135  Array<OneD, NekDouble> &outarray)
136  {
137  v_DGDeriv(dir, inarray, EdgeExp, coeffs, outarray);
138  }
139 
141  const StdRegions::ConstFactorMap &factors,
142  const StdRegions::VarCoeffMap &varcoeffs)
143  {
144  MatrixKey mkey(mtype, DetShapeType(), *this, factors, varcoeffs);
145  return GetLocMatrix(mkey);
146  }
147 
149  {
150  return m_geom;
151  }
152 
154  {
155  // Clear metrics
156  m_metrics.clear();
157 
158  // Regenerate geometry factors
159  m_metricinfo = m_geom->GetGeomFactors();
160  }
161 
163  {
164  return m_metricinfo;
165  }
166 
167 
169  {
170  NEKERROR(ErrorUtil::efatal, "This function is only valid for LocalRegions");
172  }
173 
175  Array<OneD, NekDouble> &outarray)
176  {
177  const int nqtot = GetTotPoints();
178 
179  if (m_metrics.count(eMetricQuadrature) == 0)
180  {
182  }
183 
184  Vmath::Vmul(nqtot, m_metrics[eMetricQuadrature], 1, inarray, 1, outarray, 1);
185  }
186 
188  {
190  }
191 
193  {
194  unsigned int nqtot = GetTotPoints();
195  SpatialDomains::GeomType type = m_metricinfo->GetGtype();
197  if (type == SpatialDomains::eRegular ||
199  {
201  }
202  else
203  {
205  }
206 
208  m_metrics[eMetricQuadrature]);
209  }
210 
212  Array<OneD, NekDouble> &coords_0,
213  Array<OneD, NekDouble> &coords_1,
214  Array<OneD, NekDouble> &coords_2)
215  {
216  ASSERTL1(m_geom, "m_geom not defined");
217 
218  // get physical points defined in Geom
219  m_geom->FillGeom();
220 
221  const int expDim = m_base.num_elements();
222  int nqGeom = 1;
223  bool doCopy = true;
224 
227 
228  for (int i = 0; i < expDim; ++i)
229  {
230  CBasis[i] = m_geom->GetBasis(i);
231  nqGeom *= CBasis[i]->GetNumPoints();
232  doCopy = doCopy && m_base[i]->GetBasisKey().SamePoints(
233  CBasis[i]->GetBasisKey());
234  }
235 
236  tmp[0] = coords_0;
237  tmp[1] = coords_1;
238  tmp[2] = coords_2;
239 
240  if (doCopy)
241  {
242  for (int i = 0; i < m_geom->GetCoordim(); ++i)
243  {
244  m_geom->GetXmap()->BwdTrans(m_geom->GetCoeffs(i), tmp[i]);
245  }
246  }
247  else
248  {
249  for (int i = 0; i < m_geom->GetCoordim(); ++i)
250  {
251  Array<OneD, NekDouble> tmpGeom(nqGeom);
252  m_geom->GetXmap()->BwdTrans(m_geom->GetCoeffs(i), tmpGeom);
253 
254  switch (expDim)
255  {
256  case 1:
257  {
259  CBasis[0]->GetPointsKey(), &tmpGeom[0],
260  m_base[0]->GetPointsKey(), &tmp[i][0]);
261  break;
262  }
263  case 2:
264  {
266  CBasis[0]->GetPointsKey(),
267  CBasis[1]->GetPointsKey(),
268  &tmpGeom[0],
269  m_base[0]->GetPointsKey(),
270  m_base[1]->GetPointsKey(),
271  &tmp[i][0]);
272  break;
273  }
274  case 3:
275  {
277  CBasis[0]->GetPointsKey(),
278  CBasis[1]->GetPointsKey(),
279  CBasis[2]->GetPointsKey(),
280  &tmpGeom[0],
281  m_base[0]->GetPointsKey(),
282  m_base[1]->GetPointsKey(),
283  m_base[2]->GetPointsKey(),
284  &tmp[i][0]);
285  break;
286  }
287  }
288  }
289  }
290  }
291 
293  const DNekScalMatSharedPtr &r_bnd,
294  const StdRegions::MatrixType matrixType)
295  {
296  NEKERROR(ErrorUtil::efatal, "This function is only valid for LocalRegions");
297  return NullDNekMatSharedPtr;
298  }
299 
301  const DNekScalMatSharedPtr &r_bnd)
302  {
303  NEKERROR(ErrorUtil::efatal, "This function is only valid for LocalRegions");
304  return NullDNekMatSharedPtr;
305  }
306 
308  const int edge,
309  const boost::shared_ptr<Expansion> &EdgeExp,
312  Array<OneD, NekDouble> &outarray)
313  {
314  NEKERROR(ErrorUtil::efatal, "This function is only valid for LocalRegions");
315  }
316 
318  const int edge,
319  const boost::shared_ptr<Expansion> &EdgeExp,
321  Array<OneD, NekDouble> &outarray)
322  {
323  NEKERROR(ErrorUtil::efatal, "This function is only valid for LocalRegions");
324  }
325 
327  const int face,
328  const boost::shared_ptr<Expansion> &FaceExp,
330  Array<OneD, NekDouble> &outarray)
331  {
332  NEKERROR(ErrorUtil::efatal, "This function is only valid for LocalRegions");
333  }
334 
336  const int dir,
337  const Array<OneD, const NekDouble>& inarray,
339  Array<OneD, Array<OneD, NekDouble> > &coeffs,
340  Array<OneD, NekDouble> &outarray)
341  {
342  NEKERROR(ErrorUtil::efatal, "This function is only valid for LocalRegions");
343  }
344  } //end of namespace
345 } //end of namespace
346 
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:158
std::vector< PointsKey > PointsKeyVector
Definition: Points.h:220
DNekMatSharedPtr BuildTransformationMatrix(const DNekScalMatSharedPtr &r_bnd, const StdRegions::MatrixType matrixType)
Definition: Expansion.cpp:88
void MultiplyByStdQuadratureMetric(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Definition: StdExpansion.h:949
virtual void v_MultiplyByQuadratureMetric(const Array< OneD, const NekDouble > &inarray, Array< OneD, NekDouble > &outarray)
Definition: Expansion.cpp:174
SpatialDomains::GeomFactorsSharedPtr m_metricinfo
Definition: Expansion.h:126
static DNekScalMatSharedPtr NullDNekScalMatSharedPtr
Definition: NekTypeDefs.hpp:80
DNekMatSharedPtr BuildVertexMatrix(const DNekScalMatSharedPtr &r_bnd)
Definition: Expansion.cpp:96
std::map< ConstFactorType, NekDouble > ConstFactorMap
Definition: StdRegions.hpp:251
SpatialDomains::GeometrySharedPtr m_geom
Definition: Expansion.h:125
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:292
virtual DNekMatSharedPtr v_BuildVertexMatrix(const DNekScalMatSharedPtr &r_bnd)
Definition: Expansion.cpp:300
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:121
Expansion(SpatialDomains::GeometrySharedPtr pGeom)
Definition: Expansion.cpp:46
virtual void v_ComputeLaplacianMetric()
Definition: Expansion.h:136
std::map< StdRegions::VarCoeffType, Array< OneD, NekDouble > > VarCoeffMap
Definition: StdRegions.hpp:226
virtual void v_GetCoords(Array< OneD, NekDouble > &coords_1, Array< OneD, NekDouble > &coords_2, Array< OneD, NekDouble > &coords_3)
Definition: Expansion.cpp:211
virtual DNekScalMatSharedPtr v_GetLocMatrix(const LocalRegions::MatrixKey &mkey)
Definition: Expansion.cpp:168
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:130
virtual const SpatialDomains::GeomFactorsSharedPtr & v_GetMetricInfo() const
Definition: Expansion.cpp:162
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:326
DNekScalMatSharedPtr GetLocMatrix(const LocalRegions::MatrixKey &mkey)
Definition: Expansion.cpp:83
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:148
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:335
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:191
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:102
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:307
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:169