#include "sample.hpp" #include #include sample::sample(double Lx, double Ly, double beta) { std::string filename = "fracture_" + std::to_string(Lx) + "_" + std::to_string(Ly) + "_" + std::to_string(beta) + "_sample.dat"; sample_file.open(filename, std::ifstream::app); } sample::~sample() { sample_file.close(); } void sample::pre_fracture(const network& n) { sample_file << "<|"; sample_file << "\"vr\"->{"; for (const graph::vertex &v : n.G.vertices) { sample_file <{"; for (const graph::vertex &v : n.G.vertices) { sample_file << "{"; for (const graph::coordinate &r : v.polygon) { sample_file <{"; for (const graph::vertex &v : n.G.dual_vertices) { sample_file <{"; for (const graph::vertex &v : n.G.dual_vertices) { sample_file << "{"; for (const graph::coordinate &r : v.polygon) { sample_file <{"; for (const graph::edge &e : n.G.edges) { sample_file << "{" << e.v[0] << "," << e.v[1] << "},"; } sample_file << "},\"ec\"->{"; for (const graph::edge &e : n.G.edges) { sample_file << "{" << e.crossings[0] << "," << e.crossings[1] << "},"; } sample_file << "},\"d\"->{"; for (const graph::edge &e : n.G.dual_edges) { sample_file << "{" << e.v[0] << "," << e.v[1] << "},"; } sample_file << "},\"dc\"->{"; for (const graph::edge &e : n.G.dual_edges) { sample_file << "{" << e.crossings[0] << "," << e.crossings[1] << "},"; } sample_file << "},\"data\"->{"; } void sample::bond_broken(const network& net, const current_info& cur, unsigned i) { long double c = logl(cur.conductivity[0] / fabs(cur.currents[i])) + net.thresholds[i]; sample_file << "{" << i << "," << c << "," << cur.conductivity[0] << "},"; } void sample::post_fracture(network &n) { sample_file << "}"; sample_file << "|>\n"; }