2#include <boost/algorithm/string/trim.hpp>
20 constexpr int firstLevelLen = 2;
33 auto p =
fs::path(addressDirectory.
begin(), addressDirectory.
end()) /
"precice-run" / directional;
66 "Unable to establish connection as the connection file \"{}\" couldn't be opened.",
71 "Unable to establish connection as the connection file \"{}\" is empty. "
72 "Please report this bug to the preCICE developers.",
74 boost::algorithm::trim_right(addressData);
82 PRECICE_WARN(
"Cannot clean-up the connection file \"{}\" as it doesn't exist. "
83 "In case of connection problems, please report this to the preCICE developers.",
92 "The connection file \"{}\" wasn't properly removed. "
93 "Make sure to delete the \"precice-run\" directory before restarting the simulation.",
96 PRECICE_WARN(
"Unable to clean-up connection file due to error: {}. "
97 "Make sure to delete the \"precice-run\" directory before restarting the simulation.",
108 auto message =
"Unable to establish connection as a {}connection file already exists at \"{}\". "
109 "This is likely a leftover of a previous crash or stop during communication build-up. "
110 "Please remove the \"precice-run\" directory and restart the simulation.";
115 PRECICE_DEBUG(
"Writing temporary connection file \"{}\"", tmp.generic_string());
119 PRECICE_CHECK(ofs,
"Unable to establish connection as the temporary connection file \"{}\" couldn't be opened.", tmp.generic_string());
121 "{}\nAcceptor: {}, Requester: {}, Tag: {}, Rank: {}",
125 "Unable to establish connection as the temporary connection file \"{}\" was written, but doesn't exist on disk. "
126 "Please report this bug to the preCICE developers.",
127 tmp.generic_string());
133 "The temporary connection file \"{}\" wasn't properly removed. "
134 "Make sure to delete the \"precice-run\" directory before restarting the simulation.",
135 tmp.generic_string());
137 "Unable to establish connection as the connection file \"{}\" doesn't exist on disk. "
138 "Please report this bug to the preCICE developers.",
#define PRECICE_WARN_IF(condition,...)
#define PRECICE_WARN(...)
#define PRECICE_DEBUG(...)
#define PRECICE_CHECK(check,...)
#define PRECICE_ASSERT(...)
std::string const addressDirectory
std::string const acceptorName
std::string getLocalDirectory() const
Returns the local directory which is used to store the hashed part.
std::string const requesterName
std::string getFilename() const
Returns the full path to the hashed filename.
std::string read() const
Reads the info from the connection info file. Will block, if the the file is not present.
void write(std::string_view info) const
Write the string info, e.g. IP:port to the connection info file.
~ConnectionInfoWriter()
Removes the connection info file and the directories ./precice-run/[hash], is empty.
T create_directories(T... args)
T generic_string(T... args)
std::string hashedFilePath(std::string_view acceptorName, std::string_view requesterName, std::string_view meshName, Rank rank)
Returns the file name for the connection information.
std::string localDirectory(std::string_view acceptorName, std::string_view requesterName, std::string_view addressDirectory)
contains the data communication abstraction layer.
std::string preciceHash(std::string_view s)
creates a portable hash of the given input