#include <memory>
+#include "gromacs/domdec/localatomsetmanager.h"
#include "gromacs/mdrunutility/mdmodulenotification.h"
#include "gromacs/mdtypes/imdmodule.h"
+#include "gromacs/utility/classhelpers.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/keyvaluetreebuilder.h"
/*! \internal
* \brief Collect density fitting parameters only available during simulation setup.
*
+ * \todo Implement builder pattern that will not use unqiue_ptr to check if
+ * parameters have been set or not.
+ *
* To build the density fitting force provider during simulation setup,
* the DensityFitting class needs access to parameters that become available
* only during simulation setup.
class DensityFittingSimulationParameterSetup
{
public:
+ DensityFittingSimulationParameterSetup() = default;
+ /*! \brief Set the local atom set for the density fitting.
+ * \param[in] localAtomSet of atoms to be fitted
+ */
+ void setLocalAtomSet(const LocalAtomSet &localAtomSet)
+ {
+ localAtomSet_ = std::make_unique<LocalAtomSet>(localAtomSet);
+ }
/*! \brief Return local atom set for density fitting.
* \throws InternalError if local atom set is not set
}
return *localAtomSet_;
}
+
/*! \brief Return transformation into density lattice.
* \throws InternalError if transformation into density lattice is not set
* \returns transormation into density lattice
std::unique_ptr<TranslateAndScale> transformationToDensityLattice_;
//! The local atom set to act on
std::unique_ptr<LocalAtomSet> localAtomSet_;
+ GMX_DISALLOW_COPY_AND_ASSIGN(DensityFittingSimulationParameterSetup);
};
/*! \internal
* KeyValueTreeObjectBuilder as parameter
* - reading its internal parameters from a key-value-tree during
* simulation setup by taking a const KeyValueTreeObject & parameter
+ * - constructing local atom sets in the simulation parameter setup
+ * by taking a LocalAtomSetManager * as parameter
*/
explicit DensityFitting(MdModulesNotifier *notifier)
{
densityFittingOptions_.readInternalParametersFromKvt(tree);
};
notifier->notifier_.subscribe(readInternalParametersFunction);
+ // constructing local atom sets during simulation setup
+ const auto setLocalAtomSetFunction = [this](LocalAtomSetManager *localAtomSetManager) {
+ this->constructLocalAtomSet(localAtomSetManager);
+ };
+ notifier->notifier_.subscribe(setLocalAtomSetFunction);
+
}
//! From IMDModule; this class provides the mdpOptions itself
//! This MDModule provides its own output
IMDOutputProvider *outputProvider() override { return &densityFittingOutputProvider_; }
+ /*! \brief Set up the local atom sets that are used by this module.
+ *
+ * \note When density fitting is set up with MdModuleNotification in
+ * the constructor, this function is called back.
+ *
+ * \param[in] localAtomSetManager the manager to add local atom sets.
+ */
+ void constructLocalAtomSet(LocalAtomSetManager * localAtomSetManager)
+ {
+ LocalAtomSet atomSet = localAtomSetManager->add(densityFittingOptions_.buildParameters().indices_);
+ densityFittingSimulationParameters_.setLocalAtomSet(atomSet);
+ }
+
private:
//! The output provider
DensityFittingOutputProvider densityFittingOutputProvider_;
* simulation setup time.
*/
DensityFittingSimulationParameterSetup densityFittingSimulationParameters_;
+ GMX_DISALLOW_COPY_AND_ASSIGN(DensityFitting);
};
} // namespace