Nektar++
PtsField.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File PtsField.h
4 //
5 // For more information, please see: http://www.nektar.info
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2014 Kilian Lackhove
10 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
11 // Department of Aeronautics, Imperial College London (UK), and Scientific
12 // Computing and Imaging Institute, University of Utah (USA).
13 //
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: Pts field
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef NEKTAR_LIB_UTILITIES_BASIC_UTILS_PTSFIELD_H
37 #define NEKTAR_LIB_UTILITIES_BASIC_UTILS_PTSFIELD_H
38 
39 #include <vector>
40 #include <memory>
41 
42 #include <boost/core/ignore_unused.hpp>
43 
47 
48 namespace Nektar
49 {
50 namespace LibUtilities
51 {
52 
53 enum PtsType
54 {
62 };
63 
64 enum PtsInfo
65 {
68 };
69 
70 static std::map<PtsInfo, int> NullPtsInfoMap;
71 
72 class PtsField
73 {
74 public:
76  const int dim, const Array<OneD, Array<OneD, NekDouble> > &pts);
77 
79  const int dim,
80  const std::vector<std::string> fieldnames,
81  const Array<OneD, Array<OneD, NekDouble> > &pts,
82  std::map<PtsInfo, int> ptsInfo = NullPtsInfoMap)
83  : m_ptsInfo(ptsInfo), m_dim(dim), m_fieldNames(fieldnames), m_pts(pts),
85 
87  const int dim,
88  const std::vector<std::string> fieldnames,
89  const Array<OneD, Array<OneD, NekDouble> > &pts,
90  const Array<OneD, Array<OneD, float> > & weights,
91  const Array<OneD, Array<OneD, unsigned int> > & neighInds)
92  : m_ptsInfo(NullPtsInfoMap), m_dim(dim), m_fieldNames(fieldnames),
93  m_pts(pts), m_ptsType(ePtsFile) { boost::ignore_unused(weights, neighInds); };
94 
96  std::vector<Array<OneD, int> > &conn) const;
97 
99  const std::vector<Array<OneD, int> > &conn);
100 
101  LIB_UTILITIES_EXPORT void SetDim(const int ptsDim);
102 
103  LIB_UTILITIES_EXPORT size_t GetDim() const;
104 
105  LIB_UTILITIES_EXPORT size_t GetNFields() const;
106 
107  LIB_UTILITIES_EXPORT std::vector<std::string> GetFieldNames() const;
108 
109  LIB_UTILITIES_EXPORT std::string GetFieldName(const int i) const;
110 
112  const std::vector<std::string> fieldNames);
113 
115  const std::string fieldName);
116 
117  LIB_UTILITIES_EXPORT void RemoveField(const std::string fieldName);
118 
120 
121  LIB_UTILITIES_EXPORT size_t GetNpoints() const;
122 
123  LIB_UTILITIES_EXPORT NekDouble GetPointVal(const size_t fieldInd,
124  const size_t ptInd) const;
125 
126  LIB_UTILITIES_EXPORT void SetPointVal(const size_t fieldInd,
127  const size_t ptInd,
128  const NekDouble val);
129 
131  Array<OneD, Array<OneD, NekDouble> > &pts) const;
132 
134  const int fieldInd) const;
135 
137 
138  LIB_UTILITIES_EXPORT std::vector<size_t> GetPointsPerEdge() const;
139 
140  LIB_UTILITIES_EXPORT size_t GetPointsPerEdge(const size_t i) const;
141 
143  const std::vector<size_t> nPtsPerEdge);
144 
146 
147  LIB_UTILITIES_EXPORT void SetPtsType(const PtsType type);
148 
149  LIB_UTILITIES_EXPORT std::vector<NekDouble> GetBoxSize() const;
150 
151  LIB_UTILITIES_EXPORT void SetBoxSize(const std::vector<NekDouble> boxsize);
152 
153  /// map for information about points that can be added through PtsInfo enum
154  std::map<PtsInfo, int> m_ptsInfo;
155 
156 private:
157  /// Dimension of the pts field
158  size_t m_dim;
159  /// Names of the field variables
160  std::vector<std::string> m_fieldNames;
161  /// Point data. For a n-dimensional field, the first m_dim fields are the
162  /// points spatial coordinates. Structure: m_pts[fieldIdx][ptIdx]
164  /// Number of points per edge. Empty if the point data has no
165  /// specific shape (ePtsLine) or is a block (ePtsTetBlock,
166  /// ePtsTriBlock), size=1 for ePtsLine and 2 for a ePtsPlane
167  std::vector<size_t> m_nPtsPerEdge;
168  /// Connectivity data needed for ePtsTetBlock and ePtsTriBlock. For n
169  /// Blocks with m elements each, m_ptsConn is a vector of n arrays with
170  /// 3*m (ePtsTriBlock) or 4*m (ePtsTetBlock) entries.
171  std::vector<Array<OneD, int> > m_ptsConn;
172  /// Type of the PtsField
174 
175  /// vector of box size xmin,xmax,ymin,ymax,zmin,zmax
176  std::vector<NekDouble> m_boxSize;
177 };
178 
179 typedef std::shared_ptr<PtsField> PtsFieldSharedPtr;
180 static PtsFieldSharedPtr NullPtsField;
181 }
182 }
183 
184 #endif
static std::map< PtsInfo, int > NullPtsInfoMap
Definition: PtsField.h:70
std::vector< NekDouble > m_boxSize
vector of box size xmin,xmax,ymin,ymax,zmin,zmax
Definition: PtsField.h:176
std::vector< Array< OneD, int > > m_ptsConn
Connectivity data needed for ePtsTetBlock and ePtsTriBlock. For n Blocks with m elements each...
Definition: PtsField.h:171
void SetDim(const int ptsDim)
Definition: PtsField.cpp:85
size_t m_dim
Dimension of the pts field.
Definition: PtsField.h:158
PtsField(const int dim, const Array< OneD, Array< OneD, NekDouble > > &pts)
Definition: PtsField.cpp:45
void RemoveField(const std::string fieldName)
Definition: PtsField.cpp:141
void AddField(const Array< OneD, NekDouble > &pts, const std::string fieldName)
Definition: PtsField.cpp:119
std::vector< std::string > GetFieldNames() const
Definition: PtsField.cpp:100
NekDouble GetPointVal(const size_t fieldInd, const size_t ptInd) const
Definition: PtsField.cpp:186
void SetConnectivity(const std::vector< Array< OneD, int > > &conn)
Get the connectivity data for ePtsTetBlock and ePtsTriBlock.
Definition: PtsField.cpp:76
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:163
std::shared_ptr< PtsField > PtsFieldSharedPtr
Definition: PtsField.h:179
PtsType m_ptsType
Type of the PtsField.
Definition: PtsField.h:173
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)
Definition: PtsField.h:86
#define LIB_UTILITIES_EXPORT
void AddPoints(const Array< OneD, const Array< OneD, NekDouble > > &pts)
Definition: PtsField.cpp:160
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:167
PtsField(const int dim, const std::vector< std::string > fieldnames, const Array< OneD, Array< OneD, NekDouble > > &pts, std::map< PtsInfo, int > ptsInfo=NullPtsInfoMap)
Definition: PtsField.h:78
std::vector< NekDouble > GetBoxSize() const
Definition: PtsField.cpp:252
double NekDouble
void SetPointsPerEdge(const std::vector< size_t > nPtsPerEdge)
Set the number of points per edge.
Definition: PtsField.cpp:233
std::vector< size_t > GetPointsPerEdge() const
Definition: PtsField.cpp:216
void GetPts(Array< OneD, Array< OneD, NekDouble > > &pts) const
Definition: PtsField.cpp:198
std::vector< std::string > m_fieldNames
Names of the field variables.
Definition: PtsField.h:160
std::map< PtsInfo, int > m_ptsInfo
map for information about points that can be added through PtsInfo enum
Definition: PtsField.h:154
void SetPtsType(const PtsType type)
Definition: PtsField.cpp:247
static PtsFieldSharedPtr NullPtsField
Definition: PtsField.h:180
std::string GetFieldName(const int i) const
Definition: PtsField.cpp:105
void SetBoxSize(const std::vector< NekDouble > boxsize)
Definition: PtsField.cpp:257
void SetFieldNames(const std::vector< std::string > fieldNames)
Definition: PtsField.cpp:110
void SetPts(Array< OneD, Array< OneD, NekDouble > > &pts)
Definition: PtsField.cpp:208
void GetConnectivity(std::vector< Array< OneD, int > > &conn) const
Set the connectivity data for ePtsTetBlock and ePtsTriBlock.
Definition: PtsField.cpp:63
void SetPointVal(const size_t fieldInd, const size_t ptInd, const NekDouble val)
Definition: PtsField.cpp:191