Nektar++
Public Member Functions | Public Attributes | Private Attributes | List of all members
Nektar::LibUtilities::PtsField Class Reference

#include <PtsField.h>

Public Member Functions

 PtsField (const int dim, const Array< OneD, Array< OneD, NekDouble > > &pts)
 
 PtsField (const int dim, const std::vector< std::string > fieldnames, const Array< OneD, Array< OneD, NekDouble > > &pts, std::map< PtsInfo, int > ptsInfo=NullPtsInfoMap)
 
 PtsField (const int dim, const std::vector< std::string > fieldnames, const Array< OneD, Array< OneD, NekDouble > > &pts, const Array< OneD, Array< OneD, float > > &weights, const Array< OneD, Array< OneD, unsigned int > > &neighInds)
 
void GetConnectivity (std::vector< Array< OneD, int > > &conn) const
 Set the connectivity data for ePtsTetBlock and ePtsTriBlock. More...
 
void SetConnectivity (const std::vector< Array< OneD, int > > &conn)
 Get the connectivity data for ePtsTetBlock and ePtsTriBlock. More...
 
void SetDim (const int ptsDim)
 
size_t GetDim () const
 
size_t GetNFields () const
 
std::vector< std::string > GetFieldNames () const
 
std::string GetFieldName (const int i) const
 
void SetFieldNames (const std::vector< std::string > fieldNames)
 
void AddField (const Array< OneD, NekDouble > &pts, const std::string fieldName)
 
void RemoveField (const std::string fieldName)
 
void AddPoints (const Array< OneD, const Array< OneD, NekDouble > > &pts)
 
size_t GetNpoints () const
 
NekDouble GetPointVal (const size_t fieldInd, const size_t ptInd) const
 
void SetPointVal (const size_t fieldInd, const size_t ptInd, const NekDouble val)
 
void GetPts (Array< OneD, Array< OneD, NekDouble > > &pts) const
 
Array< OneD, NekDoubleGetPts (const int fieldInd) const
 
void SetPts (Array< OneD, Array< OneD, NekDouble > > &pts)
 
void SetPts (const int fldId, const Array< OneD, const NekDouble > &pts)
 
std::vector< size_t > GetPointsPerEdge () const
 
size_t GetPointsPerEdge (const size_t i) const
 
void SetPointsPerEdge (const std::vector< size_t > nPtsPerEdge)
 Set the number of points per edge. More...
 
void SetPointsPerElement (const std::vector< int > nPtsPerElement)
 
std::vector< int > GetPointsPerElement () const
 
PtsType GetPtsType () const
 
void SetPtsType (const PtsType type)
 
std::vector< NekDoubleGetBoxSize () const
 
void SetBoxSize (const std::vector< NekDouble > boxsize)
 

Public Attributes

std::map< PtsInfo, int > m_ptsInfo
 map for information about points that can be added through PtsInfo enum More...
 

Private Attributes

size_t m_dim
 Dimension of the pts field. More...
 
std::vector< std::string > m_fieldNames
 Names of the field variables. More...
 
Array< OneD, Array< OneD, NekDouble > > m_pts
 Point data. For a n-dimensional field, the first m_dim fields are the points spatial coordinates. Structure: m_pts[fieldIdx][ptIdx]. More...
 
std::vector< size_t > m_nPtsPerEdge
 Number of points per edge. Empty if the point data has no specific shape (ePtsLine) or is a block (ePtsTetBlock, ePtsTriBlock), size=1 for ePtsLine and 2 for a ePtsPlane. More...
 
std::vector< int > m_nPtsPerElement
 
std::vector< Array< OneD, int > > m_ptsConn
 Connectivity data needed for ePtsTetBlock and ePtsTriBlock. For n Blocks with m elements each, m_ptsConn is a vector of n arrays with 3*m (ePtsTriBlock) or 4*m (ePtsTetBlock) entries. More...
 
PtsType m_ptsType
 Type of the PtsField. More...
 
std::vector< NekDoublem_boxSize
 vector of box size xmin,xmax,ymin,ymax,zmin,zmax More...
 

Detailed Description

Definition at line 68 of file PtsField.h.

Constructor & Destructor Documentation

◆ PtsField() [1/3]

Nektar::LibUtilities::PtsField::PtsField ( const int  dim,
const Array< OneD, Array< OneD, NekDouble > > &  pts 
)

Definition at line 43 of file PtsField.cpp.

45 : m_dim(dim), m_pts(pts), m_ptsType(ePtsFile)
46{
47 for (int i = 0; i < GetNFields(); ++i)
48 {
49 m_fieldNames.push_back("NA");
50 }
51}
size_t m_dim
Dimension of the pts field.
Definition: PtsField.h:162
PtsType m_ptsType
Type of the PtsField.
Definition: PtsField.h:178
std::vector< std::string > m_fieldNames
Names of the field variables.
Definition: PtsField.h:164
Array< OneD, Array< OneD, NekDouble > > m_pts
Point data. For a n-dimensional field, the first m_dim fields are the points spatial coordinates....
Definition: PtsField.h:167

References GetNFields(), and m_fieldNames.

◆ PtsField() [2/3]

Nektar::LibUtilities::PtsField::PtsField ( const int  dim,
const std::vector< std::string >  fieldnames,
const Array< OneD, Array< OneD, NekDouble > > &  pts,
std::map< PtsInfo, int >  ptsInfo = NullPtsInfoMap 
)
inline

Definition at line 74 of file PtsField.h.

78 : m_ptsInfo(ptsInfo), m_dim(dim), m_fieldNames(fieldnames), m_pts(pts),
std::map< PtsInfo, int > m_ptsInfo
map for information about points that can be added through PtsInfo enum
Definition: PtsField.h:158

◆ PtsField() [3/3]

Nektar::LibUtilities::PtsField::PtsField ( const int  dim,
const std::vector< std::string >  fieldnames,
const Array< OneD, Array< OneD, NekDouble > > &  pts,
const Array< OneD, Array< OneD, float > > &  weights,
const Array< OneD, Array< OneD, unsigned int > > &  neighInds 
)
inline

Definition at line 81 of file PtsField.h.

87 : m_ptsInfo(NullPtsInfoMap), m_dim(dim), m_fieldNames(fieldnames),
88 m_pts(pts), m_ptsType(ePtsFile){};
static std::map< PtsInfo, int > NullPtsInfoMap
Definition: PtsField.h:66

Member Function Documentation

◆ AddField()

void Nektar::LibUtilities::PtsField::AddField ( const Array< OneD, NekDouble > &  pts,
const std::string  fieldName 
)

Definition at line 117 of file PtsField.cpp.

119{
120 size_t nTotvars = m_pts.size();
121
122 ASSERTL1(pts.size() >= m_pts[0].size(), "Field size mismatch");
123
124 // redirect existing pts
125 Array<OneD, Array<OneD, NekDouble>> newpts(nTotvars + 1);
126 for (size_t i = 0; i < nTotvars; ++i)
127 {
128 newpts[i] = m_pts[i];
129 }
130 newpts[nTotvars] = Array<OneD, NekDouble>(m_pts[0].size(), pts.data());
131
132 m_pts = newpts;
133
134 m_fieldNames.push_back(fieldName);
135}
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:242

References ASSERTL1, m_fieldNames, and m_pts.

◆ AddPoints()

void Nektar::LibUtilities::PtsField::AddPoints ( const Array< OneD, const Array< OneD, NekDouble > > &  pts)

Definition at line 158 of file PtsField.cpp.

159{
160 ASSERTL1(pts.size() == m_pts.size(), "number of variables mismatch");
161
162 // TODO: dont copy, dont iterate
163 for (size_t i = 0; i < m_pts.size(); ++i)
164 {
165 Array<OneD, NekDouble> tmp(m_pts[i].size() + pts[i].size());
166 for (size_t j = 0; j < m_pts[i].size(); ++j)
167 {
168 tmp[j] = m_pts[i][j];
169 }
170 for (size_t j = 0; j < pts[i].size(); ++j)
171 {
172 tmp[m_pts[i].size() + j] = pts[i][j];
173 }
174 m_pts[i] = tmp;
175 }
176}

References ASSERTL1, and m_pts.

◆ GetBoxSize()

vector< NekDouble > Nektar::LibUtilities::PtsField::GetBoxSize ( ) const

Definition at line 264 of file PtsField.cpp.

265{
266 return m_boxSize;
267}
std::vector< NekDouble > m_boxSize
vector of box size xmin,xmax,ymin,ymax,zmin,zmax
Definition: PtsField.h:181

References m_boxSize.

◆ GetConnectivity()

void Nektar::LibUtilities::PtsField::GetConnectivity ( std::vector< Array< OneD, int > > &  conn) const

Set the connectivity data for ePtsTetBlock and ePtsTriBlock.

Parameters
connConnectivity data Connectivity data needed for ePtsTetBlock and ePtsTriBlock. For n Blocks with m elements each, m_ptsConn is a vector of n arrays with 3*m (ePtsTriBlock) or 4*m (ePtsTetBlock) entries.

Definition at line 61 of file PtsField.cpp.

62{
63 conn = m_ptsConn;
64}
std::vector< Array< OneD, int > > m_ptsConn
Connectivity data needed for ePtsTetBlock and ePtsTriBlock. For n Blocks with m elements each,...
Definition: PtsField.h:176

References m_ptsConn.

◆ GetDim()

size_t Nektar::LibUtilities::PtsField::GetDim ( ) const

Definition at line 88 of file PtsField.cpp.

89{
90 return m_dim;
91}

References m_dim.

Referenced by RemoveField().

◆ GetFieldName()

std::string Nektar::LibUtilities::PtsField::GetFieldName ( const int  i) const

Definition at line 103 of file PtsField.cpp.

104{
105 return m_fieldNames[i];
106}

References m_fieldNames.

◆ GetFieldNames()

vector< std::string > Nektar::LibUtilities::PtsField::GetFieldNames ( ) const

Definition at line 98 of file PtsField.cpp.

99{
100 return m_fieldNames;
101}

References m_fieldNames.

◆ GetNFields()

size_t Nektar::LibUtilities::PtsField::GetNFields ( ) const

Definition at line 93 of file PtsField.cpp.

94{
95 return m_pts.size() - m_dim;
96}

References m_dim, and m_pts.

Referenced by PtsField().

◆ GetNpoints()

size_t Nektar::LibUtilities::PtsField::GetNpoints ( ) const

Definition at line 178 of file PtsField.cpp.

179{
180 return m_pts[0].size();
181}

References m_pts.

◆ GetPointsPerEdge() [1/2]

vector< size_t > Nektar::LibUtilities::PtsField::GetPointsPerEdge ( ) const

Definition at line 218 of file PtsField.cpp.

219{
220 return m_nPtsPerEdge;
221}
std::vector< size_t > m_nPtsPerEdge
Number of points per edge. Empty if the point data has no specific shape (ePtsLine) or is a block (eP...
Definition: PtsField.h:171

References m_nPtsPerEdge.

◆ GetPointsPerEdge() [2/2]

size_t Nektar::LibUtilities::PtsField::GetPointsPerEdge ( const size_t  i) const

Definition at line 223 of file PtsField.cpp.

224{
225 return m_nPtsPerEdge[i];
226}

References m_nPtsPerEdge.

◆ GetPointsPerElement()

vector< int > Nektar::LibUtilities::PtsField::GetPointsPerElement ( ) const

Definition at line 244 of file PtsField.cpp.

245{
246 return m_nPtsPerElement;
247}
std::vector< int > m_nPtsPerElement
Definition: PtsField.h:172

References m_nPtsPerElement.

◆ GetPointVal()

NekDouble Nektar::LibUtilities::PtsField::GetPointVal ( const size_t  fieldInd,
const size_t  ptInd 
) const

Definition at line 183 of file PtsField.cpp.

184{
185 return m_pts[fieldInd][ptInd];
186}

References m_pts.

◆ GetPts() [1/2]

void Nektar::LibUtilities::PtsField::GetPts ( Array< OneD, Array< OneD, NekDouble > > &  pts) const

Definition at line 194 of file PtsField.cpp.

195{
196 pts = m_pts;
197}

References m_pts.

◆ GetPts() [2/2]

Array< OneD, NekDouble > Nektar::LibUtilities::PtsField::GetPts ( const int  fieldInd) const

Definition at line 199 of file PtsField.cpp.

200{
201 return m_pts[fieldInd];
202}

References m_pts.

◆ GetPtsType()

PtsType Nektar::LibUtilities::PtsField::GetPtsType ( ) const

Definition at line 254 of file PtsField.cpp.

255{
256 return m_ptsType;
257}

References m_ptsType.

◆ RemoveField()

void Nektar::LibUtilities::PtsField::RemoveField ( const std::string  fieldName)

Definition at line 137 of file PtsField.cpp.

138{
139 size_t nTotvars = m_pts.size();
140
141 // redirect existing pts
142 Array<OneD, Array<OneD, NekDouble>> newpts(nTotvars - 1);
143 for (size_t i = 0, j = 0; i < nTotvars; ++i)
144 {
145 if (i < GetDim() || m_fieldNames[i - GetDim()] != fieldName)
146 {
147 newpts[j++] = m_pts[i];
148 }
149 }
150
151 m_pts = newpts;
152
153 m_fieldNames.erase(
154 remove(m_fieldNames.begin(), m_fieldNames.end(), fieldName),
155 m_fieldNames.end());
156}

References GetDim(), m_fieldNames, and m_pts.

◆ SetBoxSize()

void Nektar::LibUtilities::PtsField::SetBoxSize ( const std::vector< NekDouble boxsize)

Definition at line 269 of file PtsField.cpp.

270{
271 m_boxSize = boxSize;
272}

References m_boxSize.

◆ SetConnectivity()

void Nektar::LibUtilities::PtsField::SetConnectivity ( const std::vector< Array< OneD, int > > &  conn)

Get the connectivity data for ePtsTetBlock and ePtsTriBlock.

Parameters
connConnectivity data Connectivity data needed for ePtsTetBlock and ePtsTriBlock. For n Blocks with m elements each, m_ptsConn is a vector of n arrays with 3*m (ePtsTriBlock) or 4*m (ePtsTetBlock) entries.

Definition at line 74 of file PtsField.cpp.

75{
78 "ptsType must be set before connectivity");
79
80 m_ptsConn = conn;
81}

References ASSERTL1, Nektar::LibUtilities::ePtsSegBlock, Nektar::LibUtilities::ePtsTetBlock, Nektar::LibUtilities::ePtsTriBlock, m_ptsConn, and m_ptsType.

◆ SetDim()

void Nektar::LibUtilities::PtsField::SetDim ( const int  ptsDim)

Definition at line 83 of file PtsField.cpp.

84{
85 m_dim = ptsDim;
86}

References m_dim.

◆ SetFieldNames()

void Nektar::LibUtilities::PtsField::SetFieldNames ( const std::vector< std::string >  fieldNames)

Definition at line 108 of file PtsField.cpp.

109{
110 ASSERTL0(fieldNames.size() == m_pts.size() - m_dim,
111 "Number of given fieldNames does not match the number of stored "
112 "fields");
113
114 m_fieldNames = fieldNames;
115}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208

References ASSERTL0, m_dim, m_fieldNames, and m_pts.

◆ SetPointsPerEdge()

void Nektar::LibUtilities::PtsField::SetPointsPerEdge ( const std::vector< size_t >  nPtsPerEdge)

Set the number of points per edge.

Parameters
nPtsPerEdgeNumber of points per edge. Empty if the point data has no specific shape (ePtsLine) or is a block (ePtsTetBlock, ePtsTriBlock), size=1 for ePtsLine, 2 for ePtsPlane and 3 for ePtsBox

Definition at line 235 of file PtsField.cpp.

236{
237 ASSERTL0(
239 "SetPointsPerEdge only supported for ePtsLine, ePtsPlane and ePtsBox.");
240
241 m_nPtsPerEdge = nPtsPerEdge;
242}

References ASSERTL0, Nektar::LibUtilities::ePtsBox, Nektar::LibUtilities::ePtsLine, Nektar::LibUtilities::ePtsPlane, m_nPtsPerEdge, and m_ptsType.

◆ SetPointsPerElement()

void Nektar::LibUtilities::PtsField::SetPointsPerElement ( const std::vector< int >  nPtsPerElement)

Definition at line 249 of file PtsField.cpp.

250{
251 m_nPtsPerElement = nPtsPerElement;
252}

References m_nPtsPerElement.

◆ SetPointVal()

void Nektar::LibUtilities::PtsField::SetPointVal ( const size_t  fieldInd,
const size_t  ptInd,
const NekDouble  val 
)

Definition at line 188 of file PtsField.cpp.

190{
191 m_pts[fieldInd][ptInd] = val;
192}

References m_pts.

◆ SetPts() [1/2]

void Nektar::LibUtilities::PtsField::SetPts ( Array< OneD, Array< OneD, NekDouble > > &  pts)

Definition at line 204 of file PtsField.cpp.

205{
206 ASSERTL1(pts.size() == m_pts.size(), "Pts field count mismatch");
207
208 m_pts = pts;
209}

References ASSERTL1, and m_pts.

◆ SetPts() [2/2]

void Nektar::LibUtilities::PtsField::SetPts ( const int  fldId,
const Array< OneD, const NekDouble > &  pts 
)

Definition at line 211 of file PtsField.cpp.

212{
213 ASSERTL1(fldId < m_pts.size(), "Pts field count mismatch");
214
215 m_pts[fldId] = pts;
216}

References ASSERTL1, and m_pts.

◆ SetPtsType()

void Nektar::LibUtilities::PtsField::SetPtsType ( const PtsType  type)

Definition at line 259 of file PtsField.cpp.

260{
261 m_ptsType = type;
262}

References m_ptsType.

Member Data Documentation

◆ m_boxSize

std::vector<NekDouble> Nektar::LibUtilities::PtsField::m_boxSize
private

vector of box size xmin,xmax,ymin,ymax,zmin,zmax

Definition at line 181 of file PtsField.h.

Referenced by GetBoxSize(), and SetBoxSize().

◆ m_dim

size_t Nektar::LibUtilities::PtsField::m_dim
private

Dimension of the pts field.

Definition at line 162 of file PtsField.h.

Referenced by GetDim(), GetNFields(), SetDim(), and SetFieldNames().

◆ m_fieldNames

std::vector<std::string> Nektar::LibUtilities::PtsField::m_fieldNames
private

Names of the field variables.

Definition at line 164 of file PtsField.h.

Referenced by AddField(), GetFieldName(), GetFieldNames(), PtsField(), RemoveField(), and SetFieldNames().

◆ m_nPtsPerEdge

std::vector<size_t> Nektar::LibUtilities::PtsField::m_nPtsPerEdge
private

Number of points per edge. Empty if the point data has no specific shape (ePtsLine) or is a block (ePtsTetBlock, ePtsTriBlock), size=1 for ePtsLine and 2 for a ePtsPlane.

Definition at line 171 of file PtsField.h.

Referenced by GetPointsPerEdge(), and SetPointsPerEdge().

◆ m_nPtsPerElement

std::vector<int> Nektar::LibUtilities::PtsField::m_nPtsPerElement
private

Definition at line 172 of file PtsField.h.

Referenced by GetPointsPerElement(), and SetPointsPerElement().

◆ m_pts

Array<OneD, Array<OneD, NekDouble> > Nektar::LibUtilities::PtsField::m_pts
private

Point data. For a n-dimensional field, the first m_dim fields are the points spatial coordinates. Structure: m_pts[fieldIdx][ptIdx].

Definition at line 167 of file PtsField.h.

Referenced by AddField(), AddPoints(), GetNFields(), GetNpoints(), GetPointVal(), GetPts(), RemoveField(), SetFieldNames(), SetPointVal(), and SetPts().

◆ m_ptsConn

std::vector<Array<OneD, int> > Nektar::LibUtilities::PtsField::m_ptsConn
private

Connectivity data needed for ePtsTetBlock and ePtsTriBlock. For n Blocks with m elements each, m_ptsConn is a vector of n arrays with 3*m (ePtsTriBlock) or 4*m (ePtsTetBlock) entries.

Definition at line 176 of file PtsField.h.

Referenced by GetConnectivity(), and SetConnectivity().

◆ m_ptsInfo

std::map<PtsInfo, int> Nektar::LibUtilities::PtsField::m_ptsInfo

map for information about points that can be added through PtsInfo enum

Definition at line 158 of file PtsField.h.

◆ m_ptsType

PtsType Nektar::LibUtilities::PtsField::m_ptsType
private

Type of the PtsField.

Definition at line 178 of file PtsField.h.

Referenced by GetPtsType(), SetConnectivity(), SetPointsPerEdge(), and SetPtsType().