Nektar++
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Nektar::SolverUtils::Coupling Class Referenceabstract

#include <Coupling.h>

Inheritance diagram for Nektar::SolverUtils::Coupling:
[legend]

Public Types

typedef std::map< std::string, std::string > CouplingConfigMap
 

Public Member Functions

virtual SOLVER_UTILS_EXPORT ~Coupling ()
 
SOLVER_UTILS_EXPORT void Init ()
 
SOLVER_UTILS_EXPORT const std::map< std::string, std::string > GetConfig ()
 
SOLVER_UTILS_EXPORT std::vector< std::string > GetSendFieldNames ()
 
SOLVER_UTILS_EXPORT std::vector< std::string > GetRecvFieldNames ()
 
SOLVER_UTILS_EXPORT void Finalize ()
 
SOLVER_UTILS_EXPORT void Send (const int step, const NekDouble time, const Array< OneD, const Array< OneD, NekDouble > > &field, std::vector< std::string > &varNames)
 
SOLVER_UTILS_EXPORT void Receive (const int step, const NekDouble time, Array< OneD, Array< OneD, NekDouble > > &field, std::vector< std::string > &varNames)
 

Protected Member Functions

SOLVER_UTILS_EXPORT Coupling (MultiRegions::ExpListSharedPtr field)
 
virtual SOLVER_UTILS_EXPORT void v_Init ()
 
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
 
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
 
virtual SOLVER_UTILS_EXPORT void v_Finalize ()
 
SOLVER_UTILS_EXPORT std::vector< int > GenerateVariableMapping (std::vector< std::string > &vars, std::vector< std::string > &transVars)
 

Protected Attributes

std::string m_couplingName
 
CouplingConfigMap m_config
 
MultiRegions::ExpListSharedPtr m_evalField
 
int m_nSendVars
 
std::vector< std::string > m_sendFieldNames
 
int m_sendSteps
 
int m_nRecvVars
 
std::vector< std::string > m_recvFieldNames
 
int m_recvSteps
 

Detailed Description

Definition at line 55 of file Coupling.h.

Member Typedef Documentation

◆ CouplingConfigMap

typedef std::map<std::string, std::string> Nektar::SolverUtils::Coupling::CouplingConfigMap

Definition at line 59 of file Coupling.h.

Constructor & Destructor Documentation

◆ ~Coupling()

virtual SOLVER_UTILS_EXPORT Nektar::SolverUtils::Coupling::~Coupling ( )
inlinevirtual

Definition at line 61 of file Coupling.h.

62 {
63 }

◆ Coupling()

Nektar::SolverUtils::Coupling::Coupling ( MultiRegions::ExpListSharedPtr  field)
protected

Definition at line 48 of file Coupling.cpp.

51{
52 m_config["RECEIVESTEPS"] = "0";
53 m_config["RECEIVEVARIABLES"] = "";
54
55 m_config["SENDSTEPS"] = "0";
56 m_config["SENDVARIABLES"] = "";
57}
MultiRegions::ExpListSharedPtr m_evalField
Definition: Coupling.h:111
CouplingConfigMap m_config
Definition: Coupling.h:109

References m_config.

Member Function Documentation

◆ Finalize()

SOLVER_UTILS_EXPORT void Nektar::SolverUtils::Coupling::Finalize ( )
inline

Definition at line 85 of file Coupling.h.

86 {
87 v_Finalize();
88 }
virtual SOLVER_UTILS_EXPORT void v_Finalize()
Definition: Coupling.h:135

References v_Finalize().

◆ GenerateVariableMapping()

vector< int > Nektar::SolverUtils::Coupling::GenerateVariableMapping ( std::vector< std::string > &  vars,
std::vector< std::string > &  transVars 
)
protected

Definition at line 132 of file Coupling.cpp.

134{
135 vector<int> transToVars;
136 Array<OneD, Array<OneD, NekDouble>> sendField(transVars.size());
137 for (int i = 0; i < transVars.size(); ++i)
138 {
139 auto it2 = find(vars.begin(), vars.end(), transVars[i]);
140 ASSERTL0(it2 != vars.end(),
141 "send variable " + transVars[i] + " not found");
142 int id = distance(vars.begin(), it2);
143
144 transToVars.push_back(id);
145 }
146
147 return transToVars;
148}
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:208
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
Definition: StdRegions.hpp:447

References ASSERTL0, and Nektar::StdRegions::find().

Referenced by Nektar::SolverUtils::CouplingCwipi::v_Receive(), Nektar::SolverUtils::CouplingFile::v_Receive(), Nektar::SolverUtils::CouplingCwipi::v_Send(), and Nektar::SolverUtils::CouplingFile::v_Send().

◆ GetConfig()

SOLVER_UTILS_EXPORT const std::map< std::string, std::string > Nektar::SolverUtils::Coupling::GetConfig ( )
inline

Definition at line 70 of file Coupling.h.

71 {
72 return m_config;
73 }

References m_config.

◆ GetRecvFieldNames()

SOLVER_UTILS_EXPORT std::vector< std::string > Nektar::SolverUtils::Coupling::GetRecvFieldNames ( )
inline

Definition at line 80 of file Coupling.h.

81 {
82 return m_recvFieldNames;
83 }
std::vector< std::string > m_recvFieldNames
Definition: Coupling.h:118

References m_recvFieldNames.

◆ GetSendFieldNames()

SOLVER_UTILS_EXPORT std::vector< std::string > Nektar::SolverUtils::Coupling::GetSendFieldNames ( )
inline

Definition at line 75 of file Coupling.h.

76 {
77 return m_sendFieldNames;
78 }
std::vector< std::string > m_sendFieldNames
Definition: Coupling.h:114

References m_sendFieldNames.

◆ Init()

SOLVER_UTILS_EXPORT void Nektar::SolverUtils::Coupling::Init ( )
inline

Definition at line 65 of file Coupling.h.

66 {
67 v_Init();
68 }
virtual SOLVER_UTILS_EXPORT void v_Init()
Definition: Coupling.cpp:59

References v_Init().

◆ Receive()

SOLVER_UTILS_EXPORT void Nektar::SolverUtils::Coupling::Receive ( const int  step,
const NekDouble  time,
Array< OneD, Array< OneD, NekDouble > > &  field,
std::vector< std::string > &  varNames 
)
inline

Definition at line 98 of file Coupling.h.

102 {
103 v_Receive(step, time, field, varNames);
104 }
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

References v_Receive().

◆ Send()

SOLVER_UTILS_EXPORT void Nektar::SolverUtils::Coupling::Send ( const int  step,
const NekDouble  time,
const Array< OneD, const Array< OneD, NekDouble > > &  field,
std::vector< std::string > &  varNames 
)
inline

Definition at line 90 of file Coupling.h.

94 {
95 v_Send(step, time, field, varNames);
96 }
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

References v_Send().

◆ v_Finalize()

virtual SOLVER_UTILS_EXPORT void Nektar::SolverUtils::Coupling::v_Finalize ( void  )
inlineprotectedvirtual

Reimplemented in Nektar::SolverUtils::CouplingCwipi.

Definition at line 135 of file Coupling.h.

136 {
137 }

Referenced by Finalize().

◆ v_Init()

void Nektar::SolverUtils::Coupling::v_Init ( )
protectedvirtual

Reimplemented in Nektar::SolverUtils::CouplingCwipi, and Nektar::SolverUtils::CouplingFile.

Definition at line 59 of file Coupling.cpp.

60{
62
63 TiXmlElement *vCoupling = session->GetElement("Nektar/Coupling");
64 ASSERTL0(vCoupling, "Invalid Coupling config");
65
66 vCoupling->QueryStringAttribute("NAME", &m_couplingName);
67 ASSERTL0(m_couplingName.size(), "No Coupling NAME attribute set");
68
69 TiXmlElement *element = vCoupling->FirstChildElement("I");
70 while (element)
71 {
72 std::stringstream tagcontent;
73 tagcontent << *element;
74 // read the property name
75 ASSERTL0(element->Attribute("PROPERTY"),
76 "Missing PROPERTY attribute in Coupling section "
77 "XML element: \n\t'" +
78 tagcontent.str() + "'");
79 std::string property = element->Attribute("PROPERTY");
80 ASSERTL0(!property.empty(),
81 "PROPERTY attribute must be non-empty in XML "
82 "element: \n\t'" +
83 tagcontent.str() + "'");
84
85 // make sure that solver property is capitalised
86 std::string propertyUpper = boost::to_upper_copy(property);
87
88 CouplingConfigMap::const_iterator x = m_config.find(propertyUpper);
89 ASSERTL0(x != m_config.end(),
90 "Invalid PROPERTY attribute in Coupling section "
91 "XML element: \n\t'" +
92 tagcontent.str() + "'");
93
94 // read the value
95 ASSERTL0(element->Attribute("VALUE"),
96 "Missing VALUE attribute in Coupling section "
97 "XML element: \n\t'" +
98 tagcontent.str() + "'");
99 std::string value = element->Attribute("VALUE");
100 ASSERTL0(!value.empty(), "VALUE attribute must be non-empty in XML "
101 "element: \n\t'" +
102 tagcontent.str() + "'");
103
104 // Set Variable
105 m_config[propertyUpper] = value;
106
107 element = element->NextSiblingElement("I");
108 }
109
110 // mangle config into variables. This is ugly
113
116
117 m_recvSteps = boost::lexical_cast<int>(m_config["RECEIVESTEPS"]);
118 m_sendSteps = boost::lexical_cast<int>(m_config["SENDSTEPS"]);
119
120 if (session->GetComm()->GetRank() == 0 &&
121 session->DefinesCmdLineArgument("verbose") && m_config.size() > 0)
122 {
123 cout << "Coupling Config:" << endl;
124 CouplingConfigMap::iterator x;
125 for (x = m_config.begin(); x != m_config.end(); ++x)
126 {
127 cout << "\t" << x->first << " = '" << x->second << "'" << endl;
128 }
129 }
130}
static bool GenerateVector(const std::string &str, std::vector< T > &out)
Takes a comma-separated string and converts it to entries in a vector.
Definition: ParseUtils.cpp:130
std::shared_ptr< SessionReader > SessionReaderSharedPtr

References ASSERTL0, Nektar::ParseUtils::GenerateVector(), m_config, m_couplingName, m_evalField, m_nRecvVars, m_nSendVars, m_recvFieldNames, m_recvSteps, m_sendFieldNames, and m_sendSteps.

Referenced by Init(), Nektar::SolverUtils::CouplingCwipi::v_Init(), and Nektar::SolverUtils::CouplingFile::v_Init().

◆ v_Receive()

virtual SOLVER_UTILS_EXPORT void Nektar::SolverUtils::Coupling::v_Receive ( const int  step,
const NekDouble  time,
Array< OneD, Array< OneD, NekDouble > > &  field,
std::vector< std::string > &  varNames 
)
protectedpure virtual

◆ v_Send()

virtual SOLVER_UTILS_EXPORT void Nektar::SolverUtils::Coupling::v_Send ( const int  step,
const NekDouble  time,
const Array< OneD, const Array< OneD, NekDouble > > &  field,
std::vector< std::string > &  varNames 
)
protectedpure virtual

Member Data Documentation

◆ m_config

CouplingConfigMap Nektar::SolverUtils::Coupling::m_config
protected

◆ m_couplingName

std::string Nektar::SolverUtils::Coupling::m_couplingName
protected

◆ m_evalField

MultiRegions::ExpListSharedPtr Nektar::SolverUtils::Coupling::m_evalField
protected

◆ m_nRecvVars

int Nektar::SolverUtils::Coupling::m_nRecvVars
protected

◆ m_nSendVars

int Nektar::SolverUtils::Coupling::m_nSendVars
protected

◆ m_recvFieldNames

std::vector<std::string> Nektar::SolverUtils::Coupling::m_recvFieldNames
protected

◆ m_recvSteps

int Nektar::SolverUtils::Coupling::m_recvSteps
protected

◆ m_sendFieldNames

std::vector<std::string> Nektar::SolverUtils::Coupling::m_sendFieldNames
protected

◆ m_sendSteps

int Nektar::SolverUtils::Coupling::m_sendSteps
protected