Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Nektar::NekMeshUtils::CADSurf Class Referenceabstract

base class for a cad surface More...

#include <CADSurf.h>

Inheritance diagram for Nektar::NekMeshUtils::CADSurf:
Inheritance graph
[legend]
Collaboration diagram for Nektar::NekMeshUtils::CADSurf:
Collaboration graph
[legend]

Public Member Functions

 CADSurf ()
 Default constructor. More...
 
 ~CADSurf ()
 
std::vector
< CADSystem::EdgeLoopSharedPtr
GetEdges ()
 Get the loop structures which bound the cad surface. More...
 
void SetEdges (std::vector< CADSystem::EdgeLoopSharedPtr > ein)
 
virtual Array< OneD, NekDoubleGetBounds ()=0
 Get the limits of the parametric space for the surface. More...
 
virtual Array< OneD, NekDoubleN (Array< OneD, NekDouble > uv)=0
 Get the normal vector at parametric point u,v. More...
 
virtual Array< OneD, NekDoubleD1 (Array< OneD, NekDouble > uv)=0
 Get the set of first derivatives at parametric point u,v. More...
 
virtual Array< OneD, NekDoubleD2 (Array< OneD, NekDouble > uv)=0
 Get the set of second derivatives at parametric point u,v. More...
 
virtual Array< OneD, NekDoubleP (Array< OneD, NekDouble > uv)=0
 Get the x,y,z at parametric point u,v. More...
 
virtual Array< OneD, NekDoublelocuv (Array< OneD, NekDouble > p)=0
 Performs a reverse look up to find u,v and x,y,z. More...
 
virtual NekDouble DistanceTo (Array< OneD, NekDouble > p)=0
 does unconstrained locuv to project point from anywhere and calculate the distance between the orthonormal projection to the surface and the point More...
 
virtual void ProjectTo (Array< OneD, NekDouble > &tp, Array< OneD, NekDouble > &uv)=0
 takes a point from anywhere find the nearest surface point and its uv More...
 
virtual NekDouble Curvature (Array< OneD, NekDouble > uv)=0
 returns curvature at point uv More...
 
CADOrientation::Orientation Orientation ()
 query reversed normal More...
 
- Public Member Functions inherited from Nektar::NekMeshUtils::CADObject
 CADObject ()
 Default constructor. More...
 
virtual ~CADObject ()
 
int GetId ()
 Return ID of the vertex. More...
 
CADType::cadType GetType ()
 

Static Public Member Functions

static void OrientateEdges (CADSurfSharedPtr surf, std::vector< CADSystem::EdgeLoopSharedPtr > &ein)
 

Protected Member Functions

virtual void Test (Array< OneD, NekDouble > uv)=0
 Function which tests the the value of uv used is within the surface. More...
 

Protected Attributes

std::vector
< CADSystem::EdgeLoopSharedPtr
m_edges
 List of bounding edges in loops with orientation. More...
 
- Protected Attributes inherited from Nektar::NekMeshUtils::CADObject
int m_id
 ID of the vert. More...
 
CADType::cadType m_type
 type of the cad object More...
 
CADOrientation::Orientation m_orientation
 orientation of the CADObject More...
 

Friends

class MemoryManager< CADSurf >
 

Detailed Description

base class for a cad surface

Definition at line 55 of file CADSurf.h.

Constructor & Destructor Documentation

Nektar::NekMeshUtils::CADSurf::CADSurf ( )
inline
Nektar::NekMeshUtils::CADSurf::~CADSurf ( )
inline

Definition at line 69 of file CADSurf.h.

70  {
71  }

Member Function Documentation

virtual NekDouble Nektar::NekMeshUtils::CADSurf::Curvature ( Array< OneD, NekDouble uv)
pure virtual

returns curvature at point uv

Implemented in Nektar::NekMeshUtils::CADSurfOCE.

virtual Array<OneD, NekDouble> Nektar::NekMeshUtils::CADSurf::D1 ( Array< OneD, NekDouble uv)
pure virtual

Get the set of first derivatives at parametric point u,v.

Parameters
uvArray of u and v parametric coords.
Returns
Array of xyz copmonents of first derivatives.

Implemented in Nektar::NekMeshUtils::CADSurfOCE.

virtual Array<OneD, NekDouble> Nektar::NekMeshUtils::CADSurf::D2 ( Array< OneD, NekDouble uv)
pure virtual

Get the set of second derivatives at parametric point u,v.

Parameters
uvarray of u and v parametric coords
Returns
array of xyz copmonents of second derivatives

Implemented in Nektar::NekMeshUtils::CADSurfOCE.

virtual NekDouble Nektar::NekMeshUtils::CADSurf::DistanceTo ( Array< OneD, NekDouble p)
pure virtual

does unconstrained locuv to project point from anywhere and calculate the distance between the orthonormal projection to the surface and the point

Implemented in Nektar::NekMeshUtils::CADSurfOCE.

virtual Array<OneD, NekDouble> Nektar::NekMeshUtils::CADSurf::GetBounds ( )
pure virtual

Get the limits of the parametric space for the surface.

Returns
Array of 4 entries with parametric umin,umax,vmin,vmax.

Implemented in Nektar::NekMeshUtils::CADSurfOCE.

std::vector<CADSystem::EdgeLoopSharedPtr> Nektar::NekMeshUtils::CADSurf::GetEdges ( )
inline

Get the loop structures which bound the cad surface.

Definition at line 79 of file CADSurf.h.

References m_edges.

80  {
81  return m_edges;
82  }
std::vector< CADSystem::EdgeLoopSharedPtr > m_edges
List of bounding edges in loops with orientation.
Definition: CADSurf.h:166
virtual Array<OneD, NekDouble> Nektar::NekMeshUtils::CADSurf::locuv ( Array< OneD, NekDouble p)
pure virtual

Performs a reverse look up to find u,v and x,y,z.

Parameters
pArray of xyz location
Returns
The parametric location of xyz on this surface

Implemented in Nektar::NekMeshUtils::CADSurfOCE.

virtual Array<OneD, NekDouble> Nektar::NekMeshUtils::CADSurf::N ( Array< OneD, NekDouble uv)
pure virtual

Get the normal vector at parametric point u,v.

Parameters
uvArray of u and v parametric coords.
Returns
Array of xyz components of normal vector.

Implemented in Nektar::NekMeshUtils::CADSurfOCE.

void Nektar::NekMeshUtils::CADSurf::OrientateEdges ( CADSurfSharedPtr  surf,
std::vector< CADSystem::EdgeLoopSharedPtr > &  ein 
)
static

Definition at line 53 of file CADSurf.cpp.

References ASSERTL0, Nektar::StdRegions::eForwards, class_topology::P, and CellMLToNektar.cellml_metadata::p.

55 {
56  // this piece of code orientates the surface,
57  // it used to be face mesh but its easier to have it here
58  int np = 20;
59  vector<vector<Array<OneD, NekDouble> > > loopt;
60  for (int i = 0; i < ein.size(); i++)
61  {
62  vector<Array<OneD, NekDouble> > loop;
63  for (int j = 0; j < ein[i]->edges.size(); j++)
64  {
65  Array<OneD, NekDouble> bnds = ein[i]->edges[j]->GetBounds();
66  NekDouble dt = (bnds[1] - bnds[0]) / (np - 1);
67  if (ein[i]->edgeo[j] == CADOrientation::eForwards)
68  {
69  for (int k = 0; k < np - 1; k++)
70  {
71  NekDouble t = bnds[0] + dt * k;
72  Array<OneD, NekDouble> l = ein[i]->edges[j]->P(t);
73  Array<OneD, NekDouble> uv = surf->locuv(l);
74  loop.push_back(uv);
75  }
76  }
77  else
78  {
79  for (int k = np - 1; k > 0; k--)
80  {
81  NekDouble t = bnds[0] + dt * k;
82  Array<OneD, NekDouble> l = ein[i]->edges[j]->P(t);
83  Array<OneD, NekDouble> uv = surf->locuv(l);
84  loop.push_back(uv);
85  }
86  }
87  }
88  loopt.push_back(loop);
89  }
90 
91  vector<bg::model::polygon<point_xy, false, true> > polygons;
92 
93  for (int i = 0; i < loopt.size(); i++)
94  {
95  bg::model::polygon<point_xy, false, true> polygon;
96  vector<point_xy> points;
97  for (int j = 0; j < loopt[i].size(); j++)
98  {
99  points.push_back(point_xy(loopt[i][j][0], loopt[i][j][1]));
100  }
101  // boost requires for closed polygons (last point == first point)
102  points.push_back(point_xy(loopt[i][0][0], loopt[i][0][1]));
103 
104  bg::assign_points(polygon, points);
105 
106  NekDouble area = bg::area(polygon);
107 
108  ein[i]->area = area;
109 
110  point_xy cen;
111  bg::centroid(polygon, cen);
112 
113  ein[i]->center = Array<OneD, NekDouble>(2);
114  ein[i]->center[0] = cen.x();
115  ein[i]->center[1] = cen.y();
116 
117  polygons.push_back(polygon);
118  }
119 
120  // order by absoulte area
121  int ct = 0;
122  do
123  {
124  ct = 0;
125  for (int i = 0; i < ein.size() - 1; i++)
126  {
127  if (fabs(ein[i]->area) < fabs(ein[i + 1]->area))
128  {
129  // swap
130  swap(ein[i], ein[i + 1]);
131  swap(loopt[i], loopt[i + 1]);
132  swap(polygons[i], polygons[i + 1]);
133  ct += 1;
134  }
135  }
136 
137  } while (ct > 0);
138 
139  // only need center points for inner loops
140  for (int i = 1; i < ein.size(); i++)
141  {
142  point_xy p(ein[i]->center[0], ein[i]->center[1]);
143 
144  if (!bg::within(p, polygons[i]))
145  {
146  Array<OneD, NekDouble> n1 = loopt[i][0];
147  Array<OneD, NekDouble> n2 = loopt[i][1];
148 
149  Array<OneD, NekDouble> N(2);
150  NekDouble mag = sqrt((n1[0] - n2[0]) * (n1[0] - n2[0]) +
151  (n1[1] - n2[1]) * (n1[1] - n2[1]));
152 
153  N[0] = (n2[1] - n1[1]) / mag;
154  N[1] = -1.0 * (n2[0] - n1[0]) / mag;
155 
156  Array<OneD, NekDouble> P(2);
157  P[0] = n1[0] + N[0];
158  P[1] = n1[1] + N[1];
159 
160  ein[i]->center = P;
161 
162  p = point_xy(P[0], P[1]);
163 
164  ASSERTL0(boost::geometry::within(p, polygons[i]), "point is not side loop");
165  }
166  }
167 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
virtual Array< OneD, NekDouble > N(Array< OneD, NekDouble > uv)=0
Get the normal vector at parametric point u,v.
virtual Array< OneD, NekDouble > P(Array< OneD, NekDouble > uv)=0
Get the x,y,z at parametric point u,v.
bg::model::d2::point_xy< double > point_xy
Definition: CADSurf.cpp:44
double NekDouble
CADOrientation::Orientation Nektar::NekMeshUtils::CADSurf::Orientation ( )
inlinevirtual

query reversed normal

Reimplemented from Nektar::NekMeshUtils::CADObject.

Definition at line 159 of file CADSurf.h.

References Nektar::NekMeshUtils::CADObject::m_orientation.

160  {
161  return m_orientation;
162  }
CADOrientation::Orientation m_orientation
orientation of the CADObject
Definition: CADObject.h:109
virtual Array<OneD, NekDouble> Nektar::NekMeshUtils::CADSurf::P ( Array< OneD, NekDouble uv)
pure virtual

Get the x,y,z at parametric point u,v.

Parameters
uvArray of u and v parametric coords.
Returns
Array of xyz location.

Implemented in Nektar::NekMeshUtils::CADSurfOCE.

virtual void Nektar::NekMeshUtils::CADSurf::ProjectTo ( Array< OneD, NekDouble > &  tp,
Array< OneD, NekDouble > &  uv 
)
pure virtual

takes a point from anywhere find the nearest surface point and its uv

Implemented in Nektar::NekMeshUtils::CADSurfOCE.

void Nektar::NekMeshUtils::CADSurf::SetEdges ( std::vector< CADSystem::EdgeLoopSharedPtr ein)
inline

Definition at line 84 of file CADSurf.h.

References m_edges.

85  {
86  m_edges = ein;
87  }
std::vector< CADSystem::EdgeLoopSharedPtr > m_edges
List of bounding edges in loops with orientation.
Definition: CADSurf.h:166
virtual void Nektar::NekMeshUtils::CADSurf::Test ( Array< OneD, NekDouble uv)
protectedpure virtual

Function which tests the the value of uv used is within the surface.

Implemented in Nektar::NekMeshUtils::CADSurfOCE.

Friends And Related Function Documentation

friend class MemoryManager< CADSurf >
friend

Definition at line 58 of file CADSurf.h.

Member Data Documentation

std::vector<CADSystem::EdgeLoopSharedPtr> Nektar::NekMeshUtils::CADSurf::m_edges
protected

List of bounding edges in loops with orientation.

Definition at line 166 of file CADSurf.h.

Referenced by GetEdges(), and SetEdges().