-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoutput_system.cpp
More file actions
137 lines (124 loc) · 5.25 KB
/
output_system.cpp
File metadata and controls
137 lines (124 loc) · 5.25 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#include <iostream>
#include <fstream>
#include <random>
#include <algorithm>
#include <math.h>
#include <ctime>
#include <string>
#include <vector>
#include "omp.h"
#include <mpi.h>
#include <iomanip>
#include <chrono>
#include "membrane_mc.hpp"
#include "output_system.hpp"
using namespace std;
OutputSystem::OutputSystem() {
// Constructor
// Does nothing
}
OutputSystem::~OutputSystem() {
// Destructor
// Does nothing
}
void OutputSystem::OutputTriangulation(MembraneMC& sys, string name) {
// Commands to speed things up
// turns off synchronization of C++ streams
ios_base::sync_with_stdio(false);
// Turns off flushing of out before in
cin.tie(NULL);
ofstream myfile;
myfile.open(sys.output_path+"/"+name);
myfile.precision(17);
myfile << "Length_x " << std::scientific << sys.lengths[0] << " Length_y " << std::scientific << sys.lengths[1] << " Length_z " << std::scientific << sys.lengths[2] << " count_step " << sys.count_step << endl;
myfile << sys.vertices << " " << sys.faces << " " << 0 << endl;
myfile << endl;
// Input radius values
for(int i=0; i<sys.vertices; i++){
myfile << sys.ising_array[i] << " " << std::scientific << sys.lengths[0]*sys.radii_tri[i][0] << " " << std::scientific << sys.lengths[1]*sys.radii_tri[i][1] << " " << std::scientific << sys.radii_tri[i][2] << "\n";
}
// Skip 2 lines
for(int i=0; i<2; i++){
myfile << "\n";
}
// Input triangle connectivity
for(int i=0; i<sys.faces; i++){
myfile << sys.triangle_list[i][0] << " " << sys.triangle_list[i][1] << " " << sys.triangle_list[i][2] << "\n";
}
myfile.close();
}
void OutputSystem::OutputTriangulationAppend(MembraneMC& sys, string name) {
// Commands to speed things up
// turns off synchronization of C++ streams
ios_base::sync_with_stdio(false);
// Turns off flushing of out before in
cin.tie(NULL);
ofstream myfile;
myfile.open(sys.output_path+"/"+name, std::ios_base::app);
myfile << "sys.lengths[0] " << std::scientific << sys.lengths[0] << " sys.lengths[1] " << std::scientific << sys.lengths[1] << " sys.lengths[2] " << std::scientific << sys.lengths[2] << " count_step " << sys.count_step << endl;
myfile << sys.vertices << " " << sys.faces << " " << 0 << endl;
myfile << endl;
for(int i=0; i<sys.vertices; i++){
myfile << sys.ising_array[i] << " " << std::scientific << sys.lengths[0]*sys.radii_tri[i][0] << " " << std::scientific << sys.lengths[1]*sys.radii_tri[i][1] << " " << std::scientific << sys.radii_tri[i][2] << "\n";
}
// Skip 2 lines
for(int i=0; i<2; i++){
myfile << "\n";
}
// Input triangle connectivity
for(int i=0; i<sys.faces; i++){
myfile << sys.triangle_list[i][0] << " " << sys.triangle_list[i][1] << " " << sys.triangle_list[i][2] << "\n";
}
myfile.close();
}
void OutputSystem::OutputTriangulationStorage(MembraneMC& sys) {
ofstream myfile;
myfile.open (sys.output_path+"/triangle_list.txt", std::ios_base::app);
for(int i=0; i<sys.faces; i++){
myfile << "For face " << i << " the points are " << sys.triangle_list[i][0] << " " << sys.triangle_list[i][1] << " " << sys.triangle_list[i][2] << endl;
}
myfile.close();
myfile.open (sys.output_path+"/max_numbers.txt", std::ios_base::app);
for(int i=0; i<sys.vertices; i++) {
myfile << "Max neighbors at " << i << " is " << sys.point_neighbor_list[i].size() << endl;
myfile << "Max triangles at " << i << " is " << sys.point_triangle_list[i].size() << endl;
}
myfile.close();
myfile.open (sys.output_path+"/point_neighbor_list.txt", std::ios_base::app);
for(int i=0; i<sys.vertices; i++) {
myfile << "Neighbor list at vertex " << i << " is given by : ";
for(int j=0; j<sys.point_neighbor_list[i].size(); j++){
myfile << sys.point_neighbor_list[i][j] << " ";
}
myfile << endl;
}
myfile.close();
myfile.open (sys.output_path+"/point_triangle_list.txt", std::ios_base::app);
for(int i=0; i<sys.vertices; i++) {
myfile << "Triangle list at vertex " << i << " is given by ";
for(int j=0; j<sys.point_triangle_list[i].size(); j++) {
myfile << sys.point_triangle_list[i][j] << " ";
}
myfile << endl;
}
myfile.close();
}
void OutputSystem::DumpXYZConfig(MembraneMC& sys, string name) {
// Commands to speed things up
// turns off synchronization of C++ streams
ios_base::sync_with_stdio(false);
// Turns off flushing of out before in
cin.tie(NULL);
ofstream myfile;
myfile.precision(6);
myfile.open (sys.output_path+"/"+name, std::ios_base::app);
myfile << sys.vertices << endl;
myfile << "Lattice=\"" << sys.lengths[0] << " 0.0 0.0 0.0 " << sys.lengths[1] << " 0.0 0.0 0.0 " << sys.lengths[2] << "\" ";
myfile << "Origin=\"" << -0.5*sys.lengths[0] << " " << -0.5*sys.lengths[1] << " " << -0.5*sys.lengths[2] << "\" ";
myfile << "Properties=species:S:1:pos:R:3 ";
myfile << "Time=" << sys.count_step << "\n";
for(int i=0; i < sys.vertices; i++) {
myfile << " " << sys.ising_array[i] << " " << std::scientific << sys.lengths[0]*sys.radii_tri[i][0] << " " << std::scientific << sys.lengths[1]*sys.radii_tri[i][1] << " " << std::scientific << sys.radii_tri[i][2] << "\n";
}
myfile.close();
}