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,
76  const int n_local_vertex,
77  const int n_local_element,
78  const int n_local_polhyedra,
79  const int n_distant_point,
80  const double local_coordinates[],
81  const int local_connectivity_index[],
82  const int local_connectivity[],
83  const int local_polyhedra_face_index[],
84  const int local_polyhedra_cell_to_face_connectivity[],
85  const int local_polyhedra_face_connectivity_index[],
86  const int local_polyhedra_face_connectivity[],
87  const double distant_points_coordinates[],
88  const int distant_points_location[],
89  const float distant_points_distance[],
90  const int distant_points_barycentric_coordinates_index[],
91  const double distant_points_barycentric_coordinates[],
92  const int stride,
93  const cwipi_solver_type_t solver_type,
94  const void *local_field,
95  void *distant_field);
96 
97 protected:
99 
101 
103 
106 
109 
112 
115 
118  double *m_points;
119  double *m_coords;
121  int *m_connec;
122  double *m_rValsInterl;
123  double *m_sValsInterl;
124 
125  std::map<int, int> m_vertMap;
126 
128 
130 
131  SOLVER_UTILS_EXPORT virtual void v_Init();
132 
133  SOLVER_UTILS_EXPORT virtual void v_Send(
134  const int step,
135  const NekDouble time,
136  const Array<OneD, const Array<OneD, NekDouble> > &field,
137  std::vector<std::string> &varNames);
138 
139  SOLVER_UTILS_EXPORT virtual void v_Receive(
140  const int step,
141  const NekDouble time,
143  std::vector<std::string> &varNames);
144 
145  SOLVER_UTILS_EXPORT virtual void v_Finalize();
146 
148  const int j) const
149  {
150  return m_sendField[i][j];
151  }
152 
153 private:
155 
156  void SetupReceive();
157 
158  void SetupSend();
159 
160  void SendComplete();
161 
162  void ReceiveStart();
163 
164  void ReceiveCwipi(const int step,
165  const NekDouble time,
166  Array<OneD, Array<OneD, NekDouble> > &field);
167 
168  void EvaluateFields(Array<OneD, Array<OneD, NekDouble> > interpField,
169  Array<OneD, Array<OneD, NekDouble> > distCoords);
170 
171  void SetupSendInterpolation();
172 
173  void AnnounceMesh();
174 
175  void DumpRawFields(const NekDouble time,
177 
179  Array<OneD, int> &notLoc);
180 
181  template <typename T>
182  void AddElementsToMesh(T geom,
183  int &coordsPos,
184  int &connecPos,
185  int &conidxPos);
186 };
187 
188 typedef std::function<void(Array<OneD, Array<OneD, NekDouble> > &interpField,
189  Array<OneD, Array<OneD, NekDouble> > &distCoords)>
191 
192 static std::map<std::string, SendCallbackType> SendCallbackMap;
193 }
194 }
195 
196 #endif
void ReceiveCwipi(const int step, const NekDouble time, Array< OneD, Array< OneD, NekDouble > > &field)
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
SOLVER_UTILS_EXPORT NekDouble GetSendField(const int i, const int j) const
Array< OneD, Array< OneD, NekDouble > > m_newFields
static CouplingSharedPtr create(MultiRegions::ExpListSharedPtr field)
Creates an instance of this class.
Definition: CouplingCwipi.h:58
static std::map< std::string, SendCallbackType > SendCallbackMap
SOLVER_UTILS_EXPORT CouplingCwipi(MultiRegions::ExpListSharedPtr field)
FieldUtils::InterpolatorSharedPtr m_sendInterpolator
std::shared_ptr< Interpolator > InterpolatorSharedPtr
void AddElementsToMesh(T geom, int &coordsPos, int &connecPos, int &conidxPos)
void ExtrapolateFields(Array< OneD, Array< OneD, NekDouble > > &rVals, Array< OneD, int > &notLoc)
virtual SOLVER_UTILS_EXPORT ~CouplingCwipi()
void EvaluateFields(Array< OneD, Array< OneD, NekDouble > > interpField, Array< OneD, Array< OneD, NekDouble > > distCoords)
Array< OneD, Array< OneD, NekDouble > > m_oldFields
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)
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
double NekDouble
FieldUtils::InterpolatorSharedPtr m_extrapInterpolator
SOLVER_UTILS_EXPORT typedef std::shared_ptr< Coupling > CouplingSharedPtr
Definition: Coupling.h:45
MultiRegions::ExpListSharedPtr m_recvField
virtual SOLVER_UTILS_EXPORT void v_Finalize()
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)
virtual SOLVER_UTILS_EXPORT void v_Init()
virtual SOLVER_UTILS_EXPORT void v_Receive(const int step, const NekDouble time, Array< OneD, Array< OneD, NekDouble > > &field, std::vector< std::string > &varNames)
#define SOLVER_UTILS_EXPORT
Array< OneD, Array< OneD, NekDouble > > m_sendField
std::function< void(Array< OneD, Array< OneD, NekDouble > > &interpField, Array< OneD, Array< OneD, NekDouble > > &distCoords)> SendCallbackType
void ReadConfig(LibUtilities::SessionReaderSharedPtr session)
SOLVER_UTILS_EXPORT void SendCallback(Array< OneD, Array< OneD, NekDouble > > &interpField, Array< OneD, Array< OneD, NekDouble > > &distCoords)
void DumpRawFields(const NekDouble time, Array< OneD, Array< OneD, NekDouble > > rVals)
std::shared_ptr< SessionReader > SessionReaderSharedPtr