Skip to content

Commit

Permalink
Started checkpoint test. Will remove all files generated and reuse sy…
Browse files Browse the repository at this point in the history
…stems for all tests
  • Loading branch information
GregorySchwing committed Oct 6, 2021
1 parent 9058f67 commit 4367b87
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 4 deletions.
4 changes: 2 additions & 2 deletions CMake/FileLists.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ set(sources
src/CheckpointOutput.cpp
src/CheckpointSetup.cpp
src/DCDlib.cpp
src/ExtendedSystemOutput.cpp
src/EnPartCntSampleOutput.cpp
src/ExtendedSystem.cpp
src/ExtendedSystemOutput.cpp
src/Ewald.cpp
src/EwaldCached.cpp
src/FFConst.cpp
Expand Down Expand Up @@ -87,11 +87,11 @@ set(headers
src/CoordinateSetup.h
src/CPUSide.h
src/DCDlib.h
src/ExtendedSystemOutput.h
src/EnergyTypes.h
src/EnPartCntSampleOutput.h
src/EnsemblePreprocessor.h
src/ExtendedSystem.h
src/ExtendedSystemOutput.h
src/Ewald.h
src/EwaldCached.h
src/FFAngles.h
Expand Down
4 changes: 4 additions & 0 deletions src/CheckpointSetup.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ class CheckpointSetup
#if GOMC_LIB_MPI
void SetParallelTemperingWasEnabled();
void SetPRNGVariablesPT(PRNG & prng);
#endif

#if GOMC_GTEST

#endif

std::string filename;
Expand Down
5 changes: 5 additions & 0 deletions src/ExposeIntrinsicsToGTest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#if GOMC_GTEST
MoleculeLookup & GetMolLookup(){
return system->molLookup;
}
#endif
6 changes: 6 additions & 0 deletions src/Simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,9 @@ bool Simulation::RecalculateAndCheck(void)

return compare;
}

#if GOMC_GTEST
MoleculeLookup & Simulation::GetMolLookup(){
return system->molLookup;
}
#endif
5 changes: 3 additions & 2 deletions src/Simulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ along with this program, also can be found at <http://www.gnu.org/licenses/>.
********************************************************************************/
#ifndef SIMULATION_H
#define SIMULATION_H

//Member vars
#include "CPUSide.h"
#include "System.h"
Expand All @@ -24,7 +23,9 @@ class Simulation

void RunSimulation(void);
bool RecalculateAndCheck(void);

#if GOMC_GTEST
MoleculeLookup & GetMolLookup();
#endif
private:
StaticVals * staticValues;
System * system;
Expand Down
1 change: 1 addition & 0 deletions test/FileList.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set(TestSources
test/src/CircuitTester.cpp
test/src/PSFParserTest.cpp
test/src/ConsistentTrajectoryTest.cpp
test/src/CheckpointTest.cpp
)

set(TestHeaders
Expand Down
2 changes: 2 additions & 0 deletions test/GoogleTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function(add_GCMC_test name)
add_test(NAME MolLookupTest_GCMC COMMAND CheckConsensusBeta)
#add_test(NAME PSFParserTest_GCMC COMMAND CheckProtAndWaterTest)
add_test(NAME ConsistentTrajectoryTest_GCMC COMMAND CheckPDBTrajCoordinates)
add_test(NAME CheckpointTest_GCMC COMMAND CheckMollookup)
add_test(NAME EndianTest_GCMC COMMAND TestBitSwap)
endfunction(add_GCMC_test)

Expand All @@ -55,6 +56,7 @@ function(add_GEMC_test name)
add_test(NAME MolLookupTest_GEMC COMMAND CheckConsensusBeta)
#add_test(NAME PSFParserTest_GEMC COMMAND CheckProtAndWaterTest)
add_test(NAME ConsistentTrajectoryTest_GEMC COMMAND CheckPDBTrajCoordinates)
add_test(NAME CheckpointTest_GEMC COMMAND CheckMollookup)
add_test(NAME EndianTest_GEMC COMMAND TestBitSwap)
endfunction(add_GEMC_test)

Expand Down
39 changes: 39 additions & 0 deletions test/src/CheckpointTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <gtest/gtest.h>
#include "PDBSetup.h"
#include "MolSetup.h"
#include "BondAdjacencyList.h"
#include "ConfigSetup.h"
#include "FFSetup.h" //For geometry kinds
#include "FFConst.h"
#include "Reader.h"
#include "InputFileReader.h"
#include "Simulation.h"
#include<unistd.h>
/* There are 4 cases for restarting from checkpoint
1) Base Case:
The first run.
Checkpoint Setup - RestartFromCheckpoint = false
Checkpoint Output - RestartFromCheckpoint = false
2) The first restart from checkpoint
Checkpoint Setup - RestartFromCheckpoint = true
Checkpoint Output - RestartFromCheckpoint = true
3) The Nth restart from checkpoint from a prev checkpoint
Checkpoint Setup - RestartFromCheckpoint = true
Checkpoint Output - RestartFromCheckpoint = true
*/
TEST(CheckpointTest, CheckAR_KR) {
chdir("./test/input/Checkpoint/AR_KR/Base/");
Simulation base("in.conf");
base.RunSimulation();
chdir("../K_1");
Simulation K_1("in.conf");
K_1.RunSimulation();
chdir("../K_N");
Simulation K_N("in.conf");
K_N.RunSimulation();
chdir("../../../../..");
}

0 comments on commit 4367b87

Please sign in to comment.