Nektar++
Coupling.h
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: Coupling.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: Coupling class
30//
31///////////////////////////////////////////////////////////////////////////////
32
33#ifndef NEKTAR_COUPLING
34#define NEKTAR_COUPLING
35
39
40namespace Nektar::SolverUtils
41{
42
43class Coupling;
44
45SOLVER_UTILS_EXPORT typedef std::shared_ptr<Coupling> CouplingSharedPtr;
46
47/// Declaration of the Coupling factory
51
52/// Declaration of the Coupling factory singleton
54
56{
57
58public:
59 typedef std::map<std::string, std::string> CouplingConfigMap;
60
62 {
63 v_Init();
64 }
65
66 SOLVER_UTILS_EXPORT inline const std::map<std::string, std::string> GetConfig()
67 {
68 return m_config;
69 }
70
71 SOLVER_UTILS_EXPORT inline std::vector<std::string> GetSendFieldNames()
72 {
73 return m_sendFieldNames;
74 }
75
76 SOLVER_UTILS_EXPORT inline std::vector<std::string> GetRecvFieldNames()
77 {
78 return m_recvFieldNames;
79 }
80
82 {
83 v_Finalize();
84 }
85
87 const int step, const NekDouble time,
89 std::vector<std::string> &varNames)
90 {
91 v_Send(step, time, field, varNames);
92 }
93
95 const int step, const NekDouble time,
97 std::vector<std::string> &varNames)
98 {
99 v_Receive(step, time, field, varNames);
100 }
101
102protected:
103 std::string m_couplingName;
104
106
108
110 std::vector<std::string> m_sendFieldNames;
112
114 std::vector<std::string> m_recvFieldNames;
116
118
119 SOLVER_UTILS_EXPORT virtual ~Coupling() = default;
120
121 SOLVER_UTILS_EXPORT virtual void v_Init();
122
124 const int step, const NekDouble time,
125 const Array<OneD, const Array<OneD, NekDouble>> &field,
126 std::vector<std::string> &varNames) = 0;
127
129 const int step, const NekDouble time,
131 std::vector<std::string> &varNames) = 0;
132
134 {
135 }
136
138 std::vector<std::string> &vars, std::vector<std::string> &transVars);
139};
140} // namespace Nektar::SolverUtils
141
142#endif
#define SOLVER_UTILS_EXPORT
Provides a generic Factory class.
virtual SOLVER_UTILS_EXPORT void v_Init()
Definition: Coupling.cpp:57
SOLVER_UTILS_EXPORT void Finalize()
Definition: Coupling.h:81
SOLVER_UTILS_EXPORT void Receive(const int step, const NekDouble time, Array< OneD, Array< OneD, NekDouble > > &field, std::vector< std::string > &varNames)
Definition: Coupling.h:94
MultiRegions::ExpListSharedPtr m_evalField
Definition: Coupling.h:107
SOLVER_UTILS_EXPORT const std::map< std::string, std::string > GetConfig()
Definition: Coupling.h:66
SOLVER_UTILS_EXPORT void Init()
Definition: Coupling.h:61
std::vector< std::string > m_sendFieldNames
Definition: Coupling.h:110
std::map< std::string, std::string > CouplingConfigMap
Definition: Coupling.h:59
virtual SOLVER_UTILS_EXPORT void v_Finalize()
Definition: Coupling.h:133
SOLVER_UTILS_EXPORT std::vector< std::string > GetRecvFieldNames()
Definition: Coupling.h:76
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)=0
CouplingConfigMap m_config
Definition: Coupling.h:105
std::vector< std::string > m_recvFieldNames
Definition: Coupling.h:114
virtual SOLVER_UTILS_EXPORT ~Coupling()=default
SOLVER_UTILS_EXPORT Coupling(MultiRegions::ExpListSharedPtr field)
Definition: Coupling.cpp:46
SOLVER_UTILS_EXPORT std::vector< std::string > GetSendFieldNames()
Definition: Coupling.h:71
SOLVER_UTILS_EXPORT void Send(const int step, const NekDouble time, const Array< OneD, const Array< OneD, NekDouble > > &field, std::vector< std::string > &varNames)
Definition: Coupling.h:86
virtual SOLVER_UTILS_EXPORT void v_Receive(const int step, const NekDouble time, Array< OneD, Array< OneD, NekDouble > > &field, std::vector< std::string > &varNames)=0
SOLVER_UTILS_EXPORT std::vector< int > GenerateVariableMapping(std::vector< std::string > &vars, std::vector< std::string > &transVars)
Definition: Coupling.cpp:131
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
SOLVER_UTILS_EXPORT typedef LibUtilities::NekFactory< std::string, Coupling, MultiRegions::ExpListSharedPtr > CouplingFactory
Declaration of the Coupling factory.
Definition: Coupling.h:50
SOLVER_UTILS_EXPORT typedef std::shared_ptr< Coupling > CouplingSharedPtr
Definition: Coupling.h:45
CouplingFactory & GetCouplingFactory()
Declaration of the Coupling factory singleton.
Definition: Coupling.cpp:40
double NekDouble