Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactor] Particle variables and functions handling #654

Closed
wants to merge 66 commits into from
Closed
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
f3f6fb2
:computer: Refactor particle to handle scalar and vector properties
kks32 Jun 29, 2020
ad09dfa
:dart: Add testing to particle refactor of scalar properties
kks32 Jun 29, 2020
e68ab89
:computer: Compute mass free function
kks32 Jul 4, 2020
d40b6b0
Merge branch 'develop' of https://github.com/cb-geo/mpm into refactor…
bodhinandach Jul 7, 2020
67303d8
:wrench: modify mass, mass_density_volume
bodhinandach Jul 8, 2020
0a6ac16
:wrench: modify compute_mass function
bodhinandach Jul 8, 2020
adfd93f
:wrench: refactor particle velocity and displacement
bodhinandach Jul 9, 2020
2b92b3f
:wrench: refactor nodal mass and volume
bodhinandach Jul 9, 2020
336cfe6
:wrench: refactor nodal velocity and acceleration
bodhinandach Jul 9, 2020
91d5c97
:wrench: refactor nodal momentum, external, and internal forces
bodhinandach Jul 9, 2020
8ed2eb8
:wrench: refactor nodal pressure
bodhinandach Jul 9, 2020
02911bf
:wrench: Add scalar and vector properties enum
bodhinandach Jul 9, 2020
0feaf6d
:wrench: aesthetic clean up order of initialise()
bodhinandach Jul 9, 2020
bcfb878
:wrench: fix particle vector_properties_ size order
bodhinandach Jul 9, 2020
99b9eea
:dart: add testings for update and return functions
bodhinandach Jul 9, 2020
315cfae
Merge branch 'develop' of https://github.com/cb-geo/mpm into refactor…
bodhinandach Jul 9, 2020
2f54b90
:wrench: add overload functions of mapping
bodhinandach Jul 9, 2020
0facda0
:construction: :dart: test nightly benchmarks with refactored particl…
bodhinandach Jul 9, 2020
4136654
:construction: :dart: refactor map_mass_momentum and tests
bodhinandach Jul 10, 2020
9da224f
Merge branch 'develop' of https://github.com/cb-geo/mpm into refactor…
bodhinandach Jul 10, 2020
cb71c90
:construction: :dart: refactor map_body_force and update_volume
bodhinandach Jul 10, 2020
52eb2b3
:construction: :dart: change assign_velocity to void and cleanup
bodhinandach Jul 10, 2020
a20a2ab
:dart: revert mass change in particle test
bodhinandach Jul 10, 2020
0a0cf7b
:construction: :dart: add return cell pointer and refactor compute_vo…
bodhinandach Jul 10, 2020
fe0f9bf
:wrench: add assert in return and update scalar and vector properties
bodhinandach Jul 10, 2020
b693709
:construction: :dart: return set traction and refactor map traction
bodhinandach Jul 10, 2020
5fc100e
:construction: :dart: refactor pressure smoothing
bodhinandach Jul 12, 2020
bfee43a
:construction: change assign pressure to update pressure
bodhinandach Jul 12, 2020
2727d34
:construction: :dart: refactor update_mass_pressure
bodhinandach Jul 12, 2020
f9602fd
:wrench: fix return value of interpolate vector properties
bodhinandach Jul 12, 2020
a3ee684
:construction: :dart: use interpolate functions in particle
bodhinandach Jul 12, 2020
45aa3ba
:construction: refactor pressure smoothing interpolation
bodhinandach Jul 13, 2020
212505e
:dart: fix and add pressure mapping test
bodhinandach Jul 13, 2020
1251bd7
:construction: add TODO notes in particle.tcc
bodhinandach Jul 13, 2020
27ea5d6
:dart: add test for assign and return scalar and vector property
bodhinandach Jul 13, 2020
b888b07
Merge branch 'develop' of https://github.com/cb-geo/mpm into refactor…
bodhinandach Jul 13, 2020
ae339f1
:wrench: clang format
bodhinandach Jul 13, 2020
f34b64c
:wrench: remove virtual in initialise particle
bodhinandach Jul 14, 2020
164491f
:dart: :construction_worker: revert benchmarks to gcc
bodhinandach Jul 14, 2020
3d35f45
:wrench: modify explanation as suggested
bodhinandach Jul 14, 2020
deb54a7
:construction: :dart: some minor corrections and test addition
bodhinandach Jul 15, 2020
fcfcf87
:hammer: Improve performance with vector
kks32 Jul 17, 2020
385fcca
:pencil: AssocVector
kks32 Jul 18, 2020
86341a6
:fire: Remove unnecessary files
kks32 Jul 20, 2020
c8b65cd
:fire: Delete flat_map
kks32 Jul 20, 2020
5421984
:pencil: External flat_map
kks32 Jul 20, 2020
23be100
:fire: Remove unused includes
kks32 Jul 20, 2020
83a1257
Merge branch 'refactor/particles' into refactor/particles-assocvec
bodhinandach Jul 20, 2020
fc8a8a2
Merge pull request #672 from kks32/refactor/particles-assocvec
cbgeo Jul 21, 2020
222ca55
:wrench: change flat map initialisation
bodhinandach Jul 21, 2020
da461c3
:pencil: External flat_map
kks32 Jul 20, 2020
532aca8
:wrench: add mpm_properties
bodhinandach Jul 21, 2020
b017a99
:wrench: clang-format
bodhinandach Jul 21, 2020
6de587f
:wrench: add functions and container in node
bodhinandach Jul 21, 2020
9f42d94
:wrench: add functions and container in particle
bodhinandach Jul 21, 2020
da1682e
:construction: cosmetic changes as suggested
bodhinandach Jul 21, 2020
3e1f9ff
:construction: add boolean property
bodhinandach Jul 22, 2020
a687fa8
Merge branch 'refactor/particles_properties' of https://github.com/cb…
bodhinandach Jul 22, 2020
47c5f48
:wrench: modify function calls
bodhinandach Jul 22, 2020
6e2913b
Merge branch 'develop' into refactor/particles
ezrayst Jul 24, 2020
4899191
Merge branch 'develop' of https://github.com/cb-geo/mpm into refactor…
bodhinandach Jul 25, 2020
b8a3932
:construction: :dart: add set_traction to boolean_properties and add …
bodhinandach Jul 25, 2020
f2a982c
Merge branch 'develop' of https://github.com/cb-geo/mpm into refactor…
bodhinandach Jul 25, 2020
68506c1
:wrench: fix particle_function for pressure smoothing
bodhinandach Jul 25, 2020
0666b0a
:construction: :dart: refactor and add test for nodal boolean properties
bodhinandach Jul 25, 2020
a0bbd15
Merge branch 'develop' of https://github.com/cb-geo/mpm into refactor…
bodhinandach Jul 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,617 changes: 1,617 additions & 0 deletions external/tsl/ordered_hash.h

Large diffs are not rendered by default.

833 changes: 833 additions & 0 deletions external/tsl/ordered_map.h

Large diffs are not rendered by default.

688 changes: 688 additions & 0 deletions external/tsl/ordered_set.h

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions include/mesh.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -1202,8 +1202,10 @@ void mpm::Mesh<Tdim>::apply_traction_on_particles(double current_time) {
std::placeholders::_1, dir, traction));
}
if (!particle_tractions_.empty()) {
this->iterate_over_particles(std::bind(
&mpm::ParticleBase<Tdim>::map_traction_force, std::placeholders::_1));
this->iterate_over_particles(
[](std::shared_ptr<mpm::ParticleBase<Tdim>> ptr) {
return mpm::particle::map_traction_force<Tdim>(ptr);
});
}
}

Expand Down Expand Up @@ -1751,8 +1753,8 @@ void mpm::Mesh<Tdim>::inject_particles(double current_time) {
}
}
for (auto particle : injected_particles) {
particle->compute_volume();
particle->compute_mass();
mpm::particle::compute_volume<Tdim>(particle);
mpm::particle::compute_mass<Tdim>(particle);
}
}
}
Expand Down
26 changes: 26 additions & 0 deletions include/mpm_properties.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef MPM_PROPERTIES_H_
#define MPM_PROPERTIES_H_

namespace mpm {
namespace properties {
//! Scalar Properties
enum Scalar : unsigned int {
Mass = 0,
Volume = 1,
MassDensity = 2,
MassPressure = 3,
Pressure = 4
};
//! Vector Properties
enum Vector : unsigned int {
Displacement = 0,
Velocity = 1,
Acceleration = 2,
Momentum = 3,
ExternalForce = 4,
InternalForce = 5
};
} // namespace properties
} // namespace mpm

#endif // MPM_PROPERTIES_H_
82 changes: 55 additions & 27 deletions include/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,35 @@ class Node : public NodeBase<Tdim> {
//! Return status
bool status() const override { return status_; }

//! Update scalar property at the nodes
//! \param[in] property Name of the property to update
//! \param[in] update A boolean to update (true) or assign (false)
//! \param[in] phase Index corresponding to the phase
//! \param[in] value Property value from the particles in a cell
void update_scalar_property(mpm::properties::Scalar property, bool update,
unsigned phase, double value) noexcept override;

//! Return property at a given node for a given phase
//! \param[in] property Name of the property to return
//! \param[in] phase Index corresponding to the phase
double scalar_property(mpm::properties::Scalar property,
unsigned phase) const override;

//! Update vector property at the nodes
//! \param[in] property Name of the property to update
//! \param[in] update A boolean to update (true) or assign (false)
//! \param[in] phase Index corresponding to the phase
//! \param[in] value Property value from the particles in a cell
virtual void update_vector_property(
mpm::properties::Vector property, bool update, unsigned phase,
const Eigen::Matrix<double, Tdim, 1>& value) noexcept override;

//! Return property at a given node for a given phase
//! \param[in] property Name of the property to return
//! \param[in] phase Index corresponding to the phase
virtual Eigen::Matrix<double, Tdim, 1> vector_property(
mpm::properties::Vector property, unsigned phase) const override;

//! Update mass at the nodes from particle
//! \param[in] update A boolean to update (true) or assign (false)
//! \param[in] phase Index corresponding to the phase
Expand All @@ -73,7 +102,9 @@ class Node : public NodeBase<Tdim> {

//! Return mass at a given node for a given phase
//! \param[in] phase Index corresponding to the phase
double mass(unsigned phase) const override { return mass_(phase); }
double mass(unsigned phase) const override {
return this->scalar_property(mpm::properties::Scalar::Mass, phase);
}

//! Update volume at the nodes from particle
//! \param[in] update A boolean to update (true) or assign (false)
Expand All @@ -84,7 +115,9 @@ class Node : public NodeBase<Tdim> {

//! Return volume at a given node for a given phase
//! \param[in] phase Index corresponding to the phase
double volume(unsigned phase) const override { return volume_(phase); }
double volume(unsigned phase) const override {
return this->scalar_property(mpm::properties::Scalar::Volume, phase);
}

//! Assign concentrated force to the node
//! \param[in] phase Index corresponding to the phase
Expand All @@ -111,7 +144,7 @@ class Node : public NodeBase<Tdim> {
//! Return external force at a given node for a given phase
//! \param[in] phase Index corresponding to the phase
VectorDim external_force(unsigned phase) const override {
return external_force_.col(phase);
return this->vector_property(mpm::properties::Vector::ExternalForce, phase);
}

//! Update internal force (body force / traction force)
Expand All @@ -124,24 +157,31 @@ class Node : public NodeBase<Tdim> {
//! Return internal force at a given node for a given phase
//! \param[in] phase Index corresponding to the phase
VectorDim internal_force(unsigned phase) const override {
return internal_force_.col(phase);
return this->vector_property(mpm::properties::Vector::InternalForce, phase);
}

//! Update pressure at the nodes from particle
//! \param[in] update A boolean to update (true) or assign (false)
//! \param[in] phase Index corresponding to the phase
//! \param[in] mass_pressure Product of mass x pressure of a particle
void update_mass_pressure(unsigned phase,
void update_mass_pressure(bool update, unsigned phase,
double mass_pressure) noexcept override;

//! Compute pressure from the mass pressure
virtual void compute_pressure() override;

//! Assign pressure at the nodes from particle
//! \param[in] update A boolean to update (true) or assign (false)
//! \param[in] phase Index corresponding to the phase
//! \param[in] mass_pressure Product of mass x pressure of a particle
void assign_pressure(unsigned phase, double mass_pressure) override;
//! \param[in] pressure Pressure of a particle
virtual void update_pressure(bool update, unsigned phase,
double pressure) override;

//! Return pressure at a given node for a given phase
//! \param[in] phase Index corresponding to the phase
double pressure(unsigned phase) const override { return pressure_(phase); }
double pressure(unsigned phase) const override {
return this->scalar_property(mpm::properties::Scalar::Pressure, phase);
}

//! Update momentum at the nodes
//! \param[in] update A boolean to update (true) or assign (false)
Expand All @@ -153,7 +193,7 @@ class Node : public NodeBase<Tdim> {
//! Return momentum at a given node for a given phase
//! \param[in] phase Index corresponding to the phase
VectorDim momentum(unsigned phase) const override {
return momentum_.col(phase);
return this->vector_property(mpm::properties::Vector::Momentum, phase);
}

//! Compute velocity from the momentum
Expand All @@ -162,7 +202,7 @@ class Node : public NodeBase<Tdim> {
//! Return velocity at a given node for a given phase
//! \param[in] phase Index corresponding to the phase
VectorDim velocity(unsigned phase) const override {
return velocity_.col(phase);
return this->vector_property(mpm::properties::Vector::Velocity, phase);
}

//! Update nodal acceleration
Expand All @@ -175,7 +215,7 @@ class Node : public NodeBase<Tdim> {
//! Return acceleration at a given node for a given phase
//! \param[in] phase Index corresponding to the phase
VectorDim acceleration(unsigned phase) const override {
return acceleration_.col(phase);
return this->vector_property(mpm::properties::Vector::Acceleration, phase);
}

//! Compute acceleration and velocity
Expand Down Expand Up @@ -278,24 +318,12 @@ class Node : public NodeBase<Tdim> {
unsigned dof_{std::numeric_limits<unsigned>::max()};
//! Status
bool status_{false};
//! Mass
Eigen::Matrix<double, 1, Tnphases> mass_;
//! Volume
Eigen::Matrix<double, 1, Tnphases> volume_;
//! External force
Eigen::Matrix<double, Tdim, Tnphases> external_force_;
//! Internal force
Eigen::Matrix<double, Tdim, Tnphases> internal_force_;
//! Pressure
Eigen::Matrix<double, 1, Tnphases> pressure_;
//! Scalar properties
std::vector<Eigen::Matrix<double, 1, Tnphases>> scalar_properties_;
//! Vector properties
std::vector<Eigen::Matrix<double, Tdim, Tnphases>> vector_properties_;
//! Displacement
Eigen::Matrix<double, Tdim, 1> contact_displacement_;
//! Velocity
Eigen::Matrix<double, Tdim, Tnphases> velocity_;
//! Momentum
Eigen::Matrix<double, Tdim, Tnphases> momentum_;
//! Acceleration
Eigen::Matrix<double, Tdim, Tnphases> acceleration_;
//! Velocity constraints
std::map<unsigned, double> velocity_constraints_;
//! Rotation matrix for general velocity constraints
Expand Down
Loading