Trilinos based (stochastic) FEM solvers
readnrldata.cpp
Go to the documentation of this file.
1 /*
2 Brian Staber (brian.staber@gmail.com)
3 */
4 
5 #include "readnrldata.hpp"
6 #include <math.h>
7 
8 readnrldata::readnrldata(bool load, std::string & path){
9  if(load){
11  import_exp_points(path);
12  //import_expenergy(path);
13  //import_exp_def(path);
14  angles.Resize(8);
15  angles(0) = 30.0;
16  angles(1) = 60.0;
17  angles(2) = 60.0;
18  angles(3) = 30.0;
19  angles(4) = 15.0;
20  angles(5) = 15.0;
21  angles(6) = 75.0;
22  angles(7) = 75.0;
23  }
24 }
25 
27 }
28 
29 void readnrldata::import_boundaryconditions(std::string & path){
30  //std::string filename = "/Users/brian/Documents/GitHub/Trilinos_results/nrl/data/dirichletbcs.txt";
31  //std::string filename = "/home/s/staber/Trilinos_results/nrl/data/dirichletbcs.txt";
32  std::string filename = path + "dirichletbcs.txt";
33  std::ifstream file;
34  double gbc;
35  file.open(filename);
36  if (file.is_open()){
37  file >> nloads;
38  boundaryconditions.Resize(nloads);
39  for (unsigned int i=0; i<nloads; ++i){
40  file >> gbc;
41  boundaryconditions(i) = gbc;
42  }
43  file.close();
44  }
45  else{
46  std::cout << "Couldn't open the file containing the boundary conditions.\n";
47  }
48 
49 /* filename = path + "linspace.txt";
50  file.open(filename);
51  if (file.is_open()){
52  linspace.Resize(nloads);
53  for (unsigned int i=0; i<nloads; ++i){
54  file >> gbc;
55  linspace(i) = gbc;
56  }
57  }
58 */
59 }
60 
61 void readnrldata::import_expenergy(std::string & path){
62  //std::string path = "/Users/brian/Documents/GitHub/Trilinos_results/nrl/data/expenergy.txt";
63  //std::string path = "/home/s/staber/Trilinos_results/nrl/data/expenergy.txt";
64  std::string filename = path + "expenergy.txt";
65  std::ifstream file;
66  double gen;
67  file.open(filename);
68  if (file.is_open()){
69  energy.Reshape(nloads,8);
70  for (unsigned int i=0; i<nloads; ++i){
71  for (unsigned int j=0; j<8; ++j){
72  file >> gen;
73  energy(i,j) = gen;
74  }
75  }
76  file.close();
77  }
78  else{
79  std::cout << "Couldn't open the file containing the experimental energies.\n";
80  }
81 }
82 
83 void readnrldata::import_exp_points(std::string & path){
84  double x,y,z;
85  //std::string filename = "/Users/brian/Documents/GitHub/Trilinos_results/nrl/data/xyz.txt";
86  //std::string filename = "/home/s/staber/Trilinos_results/nrl/data/xyz.txt";
87  std::string filename = path + "xyz.txt";
88  std::ifstream file;
89  file.open(filename);
90  if (file.is_open()){
91  file >> npoints;
92  points.Reshape(npoints,3);
93  for (unsigned int i=0; i<npoints; ++i){
94  file >> x;
95  file >> y;
96  file >> z;
97  points(i,0) = x;
98  points(i,1) = y;
99  points(i,2) = z;
100  }
101  file.close();
102  }
103  else{
104  std::cout << "Couldn't open the file containing the locations of the experimental points.\n";
105  }
106 }
107 
108 void readnrldata::import_exp_def(std::string & path){
109  //std::string path = "/Users/brian/Documents/GitHub/Trilinos_results/nrl/data/";
110  //std::string path = "/home/s/staber/Trilinos_results/nrl/data/";
111  double gexx,geyy,gexy;
112  for (unsigned int id=0; id<8; ++id){
113  std::string path_exx = path + "exx_id" + std::to_string(id+1) + ".txt";
114  std::string path_eyy = path + "eyy_id" + std::to_string(id+1) + ".txt";
115  std::string path_exy = path + "exy_id" + std::to_string(id+1) + ".txt";
116  std::ifstream file_exx,file_eyy,file_exy;
117  file_exx.open(path_exx); file_eyy.open(path_eyy); file_exy.open(path_exy);
118  exx.Reshape(nloads*npoints,8); eyy.Reshape(nloads*npoints,8); exy.Reshape(nloads*npoints,8);
119  if (file_exx.is_open() && file_eyy.is_open() && file_exy.is_open()){
120  for (unsigned int t=0; t<nloads; ++t){
121  for (unsigned int j=0; j<npoints; ++j){
122  file_exx >> gexx; file_eyy >> geyy; file_exy >> gexy;
123  exx(j+t*npoints,id) = gexx; eyy(j+t*npoints,id) = geyy; exy(j+t*npoints,id) = gexy;
124  }
125  }
126 
127  }
128  else{
129  std::cout << "Couldn't open one or some of the eij files.\n";
130  }
131  }
132 }
void import_exp_points(std::string &path)
Definition: readnrldata.cpp:83
for j
Definition: costFunction.m:42
load('/home/s/staber/Trilinos_results/nrl/data/eij.mat')
Epetra_SerialDenseMatrix eyy
Definition: readnrldata.hpp:24
void import_exp_def(std::string &path)
Epetra_SerialDenseMatrix exy
Definition: readnrldata.hpp:24
readnrldata(bool load, std::string &path)
Definition: readnrldata.cpp:8
Epetra_SerialDenseVector boundaryconditions
Definition: readnrldata.hpp:25
filename
Definition: costFunction.m:44
void import_expenergy(std::string &path)
Definition: readnrldata.cpp:61
Epetra_SerialDenseVector angles
Definition: readnrldata.hpp:25
Epetra_SerialDenseMatrix energy
Definition: readnrldata.hpp:24
Epetra_SerialDenseMatrix points
Definition: readnrldata.hpp:24
void import_boundaryconditions(std::string &path)
Definition: readnrldata.cpp:29
for i
Definition: costFunction.m:38
t
Definition: run.m:7
Epetra_SerialDenseMatrix exx
Definition: readnrldata.hpp:24