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 72 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 45 of file PtsField.cpp.

47  : m_dim(dim), m_pts(pts), m_ptsType(ePtsFile)
48 {
49  for (int i = 0; i < GetNFields(); ++i)
50  {
51  m_fieldNames.push_back("NA");
52  }
53 }
size_t m_dim
Dimension of the pts field.
Definition: PtsField.h:168
PtsType m_ptsType
Type of the PtsField.
Definition: PtsField.h:184
std::vector< std::string > m_fieldNames
Names of the field variables.
Definition: PtsField.h:170
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:173

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 78 of file PtsField.h.

82  : 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:164

◆ 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 85 of file PtsField.h.

90  : m_ptsInfo(NullPtsInfoMap), m_dim(dim), m_fieldNames(fieldnames),
91  m_pts(pts), m_ptsType(ePtsFile)
92  {
93  boost::ignore_unused(weights, neighInds);
94  };
static std::map< PtsInfo, int > NullPtsInfoMap
Definition: PtsField.h:70

Member Function Documentation

◆ AddField()

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

Definition at line 119 of file PtsField.cpp.

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

References ASSERTL1, m_fieldNames, and m_pts.

◆ AddPoints()

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

Definition at line 160 of file PtsField.cpp.

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

References ASSERTL1, and m_pts.

◆ GetBoxSize()

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

Definition at line 266 of file PtsField.cpp.

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

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 63 of file PtsField.cpp.

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

References m_ptsConn.

◆ GetDim()

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

Definition at line 90 of file PtsField.cpp.

91 {
92  return m_dim;
93 }

References m_dim.

Referenced by RemoveField().

◆ GetFieldName()

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

Definition at line 105 of file PtsField.cpp.

106 {
107  return m_fieldNames[i];
108 }

References m_fieldNames.

◆ GetFieldNames()

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

Definition at line 100 of file PtsField.cpp.

101 {
102  return m_fieldNames;
103 }

References m_fieldNames.

◆ GetNFields()

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

Definition at line 95 of file PtsField.cpp.

96 {
97  return m_pts.size() - m_dim;
98 }

References m_dim, and m_pts.

Referenced by PtsField().

◆ GetNpoints()

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

Definition at line 180 of file PtsField.cpp.

181 {
182  return m_pts[0].size();
183 }

References m_pts.

◆ GetPointsPerEdge() [1/2]

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

Definition at line 220 of file PtsField.cpp.

221 {
222  return m_nPtsPerEdge;
223 }
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:177

References m_nPtsPerEdge.

◆ GetPointsPerEdge() [2/2]

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

Definition at line 225 of file PtsField.cpp.

226 {
227  return m_nPtsPerEdge[i];
228 }

References m_nPtsPerEdge.

◆ GetPointsPerElement()

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

Definition at line 246 of file PtsField.cpp.

247 {
248  return m_nPtsPerElement;
249 }
std::vector< int > m_nPtsPerElement
Definition: PtsField.h:178

References m_nPtsPerElement.

◆ GetPointVal()

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

Definition at line 185 of file PtsField.cpp.

186 {
187  return m_pts[fieldInd][ptInd];
188 }

References m_pts.

◆ GetPts() [1/2]

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

Definition at line 196 of file PtsField.cpp.

197 {
198  pts = m_pts;
199 }

References m_pts.

◆ GetPts() [2/2]

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

Definition at line 201 of file PtsField.cpp.

202 {
203  return m_pts[fieldInd];
204 }

References m_pts.

◆ GetPtsType()

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

Definition at line 256 of file PtsField.cpp.

257 {
258  return m_ptsType;
259 }

References m_ptsType.

◆ RemoveField()

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

Definition at line 139 of file PtsField.cpp.

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

References GetDim(), m_fieldNames, and m_pts.

◆ SetBoxSize()

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

Definition at line 271 of file PtsField.cpp.

272 {
273  m_boxSize = boxSize;
274 }

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 76 of file PtsField.cpp.

77 {
80  "ptsType must be set before connectivity");
81 
82  m_ptsConn = conn;
83 }

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 85 of file PtsField.cpp.

86 {
87  m_dim = ptsDim;
88 }

References m_dim.

◆ SetFieldNames()

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

Definition at line 110 of file PtsField.cpp.

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

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 237 of file PtsField.cpp.

238 {
239  ASSERTL0(
241  "SetPointsPerEdge only supported for ePtsLine, ePtsPlane and ePtsBox.");
242 
243  m_nPtsPerEdge = nPtsPerEdge;
244 }

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 251 of file PtsField.cpp.

252 {
253  m_nPtsPerElement = nPtsPerElement;
254 }

References m_nPtsPerElement.

◆ SetPointVal()

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

Definition at line 190 of file PtsField.cpp.

192 {
193  m_pts[fieldInd][ptInd] = val;
194 }

References m_pts.

◆ SetPts() [1/2]

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

Definition at line 206 of file PtsField.cpp.

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

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 213 of file PtsField.cpp.

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

References ASSERTL1, and m_pts.

◆ SetPtsType()

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

Definition at line 261 of file PtsField.cpp.

262 {
263  m_ptsType = type;
264 }

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 187 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 168 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 170 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 177 of file PtsField.h.

Referenced by GetPointsPerEdge(), and SetPointsPerEdge().

◆ m_nPtsPerElement

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

Definition at line 178 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 173 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 182 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 164 of file PtsField.h.

◆ m_ptsType

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

Type of the PtsField.

Definition at line 184 of file PtsField.h.

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