Skip to content

Commit 6c1d9ac

Browse files
committed
added a test for ready(), getUpdatedCouple is checked by the coordination tests
1 parent e1d9d01 commit 6c1d9ac

2 files changed

Lines changed: 45 additions & 16 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Single list: ready() before update returns "false"
2+
Single list: ready() after update returns "true"
3+
Single list: ready() before update returns "false"
4+
Single list: ready() after update returns "true"
5+
Two lists: ready() before update returns "false"
6+
Two lists: ready() after update returns "true"
7+
Two lists: ready() before update returns "false"
8+
Two lists: ready() after update returns "true"
9+
List of pairs: ready() before update returns "true"
10+
List of pairs: ready() after update returns "true"
11+
List of pairs: ready() before update returns "true"
12+
List of pairs: ready() after update returns "true"
13+
NoNL: ready() (always) returns "true"
14+
NoNL: ready() (always) returns "true"

regtest/tools/rt-Neigbourlist/main.cpp

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
#define check(arg) (((arg)) ? "pass\n" : "not pass\n")
1818

1919
constexpr bool serial = false;
20-
void testSingleList(bool do_pbc, std::ostream& ofs, PLMD::Communicator& comm);
21-
void testDoubleList(bool do_pbc, std::ostream& ofs, PLMD::Communicator& comm);
22-
void testPairList(bool do_pbc, std::ostream& ofs, PLMD::Communicator& comm);
23-
void testNoNL(bool do_pbc, std::ostream& ofs, PLMD::Communicator& comm);
20+
void testSingleList(bool do_pbc, std::ostream& ofs, std::ostream& initFile, PLMD::Communicator& comm);
21+
void testDoubleList(bool do_pbc, std::ostream& ofs, std::ostream& initFile, PLMD::Communicator& comm);
22+
void testPairList(bool do_pbc, std::ostream& ofs, std::ostream& initFile, PLMD::Communicator& comm);
23+
void testNoNL(bool do_pbc, std::ostream& ofs, std::ostream& initFile, PLMD::Communicator& comm);
2424

2525
void testResult(std::string name,
2626
const std::vector<PLMD::AtomNumber> &indexes,
@@ -60,23 +60,24 @@ int main(int argc, char **argv) {
6060
rank=std::to_string(myrank);
6161
}
6262
std::ofstream ofs("unitTest"+rank);
63-
testSingleList(false,ofs,comm);
64-
testSingleList(true,ofs,comm);
65-
testDoubleList(false,ofs,comm);
66-
testDoubleList(true,ofs,comm);
67-
testPairList(false,ofs,comm);
68-
testPairList(true,ofs,comm);
63+
std::ofstream initfile("initCheck"+rank);
64+
testSingleList(false,ofs,initfile,comm);
65+
testSingleList(true, ofs,initfile,comm);
66+
testDoubleList(false,ofs,initfile,comm);
67+
testDoubleList(true, ofs,initfile,comm);
68+
testPairList(false,ofs,initfile,comm);
69+
testPairList(true, ofs,initfile,comm);
6970
// an extra test to check for the NL with no NL
7071
std::ofstream ofsnl("testNoNL"+rank);
71-
testNoNL(false,ofsnl,comm);
72-
testNoNL(true,ofsnl,comm);
72+
testNoNL(false,ofsnl,initfile,comm);
73+
testNoNL(true, ofsnl,initfile,comm);
7374
}
7475
#ifdef USE_MPI
7576
MPI_Finalize();
7677
#endif //USE_MPI
7778
}
7879

79-
void testSingleList(const bool do_pbc, std::ostream& ofs, PLMD::Communicator& cm) {
80+
void testSingleList(const bool do_pbc, std::ostream& ofs, std::ostream& initfile, PLMD::Communicator& cm) {
8081
using namespace PLMD;
8182
Pbc pbc{};
8283
Random rng;
@@ -98,11 +99,15 @@ void testSingleList(const bool do_pbc, std::ostream& ofs, PLMD::Communicator& cm
9899
cm,
99100
cutoff,
100101
1);
102+
initfile << "Single list: ready() before update returns \""
103+
<< (nl.ready() ? "true" : "false") << "\"\n";
101104
nl.update(atoms);
105+
initfile << "Single list: ready() after update returns \""
106+
<< (nl.ready() ? "true" : "false") << "\"\n";
102107
testResult("Single list",indexes,do_pbc,nl,ofs);
103108
}
104109

105-
void testDoubleList(const bool do_pbc, std::ostream& ofs, PLMD::Communicator& cm) {
110+
void testDoubleList(const bool do_pbc, std::ostream& ofs, std::ostream& initfile, PLMD::Communicator& cm) {
106111
using namespace PLMD;
107112
Pbc pbc{};
108113
Random rng;
@@ -140,12 +145,16 @@ void testDoubleList(const bool do_pbc, std::ostream& ofs, PLMD::Communicator& cm
140145
atoms_indexed[i] = atoms[indexesA[i].index()];
141146
atoms_indexed[i+indexesA.size()] = atoms[indexesB[i].index()];
142147
}
148+
initfile << "Two lists: ready() before update returns \""
149+
<< (nl.ready() ? "true" : "false") << "\"\n";
143150
nl.update(atoms_indexed);
151+
initfile << "Two lists: ready() after update returns \""
152+
<< (nl.ready() ? "true" : "false") << "\"\n";
144153
auto indexes=indexesA;
145154
indexes.insert(indexes.end(),indexesB.begin(),indexesB.end());
146155
testResult("Two lists",indexes,do_pbc,nl,ofs);
147156
}
148-
void testPairList(const bool do_pbc, std::ostream& ofs, PLMD::Communicator& cm) {
157+
void testPairList(const bool do_pbc, std::ostream& ofs, std::ostream& initfile, PLMD::Communicator& cm) {
149158
using namespace PLMD;
150159
Pbc pbc{};
151160
Random rng;
@@ -181,13 +190,17 @@ void testPairList(const bool do_pbc, std::ostream& ofs, PLMD::Communicator& cm)
181190
atoms_indexed[i] = atoms[indexesA[i].index()];
182191
atoms_indexed[i+indexesA.size()] = atoms[indexesB[i].index()];
183192
}
193+
initfile << "List of pairs: ready() before update returns \""
194+
<< (nl.ready() ? "true" : "false") << "\"\n";
184195
nl.update(atoms_indexed);
196+
initfile << "List of pairs: ready() after update returns \""
197+
<< (nl.ready() ? "true" : "false") << "\"\n";
185198
auto indexes=indexesA;
186199
indexes.insert(indexes.end(),indexesB.begin(),indexesB.end());
187200
testResult("List of pairs",indexes,do_pbc,nl,ofs);
188201
}
189202

190-
void testNoNL(const bool do_pbc, std::ostream& ofs, PLMD::Communicator& cm) {
203+
void testNoNL(const bool do_pbc, std::ostream& ofs, std::ostream& initfile, PLMD::Communicator& cm) {
191204
using namespace PLMD;
192205
Pbc pbc{};
193206
Random rng;
@@ -208,6 +221,8 @@ void testNoNL(const bool do_pbc, std::ostream& ofs, PLMD::Communicator& cm) {
208221
pbc,
209222
cm);
210223

224+
initfile << "NoNL: ready() (always) returns \""
225+
<< (nl.ready() ? "true" : "false") << "\"\n";
211226
if(nl.getStride()>0) {
212227
//you should not be here
213228
plumed_assert(false)<<"getstride returned > 0!!!";

0 commit comments

Comments
 (0)