Nektar++
CouplingCwipi.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File CouplingCwipi.h
4 //
5 // For more information, please see: http://www.nektar.info
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2017 Kilian Lackhove
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining a
12 // copy of this software and associated documentation files (the "Software"),
13 // to deal in the Software without restriction, including without limitation
14 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 // and/or sell copies of the Software, and to permit persons to whom the
16 // Software is furnished to do so, subject to the following conditions:
17 //
18 // The above copyright notice and this permission notice shall be included
19 // in all copies or substantial portions of the Software.
20 //
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 // DEALINGS IN THE SOFTWARE.
28 //
29 // Description: CWIPI Coupling class
30 //
31 ///////////////////////////////////////////////////////////////////////////////
32 
33 #ifndef NEKTAR_COUPLINGCWIPI
34 #define NEKTAR_COUPLINGCWIPI
35 
37 
39 
40 #include <cwipi.h>
41 
42 #include <functional>
43 
44 namespace Nektar
45 {
46 namespace SolverUtils
47 {
48 
49 class CouplingCwipi;
50 
51 class CouplingCwipi : public Coupling
52 {
53 
54 public:
55  static std::string className;
56 
57  /// Creates an instance of this class
59  {
62  p->Init();
63  return p;
64  }
65 
67 
69 
71  Array<OneD, Array<OneD, NekDouble>> &interpField,
72  Array<OneD, Array<OneD, NekDouble>> &distCoords);
73 
75  const int entities_dim, const int n_local_vertex,
76  const int n_local_element, const int n_local_polhyedra,
77  const int n_distant_point, const double local_coordinates[],
78  const int local_connectivity_index[], const int local_connectivity[],
79  const int local_polyhedra_face_index[],
80  const int local_polyhedra_cell_to_face_connectivity[],
81  const int local_polyhedra_face_connectivity_index[],
82  const int local_polyhedra_face_connectivity[],
83  const double distant_points_coordinates[],
84  const int distant_points_location[],
85  const float distant_points_distance[],
86  const int distant_points_barycentric_coordinates_index[],
87  const double distant_points_barycentric_coordinates[], const int stride,
88  const cwipi_solver_type_t solver_type, const void *local_field,
89  void *distant_field);
90 
91 protected:
93 
95 
97 
100 
103 
106 
109 
112  double *m_points;
113  double *m_coords;
115  int *m_connec;
116  double *m_rValsInterl;
117  double *m_sValsInterl;
118 
119  std::map<int, int> m_vertMap;
120 
122 
124 
125  SOLVER_UTILS_EXPORT virtual void v_Init();
126 
127  SOLVER_UTILS_EXPORT virtual void v_Send(
128  const int step, const NekDouble time,
129  const Array<OneD, const Array<OneD, NekDouble>> &field,
130  std::vector<std::string> &varNames);
131 
132  SOLVER_UTILS_EXPORT virtual void v_Receive(
133  const int step, const NekDouble time,
135  std::vector<std::string> &varNames);
136 
137  SOLVER_UTILS_EXPORT virtual void v_Finalize();
138 
139  SOLVER_UTILS_EXPORT NekDouble GetSendField(const int i, const int j) const
140  {
141  return m_sendField[i][j];
142  }
143 
144 private:
146 
147  void SetupReceive();
148 
149  void SetupSend();
150 
151  void SendComplete();
152 
153  void ReceiveStart();
154 
155  void ReceiveCwipi(const int step, const NekDouble time,
157 
158  void EvaluateFields(Array<OneD, Array<OneD, NekDouble>> interpField,
159  Array<OneD, Array<OneD, NekDouble>> distCoords);
160 
161  void SetupSendInterpolation();
162 
163  void AnnounceMesh();
164 
165  void DumpRawFields(const NekDouble time,
167 
169  Array<OneD, int> &notLoc);
170 
171  template <typename T>
172  void AddElementsToMesh(T geom, int &coordsPos, int &connecPos,
173  int &conidxPos);
174 };
175 
176 typedef std::function<void(Array<OneD, Array<OneD, NekDouble>> &interpField,
177  Array<OneD, Array<OneD, NekDouble>> &distCoords)>
179 
180 static std::map<std::string, SendCallbackType> SendCallbackMap;
181 } // namespace SolverUtils
182 } // namespace Nektar
183 
184 #endif
#define SOLVER_UTILS_EXPORT
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
static SOLVER_UTILS_EXPORT void InterpCallback(const int entities_dim, const int n_local_vertex, const int n_local_element, const int n_local_polhyedra, const int n_distant_point, const double local_coordinates[], const int local_connectivity_index[], const int local_connectivity[], const int local_polyhedra_face_index[], const int local_polyhedra_cell_to_face_connectivity[], const int local_polyhedra_face_connectivity_index[], const int local_polyhedra_face_connectivity[], const double distant_points_coordinates[], const int distant_points_location[], const float distant_points_distance[], const int distant_points_barycentric_coordinates_index[], const double distant_points_barycentric_coordinates[], const int stride, const cwipi_solver_type_t solver_type, const void *local_field, void *distant_field)
virtual SOLVER_UTILS_EXPORT void v_Finalize()
Array< OneD, Array< OneD, NekDouble > > m_oldFields
Definition: CouplingCwipi.h:98
FieldUtils::InterpolatorSharedPtr m_extrapInterpolator
FieldUtils::InterpolatorSharedPtr m_sendInterpolator
void AddElementsToMesh(T geom, int &coordsPos, int &connecPos, int &conidxPos)
virtual SOLVER_UTILS_EXPORT void v_Send(const int step, const NekDouble time, const Array< OneD, const Array< OneD, NekDouble >> &field, std::vector< std::string > &varNames)
Array< OneD, Array< OneD, NekDouble > > m_sendField
Definition: CouplingCwipi.h:94
virtual SOLVER_UTILS_EXPORT ~CouplingCwipi()
SOLVER_UTILS_EXPORT CouplingCwipi(MultiRegions::ExpListSharedPtr field)
void EvaluateFields(Array< OneD, Array< OneD, NekDouble >> interpField, Array< OneD, Array< OneD, NekDouble >> distCoords)
void ExtrapolateFields(Array< OneD, Array< OneD, NekDouble >> &rVals, Array< OneD, int > &notLoc)
virtual SOLVER_UTILS_EXPORT void v_Init()
SOLVER_UTILS_EXPORT void SendCallback(Array< OneD, Array< OneD, NekDouble >> &interpField, Array< OneD, Array< OneD, NekDouble >> &distCoords)
static CouplingSharedPtr create(MultiRegions::ExpListSharedPtr field)
Creates an instance of this class.
Definition: CouplingCwipi.h:58
Array< OneD, Array< OneD, NekDouble > > m_newFields
Definition: CouplingCwipi.h:99
virtual SOLVER_UTILS_EXPORT void v_Receive(const int step, const NekDouble time, Array< OneD, Array< OneD, NekDouble >> &field, std::vector< std::string > &varNames)
void DumpRawFields(const NekDouble time, Array< OneD, Array< OneD, NekDouble >> rVals)
SOLVER_UTILS_EXPORT NekDouble GetSendField(const int i, const int j) const
void ReadConfig(LibUtilities::SessionReaderSharedPtr session)
void ReceiveCwipi(const int step, const NekDouble time, Array< OneD, Array< OneD, NekDouble >> &field)
MultiRegions::ExpListSharedPtr m_recvField
Definition: CouplingCwipi.h:96
std::shared_ptr< Interpolator > InterpolatorSharedPtr
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
static std::map< std::string, SendCallbackType > SendCallbackMap
SOLVER_UTILS_EXPORT typedef std::shared_ptr< Coupling > CouplingSharedPtr
Definition: Coupling.h:45
std::function< void(Array< OneD, Array< OneD, NekDouble >> &interpField, Array< OneD, Array< OneD, NekDouble >> &distCoords)> SendCallbackType
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
double NekDouble