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 
37 #include <MultiRegions/ExpList.h>
39 
40 namespace Nektar
41 {
42 namespace SolverUtils
43 {
44 
45 class Coupling;
46 
47 SOLVER_UTILS_EXPORT typedef std::shared_ptr<Coupling> CouplingSharedPtr;
48 
49 /// Declaration of the Coupling factory
50 SOLVER_UTILS_EXPORT typedef LibUtilities::
51  NekFactory<std::string, Coupling, MultiRegions::ExpListSharedPtr>
53 
54 /// Declaration of the Coupling factory singleton
56 
57 class Coupling
58 {
59 
60 public:
61  typedef std::map<std::string, std::string> CouplingConfigMap;
62 
64  {
65  }
66 
67  SOLVER_UTILS_EXPORT inline void Init()
68  {
69  v_Init();
70  }
71 
72  SOLVER_UTILS_EXPORT inline const std::map<std::string, std::string> GetConfig()
73  {
74  return m_config;
75  }
76 
77  SOLVER_UTILS_EXPORT inline std::vector<std::string> GetSendFieldNames()
78  {
79  return m_sendFieldNames;
80  }
81 
82  SOLVER_UTILS_EXPORT inline std::vector<std::string> GetRecvFieldNames()
83  {
84  return m_recvFieldNames;
85  }
86 
88  {
89  v_Finalize();
90  }
91 
93  const int step,
94  const NekDouble time,
95  const Array<OneD, const Array<OneD, NekDouble> > &field,
96  std::vector<std::string> &varNames)
97  {
98  v_Send(step, time, field, varNames);
99  }
100 
102  const int step,
103  const NekDouble time,
105  std::vector<std::string> &varNames)
106  {
107  v_Receive(step, time, field, varNames);
108  }
109 
110 protected:
111  std::string m_couplingName;
112 
114 
116 
118  std::vector<std::string> m_sendFieldNames;
120 
122  std::vector<std::string> m_recvFieldNames;
124 
126 
127  SOLVER_UTILS_EXPORT virtual void v_Init();
128 
130  const int step,
131  const NekDouble time,
132  const Array<OneD, const Array<OneD, NekDouble> > &field,
133  std::vector<std::string> &varNames) = 0;
134 
136  const int step,
137  const NekDouble time,
139  std::vector<std::string> &varNames) = 0;
140 
142  {
143  }
144 
146  std::vector<std::string> &vars, std::vector<std::string> &transVars);
147 };
148 }
149 }
150 
151 #endif
#define SOLVER_UTILS_EXPORT
SOLVER_UTILS_EXPORT const std::map< std::string, std::string > GetConfig()
Definition: Coupling.h:72
virtual SOLVER_UTILS_EXPORT void v_Init()
Definition: Coupling.cpp:61
SOLVER_UTILS_EXPORT void Finalize()
Definition: Coupling.h:87
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:101
MultiRegions::ExpListSharedPtr m_evalField
Definition: Coupling.h:115
SOLVER_UTILS_EXPORT void Init()
Definition: Coupling.h:67
std::vector< std::string > m_sendFieldNames
Definition: Coupling.h:118
std::map< std::string, std::string > CouplingConfigMap
Definition: Coupling.h:61
virtual SOLVER_UTILS_EXPORT void v_Finalize()
Definition: Coupling.h:141
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:113
virtual SOLVER_UTILS_EXPORT ~Coupling()
Definition: Coupling.h:63
std::vector< std::string > m_recvFieldNames
Definition: Coupling.h:122
SOLVER_UTILS_EXPORT std::vector< std::string > GetSendFieldNames()
Definition: Coupling.h:77
SOLVER_UTILS_EXPORT std::vector< std::string > GetRecvFieldNames()
Definition: Coupling.h:82
SOLVER_UTILS_EXPORT Coupling(MultiRegions::ExpListSharedPtr field)
Definition: Coupling.cpp:50
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:92
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:135
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
SOLVER_UTILS_EXPORT typedef std::shared_ptr< Coupling > CouplingSharedPtr
Definition: Coupling.h:45
CouplingFactory & GetCouplingFactory()
Declaration of the Coupling factory singleton.
Definition: Coupling.cpp:44
SOLVER_UTILS_EXPORT typedef LibUtilities::NekFactory< std::string, Coupling, MultiRegions::ExpListSharedPtr > CouplingFactory
Declaration of the Coupling factory.
Definition: Coupling.h:52
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
double NekDouble