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

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 ~Coupling ()=default
 
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()

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

Definition at line 46 of file Coupling.cpp.

49{
50 m_config["RECEIVESTEPS"] = "0";
51 m_config["RECEIVEVARIABLES"] = "";
52
53 m_config["SENDSTEPS"] = "0";
54 m_config["SENDVARIABLES"] = "";
55}
MultiRegions::ExpListSharedPtr m_evalField
Definition: Coupling.h:107
CouplingConfigMap m_config
Definition: Coupling.h:105

References m_config.

◆ ~Coupling()

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

Member Function Documentation

◆ Finalize()

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

Definition at line 81 of file Coupling.h.

82 {
83 v_Finalize();
84 }
virtual SOLVER_UTILS_EXPORT void v_Finalize()
Definition: Coupling.h:133

References v_Finalize().

◆ GenerateVariableMapping()

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

Definition at line 131 of file Coupling.cpp.

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

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

67 {
68 return m_config;
69 }

References m_config.

◆ GetRecvFieldNames()

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

Definition at line 76 of file Coupling.h.

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

References m_recvFieldNames.

◆ GetSendFieldNames()

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

Definition at line 71 of file Coupling.h.

72 {
73 return m_sendFieldNames;
74 }
std::vector< std::string > m_sendFieldNames
Definition: Coupling.h:110

References m_sendFieldNames.

◆ Init()

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

Definition at line 61 of file Coupling.h.

62 {
63 v_Init();
64 }
virtual SOLVER_UTILS_EXPORT void v_Init()
Definition: Coupling.cpp:57

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

98 {
99 v_Receive(step, time, field, varNames);
100 }
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 FilterPython_Function::field, and 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 86 of file Coupling.h.

90 {
91 v_Send(step, time, field, varNames);
92 }
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 FilterPython_Function::field, and v_Send().

◆ v_Finalize()

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

Reimplemented in Nektar::SolverUtils::CouplingCwipi.

Definition at line 133 of file Coupling.h.

134 {
135 }

Referenced by Finalize().

◆ v_Init()

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

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

Definition at line 57 of file Coupling.cpp.

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