MDStressLab++
main.cpp
Go to the documentation of this file.
1 /*
2  * main.cpp
3  *
4  * Created on: Nov 3, 2019
5  * Author: Nikhil Admal
6  */
7 #include "MethodSphere.h"
8 #include <string>
9 #include <iostream>
10 #include <tuple>
11 #include <fstream>
12 #include "BoxConfiguration.h"
13 #include "calculateStress.h"
14 #include "Grid.h"
15 #include "typedef.h"
16 
17 
18 int main()
19 {
20  int numberOfParticles;
21  int referenceAndFinal= true;
22  std::string configFileName= "config.data";
23  std::string modelname= "SW_BalamaneHauchShi_2017Brittle_Si__MO_381114941873_002";
24 
25 // -------------------------------------------------------------------
26 // Input configuration and potential
27 // -------------------------------------------------------------------
28 
29  std::ifstream file(configFileName);
30  if(!file) MY_ERROR("ERROR: config.dat could not be opened for reading!");
31 
32  file >> numberOfParticles;
33  if (numberOfParticles < 0) MY_ERROR("Error: Negative number of particles.\n");
34 
35  BoxConfiguration body{numberOfParticles,referenceAndFinal};
36  body.read(configFileName,referenceAndFinal);
37 
38  Kim kim(modelname);
39 
40 // -------------------------------------------------------------------
41 // Create grid
42 // -------------------------------------------------------------------
43  int ngrid;
44  ngrid= 90601;
45  Grid<Current> gridFromFile(ngrid);
46  gridFromFile.read("grid_cauchy.data");
47 
48 
49 // -------------------------------------------------------------------
50 // Calculate stress on the grid
51 // -------------------------------------------------------------------
52  // Create hardyStress object
53 
54  // Hardy stress
55  MethodSphere hardy5(5,"hardy");
56  MethodSphere hardy10(10,"hardy");
57  MethodSphere hardy15(15,"hardy");
58  MethodSphere hardy20(20,"hardy");
59 
60  Stress<MethodSphere,Cauchy> hardyStress5("hardy5",hardy5,&gridFromFile);
61  Stress<MethodSphere,Cauchy> hardyStress10("hardy10",hardy10,&gridFromFile);
62  Stress<MethodSphere,Cauchy> hardyStress15("hardy15",hardy15,&gridFromFile);
63  Stress<MethodSphere,Cauchy> hardyStress20("hardy20",hardy20,&gridFromFile);
64 
65  calculateStress(body,kim,
66  std::tie(),
67  std::tie(hardyStress5,hardyStress10,hardyStress15,hardyStress20));
68  hardyStress5.write();
69  hardyStress10.write();
70  hardyStress15.write();
71  hardyStress20.write();
72 
73 
74  return 0;
75 }
76 
77 
void read(std::string)
Definition: Grid.cpp:134
Definition: Grid.h:31
void read(std::string, int)
Definition: kim.h:17
int main()
Definition: main.cpp:18
void write()
Definition: Stress.h:46
Definition: Stress.h:23
#define MY_ERROR(message)
Definition: typedef.h:17
int calculateStress(const BoxConfiguration &body, Kim &kim, std::tuple<> stress)