Merge branch release-2021
[alexxy/gromacs.git] / api / nblib / tests / topology.cpp
index 5d625d2fee8a9eaf02876bdb132e1b34aeebbd7b..ff4d0336d929edc9eaa0e3c2af468a7d70628dfa 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * 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.
 #include <gtest/gtest.h>
 
 #include "gromacs/topology/exclusionblocks.h"
+#include "gromacs/utility/listoflists.h"
 #include "nblib/exception.h"
 #include "nblib/particletype.h"
+#include "nblib/sequencing.hpp"
 #include "nblib/tests/testsystems.h"
 #include "nblib/topology.h"
+#include "nblib/topologyhelpers.h"
+#include "nblib/particlesequencer.h"
 
 namespace nblib
 {
@@ -167,9 +171,11 @@ TEST(NBlibTest, TopologyThrowsIdenticalParticleType)
 
 TEST(NBlibTest, TopologyHasExclusions)
 {
-    WaterTopologyBuilder         waters;
-    Topology                     watersTopology = waters.buildTopology(2);
-    const gmx::ListOfLists<int>& testExclusions = watersTopology.getGmxExclusions();
+    WaterTopologyBuilder        waters;
+    Topology                    watersTopology = waters.buildTopology(2);
+    ExclusionLists<int>         exclusionLists = watersTopology.exclusionLists();
+    const gmx::ListOfLists<int> testExclusions(std::move(exclusionLists.ListRanges),
+                                               std::move(exclusionLists.ListElements));
 
     const std::vector<std::vector<int>>& refExclusions = { { 0, 1, 2 }, { 0, 1, 2 }, { 0, 1, 2 },
                                                            { 3, 4, 5 }, { 3, 4, 5 }, { 3, 4, 5 } };
@@ -228,7 +234,7 @@ TEST(NBlibTest, TopologyCanSequencePairIDs)
 
     std::vector<std::tuple<Molecule, int>> molecules{ std::make_tuple(water, 2),
                                                       std::make_tuple(methanol, 1) };
-    detail::ParticleSequencer              particleSequencer;
+    ParticleSequencer                      particleSequencer;
     particleSequencer.build(molecules);
     auto pairs = detail::sequenceIDs<HarmonicBondType>(molecules, particleSequencer);
 
@@ -263,7 +269,7 @@ TEST(NBlibTest, TopologySequenceIdThrows)
 
     std::vector<std::tuple<Molecule, int>> molecules{ std::make_tuple(water, 2),
                                                       std::make_tuple(methanol, 1) };
-    detail::ParticleSequencer              particleSequencer;
+    ParticleSequencer                      particleSequencer;
     particleSequencer.build(molecules);
     auto pairs = detail::sequenceIDs<HarmonicBondType>(molecules, particleSequencer);
 
@@ -360,8 +366,8 @@ TEST(NBlibTest, TopologyListedInteractionsMultipleTypes)
     Molecule water    = WaterMoleculeBuilder{}.waterMolecule();
     Molecule methanol = MethanolMoleculeBuilder{}.methanolMolecule();
 
-    CubicBondType testBond(1., 1., 1.);
-    DefaultAngle  testAngle(Degrees(1), 1);
+    CubicBondType     testBond(1., 1., 1.);
+    HarmonicAngleType testAngle(Degrees(1), 1);
 
     water.addInteraction(ParticleName("H1"), ParticleName("H2"), testBond);
     water.addInteraction(ParticleName("H1"), ParticleName("Oxygen"), ParticleName("H2"), testAngle);
@@ -383,7 +389,7 @@ TEST(NBlibTest, TopologyListedInteractionsMultipleTypes)
     auto  interactionData   = topology.getInteractionData();
     auto& harmonicBonds     = pickType<HarmonicBondType>(interactionData);
     auto& cubicBonds        = pickType<CubicBondType>(interactionData);
-    auto& angleInteractions = pickType<DefaultAngle>(interactionData);
+    auto& angleInteractions = pickType<HarmonicAngleType>(interactionData);
 
     HarmonicBondType              ohBond(1., 1.);
     HarmonicBondType              ohBondMethanol(1.01, 1.02);
@@ -407,9 +413,9 @@ TEST(NBlibTest, TopologyListedInteractionsMultipleTypes)
     EXPECT_EQ(cubicBondsReference, cubicBonds.parameters);
     EXPECT_EQ(cubicIndicesReference, cubicBonds.indices);
 
-    DefaultAngle                                methanolAngle(Degrees(108.52), 397.5);
-    std::vector<DefaultAngle>                   angleReference{ testAngle, methanolAngle };
-    std::vector<InteractionIndex<DefaultAngle>> angleIndicesReference{
+    HarmonicAngleType                                methanolAngle(Degrees(108.52), 397.5);
+    std::vector<HarmonicAngleType>                   angleReference{ testAngle, methanolAngle };
+    std::vector<InteractionIndex<HarmonicAngleType>> angleIndicesReference{
         { std::min(H1, H2), Ow, std::max(H1, H2), 0 }, { std::min(MeH1, MeO1), Me1, std::max(MeO1, MeH1), 1 }
     };
     EXPECT_EQ(angleReference, angleInteractions.parameters);
@@ -458,7 +464,7 @@ TEST(NBlibTest, toGmxExclusionBlockWorks)
     reference.push_back(localBlock);
     reference.push_back(localBlock);
 
-    std::vector<gmx::ExclusionBlock> probe = detail::toGmxExclusionBlock(testInput);
+    std::vector<gmx::ExclusionBlock> probe = toGmxExclusionBlock(testInput);
 
     ASSERT_EQ(reference.size(), probe.size());
     for (size_t i = 0; i < reference.size(); ++i)