-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread_json.cpp
More file actions
35 lines (35 loc) · 1.22 KB
/
read_json.cpp
File metadata and controls
35 lines (35 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//
#include "main.h"
//
void read_json(string nam, MatrixXd& nds, MatrixXi& els, int *gss, MatrixXd& mat, string& mat_aux, MatrixXd& bds, MatrixXd& lds)
{
//
std::ifstream f(nam);
json data = json::parse(f);
//
int nds_r = data["nodes"].size();
int nds_c = data["nodes"][0].size();
int els_r = data["elements"].size();
int els_c = data["elements"][0].size();
int mat_e = data["material"].size()-1;
int bds_r = data["boundary"].size();
int bds_c = data["boundary"][0].size();
int lds_r = data["load"].size();
int lds_c = data["load"][0].size();
//
nds.resize(nds_r,nds_c);
for(int j = 0; j < nds_r; j++){for(int i = 0; i < nds_c; i++){ nds(j,i) = data["nodes"][j][i];}}
els.resize(els_r,els_c);
for(int j = 0; j < els_r; j++){for(int i = 0; i < els_c; i++){ els(j,i) = data["elements"][j][i];}}
mat.resize(1,mat_e);
for(int j = 0; j < mat_e; j++){mat(0,j) = data["material"][j];}
mat_aux = data["material"][mat_e];
bds.resize(bds_r,bds_c);
for(int j = 0; j < bds_r; j++){for(int i = 0; i < bds_c; i++){ bds(j,i) = data["boundary"][j][i];}}
lds.resize(lds_r,lds_c);
for(int j = 0; j < lds_r; j++){for(int i = 0; i < lds_c; i++){ lds(j,i) = data["load"][j][i];}}
//
*gss = data["gauss"];
//
}
//