PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
baseParticle.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 "baseParticle.h"
12#include "util/vecMethods.h"
13#include "fe/elemIncludes.h"
15#include "util/feElementDefs.h"
16#include "util/function.h"
17#include "geom/geomIncludes.h"
18#include <cmath>
19#include <iostream>
20
22: d_isWall(false),
23 d_id(id),
24 d_dim(0),
25 d_numNodes(0),
26 d_h(0.),
27 d_horizon(0.),
28 d_density(0.),
29 d_allDofsConstrained(false),
30 d_computeForce(true),
31 d_mpiOwner(0),
32 d_material_p(nullptr),
33 d_Rc(0.),
34 d_Kn(0.),
35 d_globStart(0),
36 d_globEnd(0),
37 d_globQuadStart(0),
38 d_globQuadEnd(0),
39 d_modelData_p(nullptr),
40 d_rp_p(nullptr),
41 d_geom_p(nullptr),
42 d_tform(geom::ParticleTransform()),
43 d_mesh_p(nullptr) {}
44
46 bool isWall,
47 size_t dim,
48 std::map<std::string, size_t> groups,
49 bool are_all_dofs_constrained,
50 size_t num_nodes,
51 double h,
52 std::shared_ptr<data::ModelData> model_data,
53 std::shared_ptr<particle::RefParticle> ref_particle,
54 std::shared_ptr<geom::GeomObject> geom,
55 geom::ParticleTransform &transform,
56 std::shared_ptr<mesh::Mesh> mesh,
57 inp::MaterialDeck &material_deck,
58 bool populate_data)
59 : d_id(id),
60 d_dim(dim),
61 d_isWall(isWall),
62 d_groups(groups),
63 d_numNodes(num_nodes),
64 d_h(h),
65 d_horizon(0),
66 d_density(0),
67 d_allDofsConstrained(are_all_dofs_constrained),
68 d_computeForce(true),
69 d_mpiOwner(0),
70 d_material_p(nullptr),
71 d_Rc(0.),
72 d_Kn(0.),
73 d_globStart(0),
74 d_globEnd(0),
75 d_globQuadStart(0),
76 d_globQuadEnd(0),
77 d_modelData_p(model_data),
78 d_rp_p(ref_particle),
79 d_geom_p(geom),
80 d_tform(transform),
81 d_mesh_p(mesh),
82 d_pRadius(geom->boundingRadius()) {
83
85
86 if (populate_data) {
87
88 d_globStart = d_modelData_p->d_x.size();
89 d_globEnd = d_modelData_p->d_x.size() + d_rp_p->getNumNodes();
90
91 for (size_t i = 0; i < d_rp_p->getNumNodes(); i++) {
92
93 const util::Point vn = d_rp_p->getNode(i);
94 util::Point x0 = d_tform.apply(vn);
95
96 d_modelData_p->d_xRef.push_back(x0);
97 d_modelData_p->d_x.push_back(x0);
98 d_modelData_p->d_u.push_back(util::Point());
99 d_modelData_p->d_v.push_back(util::Point());
100 d_modelData_p->d_vMag.push_back(0.);
101 d_modelData_p->d_f.push_back(util::Point());
102 d_modelData_p->d_vol.push_back(
103 d_rp_p->getNodalVolume(i) *
104 std::pow(d_tform.d_scale, d_rp_p->getDimension()));
105 d_modelData_p->d_fix.push_back(uint8_t(0));
106 d_modelData_p->d_forceFixity.push_back(uint8_t(0));
107 d_modelData_p->d_thetaX.push_back(0.);
108 d_modelData_p->d_mX.push_back(0.);
109 d_modelData_p->d_ptId.push_back(id); // id of this particle
110 }
111 }
112
114
115 // initialize material class
116 inp::MaterialDeck p_material_deck = material_deck;
117 // double horizon = d_geom_p->inscribedRadius();
118 double horizon = p_material_deck.d_horizon;
119 if (p_material_deck.d_horizonMeshRatio > 0.)
120 horizon = p_material_deck.d_horizonMeshRatio * d_h;
121
122 if (p_material_deck.d_materialType == "RNPBond")
123 d_material_p = std::make_unique<material::RnpMaterial>(
124 p_material_deck, d_rp_p->getDimension(), horizon);
125 else if (p_material_deck.d_materialType == "PMBBond")
126 d_material_p = std::make_unique<material::PmbMaterial>(
127 p_material_deck, d_rp_p->getDimension(), horizon);
128 else if (p_material_deck.d_materialType == "PDElasticBond")
129 d_material_p = std::make_unique<material::PdElastic>(
130 p_material_deck, d_rp_p->getDimension(), horizon);
131 else if (p_material_deck.d_materialType == "PDState")
132 d_material_p = std::make_unique<material::PdState>(
133 p_material_deck, d_rp_p->getDimension(), horizon);
134
135 d_horizon = horizon;
136 d_density = d_material_p->getDensity();
137
138 // d_material_p->print();
139
140 // set contact radius for internal contact
141 d_Rc = 0.95 * d_h;
142
143 // set contact coefficient for internal contact
144 const double K_self =
145 d_material_p->computeMaterialProperties(getDimension()).d_K;
146 d_Kn = util::selfContactStiffness(K_self, horizon);
147
148 if (!d_computeForce) {
149 std::cout << "Warning: Compute force is OFF in particle with id = "
150 << d_id << "\n";
151 }
153 std::cout << "Warning: All DoFs are OFF in particle with id = "
154 << d_id << "\n";
155 }
156}
157
158std::string particle::BaseParticle::printStr(int nt, int lvl) const {
159
160 auto tabS = util::io::getTabS(nt);
161 std::ostringstream oss;
162 oss << tabS << "------- BaseParticle --------" << std::endl
163 << std::endl;
164
165 oss << tabS << "d_isWall = " << d_isWall << std::endl;
166 oss << tabS << "d_id = " << d_id << std::endl;
167 oss << tabS << "d_dim = " << d_dim << std::endl;
168 //oss << tabS << "d_groups = " << util::io::printStr<std::string, size_t>(d_groups) << std::endl;
169 oss << tabS << "d_numNodes = " << d_numNodes << std::endl;
170 oss << tabS << "d_pRadius = " << d_pRadius << std::endl;
171 oss << tabS << "d_h = " << d_h << std::endl;
172 oss << tabS << "d_allDofsConstrained = " << d_allDofsConstrained << std::endl;
173 oss << tabS << "d_computeForce = " << d_computeForce << std::endl;
174 oss << tabS << "d_horizon = " << d_horizon << std::endl;
175 oss << tabS << "d_density = " << d_density << std::endl;
176 oss << tabS << "d_Rc = " << d_Rc << std::endl;
177 oss << tabS << "d_Kn = " << d_Kn << std::endl;
178 oss << tabS << "d_globStart = " << d_globStart << std::endl;
179 oss << tabS << "d_globEnd = " << d_globEnd << std::endl;
180 oss << tabS << "d_globQuadStart = " << d_globQuadStart << std::endl;
181 oss << tabS << "d_globQuadEnd = " << d_globQuadEnd << std::endl;
182 oss << tabS << std::endl;
183 oss << tabS << std::endl;
184 oss << tabS << "Ref particle info = " << std::endl;
185 oss << d_rp_p->printStr(nt + 1, lvl);
186 oss << tabS << "Geometry info: " << std::endl;
187 oss << d_geom_p->printStr(nt + 1, lvl);
188
189 oss << tabS << std::endl;
190
191 return oss.str();
192}
double d_Rc
Contact radius for contact between internal nodes of particle.
BaseParticle(size_t id=0)
Constructor.
geom::ParticleTransform d_tform
Transformation related data.
bool d_allDofsConstrained
Specify if all dofs are constrained so we do not update displacement, velocity, and force data.
bool d_computeForce
Specify if we compute force.
double d_horizon
horizon
double d_h
mesh size
size_t d_globStart
Id of first node of this object in global node list.
double d_density
density
size_t d_id
Id of this particle in all particles list.
size_t getDimension() const
Get the dimension of the domain.
size_t d_globEnd
Id of last node of this object in global node list.
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.
std::unique_ptr< material::Material > d_material_p
Pointer to peridynamic material object.
double d_Kn
Normal contact coefficient for internal contact.
std::shared_ptr< particle::RefParticle > d_rp_p
Pointer to reference particle.
std::shared_ptr< data::ModelData > d_modelData_p
Reference to model class.
double computeMeshSize(const std::vector< util::Point > &nodes)
Computes minimum distance between any two nodes.
Collection of methods and data related to finite element and mesh.
Definition mesh.cpp:29
std::string getTabS(int nt)
Returns tab spaces of a given size.
Definition io.h:82
double selfContactStiffness(const double &K, const double &horizon, int horizonPower=5)
Contact stiffness for a body against itself.
Definition function.cpp:148
A struct that stores transformation parameters and provides method to transform the particle....
util::Point apply(const util::Point &v) const
Maps a reference-configuration point to world coordinates using the same rule as geom::mapSimilarity...
double d_scale
Uniform scale factor.
Structure to read and store material related data.
double d_horizonMeshRatio
Horizon to mesh ratio.
std::string d_materialType
Material type.
double d_horizon
Horizon for peridynamic interaction.
A structure to represent 3d vectors.
Definition point.h:30
double d_x
the x coordinate
Definition point.h:33