PeriDEM 0.2.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
geometry::Fracture Class Reference

A class for fracture state of bonds. More...

#include <fracture.h>

Collaboration diagram for geometry::Fracture:

Public Member Functions

 Fracture (const std::vector< util::Point > *nodes, const std::vector< std::vector< std::size_t > > *neighbor_list=nullptr)
 Constructor.
 
 Fracture ()
 Constructor.
 
void setBondState (const std::size_t &i, const std::size_t &j, const bool &state)
 Sets the bond state.
 
bool getBondState (const std::size_t &i, const std::size_t &j) const
 Read bond state.
 
const std::vector< uint8_t > & getBonds (const std::size_t &i) const
 Returns the list of bonds of node i.
 
std::vector< uint8_t > & getBonds (const std::size_t &i)
 Returns the list of bonds of node i.
 
std::string printStr (int nt=0, int lvl=0) const
 Returns the string containing printable information about the object.
 
void print (int nt=0, int lvl=0) const
 Prints the information about the object.
 

Private Attributes

std::vector< std::vector< uint8_t > > d_fracture
 Vector which stores the state of bonds.
 

Detailed Description

A class for fracture state of bonds.

This class provides method to read and modify fracture state of bonds

Definition at line 26 of file fracture.h.

Constructor & Destructor Documentation

◆ Fracture() [1/2]

geometry::Fracture::Fracture ( const std::vector< util::Point > *  nodes,
const std::vector< std::vector< std::size_t > > *  neighbor_list = nullptr 
)

Constructor.

If neighbor list is null, then it assumes all nodes interact with all other nodes (PeriDEM implementation).

Parameters
nodesPointer to nodal coordinates
neighbor_listPointer to neighbor list

Definition at line 20 of file fracture.cpp.

21 {
22
23 std::size_t n = nodes->size();
24 d_fracture.resize(n);
25
26 tf::Executor executor(util::parallel::getNThreads());
27 tf::Taskflow taskflow;
28
29 taskflow.for_each_index(
30 (std::size_t) 0, n, (std::size_t) 1, [this, &nodes, &neighbor_list, n](std::size_t i) {
31 // get neighborlist of node i if neighborlist is provided
32 std::vector<size_t> neighs;
33 if (neighbor_list != nullptr)
34 neighs = (*neighbor_list)[i];
35
36 // compute number of neighbors
37 size_t ns = n;
38 if (!neighs.empty())
39 ns = neighs.size();
40
41 size_t s = ns / 8;
42 if (s * 8 < ns)
43 s++;
44 d_fracture[i] = std::vector<uint8_t>(s, uint8_t(0));
45 }
46 ); // for_each
47
48 executor.run(taskflow).get();
49}
std::vector< std::vector< uint8_t > > d_fracture
Vector which stores the state of bonds.
Definition fracture.h:101
unsigned int getNThreads()
Get number of threads to be used by taskflow.

References util::parallel::getNThreads().

Here is the call graph for this function:

◆ Fracture() [2/2]

geometry::Fracture::Fracture ( )

Constructor.

Definition at line 18 of file fracture.cpp.

18{}

Member Function Documentation

◆ getBonds() [1/2]

std::vector< uint8_t > & geometry::Fracture::getBonds ( const std::size_t &  i)

Returns the list of bonds of node i.

Parameters
iNodal id
Returns
list Bonds of node i

Definition at line 74 of file fracture.cpp.

74 {
75 return d_fracture[i];
76}

◆ getBonds() [2/2]

const std::vector< uint8_t > & geometry::Fracture::getBonds ( const std::size_t &  i) const

Returns the list of bonds of node i.

Parameters
iNodal id
Returns
list Bonds of node i

Definition at line 70 of file fracture.cpp.

71 {
72 return d_fracture[i];
73}

◆ getBondState()

bool geometry::Fracture::getBondState ( const std::size_t &  i,
const std::size_t &  j 
) const

Read bond state.

Parameters
iNodal id
jLocal id of bond in neighbor list of i
Returns
bool True if bond is fractured otherwise false

Definition at line 64 of file fracture.cpp.

64 {
65
66 auto bond = d_fracture[i][j / 8];
67 return bond >> (j % 8) & 1UL;
68}

Referenced by anonymous_namespace{materialUtil.cpp}::computeHydrostaticStrainI(), anonymous_namespace{materialUtil.cpp}::computeStateThetaxI(), and anonymous_namespace{materialUtil.cpp}::updateBondFractureDataI().

Here is the caller graph for this function:

◆ print()

void geometry::Fracture::print ( int  nt = 0,
int  lvl = 0 
) const
inline

Prints the information about the object.

Parameters
ntNumber of tabs to append before printing
lvlInformation level (higher means more information)

Definition at line 90 of file fracture.h.

90{ std::cout << printStr(nt, lvl); }
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.
Definition fracture.cpp:78

References printStr().

Here is the call graph for this function:

◆ printStr()

std::string geometry::Fracture::printStr ( int  nt = 0,
int  lvl = 0 
) const

Returns the string containing printable information about the object.

Parameters
ntNumber of tabs to append before printing
lvlInformation level (higher means more information)
Returns
string String containing printable information about the object

Definition at line 78 of file fracture.cpp.

78 {
79
80 auto tabS = util::io::getTabS(nt);
81 std::ostringstream oss;
82 oss << tabS << "------- Fracture --------" << std::endl << std::endl;
83 oss << tabS << "Num of outer fracture data = " << d_fracture.size() <<
84 std::endl;
85 oss << tabS << std::endl;
86
87 return oss.str();
88}
std::string getTabS(int nt)
Returns tab spaces of given size.
Definition io.h:40

References util::io::getTabS().

Referenced by print().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setBondState()

void geometry::Fracture::setBondState ( const std::size_t &  i,
const std::size_t &  j,
const bool &  state 
)

Sets the bond state.

Parameters
iNodal id
jLocal id of bond in neighbor list of i
stateState which is applied to the bond

Definition at line 51 of file fracture.cpp.

52 {
53
54 // to set i^th bit as true of integer a,
55 // a |= 1UL << (i % 8)
56
57 // to set i^th bit as false of integer a,
58 // a &= ~(1UL << (i % 8))
59
60 state ? (d_fracture[i][j / 8] |= 1UL << (j % 8))
61 : (d_fracture[i][j / 8] &= ~(1UL << (j % 8)));
62}

Referenced by anonymous_namespace{materialUtil.cpp}::updateBondFractureDataI().

Here is the caller graph for this function:

Field Documentation

◆ d_fracture

std::vector<std::vector<uint8_t> > geometry::Fracture::d_fracture
private

Vector which stores the state of bonds.

Given node i, vector d_fracture[i] is the list of state of bonds of node i.

We only use 1 bit per bond of node to store the state.

Definition at line 101 of file fracture.h.


The documentation for this class was generated from the following files: