Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
Nektar::SpatialDomains::Geometry2D Class Reference

2D geometry information More...

#include <Geometry2D.h>

Inheritance diagram for Nektar::SpatialDomains::Geometry2D:
Inheritance graph
[legend]
Collaboration diagram for Nektar::SpatialDomains::Geometry2D:
Collaboration graph
[legend]

Public Member Functions

 Geometry2D ()
 Geometry2D (const int coordim)
virtual ~Geometry2D ()
int GetFid () const
const Geometry1DSharedPtr GetEdge (int i) const
const Geometry2DSharedPtr GetFace (int i) const
int WhichEdge (SegGeomSharedPtr edge)
int WhichFace (Geometry2DSharedPtr face)
const LibUtilities::BasisSharedPtr GetEdgeBasis (const int i)
StdRegions::Orientation GetFaceOrient (const int i) const
StdRegions::Orientation GetCartesianEorient (const int i) const
- Public Member Functions inherited from Nektar::SpatialDomains::Geometry
 Geometry ()
 Geometry (int coordim)
virtual ~Geometry ()
bool IsElmtConnected (int gvo_id, int locid) const
void AddElmtConnected (int gvo_id, int locid)
int NumElmtConnected () const
int GetCoordim () const
void SetCoordim (int coordim)
GeomFactorsSharedPtr GetGeomFactors ()
GeomFactorsSharedPtr GetRefGeomFactors (const Array< OneD, const LibUtilities::BasisSharedPtr > &tbasis)
GeomFactorsSharedPtr GetMetricInfo ()
LibUtilities::ShapeType GetShapeType (void)
int GetGlobalID (void)
void SetGlobalID (int globalid)
int GetVid (int i) const
int GetEid (int i) const
int GetFid (int i) const
int GetTid (int i) const
int GetNumVerts () const
PointGeomSharedPtr GetVertex (int i) const
StdRegions::Orientation GetEorient (const int i) const
StdRegions::Orientation GetPorient (const int i) const
StdRegions::Orientation GetForient (const int i) const
int GetNumEdges () const
int GetNumFaces () const
int GetShapeDim () const
StdRegions::StdExpansionSharedPtr GetXmap () const
const Array< OneD, const
NekDouble > & 
GetCoeffs (const int i) const
bool ContainsPoint (const Array< OneD, const NekDouble > &gloCoord, NekDouble tol=0.0)
bool ContainsPoint (const Array< OneD, const NekDouble > &gloCoord, Array< OneD, NekDouble > &locCoord, NekDouble tol)
bool ContainsPoint (const Array< OneD, const NekDouble > &gloCoord, Array< OneD, NekDouble > &locCoord, NekDouble tol, NekDouble &resid)
int GetVertexEdgeMap (int i, int j) const
int GetVertexFaceMap (int i, int j) const
 return the id of the $j^{th}$ face attached to the $ i^{th}$ vertex
int GetEdgeFaceMap (int i, int j) const
void FillGeom ()
 Put all quadrature information into face/edge structure and backward transform.
NekDouble GetLocCoords (const Array< OneD, const NekDouble > &coords, Array< OneD, NekDouble > &Lcoords)
NekDouble GetCoord (const int i, const Array< OneD, const NekDouble > &Lcoord)
 Given local collapsed coordinate Lcoord return the value of physical coordinate in direction i.
void SetOwnData ()
const LibUtilities::BasisSharedPtr GetBasis (const int i)
 Return the j-th basis of the i-th co-ordinate dimension.
const LibUtilities::PointsKeyVector GetPointsKeys ()

Protected Member Functions

void NewtonIterationForLocCoord (const Array< OneD, const NekDouble > &coords, const Array< OneD, const NekDouble > &ptsx, const Array< OneD, const NekDouble > &ptsy, Array< OneD, NekDouble > &Lcoords, NekDouble &resid)
- Protected Member Functions inherited from Nektar::SpatialDomains::Geometry
void GenGeomFactors ()
virtual bool v_IsElmtConnected (int gvo_id, int locid) const
virtual void v_AddElmtConnected (int gvo_id, int locid)
virtual int v_NumElmtConnected () const
virtual int v_GetEid (int i) const
virtual int v_GetVid (int i) const
virtual int v_GetFid (int i) const
virtual void v_GenGeomFactors ()=0
virtual int v_GetNumVerts () const
virtual PointGeomSharedPtr v_GetVertex (int i) const =0
virtual StdRegions::Orientation v_GetEorient (const int i) const
virtual StdRegions::Orientation v_GetPorient (const int i) const
virtual StdRegions::Orientation v_GetForient (const int i) const
virtual int v_GetNumEdges () const
virtual int v_GetNumFaces () const
virtual int v_GetShapeDim () const
virtual
StdRegions::StdExpansionSharedPtr 
v_GetXmap () const
virtual int v_GetCoordim () const
virtual bool v_ContainsPoint (const Array< OneD, const NekDouble > &gloCoord, NekDouble tol=0.0)
virtual bool v_ContainsPoint (const Array< OneD, const NekDouble > &gloCoord, Array< OneD, NekDouble > &locCoord, NekDouble tol)
virtual bool v_ContainsPoint (const Array< OneD, const NekDouble > &gloCoord, Array< OneD, NekDouble > &locCoord, NekDouble tol, NekDouble &resid)
virtual int v_GetVertexEdgeMap (int i, int j) const
virtual int v_GetVertexFaceMap (int i, int j) const
virtual int v_GetEdgeFaceMap (int i, int j) const
virtual void v_FillGeom ()
virtual NekDouble v_GetCoord (const int i, const Array< OneD, const NekDouble > &Lcoord)
virtual NekDouble v_GetLocCoords (const Array< OneD, const NekDouble > &coords, Array< OneD, NekDouble > &Lcoords)
virtual void v_SetOwnData ()
virtual const
LibUtilities::BasisSharedPtr 
v_GetBasis (const int i)
void SetUpCoeffs (const int nCoeffs)

Private Member Functions

virtual int v_GetShapeDim () const
virtual int v_GetFid () const
virtual int v_GetEid (int i) const
virtual PointGeomSharedPtr v_GetVertex (int i) const
virtual const Geometry1DSharedPtr v_GetEdge (int i) const
virtual const Geometry2DSharedPtr v_GetFace (int i) const
virtual StdRegions::Orientation v_GetFaceOrient (const int i) const
virtual StdRegions::Orientation v_GetEorient (const int i) const
virtual StdRegions::Orientation v_GetCartesianEorient (const int i) const
virtual int v_WhichEdge (SegGeomSharedPtr edge)
virtual int v_WhichFace (Geometry2DSharedPtr face)
virtual const
LibUtilities::BasisSharedPtr 
v_GetEdgeBasis (const int i)
virtual bool v_ContainsPoint (const Array< OneD, const NekDouble > &gloCoord, NekDouble tol=0.0)

Additional Inherited Members

- Static Protected Member Functions inherited from Nektar::SpatialDomains::Geometry
static GeomFactorsSharedPtr ValidateRegGeomFactor (GeomFactorsSharedPtr geomFactor)
- Protected Attributes inherited from Nektar::SpatialDomains::Geometry
int m_coordim
 coordinate dimension
GeomFactorsSharedPtr m_geomFactors
GeomState m_geomFactorsState
StdRegions::StdExpansionSharedPtr m_xmap
GeomState m_state
 enum identifier to determine if quad points are filled
GeomType m_geomType
LibUtilities::ShapeType m_shapeType
int m_globalID
Array< OneD, Array< OneD,
NekDouble > > 
m_coeffs
- Static Protected Attributes inherited from Nektar::SpatialDomains::Geometry
static GeomFactorsVector m_regGeomFactorsManager

Detailed Description

2D geometry information

Definition at line 65 of file Geometry2D.h.

Constructor & Destructor Documentation

Nektar::SpatialDomains::Geometry2D::Geometry2D ( )

Definition at line 45 of file Geometry2D.cpp.

{
}
Nektar::SpatialDomains::Geometry2D::Geometry2D ( const int  coordim)

Definition at line 49 of file Geometry2D.cpp.

References ASSERTL0, and Nektar::SpatialDomains::Geometry::m_coordim.

:
Geometry(coordim)
{
"Coordinate dimension should be at least 2 for a 2D geometry");
}
Nektar::SpatialDomains::Geometry2D::~Geometry2D ( )
virtual

Definition at line 56 of file Geometry2D.cpp.

{
}

Member Function Documentation

StdRegions::Orientation Nektar::SpatialDomains::Geometry2D::GetCartesianEorient ( const int  i) const

Definition at line 85 of file Geometry2D.cpp.

References v_GetCartesianEorient().

{
}
const Geometry1DSharedPtr Nektar::SpatialDomains::Geometry2D::GetEdge ( int  i) const

Definition at line 80 of file Geometry2D.cpp.

References v_GetEdge().

{
return v_GetEdge(i);
}
const LibUtilities::BasisSharedPtr Nektar::SpatialDomains::Geometry2D::GetEdgeBasis ( const int  i)

Definition at line 65 of file Geometry2D.cpp.

References v_GetEdgeBasis().

{
return v_GetEdgeBasis(i);
}
const Geometry2DSharedPtr Nektar::SpatialDomains::Geometry2D::GetFace ( int  i) const

Definition at line 70 of file Geometry2D.cpp.

References v_GetFace().

{
return v_GetFace(i);
}
StdRegions::Orientation Nektar::SpatialDomains::Geometry2D::GetFaceOrient ( const int  i) const

Definition at line 75 of file Geometry2D.cpp.

References v_GetFaceOrient().

{
return v_GetFaceOrient(i);
}
int Nektar::SpatialDomains::Geometry2D::GetFid ( ) const

Definition at line 60 of file Geometry2D.cpp.

References v_GetFid().

{
return v_GetFid();
}
void Nektar::SpatialDomains::Geometry2D::NewtonIterationForLocCoord ( const Array< OneD, const NekDouble > &  coords,
const Array< OneD, const NekDouble > &  ptsx,
const Array< OneD, const NekDouble > &  ptsy,
Array< OneD, NekDouble > &  Lcoords,
NekDouble resid 
)
protected

Definition at line 100 of file Geometry2D.cpp.

References Nektar::SpatialDomains::Geometry::m_geomFactors, Nektar::SpatialDomains::Geometry::m_xmap, Vmath::Vsum(), and WARNINGL1.

Referenced by Nektar::SpatialDomains::QuadGeom::v_GetLocCoords(), and Nektar::SpatialDomains::TriGeom::v_GetLocCoords().

{
// Maximum iterations for convergence
const int MaxIterations = 51;
// |x-xp|^2 < EPSILON error tolerance
const NekDouble Tol = 1.e-8;
// |r,s| > LcoordDIV stop the search
const NekDouble LcoordDiv = 15.0;
Array<OneD, const NekDouble > Jac =
m_geomFactors->GetJac(m_xmap->GetPointsKeys());
NekDouble ScaledTol = Vmath::Vsum(Jac.num_elements(),Jac,1)/
((NekDouble)Jac.num_elements());
ScaledTol *= Tol;
NekDouble xmap,ymap, F1,F2;
NekDouble derx_1, derx_2, dery_1, dery_2,jac;
// save intiial guess for later reference if required.
NekDouble init0 = Lcoords[0], init1 = Lcoords[1];
Array<OneD, NekDouble> DxD1(ptsx.num_elements());
Array<OneD, NekDouble> DxD2(ptsx.num_elements());
Array<OneD, NekDouble> DyD1(ptsx.num_elements());
Array<OneD, NekDouble> DyD2(ptsx.num_elements());
// Ideally this will be stored in m_geomfactors
m_xmap->PhysDeriv(ptsx,DxD1,DxD2);
m_xmap->PhysDeriv(ptsy,DyD1,DyD2);
int cnt=0;
Array<OneD, DNekMatSharedPtr > I(2);
Array<OneD, NekDouble> eta(2);
F1 = F2 = 2000; // Starting value of Function
while(cnt++ < MaxIterations)
{
// evaluate lagrange interpolant at Lcoords
m_xmap->LocCoordToLocCollapsed(Lcoords,eta);
I[0] = m_xmap->GetBasis(0)->GetI(eta);
I[1] = m_xmap->GetBasis(1)->GetI(eta+1);
//calculate the global point `corresponding to Lcoords
xmap = m_xmap->PhysEvaluate(I, ptsx);
ymap = m_xmap->PhysEvaluate(I, ptsy);
F1 = coords[0] - xmap;
F2 = coords[1] - ymap;
if(F1*F1 + F2*F2 < ScaledTol)
{
resid = sqrt(F1*F1 + F2*F2);
break;
}
//Interpolate derivative metric at Lcoords
derx_1 = m_xmap->PhysEvaluate(I, DxD1);
derx_2 = m_xmap->PhysEvaluate(I, DxD2);
dery_1 = m_xmap->PhysEvaluate(I, DyD1);
dery_2 = m_xmap->PhysEvaluate(I, DyD2);
jac = dery_2*derx_1 - dery_1*derx_2;
// use analytical inverse of derivitives which are
// also similar to those of metric factors.
Lcoords[0] = Lcoords[0] + (dery_2*(coords[0]-xmap) -
derx_2*(coords[1]-ymap))/jac;
Lcoords[1] = Lcoords[1] + ( - dery_1*(coords[0]-xmap)
+ derx_1*(coords[1]-ymap))/jac;
if(fabs(Lcoords[0]) > LcoordDiv || fabs(Lcoords[1]) > LcoordDiv)
{
break; // lcoords have diverged so stop iteration
}
}
resid = sqrt(F1*F1 + F2*F2);
if(cnt >= MaxIterations)
{
Array<OneD, NekDouble> collCoords(2);
m_xmap->LocCoordToLocCollapsed(Lcoords,collCoords);
// if coordinate is inside element dump error!
if((collCoords[0] >= -1.0 && collCoords[0] <= 1.0)&&
(collCoords[1] >= -1.0 && collCoords[1] <= 1.0))
{
std::ostringstream ss;
ss << "Reached MaxIterations (" << MaxIterations
<< ") in Newton iteration ";
ss << "Init value ("<< setprecision(4) << init0 << ","
<< init1<< "," <<") ";
ss << "Fin value ("<<Lcoords[0] << "," << Lcoords[1]
<< "," << ") ";
ss << "Resid = " << resid << " Tolerance = "
<< sqrt(ScaledTol) ;
WARNINGL1(cnt < MaxIterations,ss.str());
}
}
}
bool Nektar::SpatialDomains::Geometry2D::v_ContainsPoint ( const Array< OneD, const NekDouble > &  gloCoord,
NekDouble  tol = 0.0 
)
privatevirtual

Reimplemented in Nektar::SpatialDomains::TriGeom, and Nektar::SpatialDomains::QuadGeom.

Definition at line 298 of file Geometry2D.cpp.

References ErrorUtil::efatal, and NEKERROR.

{
"This function has not been defined for this geometry");
return false;
}
StdRegions::Orientation Nektar::SpatialDomains::Geometry2D::v_GetCartesianEorient ( const int  i) const
privatevirtual

Reimplemented in Nektar::SpatialDomains::TriGeom, and Nektar::SpatialDomains::QuadGeom.

Definition at line 272 of file Geometry2D.cpp.

References ErrorUtil::efatal, Nektar::StdRegions::eForwards, and NEKERROR.

Referenced by GetCartesianEorient().

{
"This function is only valid for shape type geometries");
}
const Geometry1DSharedPtr Nektar::SpatialDomains::Geometry2D::v_GetEdge ( int  i) const
privatevirtual

Reimplemented in Nektar::SpatialDomains::TriGeom, and Nektar::SpatialDomains::QuadGeom.

Definition at line 234 of file Geometry2D.cpp.

References ErrorUtil::efatal, and NEKERROR.

Referenced by GetEdge().

{
"This function is only valid for shape type geometries");
SegGeomSharedPtr returnval;
return returnval;
}
const LibUtilities::BasisSharedPtr Nektar::SpatialDomains::Geometry2D::v_GetEdgeBasis ( const int  i)
privatevirtual

Reimplemented in Nektar::SpatialDomains::TriGeom, and Nektar::SpatialDomains::QuadGeom.

Definition at line 218 of file Geometry2D.cpp.

References ErrorUtil::efatal, and NEKERROR.

Referenced by GetEdgeBasis().

{
"This function is only valid for shape type geometries");
return returnval;
}
int Nektar::SpatialDomains::Geometry2D::v_GetEid ( int  i) const
privatevirtual

Reimplemented in Nektar::SpatialDomains::TriGeom, and Nektar::SpatialDomains::QuadGeom.

Definition at line 227 of file Geometry2D.cpp.

References ErrorUtil::efatal, and NEKERROR.

{
"This function is only valid for shape type geometries");
return 0;
}
StdRegions::Orientation Nektar::SpatialDomains::Geometry2D::v_GetEorient ( const int  i) const
privatevirtual

Reimplemented in Nektar::SpatialDomains::TriGeom, and Nektar::SpatialDomains::QuadGeom.

Definition at line 250 of file Geometry2D.cpp.

References ErrorUtil::efatal, Nektar::StdRegions::eForwards, and NEKERROR.

{
"This function is only valid for shape type geometries");
}
const Geometry2DSharedPtr Nektar::SpatialDomains::Geometry2D::v_GetFace ( int  i) const
privatevirtual

Definition at line 257 of file Geometry2D.cpp.

References ErrorUtil::efatal, and NEKERROR.

Referenced by GetFace().

{
"This function is only valid for shape type geometries");
return returnval;
}
StdRegions::Orientation Nektar::SpatialDomains::Geometry2D::v_GetFaceOrient ( const int  i) const
privatevirtual

Definition at line 265 of file Geometry2D.cpp.

References Nektar::StdRegions::eDir1FwdDir1_Dir2FwdDir2, ErrorUtil::efatal, and NEKERROR.

Referenced by GetFaceOrient().

{
"This function is only valid for shape type geometries");
}
int Nektar::SpatialDomains::Geometry2D::v_GetFid ( ) const
privatevirtual

Reimplemented in Nektar::SpatialDomains::TriGeom, and Nektar::SpatialDomains::QuadGeom.

Definition at line 211 of file Geometry2D.cpp.

References ErrorUtil::efatal, and NEKERROR.

Referenced by GetFid().

{
"This function is only valid for shape type geometries");
return 0;
}
int Nektar::SpatialDomains::Geometry2D::v_GetShapeDim ( ) const
privatevirtual

Definition at line 293 of file Geometry2D.cpp.

{
return 2;
}
PointGeomSharedPtr Nektar::SpatialDomains::Geometry2D::v_GetVertex ( int  i) const
privatevirtual

Reimplemented in Nektar::SpatialDomains::TriGeom, and Nektar::SpatialDomains::QuadGeom.

Definition at line 242 of file Geometry2D.cpp.

References ErrorUtil::efatal, and NEKERROR.

{
"This function is only valid for shape type geometries");
PointGeomSharedPtr returnval;
return returnval;
}
int Nektar::SpatialDomains::Geometry2D::v_WhichEdge ( SegGeomSharedPtr  edge)
privatevirtual

Reimplemented in Nektar::SpatialDomains::TriGeom, and Nektar::SpatialDomains::QuadGeom.

Definition at line 279 of file Geometry2D.cpp.

References ErrorUtil::efatal, and NEKERROR.

Referenced by WhichEdge().

{
"This function is only valid for shape type geometries");
return 0;
}
int Nektar::SpatialDomains::Geometry2D::v_WhichFace ( Geometry2DSharedPtr  face)
privatevirtual

Definition at line 286 of file Geometry2D.cpp.

References ErrorUtil::efatal, and NEKERROR.

Referenced by WhichFace().

{
"This function is only valid for shape type geometries");
return 0;
}
int Nektar::SpatialDomains::Geometry2D::WhichEdge ( SegGeomSharedPtr  edge)

Definition at line 90 of file Geometry2D.cpp.

References v_WhichEdge().

{
return v_WhichEdge(edge);
}
int Nektar::SpatialDomains::Geometry2D::WhichFace ( Geometry2DSharedPtr  face)

Definition at line 95 of file Geometry2D.cpp.

References v_WhichFace().

{
return v_WhichFace(face);
}