Nektar++
Geometry1D.cpp
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: Geometry1D.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 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description: 1D geometry information
32 //
33 //
34 ////////////////////////////////////////////////////////////////////////////////
36 
37 namespace Nektar
38 {
39 namespace SpatialDomains
40 {
41 
43 {
44 }
45 
46 Geometry1D::Geometry1D(const int coordim) : Geometry(coordim)
47 {
48 }
49 
51 {
52 }
53 
55 {
56  return 1;
57 }
58 
60  Array<OneD, NekDouble> &Lcoords)
61 {
62  NekDouble dist = 0.;
63  v_FillGeom();
64 
65  // calculate local coordinate for coord
66  if (GetMetricInfo()->GetGtype() == eRegular)
67  {
68  NekDouble len = 0.0;
69  NekDouble xi = 0.0;
70 
71  const int npts = m_xmap->GetTotPoints();
72  Array<OneD, NekDouble> pts(npts);
73 
74  for (int i = 0; i < m_coordim; ++i)
75  {
76  m_xmap->BwdTrans(m_coeffs[i], pts);
77  len += (pts[npts - 1] - pts[0]) * (pts[npts - 1] - pts[0]);
78  xi += (coords[i] - pts[0]) * (pts[npts-1] - pts[0]);
79  }
80  xi = xi / len;
81  if(xi<0.)
82  {
83  dist = - xi * sqrt(len);
84  }
85  else if(xi>1.)
86  {
87  dist = (xi - 1.) * sqrt(len);
88  }
89 
90  Lcoords[0] = 2. * xi - 1.0;
91  }
92  else
93  {
95  "inverse mapping must be set up to use this call");
96  }
97  return dist;
98 }
99 }
100 }
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Definition: ErrorUtil.hpp:209
virtual NekDouble v_GetLocCoords(const Array< OneD, const NekDouble > &coords, Array< OneD, NekDouble > &Lcoords)
Determine the local collapsed coordinates that correspond to a given Cartesian coordinate for this ge...
Definition: Geometry1D.cpp:59
virtual int v_GetShapeDim() const
Get the object's shape dimension.
Definition: Geometry1D.cpp:54
Base class for shape geometry information.
Definition: Geometry.h:84
virtual void v_FillGeom()
Populate the coordinate mapping Geometry::m_coeffs information from any children geometry elements.
Definition: Geometry.cpp:346
Array< OneD, Array< OneD, NekDouble > > m_coeffs
Array containing expansion coefficients of m_xmap.
Definition: Geometry.h:203
GeomFactorsSharedPtr GetMetricInfo()
Get the geometric factors for this object.
Definition: Geometry.h:303
StdRegions::StdExpansionSharedPtr m_xmap
mapping containing isoparametric transformation.
Definition: Geometry.h:191
int m_coordim
Coordinate dimension of this geometry object.
Definition: Geometry.h:185
@ eRegular
Geometry is straight-sided with constant geometric factors.
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
double NekDouble
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:267