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 StdRegions::ConstFactorMap &factors,
104  const StdRegions::VarCoeffMap &varcoeffs)
105  {
106  MatrixKey mkey(mtype, DetShapeType(), *this, factors, varcoeffs);
107  return GetLocMatrix(mkey);
108  }
109 
111  {
112  return m_geom;
113  }
114 
116  {
117  return m_metricinfo;
118  }
119 
120 
122  {
123  NEKERROR(ErrorUtil::efatal, "This function is only valid for LocalRegions");
125  }
126 
127  void Expansion::v_MultiplyByQuadratureMetric(const Array<OneD, const NekDouble>& inarray,
128  Array<OneD, NekDouble> &outarray)
129  {
130  const int nqtot = GetTotPoints();
131 
132  if (m_metrics.count(MetricQuadrature) == 0)
133  {
135  }
136 
137  Vmath::Vmul(nqtot, m_metrics[MetricQuadrature], 1, inarray, 1, outarray, 1);
138  }
139 
141  {
143  }
144 
146  {
147  unsigned int nqtot = GetTotPoints();
148  SpatialDomains::GeomType type = m_metricinfo->GetGtype();
150  if (type == SpatialDomains::eRegular ||
152  {
153  m_metrics[MetricQuadrature] = Array<OneD, NekDouble>(nqtot, m_metricinfo->GetJac(p)[0]);
154  }
155  else
156  {
158  }
159 
161  m_metrics[MetricQuadrature]);
162  }
163 
165  Array<OneD, NekDouble> &coords_0,
166  Array<OneD, NekDouble> &coords_1,
167  Array<OneD, NekDouble> &coords_2)
168  {
169  ASSERTL1(m_geom, "m_geom not defined");
170 
171  // get physical points defined in Geom
172  m_geom->FillGeom();
173 
174  const int expDim = m_base.num_elements();
175  int nqGeom = 1;
176  bool doCopy = true;
177 
178  Array<OneD, LibUtilities::BasisSharedPtr> CBasis(expDim);
179  Array<OneD, Array<OneD, NekDouble> > tmp(3);
180 
181  for (int i = 0; i < expDim; ++i)
182  {
183  CBasis[i] = m_geom->GetBasis(i);
184  nqGeom *= CBasis[i]->GetNumPoints();
185  doCopy = doCopy && m_base[i]->GetBasisKey().SamePoints(
186  CBasis[i]->GetBasisKey());
187  }
188 
189  tmp[0] = coords_0;
190  tmp[1] = coords_1;
191  tmp[2] = coords_2;
192 
193  if (doCopy)
194  {
195  for (int i = 0; i < m_geom->GetCoordim(); ++i)
196  {
197  m_geom->GetXmap()->BwdTrans(m_geom->GetCoeffs(i), tmp[i]);
198  }
199  }
200  else
201  {
202  for (int i = 0; i < m_geom->GetCoordim(); ++i)
203  {
204  Array<OneD, NekDouble> tmpGeom(nqGeom);
205  m_geom->GetXmap()->BwdTrans(m_geom->GetCoeffs(i), tmpGeom);
206 
207  switch (expDim)
208  {
209  case 1:
210  {
212  CBasis[0]->GetPointsKey(), &tmpGeom[0],
213  m_base[0]->GetPointsKey(), &tmp[i][0]);
214  break;
215  }
216  case 2:
217  {
219  CBasis[0]->GetPointsKey(),
220  CBasis[1]->GetPointsKey(),
221  &tmpGeom[0],
222  m_base[0]->GetPointsKey(),
223  m_base[1]->GetPointsKey(),
224  &tmp[i][0]);
225  break;
226  }
227  case 3:
228  {
230  CBasis[0]->GetPointsKey(),
231  CBasis[1]->GetPointsKey(),
232  CBasis[2]->GetPointsKey(),
233  &tmpGeom[0],
234  m_base[0]->GetPointsKey(),
235  m_base[1]->GetPointsKey(),
236  m_base[2]->GetPointsKey(),
237  &tmp[i][0]);
238  break;
239  }
240  }
241  }
242  }
243  }
244 
246  const DNekScalMatSharedPtr &r_bnd,
247  const StdRegions::MatrixType matrixType)
248  {
249  NEKERROR(ErrorUtil::efatal, "This function is only valid for LocalRegions");
250  return NullDNekMatSharedPtr;
251  }
252 
254  const DNekScalMatSharedPtr &r_bnd)
255  {
256  NEKERROR(ErrorUtil::efatal, "This function is only valid for LocalRegions");
257  return NullDNekMatSharedPtr;
258  }
259  } //end of namespace
260 } //end of namespace
261