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 namespace Nektar
50 {
51 namespace LibUtilities
52 {
53 using namespace std;
54 
55 enum PtsType{
62 };
63 
64 
65 enum PtsInfo{
68 };
69 
70 
71 static map<PtsInfo,int> NullPtsInfoMap;
72 
73 class PtsPoint
74 {
75  public:
76 
77  int m_idx;
80 
82 
84  NekDouble distSq):
85  m_idx(idx),
86  m_coords(coords),
87  m_distSq(distSq)
88  {
89  };
90 
91  LIB_UTILITIES_EXPORT bool operator < (const PtsPoint &comp) const
92  {
93  return (m_distSq < comp.m_distSq);
94  };
95 };
96 
97 
98 class PtsField
99 {
100  public:
102  const int dim,
103  const Array<OneD, Array<OneD, NekDouble> > &pts);
104 
106  const int dim,
107  const vector<std::string> fieldnames,
108  const Array<OneD, Array<OneD, NekDouble> > &pts,
109  map<PtsInfo,int> ptsInfo = NullPtsInfoMap):
110  m_ptsInfo(ptsInfo),
111  m_dim(dim),
112  m_fieldNames(fieldnames),
113  m_pts(pts),
114  m_ptsType(ePtsFile)
115  {
116  };
117 
119  const int dim,
120  const vector<std::string> fieldnames,
121  const Array<OneD, Array<OneD, NekDouble> > &pts,
123  const Array<OneD, Array<OneD, unsigned int> > &neighInds) :
124  m_ptsInfo(NullPtsInfoMap),
125  m_dim(dim),
126  m_fieldNames(fieldnames),
127  m_pts(pts),
128  m_ptsType(ePtsFile),
129  m_weights(weights),
130  m_neighInds(neighInds)
131  {
132  };
133 
134  LIB_UTILITIES_EXPORT void CalcWeights(
135  const Array< OneD, Array< OneD, NekDouble > > &physCoords,
136  short int coordId = -1);
137 
138  LIB_UTILITIES_EXPORT void Interpolate(
139  const Array< OneD, Array< OneD, NekDouble > > &physCoords,
140  Array<OneD, Array<OneD, NekDouble> > &intFields,
141  short int coordId = -1);
142 
143  LIB_UTILITIES_EXPORT void Interpolate(
145  &intFields);
146 
147  LIB_UTILITIES_EXPORT void SetWeights
148  (const Array<OneD, Array<OneD, float> >
149  &weights,
150  const Array<OneD, Array<OneD, unsigned int> > &neighbourInds);
151 
152  LIB_UTILITIES_EXPORT void GetWeights(
154  Array<OneD, Array<OneD, unsigned int> > &neighbourInds) const;
155 
156  LIB_UTILITIES_EXPORT void GetConnectivity(vector<Array<OneD, int> > &conn) const;
157 
158  LIB_UTILITIES_EXPORT void SetConnectivity(const vector<Array<OneD, int> > &conn);
159 
160  LIB_UTILITIES_EXPORT void SetDim(const int ptsDim);
161 
162  LIB_UTILITIES_EXPORT int GetDim() const;
163 
164  LIB_UTILITIES_EXPORT int GetNFields() const;
165 
166  LIB_UTILITIES_EXPORT vector<std::string> GetFieldNames() const;
167 
168  LIB_UTILITIES_EXPORT std::string GetFieldName(const int i) const;
169 
170  LIB_UTILITIES_EXPORT void SetFieldNames(
171  const vector<std::string> fieldNames);
172 
173  LIB_UTILITIES_EXPORT void AddField(const Array<OneD, NekDouble> &pts,
174  const std::string fieldName);
175 
176  LIB_UTILITIES_EXPORT int GetNpoints() const;
177 
178  LIB_UTILITIES_EXPORT NekDouble GetPointVal(const int fieldInd, const int ptInd) const;
179 
180  LIB_UTILITIES_EXPORT void GetPts(
181  Array<OneD, Array<OneD, NekDouble> > &pts) const;
182 
183  LIB_UTILITIES_EXPORT Array<OneD, NekDouble> GetPts(const int fieldInd) const;
184 
186 
187  LIB_UTILITIES_EXPORT vector<int> GetPointsPerEdge() const;
188 
189  LIB_UTILITIES_EXPORT int GetPointsPerEdge(const int i) const;
190 
191  LIB_UTILITIES_EXPORT void SetPointsPerEdge(const vector<int> nPtsPerEdge);
192 
193  LIB_UTILITIES_EXPORT PtsType GetPtsType() const;
194 
195  LIB_UTILITIES_EXPORT void SetPtsType(const PtsType type);
196 
197  LIB_UTILITIES_EXPORT vector<NekDouble> GetBoxSize() const;
198 
199  LIB_UTILITIES_EXPORT void SetBoxSize(const vector<NekDouble> boxsize);
200  template<typename FuncPointerT, typename ObjectPointerT>
201  void setProgressCallback(FuncPointerT func,
202  ObjectPointerT obj)
203  {
204  m_progressCallback = boost::bind(func, obj, _1, _2);
205  }
206 
207  /// map for information about points that can be added through PtsInfo enum
208  map<PtsInfo,int> m_ptsInfo;
209 
210  private:
211 
212  /// Dimension of the pts field
213  int m_dim;
214  /// Names of the field variables
215  vector<std::string> m_fieldNames;
216  /// Point data. For a n-dimensional field, the first m_dim fields are the
217  /// points spatial coordinates. Structure: m_pts[fieldIdx][ptIdx]
219  /// Number of points per edge. Empty if the point data has no
220  /// specific shape (ePtsLine) or is a block (ePtsTetBlock,
221  /// ePtsTriBlock), size=1 for ePtsLine and 2 for a ePtsPlane
222  vector<int> m_nPtsPerEdge;
223  /// Connectivity data needed for ePtsTetBlock and ePtsTriBlock. For n
224  /// Blocks with m elements each, m_ptsConn is a vector of n arrays with
225  /// 3*m (ePtsTriBlock) or 4*m (ePtsTetBlock) entries.
226  vector<Array<OneD, int> > m_ptsConn;
227  /// Type of the PtsField
229  /// Interpolation weights for each neighbour.
230  /// Structure: m_weights[physPtIdx][neighbourIdx]
232  /// Indices of the relevant neighbours for each physical point.
233  /// Structure: m_neighInds[ptIdx][neighbourIdx]
235 
236  /// vector of box size xmin,xmax,ymin,ymax,zmin,zmax
237  vector<NekDouble> m_boxSize;
238 
239  boost::function<void (const int position, const int goal)> m_progressCallback;
240 
241  LIB_UTILITIES_EXPORT void CalcW_Linear(const int physPtIdx,
242  const NekDouble coord);
243 
244  LIB_UTILITIES_EXPORT void CalcW_Shepard(
245  const int physPtIdx,
246  const Array< OneD, NekDouble > &physPtCoords);
247 
248  LIB_UTILITIES_EXPORT void CalcW_Quadratic(const int physPtIdx,
249  const NekDouble coord);
250 
252  const Array<OneD, NekDouble > &point1,
253  const Array<OneD, NekDouble > &point2) const;
254 
255  LIB_UTILITIES_EXPORT void FindNeighbours(const Array<OneD, NekDouble>
256  &physPtCoords,
257  vector<PtsPoint> &neighbourPts,
258  const unsigned int numPts = 1);
259 
260 };
261 
262 typedef boost::shared_ptr<PtsField> PtsFieldSharedPtr;
263 static PtsFieldSharedPtr NullPtsField;
264 
265 
266 }
267 }
268 #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:234
map< PtsInfo, int > m_ptsInfo
map for information about points that can be added through PtsInfo enum
Definition: PtsField.h:208
Array< OneD, Array< OneD, float > > m_weights
Interpolation weights for each neighbour. Structure: m_weights[physPtIdx][neighbourIdx].
Definition: PtsField.h:231
PtsPoint(int idx, Array< OneD, NekDouble > coords, NekDouble distSq)
Definition: PtsField.h:83
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:226
boost::shared_ptr< PtsField > PtsFieldSharedPtr
Definition: PtsField.h:262
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:222
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:218
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:228
#define LIB_UTILITIES_EXPORT
int m_dim
Dimension of the pts field.
Definition: PtsField.h:213
vector< std::string > m_fieldNames
Names of the field variables.
Definition: PtsField.h:215
PtsField(const int dim, const vector< std::string > fieldnames, const Array< OneD, Array< OneD, NekDouble > > &pts, map< PtsInfo, int > ptsInfo=NullPtsInfoMap)
Definition: PtsField.h:105
void setProgressCallback(FuncPointerT func, ObjectPointerT obj)
Definition: PtsField.h:201
double NekDouble
Array< OneD, NekDouble > m_coords
Definition: PtsField.h:78
bool operator<(const BasisKey &lhs, const BasisKey &rhs)
Definition: Basis.cpp:49
static PtsFieldSharedPtr NullPtsField
Definition: PtsField.h:263
static map< PtsInfo, int > NullPtsInfoMap
Definition: PtsField.h:71
vector< NekDouble > m_boxSize
vector of box size xmin,xmax,ymin,ymax,zmin,zmax
Definition: PtsField.h:237
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:118
boost::function< void(const int position, const int goal)> m_progressCallback
Definition: PtsField.h:239