Skip to content

Commit

Permalink
Move client constructor to dump init
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Partee committed Sep 22, 2021
1 parent 6d3c538 commit 3b799ac
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/SMARTSIM/dump_atom_smartsim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,28 @@ using namespace LAMMPS_NS;
DumpAtomSmartSim::DumpAtomSmartSim(LAMMPS *lmp, int narg, char **arg)
: DumpAtom(lmp, narg, arg)
{
SmartRedis::Client* client = NULL;
this->_client = NULL;
try {
Client* client = new Client(true);
this->_client = client;
}
catch(std::exception& e) {
throw std::runtime_error(e.what());
}
catch(...) {
throw std::runtime_error("A non-standard exception "\
"was encountered during SmartRedis client "\
"construction.");
}
}

/* ---------------------------------------------------------------------- */

DumpAtomSmartSim::~DumpAtomSmartSim()
{
if(this->_client != NULL)
delete this->_client;
}

/* ---------------------------------------------------------------------- */
Expand Down Expand Up @@ -63,10 +79,6 @@ void DumpAtomSmartSim::write()
}


/* Construct SmartRedis Client object
*/
SmartRedis::Client client(true);

/* Construct DataSet object with unique
name based on user prefix, MPI rank, and
timestep
Expand Down Expand Up @@ -181,7 +193,7 @@ void DumpAtomSmartSim::write()

/* Send the DataSet to the SmartSim experiment database
*/
client.put_dataset(dataset);
this->_client->put_dataset(dataset);

/* Free temporary memory needed to preprocess LAMMPS output
*/
Expand Down
1 change: 1 addition & 0 deletions src/SMARTSIM/dump_atom_smartsim.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class DumpAtomSmartSim : public DumpAtom
virtual void write();
virtual void init_style();
private:
SmartRedis::Client* _client;
std::string _make_dataset_key();
template <typename T>
void _pack_buf_into_array(T* data, int length,
Expand Down

0 comments on commit 3b799ac

Please sign in to comment.