Commit 4623e0b7 authored by Joe Frazier's avatar Joe Frazier
Browse files

Added ability to create in the base points class.


git-svn-id: https://gforge.sci.utah.edu/svn/nektar/trunk@251 305cdda6-5ce1-45b3-a98d-dfc68c8b3305
parent 5180c19d
......@@ -54,7 +54,20 @@ namespace Nektar
eChebyshev, //!< Chebyshev Polynomials \f$ T_p(z_i) = P^{-1/2,-1/2}_p(z_i)\f$
SIZE_BasisType //!< Length of enum list
};
const char* const BasisTypeMap[] =
{
"Ortho_A",
"Ortho_B",
"Ortho_C",
"Modified_A",
"Modified_B",
"Modified_C",
"Fourier",
"GLL_Lagrange",
"Legendre",
"Chebyshev"
};
enum PointsType
{
......@@ -71,6 +84,19 @@ namespace Nektar
SIZE_PointsType //!< Length of enum list
};
const char* const PointsTypeMap[] =
{
"Gauss",
"Lobatto",
"RadauM",
"RadauP",
"PolyEvenSp",
"FourierEvenSp",
"Arbitrary",
"NodalTriElec",
"NodalTriFekete",
"NodalTetElec"
};
enum PointsIdentifier
{
......@@ -83,6 +109,15 @@ namespace Nektar
SIZE_PointsIdentifier //!< Length of enum list
};
const char* const PointsIdentifierMap[] =
{
"Wildcard",
"GaussChebyshevFirstKind",
"GaussChebyshevSecondKind",
"GaussLegendre",
"GaussAlpha0Beta1",
"GaussAlpha0Beta2"
};
} // end of namespace
} // end of namespace
......
......@@ -61,14 +61,14 @@ namespace Nektar
bool opLess::operator()(const PointsKey &lhs, const PointsKey &rhs)
{
if (lhs.m_pointsdim < rhs.m_pointsdim) return true;
if (lhs.m_pointsdim < rhs.m_pointsdim) return true;
if (lhs.m_pointsdim > rhs.m_pointsdim) return false;
if (lhs.m_pointstype < rhs.m_pointstype) return true;
if (lhs.m_pointstype > rhs.m_pointstype) return false;
return (lhs.m_pointsid < rhs.m_pointsid);
}
}
std::ostream& operator<<(std::ostream& os, const PointsKey& rhs)
{
......
......@@ -45,8 +45,11 @@ namespace Nektar
{
namespace LibUtilities
{
// Need to add method to compute total number of points given dimension
// and number of points.
class PointsKey;
// Use for looking up the creator. The creator for number of points
// can generate for any number, so we want the same creator called
// for all number.
......@@ -54,17 +57,17 @@ namespace Nektar
{
bool operator()(const PointsKey &lhs, const PointsKey &rhs);
};
class PointsKey
{
public:
PointsKey(const unsigned int &pointsdim, const int &numpoints,
const PointsType &pointstype, const PointsIdentifier &pointsid = eWildcard):
m_pointsdim(pointsdim),
m_numpoints(numpoints),
m_pointstype(pointstype),
m_pointsid(pointsid)
const PointsType &pointstype, const PointsIdentifier &pointsid = eWildcard):
m_pointsdim(pointsdim),
m_numpoints(numpoints),
m_pointstype(pointstype),
m_pointsid(pointsid)
{
}
......@@ -92,7 +95,7 @@ namespace Nektar
return m_pointsdim;
}
inline int GetNumPoints() const
inline unsigned int GetNumPoints() const
{
return m_numpoints;
}
......@@ -110,9 +113,9 @@ namespace Nektar
bool operator==(const PointsKey &key)
{
return (m_pointsdim == key.m_pointsdim &&
m_numpoints == key.m_numpoints &&
m_pointstype == key.m_pointstype &&
m_pointsid == key.m_pointsid);
m_numpoints == key.m_numpoints &&
m_pointstype == key.m_pointstype &&
m_pointsid == key.m_pointsid);
}
......@@ -136,7 +139,7 @@ namespace Nektar
protected:
unsigned int m_pointsdim; //!< dimension of the points
int m_numpoints; //!< number of the points (as appropriately defined for PointsType)
unsigned int m_numpoints; //!< number of the points (as appropriately defined for PointsType)
PointsType m_pointstype; //!< Type of Points
PointsIdentifier m_pointsid; //!< Unique indentifier (when needed)
......@@ -151,39 +154,45 @@ namespace Nektar
std::ostream& operator<<(std::ostream& os, const PointsKey& rhs);
template<typename DataType>
template<typename DataT>
class Points
{
public:
typedef DataT DataType;
Points(const PointsKey &key): m_pkey(key)
{
}
virtual ~Points()
{
if(m_pkey.GetNumPoints())
{
//unsigned int dim = m_pkey.GetPointsDim();
unsigned int dim = m_pkey.GetPointsDim();
//for(unsigned int i = 0; i < dim; ++i)
//{
// delete[] m_points[i];
//}
for(unsigned int i = 0; i < dim; ++i)
{
delete[] m_points[i];
}
//delete[] m_points;
//delete[] m_weights;
delete[] m_points;
delete[] m_weights;
}
}
void Initialize(void)
{
CalculatePoints();
CalculateWeights();
CalculateDerivMatrix();
}
inline int GetPointsDim() const
inline unsigned int GetPointsDim() const
{
return m_pkey.GetPointsDim();
}
inline int GetNumPoints() const
inline unsigned int GetNumPoints() const
{
return m_pkey.GetNumPoints();
}
......@@ -251,11 +260,28 @@ namespace Nektar
DataType *m_weights;
boost::shared_ptr<NekMatrix<DataType> > m_derivmatrix;
private:
virtual void CalculatePoints() = 0;
virtual void CalculateWeights() = 0;
virtual void CalculateDerivMatrix() = 0;
virtual void CalculatePoints()
{
unsigned int pointsDim = GetPointsDim();
m_points = new Points::DataType*[pointsDim];
for (unsigned int i=0; i<pointsDim; ++i)
{
m_points[i] = new Points::DataType[GetNumPoints()];
}
}
virtual void CalculateWeights()
{
m_weights = new Points::DataType[GetNumPoints()];
}
virtual void CalculateDerivMatrix()
{
}
private:
// This should never be called.
Points()
{
......
......@@ -47,14 +47,22 @@ namespace Nektar
{
void GaussPolyPoints::CalculatePoints()
{
// Allocate the points.
Points<double>::CalculatePoints();
// Now set the points.
}
void GaussPolyPoints::CalculateWeights()
{
// Allocate the weights.
Points<double>::CalculateWeights();
}
void GaussPolyPoints::CalculateDerivMatrix()
{
// Allocate the derivative matrix.
Points<double>::CalculateDerivMatrix();
}
GaussPolyPoints::GaussPolyPoints(const PointsKey &key,
......@@ -68,6 +76,9 @@ namespace Nektar
boost::shared_ptr< Points<double> > GaussPolyPoints::Create(const PointsKey &key)
{
boost::shared_ptr< Points<double> > returnval(new GaussPolyPoints(key, 1.0, 1.0));
returnval->Initialize();
return returnval;
}
......
......@@ -48,25 +48,38 @@ namespace Nektar
class GaussPolyPoints: public Points<double>
{
public:
GaussPolyPoints::GaussPolyPoints(const PointsKey &key,
const double alpha, const double beta);
GaussPolyPoints(const PointsKey &key,
const double alpha, const double beta);
virtual ~GaussPolyPoints()
{
}
// Not sure what to return here for the create function.
// Since this function will be registered in a manager with
// other points types, it needs to return a base type.
// I am not sure if Points<> will work because of its type
// obtained from the template parameters. That would make
// it so the given manager can only hold, say, Points<double>.
static boost::shared_ptr< Points<double> > Create(const PointsKey &key);
protected:
double m_alpha;
double m_beta;
private:
void CalculatePoints();
void CalculateWeights();
void CalculateDerivMatrix();
};
class FourierPoints: public Points<double>
{
public:
FourierPoints(const PointsKey &key);
virtual ~FourierPoints()
{
}
static boost::shared_ptr< Points<double> > Create(const PointsKey &key);
protected:
private:
void CalculatePoints();
void CalculateWeights();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment