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 57 of file Coupling.h.

Member Typedef Documentation

◆ CouplingConfigMap

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

Definition at line 61 of file Coupling.h.

Constructor & Destructor Documentation

◆ ~Coupling()

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

Definition at line 63 of file Coupling.h.

64 {
65 }

◆ Coupling()

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

Definition at line 50 of file Coupling.cpp.

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

References m_config.

Member Function Documentation

◆ Finalize()

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

Definition at line 87 of file Coupling.h.

88 {
89 v_Finalize();
90 }
virtual SOLVER_UTILS_EXPORT void v_Finalize()
Definition: Coupling.h:137

References v_Finalize().

◆ GenerateVariableMapping()

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

Definition at line 134 of file Coupling.cpp.

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

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 72 of file Coupling.h.

73 {
74 return m_config;
75 }

References m_config.

◆ GetRecvFieldNames()

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

Definition at line 82 of file Coupling.h.

83 {
84 return m_recvFieldNames;
85 }
std::vector< std::string > m_recvFieldNames
Definition: Coupling.h:120

References m_recvFieldNames.

◆ GetSendFieldNames()

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

Definition at line 77 of file Coupling.h.

78 {
79 return m_sendFieldNames;
80 }
std::vector< std::string > m_sendFieldNames
Definition: Coupling.h:116

References m_sendFieldNames.

◆ Init()

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

Definition at line 67 of file Coupling.h.

68 {
69 v_Init();
70 }
virtual SOLVER_UTILS_EXPORT void v_Init()
Definition: Coupling.cpp:61

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 100 of file Coupling.h.

104 {
105 v_Receive(step, time, field, varNames);
106 }
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 92 of file Coupling.h.

96 {
97 v_Send(step, time, field, varNames);
98 }
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 137 of file Coupling.h.

138 {
139 }

Referenced by Finalize().

◆ v_Init()

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

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

Definition at line 61 of file Coupling.cpp.

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