Skip to content

Commit e8895e7

Browse files
authored
modified way to provide microstructure input in json (#43)
* modified way to provide microstructure input in json * modified the path where results would be written to h5 file
1 parent 9570e40 commit e8895e7

File tree

8 files changed

+31
-20
lines changed

8 files changed

+31
-20
lines changed

include/reader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class Reader {
1818
json materialProperties;
1919
double TOL;
2020
json errorParameters;
21+
json microstructure;
2122
int n_it;
2223
vector<vector<vector<double>>> g0;
2324
string problemType;

include/solver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ void Solver<howmany>::postprocess(Reader reader, const char resultsFileName[], i
464464
}
465465

466466
// Concatenate reader.ms_datasetname and reader.results_prefix into reader.ms_datasetname
467-
strcat(reader.ms_datasetname, "/");
467+
strcat(reader.ms_datasetname, "_results/");
468468
strcat(reader.ms_datasetname, reader.results_prefix);
469469

470470
// Write results to results h5 file

src/reader.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,17 @@ void Reader ::ReadInputFile(char fn[])
6060
json j;
6161
i >> j;
6262

63-
strcpy(ms_filename, j["ms_filename"].get<string>().c_str());
64-
strcpy(ms_datasetname, j["ms_datasetname"].get<string>().c_str());
63+
microstructure = j["microstructure"];
64+
strcpy(ms_filename, microstructure["filepath"].get<string>().c_str());
65+
strcpy(ms_datasetname, microstructure["datasetname"].get<string>().c_str());
66+
L = microstructure["L"].get<vector<double>>();
6567

6668
if (j.contains("results_prefix")) {
6769
strcpy(results_prefix, j["results_prefix"].get<string>().c_str());
6870
} else {
6971
strcpy(results_prefix, "");
7072
}
7173

72-
L = j["ms_L"].get<vector<double>>();
73-
7474
errorParameters = j["error_parameters"];
7575
TOL = errorParameters["tolerance"].get<double>();
7676
n_it = j["n_it"].get<int>();

test/input_files/test_J2Plasticity.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
2-
"ms_filename": "microstructures/sphere32.h5",
3-
"ms_datasetname": "/sphere/32x32x32/ms",
4-
"ms_L": [1.0, 1.0, 1.0],
2+
"microstructure": {
3+
"filepath": "microstructures/sphere32.h5",
4+
"datasetname": "/sphere/32x32x32/ms",
5+
"L": [1.0, 1.0, 1.0]
6+
},
57

68
"problem_type": "mechanical",
79
"matmodel": "J2ViscoPlastic_NonLinearIsotropicHardening",

test/input_files/test_LinearElastic.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
2-
"ms_filename": "microstructures/sphere32.h5",
3-
"ms_datasetname": "/sphere/32x32x32/ms",
4-
"ms_L": [1.0, 1.0, 1.0],
2+
"microstructure": {
3+
"filepath": "microstructures/sphere32.h5",
4+
"datasetname": "/sphere/32x32x32/ms",
5+
"L": [1.0, 1.0, 1.0]
6+
},
57

68
"problem_type": "mechanical",
79
"matmodel": "LinearElasticIsotropic",

test/input_files/test_LinearThermal.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
2-
"ms_filename": "microstructures/sphere32.h5",
3-
"ms_datasetname": "/sphere/32x32x32/ms",
4-
"ms_L": [1.0, 1.0, 1.0],
2+
"microstructure": {
3+
"filepath": "microstructures/sphere32.h5",
4+
"datasetname": "/sphere/32x32x32/ms",
5+
"L": [1.0, 1.0, 1.0]
6+
},
57

68
"problem_type": "thermal",
79
"matmodel": "LinearThermalIsotropic",

test/input_files/test_PseudoPlastic.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
2-
"ms_filename": "microstructures/sphere32.h5",
3-
"ms_datasetname": "/sphere/32x32x32/ms",
4-
"ms_L": [1.0, 1.0, 1.0],
2+
"microstructure": {
3+
"filepath": "microstructures/sphere32.h5",
4+
"datasetname": "/sphere/32x32x32/ms",
5+
"L": [1.0, 1.0, 1.0]
6+
},
57

68
"problem_type": "mechanical",
79
"matmodel": "PseudoPlasticNonLinearHardening",

test/test_pyfans/input.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
2-
"ms_filename": "../microstructures/sphere32.h5",
3-
"ms_datasetname": "/sphere/32x32x32/ms",
4-
"ms_L": [1.0, 1.0, 1.0],
2+
"microstructure": {
3+
"filepath": "../microstructures/sphere32.h5",
4+
"datasetname": "/sphere/32x32x32/ms",
5+
"L": [1.0, 1.0, 1.0]
6+
},
57

68
"problem_type": "mechanical",
79
"matmodel": "LinearElasticIsotropic",

0 commit comments

Comments
 (0)