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
44namespace Nektar::SolverUtils
45{
46
47class CouplingCwipi;
48
49class CouplingCwipi : public Coupling
50{
51
52public:
53 static std::string className;
54
55 /// Creates an instance of this class
57 {
60 p->Init();
61 return p;
62 }
63
65
67
69 Array<OneD, Array<OneD, NekDouble>> &interpField,
70 Array<OneD, Array<OneD, NekDouble>> &distCoords);
71
73 const int entities_dim, const int n_local_vertex,
74 const int n_local_element, const int n_local_polhyedra,
75 const int n_distant_point, const double local_coordinates[],
76 const int local_connectivity_index[], const int local_connectivity[],
77 const int local_polyhedra_face_index[],
78 const int local_polyhedra_cell_to_face_connectivity[],
79 const int local_polyhedra_face_connectivity_index[],
80 const int local_polyhedra_face_connectivity[],
81 const double distant_points_coordinates[],
82 const int distant_points_location[],
83 const float distant_points_distance[],
84 const int distant_points_barycentric_coordinates_index[],
85 const double distant_points_barycentric_coordinates[], const int stride,
86 const cwipi_solver_type_t solver_type, const void *local_field,
87 void *distant_field);
88
89protected:
91
93
95
98
101
104
107
110 double *m_points;
111 double *m_coords;
116
117 std::map<int, int> m_vertMap;
118
119 std::shared_ptr<
122
123 std::shared_ptr<
126
127 SOLVER_UTILS_EXPORT void v_Init() override;
128
130 const int step, const NekDouble time,
131 const Array<OneD, const Array<OneD, NekDouble>> &field,
132 std::vector<std::string> &varNames) override;
133
135 const int step, const NekDouble time,
137 std::vector<std::string> &varNames) override;
138
139 SOLVER_UTILS_EXPORT void v_Finalize() override;
140
141 SOLVER_UTILS_EXPORT NekDouble GetSendField(const int i, const int j) const
142 {
143 return m_sendField[i][j];
144 }
145
146private:
148
149 void SetupReceive();
150
151 void SetupSend();
152
153 void SendComplete();
154
155 void ReceiveStart();
156
157 void ReceiveCwipi(const int step, const NekDouble time,
159
161 Array<OneD, Array<OneD, NekDouble>> distCoords);
162
164
165 void AnnounceMesh();
166
167 void DumpRawFields(const NekDouble time,
169
171 Array<OneD, int> &notLoc);
172
173 template <typename T>
174 void AddElementsToMesh(T geom, int &coordsPos, int &connecPos,
175 int &conidxPos);
176};
177
178typedef std::function<void(Array<OneD, Array<OneD, NekDouble>> &interpField,
179 Array<OneD, Array<OneD, NekDouble>> &distCoords)>
181
182static std::map<std::string, SendCallbackType> SendCallbackMap;
183} // namespace Nektar::SolverUtils
184
185#endif
#define SOLVER_UTILS_EXPORT
A class that contains algorithms for interpolation between pts fields, expansions and different meshe...
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)
Array< OneD, Array< OneD, NekDouble > > m_oldFields
Definition: CouplingCwipi.h:96
SOLVER_UTILS_EXPORT void v_Receive(const int step, const NekDouble time, Array< OneD, Array< OneD, NekDouble > > &field, std::vector< std::string > &varNames) override
void AddElementsToMesh(T geom, int &coordsPos, int &connecPos, int &conidxPos)
Array< OneD, Array< OneD, NekDouble > > m_sendField
Definition: CouplingCwipi.h:92
SOLVER_UTILS_EXPORT CouplingCwipi(MultiRegions::ExpListSharedPtr field)
SOLVER_UTILS_EXPORT void v_Init() override
void ExtrapolateFields(Array< OneD, Array< OneD, NekDouble > > &rVals, Array< OneD, int > &notLoc)
std::shared_ptr< FieldUtils::Interpolator< std::vector< MultiRegions::ExpListSharedPtr > > > m_sendInterpolator
void EvaluateFields(Array< OneD, Array< OneD, NekDouble > > interpField, Array< OneD, Array< OneD, NekDouble > > distCoords)
SOLVER_UTILS_EXPORT void v_Finalize() override
SOLVER_UTILS_EXPORT ~CouplingCwipi() override
static CouplingSharedPtr create(MultiRegions::ExpListSharedPtr field)
Creates an instance of this class.
Definition: CouplingCwipi.h:56
Array< OneD, Array< OneD, NekDouble > > m_newFields
Definition: CouplingCwipi.h:97
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) override
SOLVER_UTILS_EXPORT void SendCallback(Array< OneD, Array< OneD, NekDouble > > &interpField, Array< OneD, Array< OneD, NekDouble > > &distCoords)
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)
std::shared_ptr< FieldUtils::Interpolator< std::vector< MultiRegions::ExpListSharedPtr > > > m_extrapInterpolator
void DumpRawFields(const NekDouble time, Array< OneD, Array< OneD, NekDouble > > rVals)
MultiRegions::ExpListSharedPtr m_recvField
Definition: CouplingCwipi.h:94
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
double NekDouble