-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gmxapi-62 Stop condition hook task 1
Work in progress. This commit will be rewritten soon. Don't merge into anything but a temporary integration branch.
- Loading branch information
Showing
8 changed files
with
215 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// | ||
// Created by Eric Irrgang on 5/18/18. | ||
// | ||
|
||
/* WARNING | ||
* This whole file is not intended to make it into a public release and is not part of the gmxapi API. It is for | ||
* prototyping only. Please don't let it slip into a release without serious design considerations. | ||
*/ | ||
|
||
#ifndef GROMACS_SIGNALS_H | ||
#define GROMACS_SIGNALS_H | ||
|
||
#include <memory> | ||
|
||
namespace gmxapi { | ||
|
||
namespace md | ||
{ | ||
|
||
enum class signals { | ||
STOP | ||
}; | ||
|
||
} // end namespace md | ||
|
||
|
||
class Session; // defined in gmxapi/session.h | ||
|
||
/*! | ||
* \brief Proxy for signalling function objects. | ||
* | ||
* Objects of this type are simple callables that issue a specific signal. | ||
*/ | ||
class Signal | ||
{ | ||
public: | ||
class SignalImpl; | ||
explicit Signal(std::unique_ptr<SignalImpl>&& signal); | ||
|
||
void operator()(); | ||
|
||
private: | ||
std::unique_ptr<SignalImpl> impl_; | ||
}; | ||
|
||
/*! | ||
* \brief Get a function object that issues a signal to the currently active MD runner. | ||
* | ||
* \param session pointer to the active Session. | ||
* \return Callable function object handle | ||
*/ | ||
Signal getMdrunnerSignal(Session* session, md::signals signal); | ||
|
||
} // end namespace md | ||
|
||
#endif //GROMACS_SIGNALS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// | ||
// Created by Eric Irrgang on 5/18/18. | ||
// | ||
|
||
|
||
|
||
#include <gromacs/compat/make_unique.h> | ||
#include "gmxapi/md/mdsignals.h" | ||
|
||
#include "gromacs/mdlib/simulationsignal.h" | ||
#include "programs/mdrun/runner.h" | ||
|
||
#include "gmxapi/session.h" | ||
|
||
#include "session-impl.h" | ||
|
||
namespace gmxapi { | ||
|
||
class Signal::SignalImpl | ||
{ | ||
public: | ||
virtual void call() = 0; | ||
|
||
|
||
}; | ||
|
||
Signal::Signal(std::unique_ptr<gmxapi::Signal::SignalImpl>&& impl) : | ||
impl_{std::move(impl)} | ||
{ | ||
} | ||
|
||
void Signal::operator()() | ||
{ | ||
impl_->call(); | ||
} | ||
|
||
class StopSignal : public Signal::SignalImpl | ||
{ | ||
public: | ||
explicit StopSignal(gmx::Mdrunner* runner) : runner_{runner} {}; | ||
|
||
static Signal create(gmx::Mdrunner* runner) | ||
{ | ||
auto impl = gmx::compat::make_unique<StopSignal>(runner); | ||
auto signal = gmxapi::Signal(std::move(impl)); | ||
return signal; | ||
} | ||
|
||
void call() override | ||
{ | ||
auto signals = runner_->signals(); | ||
signals->at(eglsSTOPCOND).sig = true; | ||
} | ||
|
||
private: | ||
gmx::Mdrunner* runner_; | ||
}; | ||
|
||
|
||
Signal getMdrunnerSignal(Session* session, md::signals signal) | ||
{ | ||
// if (signal == md::signals::STOP) | ||
// { | ||
assert(session); | ||
|
||
auto impl = session->getRaw(); | ||
assert(impl); | ||
|
||
auto runner = impl->getRunner(); | ||
assert(runner); | ||
|
||
return StopSignal::create(runner); | ||
// } | ||
// else | ||
// { | ||
// } | ||
} | ||
|
||
} // end namespace gmxapi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# | ||
#add_library(restraint OBJECT | ||
# restraintpotential.h | ||
# restraintpotential.cpp | ||
# vectortype.h | ||
# manager.cpp | ||
# manager.h | ||
# restraintfunctor-impl.cpp | ||
# restraintfunctor-impl.h | ||
# restraintcalculation.h | ||
# restraintcalculation.cpp | ||
# restraintcalculation-impl.h | ||
# restraintmdmodule.h | ||
# restraintmdmodule.cpp | ||
# restraintmdmodule-impl.h) | ||
#set_target_properties(restraint PROPERTIES POSITION_INDEPENDENT_CODE ON) | ||
# | ||
#set(LIBGROMACS_SOURCES ${LIBGROMACS_SOURCES} $<TARGET_OBJECTS:restraint> PARENT_SCOPE) | ||
# | ||
#gmx_install_headers(restraintpotential.h | ||
# vectortype.h) | ||
# | ||
#if (BUILD_TESTING) | ||
# add_subdirectory(tests) | ||
#endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters