Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 // License for the specific language governing rights and limitations under
15 // Permission is hereby granted, free of charge, to any person obtaining a
16 // copy of this software and associated documentation files (the "Software"),
17 // to deal in the Software without restriction, including without limitation
18 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
19 // and/or sell copies of the Software, and to permit persons to whom the
20 // Software is furnished to do so, subject to the following conditions:
21 //
22 // The above copyright notice and this permission notice shall be included
23 // in all copies or substantial portions of the Software.
24 //
25 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
26 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
28 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
30 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
31 // DEALINGS IN THE SOFTWARE.
32 //
33 // Description: Pts field
34 //
35 ///////////////////////////////////////////////////////////////////////////////
36 
37 #ifndef NEKTAR_LIB_UTILITIES_BASIC_UTILS_PTSFIELD_H
38 #define NEKTAR_LIB_UTILITIES_BASIC_UTILS_PTSFIELD_H
39 
40 #include <vector>
41 
42 #include <boost/shared_ptr.hpp>
43 #include <boost/function.hpp>
44 
48 
49 using namespace std;
50 
51 namespace Nektar
52 {
53 namespace LibUtilities
54 {
55 
56 enum PtsType{
63 };
64 
65 
66 enum PtsInfo{
69 };
70 
71 
72 static map<PtsInfo,int> NullPtsInfoMap;
73 
74 class PtsPoint
75 {
76  public:
77 
78  int m_idx;
81 
83 
85  NekDouble distSq):
86  m_idx(idx),
87  m_coords(coords),
88  m_distSq(distSq)
89  {
90  };
91 
92  LIB_UTILITIES_EXPORT bool operator < (const PtsPoint &comp) const
93  {
94  return (m_distSq < comp.m_distSq);
95  };
96 };
97 
98 
99 class PtsField
100 {
101  public:
103  const int dim,
104  const Array<OneD, Array<OneD, NekDouble> > &pts);
105 
107  const int dim,
108  const vector<std::string> fieldnames,
109  const Array<OneD, Array<OneD, NekDouble> > &pts,
110  map<PtsInfo,int> ptsInfo = NullPtsInfoMap):
111  m_ptsInfo(ptsInfo),
112  m_dim(dim),
113  m_fieldNames(fieldnames),
114  m_pts(pts),
115  m_ptsType(ePtsFile)
116  {
117  };
118 
120  const int dim,
121  const vector<std::string> fieldnames,
122  const Array<OneD, Array<OneD, NekDouble> > &pts,
124  const Array<OneD, Array<OneD, unsigned int> > &neighInds) :
125  m_ptsInfo(NullPtsInfoMap),
126  m_dim(dim),
127  m_fieldNames(fieldnames),
128  m_pts(pts),
129  m_ptsType(ePtsFile),
130  m_weights(weights),
131  m_neighInds(neighInds)
132  {
133  };
134 
135  LIB_UTILITIES_EXPORT void CalcWeights(
136  const Array< OneD, Array< OneD, NekDouble > > &physCoords,
137  short int coordId = -1);
138 
139  LIB_UTILITIES_EXPORT void Interpolate(
140  const Array< OneD, Array< OneD, NekDouble > > &physCoords,
141  Array<OneD, Array<OneD, NekDouble> > &intFields,
142  short int coordId = -1);
143 
144  LIB_UTILITIES_EXPORT void Interpolate(
146  &intFields);
147 
148  LIB_UTILITIES_EXPORT void SetWeights
149  (const Array<OneD, Array<OneD, float> >
150  &weights,
151  const Array<OneD, Array<OneD, unsigned int> > &neighbourInds);
152 
153  LIB_UTILITIES_EXPORT void GetWeights(
155  Array<OneD, Array<OneD, unsigned int> > &neighbourInds) const;
156 
157  LIB_UTILITIES_EXPORT void GetConnectivity(vector<Array<OneD, int> > &conn) const;
158 
159  LIB_UTILITIES_EXPORT void SetConnectivity(const vector<Array<OneD, int> > &conn);
160 
161  LIB_UTILITIES_EXPORT void SetDim(const int ptsDim);
162 
163  LIB_UTILITIES_EXPORT int GetDim() const;
164 
165  LIB_UTILITIES_EXPORT int GetNFields() const;
166 
167  LIB_UTILITIES_EXPORT vector<std::string> GetFieldNames() const;
168 
169  LIB_UTILITIES_EXPORT std::string GetFieldName(const int i) const;
170 
171  LIB_UTILITIES_EXPORT void SetFieldNames(
172  const vector<std::string> fieldNames);
173 
174  LIB_UTILITIES_EXPORT void AddField(const Array<OneD, NekDouble> &pts,
175  const std::string fieldName);
176 
177  LIB_UTILITIES_EXPORT int GetNpoints() const;
178 
179  LIB_UTILITIES_EXPORT NekDouble GetPointVal(const int fieldInd, const int ptInd) const;
180 
181  LIB_UTILITIES_EXPORT void GetPts(
182  Array<OneD, Array<OneD, NekDouble> > &pts) const;
183 
184  LIB_UTILITIES_EXPORT Array<OneD, NekDouble> GetPts(const int fieldInd) const;
185 
187 
188  LIB_UTILITIES_EXPORT vector<int> GetPointsPerEdge() const;
189 
190  LIB_UTILITIES_EXPORT int GetPointsPerEdge(const int i) const;
191 
192  LIB_UTILITIES_EXPORT void SetPointsPerEdge(const vector<int> nPtsPerEdge);
193 
194  LIB_UTILITIES_EXPORT PtsType GetPtsType() const;
195 
196  LIB_UTILITIES_EXPORT void SetPtsType(const PtsType type);
197 
198  LIB_UTILITIES_EXPORT vector<NekDouble> GetBoxSize() const;
199 
200  LIB_UTILITIES_EXPORT void SetBoxSize(const vector<NekDouble> boxsize);
201  template<typename FuncPointerT, typename ObjectPointerT>
202  void setProgressCallback(FuncPointerT func,
203  ObjectPointerT obj)
204  {
205  m_progressCallback = boost::bind(func, obj, _1, _2);
206  }
207 
208  /// map for information about points that can be added through PtsInfo enum
209  map<PtsInfo,int> m_ptsInfo;
210 
211  private:
212 
213  /// Dimension of the pts field
214  int m_dim;
215  /// Names of the field variables
216  vector<std::string> m_fieldNames;
217  /// Point data. For a n-dimensional field, the first m_dim fields are the
218  /// points spatial coordinates. Structure: m_pts[fieldIdx][ptIdx]
220  /// Number of points per edge. Empty if the point data has no
221  /// specific shape (ePtsLine) or is a block (ePtsTetBlock,
222  /// ePtsTriBlock), size=1 for ePtsLine and 2 for a ePtsPlane
223  vector<int> m_nPtsPerEdge;
224  /// Connectivity data needed for ePtsTetBlock and ePtsTriBlock. For n
225  /// Blocks with m elements each, m_ptsConn is a vector of n arrays with
226  /// 3*m (ePtsTriBlock) or 4*m (ePtsTetBlock) entries.
227  vector<Array<OneD, int> > m_ptsConn;
228  /// Type of the PtsField
230  /// Interpolation weights for each neighbour.
231  /// Structure: m_weights[physPtIdx][neighbourIdx]
233  /// Indices of the relevant neighbours for each physical point.
234  /// Structure: m_neighInds[ptIdx][neighbourIdx]
236 
237  /// vector of box size xmin,xmax,ymin,ymax,zmin,zmax
238  vector<NekDouble> m_boxSize;
239 
240  boost::function<void (const int position, const int goal)> m_progressCallback;
241 
242  LIB_UTILITIES_EXPORT void CalcW_Linear(const int physPtIdx,
243  const NekDouble coord);
244 
245  LIB_UTILITIES_EXPORT void CalcW_Shepard(
246  const int physPtIdx,
247  const Array< OneD, NekDouble > &physPtCoords);
248 
249  LIB_UTILITIES_EXPORT void CalcW_Quadratic(const int physPtIdx,
250  const NekDouble coord);
251 
253  const Array<OneD, NekDouble > &point1,
254  const Array<OneD, NekDouble > &point2) const;
255 
256  LIB_UTILITIES_EXPORT void FindNeighbours(const Array<OneD, NekDouble>
257  &physPtCoords,
258  vector<PtsPoint> &neighbourPts,
259  const unsigned int numPts = 1);
260 
261 };
262 
263 typedef boost::shared_ptr<PtsField> PtsFieldSharedPtr;
264 static PtsFieldSharedPtr NullPtsField;
265 
266 
267 }
268 }
269 #endif
Array< OneD, Array< OneD, unsigned int > > m_neighInds
Indices of the relevant neighbours for each physical point. Structure: m_neighInds[ptIdx][neighbourId...
Definition: PtsField.h:235
map< PtsInfo, int > m_ptsInfo
map for information about points that can be added through PtsInfo enum
Definition: PtsField.h:209
Array< OneD, Array< OneD, float > > m_weights
Interpolation weights for each neighbour. Structure: m_weights[physPtIdx][neighbourIdx].
Definition: PtsField.h:232
PtsPoint(int idx, Array< OneD, NekDouble > coords, NekDouble distSq)
Definition: PtsField.h:84
STL namespace.
vector< Array< OneD, int > > m_ptsConn
Connectivity data needed for ePtsTetBlock and ePtsTriBlock. For n Blocks with m elements each...
Definition: PtsField.h:227
boost::shared_ptr< PtsField > PtsFieldSharedPtr
Definition: PtsField.h:263
vector< int > 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:223
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:219
map< pair< int, int >, NekDouble > weights(set< pair< int, int > > springs, Array< OneD, NekDouble > u, Array< OneD, NekDouble > v)
PtsType m_ptsType
Type of the PtsField.
Definition: PtsField.h:229
#define LIB_UTILITIES_EXPORT
int m_dim
Dimension of the pts field.
Definition: PtsField.h:214
vector< std::string > m_fieldNames
Names of the field variables.
Definition: PtsField.h:216
PtsField(const int dim, const vector< std::string > fieldnames, const Array< OneD, Array< OneD, NekDouble > > &pts, map< PtsInfo, int > ptsInfo=NullPtsInfoMap)
Definition: PtsField.h:106
void setProgressCallback(FuncPointerT func, ObjectPointerT obj)
Definition: PtsField.h:202
double NekDouble
Array< OneD, NekDouble > m_coords
Definition: PtsField.h:79
bool operator<(const BasisKey &lhs, const BasisKey &rhs)
Definition: Basis.cpp:49
static PtsFieldSharedPtr NullPtsField
Definition: PtsField.h:264
static map< PtsInfo, int > NullPtsInfoMap
Definition: PtsField.h:72
vector< NekDouble > m_boxSize
vector of box size xmin,xmax,ymin,ymax,zmin,zmax
Definition: PtsField.h:238
PtsField(const int dim, const 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:119
boost::function< void(const int position, const int goal)> m_progressCallback
Definition: PtsField.h:240