1717#define check (arg ) (((arg)) ? " pass\n " : " not pass\n " )
1818
1919constexpr 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
2525void 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