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
45{
46namespace SolverUtils
47{
48
49class CouplingCwipi;
50
51class CouplingCwipi : public Coupling
52{
53
54public:
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
91protected:
93
95
97
100
103
106
109
112 double *m_points;
113 double *m_coords;
118
119 std::map<int, int> m_vertMap;
120
121 std::shared_ptr<
124
125 std::shared_ptr<
128
129 SOLVER_UTILS_EXPORT virtual void v_Init() override;
130
131 SOLVER_UTILS_EXPORT virtual void v_Send(
132 const int step, const NekDouble time,
133 const Array<OneD, const Array<OneD, NekDouble>> &field,
134 std::vector<std::string> &varNames) override;
135
136 SOLVER_UTILS_EXPORT virtual void v_Receive(
137 const int step, const NekDouble time,
139 std::vector<std::string> &varNames) override;
140
141 SOLVER_UTILS_EXPORT virtual void v_Finalize() override;
142
143 SOLVER_UTILS_EXPORT NekDouble GetSendField(const int i, const int j) const
144 {
145 return m_sendField[i][j];
146 }
147
148private:
150
151 void SetupReceive();
152
153 void SetupSend();
154
155 void SendComplete();
156
157 void ReceiveStart();
158
159 void ReceiveCwipi(const int step, const NekDouble time,
161
163 Array<OneD, Array<OneD, NekDouble>> distCoords);
164
166
167 void AnnounceMesh();
168
169 void DumpRawFields(const NekDouble time,
171
173 Array<OneD, int> &notLoc);
174
175 template <typename T>
176 void AddElementsToMesh(T geom, int &coordsPos, int &connecPos,
177 int &conidxPos);
178};
179
180typedef std::function<void(Array<OneD, Array<OneD, NekDouble>> &interpField,
181 Array<OneD, Array<OneD, NekDouble>> &distCoords)>
183
184static std::map<std::string, SendCallbackType> SendCallbackMap;
185} // namespace SolverUtils
186} // namespace Nektar
187
188#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:98
virtual 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:94
virtual SOLVER_UTILS_EXPORT ~CouplingCwipi()
SOLVER_UTILS_EXPORT CouplingCwipi(MultiRegions::ExpListSharedPtr field)
virtual 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)
virtual SOLVER_UTILS_EXPORT void v_Finalize() override
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_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:96
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:47
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:2
double NekDouble