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
38{
39
41{
42}
43
44Geometry1D::Geometry1D(const int coordim) : Geometry(coordim)
45{
46}
47
49{
50}
51
53{
54 return 1;
55}
56
59{
60 NekDouble dist = std::numeric_limits<double>::max();
61 v_FillGeom();
62
63 // calculate local coordinate for coord
64 if (GetMetricInfo()->GetGtype() == eRegular)
65 {
66 NekDouble len = 0.0;
67 NekDouble xi = 0.0;
68
69 const int npts = m_xmap->GetTotPoints();
70 Array<OneD, NekDouble> pts(npts);
71
72 for (int i = 0; i < m_coordim; ++i)
73 {
74 m_xmap->BwdTrans(m_coeffs[i], pts);
75 len += (pts[npts - 1] - pts[0]) * (pts[npts - 1] - pts[0]);
76 xi += (coords[i] - pts[0]) * (pts[npts - 1] - pts[0]);
77 }
78 xi = xi / len;
79 if (xi < 0.)
80 {
81 dist = -xi * sqrt(len);
82 }
83 else if (xi > 1.)
84 {
85 dist = (xi - 1.) * sqrt(len);
86 }
87
88 Lcoords[0] = 2. * xi - 1.0;
89 }
90 else
91 {
93 "inverse mapping must be set up to use this call");
94 }
95 return dist;
96}
97} // namespace Nektar::SpatialDomains
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Definition: ErrorUtil.hpp:202
int v_GetShapeDim() const override
Get the object's shape dimension.
Definition: Geometry1D.cpp:52
NekDouble v_GetLocCoords(const Array< OneD, const NekDouble > &coords, Array< OneD, NekDouble > &Lcoords) override
Determine the local collapsed coordinates that correspond to a given Cartesian coordinate for this ge...
Definition: Geometry1D.cpp:57
Base class for shape geometry information.
Definition: Geometry.h:79
virtual void v_FillGeom()
Populate the coordinate mapping Geometry::m_coeffs information from any children geometry elements.
Definition: Geometry.cpp:375
Array< OneD, Array< OneD, NekDouble > > m_coeffs
Array containing expansion coefficients of m_xmap.
Definition: Geometry.h:201
GeomFactorsSharedPtr GetMetricInfo()
Get the geometric factors for this object.
Definition: Geometry.h:308
StdRegions::StdExpansionSharedPtr m_xmap
mapping containing isoparametric transformation.
Definition: Geometry.h:189
int m_coordim
Coordinate dimension of this geometry object.
Definition: Geometry.h:183
@ eRegular
Geometry is straight-sided with constant geometric factors.
double NekDouble
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:294