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 <memory>
40#include <vector>
41
45
47{
48
50{
58};
59
61{
64};
65
66static std::map<PtsInfo, int> NullPtsInfoMap;
67
69{
70public:
72 const int dim, const Array<OneD, Array<OneD, NekDouble>> &pts);
73
75 const int dim, const std::vector<std::string> fieldnames,
77 std::map<PtsInfo, int> ptsInfo = NullPtsInfoMap)
78 : m_ptsInfo(ptsInfo), m_dim(dim), m_fieldNames(fieldnames), m_pts(pts),
80
82 const int dim, const std::vector<std::string> fieldnames,
84 [[maybe_unused]] const Array<OneD, Array<OneD, float>> &weights,
85 [[maybe_unused]] const Array<OneD, Array<OneD, unsigned int>>
86 &neighInds)
87 : m_ptsInfo(NullPtsInfoMap), m_dim(dim), m_fieldNames(fieldnames),
88 m_pts(pts), m_ptsType(ePtsFile){};
89
91 std::vector<Array<OneD, int>> &conn) const;
92
94 const std::vector<Array<OneD, int>> &conn);
95
96 LIB_UTILITIES_EXPORT void SetDim(const int ptsDim);
97
98 LIB_UTILITIES_EXPORT size_t GetDim() const;
99
100 LIB_UTILITIES_EXPORT size_t GetNFields() const;
101
102 LIB_UTILITIES_EXPORT std::vector<std::string> GetFieldNames() const;
103
104 LIB_UTILITIES_EXPORT std::string GetFieldName(const int i) const;
105
107 const std::vector<std::string> fieldNames);
108
110 const std::string fieldName);
111
112 LIB_UTILITIES_EXPORT void RemoveField(const std::string fieldName);
113
115 const Array<OneD, const Array<OneD, NekDouble>> &pts);
116
117 LIB_UTILITIES_EXPORT size_t GetNpoints() const;
118
119 LIB_UTILITIES_EXPORT NekDouble GetPointVal(const size_t fieldInd,
120 const size_t ptInd) const;
121
122 LIB_UTILITIES_EXPORT void SetPointVal(const size_t fieldInd,
123 const size_t ptInd,
124 const NekDouble val);
125
127 Array<OneD, Array<OneD, NekDouble>> &pts) const;
128
130 const int fieldInd) const;
131
133
134 LIB_UTILITIES_EXPORT void SetPts(const int fldId,
136
137 LIB_UTILITIES_EXPORT std::vector<size_t> GetPointsPerEdge() const;
138
139 LIB_UTILITIES_EXPORT size_t GetPointsPerEdge(const size_t i) const;
140
142 const std::vector<size_t> nPtsPerEdge);
143
145 const std::vector<int> nPtsPerElement);
146
147 LIB_UTILITIES_EXPORT std::vector<int> GetPointsPerElement() const;
148
150
151 LIB_UTILITIES_EXPORT void SetPtsType(const PtsType type);
152
153 LIB_UTILITIES_EXPORT std::vector<NekDouble> GetBoxSize() const;
154
155 LIB_UTILITIES_EXPORT void SetBoxSize(const std::vector<NekDouble> boxsize);
156
157 /// map for information about points that can be added through PtsInfo enum
158 std::map<PtsInfo, int> m_ptsInfo;
159
160private:
161 /// Dimension of the pts field
162 size_t m_dim;
163 /// Names of the field variables
164 std::vector<std::string> m_fieldNames;
165 /// Point data. For a n-dimensional field, the first m_dim fields are the
166 /// points spatial coordinates. Structure: m_pts[fieldIdx][ptIdx]
168 /// Number of points per edge. Empty if the point data has no
169 /// specific shape (ePtsLine) or is a block (ePtsTetBlock,
170 /// ePtsTriBlock), size=1 for ePtsLine and 2 for a ePtsPlane
171 std::vector<size_t> m_nPtsPerEdge;
172 std::vector<int> m_nPtsPerElement;
173 /// Connectivity data needed for ePtsTetBlock and ePtsTriBlock. For n
174 /// Blocks with m elements each, m_ptsConn is a vector of n arrays with
175 /// 3*m (ePtsTriBlock) or 4*m (ePtsTetBlock) entries.
176 std::vector<Array<OneD, int>> m_ptsConn;
177 /// Type of the PtsField
179
180 /// vector of box size xmin,xmax,ymin,ymax,zmin,zmax
181 std::vector<NekDouble> m_boxSize;
182};
183
184typedef std::shared_ptr<PtsField> PtsFieldSharedPtr;
186} // namespace Nektar::LibUtilities
187
188#endif
#define LIB_UTILITIES_EXPORT
std::vector< int > GetPointsPerElement() const
Definition: PtsField.cpp:244
void SetBoxSize(const std::vector< NekDouble > boxsize)
Definition: PtsField.cpp:269
NekDouble GetPointVal(const size_t fieldInd, const size_t ptInd) const
Definition: PtsField.cpp:183
std::vector< std::string > GetFieldNames() const
Definition: PtsField.cpp:98
std::vector< size_t > GetPointsPerEdge() const
Definition: PtsField.cpp:218
void SetFieldNames(const std::vector< std::string > fieldNames)
Definition: PtsField.cpp:108
std::vector< Array< OneD, int > > m_ptsConn
Connectivity data needed for ePtsTetBlock and ePtsTriBlock. For n Blocks with m elements each,...
Definition: PtsField.h:176
void SetPointVal(const size_t fieldInd, const size_t ptInd, const NekDouble val)
Definition: PtsField.cpp:188
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:74
void SetDim(const int ptsDim)
Definition: PtsField.cpp:83
PtsField(const int dim, const Array< OneD, Array< OneD, NekDouble > > &pts)
Definition: PtsField.cpp:43
std::vector< NekDouble > GetBoxSize() const
Definition: PtsField.cpp:264
size_t m_dim
Dimension of the pts field.
Definition: PtsField.h:162
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:171
std::vector< int > m_nPtsPerElement
Definition: PtsField.h:172
std::string GetFieldName(const int i) const
Definition: PtsField.cpp:103
void SetPointsPerElement(const std::vector< int > nPtsPerElement)
Definition: PtsField.cpp:249
void GetConnectivity(std::vector< Array< OneD, int > > &conn) const
Set the connectivity data for ePtsTetBlock and ePtsTriBlock.
Definition: PtsField.cpp:61
PtsType m_ptsType
Type of the PtsField.
Definition: PtsField.h:178
std::vector< std::string > m_fieldNames
Names of the field variables.
Definition: PtsField.h:164
std::vector< NekDouble > m_boxSize
vector of box size xmin,xmax,ymin,ymax,zmin,zmax
Definition: PtsField.h:181
void SetPts(Array< OneD, Array< OneD, NekDouble > > &pts)
Definition: PtsField.cpp:204
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:167
void SetConnectivity(const std::vector< Array< OneD, int > > &conn)
Get the connectivity data for ePtsTetBlock and ePtsTriBlock.
Definition: PtsField.cpp:74
std::map< PtsInfo, int > m_ptsInfo
map for information about points that can be added through PtsInfo enum
Definition: PtsField.h:158
void RemoveField(const std::string fieldName)
Definition: PtsField.cpp:137
void SetPointsPerEdge(const std::vector< size_t > nPtsPerEdge)
Set the number of points per edge.
Definition: PtsField.cpp:235
void SetPtsType(const PtsType type)
Definition: PtsField.cpp:259
void AddPoints(const Array< OneD, const Array< OneD, NekDouble > > &pts)
Definition: PtsField.cpp:158
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:81
void GetPts(Array< OneD, Array< OneD, NekDouble > > &pts) const
Definition: PtsField.cpp:194
void AddField(const Array< OneD, NekDouble > &pts, const std::string fieldName)
Definition: PtsField.cpp:117
static std::map< PtsInfo, int > NullPtsInfoMap
Definition: PtsField.h:66
std::shared_ptr< PtsField > PtsFieldSharedPtr
Definition: PtsField.h:184
static PtsFieldSharedPtr NullPtsField
Definition: PtsField.h:185
double NekDouble