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

base class for CAD curves. More...

#include <CADCurve.h>

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

Public Member Functions

 CADCurve ()
 Default constructor.
 
 ~CADCurve () override
 
virtual std::array< NekDouble, 2 > GetBounds ()=0
 Returns the minimum and maximum parametric coords t of the curve.
 
virtual void GetBounds (NekDouble &tmin, NekDouble &tmax)=0
 Returns the minimum and maximum parametric coords t of the curve.
 
virtual NekDouble Length (NekDouble ti, NekDouble tf)=0
 Calculates the arclength between the two paremetric points ti and tf. ti must be less than tf.
 
virtual std::array< NekDouble, 3 > P (NekDouble t)=0
 Gets the location (x,y,z) in an array out of the curve at point t.
 
virtual void P (NekDouble t, NekDouble &x, NekDouble &y, NekDouble &z)=0
 Gets the location (x,y,z) in an array out of the curve at point t.
 
virtual std::array< NekDouble, 9 > D2 (NekDouble t)=0
 Gets the second derivatives at t.
 
virtual NekDouble Curvature (NekDouble t)=0
 Calculates the radius of curvature of the curve at point t.
 
virtual NekDouble tAtArcLength (NekDouble s)=0
 Calculates the parametric coordinate and arclength location defined by s.
 
virtual std::array< NekDouble, 6 > GetMinMax ()=0
 Gets the start and end of the curve.
 
void SetAdjSurf (std::pair< CADSurfSharedPtr, CADOrientation::Orientation > i)
 set the ids of the surfaces either side of the curve
 
std::vector< std::pair< std::weak_ptr< CADSurf >, CADOrientation::Orientation > > GetAdjSurf ()
 returns the ids of surfaces bound by this curve as well as their Orientation with respect to the loop of curves
 
NekDouble GetTotLength ()
 returns lenght of the curve
 
void SetVert (std::vector< CADVertSharedPtr > &falVert)
 assign ids of end vertices in main cad
 
std::vector< CADVertSharedPtr > GetVertex ()
 get the vertices that are the ends of the curve, which are in the main cad list
 
virtual NekDouble loct (std::array< NekDouble, 3 > xyz, NekDouble &t)=0
 locates a point in the parametric space. returns the distance to the point and passes t by reference and updates it
 
virtual NekDouble loct (std::array< NekDouble, 3 > xyz, NekDouble &t, NekDouble cf, NekDouble cl)=0
 locates a point in the parametric space. returns the distance to the point and passes t by reference and updates it This is in the parametric bounds of the Curve and is important for periodic surfaces (Circles)
 
virtual NekDouble GetMinDistance (std::array< NekDouble, 3 > &xyz)=0
 Locates a point xyz in the parametric space. returns the distance to the point.
 
CADOrientation::Orientation GetOrienationWRT (int surf)
 Returns the orientation of the curve with respect to a given surface by id surf.
 
std::array< NekDouble, 3 > NormalWRT (NekDouble t, int surf)
 Returns the normal to the curve which is orientate with respect to the surface surf.
 
virtual std::array< NekDouble, 3 > N (NekDouble t)=0
 Returns the normal to a curve, it will always point in the concave direction.
 
virtual std::array< NekDouble, 6 > BoundingBox (NekDouble scale)=0
 Returns the bounding box of a curve enlarged by 5e-3mm * scale.
 
- 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.
 
virtual CADOrientation::Orientation Orientation ()
 Get the Orientation 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.
 

Protected Attributes

NekDouble m_length
 Length of edge.
 
std::vector< std::pair< std::weak_ptr< CADSurf >, CADOrientation::Orientation > > m_adjSurfs
 List of surfaces which this curve belongs to.
 
std::vector< CADVertSharedPtr > m_mainVerts
 list of end vertices
 
- 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< CADCurve >
 

Detailed Description

base class for CAD curves.

Definition at line 57 of file CADCurve.h.

Constructor & Destructor Documentation

◆ CADCurve()

Nektar::SpatialDomains::CADCurve::CADCurve ( )
inline

Default constructor.

Definition at line 65 of file CADCurve.h.

66 {
68 }
CADType::cadType m_type
type of the cad object
Definition CADObject.h:148

References Nektar::SpatialDomains::CADType::eCurve, and Nektar::SpatialDomains::CADObject::m_type.

◆ ~CADCurve()

Nektar::SpatialDomains::CADCurve::~CADCurve ( )
inlineoverride

Definition at line 70 of file CADCurve.h.

71 {
72 }

Member Function Documentation

◆ BoundingBox()

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

Returns the bounding box of a curve enlarged by 5e-3mm * scale.

Implemented in Nektar::SpatialDomains::CADCurveOCE.

◆ Curvature()

virtual NekDouble Nektar::SpatialDomains::CADCurve::Curvature ( NekDouble  t)
pure virtual

Calculates the radius of curvature of the curve at point t.

Implemented in Nektar::SpatialDomains::CADCurveOCE.

◆ D2()

virtual std::array< NekDouble, 9 > Nektar::SpatialDomains::CADCurve::D2 ( NekDouble  t)
pure virtual

Gets the second derivatives at t.

Implemented in Nektar::SpatialDomains::CADCurveOCE.

◆ GetAdjSurf()

std::vector< std::pair< std::weak_ptr< CADSurf >, CADOrientation::Orientation > > Nektar::SpatialDomains::CADCurve::GetAdjSurf ( )
inline

returns the ids of surfaces bound by this curve as well as their Orientation with respect to the loop of curves

Definition at line 157 of file CADCurve.h.

158 {
159 return m_adjSurfs;
160 }
std::vector< std::pair< std::weak_ptr< CADSurf >, CADOrientation::Orientation > > m_adjSurfs
List of surfaces which this curve belongs to.
Definition CADCurve.h:242

References m_adjSurfs.

◆ GetBounds() [1/2]

virtual std::array< NekDouble, 2 > Nektar::SpatialDomains::CADCurve::GetBounds ( )
pure virtual

Returns the minimum and maximum parametric coords t of the curve.

Returns
Array of two entries, min and max parametric coordinate.

Implemented in Nektar::SpatialDomains::CADCurveOCE.

◆ GetBounds() [2/2]

virtual void Nektar::SpatialDomains::CADCurve::GetBounds ( NekDouble &  tmin,
NekDouble &  tmax 
)
pure virtual

Returns the minimum and maximum parametric coords t of the curve.

Implemented in Nektar::SpatialDomains::CADCurveOCE.

◆ GetMinDistance()

virtual NekDouble Nektar::SpatialDomains::CADCurve::GetMinDistance ( std::array< NekDouble, 3 > &  xyz)
pure virtual

Locates a point xyz in the parametric space. returns the distance to the point.

Implemented in Nektar::SpatialDomains::CADCurveOCE.

◆ GetMinMax()

virtual std::array< NekDouble, 6 > Nektar::SpatialDomains::CADCurve::GetMinMax ( )
pure virtual

Gets the start and end of the curve.

Returns
Array with 6 entries of endpoints x1,y1,z1,x2,y2,z2.

Implemented in Nektar::SpatialDomains::CADCurveOCE.

◆ GetOrienationWRT()

CADOrientation::Orientation CADCurve::GetOrienationWRT ( int  surf)

Returns the orientation of the curve with respect to a given surface by id surf.

Definition at line 87 of file CADCurve.cpp.

88{
89 for (int i = 0; i < m_adjSurfs.size(); i++)
90 {
91 if (m_adjSurfs[i].first.lock()->GetId() == surf)
92 {
93 return m_adjSurfs[i].second;
94 }
95 }
96
97 ASSERTL0(true, "Unable to find surface in adjacency list.");
99}
#define ASSERTL0(condition, msg)

References ASSERTL0, Nektar::SpatialDomains::CADOrientation::eUnknown, and m_adjSurfs.

◆ GetTotLength()

NekDouble Nektar::SpatialDomains::CADCurve::GetTotLength ( )
inline

returns lenght of the curve

Definition at line 165 of file CADCurve.h.

166 {
167 return m_length;
168 }
NekDouble m_length
Length of edge.
Definition CADCurve.h:239

References m_length.

◆ GetVertex()

std::vector< CADVertSharedPtr > Nektar::SpatialDomains::CADCurve::GetVertex ( )
inline

get the vertices that are the ends of the curve, which are in the main cad list

Definition at line 182 of file CADCurve.h.

183 {
184 return m_mainVerts;
185 }
std::vector< CADVertSharedPtr > m_mainVerts
list of end vertices
Definition CADCurve.h:244

References m_mainVerts.

◆ Length()

virtual NekDouble Nektar::SpatialDomains::CADCurve::Length ( NekDouble  ti,
NekDouble  tf 
)
pure virtual

Calculates the arclength between the two paremetric points ti and tf. ti must be less than tf.

Parameters
tiFirst parametric coordinate.
tfSecond parametric coordinate.
Returns
Arc length between ti and tf.

Implemented in Nektar::SpatialDomains::CADCurveOCE.

◆ loct() [1/2]

virtual NekDouble Nektar::SpatialDomains::CADCurve::loct ( std::array< NekDouble, 3 >  xyz,
NekDouble &  t 
)
pure virtual

locates a point in the parametric space. returns the distance to the point and passes t by reference and updates it

Implemented in Nektar::SpatialDomains::CADCurveOCE.

◆ loct() [2/2]

virtual NekDouble Nektar::SpatialDomains::CADCurve::loct ( std::array< NekDouble, 3 >  xyz,
NekDouble &  t,
NekDouble  cf,
NekDouble  cl 
)
pure virtual

locates a point in the parametric space. returns the distance to the point and passes t by reference and updates it This is in the parametric bounds of the Curve and is important for periodic surfaces (Circles)

Implemented in Nektar::SpatialDomains::CADCurveOCE.

◆ N()

virtual std::array< NekDouble, 3 > Nektar::SpatialDomains::CADCurve::N ( NekDouble  t)
pure virtual

Returns the normal to a curve, it will always point in the concave direction.

Implemented in Nektar::SpatialDomains::CADCurveOCE.

◆ NormalWRT()

std::array< NekDouble, 3 > CADCurve::NormalWRT ( NekDouble  t,
int  surf 
)

Returns the normal to the curve which is orientate with respect to the surface surf.

Definition at line 44 of file CADCurve.cpp.

46{
47 auto p = P(t);
48 pair<weak_ptr<CADSurf>, CADOrientation::Orientation> surface;
49
50 if (m_adjSurfs.size() != 1)
51 {
52 ASSERTL0(true,
53 "This will only work in 2D for one surface at the moment");
54 }
55
56 surface = m_adjSurfs[0];
57
58 auto uv = surface.first.lock()->locuv(p);
59 auto d1 = surface.first.lock()->D1(uv);
60
61 NekDouble t1 = t - 1e-8;
62 NekDouble t2 = t + 1e-8;
63
64 if (surface.second == CADOrientation::eBackwards)
65 {
66 swap(t1, t2);
67 }
68
69 auto uv1 = surface.first.lock()->locuv(P(t1));
70 auto uv2 = surface.first.lock()->locuv(P(t2));
71
72 NekDouble du = uv2[1] - uv1[1];
73 NekDouble dv = -1.0 * (uv2[0] - uv1[0]);
74
75 std::array<NekDouble, 3> N = {(d1[3] * du + d1[6] * dv) / 2.0,
76 (d1[4] * du + d1[7] * dv) / 2.0,
77 (d1[5] * du + d1[8] * dv) / 2.0};
78
79 NekDouble mag = sqrt(N[0] * N[0] + N[1] * N[1] + N[2] * N[2]);
80 N[0] /= mag;
81 N[1] /= mag;
82 N[2] /= mag;
83
84 return N;
85}
#define N
std::vector< double > p(NPUPPER)
scalarT< T > sqrt(scalarT< T > in)
Definition scalar.hpp:289

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

◆ P() [1/2]

virtual std::array< NekDouble, 3 > Nektar::SpatialDomains::CADCurve::P ( NekDouble  t)
pure virtual

Gets the location (x,y,z) in an array out of the curve at point t.

Parameters
tParametric coordinate
Returns
Array of x,y,z

Implemented in Nektar::SpatialDomains::CADCurveOCE.

Referenced by class_topology.Topology::Serial_Compute().

◆ P() [2/2]

virtual void Nektar::SpatialDomains::CADCurve::P ( NekDouble  t,
NekDouble &  x,
NekDouble &  y,
NekDouble &  z 
)
pure virtual

Gets the location (x,y,z) in an array out of the curve at point t.

Parameters
tParametric coordinate

Implemented in Nektar::SpatialDomains::CADCurveOCE.

Referenced by class_topology.Topology::Serial_Compute().

◆ SetAdjSurf()

void Nektar::SpatialDomains::CADCurve::SetAdjSurf ( std::pair< CADSurfSharedPtr, CADOrientation::Orientation >  i)
inline

set the ids of the surfaces either side of the curve

Definition at line 147 of file CADCurve.h.

148 {
149 m_adjSurfs.push_back(i);
150 }

References m_adjSurfs.

◆ SetVert()

void Nektar::SpatialDomains::CADCurve::SetVert ( std::vector< CADVertSharedPtr > &  falVert)
inline

assign ids of end vertices in main cad

Definition at line 173 of file CADCurve.h.

174 {
175 m_mainVerts = falVert;
176 }

References m_mainVerts.

◆ tAtArcLength()

virtual NekDouble Nektar::SpatialDomains::CADCurve::tAtArcLength ( NekDouble  s)
pure virtual

Calculates the parametric coordinate and arclength location defined by s.

Parameters
sArclength location.
Returns
Calculated parametric coordinate.
Todo:
This really needs improving for accuracy.

Implemented in Nektar::SpatialDomains::CADCurveOCE.

Friends And Related Symbol Documentation

◆ MemoryManager< CADCurve >

friend class MemoryManager< CADCurve >
friend

Definition at line 251 of file CADCurve.h.

Member Data Documentation

◆ m_adjSurfs

std::vector<std::pair<std::weak_ptr<CADSurf>, CADOrientation::Orientation> > Nektar::SpatialDomains::CADCurve::m_adjSurfs
protected

List of surfaces which this curve belongs to.

Definition at line 242 of file CADCurve.h.

Referenced by GetAdjSurf(), GetOrienationWRT(), NormalWRT(), and SetAdjSurf().

◆ m_length

NekDouble Nektar::SpatialDomains::CADCurve::m_length
protected

Length of edge.

Definition at line 239 of file CADCurve.h.

Referenced by GetTotLength(), and Nektar::SpatialDomains::CADCurveOCE::Initialise().

◆ m_mainVerts

std::vector<CADVertSharedPtr> Nektar::SpatialDomains::CADCurve::m_mainVerts
protected

list of end vertices

Definition at line 244 of file CADCurve.h.

Referenced by GetVertex(), and SetVert().