GraphNet: Discrete element modeling for network connected materials
Applications to polymeric networks
Functions
helper_funcs.h File Reference
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <math.h>
#include <random>
#include <time.h>
#include <vector>
#include <unistd.h>
#include <algorithm>
#include <ctime>
#include <chrono>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <stddef.h>
#include "vel.h"
#include "params.h"
Include dependency graph for helper_funcs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int get_num_vertices (int elem_type)
 
bool contains (vector< int > &vec, int elem)
 
float getnorm (const float *vec, const int dim=DIM)
 
void mapping (int &edge_counter, int elem_type, int n_vertices, stringstream &input, int *edges)
 Converts mesh elements from GMSH file to edges and nodes. Only implemented elements of <element-id> = 2 or 3. Need to extend for 3D. More...
 
string read_dump (int &n_nodes, int &n_elems, string &fname)
 Reads the number of nodes and poly chains left at the end of previous simulation. The code does not take care of parameters. Assumes user will change params.h file while restarting the previous simulation. More...
 
void mapping (int &edge_counter, int elem_type)
 Reads the number of edges in elements. Only implemented elements of <element-id> = 2 or 3. More...
 
void read_n (int &n_nodes, int &n_elems, string &fname)
 Reads the number of nodes and edges according to the .msh file. Useful for allocating memory in the class' constructors. More...
 
void take_input (float *R, int *edges, int n_nodes, int n_elems, string &fname)
 Reads the input and converts to appropriate network data. More...
 
void __init__ (float *L, float *damage, bool *PBC, int n_elems)
 Initializes various properties for each edge in the graph. More...
 
int filename (const string &)
 Gives an integer value to be appended to the network dump filename. More...
 
void normalize_vector (float *result, const float *vec)
 
bool does_file_exist (string &fname)
 
void normalize_vector (float *vec)
 
void unitvector (float *result, float *r1, float *r2)
 
float force_wlc (float x, float L)
 
void convert_to_vector (float *result, const float mag, const float *direction)
 
float dist (const float *r1, const float *r2)
 
void forcevector (float *result, float *r1, float *r2, float L)
 Gives a force vector given the nodes and the contour length of the polymer connecting these. More...
 
bool ismember (int item, int *array, size_t size)
 
float getabsmax (float *arr, size_t sizeofarr)
 Gets the absolute maximum of an array. More...
 
template<typename t >
void write_to_file (string &fname, t *arr, int rows, int cols)
 
float kf (float force)
 
float kfe (float force_mag)
 
void __init__ (float *L, int *m, float *damage, float *sacdamage, bool *PBC, int n_elems)
 Overrides init for sacNetworks. More...
 

Function Documentation

void __init__ ( float *  L,
float *  damage,
bool *  PBC,
int  n_elems 
)

Initializes various properties for each edge in the graph.

void __init__ ( float *  L,
int *  m,
float *  damage,
float *  sacdamage,
bool *  PBC,
int  n_elems 
)

Overrides init for sacNetworks.

bool contains ( vector< int > &  vec,
int  elem 
)
inline
void convert_to_vector ( float *  result,
const float  mag,
const float *  direction 
)
inline
float dist ( const float *  r1,
const float *  r2 
)
inline
bool does_file_exist ( string &  fname)
inline
int filename ( const string &  )

Gives an integer value to be appended to the network dump filename.

float force_wlc ( float  x,
float  L 
)
inline
void forcevector ( float *  result,
float *  r1,
float *  r2,
float  L 
)

Gives a force vector given the nodes and the contour length of the polymer connecting these.

int get_num_vertices ( int  elem_type)
inline
float getabsmax ( float *  arr,
size_t  sizeofarr 
)

Gets the absolute maximum of an array.

float getnorm ( const float *  vec,
const int  dim = DIM 
)
inline
bool ismember ( int  item,
int *  array,
size_t  size 
)
inline
float kf ( float  force)
inline
float kfe ( float  force_mag)
inline
void mapping ( int &  edge_counter,
int  elem_type,
int  n_vertices,
stringstream &  input,
int *  edges 
)

Converts mesh elements from GMSH file to edges and nodes. Only implemented elements of <element-id> = 2 or 3. Need to extend for 3D.

void mapping ( int &  edge_counter,
int  elem_type 
)

Reads the number of edges in elements. Only implemented elements of <element-id> = 2 or 3.

void normalize_vector ( float *  result,
const float *  vec 
)
inline
void normalize_vector ( float *  vec)
inline
string read_dump ( int &  n_nodes,
int &  n_elems,
string &  fname 
)

Reads the number of nodes and poly chains left at the end of previous simulation. The code does not take care of parameters. Assumes user will change params.h file while restarting the previous simulation.

void read_n ( int &  n_nodes,
int &  n_elems,
string &  fname 
)

Reads the number of nodes and edges according to the .msh file. Useful for allocating memory in the class' constructors.

void take_input ( float *  R,
int *  edges,
int  n_nodes,
int  n_elems,
string &  fname 
)

Reads the input and converts to appropriate network data.

void unitvector ( float *  result,
float *  r1,
float *  r2 
)
inline
template<typename t >
void write_to_file ( string &  fname,
t *  arr,
int  rows,
int  cols 
)