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 void SetPts(const int fldId,
139  const Array< OneD, const NekDouble > &pts);
140 
141  LIB_UTILITIES_EXPORT std::vector<size_t> GetPointsPerEdge() const;
142 
143  LIB_UTILITIES_EXPORT size_t GetPointsPerEdge(const size_t i) const;
144 
146  const std::vector<size_t> nPtsPerEdge);
147 
149 
150  LIB_UTILITIES_EXPORT void SetPtsType(const PtsType type);
151 
152  LIB_UTILITIES_EXPORT std::vector<NekDouble> GetBoxSize() const;
153 
154  LIB_UTILITIES_EXPORT void SetBoxSize(const std::vector<NekDouble> boxsize);
155 
156  /// map for information about points that can be added through PtsInfo enum
157  std::map<PtsInfo, int> m_ptsInfo;
158 
159 private:
160  /// Dimension of the pts field
161  size_t m_dim;
162  /// Names of the field variables
163  std::vector<std::string> m_fieldNames;
164  /// Point data. For a n-dimensional field, the first m_dim fields are the
165  /// points spatial coordinates. Structure: m_pts[fieldIdx][ptIdx]
167  /// Number of points per edge. Empty if the point data has no
168  /// specific shape (ePtsLine) or is a block (ePtsTetBlock,
169  /// ePtsTriBlock), size=1 for ePtsLine and 2 for a ePtsPlane
170  std::vector<size_t> m_nPtsPerEdge;
171  /// Connectivity data needed for ePtsTetBlock and ePtsTriBlock. For n
172  /// Blocks with m elements each, m_ptsConn is a vector of n arrays with
173  /// 3*m (ePtsTriBlock) or 4*m (ePtsTetBlock) entries.
174  std::vector<Array<OneD, int> > m_ptsConn;
175  /// Type of the PtsField
177 
178  /// vector of box size xmin,xmax,ymin,ymax,zmin,zmax
179  std::vector<NekDouble> m_boxSize;
180 };
181 
182 typedef std::shared_ptr<PtsField> PtsFieldSharedPtr;
184 }
185 }
186 
187 #endif
#define LIB_UTILITIES_EXPORT
void SetBoxSize(const std::vector< NekDouble > boxsize)
Definition: PtsField.cpp:265
NekDouble GetPointVal(const size_t fieldInd, const size_t ptInd) const
Definition: PtsField.cpp:186
std::vector< std::string > GetFieldNames() const
Definition: PtsField.cpp:100
std::vector< size_t > GetPointsPerEdge() const
Definition: PtsField.cpp:224
void SetFieldNames(const std::vector< std::string > fieldNames)
Definition: PtsField.cpp:110
std::vector< Array< OneD, int > > m_ptsConn
Connectivity data needed for ePtsTetBlock and ePtsTriBlock. For n Blocks with m elements each,...
Definition: PtsField.h:174
void SetPointVal(const size_t fieldInd, const size_t ptInd, const NekDouble val)
Definition: PtsField.cpp:191
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
void SetDim(const int ptsDim)
Definition: PtsField.cpp:85
PtsField(const int dim, const Array< OneD, Array< OneD, NekDouble > > &pts)
Definition: PtsField.cpp:45
std::vector< NekDouble > GetBoxSize() const
Definition: PtsField.cpp:260
size_t m_dim
Dimension of the pts field.
Definition: PtsField.h:161
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:170
std::string GetFieldName(const int i) const
Definition: PtsField.cpp:105
void GetConnectivity(std::vector< Array< OneD, int > > &conn) const
Set the connectivity data for ePtsTetBlock and ePtsTriBlock.
Definition: PtsField.cpp:63
PtsType m_ptsType
Type of the PtsField.
Definition: PtsField.h:176
std::vector< std::string > m_fieldNames
Names of the field variables.
Definition: PtsField.h:163
std::vector< NekDouble > m_boxSize
vector of box size xmin,xmax,ymin,ymax,zmin,zmax
Definition: PtsField.h:179
void SetPts(Array< OneD, Array< OneD, NekDouble > > &pts)
Definition: PtsField.cpp:208
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:166
void SetConnectivity(const std::vector< Array< OneD, int > > &conn)
Get the connectivity data for ePtsTetBlock and ePtsTriBlock.
Definition: PtsField.cpp:76
std::map< PtsInfo, int > m_ptsInfo
map for information about points that can be added through PtsInfo enum
Definition: PtsField.h:157
void RemoveField(const std::string fieldName)
Definition: PtsField.cpp:141
void SetPointsPerEdge(const std::vector< size_t > nPtsPerEdge)
Set the number of points per edge.
Definition: PtsField.cpp:241
void SetPtsType(const PtsType type)
Definition: PtsField.cpp:255
void AddPoints(const Array< OneD, const Array< OneD, NekDouble > > &pts)
Definition: PtsField.cpp:160
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
void GetPts(Array< OneD, Array< OneD, NekDouble > > &pts) const
Definition: PtsField.cpp:198
void AddField(const Array< OneD, NekDouble > &pts, const std::string fieldName)
Definition: PtsField.cpp:119
static std::map< PtsInfo, int > NullPtsInfoMap
Definition: PtsField.h:70
std::shared_ptr< PtsField > PtsFieldSharedPtr
Definition: PtsField.h:182
static PtsFieldSharedPtr NullPtsField
Definition: PtsField.h:183
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
double NekDouble