Skip to content

Commit

Permalink
Merge pull request #36 from AlexJamesWright/save_seed
Browse files Browse the repository at this point in the history
Interface update
  • Loading branch information
aniabrown committed Mar 26, 2021
2 parents e060205 + 46345e6 commit 89917b2
Show file tree
Hide file tree
Showing 30 changed files with 879 additions and 150 deletions.
16 changes: 14 additions & 2 deletions Examples/KelvinHelmholtz/SingleFluidIdealRandomMPIHDF5/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,27 @@ int main(int argc, char *argv[]) {
bool output(false);
if (argc != 2) throw std::invalid_argument("Expected ./main seed!\n");
int seed(atoi(argv[1]));
int reportItersPeriod(50);

double nxRanks(2);
double nyRanks(2);
double nzRanks(1);

ParallelEnv env(&argc, &argv, nxRanks, nyRanks, nzRanks);

Data data(nx, ny, nz, xmin, xmax, ymin, ymax, zmin, zmax, endTime, &env,
cfl, Ng, gamma, sigma, cp, mu1, mu2, frameSkip);
const int nOptionalSimArgs = 1;
std::vector<double> optionalSimArgs = {seed};
std::vector<std::string> optionalSimArgNames = {"seed"};

// Create an arg object that will contain all parameters needed by the simulation, that will be stored on the Data object.
// The DataArgs constructor takes those parameters that are required rather than optional.
// The chained setter functions can be used to set any of the optional parameters. They can be used in any order and default
// values will be used for any parameters that are not set
DataArgs dataArgs = DataArgs(nx, ny, nz, xmin, xmax, ymin, ymax, zmin, zmax, endTime)
.sCfl(cfl).sNg(Ng).sGamma(gamma).sCp(cp).sMu1(mu1).sMu2(mu2).sFrameSkip(frameSkip).sSigma(sigma)
.sReportItersPeriod(reportItersPeriod).sOptionalSimArgs(optionalSimArgs, optionalSimArgNames, nOptionalSimArgs);

Data data = Data(dataArgs, &env);

// Choose particulars of simulation
SRMHD model(&data);
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ int main(int argc, char *argv[]) {
double ymax(1.0);
double zmin(0.0);
double zmax(1.0);
double endTime(3.0);
//double endTime(3.0);
double endTime(0.01);
double cfl(0.6);
double gamma(4.0/3.0);
double sigma(10);
Expand All @@ -43,16 +44,16 @@ int main(int argc, char *argv[]) {

ParallelEnv env(&argc, &argv, 2, 2, 1);

//const char* filename = "data_t3.checkpoint.hdf5";
const char* filename = "data_t0.checkpoint.hdf5";

//Data data(nx, ny, nz, xmin, xmax, ymin, ymax, zmin, zmax, endTime, &env,
//cfl, Ng, gamma, sigma, cp, mu1, mu2, frameSkip, reportItersPeriod);
// Create an arg object that will contain all parameters needed by the simulation, that will be stored on the Data object.
// ParallelCheckpointArgs sets those parameters that can be read from the restart file, while the chained setter functions
// that follow can be used to set the additional variables that are not stored in the restart file, as well as override
// any other variables (should only need to overwrite endTime when starting from a restart file)
ParallelCheckpointArgs checkpointArgs = ParallelCheckpointArgs(filename, &env).sEndTime(endTime)
.sMu1(mu1).sMu2(mu2).sFrameSkip(frameSkip).sReportItersPeriod(reportItersPeriod);

ParallelCheckpointArgs checkpointArgs(filename, &env);
checkpointArgs.endTime=endTime;

Data data(checkpointArgs, &env, mu1, mu2, frameSkip, reportItersPeriod);
Data data = Data(checkpointArgs, &env);

// Choose particulars of simulation
SRMHD model(&data);
Expand All @@ -67,11 +68,11 @@ int main(int argc, char *argv[]) {

printf("Seed: %d\n", seed);

KHRandomInstabilitySingleFluid init(&data, 1, seed);
//ParallelCheckpointRestart init(&data, filename, &env);

//KHRandomInstabilitySingleFluid init(&data, 1, seed);
ParallelCheckpointRestart init(&data, filename, &env);
RKSplit timeInt(&data, &model, &bcs, &fluxMethod);

ParallelSaveDataHDF5 save(&data, &env, "data_parallel", ParallelSaveDataHDF5::OUTPUT_ALL);

// Now objects have been created, set up the simulation
Expand Down
24 changes: 21 additions & 3 deletions Examples/KelvinHelmholtz/SingleFluidIdealRandomSerialHDF5/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "serialSaveDataHDF5.h"
#include "weno.h"
#include <cstring>
#include <vector>
#include <string>

using namespace std;

Expand All @@ -27,7 +29,7 @@ int main(int argc, char *argv[]) {
double zmin(0.0);
double zmax(1.0);
//double endTime(3.0);
double endTime(0.0);
double endTime(0.01);
double cfl(0.6);
double gamma(4.0/3.0);
double sigma(10);
Expand All @@ -42,8 +44,24 @@ int main(int argc, char *argv[]) {

SerialEnv env(&argc, &argv, 1, 1, 1);

Data data(nx, ny, nz, xmin, xmax, ymin, ymax, zmin, zmax, endTime, &env,
cfl, Ng, gamma, sigma, cp, mu1, mu2, frameSkip, reportItersPeriod);
const int nOptionalSimArgs = 1;
std::vector<double> optionalSimArgs = {seed};
std::vector<std::string> optionalSimArgNames = {"seed"};

// Create an arg object that will contain all parameters needed by the simulation, that will be stored on the Data object.
// The DataArgs constructor takes those parameters that are required rather than optional.
// The chained setter functions can be used to set any of the optional parameters. They can be used in any order and default
// values will be used for any parameters that are not set
DataArgs dataArgs = DataArgs(nx, ny, nz, xmin, xmax, ymin, ymax, zmin, zmax, endTime)
.sCfl(cfl).sNg(Ng).sGamma(gamma).sCp(cp).sMu1(mu1).sMu2(mu2).sFrameSkip(frameSkip).sSigma(sigma)
.sReportItersPeriod(reportItersPeriod).sOptionalSimArgs(optionalSimArgs, optionalSimArgNames, nOptionalSimArgs);

Data data = Data(dataArgs, &env);

// The following is an example of creating the Data object without using named parameters -- in this case vars must be specified
// in order and all optional parameters before the last optional parameter of interest must be listed
//Data data(nx, ny, nz, xmin, xmax, ymin, ymax, zmin, zmax, endTime, &env,
//cfl, Ng, gamma, sigma, cp, mu1, mu2, frameSkip, reportItersPeriod);

// Choose particulars of simulation
SRMHD model(&data);
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
#include "serialEnv.h"
#include "serialSaveDataHDF5.h"
#include "weno.h"
#include <cstring>
#include <string>
#include <vector>

using namespace std;

Expand All @@ -28,7 +29,8 @@ int main(int argc, char *argv[]) {
double ymax(1.0);
double zmin(0.0);
double zmax(1.0);
double endTime(3.0);
//double endTime(3.0);
double endTime(0.01);
double cfl(0.6);
double gamma(4.0/3.0);
double sigma(10);
Expand All @@ -43,16 +45,21 @@ int main(int argc, char *argv[]) {

SerialEnv env(&argc, &argv, 1, 1, 1);

//const char* filename = "data_t3.checkpoint.hdf5";
const char* filename = "data_t0.checkpoint.hdf5";

//Data data(nx, ny, nz, xmin, xmax, ymin, ymax, zmin, zmax, endTime, &env,
// cfl, Ng, gamma, sigma, cp, mu1, mu2, frameSkip, reportItersPeriod);

SerialCheckpointArgs checkpointArgs(filename, &env);
checkpointArgs.endTime=endTime;

Data data(checkpointArgs, &env, mu1, mu2, frameSkip, reportItersPeriod);
const int nOptionalSimArgs = 1;
std::vector<double> optionalSimArgs = {seed};
std::vector<std::string> optionalSimArgNames = {"seed"};

// Create an arg object that will contain all parameters needed by the simulation, that will be stored on the Data object.
// SerialCheckpointArgs sets those parameters that can be read from the restart file, while the chained setter functions
// that follow can be used to set the additional variables that are not stored in the restart file, as well as override
// any other variables (should only need to overwrite endTime when starting from a restart file)
SerialCheckpointArgs checkpointArgs = SerialCheckpointArgs(filename, &env).sEndTime(endTime)
.sMu1(mu1).sMu2(mu2).sFrameSkip(frameSkip).sReportItersPeriod(reportItersPeriod);
//.sOptionalSimArgs(optionalSimArgs, optionalSimArgNames, nOptionalSimArgs);

Data data = Data(checkpointArgs, &env);

// Choose particulars of simulation
SRMHD model(&data);
Expand Down
63 changes: 0 additions & 63 deletions Project/CPU/Include/checkpointArgs.h

This file was deleted.

Loading

0 comments on commit 89917b2

Please sign in to comment.