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

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

#include <contactPairDeck.h>

Collaboration diagram for inp::ContactPairDeck:

Public Member Functions

 ContactPairDeck (const json &j=json({}))
 Constructor.
 
 ContactPairDeck (double contactR, bool computeContactR=true, bool dampingOn=true, bool frictionOn=true, double Kn=0., double eps=1., double mu=0., double KnFactor=1., double betanFactor=1., double deltaMax=1., double vMax=0.)
 Constructor.
 
 ContactPairDeck (const ContactPairDeck &cd)
 Copy constructor.
 
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< ContactPairDeck > > & fields ()
 The fields of this deck, declared once.
 
static const std::vector< OneOf > & groups ()
 Quantities this deck accepts in more than one form.
 
static json getExampleJson (const json &given=json::object())
 Returns example JSON object for ModelDeck configuration.
 

Data Fields

double d_contactR
 contact radius
 
bool d_computeContactR
 Flag that indicates whether contact radius is to be computed.
 
double d_vMax
 parameters for normal force
 
double d_deltaMax
 parameters for normal force
 
double d_Kn
 parameters for normal force
 
double d_KnFactor
 parameters for normal force
 
double d_eps
 parameters for normal damping force
 
double d_betan
 parameters for normal damping force
 
bool d_dampingOn
 parameters for normal damping force
 
double d_betanFactor
 parameters for normal damping force
 
double d_mu
 parameters for frictional force
 
bool d_frictionOn
 parameters for frictional force
 
double d_K
 parameters for frictional force
 

Detailed Description

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

Definition at line 27 of file contactPairDeck.h.

Constructor & Destructor Documentation

◆ ContactPairDeck() [1/3]

inp::ContactPairDeck::ContactPairDeck ( const json &  j = json({}))
inline

Constructor.

Definition at line 61 of file contactPairDeck.h.

61 {}))
62 : d_contactR(0.), d_computeContactR(true), d_vMax(0.), d_deltaMax(0.),
63 d_Kn(0.), d_eps(1.), d_betan(0.), d_mu(0.), d_dampingOn(true),
64 d_frictionOn(true), d_KnFactor(1.), d_betanFactor(1.), d_K(0.) {
65 readFromJson(j);
66 };
double d_contactR
contact radius
void readFromJson(const json &j)
Reads from json object.
bool d_frictionOn
parameters for frictional force
double d_eps
parameters for normal damping force
bool d_computeContactR
Flag that indicates whether contact radius is to be computed.
double d_betan
parameters for normal damping force
double d_betanFactor
parameters for normal damping force
double d_vMax
parameters for normal force
double d_KnFactor
parameters for normal force
double d_Kn
parameters for normal force
double d_mu
parameters for frictional force
double d_K
parameters for frictional force
double d_deltaMax
parameters for normal force
bool d_dampingOn
parameters for normal damping force

◆ ContactPairDeck() [2/3]

inp::ContactPairDeck::ContactPairDeck ( double  contactR,
bool  computeContactR = true,
bool  dampingOn = true,
bool  frictionOn = true,
double  Kn = 0.,
double  eps = 1.,
double  mu = 0.,
double  KnFactor = 1.,
double  betanFactor = 1.,
double  deltaMax = 1.,
double  vMax = 0. 
)
inline

Constructor.

Definition at line 71 of file contactPairDeck.h.

76 : d_contactR(contactR), d_computeContactR(computeContactR), d_vMax(vMax), d_deltaMax(deltaMax),
77 d_Kn(Kn), d_eps(eps), d_betan(0.), d_mu(mu), d_dampingOn(dampingOn),
78 d_frictionOn(frictionOn), d_KnFactor(KnFactor), d_betanFactor(betanFactor), d_K(0.) {
79 };

◆ ContactPairDeck() [3/3]

inp::ContactPairDeck::ContactPairDeck ( const ContactPairDeck &  cd)
inline

Copy constructor.

Parameters
cdAnother ContactPairDeck object

Definition at line 86 of file contactPairDeck.h.

87 : d_contactR(cd.d_contactR), d_computeContactR(cd.d_computeContactR),
88 d_vMax(cd.d_vMax), d_deltaMax(cd.d_deltaMax),
89 d_Kn(cd.d_Kn), d_eps(cd.d_eps), d_betan(cd.d_betan),
90 d_mu(cd.d_mu), d_dampingOn(cd.d_dampingOn),
91 d_frictionOn(cd.d_frictionOn), d_KnFactor(cd.d_KnFactor),
92 d_betanFactor(cd.d_betanFactor), d_K(cd.d_K) {
93 };

Member Function Documentation

◆ fields()

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

The fields of this deck, declared once.

The contact radius and the contact stiffness are each given in one of two ways and are resolved in readFromJson. What remains maps one key to one member.

Returns
fields The field table

Definition at line 104 of file contactPairDeck.h.

104 {
105 static const std::vector<Field<ContactPairDeck>> f = {
106 field(&ContactPairDeck::d_KnFactor, "Kn_Factor", 1.,
107 "Normal stiffness is scaled by this"),
108 field(&ContactPairDeck::d_dampingOn, "Damping_On", true,
109 "Apply the normal damping force"),
110 field(&ContactPairDeck::d_eps, "Epsilon", 1.,
111 "Coefficient of restitution", {{}, 0., 1.}),
112 field(&ContactPairDeck::d_betanFactor, "Beta_n_Factor", 1.,
113 "Damping coefficient is scaled by this"),
114 field(&ContactPairDeck::d_frictionOn, "Friction_On", true,
115 "Apply the tangential friction force"),
116 field(&ContactPairDeck::d_mu, "Friction_Coeff", 0.,
117 "Coefficient of friction"),
118 // Left out when it is not set, because a pair without friction
119 // does not use it.
120 field<ContactPairDeck, double>(
121 &ContactPairDeck::d_K, "K", 0.,
122 "Bulk modulus the tangential force is built from", {},
123 [](const double &v) { return v > 1.E-10; }),
124 };
125 return f;
126 }
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_betanFactor, d_dampingOn, d_eps, d_frictionOn, d_K, d_KnFactor, d_mu, and inp::field().

Referenced by getExampleJson(), and readFromJson().

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

◆ getExampleJson()

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

Returns example JSON object for ModelDeck configuration.

Returns
JSON object with example configuration

Returns the block with the given fields set

The contact radius is given either as Contact_Radius, an absolute length, or as Contact_Radius_Factor, a multiple of the mesh size. The contact stiffness is given either as Kn, or as V_Max with an optional Delta_Max, the speed and overlap the stiffness is derived from. Naming one of each pair is what selects it; there is no flag and no value standing in for "not set".

Parameters
givenField names and values to set, checked against the table
Returns
JSON object for this deck

Definition at line 158 of file contactPairDeck.h.

158 {
159 const std::vector<std::string> extra = {"Contact_Radius",
160 "Contact_Radius_Factor", "Kn",
161 "V_Max", "Delta_Max"};
162 checkKeys(given, fields(), extra);
163
164 json g = given;
165
166 // Damping with no coefficient is no damping.
167 bool dampingOn = g.value("Damping_On", true);
168 double betanFactor = g.value("Beta_n_Factor", 1.);
169 if (dampingOn and betanFactor < 1.E-10)
170 dampingOn = false;
171 if (!dampingOn)
172 betanFactor = 0.;
173 g["Damping_On"] = dampingOn;
174 g["Beta_n_Factor"] = betanFactor;
175
176 if (g.value("Friction_On", true) and
177 g.value("Friction_Coeff", 0.) < 1.E-10)
178 throw std::runtime_error("Friction coefficient can not be zero.");
179
180 if (g.find("Contact_Radius_Factor") != g.end() and
181 g.at("Contact_Radius_Factor").get<double>() < 1.E-10)
182 throw std::runtime_error("Contact radius factor can not be zero.");
183
184 if (g.find("Kn") != g.end() and g.at("Kn").get<double>() < 1.E-10)
185 throw std::runtime_error(
186 "Kn can not be zero. Give V_Max instead to derive it.");
187
188 // The speed is what the stiffness is derived from, so the overlap it
189 // is measured against goes with it.
190 if (g.find("V_Max") != g.end()) {
191 if (g.at("V_Max").get<double>() < 1.E-10)
192 throw std::runtime_error(
193 "Need V_Max parameter for contact force.");
194 if (g.find("Delta_Max") == g.end() or
195 g.at("Delta_Max").get<double>() < 1.E-10)
196 g["Delta_Max"] = 1.;
197 }
198
199 json j = applyGiven(g, fields(), extra);
200 checkGroups(j, groups());
201 return j;
202 }
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
void checkKeys(const json &given, const std::vector< Field< Deck > > &fs, const std::vector< std::string > &extra={})
Rejects a key that no field declares.
Definition deckField.h:421
void checkGroups(const json &block, const std::vector< OneOf > &groups)
Checks that each group has exactly one of its keys.
Definition deckField.h:317
static const std::vector< OneOf > & groups()
Quantities this deck accepts in more than one form.
static const std::vector< Field< ContactPairDeck > > & fields()
The fields of this deck, declared once.

References inp::applyGiven(), inp::checkGroups(), inp::checkKeys(), fields(), and groups().

Referenced by anonymous_namespace{main.cpp}::buildBhatInputJson(), anonymous_namespace{main.cpp}::buildImpactInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), anonymous_namespace{main.cpp}::buildInputJson(), getInputJson(), anonymous_namespace{main.cpp}::makeDeck(), and anonymous_namespace{testDeckRoundTrip.cpp}::testContactPairDeck().

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

◆ groups()

static const std::vector< OneOf > & inp::ContactPairDeck::groups ( )
inlinestatic

Quantities this deck accepts in more than one form.

Returns
groups The groups

Definition at line 132 of file contactPairDeck.h.

132 {
133 static const std::vector<OneOf> g = {
134 {"the contact radius",
135 {"Contact_Radius", "Contact_Radius_Factor"}},
136 {"the contact stiffness", {"Kn", "V_Max"}},
137 };
138 return g;
139 }

Referenced by getExampleJson(), and readFromJson().

Here is the caller graph for this function:

◆ print()

void inp::ContactPairDeck::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 277 of file contactPairDeck.h.

277{ 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::ContactPairDeck::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 254 of file contactPairDeck.h.

254 {
255 auto tabS = util::io::getTabS(nt);
256 std::ostringstream oss;
257 oss << tabS << "------- ContactPairDeck --------" << std::endl << std::endl;
258 oss << tabS << "Contact radius = " << d_contactR << std::endl;
259 oss << tabS << "v_max = " << d_vMax << ", Delta_max = " << d_deltaMax
260 << ", Kn = " << d_Kn << std::endl;
261 oss << tabS << "epsilon = " << d_eps << ", Beta_n = " << d_betan << std::endl;
262 oss << tabS << "Friction coefficient = " << d_mu << std::endl;
263 oss << tabS << "Damping status = " << d_dampingOn << std::endl;
264 oss << tabS << "Kn factor = " << d_KnFactor
265 << ", Beta n factor = " << d_betanFactor << std::endl;
266 oss << tabS << "Bulk modulus = " << d_K << std::endl;
267 oss << tabS << std::endl;
268 return oss.str();
269 }
std::string getTabS(int nt)
Returns tab spaces of a given size.
Definition io.h:82

References d_betan, d_betanFactor, d_contactR, d_dampingOn, d_deltaMax, d_eps, d_K, d_Kn, d_KnFactor, d_mu, d_vMax, and util::io::getTabS().

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

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

◆ readFromJson()

void inp::ContactPairDeck::readFromJson ( const json &  j)
inline

Reads from json object.

Definition at line 207 of file contactPairDeck.h.

207 {
208
209 if (j.empty())
210 return;
211
212 checkGroups(j, groups());
213 readFields(*this, j, fields());
214
215 // A factor is applied to the mesh size, an absolute radius is not.
216 d_computeContactR = j.find("Contact_Radius_Factor") != j.end();
217 d_contactR = d_computeContactR ? j.at("Contact_Radius_Factor").get<double>()
218 : j.at("Contact_Radius").get<double>();
219
220 // Given a stiffness, the speed that produces the reference overlap
221 // follows from it. Given that speed instead, the stiffness follows in
222 // the contact force.
223 if (j.find("Kn") != j.end()) {
224 d_Kn = j.at("Kn");
225 d_deltaMax = 1.;
226 d_vMax = std::sqrt(d_Kn);
227 } else {
228 d_vMax = j.at("V_Max");
229 d_deltaMax = j.value("Delta_Max", 1.);
230 }
231
232 if (d_betanFactor < 1.E-8)
233 d_dampingOn = false;
234
235 if (!d_dampingOn)
236 d_betanFactor = 0.;
237
238 if (d_frictionOn and d_mu < 1.E-10) {
239 throw std::runtime_error("Friction coefficient can not be zero.");
240 }
241 if (d_frictionOn and d_K < 1.E-10) {
242 throw std::runtime_error("Bulk modulus can not be zero.");
243 }
244 }
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

References inp::checkGroups(), d_betanFactor, d_computeContactR, d_contactR, d_dampingOn, d_deltaMax, d_frictionOn, d_K, d_Kn, d_mu, d_vMax, fields(), groups(), and inp::readFields().

Referenced by anonymous_namespace{testDeckRoundTrip.cpp}::testContactPairDeck().

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

Field Documentation

◆ d_betan

double inp::ContactPairDeck::d_betan

parameters for normal damping force

Definition at line 46 of file contactPairDeck.h.

Referenced by main(), contact::PairForce::nodeDampingForce(), printStr(), and contact::Contact::setup().

◆ d_betanFactor

double inp::ContactPairDeck::d_betanFactor

parameters for normal damping force

Definition at line 48 of file contactPairDeck.h.

Referenced by fields(), printStr(), readFromJson(), and contact::Contact::setup().

◆ d_computeContactR

bool inp::ContactPairDeck::d_computeContactR

Flag that indicates whether contact radius is to be computed.

Definition at line 33 of file contactPairDeck.h.

Referenced by readFromJson(), and contact::Contact::setup().

◆ d_contactR

◆ d_dampingOn

bool inp::ContactPairDeck::d_dampingOn

parameters for normal damping force

Definition at line 47 of file contactPairDeck.h.

Referenced by fields(), contact::PairForce::nodeDampingForce(), printStr(), and readFromJson().

◆ d_deltaMax

double inp::ContactPairDeck::d_deltaMax

parameters for normal force

Definition at line 38 of file contactPairDeck.h.

Referenced by printStr(), and readFromJson().

◆ d_eps

double inp::ContactPairDeck::d_eps

parameters for normal damping force

Definition at line 45 of file contactPairDeck.h.

Referenced by fields(), printStr(), and contact::Contact::setup().

◆ d_frictionOn

bool inp::ContactPairDeck::d_frictionOn

parameters for frictional force

Definition at line 54 of file contactPairDeck.h.

Referenced by fields(), readFromJson(), contact::PairForce::springForce(), and contact::StickSlipPairForce::springForce().

◆ d_K

double inp::ContactPairDeck::d_K

parameters for frictional force

Definition at line 55 of file contactPairDeck.h.

Referenced by fields(), main(), contact::PairForce::nodeDampingForce(), printStr(), readFromJson(), and contact::Contact::setup().

◆ d_Kn

double inp::ContactPairDeck::d_Kn

◆ d_KnFactor

double inp::ContactPairDeck::d_KnFactor

parameters for normal force

Definition at line 40 of file contactPairDeck.h.

Referenced by fields(), printStr(), and contact::Contact::setup().

◆ d_mu

double inp::ContactPairDeck::d_mu

◆ d_vMax

double inp::ContactPairDeck::d_vMax

parameters for normal force

Definition at line 37 of file contactPairDeck.h.

Referenced by printStr(), readFromJson(), and contact::Contact::setup().


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