GraphNet: Discrete element modeling for network connected materials
Applications to polymeric networks
network.h
Go to the documentation of this file.
1 #ifndef NETWORK_H
2 #define NETWORK_H
3 #include <iostream>
4 #include <cmath>
5 #include <cstdlib>
6 #include <math.h>
7 #include <random>
8 #include <time.h>
9 #include <vector>
10 #include <unistd.h>
11 #include <algorithm>
12 #include <ctime>
13 #include <chrono>
14 #include <fstream>
15 #include <sstream>
16 #include <string>
17 #include <cstring>
18 #include <stddef.h>
19 #include "vel.h"
20 
27 #include "helper_funcs.h"
28 #include "crack.h"
29 using namespace std;
30 
31 const float PBC_vector[DIM] = {MAXBOUND_X*1.1, 0};
32 const float vel[DIM] = {vel_x, vel_y};
33 
34 class Network {
46 public:
47  Network();
48  Network(Network const & source);
49  Network(string& fname, bool from_dump = false);
50  virtual ~Network();
51  Network const & operator=(Network const & other);
52  virtual void build_network();
53  void side_nodes(float max_x = MAXBOUND_X, float max_y = MAXBOUND_Y);
54  void remove_duplicates(int&);
55  // add long range edges in the network
56  void add_long_range_egdes_y(int, float);
57  void add_long_range_egdes_random(int, float);
58  void load_from_dump(string&);
59  void apply_crack(Cracklist &);
60  virtual void load_network(string&);
61  virtual void malloc_network();
62  void make_edge_connections(float dely_allowed = 10.0);
63  virtual void get_forces(bool);
64  virtual void move_top_plate();
65  virtual void get_plate_forces(float*, int);
66  virtual void optimize(float eta = 0.1, float alpha = 0.9, int max_iter = 800);
67  virtual void qd_optimize(float C = 0.001, int max_iter = 800);
68 
69 
70  float get_weight();
71  float set_weight(float);
72  bool get_stats(float force_threshold = 1000.0);
73  int get_current_edges();
74  virtual void plotNetwork(int, bool);
75  virtual void clear();
76  void copy(Network const & source);
77  void dump(int,bool first_time = false);
78 
79  bool cracked;
80  int n_nodes;
81  int n_elems;
82 
83  int n_rside;
84  int n_lside;
85  int n_bside;
86  int n_tside;
87 
88  float * R;
89  int * edges;
90 
91  float * forces;
92  float * damage;
93  float * L;
94  bool* PBC;
95 
96  int* lsideNodes;
97  int* rsideNodes;
98  int* tsideNodes;
99  int* bsideNodes;
100 
101  bool initialized;
102 
103  float __init_force;
104 
105  float weight_multiplier = 1.0;
106  int iter_offset = 0;
107  //add moving nodes to speed up force
109  int n_moving;
110 };
111 
112 #endif
Definition: crack.h:36
int n_lside
Stores number of crosslinker nodes on the left edge of the network sample.
Definition: network.h:84
float * forces
Stores the forces on all nodes of the network in a flat n_nodes*DIM size array.
Definition: network.h:91
float * R
Stores the position of all nodes of the graph in a flat n_nodes*DIM size array.
Definition: network.h:88
int * rsideNodes
Stores index of crosslinker nodes on the right edge of the network sample.
Definition: network.h:97
#define vel_y
Definition: vel.h:9
int * edges
Stores the i,j pairs that form edges, size is n_elems*2.
Definition: network.h:89
const float PBC_vector[DIM]
Definition: network.h:31
#define vel_x
Definition: vel.h:8
float * L
Stores the contour length of the edge.
Definition: network.h:93
int * moving_nodes
Stores index of all nodes where no boundary condition is applied (i.e. they participate in optimizati...
Definition: network.h:108
Definition: network.h:34
Defines a crack in terms of 2D ellipses.
bool initialized
Internal variable to check if Network object is initialized.
Definition: network.h:101
int n_tside
Stores number of crosslinker nodes on the top edge of the network sample.
Definition: network.h:86
int n_rside
Stores number of crosslinker nodes on the right edge of the network sample.
Definition: network.h:83
bool * PBC
Tag to check if an edge is a periodic boundary condition edge.
Definition: network.h:94
int n_nodes
Stores number of crosslinker nodes in the network.
Definition: network.h:80
int * bsideNodes
Stores index of crosslinker nodes on the bottom edge of the network sample.
Definition: network.h:99
float * damage
Stores the damage in each edge of the network.
Definition: network.h:92
int * lsideNodes
Stores index of crosslinker nodes on the left edge of the network sample.
Definition: network.h:96
int n_moving
Stores number of moving nodes.
Definition: network.h:109
#define MAXBOUND_Y
Definition: params.h:12
bool cracked
Flag to check if the network has cracks.
Definition: network.h:79
int n_elems
Stores number of polymer connections in the network.
Definition: network.h:81
int * tsideNodes
Stores index of crosslinker nodes on the top edge of the network sample.
Definition: network.h:98
float __init_force
Initial force on the plate (simulation stopped if force goes below this.)
Definition: network.h:103
#define DIM
Definition: params.h:4
#define MAXBOUND_X
Definition: params.h:11
const float vel[DIM]
Definition: network.h:32
int n_bside
Stores number of crosslinker nodes on the bottom edge of the network sample.
Definition: network.h:85