Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Public Attributes | List of all members
Nektar::Utilities::FieldPts Struct Reference

#include <Field.hpp>

Collaboration diagram for Nektar::Utilities::FieldPts:
Collaboration graph
[legend]

Public Member Functions

 FieldPts (void)
void Interp1DPts (const NekDouble coord, Array< OneD, NekDouble > &intfields)

Public Attributes

int m_ptsDim
int m_nFields
Array< OneD, Array< OneD,
NekDouble > > 
m_pts
PtsType m_ptype
vector< int > m_npts
vector< std::string > m_fields
vector< Array< OneD, int > > m_ptsConn

Detailed Description

Definition at line 74 of file Field.hpp.

Constructor & Destructor Documentation

Nektar::Utilities::FieldPts::FieldPts ( void  )
inline

Definition at line 76 of file Field.hpp.

Member Function Documentation

void Nektar::Utilities::FieldPts::Interp1DPts ( const NekDouble  coord,
Array< OneD, NekDouble > &  intfields 
)
inline

Definition at line 88 of file Field.hpp.

References ASSERTL0, npts, and WARNINGL1.

{
// currently assume first field is coordinate
"Assumed only one coordinate given taking first coordinate "
"for interpolation");
int npts = m_pts[0].num_elements();
int i;
for(i = 0; i < npts-1; ++i)
{
if((m_pts[0][i] <= coord) && (coord <= m_pts[0][i+1]))
{
NekDouble pdiff = m_pts[0][i+1]-m_pts[0][i];
if(npts <= 2)
{
// linear interpolation
for(int j = 0; j < m_nFields; ++j)
{
intfields[j] = m_pts[m_ptsDim+j][i]
* (m_pts[0][i+1] - coord) / pdiff
+ m_pts[m_ptsDim+j][i+1]
* (coord - m_pts[0][i]) / pdiff;
}
}
else // quadratic interpolation
{
if(i < npts-2)
{ // forwards stencil
NekDouble pdiff2 = m_pts[0][i+2] - m_pts[0][i+1];
NekDouble h1 = (m_pts[0][i+1]-coord)
* (m_pts[0][i+2] - coord)
/ (pdiff * (pdiff+pdiff2));
NekDouble h2 = (coord-m_pts[0][i])
* (m_pts[0][i+2] - coord)
/ (pdiff * pdiff2);
NekDouble h3 = (coord-m_pts[0][i])
* (coord - m_pts[0][i+1])
/ ((pdiff + pdiff2) * pdiff2);
for(int j = 0; j < m_nFields; ++j)
{
intfields[j] = m_pts[m_ptsDim+j][i] * h1
+ m_pts[m_ptsDim+j][i+1] * h2
+ m_pts[m_ptsDim+j][i+2] * h3;
}
}
else
{ // backwards stencil
NekDouble pdiff2 = m_pts[0][i] - m_pts[0][i-1];
NekDouble h1 = (m_pts[0][i+1]-coord)
* (coord - m_pts[0][i-1])
/ (pdiff * pdiff2);
NekDouble h2 = (coord - m_pts[0][i])
* (coord - m_pts[0][i-1])
/ (pdiff * (pdiff + pdiff2));
NekDouble h3 = (m_pts[0][i]-coord)
* (m_pts[0][i+1] - coord)
/ ((pdiff + pdiff2) * pdiff);
for(int j = 0; j < m_nFields; ++j)
{
intfields[j] = m_pts[m_ptsDim+j][i] * h1
+ m_pts[m_ptsDim+j][i+1] * h2
+ m_pts[m_ptsDim+j][i-1] * h3;
}
}
}
break;
}
}
ASSERTL0(i != npts-1, "Failed to find coordinate " +
boost::lexical_cast<string>(coord) +
" within provided input points");
};

Member Data Documentation

vector<std::string> Nektar::Utilities::FieldPts::m_fields

Definition at line 84 of file Field.hpp.

int Nektar::Utilities::FieldPts::m_nFields

Definition at line 80 of file Field.hpp.

vector<int> Nektar::Utilities::FieldPts::m_npts

Definition at line 83 of file Field.hpp.

Array<OneD, Array<OneD, NekDouble> > Nektar::Utilities::FieldPts::m_pts

Definition at line 81 of file Field.hpp.

vector<Array<OneD, int> > Nektar::Utilities::FieldPts::m_ptsConn

Definition at line 85 of file Field.hpp.

int Nektar::Utilities::FieldPts::m_ptsDim

Definition at line 79 of file Field.hpp.

PtsType Nektar::Utilities::FieldPts::m_ptype

Definition at line 82 of file Field.hpp.