PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
inp::ContactDeck Struct Reference

Structure to read and store particle-particle contact related input data. More...

#include <contactDeck.h>

Collaboration diagram for inp::ContactDeck:

Public Member Functions

 ContactDeck (const json &j=json({}))
 Constructor.
 
const ContactPairDeckgetContact (const size_t &i, const size_t &j) const
 Returns the contact data.
 
ContactPairDeckgetContact (const size_t &i, const size_t &j)
 Returns the contact data.
 
void readFromJson (const json &j)
 Reads from json object.
 
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.
 

Static Public Member Functions

static const std::vector< Field< ContactDeck > > & fields ()
 Returns example JSON object for ModelDeck configuration.
 
static json getExampleJson (const json &given=json::object())
 Returns the block with the given fields set.
 

Data Fields

std::vector< std::vector< ContactPairDeck > > d_data
 Store contact parameters for each pair of zone.
 
std::string d_dampingLaw
 Contact damping law name (default com_and_node).
 
std::string d_frictionLaw
 Friction law name (default coulomb_simple).
 
bool d_correctVolume
 If true (default), DEM contact uses partial neighbor volume near the contact radius (correctedContactVolume). Set false to use full nodal volume (main-branch DEM contact spring).
 

Detailed Description

Structure to read and store particle-particle contact related input data.

Definition at line 27 of file contactDeck.h.

Constructor & Destructor Documentation

◆ ContactDeck()

inp::ContactDeck::ContactDeck ( const json j = json({}))
inline

Constructor.

Definition at line 50 of file contactDeck.h.

50 {}))
51 : d_dampingLaw("com_and_node"), d_frictionLaw("coulomb_simple"),
52 d_correctVolume(true) {
53 readFromJson(j);
54 };
std::string d_dampingLaw
Contact damping law name (default com_and_node).
Definition contactDeck.h:35
std::string d_frictionLaw
Friction law name (default coulomb_simple).
Definition contactDeck.h:38
void readFromJson(const json &j)
Reads from json object.
bool d_correctVolume
If true (default), DEM contact uses partial neighbor volume near the contact radius (correctedContact...
Definition contactDeck.h:45

Member Function Documentation

◆ fields()

static const std::vector< Field< ContactDeck > > & inp::ContactDeck::fields ( )
inlinestatic

Returns example JSON object for ModelDeck configuration.

Returns
JSON object with example configuration

Definition at line 78 of file contactDeck.h.

78 {
79 static const std::vector<Field<ContactDeck>> f = {
80 field(&ContactDeck::d_dampingLaw, "Damping_Law",
81 std::string("com_and_node"), "Where contact damping is applied",
82 {{"com_and_node", "com", "node", "off"}, {}, {}}),
83 field(&ContactDeck::d_frictionLaw, "Friction_Law",
84 std::string("coulomb_simple"), "Tangential contact law",
85 {{"coulomb_simple", "stick_slip"}, {}, {}}),
86 field(&ContactDeck::d_correctVolume, "Correct_Volume", true,
87 "Scale the neighbor volume by the overlap with the contact "
88 "sphere"),
89 };
90 return f;
91 }
Field< Deck > field(T Deck::*m, std::string key, T def, std::string doc, Accepts< T > accepts={}, std::function< bool(const T &)> emitIf=[](const T &) { return true;})
Declares a field that maps one key to one member.
Definition deckField.h:144

References d_correctVolume, d_dampingLaw, d_frictionLaw, and inp::field().

Referenced by getExampleJson(), printStr(), and readFromJson().

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

◆ getContact() [1/2]

ContactPairDeck & inp::ContactDeck::getContact ( const size_t &  i,
const size_t &  j 
)
inline

Returns the contact data.

Parameters
iZone i
jZone j
Returns
data Contact data between zone i and j

Definition at line 69 of file contactDeck.h.

69 {
70 //return d_data[i < j ? i : j][i < j ? j : i];
71 return d_data[i][j];
72 }
std::vector< std::vector< ContactPairDeck > > d_data
Store contact parameters for each pair of zone.
Definition contactDeck.h:32

References d_data.

◆ getContact() [2/2]

const ContactPairDeck & inp::ContactDeck::getContact ( const size_t &  i,
const size_t &  j 
) const
inline

Returns the contact data.

Parameters
iZone i
jZone j
Returns
data Contact data between zone i and j

Definition at line 63 of file contactDeck.h.

63 {
64 //return d_data[i < j ? i : j][i < j ? j : i];
65 return d_data[i][j];
66 }

References d_data.

Referenced by printStr().

Here is the caller graph for this function:

◆ getExampleJson()

static json inp::ContactDeck::getExampleJson ( const json given = json::object())
inlinestatic

Returns the block with the given fields set.

One pair block is written for each pair of contact groups. Without any groups the block is empty.

Parameters
givenField names and values to set, checked against the table, and Sets, the number of contact groups
Returns
JSON object for this deck

Definition at line 103 of file contactDeck.h.

103 {
104 json j = applyGiven(given, fields(), {"Sets"});
105 const auto nSets = j.value("Sets", size_t(0));
106 if (nSets == 0)
107 return json({});
108
109 for (size_t i = 0; i < nSets; i++)
110 for (size_t k = i; k < nSets; k++)
111 j["Set_" + std::to_string(i + 1) + "_" + std::to_string(k + 1)] = {};
112
113 return j;
114 }
nlohmann::ordered_json json
json applyGiven(const json &given, const std::vector< Field< Deck > > &fs, const std::vector< std::string > &extra={})
The default block with the given keys replaced.
Definition deckField.h:443
static const std::vector< Field< ContactDeck > > & fields()
Returns example JSON object for ModelDeck configuration.
Definition contactDeck.h:78

References inp::applyGiven(), and fields().

Referenced by anonymous_namespace{main.cpp}::buildInputJson(), inp::ParticleDeck::getParticleContactExampleJson(), and anonymous_namespace{testDeckRoundTrip.cpp}::testContactDeck().

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

◆ print()

void inp::ContactDeck::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 197 of file contactDeck.h.

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

References printStr().

Here is the call graph for this function:

◆ printStr()

std::string inp::ContactDeck::printStr ( int  nt = 0,
int  lvl = 0 
) const
inline

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 172 of file contactDeck.h.

172 {
173
174 auto tabS = util::io::getTabS(nt);
175 std::ostringstream oss;
176 oss << tabS << "------- ContactDeck --------" << std::endl << std::endl;
177 printFields(*this, oss, fields(), tabS);
178 for (size_t i =0; i<d_data.size(); i++) {
179 for (size_t j = 0; j < d_data.size(); j++) {
180 oss << tabS << "ContactPairData id = (" << i << "," << j << ") info:"
181 << std::endl;
182 oss << getContact(i,j).printStr(nt+2, lvl);
183 }
184 }
185
186 oss << tabS << std::endl;
187
188 return oss.str();
189 }
void printFields(const Deck &d, std::ostringstream &oss, const std::vector< Field< Deck > > &fs, const std::string &tab="")
Appends every field of the table to a stream.
Definition deckField.h:251
std::string getTabS(int nt)
Returns tab spaces of a given size.
Definition io.h:82
const ContactPairDeck & getContact(const size_t &i, const size_t &j) const
Returns the contact data.
Definition contactDeck.h:63
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.

References d_data, fields(), getContact(), util::io::getTabS(), inp::printFields(), and inp::ContactPairDeck::printStr().

Referenced by print(), and inp::ParticleDeck::printStr().

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

◆ readFromJson()

void inp::ContactDeck::readFromJson ( const json j)
inline

Reads from json object.

Definition at line 119 of file contactDeck.h.

119 {
120 if (j.empty())
121 return;
122
123 readFields(*this, j, fields());
124
125 auto nSets = j.value("Sets", size_t(0));
126 d_data.resize(nSets);
127 for (size_t i=0; i<nSets; i++)
128 d_data[i].resize(nSets);
129
130 for (size_t i = 0; i < nSets; i++) {
131 for (size_t k = i; k < nSets; k++) {
132 std::string set_name = "Set_" + std::to_string(i+1) + "_" + std::to_string(k+1);
133 //std::cout << "\n\n\n processing " << set_name << "\n\n\n" << std::flush;
134
135 auto cd = inp::ContactPairDeck();
136
137 if (j.find(set_name) == j.end())
138 throw std::runtime_error("Set " + set_name + " not found in contact block.");
139
140 auto js = j.at(set_name);
141
142 // copy this set from previous set?
143 std::vector<int> copy_set = js.value("Copy_Data", std::vector<int>({-1, -1}));
144 //std::cout << "copy_data = " << copy_set[0] << ", " << copy_set[1] << "\n" << std::flush;
145
146 // check
147 if ((copy_set[0] != -1 and copy_set[1] == -1) or (copy_set[0] == -1 and copy_set[1] != -1) or (copy_set.size() != 2))
148 throw std::runtime_error("The pair of set ids for copying is invalid in contact block.");
149
150 if (copy_set[0] != -1) {
151 std::string copy_set_tag = "Set_" + std::to_string(copy_set[0]) + "_" + std::to_string(copy_set[1]);
152 auto js_copy = j.at(copy_set_tag);
153 cd.readFromJson(js_copy);
154 } else {
155 cd.readFromJson(js);
156 }
157
158 d_data[i][k] = cd;
159 if (i != k)
160 d_data[k][i] = cd;
161 }
162 }
163 }
void readFields(Deck &d, const json &j, const std::vector< Field< Deck > > &fs)
Reads every field of the table from the block.
Definition deckField.h:230
Structure to read and store particle-particle contact related input data.

References d_data, fields(), and inp::readFields().

Referenced by inp::ParticleDeck::readParticleContactFromJson().

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

Field Documentation

◆ d_correctVolume

bool inp::ContactDeck::d_correctVolume

If true (default), DEM contact uses partial neighbor volume near the contact radius (correctedContactVolume). Set false to use full nodal volume (main-branch DEM contact spring).

Definition at line 45 of file contactDeck.h.

Referenced by fields().

◆ d_dampingLaw

std::string inp::ContactDeck::d_dampingLaw

Contact damping law name (default com_and_node).

Definition at line 35 of file contactDeck.h.

Referenced by fields().

◆ d_data

std::vector<std::vector<ContactPairDeck> > inp::ContactDeck::d_data

Store contact parameters for each pair of zone.

Definition at line 32 of file contactDeck.h.

Referenced by getContact(), getContact(), printStr(), and readFromJson().

◆ d_frictionLaw

std::string inp::ContactDeck::d_frictionLaw

Friction law name (default coulomb_simple).

Definition at line 38 of file contactDeck.h.

Referenced by fields().


The documentation for this struct was generated from the following file: