PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
policy.cpp
Go to the documentation of this file.
1/*
2 * -------------------------------------------
3 * Copyright (c) 2021 - 2026 Prashant K. Jha
4 * -------------------------------------------
5 * PeriDEM https://github.com/prashjha/PeriDEM
6 *
7 * Distributed under the Boost Software License, Version 1.0. (See accompanying
8 * file LICENSE)
9 */
10
11#include "policy.h"
12
13#include <stdexcept>
14
15namespace contact {
16
17std::unique_ptr<PairForce> makePairForce(const std::string &friction_law) {
18 if (friction_law != "coulomb_simple" && friction_law != "stick_slip") {
19 throw std::runtime_error(
20 "Unknown Contact.Friction_Law '" + friction_law +
21 "'. Supported: coulomb_simple, stick_slip.");
22 }
23
24 if (friction_law == "stick_slip")
25 return std::make_unique<StickSlipPairForce>();
26 return std::make_unique<PairForce>();
27}
28
29std::unique_ptr<Damping> makeDamping(const std::string &name) {
30 if (name == "com_and_node" || name == "com")
31 return std::make_unique<Damping>();
32 if (name == "node" || name == "off")
33 return nullptr;
34 throw std::runtime_error(
35 "Unknown Contact.Damping_Law '" + name +
36 "'. Supported: com_and_node, com, node, off.");
37}
38
39bool usesComDamping(const std::string &damping_law) {
40 return damping_law == "com" || damping_law == "com_and_node";
41}
42
43bool usesNodeDamping(const std::string &damping_law) {
44 return damping_law == "node" || damping_law == "com_and_node";
45}
46
47} // namespace contact
std::unique_ptr< Damping > makeDamping(const std::string &name)
Build COM damping object, or nullptr when the law has no COM term.
Definition policy.cpp:29
std::unique_ptr< PairForce > makePairForce(const std::string &friction_law)
Build pair-force object from friction-law name.
Definition policy.cpp:17
bool usesNodeDamping(const std::string &damping_law)
True for node / com_and_node.
Definition policy.cpp:43
bool usesComDamping(const std::string &damping_law)
True for com / com_and_node.
Definition policy.cpp:39