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 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 
105  const int edge,
106  const boost::shared_ptr<Expansion> &EdgeExp,
109  Array<OneD, NekDouble> &outarray)
110  {
111  v_AddEdgeNormBoundaryInt(edge, EdgeExp, Fx, Fy, outarray);
112  }
113 
115  const int edge,
116  const boost::shared_ptr<Expansion> &EdgeExp,
118  Array<OneD, NekDouble> &outarray)
119  {
120  v_AddEdgeNormBoundaryInt(edge, EdgeExp, Fn, outarray);
121  }
122 
124  const int face,
125  const boost::shared_ptr<Expansion> &FaceExp,
127  Array<OneD, NekDouble> &outarray)
128  {
129  v_AddFaceNormBoundaryInt(face, FaceExp, Fn, outarray);
130  }
131 
133  const int dir,
134  const Array<OneD, const NekDouble>& inarray,
136  Array<OneD, Array<OneD, NekDouble> > &coeffs,
137  Array<OneD, NekDouble> &outarray)
138  {
139  v_DGDeriv(dir, inarray, EdgeExp, coeffs, outarray);
140  }
141 
143  const StdRegions::ConstFactorMap &factors,
144  const StdRegions::VarCoeffMap &varcoeffs)
145  {
146  MatrixKey mkey(mtype, DetShapeType(), *this, factors, varcoeffs);
147  return GetLocMatrix(mkey);
148  }
149 
151  {
152  return m_geom;
153  }
154 
156  {
157  // Clear metrics
158  m_metrics.clear();
159 
160  // Regenerate geometry factors
161  m_metricinfo = m_geom->GetGeomFactors();
162  }
163 
165  {
166  return m_metricinfo;
167  }
168 
169 
171  {
172  NEKERROR(ErrorUtil::efatal, "This function is only valid for LocalRegions");
174  }
175 
177  Array<OneD, NekDouble> &outarray)
178  {
179  const int nqtot = GetTotPoints();
180 
181  if (m_metrics.count(eMetricQuadrature) == 0)
182  {
184  }
185 
186  Vmath::Vmul(nqtot, m_metrics[eMetricQuadrature], 1, inarray, 1, outarray, 1);
187  }
188 
190  {
192  }
193 
195  {
196  unsigned int nqtot = GetTotPoints();
197  SpatialDomains::GeomType type = m_metricinfo->GetGtype();
199  if (type == SpatialDomains::eRegular ||
201  {
203  }
204  else
205  {
207  }
208 
210  m_metrics[eMetricQuadrature]);
211  }
212 
214  Array<OneD, NekDouble> &coords_0,
215  Array<OneD, NekDouble> &coords_1,
216  Array<OneD, NekDouble> &coords_2)
217  {
218  ASSERTL1(m_geom, "m_geom not defined");
219 
220  // get physical points defined in Geom
221  m_geom->FillGeom();
222 
223  const int expDim = m_base.num_elements();
224  int nqGeom = 1;
225  bool doCopy = true;
226 
229 
230  for (int i = 0; i < expDim; ++i)
231  {
232  CBasis[i] = m_geom->GetBasis(i);
233  nqGeom *= CBasis[i]->GetNumPoints();
234  doCopy = doCopy && m_base[i]->GetBasisKey().SamePoints(
235  CBasis[i]->GetBasisKey());
236  }
237 
238  tmp[0] = coords_0;
239  tmp[1] = coords_1;
240  tmp[2] = coords_2;
241 
242  if (doCopy)
243  {
244  for (int i = 0; i < m_geom->GetCoordim(); ++i)
245  {
246  m_geom->GetXmap()->BwdTrans(m_geom->GetCoeffs(i), tmp[i]);
247  }
248  }
249  else
250  {
251  for (int i = 0; i < m_geom->GetCoordim(); ++i)
252  {
253  Array<OneD, NekDouble> tmpGeom(nqGeom);
254  m_geom->GetXmap()->BwdTrans(m_geom->GetCoeffs(i), tmpGeom);
255 
256  switch (expDim)
257  {
258  case 1:
259  {
261  CBasis[0]->GetPointsKey(), &tmpGeom[0],
262  m_base[0]->GetPointsKey(), &tmp[i][0]);
263  break;
264  }
265  case 2:
266  {
268  CBasis[0]->GetPointsKey(),
269  CBasis[1]->GetPointsKey(),
270  &tmpGeom[0],
271  m_base[0]->GetPointsKey(),
272  m_base[1]->GetPointsKey(),
273  &tmp[i][0]);
274  break;
275  }
276  case 3:
277  {
279  CBasis[0]->GetPointsKey(),
280  CBasis[1]->GetPointsKey(),
281  CBasis[2]->GetPointsKey(),
282  &tmpGeom[0],
283  m_base[0]->GetPointsKey(),
284  m_base[1]->GetPointsKey(),
285  m_base[2]->GetPointsKey(),
286  &tmp[i][0]);
287  break;
288  }
289  }
290  }
291  }
292  }
293 
295  const DNekScalMatSharedPtr &r_bnd,
296  const StdRegions::MatrixType matrixType)
297  {
298  NEKERROR(ErrorUtil::efatal, "This function is only valid for LocalRegions");
299  return NullDNekMatSharedPtr;
300  }
301 
303  const DNekScalMatSharedPtr &r_bnd)
304  {
305  NEKERROR(ErrorUtil::efatal, "This function is only valid for LocalRegions");
306  return NullDNekMatSharedPtr;
307  }
308 
310  const int edge,
311  const boost::shared_ptr<Expansion> &EdgeExp,
314  Array<OneD, NekDouble> &outarray)
315  {
316  NEKERROR(ErrorUtil::efatal, "This function is only valid for LocalRegions");
317  }
318 
320  const int edge,
321  const boost::shared_ptr<Expansion> &EdgeExp,
323  Array<OneD, NekDouble> &outarray)
324  {
325  NEKERROR(ErrorUtil::efatal, "This function is only valid for LocalRegions");
326  }
327 
329  const int face,
330  const boost::shared_ptr<Expansion> &FaceExp,
332  Array<OneD, NekDouble> &outarray)
333  {
334  NEKERROR(ErrorUtil::efatal, "This function is only valid for LocalRegions");
335  }
336 
338  const int dir,
339  const Array<OneD, const NekDouble>& inarray,
341  Array<OneD, Array<OneD, NekDouble> > &coeffs,
342  Array<OneD, NekDouble> &outarray)
343  {
344  NEKERROR(ErrorUtil::efatal, "This function is only valid for LocalRegions");
345  }
346  } //end of namespace
347 } //end of namespace
348 
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:90
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:176
SpatialDomains::GeomFactorsSharedPtr m_metricinfo
Definition: Expansion.h:126
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: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:294
virtual DNekMatSharedPtr v_BuildVertexMatrix(const DNekScalMatSharedPtr &r_bnd)
Definition: Expansion.cpp:302
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:123
Expansion(SpatialDomains::GeometrySharedPtr pGeom)
Definition: Expansion.cpp:48
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:213
virtual DNekScalMatSharedPtr v_GetLocMatrix(const LocalRegions::MatrixKey &mkey)
Definition: Expansion.cpp:170
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:132
virtual const SpatialDomains::GeomFactorsSharedPtr & v_GetMetricInfo() const
Definition: Expansion.cpp:164
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:328
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:150
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:337
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:104
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:309
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