Skip to content

Commit

Permalink
Correct the names of nodal phases
Browse files Browse the repository at this point in the history
  • Loading branch information
tianchiTJ committed Nov 4, 2020
1 parent ad851bf commit 2b195ee
Show file tree
Hide file tree
Showing 7 changed files with 608 additions and 608 deletions.
2 changes: 1 addition & 1 deletion include/node.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ void mpm::Node<Tdim, Tdof,
const Eigen::Matrix<double, Tdim, 1> momentum =
property_handle_->property("momenta", prop_id_, *mitr, Tdim);
const Eigen::Matrix<double, Tdim, 1> change_in_momenta =
velocity_.col(mpm::NodePhase::nSolid) * mass - momentum;
velocity_.col(mpm::NodePhase::NSolid) * mass - momentum;
property_handle_->update_property("change_in_momenta", prop_id_, *mitr,
change_in_momenta, Tdim);
}
Expand Down
6 changes: 3 additions & 3 deletions include/node_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ namespace mpm {

//! Particle phases
enum NodePhase : unsigned int {
nSolid = 0,
nLiquid = 1,
NSolid = 0,
NLiquid = 1,
nGas = 2,
nMixture = 0
NMixture = 0
};

//! NodeBase base class for nodes
Expand Down
92 changes: 46 additions & 46 deletions include/node_twophase.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@ bool mpm::Node<Tdim, Tdof, Tnphases>::
compute_acceleration_velocity_twophase_explicit(double dt) noexcept {
bool status = false;
const double tolerance = 1.0E-15;
if (this->mass(mpm::NodePhase::nSolid) > tolerance &&
this->mass(mpm::NodePhase::nLiquid) > tolerance) {
if (this->mass(mpm::NodePhase::NSolid) > tolerance &&
this->mass(mpm::NodePhase::NLiquid) > tolerance) {
// Compute drag force
VectorDim drag_force = drag_force_coefficient_.cwiseProduct(
velocity_.col(mpm::NodePhase::nLiquid) -
velocity_.col(mpm::NodePhase::nSolid));
velocity_.col(mpm::NodePhase::NLiquid) -
velocity_.col(mpm::NodePhase::NSolid));

// Acceleration of pore fluid (momentume balance of fluid phase)
this->acceleration_.col(mpm::NodePhase::nLiquid) =
(this->external_force_.col(mpm::NodePhase::nLiquid) +
this->internal_force_.col(mpm::NodePhase::nLiquid) - drag_force) /
this->mass_(mpm::NodePhase::nLiquid);
this->acceleration_.col(mpm::NodePhase::NLiquid) =
(this->external_force_.col(mpm::NodePhase::NLiquid) +
this->internal_force_.col(mpm::NodePhase::NLiquid) - drag_force) /
this->mass_(mpm::NodePhase::NLiquid);

// Acceleration of solid skeleton (momentume balance of mixture)
this->acceleration_.col(mpm::NodePhase::nSolid) =
(this->external_force_.col(mpm::NodePhase::nMixture) +
this->internal_force_.col(mpm::NodePhase::nMixture) -
this->mass_(mpm::NodePhase::nLiquid) *
this->acceleration_.col(mpm::NodePhase::nLiquid)) /
this->mass_(mpm::NodePhase::nSolid);
this->acceleration_.col(mpm::NodePhase::NSolid) =
(this->external_force_.col(mpm::NodePhase::NMixture) +
this->internal_force_.col(mpm::NodePhase::NMixture) -
this->mass_(mpm::NodePhase::NLiquid) *
this->acceleration_.col(mpm::NodePhase::NLiquid)) /
this->mass_(mpm::NodePhase::NSolid);

// Apply friction constraints
this->apply_friction_constraints(dt);
Expand All @@ -52,14 +52,14 @@ bool mpm::Node<Tdim, Tdof, Tnphases>::

// Set a threshold
for (unsigned i = 0; i < Tdim; ++i) {
if (std::abs(velocity_.col(mpm::NodePhase::nSolid)(i)) < tolerance)
velocity_.col(mpm::NodePhase::nSolid)(i) = 0.;
if (std::abs(acceleration_.col(mpm::NodePhase::nSolid)(i)) < tolerance)
acceleration_.col(mpm::NodePhase::nSolid)(i) = 0.;
if (std::abs(velocity_.col(mpm::NodePhase::nLiquid)(i)) < tolerance)
velocity_.col(mpm::NodePhase::nLiquid)(i) = 0.;
if (std::abs(acceleration_.col(mpm::NodePhase::nLiquid)(i)) < tolerance)
acceleration_.col(mpm::NodePhase::nLiquid)(i) = 0.;
if (std::abs(velocity_.col(mpm::NodePhase::NSolid)(i)) < tolerance)
velocity_.col(mpm::NodePhase::NSolid)(i) = 0.;
if (std::abs(acceleration_.col(mpm::NodePhase::NSolid)(i)) < tolerance)
acceleration_.col(mpm::NodePhase::NSolid)(i) = 0.;
if (std::abs(velocity_.col(mpm::NodePhase::NLiquid)(i)) < tolerance)
velocity_.col(mpm::NodePhase::NLiquid)(i) = 0.;
if (std::abs(acceleration_.col(mpm::NodePhase::NLiquid)(i)) < tolerance)
acceleration_.col(mpm::NodePhase::NLiquid)(i) = 0.;
}
status = true;
}
Expand All @@ -74,36 +74,36 @@ bool mpm::Node<Tdim, Tdof, Tnphases>::
bool status = false;
const double tolerance = 1.0E-15;

if (this->mass(mpm::NodePhase::nSolid) > tolerance &&
this->mass(mpm::NodePhase::nLiquid) > tolerance) {
if (this->mass(mpm::NodePhase::NSolid) > tolerance &&
this->mass(mpm::NodePhase::NLiquid) > tolerance) {
// Compute drag force
VectorDim drag_force = drag_force_coefficient_.cwiseProduct(
velocity_.col(mpm::NodePhase::nLiquid) -
velocity_.col(mpm::NodePhase::nSolid));
velocity_.col(mpm::NodePhase::NLiquid) -
velocity_.col(mpm::NodePhase::NSolid));

// Unbalanced force of liquid phase
auto unbalanced_force_liquid =
this->external_force_.col(mpm::NodePhase::nLiquid) +
this->internal_force_.col(mpm::NodePhase::nLiquid) - drag_force;
this->external_force_.col(mpm::NodePhase::NLiquid) +
this->internal_force_.col(mpm::NodePhase::NLiquid) - drag_force;
// Acceleration of liquid phase (momentume balance of fluid phase)
this->acceleration_.col(mpm::NodePhase::nLiquid) =
this->acceleration_.col(mpm::NodePhase::NLiquid) =
(unbalanced_force_liquid -
damping_factor * unbalanced_force_liquid.norm() *
this->velocity_.col(mpm::NodePhase::nLiquid).cwiseSign()) /
this->mass(mpm::NodePhase::nLiquid);
this->velocity_.col(mpm::NodePhase::NLiquid).cwiseSign()) /
this->mass(mpm::NodePhase::NLiquid);

// Unbalanced force of solid phase
auto unbalanced_force_solid =
this->external_force_.col(mpm::NodePhase::nMixture) +
this->internal_force_.col(mpm::NodePhase::nMixture) -
this->mass_(mpm::NodePhase::nLiquid) *
this->acceleration_.col(mpm::NodePhase::nLiquid);
this->external_force_.col(mpm::NodePhase::NMixture) +
this->internal_force_.col(mpm::NodePhase::NMixture) -
this->mass_(mpm::NodePhase::NLiquid) *
this->acceleration_.col(mpm::NodePhase::NLiquid);
// Acceleration of solid phase (momentume balance of mixture)
this->acceleration_.col(mpm::NodePhase::nSolid) =
this->acceleration_.col(mpm::NodePhase::NSolid) =
(unbalanced_force_solid -
damping_factor * unbalanced_force_solid.norm() *
this->velocity_.col(mpm::NodePhase::nSolid).cwiseSign()) /
this->mass(mpm::NodePhase::nSolid);
this->velocity_.col(mpm::NodePhase::NSolid).cwiseSign()) /
this->mass(mpm::NodePhase::NSolid);

// Apply friction constraints
this->apply_friction_constraints(dt);
Expand All @@ -117,14 +117,14 @@ bool mpm::Node<Tdim, Tdof, Tnphases>::

// Set a threshold
for (unsigned i = 0; i < Tdim; ++i) {
if (std::abs(velocity_.col(mpm::NodePhase::nSolid)(i)) < tolerance)
velocity_.col(mpm::NodePhase::nSolid)(i) = 0.;
if (std::abs(acceleration_.col(mpm::NodePhase::nSolid)(i)) < tolerance)
acceleration_.col(mpm::NodePhase::nSolid)(i) = 0.;
if (std::abs(velocity_.col(mpm::NodePhase::nLiquid)(i)) < tolerance)
velocity_.col(mpm::NodePhase::nLiquid)(i) = 0.;
if (std::abs(acceleration_.col(mpm::NodePhase::nLiquid)(i)) < tolerance)
acceleration_.col(mpm::NodePhase::nLiquid)(i) = 0.;
if (std::abs(velocity_.col(mpm::NodePhase::NSolid)(i)) < tolerance)
velocity_.col(mpm::NodePhase::NSolid)(i) = 0.;
if (std::abs(acceleration_.col(mpm::NodePhase::NSolid)(i)) < tolerance)
acceleration_.col(mpm::NodePhase::NSolid)(i) = 0.;
if (std::abs(velocity_.col(mpm::NodePhase::NLiquid)(i)) < tolerance)
velocity_.col(mpm::NodePhase::NLiquid)(i) = 0.;
if (std::abs(acceleration_.col(mpm::NodePhase::NLiquid)(i)) < tolerance)
acceleration_.col(mpm::NodePhase::NLiquid)(i) = 0.;
}
status = true;
}
Expand Down
32 changes: 16 additions & 16 deletions include/solvers/mpm_explicit_twophase.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -161,29 +161,29 @@ bool mpm::MPMExplicitTwoPhase<Tdim>::solve() {
// MPI all reduce nodal mass for solid phase
mesh_->template nodal_halo_exchange<double, 1>(
std::bind(&mpm::NodeBase<Tdim>::mass, std::placeholders::_1,
mpm::NodePhase::nSolid),
mpm::NodePhase::NSolid),
std::bind(&mpm::NodeBase<Tdim>::update_mass, std::placeholders::_1,
false, mpm::NodePhase::nSolid, std::placeholders::_2));
false, mpm::NodePhase::NSolid, std::placeholders::_2));
// MPI all reduce nodal momentum for solid phase
mesh_->template nodal_halo_exchange<Eigen::Matrix<double, Tdim, 1>, Tdim>(
std::bind(&mpm::NodeBase<Tdim>::momentum, std::placeholders::_1,
mpm::NodePhase::nSolid),
mpm::NodePhase::NSolid),
std::bind(&mpm::NodeBase<Tdim>::update_momentum,
std::placeholders::_1, false, mpm::NodePhase::nSolid,
std::placeholders::_1, false, mpm::NodePhase::NSolid,
std::placeholders::_2));

// MPI all reduce nodal mass for liquid phase
mesh_->template nodal_halo_exchange<double, 1>(
std::bind(&mpm::NodeBase<Tdim>::mass, std::placeholders::_1,
mpm::NodePhase::nLiquid),
mpm::NodePhase::NLiquid),
std::bind(&mpm::NodeBase<Tdim>::update_mass, std::placeholders::_1,
false, mpm::NodePhase::nLiquid, std::placeholders::_2));
false, mpm::NodePhase::NLiquid, std::placeholders::_2));
// MPI all reduce nodal momentum for liquid phase
mesh_->template nodal_halo_exchange<Eigen::Matrix<double, Tdim, 1>, Tdim>(
std::bind(&mpm::NodeBase<Tdim>::momentum, std::placeholders::_1,
mpm::NodePhase::nLiquid),
mpm::NodePhase::NLiquid),
std::bind(&mpm::NodeBase<Tdim>::update_momentum,
std::placeholders::_1, false, mpm::NodePhase::nLiquid,
std::placeholders::_1, false, mpm::NodePhase::NLiquid,
std::placeholders::_2));
}
#endif
Expand Down Expand Up @@ -263,31 +263,31 @@ bool mpm::MPMExplicitTwoPhase<Tdim>::solve() {
// MPI all reduce external force of mixture
mesh_->template nodal_halo_exchange<Eigen::Matrix<double, Tdim, 1>, Tdim>(
std::bind(&mpm::NodeBase<Tdim>::external_force, std::placeholders::_1,
mpm::NodePhase::nMixture),
mpm::NodePhase::NMixture),
std::bind(&mpm::NodeBase<Tdim>::update_external_force,
std::placeholders::_1, false, mpm::NodePhase::nMixture,
std::placeholders::_1, false, mpm::NodePhase::NMixture,
std::placeholders::_2));
// MPI all reduce external force of pore fluid
mesh_->template nodal_halo_exchange<Eigen::Matrix<double, Tdim, 1>, Tdim>(
std::bind(&mpm::NodeBase<Tdim>::external_force, std::placeholders::_1,
mpm::NodePhase::nLiquid),
mpm::NodePhase::NLiquid),
std::bind(&mpm::NodeBase<Tdim>::update_external_force,
std::placeholders::_1, false, mpm::NodePhase::nLiquid,
std::placeholders::_1, false, mpm::NodePhase::NLiquid,
std::placeholders::_2));

// MPI all reduce internal force of mixture
mesh_->template nodal_halo_exchange<Eigen::Matrix<double, Tdim, 1>, Tdim>(
std::bind(&mpm::NodeBase<Tdim>::internal_force, std::placeholders::_1,
mpm::NodePhase::nMixture),
mpm::NodePhase::NMixture),
std::bind(&mpm::NodeBase<Tdim>::update_internal_force,
std::placeholders::_1, false, mpm::NodePhase::nMixture,
std::placeholders::_1, false, mpm::NodePhase::NMixture,
std::placeholders::_2));
// MPI all reduce internal force of pore liquid
mesh_->template nodal_halo_exchange<Eigen::Matrix<double, Tdim, 1>, Tdim>(
std::bind(&mpm::NodeBase<Tdim>::internal_force, std::placeholders::_1,
mpm::NodePhase::nLiquid),
mpm::NodePhase::NLiquid),
std::bind(&mpm::NodeBase<Tdim>::update_internal_force,
std::placeholders::_1, false, mpm::NodePhase::nLiquid,
std::placeholders::_1, false, mpm::NodePhase::NLiquid,
std::placeholders::_2));

// MPI all reduce drag force
Expand Down
18 changes: 9 additions & 9 deletions tests/nodes/node_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,13 @@ TEST_CASE("Node is checked for 1D case", "[node][1D]") {
// Check pressure constraints
SECTION("Check nodal pressure constraints") {
// Check assign pressure constraint
REQUIRE(node->assign_pressure_constraint(mpm::NodePhase::nSolid, 8000,
REQUIRE(node->assign_pressure_constraint(mpm::NodePhase::NSolid, 8000,
nullptr) == true);
// Check apply pressure constraint
REQUIRE_NOTHROW(
node->apply_pressure_constraint(mpm::NodePhase::nSolid));
node->apply_pressure_constraint(mpm::NodePhase::NSolid));
// Check pressure
REQUIRE(node->pressure(mpm::NodePhase::nSolid) ==
REQUIRE(node->pressure(mpm::NodePhase::NSolid) ==
Approx(8000).epsilon(Tolerance));
}
}
Expand Down Expand Up @@ -636,13 +636,13 @@ TEST_CASE("Node is checked for 2D case", "[node][2D]") {
// Check pressure constraints
SECTION("Check nodal pressure constraints") {
// Check assign pressure constraint
REQUIRE(node->assign_pressure_constraint(mpm::NodePhase::nSolid, 8000,
REQUIRE(node->assign_pressure_constraint(mpm::NodePhase::NSolid, 8000,
nullptr) == true);
// Check apply pressure constraint
REQUIRE_NOTHROW(
node->apply_pressure_constraint(mpm::NodePhase::nSolid));
node->apply_pressure_constraint(mpm::NodePhase::NSolid));
// Check pressure
REQUIRE(node->pressure(mpm::NodePhase::nSolid) ==
REQUIRE(node->pressure(mpm::NodePhase::NSolid) ==
Approx(8000).epsilon(Tolerance));
}
}
Expand Down Expand Up @@ -1250,13 +1250,13 @@ TEST_CASE("Node is checked for 3D case", "[node][3D]") {
// Check pressure constraints
SECTION("Check nodal pressure constraints") {
// Check assign pressure constraint
REQUIRE(node->assign_pressure_constraint(mpm::NodePhase::nSolid, 8000,
REQUIRE(node->assign_pressure_constraint(mpm::NodePhase::NSolid, 8000,
nullptr) == true);
// Check apply pressure constraint
REQUIRE_NOTHROW(
node->apply_pressure_constraint(mpm::NodePhase::nSolid));
node->apply_pressure_constraint(mpm::NodePhase::NSolid));
// Check pressure
REQUIRE(node->pressure(mpm::NodePhase::nSolid) ==
REQUIRE(node->pressure(mpm::NodePhase::NSolid) ==
Approx(8000).epsilon(Tolerance));
}
}
Expand Down
Loading

0 comments on commit 2b195ee

Please sign in to comment.