11#ifndef INP_CONTACTPAIRDECK_H
12#define INP_CONTACTPAIRDECK_H
72 bool dampingOn =
true,
bool frictionOn =
true,
73 double Kn = 0.,
double eps = 1.,
double mu = 0.,
74 double KnFactor = 1.,
double betanFactor = 1.,
75 double deltaMax = 1.,
double vMax = 0.)
104 static const std::vector<Field<ContactPairDeck>> &
fields() {
105 static const std::vector<Field<ContactPairDeck>> f = {
107 "Normal stiffness is scaled by this"),
109 "Apply the normal damping force"),
111 "Coefficient of restitution", {{}, 0., 1.}),
113 "Damping coefficient is scaled by this"),
115 "Apply the tangential friction force"),
117 "Coefficient of friction"),
120 field<ContactPairDeck, double>(
122 "Bulk modulus the tangential force is built from", {},
123 [](
const double &v) {
return v > 1.E-10; }),
132 static const std::vector<OneOf> &
groups() {
133 static const std::vector<OneOf> g = {
134 {
"the contact radius",
135 {
"Contact_Radius",
"Contact_Radius_Factor"}},
136 {
"the contact stiffness", {
"Kn",
"V_Max"}},
159 const std::vector<std::string> extra = {
"Contact_Radius",
160 "Contact_Radius_Factor",
"Kn",
161 "V_Max",
"Delta_Max"};
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)
173 g[
"Damping_On"] = dampingOn;
174 g[
"Beta_n_Factor"] = betanFactor;
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.");
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.");
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.");
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)
218 : j.at(
"Contact_Radius").get<
double>();
223 if (j.find(
"Kn") != j.end()) {
239 throw std::runtime_error(
"Friction coefficient can not be zero.");
242 throw std::runtime_error(
"Bulk modulus can not be zero.");
254 std::string
printStr(
int nt = 0,
int lvl = 0)
const {
256 std::ostringstream oss;
257 oss << tabS <<
"------- ContactPairDeck --------" << std::endl << std::endl;
258 oss << tabS <<
"Contact radius = " <<
d_contactR << std::endl;
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;
266 oss << tabS <<
"Bulk modulus = " <<
d_K << std::endl;
267 oss << tabS << std::endl;
277 void print(
int nt = 0,
int lvl = 0)
const { std::cout <<
printStr(nt, lvl); }
nlohmann::ordered_json json
Collection of methods and database related to input.
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.
void readFields(Deck &d, const json &j, const std::vector< Field< Deck > > &fs)
Reads every field of the table from the block.
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.
void checkKeys(const json &given, const std::vector< Field< Deck > > &fs, const std::vector< std::string > &extra={})
Rejects a key that no field declares.
void checkGroups(const json &block, const std::vector< OneOf > &groups)
Checks that each group has exactly one of its keys.
std::string getTabS(int nt)
Returns tab spaces of a given size.