Nektar++
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Nektar::SpatialDomains::CADSurf Class Referenceabstract

base class for a cad surface More...

#include <CADSurf.h>

Inheritance diagram for Nektar::SpatialDomains::CADSurf:
[legend]

Public Member Functions

 CADSurf ()
 Default constructor.
 
 ~CADSurf () override
 
std::vector< EdgeLoopSharedPtr > GetEdges ()
 Get the loop structures which bound the cad surface.
 
void SetEdges (std::vector< EdgeLoopSharedPtr > ein)
 Set the edge loop.
 
virtual std::array< NekDouble, 4 > GetBounds ()=0
 Get the limits of the parametric space for the surface.
 
virtual void GetBounds (NekDouble &umin, NekDouble &umax, NekDouble &vmin, NekDouble &vmax)=0
 Get the limits of the parametric space for the surface.
 
virtual std::array< NekDouble, 3 > N (std::array< NekDouble, 2 > uv)=0
 Get the normal vector at parametric point u,v.
 
virtual std::array< NekDouble, 9 > D1 (std::array< NekDouble, 2 > uv)=0
 Get the set of first derivatives at parametric point u,v.
 
virtual std::array< NekDouble, 18 > D2 (std::array< NekDouble, 2 > uv)=0
 Get the set of second derivatives at parametric point u,v.
 
virtual std::array< NekDouble, 3 > P (std::array< NekDouble, 2 > uv)=0
 Get the x,y,z at parametric point u,v.
 
virtual void P (std::array< NekDouble, 2 > uv, NekDouble &x, NekDouble &y, NekDouble &z)=0
 Get the x,y,z at parametric point u,v.
 
virtual std::array< NekDouble, 2 > locuv (std::array< NekDouble, 3 > p, NekDouble &dist)=0
 Performs a reverse look up to find u,v and x,y,z. if xyz is off the surface it will return the closest point.
 
std::array< NekDouble, 2 > locuv (std::array< NekDouble, 3 > p)
 overload function of locuv ommiting the dist parameter in this case if the projection is greater than a certain distance it will produce a warning. To do large distance projection use the other locuv method
 
virtual std::array< NekDouble, 2 > locuv (std::array< NekDouble, 3 > p, NekDouble &dist, NekDouble Umin, NekDouble Usup, NekDouble Vmin, NekDouble Vsup)=0
 Performs a reverse look up to find u,v and x,y,z. if xyz is off the surface it will return the closest point.
 
virtual std::array< NekDouble, 6 > BoundingBox ()=0
 Returns the bounding box of the surface.
 
virtual std::array< NekDouble, 6 > BoundingBox (NekDouble scale)=0
 Returns the bounding box of the surface that scales the enlargement and the meshing parameters * scale.
 
virtual NekDouble Curvature (std::array< NekDouble, 2 > uv)=0
 returns curvature at point uv
 
virtual std::array< NekDouble, 2 > locuvFrom (std::array< NekDouble, 3 > p, std::array< NekDouble, 2 > guess, NekDouble &dist)
 Curvature and position at uv together.
 
virtual std::array< NekDouble, 2 > locuvOnCurve (const CADCurveSharedPtr &curve, NekDouble t)
 
virtual NekDouble CurvatureAndPosition (std::array< NekDouble, 2 > uv, std::array< NekDouble, 3 > &loc)
 
virtual bool IsPlanar ()=0
 Is the surface defined by a planar surface (i.e not nurbs and is flat)
 
CADOrientation::Orientation Orientation () override
 query reversed normal
 
- Public Member Functions inherited from Nektar::SpatialDomains::CADObject
 CADObject ()
 Default constructor.
 
virtual ~CADObject ()
 
int GetId ()
 Return ID of the CAD object.
 
CADType::cadType GetType ()
 Get the type of the CAD object.
 
void SetName (std::string i)
 Give the CAD object a string name.
 
std::string GetName ()
 Get the name of a CAD object.
 
void SetLogger (Logger &log)
 Set the logger for this CAD object.
 

Static Public Member Functions

static void OrientateEdges (CADSurfSharedPtr surf, std::vector< EdgeLoopSharedPtr > &ein)
 Static function which orientates the edge loop on a surface.
 

Protected Member Functions

virtual void Test (std::array< NekDouble, 2 > uv)=0
 Function which tests the the value of uv used is within the surface.
 

Protected Attributes

std::vector< EdgeLoopSharedPtr > m_edges
 List of bounding edges in loops with orientation.
 
- Protected Attributes inherited from Nektar::SpatialDomains::CADObject
int m_id
 ID of the vert.
 
CADType::cadType m_type
 type of the cad object
 
CADOrientation::Orientation m_orientation
 orientation of the CADObject
 
std::string m_name
 string name of the cad
 
Logger m_log
 Logger.
 

Friends

class MemoryManager< CADSurf >
 

Detailed Description

base class for a cad surface

Definition at line 69 of file CADSurf.h.

Constructor & Destructor Documentation

◆ CADSurf()

Nektar::SpatialDomains::CADSurf::CADSurf ( )
inline

◆ ~CADSurf()

Nektar::SpatialDomains::CADSurf::~CADSurf ( )
inlineoverride

Definition at line 83 of file CADSurf.h.

84 {
85 }

Member Function Documentation

◆ BoundingBox() [1/2]

virtual std::array< NekDouble, 6 > Nektar::SpatialDomains::CADSurf::BoundingBox ( )
pure virtual

Returns the bounding box of the surface.

Implemented in Nektar::SpatialDomains::CADSurfOCE.

◆ BoundingBox() [2/2]

virtual std::array< NekDouble, 6 > Nektar::SpatialDomains::CADSurf::BoundingBox ( NekDouble  scale)
pure virtual

Returns the bounding box of the surface that scales the enlargement and the meshing parameters * scale.

Implemented in Nektar::SpatialDomains::CADSurfOCE.

◆ Curvature()

virtual NekDouble Nektar::SpatialDomains::CADSurf::Curvature ( std::array< NekDouble, 2 >  uv)
pure virtual

returns curvature at point uv

Implemented in Nektar::SpatialDomains::CADSurfOCE.

Referenced by CurvatureAndPosition().

◆ CurvatureAndPosition()

virtual NekDouble Nektar::SpatialDomains::CADSurf::CurvatureAndPosition ( std::array< NekDouble, 2 >  uv,
std::array< NekDouble, 3 > &  loc 
)
inlinevirtual

Reimplemented in Nektar::SpatialDomains::CADSurfOCE.

Definition at line 260 of file CADSurf.h.

262 {
263 NekDouble curvature = Curvature(uv);
264 loc = P(uv);
265 return curvature;
266 }
virtual NekDouble Curvature(std::array< NekDouble, 2 > uv)=0
returns curvature at point uv

References Curvature(), and Nektar::LibUtilities::P.

◆ D1()

virtual std::array< NekDouble, 9 > Nektar::SpatialDomains::CADSurf::D1 ( std::array< NekDouble, 2 >  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::SpatialDomains::CADSurfOCE.

◆ D2()

virtual std::array< NekDouble, 18 > Nektar::SpatialDomains::CADSurf::D2 ( std::array< NekDouble, 2 >  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::SpatialDomains::CADSurfOCE.

◆ GetBounds() [1/2]

virtual std::array< NekDouble, 4 > Nektar::SpatialDomains::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::SpatialDomains::CADSurfOCE.

◆ GetBounds() [2/2]

virtual void Nektar::SpatialDomains::CADSurf::GetBounds ( NekDouble &  umin,
NekDouble &  umax,
NekDouble &  vmin,
NekDouble &  vmax 
)
pure virtual

Get the limits of the parametric space for the surface.

Implemented in Nektar::SpatialDomains::CADSurfOCE.

◆ GetEdges()

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

Get the loop structures which bound the cad surface.

Definition at line 96 of file CADSurf.h.

97 {
98 return m_edges;
99 }
std::vector< EdgeLoopSharedPtr > m_edges
List of bounding edges in loops with orientation.
Definition CADSurf.h:284

References m_edges.

◆ IsPlanar()

virtual bool Nektar::SpatialDomains::CADSurf::IsPlanar ( )
pure virtual

Is the surface defined by a planar surface (i.e not nurbs and is flat)

Implemented in Nektar::SpatialDomains::CADSurfOCE.

◆ locuv() [1/3]

std::array< NekDouble, 2 > Nektar::SpatialDomains::CADSurf::locuv ( std::array< NekDouble, 3 >  p)
inline

overload function of locuv ommiting the dist parameter in this case if the projection is greater than a certain distance it will produce a warning. To do large distance projection use the other locuv method

Definition at line 185 of file CADSurf.h.

186 {
187 NekDouble dist;
188 auto uv = locuv(p, dist);
189 WARNINGL1(dist < 1e-3, "large locuv distance: " + std::to_string(dist));
190 return uv;
191 }
#define WARNINGL1(condition, msg)
virtual std::array< NekDouble, 2 > locuv(std::array< NekDouble, 3 > p, NekDouble &dist)=0
Performs a reverse look up to find u,v and x,y,z. if xyz is off the surface it will return the closes...

References locuv(), and WARNINGL1.

◆ locuv() [2/3]

virtual std::array< NekDouble, 2 > Nektar::SpatialDomains::CADSurf::locuv ( std::array< NekDouble, 3 >  p,
NekDouble &  dist 
)
pure virtual

Performs a reverse look up to find u,v and x,y,z. if xyz is off the surface it will return the closest point.

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

Implemented in Nektar::SpatialDomains::CADSurfOCE.

Referenced by locuv(), locuvFrom(), locuvOnCurve(), and Nektar::SpatialDomains::CADSurfOCE::locuvOnCurve().

◆ locuv() [3/3]

virtual std::array< NekDouble, 2 > Nektar::SpatialDomains::CADSurf::locuv ( std::array< NekDouble, 3 >  p,
NekDouble &  dist,
NekDouble  Umin,
NekDouble  Usup,
NekDouble  Vmin,
NekDouble  Vsup 
)
pure virtual

Performs a reverse look up to find u,v and x,y,z. if xyz is off the surface it will return the closest point.

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

Implemented in Nektar::SpatialDomains::CADSurfOCE.

◆ locuvFrom()

virtual std::array< NekDouble, 2 > Nektar::SpatialDomains::CADSurf::locuvFrom ( std::array< NekDouble, 3 >  p,
std::array< NekDouble, 2 >  guess,
NekDouble &  dist 
)
inlinevirtual

Curvature and position at uv together.

The octree wants both at every one of its curvature samples, of which there are millions, and a CAD engine that derives curvature from the surface's second derivatives has the position in hand already. This default asks twice, which is what the callers used to do; an engine that can do better overrides it.

The \( (u,v) \) of the point at parameter t on curve, which must be one of this surface's bounding curves.

Projecting a point back onto the surface it is already known to lie on is expensive and unnecessary where the CAD engine stores the curve's own representation in the surface's parameter plane. This default does the projection; an engine that keeps that representation overrides it.

As locuv(), but starting the search from guess.

Finding the parameters of a point on a surface is an iterative minimisation, and the cost of it depends strongly on where it starts. Callers placing a run of points that lie near one another – the interior nodes of one high-order element, say – can hand each the answer from the last. The default ignores the guess.

Reimplemented in Nektar::SpatialDomains::CADSurfOCE.

Definition at line 249 of file CADSurf.h.

252 {
253 (void)guess;
254 return locuv(p, dist);
255 }

References locuv(), and Nektar::void.

◆ locuvOnCurve()

std::array< NekDouble, 2 > CADSurf::locuvOnCurve ( const CADCurveSharedPtr &  curve,
NekDouble  t 
)
virtual

Reimplemented in Nektar::SpatialDomains::CADSurfOCE.

Definition at line 50 of file CADSurf.cpp.

52{
53 return locuv(curve->P(t));
54}

References locuv().

◆ N()

virtual std::array< NekDouble, 3 > Nektar::SpatialDomains::CADSurf::N ( std::array< NekDouble, 2 >  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::SpatialDomains::CADSurfOCE.

◆ OrientateEdges()

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

Static function which orientates the edge loop on a surface.

Definition at line 56 of file CADSurf.cpp.

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

References ASSERTL0, Nektar::SpatialDomains::CADOrientation::eForwards, N, Nektar::LibUtilities::P, and tinysimd::sqrt().

Referenced by Nektar::SpatialDomains::CADSystemOCE::AddSurf().

◆ Orientation()

CADOrientation::Orientation Nektar::SpatialDomains::CADSurf::Orientation ( )
inlineoverridevirtual

query reversed normal

Reimplemented from Nektar::SpatialDomains::CADObject.

Definition at line 277 of file CADSurf.h.

278 {
279 return m_orientation;
280 }

References Nektar::SpatialDomains::CADObject::m_orientation.

◆ P() [1/2]

virtual std::array< NekDouble, 3 > Nektar::SpatialDomains::CADSurf::P ( std::array< NekDouble, 2 >  uv)
pure virtual

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

Parameters
uvArray of u and v parametric coords.
Returns
Array of x,y,z location.

Implemented in Nektar::SpatialDomains::CADSurfOCE.

Referenced by class_topology.Topology::Serial_Compute().

◆ P() [2/2]

virtual void Nektar::SpatialDomains::CADSurf::P ( std::array< NekDouble, 2 >  uv,
NekDouble &  x,
NekDouble &  y,
NekDouble &  z 
)
pure virtual

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

Parameters
uvArray of u and v parametric coords.

Implemented in Nektar::SpatialDomains::CADSurfOCE.

Referenced by class_topology.Topology::Serial_Compute().

◆ SetEdges()

void Nektar::SpatialDomains::CADSurf::SetEdges ( std::vector< EdgeLoopSharedPtr >  ein)
inline

Set the edge loop.

Definition at line 104 of file CADSurf.h.

105 {
106 m_edges = ein;
107 }

References m_edges.

◆ Test()

virtual void Nektar::SpatialDomains::CADSurf::Test ( std::array< NekDouble, 2 >  uv)
protectedpure virtual

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

Implemented in Nektar::SpatialDomains::CADSurfOCE.

Friends And Related Symbol Documentation

◆ MemoryManager< CADSurf >

friend class MemoryManager< CADSurf >
friend

Definition at line 60 of file CADSurf.h.

Member Data Documentation

◆ m_edges

std::vector<EdgeLoopSharedPtr> Nektar::SpatialDomains::CADSurf::m_edges
protected

List of bounding edges in loops with orientation.

Definition at line 284 of file CADSurf.h.

Referenced by GetEdges(), and SetEdges().