Nektar++
Loading...
Searching...
No Matches
EvaluatePoints.h
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: EvaluatePoints.h
4//
5// For more information, please see: http://www.nektar.info
6//
7// The MIT License
8//
9// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10// Department of Aeronautics, Imperial College London (UK), and Scientific
11// Computing and Imaging Institute, University of Utah (USA).
12//
13// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description: base class for physics evaluation.
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#ifndef NEKTAR_SOLVERUTILS_FILTERS_EVALUATEPOINTS_H
36#define NEKTAR_SOLVERUTILS_FILTERS_EVALUATEPOINTS_H
37
44
46
47namespace Nektar::SolverUtils
48{
49
50class MobilePoint;
51class EvaluatePoints;
52class StationaryPoints;
53
54typedef std::shared_ptr<MobilePoint> MobilePointSharedPtr;
55typedef std::shared_ptr<StationaryPoints> StationaryPointsSharedPtr;
56
58{
59public:
60 virtual ~StationaryPoints() = default;
62 std::string filename, bool verbose,
63 std::map<std::string, NekDouble> &params)
64 {
65 v_OutputData(filename, verbose, params);
66 }
71 inline void ReSize(int Np)
72 {
73 v_ReSize(Np);
74 }
75 inline void AssignPoint(int id, int pid,
76 const Array<OneD, NekDouble> &gcoords)
77 {
78 v_AssignPoint(id, pid, gcoords);
79 }
80 inline void GetCoordsByPID(int pid, Array<OneD, NekDouble> &gcoords)
81 {
82 v_GetCoords(GlobalToLocal(pid), gcoords);
83 }
84 inline void SetCoordsByPID(int pid, const Array<OneD, NekDouble> &gcoords)
85 {
86 v_SetCoords(GlobalToLocal(pid), gcoords);
87 }
88 inline void GetPhysicsByPID(int pid, Array<OneD, NekDouble> &data)
89 {
90 v_GetPhysics(GlobalToLocal(pid), data);
91 }
92 inline void SetPhysicsByPID(int pid, const Array<OneD, NekDouble> &data)
93 {
94 v_SetPhysics(GlobalToLocal(pid), data);
95 }
96 inline void GetCoords(int pid, Array<OneD, NekDouble> &gcoords)
97 {
98 v_GetCoords(pid, gcoords);
99 }
100 inline void SetCoords(int pid, const Array<OneD, NekDouble> &gcoords)
101 {
102 v_SetCoords(pid, gcoords);
103 }
104 inline void GetPhysics(int pid, Array<OneD, NekDouble> &data)
105 {
106 v_GetPhysics(pid, data);
107 }
108 inline void SetPhysics(int pid, const Array<OneD, NekDouble> &data)
109 {
110 v_SetPhysics(pid, data);
111 }
112 inline void TimeAdvance(int order)
113 {
114 v_TimeAdvance(order);
115 }
116 inline int GetTotPoints()
117 {
118 return m_totPts;
119 }
120 inline int GetDim()
121 {
122 return m_dim;
123 }
124 inline int LocalToGlobal(int id)
125 {
126 return m_localIDToGlobal[id];
127 }
128 inline int GlobalToLocal(int id)
129 {
130 return m_globalIDToLocal[id];
131 }
132
133protected:
134 virtual void v_OutputData(std::string filename, bool verbose,
135 std::map<std::string, NekDouble> &params) = 0;
136 virtual void v_OutputError() = 0;
137 virtual void v_TimeAdvance(int order) = 0;
138 virtual void v_GetCoords(int pid, Array<OneD, NekDouble> &gcoords) = 0;
139 virtual void v_SetCoords(int pid,
140 const Array<OneD, NekDouble> &gcoords) = 0;
141 virtual void v_GetPhysics(int pid, Array<OneD, NekDouble> &data) = 0;
142 virtual void v_SetPhysics(int pid, const Array<OneD, NekDouble> &data) = 0;
143 virtual void v_ReSize(int Np) = 0;
144 virtual void v_AssignPoint(int id, int pid,
145 const Array<OneD, NekDouble> &gcoords);
146 int m_dim;
148 std::map<int, int> m_localIDToGlobal; // size should be m_totPts
149 std::map<int, int> m_globalIDToLocal; // size should be m_totPts
150};
151
153{
154public:
155 friend class MemoryManager<MobilePoint>;
158 int m_eId;
161
162 /// Creates an instance of this class
163 static MobilePointSharedPtr create(int dim, int sRank,
164 const Array<OneD, NekDouble> global)
165 {
168 return p;
169 }
170
171 MobilePoint(int dim, int sRank, const Array<OneD, NekDouble> global)
172 : m_sRank(sRank)
173 {
175 Vmath::Vcopy(dim, global, 1, m_global, 1);
177 }
178
179 void SetLocalCoords(int eId, const Array<OneD, NekDouble> &local)
180 {
181 m_eId = eId;
182 Vmath::Vcopy(m_local.size(), local, 1, m_local, 1);
183 }
184
186 {
187 Vmath::Vcopy(m_global.size(), global, 1, m_global, 1);
188 }
189
190 void SetData(int nPhys, const Array<OneD, NekDouble> data)
191 {
192 if (m_data.size() < nPhys)
193 {
195 }
196 Vmath::Vcopy(nPhys, data, 1, m_data, 1);
197 }
198
200 {
201 return m_data;
202 }
203
205 {
206 return m_global;
207 }
208
210 {
211 return m_local;
212 }
213};
214
216{
217public:
219 virtual ~EvaluatePoints();
223 const MultiRegions::ExpListSharedPtr &pField,
224 std::vector<Array<OneD, NekDouble>> &PhysicsData, NekDouble time);
226 std::map<int, std::set<int>> &callbackUpdateMobCoords);
228 std::map<int, std::set<int>> &callbackUpdateMobCoords);
233 const NekDouble &time, std::vector<std::string> &defaultValues);
235
236protected:
238 std::map<int, Array<OneD, NekDouble>> &globalCoords);
239 void GatherMobilePhysics(std::map<int, Array<OneD, NekDouble>> &revData);
242 std::set<int> &notfound);
245 std::set<int> &notfound);
246 void SyncColumnComm();
248 const NekDouble time);
249 void Pack2Int(const int &a, const int &b, double &d);
250 void unPack2Int(int &a, int &b, const double &d);
251 void Pack3Int(const int &a, const int &b, const int &c, double &d);
252 void unPack3Int(int &a, int &b, int &c, const double &d);
253 void Pack2Short(const int &a, const int &b, int &c);
254 void unPack2Short(int &a, int &b, const int &c);
255 virtual void v_ModifyVelocity(Array<OneD, NekDouble> gcoords,
265 std::map<int, MobilePointSharedPtr> m_mobilePts;
266 std::map<int, LibUtilities::EquationSharedPtr> m_defaultValueFunction;
267 // m_recvMobInfo[t] = n, in the current stationary pts, there are n mobile
268 // points from thread t; all threads; global
269 // m_recvStatInfo[t] = n, in the
270 // current mobile pts, there are n stationary points from thread t;
271 // m_columnRank == 0 only; local
272 std::map<int, int> m_recvMobInfo;
273 std::map<int, int> m_recvStatInfo;
274};
275
276} // namespace Nektar::SolverUtils
277
278#endif /* NEKTAR_SOLVERUTILS_FILTERS_EVALUATEPOINTS_H */
#define SOLVER_UTILS_EXPORT
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
void PartitionLocalPoints(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, std::set< int > &notfound)
SOLVER_UTILS_EXPORT void EvaluateMobilePhys(const MultiRegions::ExpListSharedPtr &pField, std::vector< Array< OneD, NekDouble > > &PhysicsData, NekDouble time)
SOLVER_UTILS_EXPORT void Initialise(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time, std::vector< std::string > &defaultValues)
NekDouble GetDefaultValue(const int i, const Array< OneD, const NekDouble > x, const NekDouble time)
SOLVER_UTILS_EXPORT void PassMobilePhysToStatic(std::map< int, std::set< int > > &callbackUpdateMobCoords)
void Pack2Int(const int &a, const int &b, double &d)
SOLVER_UTILS_EXPORT void PartitionMobilePts(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields)
void unPack2Short(int &a, int &b, const int &c)
SOLVER_UTILS_EXPORT void SetUpCommInfo()
SOLVER_UTILS_EXPORT void CopyMobilePtsToStatic()
SOLVER_UTILS_EXPORT void CopyStaticPtsToMobile()
void Pack2Short(const int &a, const int &b, int &c)
StationaryPointsSharedPtr m_staticPts
virtual void v_ModifyVelocity(Array< OneD, NekDouble > gcoords, NekDouble time, Array< OneD, NekDouble > vel)
void PartitionExchangeNonlocalPoints(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, std::set< int > &notfound)
void GatherMobilePhysics(std::map< int, Array< OneD, NekDouble > > &revData)
void Pack3Int(const int &a, const int &b, const int &c, double &d)
void unPack2Int(int &a, int &b, const double &d)
void UpdateMobileCoords(std::map< int, Array< OneD, NekDouble > > &globalCoords)
std::map< int, MobilePointSharedPtr > m_mobilePts
LibUtilities::CommSharedPtr m_comm
std::map< int, LibUtilities::EquationSharedPtr > m_defaultValueFunction
SOLVER_UTILS_EXPORT void PassStaticCoordsToMobile(std::map< int, std::set< int > > &callbackUpdateMobCoords)
void unPack3Int(int &a, int &b, int &c, const double &d)
Array< OneD, NekDouble > m_data
Array< OneD, NekDouble > m_global
static MobilePointSharedPtr create(int dim, int sRank, const Array< OneD, NekDouble > global)
Creates an instance of this class.
void SetLocalCoords(int eId, const Array< OneD, NekDouble > &local)
MobilePoint(int dim, int sRank, const Array< OneD, NekDouble > global)
Array< OneD, NekDouble > GetData()
Array< OneD, NekDouble > m_local
Array< OneD, NekDouble > GetLocalCoords()
void SetGlobalCoords(const Array< OneD, NekDouble > &global)
Array< OneD, NekDouble > GetGlobalCoords()
void SetData(int nPhys, const Array< OneD, NekDouble > data)
void SetCoordsByPID(int pid, const Array< OneD, NekDouble > &gcoords)
void GetCoordsByPID(int pid, Array< OneD, NekDouble > &gcoords)
virtual void v_GetPhysics(int pid, Array< OneD, NekDouble > &data)=0
virtual void v_SetPhysics(int pid, const Array< OneD, NekDouble > &data)=0
void GetPhysicsByPID(int pid, Array< OneD, NekDouble > &data)
void SetPhysics(int pid, const Array< OneD, NekDouble > &data)
virtual void v_SetCoords(int pid, const Array< OneD, NekDouble > &gcoords)=0
virtual void v_TimeAdvance(int order)=0
void AssignPoint(int id, int pid, const Array< OneD, NekDouble > &gcoords)
SOLVER_UTILS_EXPORT void OutputData(std::string filename, bool verbose, std::map< std::string, NekDouble > &params)
void SetPhysicsByPID(int pid, const Array< OneD, NekDouble > &data)
SOLVER_UTILS_EXPORT void OutputError()
void GetPhysics(int pid, Array< OneD, NekDouble > &data)
virtual void v_GetCoords(int pid, Array< OneD, NekDouble > &gcoords)=0
virtual void v_OutputData(std::string filename, bool verbose, std::map< std::string, NekDouble > &params)=0
void GetCoords(int pid, Array< OneD, NekDouble > &gcoords)
void SetCoords(int pid, const Array< OneD, NekDouble > &gcoords)
virtual void v_AssignPoint(int id, int pid, const Array< OneD, NekDouble > &gcoords)
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition Comm.h:55
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::shared_ptr< StationaryPoints > StationaryPointsSharedPtr
std::shared_ptr< MobilePoint > MobilePointSharedPtr
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition Vmath.hpp:825