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

Kelvin-Voigt Boundary Implementation for #692 #710

Open
wants to merge 23 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9c73b25
Kelvin-Voight Boundary Condition Implementation
cgeudeker Mar 24, 2021
55d7b19
First Edits, and absorbing constraint file
cgeudeker Mar 25, 2021
97e282d
Merge branch 'develop' into material
cgeudeker Mar 25, 2021
e1d24ce
Test cases
cgeudeker May 19, 2021
d61aafa
Test cases
cgeudeker May 19, 2021
e30d186
Test cases, minor fix
cgeudeker May 19, 2021
6a53280
Test Case for Absorbing Constraint File
cgeudeker May 25, 2021
04380c3
Minor Fixes
cgeudeker May 25, 2021
4999748
Switched Assert for If Statement
cgeudeker May 25, 2021
e1ccc53
Absorbing Boundary in Scheme
cgeudeker Aug 1, 2021
f082fbf
Merge branch 'develop' of https://github.com/cb-geo/mpm into material
jgiven100 Aug 12, 2021
fe5f74e
:hammer: add position input to absorb boundary
jgiven100 Aug 19, 2021
472fce5
:hammer::fire: remove unused variables
jgiven100 Aug 19, 2021
f3b70e6
:hammer: change absorb bound position from string to enum
jgiven100 Aug 19, 2021
fd06771
:dart::heavy_check_mark: update absorb boundary tests
jgiven100 Aug 19, 2021
f5f2d1b
:hammer::bug: replace if with switch statement and cppcheck suppress
jgiven100 Aug 19, 2021
805626c
:bug::hammer: fix traction -> force for absorb boundary
jgiven100 Sep 21, 2021
1e3e479
Merge branch 'develop' of https://github.com/cb-geo/mpm into material
jgiven100 Nov 24, 2021
229e1d7
:wrench::sparkles: add 3d support for Kelvin-Voigt
jgiven100 Nov 24, 2021
746283d
:construction::dart: improve test coverage
jgiven100 Nov 25, 2021
397e6e9
:bug: clang-format
jgiven100 Nov 25, 2021
6fa65b9
:construction::dart: improve test coverage
jgiven100 Nov 25, 2021
4cbc60a
:dart::fire: tidy commented-out lines
jgiven100 Nov 25, 2021
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
6 changes: 6 additions & 0 deletions include/io/io_mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ class IOMesh {
read_friction_constraints(
const std::string& friction_constraints_file) = 0;

//! Read absorbing constraints file
//! \param[in] absorbing_constraints_files file name with tractions
jgiven100 marked this conversation as resolved.
Show resolved Hide resolved
virtual std::vector<std::tuple<mpm::Index, unsigned, double, double, double>>
read_absorbing_constraints(
const std::string& absorbing_constraints_file) = 0;

//! Read forces file
//! \param[in] forces_files file name with nodal concentrated force
virtual std::vector<std::tuple<mpm::Index, unsigned, double>> read_forces(
Expand Down
6 changes: 6 additions & 0 deletions include/io/io_mesh_ascii.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ class IOMeshAscii : public IOMesh<Tdim> {
read_friction_constraints(
const std::string& friction_constraints_file) override;

//! Read absorping constraints file
jgiven100 marked this conversation as resolved.
Show resolved Hide resolved
//! \param[in] absorbing_constraints_files file name with tractions
std::vector<std::tuple<mpm::Index, unsigned, double, double, double>>
read_absorbing_constraints(
const std::string& absorbing_constraints_file) override;

//! Read traction file
//! \param[in] forces_files file name with nodal concentrated force
std::vector<std::tuple<mpm::Index, unsigned, double>> read_forces(
Expand Down
51 changes: 51 additions & 0 deletions include/io/io_mesh_ascii.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,57 @@ std::vector<std::tuple<mpm::Index, unsigned, int, double>>
return constraints;
}

//! Return absorbing constraints of particles
template <unsigned Tdim>
jgiven100 marked this conversation as resolved.
Show resolved Hide resolved
std::vector<std::tuple<mpm::Index, unsigned, double, double, double>>
mpm::IOMeshAscii<Tdim>::read_absorbing_constraints(
const std::string& absorbing_constraints_file) {

// Nodal absorbing constraints
std::vector<std::tuple<mpm::Index, unsigned, double, double, double>>
constraints;
constraints.clear();

// input file stream
std::fstream file;
file.open(absorbing_constraints_file.c_str(), std::ios::in);

try {
if (file.is_open() && file.good()) {
// Line
std::string line;
while (std::getline(file, line)) {
boost::algorithm::trim(line);
std::istringstream istream(line);
// ignore comment lines (# or !) or blank lines
if ((line.find('#') == std::string::npos) &&
(line.find('!') == std::string::npos) && (line != "")) {
while (istream.good()) {
// ID
mpm::Index id;
// Direction
unsigned dir;
// Delta
double delta;
// a
double a;
// b
double b;
// Read stream
istream >> id >> dir >> delta >> a >> b;
constraints.emplace_back(std::make_tuple(id, dir, delta, a, b));
}
}
}
}
file.close();
} catch (std::exception& exception) {
console_->error("Read absorbing constraints: {}", exception.what());
file.close();
}
return constraints;
}

//! Return particles force
template <unsigned Tdim>
std::vector<std::tuple<mpm::Index, unsigned, double>>
Expand Down
14 changes: 14 additions & 0 deletions include/loads_bcs/constraints.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <memory>

#include "absorbing_constraint.h"
jgiven100 marked this conversation as resolved.
Show resolved Hide resolved
#include "friction_constraint.h"
#include "logger.h"
#include "mesh.h"
Expand Down Expand Up @@ -48,6 +49,19 @@ class Constraints {
const std::vector<std::tuple<mpm::Index, unsigned, int, double>>&
friction_constraints);

//! Assign nodal absorbing constraints
//! \param[in] setid Node set id
//! \param[in] absorbing_constraints Constraint at node, dir, delta, a, b
jgiven100 marked this conversation as resolved.
Show resolved Hide resolved
bool assign_nodal_absorbing_constraint(
int nset_id,
const std::shared_ptr<mpm::AbsorbingConstraint>& aconstraints);
jgiven100 marked this conversation as resolved.
Show resolved Hide resolved

//! Assign absorbing constraints to nodes
//! \param[in] absorbing_constraints Constraint at node, dir, delta, a, and b
bool assign_nodal_absorbing_constraints(
const std::vector<std::tuple<mpm::Index, unsigned, double, double,
double>>& absorbing_constraints);

private:
//! Mesh object
std::shared_ptr<mpm::Mesh<Tdim>> mesh_;
Expand Down
62 changes: 62 additions & 0 deletions include/loads_bcs/constraints.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,65 @@ bool mpm::Constraints<Tdim>::assign_nodal_friction_constraints(
}
return status;
}

//! Assign absorbing constraints to nodes
template <unsigned Tdim>
bool mpm::Constraints<Tdim>::assign_nodal_absorbing_constraint(
int nset_id, const std::shared_ptr<mpm::AbsorbingConstraint>& aconstraint) {
bool status = true;
try {
int set_id = aconstraint->setid();
auto nset = mesh_->nodes(set_id);
if (nset.size() == 0)
throw std::runtime_error(
"Node set is empty for assignment of absorbing constraints");
unsigned dir = aconstraint->dir();
double delta = aconstraint->delta();
double a = aconstraint->a();
double b = aconstraint->b();
double h_min = 1.0; // mesh_->cells()->mean_length_;
for (auto nitr = nset.cbegin(); nitr != nset.cend(); ++nitr) {
if (!(*nitr)->assign_absorbing_constraint(dir, delta, a, b, h_min))
throw std::runtime_error(
"Failed to initialise absorbing constraint at node");
}
} catch (std::exception& exception) {
console_->error("{} #{}: {}\n", __FILE__, __LINE__, exception.what());
status = false;
}
return status;
}

//! Assign absorbing constraints to nodes
template <unsigned Tdim>
bool mpm::Constraints<Tdim>::assign_nodal_absorbing_constraints(
const std::vector<std::tuple<mpm::Index, unsigned, double, double, double>>&
absorbing_constraints) {
bool status = true;
try {
for (const auto& absorbing_constraint : absorbing_constraints) {
// Node id
mpm::Index nid = std::get<0>(absorbing_constraint);
// Direction
unsigned dir = std::get<1>(absorbing_constraint);
// Delta
double delta = std::get<2>(absorbing_constraint);
// a
double a = std::get<3>(absorbing_constraint);
// b
double b = std::get<4>(absorbing_constraint);
// Cell Height
double h_min = 1.0; // mesh_->cells()->mean_length_;

// Apply constraint
if (!mesh_->node(nid)->assign_absorbing_constraint(dir, delta, a, b,
h_min))
throw std::runtime_error(
"Nodal absorbing constraints assignment failed");
}
} catch (std::exception& exception) {
console_->error("{} #{}: {}\n", __FILE__, __LINE__, exception.what());
status = false;
}
return status;
}
17 changes: 17 additions & 0 deletions include/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,19 @@ class Node : public NodeBase<Tdim> {
//! \param[in] dt Time-step
void apply_friction_constraints(double dt) override;

//! Assign absorbing constraint
//! Directions can take values between 0 and Dim * Nphases
//! \param[in] dir Direction of absorbing constraint
//! \param[in] delta Virtual viscous layer thickness
//! \param[in] a Equation constant
jgiven100 marked this conversation as resolved.
Show resolved Hide resolved
//! \param[in] a Equation constant
//! \param[in] h_min Characteristic Length
bool assign_absorbing_constraint(unsigned dir, double delta, double a,
double b, double h_min) override;

//! Apply absorbing_constraint
void apply_absorbing_constraint() override;

//! Assign rotation matrix
//! \param[in] rotation_matrix Rotation matrix of the node
void assign_rotation_matrix(
Expand Down Expand Up @@ -306,6 +319,10 @@ class Node : public NodeBase<Tdim> {
//! A general velocity (non-Cartesian/inclined) constraint is specified at the
//! node
bool generic_boundary_constraints_{false};
//! Absorbing constraints
jgiven100 marked this conversation as resolved.
Show resolved Hide resolved
std::tuple<unsigned, double, double, double> absorbing_constraint_;
//! Absorbing traction
Eigen::Matrix<double, Tdim, 1> absorbing_traction_;
jgiven100 marked this conversation as resolved.
Show resolved Hide resolved
//! Frictional constraints
bool friction_{false};
std::tuple<unsigned, int, double> friction_constraint_;
Expand Down
72 changes: 72 additions & 0 deletions include/node.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,78 @@ void mpm::Node<Tdim, Tdof, Tnphases>::apply_velocity_constraints() {
}
}
}
//! Assign absorbing constraints
template <unsigned Tdim, unsigned Tdof, unsigned Tnphases>
bool mpm::Node<Tdim, Tdof, Tnphases>::assign_absorbing_constraint(
unsigned dir, double delta, double a, double b, double h_min) {
bool status = true;
try {
assert(dir <= Tdim);
if (delta >= h_min / (2 * a) and delta >= h_min / (2 * b)) {
jgiven100 marked this conversation as resolved.
Show resolved Hide resolved
jgiven100 marked this conversation as resolved.
Show resolved Hide resolved
this->absorbing_constraint_ = std::make_tuple(
static_cast<unsigned>(dir), static_cast<double>(delta),
static_cast<double>(a), static_cast<double>(b));
} else
throw std::runtime_error("Delta input is too small");
} catch (std::exception& exception) {
console_->error("{} #{}: {}\n", __FILE__, __LINE__, exception.what());
status = false;
}
return status;
}

// !Apply absorbing constraints
template <unsigned Tdim, unsigned Tdof, unsigned Tnphases>
void mpm::Node<Tdim, Tdof, Tnphases>::apply_absorbing_constraint() {
// Normal direction
const unsigned dir = std::get<0>(this->absorbing_constraint_);

// Delta value
const double delta = std::get<1>(this->absorbing_constraint_);

// a coefficient
const double a = std::get<2>(this->absorbing_constraint_);

// b coefficient
const double b = std::get<3>(this->absorbing_constraint_);

// Get material id
auto mat_id = material_ids_.begin();

// Extract material properties and displacements
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to check if the node has only one material, otherwise this would be incorrect...

double pwave_v = this->property_handle_->property("pwave_velocity", prop_id_,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When do we map this information?

*mat_id)(0, 0);
double swave_v = this->property_handle_->property("swave_velocity", prop_id_,
*mat_id)(0, 0);
double density =
this->property_handle_->property("density", prop_id_, *mat_id)(0, 0);
const Eigen::Matrix<double, Tdim, 1> material_displacement =
this->property_handle_->property("displacements", prop_id_, *mat_id,
Tdim);

// Wave velocity Eigen Matrix
Eigen::Matrix<double, Tdim, 1> wave_velocity =
Eigen::MatrixXd::Constant(Tdim, 1, b * swave_v);
wave_velocity(dir, 0) = a * pwave_v;

// Spring constant Eigen matrix
double k_s = (density * pow(swave_v, 2)) / delta;
double k_p = (density * pow(pwave_v, 2)) / delta;
Eigen::Matrix<double, Tdim, 1> spring_constant =
Eigen::MatrixXd::Constant(Tdim, 1, k_s);
spring_constant(dir, 0) = k_p;

// Iterate through each phase
for (unsigned phase = 0; phase < Tnphases; ++phase) {
// Calculate Aborbing Traction
Eigen::Matrix<double, Tdim, 1> absorbing_traction_ =
jgiven100 marked this conversation as resolved.
Show resolved Hide resolved
this->velocity_.col(phase).cwiseProduct(wave_velocity) * density +
material_displacement.cwiseProduct(spring_constant);

// Update external force
this->update_external_force(true, phase, -absorbing_traction_);
}
}

//! Assign friction constraint
//! Constrain directions can take values between 0 and Dim * Nphases
Expand Down
13 changes: 13 additions & 0 deletions include/node_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,19 @@ class NodeBase {
//! \param[in] dt Time-step
virtual void apply_friction_constraints(double dt) = 0;

//! Assign absorbing constraint
//! Directions can take values between 0 and Dim * Nphases
//! \param[in] dir Direction of absorbing constraint
//! \param[in] delta Virtual viscous layer thickness
//! \param[in] a Equation constant
//! \param[in] a Equation constant
//! \param[in] h_min Characteristic Length
virtual bool assign_absorbing_constraint(unsigned dir, double delta, double a,
double b, double h_min) = 0;

//! Apply absorbing_constraint
virtual void apply_absorbing_constraint() = 0;

//! Assign rotation matrix
//! \param[in] rotation_matrix Rotation matrix of the node
virtual void assign_rotation_matrix(
Expand Down
6 changes: 6 additions & 0 deletions include/solvers/mpm_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ class MPMBase : public MPM {
void nodal_frictional_constraints(
const Json& mesh_prop, const std::shared_ptr<mpm::IOMesh<Tdim>>& mesh_io);

//! Nodal absorbing constraints
//! \param[in] mesh_prop Mesh properties
//! \param[in] mesh_io Mesh IO handle
void nodal_absorbing_constraints(
const Json& mesh_prop, const std::shared_ptr<mpm::IOMesh<Tdim>>& mesh_io);

//! Cell entity sets
//! \param[in] mesh_prop Mesh properties
//! \param[in] check Check duplicates
Expand Down
59 changes: 59 additions & 0 deletions include/solvers/mpm_base.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ void mpm::MPMBase<Tdim>::initialise_mesh() {
// Read and assign friction constraints
this->nodal_frictional_constraints(mesh_props, mesh_io);

// Read and assign absorbing constraintes
this->nodal_absorbing_constraints(mesh_props, mesh_io);

// Initialise cell
auto cells_begin = std::chrono::steady_clock::now();
// Shape function name
Expand Down Expand Up @@ -937,6 +940,62 @@ void mpm::MPMBase<Tdim>::nodal_frictional_constraints(
}
}

// Nodal absorbing constraints
template <unsigned Tdim>
void mpm::MPMBase<Tdim>::nodal_absorbing_constraints(
const Json& mesh_props, const std::shared_ptr<mpm::IOMesh<Tdim>>& mesh_io) {
try {
// Read and assign absorbing constraints
if (mesh_props.find("boundary_conditions") != mesh_props.end() &&
mesh_props["boundary_conditions"].find("absorbing_constraints") !=
mesh_props["boundary_conditions"].end()) {
// Iterate over velocity constraints
for (const auto& constraints :
mesh_props["boundary_conditions"]["absorbing_constraints"]) {
// Absorbing constraints are specified in a file
if (constraints.find("file") != constraints.end()) {
std::string absorbing_constraints_file =
constraints.at("file").template get<std::string>();
bool absorbing_constraints =
constraints_->assign_nodal_absorbing_constraints(
mesh_io->read_absorbing_constraints(
io_->file_name(absorbing_constraints_file)));
if (!absorbing_constraints)
throw std::runtime_error(
"Absorbing constraints are not properly assigned");

} else {
jgiven100 marked this conversation as resolved.
Show resolved Hide resolved

// Set id
int nset_id = constraints.at("nset_id").template get<int>();
// Direction
unsigned dir = constraints.at("dir").template get<unsigned>();
// Delta
double delta = constraints.at("delta").template get<double>();
// a
double a = constraints.at("a").template get<double>();
// b
double b = constraints.at("b").template get<double>();
// Add absorbing constraint to mesh
auto absorbing_constraint =
std::make_shared<mpm::AbsorbingConstraint>(nset_id, dir, delta, a,
b);
bool absorbing_constraints =
constraints_->assign_nodal_absorbing_constraint(
nset_id, absorbing_constraint);
if (!absorbing_constraints)
throw std::runtime_error(
"Nodal absorbing constraint is not properly assigned");
}
}
} else
throw std::runtime_error("Absorbing constraints JSON not found");

} catch (std::exception& exception) {
console_->warn("#{}: Absorbing conditions are undefined {} ", __LINE__,
exception.what());
}
}
//! Cell entity sets
template <unsigned Tdim>
void mpm::MPMBase<Tdim>::cell_entity_sets(const Json& mesh_props,
Expand Down