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

New features QPot #55

Merged
merged 6 commits into from Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -42,6 +42,7 @@ conveniently compiled to this [PDF](docs/readme.pdf).
- [Upgrading instructions](#upgrading-instructions)
- [Upgrading to v0.6.*](#upgrading-to-v06)
- [Change-log](#change-log)
- [v0.7.0](#v070)
- [v0.6.4](#v064)
- [v0.6.3](#v063)
- [v0.6.2](#v062)
Expand Down Expand Up @@ -466,6 +467,11 @@ This requires the following changes:

# Change-log

## v0.7.0

* Exposing "checkYieldBoundLeft" and "checkYieldBoundRight" from QPot v0.2.0.
* Proper float testing using Catch2.

## v0.6.4

* Increasing robustness using the new xtensor's `has_fixed_rank` and `get_rank`.
Expand Down
2 changes: 2 additions & 0 deletions examples/CMakeLists.txt
Expand Up @@ -21,6 +21,8 @@ foreach(testsourcefile ${APP_SOURCES})
add_executable(${testname} ${testsourcefile})

find_package(GooseFEM REQUIRED)
find_package(xtensor REQUIRED)
find_package(xsimd REQUIRED)

target_link_libraries(${testname} PUBLIC
GMatElastoPlasticQPot
Expand Down
2 changes: 2 additions & 0 deletions examples/friction-optimized.cpp
Expand Up @@ -314,6 +314,8 @@ class System {

xt::noalias(m_u) = m_u + m_dt * m_v + 0.5 * std::pow(m_dt, 2.) * m_a;

// compute strain/strain, and corresponding force

computeStrainStressForcesWeakLayer();

#ifdef CHECK_MYSHORTCUT
Expand Down
1 change: 1 addition & 0 deletions examples/friction.cpp
Expand Up @@ -140,6 +140,7 @@ class System {

m_Eps = m_quad.AllocateQtensor<2>(0.0);
m_Sig = m_quad.AllocateQtensor<2>(0.0);

// --------
// material
// --------
Expand Down
10 changes: 10 additions & 0 deletions include/GMatElastoPlasticQPot/Cartesian2d.h
Expand Up @@ -149,6 +149,10 @@ class Cusp
double epsp() const; // "plastic strain" (mean of currentYieldLeft and currentYieldRight)
double energy() const; // potential energy

// Check that 'the particle' is at least "n" wells from the far-left/right
bool checkYieldBoundLeft(size_t n = 0) const;
bool checkYieldBoundRight(size_t n = 0) const;

private:
double m_K; // bulk modulus
double m_G; // shear modulus
Expand Down Expand Up @@ -200,6 +204,10 @@ class Smooth
double epsp() const; // "plastic strain" (mean of currentYieldLeft and currentYieldRight)
double energy() const; // potential energy

// Check that 'the particle' is at least "n" wells from the far-left/right
bool checkYieldBoundLeft(size_t n = 0) const;
bool checkYieldBoundRight(size_t n = 0) const;

private:
double m_K; // bulk modulus
double m_G; // shear modulus
Expand Down Expand Up @@ -316,6 +324,8 @@ class Array
void currentIndex(xt::xtensor<size_t, rank>& arg) const;
void currentYieldLeft(xt::xtensor<double, rank>& arg) const;
void currentYieldRight(xt::xtensor<double, rank>& arg) const;
bool checkYieldBoundLeft(size_t n = 0) const;
bool checkYieldBoundRight(size_t n = 0) const;
void epsp(xt::xtensor<double, rank>& arg) const;
void energy(xt::xtensor<double, rank>& arg) const;

Expand Down
52 changes: 52 additions & 0 deletions include/GMatElastoPlasticQPot/Cartesian2d_Array.hpp
Expand Up @@ -502,6 +502,58 @@ inline void Array<rank>::currentIndex(xt::xtensor<size_t, rank>& A) const
}
}

template <size_t rank>
inline bool Array<rank>::checkYieldBoundLeft(size_t n) const
{
GMATELASTOPLASTICQPOT_ASSERT(m_allSet);

#pragma omp parallel for
for (size_t i = 0; i < m_size; ++i) {
switch (m_type.data()[i]) {
case Type::Elastic:
break;
case Type::Cusp:
if (!m_Cusp[m_index.data()[i]].checkYieldBoundLeft(n)) {
return false;
}
break;
case Type::Smooth:
if (!m_Smooth[m_index.data()[i]].checkYieldBoundLeft(n)) {
return false;
}
break;
}
}

return true;
}

template <size_t rank>
inline bool Array<rank>::checkYieldBoundRight(size_t n) const
{
GMATELASTOPLASTICQPOT_ASSERT(m_allSet);

#pragma omp parallel for
for (size_t i = 0; i < m_size; ++i) {
switch (m_type.data()[i]) {
case Type::Elastic:
break;
case Type::Cusp:
if (!m_Cusp[m_index.data()[i]].checkYieldBoundRight(n)) {
return false;
}
break;
case Type::Smooth:
if (!m_Smooth[m_index.data()[i]].checkYieldBoundRight(n)) {
return false;
}
break;
}
}

return true;
}

template <size_t rank>
inline void Array<rank>::currentYieldLeft(xt::xtensor<double, rank>& A) const
{
Expand Down
10 changes: 10 additions & 0 deletions include/GMatElastoPlasticQPot/Cartesian2d_Cusp.hpp
Expand Up @@ -147,6 +147,16 @@ inline double Cusp::energy() const
return U + V;
}

inline bool Cusp::checkYieldBoundLeft(size_t n) const
{
return m_yield.checkYieldBoundLeft(n);
}

inline bool Cusp::checkYieldBoundRight(size_t n) const
{
return m_yield.checkYieldBoundRight(n);
}

} // namespace Cartesian2d
} // namespace GMatElastoPlasticQPot

Expand Down
10 changes: 10 additions & 0 deletions include/GMatElastoPlasticQPot/Cartesian2d_Smooth.hpp
Expand Up @@ -149,6 +149,16 @@ inline double Smooth::energy() const
return U + V;
}

inline bool Smooth::checkYieldBoundLeft(size_t n) const
{
return m_yield.checkYieldBoundLeft(n);
}

inline bool Smooth::checkYieldBoundRight(size_t n) const
{
return m_yield.checkYieldBoundRight(n);
}

} // namespace Cartesian2d
} // namespace GMatElastoPlasticQPot

Expand Down
4 changes: 2 additions & 2 deletions include/GMatElastoPlasticQPot/config.h
Expand Up @@ -49,8 +49,8 @@
#endif

#define GMATELASTOPLASTICQPOT_VERSION_MAJOR 0
#define GMATELASTOPLASTICQPOT_VERSION_MINOR 6
#define GMATELASTOPLASTICQPOT_VERSION_PATCH 4
#define GMATELASTOPLASTICQPOT_VERSION_MINOR 7
#define GMATELASTOPLASTICQPOT_VERSION_PATCH 0

#define GMATELASTOPLASTICQPOT_VERSION_AT_LEAST(x,y,z) \
(GMATELASTOPLASTICQPOT_VERSION_MAJOR > x || (GMATELASTOPLASTICQPOT_VERSION_MAJOR >= x && \
Expand Down
90 changes: 51 additions & 39 deletions python/main.cpp
Expand Up @@ -24,59 +24,35 @@ auto add_common_members_array(T& self)

self.def(py::init<std::array<size_t, rank>>(), "Matrix of material points.", py::arg("shape"))

.def("shape", &SM::Array<rank>::shape, "Return matrix shape.")
.def("shape", &SM::Array<rank>::shape, "Matrix shape.")

.def("K", &SM::Array<rank>::K, "Return matrix with bulk moduli.")
.def("K", &SM::Array<rank>::K, "Matrix with bulk moduli.")

.def("G", &SM::Array<rank>::G, "Return matrix with shear moduli.")
.def("G", &SM::Array<rank>::G, "Matrix with shear moduli.")

.def("I2", &SM::Array<rank>::I2, "Return matrix with second order unit tensors.")
.def("I2", &SM::Array<rank>::I2, "Matrix with 2nd-order unit tensors.")

.def(
"II",
&SM::Array<rank>::II,
"Return matrix with fourth order tensors with the result of the dyadic product II.")
.def("II", &SM::Array<rank>::II, "Matrix with 4th-order tensors = dyadic(I2, I2).")

.def("I4", &SM::Array<rank>::I4, "Return matrix with fourth order unit tensors.")
.def("I4", &SM::Array<rank>::I4, "Matrix with 4th-order unit tensors.")

.def(
"I4rt",
&SM::Array<rank>::I4rt,
"Return matrix with fourth right-transposed order unit tensors.")
.def("I4rt", &SM::Array<rank>::I4rt, "Matrix with 4th-order right-transposed unit tensors.")

.def(
"I4s",
&SM::Array<rank>::I4s,
"Return matrix with fourth order symmetric projection tensors.")
.def("I4s", &SM::Array<rank>::I4s, "Matrix with 4th-order symmetric projection tensors.")

.def(
"I4d",
&SM::Array<rank>::I4d,
"Return matrix with fourth order deviatoric projection tensors.")
.def("I4d", &SM::Array<rank>::I4d, "Matrix with 4th-order deviatoric projection tensors.")

.def("type", &SM::Array<rank>::type, "Return matrix with material types.")
.def("type", &SM::Array<rank>::type, "Matrix with material types.")

.def(
"isElastic",
&SM::Array<rank>::isElastic,
"Return matrix with boolean: Elastic (1) or not (0).")
.def("isElastic", &SM::Array<rank>::isElastic, "Boolean-matrix: true for Elastic.")

.def(
"isPlastic",
&SM::Array<rank>::isPlastic,
"Return matrix with boolean: Elastic (0) or plastic (Cusp/Smooth) (1).")
.def("isPlastic", &SM::Array<rank>::isPlastic, "Boolean-matrix: true for Cusp/Smooth.")

.def("isCusp", &SM::Array<rank>::isCusp, "Return matrix with boolean: Cusp (1) or not (0).")
.def("isCusp", &SM::Array<rank>::isCusp, "Boolean-matrix: true for Cusp.")

.def(
"isSmooth",
&SM::Array<rank>::isSmooth,
"Return matrix with boolean: Smooth (1) or not (0).")
.def("isSmooth", &SM::Array<rank>::isSmooth, "Boolean-matrix: true for Smooth.")

.def(
"check",
&SM::Array<rank>::check,
"Check that all matrix entries are set. Throws if any unset point is found.")
.def("check", &SM::Array<rank>::check, "Throws if any unset point is found.")

.def(
"setElastic",
Expand Down Expand Up @@ -195,6 +171,18 @@ auto add_common_members_array(T& self)
&SM::Array<rank>::CurrentYieldRight,
"Returns matrix of yield strains to the left, given the current strain.")

.def(
"checkYieldBoundLeft",
&SM::Array<rank>::checkYieldBoundLeft,
"Check that 'the particle' is at least 'n' wells from the far-left.",
py::arg("n") = 0)

.def(
"checkYieldBoundRight",
&SM::Array<rank>::checkYieldBoundRight,
"Check that 'the particle' is at least 'n' wells from the far-right.",
py::arg("n") = 0)

.def(
"Epsp",
&SM::Array<rank>::Epsp,
Expand Down Expand Up @@ -385,6 +373,18 @@ PYBIND11_MODULE(GMatElastoPlasticQPot, m)
&SM::Cusp::currentYieldRight,
"Returns the yield strain to the right, for last known strain.")

.def(
"checkYieldBoundLeft",
&SM::Cusp::checkYieldBoundLeft,
"Check that 'the particle' is at least 'n' wells from the far-left.",
py::arg("n") = 0)

.def(
"checkYieldBoundRight",
&SM::Cusp::checkYieldBoundRight,
"Check that 'the particle' is at least 'n' wells from the far-right.",
py::arg("n") = 0)

.def(
"epsp", &SM::Cusp::epsp, "Returns the equivalent plastic strain for last known strain.")

Expand Down Expand Up @@ -436,6 +436,18 @@ PYBIND11_MODULE(GMatElastoPlasticQPot, m)
&SM::Smooth::currentYieldRight,
"Returns the yield strain to the right, for last known strain.")

.def(
"checkYieldBoundLeft",
&SM::Smooth::checkYieldBoundLeft,
"Check that 'the particle' is at least 'n' wells from the far-left.",
py::arg("n") = 0)

.def(
"checkYieldBoundRight",
&SM::Smooth::checkYieldBoundRight,
"Check that 'the particle' is at least 'n' wells from the far-right.",
py::arg("n") = 0)

.def(
"epsp",
&SM::Smooth::epsp,
Expand Down