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 }
64
66 {
67 v_Init();
68 }
69
70 SOLVER_UTILS_EXPORT inline const std::map<std::string, std::string> GetConfig()
71 {
72 return m_config;
73 }
74
75 SOLVER_UTILS_EXPORT inline std::vector<std::string> GetSendFieldNames()
76 {
77 return m_sendFieldNames;
78 }
79
80 SOLVER_UTILS_EXPORT inline std::vector<std::string> GetRecvFieldNames()
81 {
82 return m_recvFieldNames;
83 }
84
86 {
87 v_Finalize();
88 }
89
91 const int step, const NekDouble time,
92 const Array<OneD, const Array<OneD, NekDouble>> &field,
93 std::vector<std::string> &varNames)
94 {
95 v_Send(step, time, field, varNames);
96 }
97
99 const int step, const NekDouble time,
101 std::vector<std::string> &varNames)
102 {
103 v_Receive(step, time, field, varNames);
104 }
105
106protected:
107 std::string m_couplingName;
108
110
112
114 std::vector<std::string> m_sendFieldNames;
116
118 std::vector<std::string> m_recvFieldNames;
120
122
123 SOLVER_UTILS_EXPORT virtual void v_Init();
124
126 const int step, const NekDouble time,
127 const Array<OneD, const Array<OneD, NekDouble>> &field,
128 std::vector<std::string> &varNames) = 0;
129
131 const int step, const NekDouble time,
133 std::vector<std::string> &varNames) = 0;
134
136 {
137 }
138
140 std::vector<std::string> &vars, std::vector<std::string> &transVars);
141};
142} // namespace Nektar::SolverUtils
143
144#endif
#define SOLVER_UTILS_EXPORT
Provides a generic Factory class.
Definition: NekFactory.hpp:104
virtual SOLVER_UTILS_EXPORT void v_Init()
Definition: Coupling.cpp:59
SOLVER_UTILS_EXPORT void Finalize()
Definition: Coupling.h:85
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:98
MultiRegions::ExpListSharedPtr m_evalField
Definition: Coupling.h:111
SOLVER_UTILS_EXPORT const std::map< std::string, std::string > GetConfig()
Definition: Coupling.h:70
SOLVER_UTILS_EXPORT void Init()
Definition: Coupling.h:65
std::vector< std::string > m_sendFieldNames
Definition: Coupling.h:114
std::map< std::string, std::string > CouplingConfigMap
Definition: Coupling.h:59
virtual SOLVER_UTILS_EXPORT void v_Finalize()
Definition: Coupling.h:135
SOLVER_UTILS_EXPORT std::vector< std::string > GetRecvFieldNames()
Definition: Coupling.h:80
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:109
virtual SOLVER_UTILS_EXPORT ~Coupling()
Definition: Coupling.h:61
std::vector< std::string > m_recvFieldNames
Definition: Coupling.h:118
SOLVER_UTILS_EXPORT Coupling(MultiRegions::ExpListSharedPtr field)
Definition: Coupling.cpp:48
SOLVER_UTILS_EXPORT std::vector< std::string > GetSendFieldNames()
Definition: Coupling.h:75
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:90
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:132
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:42
double NekDouble