/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2020, by the GROMACS development team, led by
+ * Copyright (c) 2020,2021, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
* \author Sebastian Keller <keller@cscs.ch>
* \author Artem Zhmurov <zhmurov@gmail.com>
*/
+#include <algorithm>
#include <numeric>
#include "gromacs/topology/exclusionblocks.h"
#include "gromacs/utility/smalloc.h"
#include "nblib/exception.h"
#include "nblib/particletype.h"
+#include "nblib/sequencing.hpp"
#include "nblib/topology.h"
-#include "nblib/util/internal.h"
+#include "nblib/util/util.hpp"
+#include "nblib/topologyhelpers.h"
namespace nblib
{
TopologyBuilder::TopologyBuilder() : numParticles_(0) {}
-gmx::ListOfLists<int> TopologyBuilder::createExclusionsListOfLists() const
+ExclusionLists<int> TopologyBuilder::createExclusionsLists() const
{
const auto& moleculesList = molecules_;
"No exclusions found in the " + molecule.name().value() + " molecule.";
assert((!exclusions.empty() && message.c_str()));
- std::vector<gmx::ExclusionBlock> exclusionBlockPerMolecule =
- detail::toGmxExclusionBlock(exclusions);
+ std::vector<gmx::ExclusionBlock> exclusionBlockPerMolecule = toGmxExclusionBlock(exclusions);
// duplicate the exclusionBlockPerMolecule for the number of Molecules of (numMols)
for (size_t i = 0; i < numMols; ++i)
{
- auto offsetExclusions =
- detail::offsetGmxBlock(exclusionBlockPerMolecule, particleNumberOffset);
+ auto offsetExclusions = offsetGmxBlock(exclusionBlockPerMolecule, particleNumberOffset);
std::copy(std::begin(offsetExclusions),
std::end(offsetExclusions),
exclusionsListOfListsGlobal.pushBack(block.atomNumber);
}
- return exclusionsListOfListsGlobal;
+ std::vector<int> listRanges(exclusionsListOfListsGlobal.listRangesView().begin(),
+ exclusionsListOfListsGlobal.listRangesView().end());
+ std::vector<int> listElements(exclusionsListOfListsGlobal.elementsView().begin(),
+ exclusionsListOfListsGlobal.elementsView().end());
+ ExclusionLists<int> exclusionListsGlobal;
+ exclusionListsGlobal.ListRanges = std::move(listRanges);
+ exclusionListsGlobal.ListElements = std::move(listElements);
+
+ return exclusionListsGlobal;
}
-ListedInteractionData TopologyBuilder::createInteractionData(const detail::ParticleSequencer& particleSequencer)
+ListedInteractionData TopologyBuilder::createInteractionData(const ParticleSequencer& particleSequencer)
{
ListedInteractionData interactionData;
}
topology_.numParticles_ = numParticles_;
- topology_.exclusions_ = createExclusionsListOfLists();
- topology_.charges_ = extractParticleTypeQuantity<real>([](const auto& data, auto& map) {
- ignore_unused(map);
- return data.charge_;
- });
+ topology_.exclusionLists_ = createExclusionsLists();
+ topology_.charges_ = extractParticleTypeQuantity<real>(
+ [](const auto& data, [[maybe_unused]] auto& map) { return data.charge_; });
// map unique ParticleTypes to IDs
std::unordered_map<std::string, int> nameToId;
}
topology_.particleTypeIdOfAllParticles_ =
- extractParticleTypeQuantity<int>([&nameToId](const auto& data, auto& map) {
- ignore_unused(map);
+ extractParticleTypeQuantity<int>([&nameToId](const auto& data, [[maybe_unused]] auto& map) {
return nameToId[data.particleTypeName_];
});
- detail::ParticleSequencer particleSequencer;
+ ParticleSequencer particleSequencer;
particleSequencer.build(molecules_);
topology_.particleSequencer_ = std::move(particleSequencer);
return combinationRule_;
}
-gmx::ListOfLists<int> Topology::getGmxExclusions() const
+ExclusionLists<int> Topology::exclusionLists() const
{
- return exclusions_;
+ return exclusionLists_;
}
} // namespace nblib