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

Removing virtual where unneeded #148

Merged
merged 1 commit into from
Mar 22, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions include/FrictionQPotFEM/Generic2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,24 +120,27 @@ class System {
Set material parameters for the elastic elements
(taken uniform per element, ordering the same as in the constructor).

\tparam S e.g. `xt::xtensor<double, 1>`.
\tparam T e.g. `xt::xtensor<double, 1>`.
\param K_elem Bulk modulus per element.
\param G_elem Bulk modulus per element.
*/
virtual void
setElastic(const xt::xtensor<double, 1>& K_elem, const xt::xtensor<double, 1>& G_elem);
template <class S, class T>
void setElastic(const S& K_elem, const T& G_elem);

/**
Set material parameters for the plastic elements
(taken uniform per element, ordering the same as in the constructor).

\tparam S e.g. `xt::xtensor<double, 1>`.
\tparam T e.g. `xt::xtensor<double, 1>`.
\tparam Y e.g. `xt::xtensor<double, 2>`.
\param K_elem Bulk modulus per element.
\param G_elem Bulk modulus per element.
\param epsy_elem Yield history per element.
*/
virtual void setPlastic(
const xt::xtensor<double, 1>& K_elem,
const xt::xtensor<double, 1>& G_elem,
const xt::xtensor<double, 2>& epsy_elem);
template <class S, class T, class Y>
void setPlastic(const S& K_elem, const T& G_elem, const Y& epsy_elem);

/**
Get the current yield strains per plastic element.
Expand All @@ -149,9 +152,11 @@ class System {

/**
Reset yield strains (to avoid re-construction).
\tparam T e.g. `xt::xtensor<double, 2>`.
\param epsy_elem Yield history per element.
*/
virtual void reset_epsy(const xt::xtensor<double, 2>& epsy_elem);
template <class T>
void reset_epsy(const T& epsy_elem);

/**
Check if elasticity is homogeneous.
Expand Down
23 changes: 12 additions & 11 deletions include/FrictionQPotFEM/Generic2d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,12 @@ inline void System::setDampingMatrix(const T& val_elem)
this->evalAllSet();
}

inline void
System::setElastic(const xt::xtensor<double, 1>& K_elem, const xt::xtensor<double, 1>& G_elem)
template <class S, class T>
inline void System::setElastic(const S& K_elem, const T& G_elem)
{
FRICTIONQPOTFEM_ASSERT(!m_set_elas || m_nelem_elas == 0);
FRICTIONQPOTFEM_ASSERT(K_elem.size() == m_nelem_elas);
FRICTIONQPOTFEM_ASSERT(G_elem.size() == m_nelem_elas);
FRICTIONQPOTFEM_ASSERT(xt::has_shape(K_elem, {m_nelem_elas}));
FRICTIONQPOTFEM_ASSERT(xt::has_shape(G_elem, {m_nelem_elas}));

if (m_nelem_elas > 0) {
xt::xtensor<size_t, 2> I(std::array<size_t, 2>{m_nelem_elas, m_nip}, 1);
Expand All @@ -250,14 +250,13 @@ System::setElastic(const xt::xtensor<double, 1>& K_elem, const xt::xtensor<doubl
this->evalAllSet();
}

inline void System::setPlastic(
const xt::xtensor<double, 1>& K_elem,
const xt::xtensor<double, 1>& G_elem,
const xt::xtensor<double, 2>& epsy_elem)
template <class S, class T, class Y>
inline void System::setPlastic(const S& K_elem, const T& G_elem, const Y& epsy_elem)
{
FRICTIONQPOTFEM_ASSERT(!m_set_plas || m_nelem_plas == 0);
FRICTIONQPOTFEM_ASSERT(K_elem.size() == m_nelem_plas);
FRICTIONQPOTFEM_ASSERT(G_elem.size() == m_nelem_plas);
FRICTIONQPOTFEM_ASSERT(xt::has_shape(K_elem, {m_nelem_plas}));
FRICTIONQPOTFEM_ASSERT(xt::has_shape(G_elem, {m_nelem_plas}));
FRICTIONQPOTFEM_ASSERT(epsy_elem.dimension() == 2);
FRICTIONQPOTFEM_ASSERT(epsy_elem.shape(0) == m_nelem_plas);

if (m_nelem_plas > 0) {
Expand All @@ -278,9 +277,11 @@ inline void System::setPlastic(
this->evalAllSet();
}

inline void System::reset_epsy(const xt::xtensor<double, 2>& epsy_elem)
template <class T>
inline void System::reset_epsy(const T& epsy_elem)
{
FRICTIONQPOTFEM_ASSERT(m_set_plas);
FRICTIONQPOTFEM_ASSERT(epsy_elem.dimension() == 2);
FRICTIONQPOTFEM_ASSERT(epsy_elem.shape(0) == m_nelem_plas);

if (m_nelem_plas > 0) {
Expand Down
13 changes: 10 additions & 3 deletions python/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,27 @@ PYBIND11_MODULE(_FrictionQPotFEM, mod)

cls.def(
"setElastic",
&SUB::System::setElastic,
&SUB::System::setElastic<xt::pytensor<double, 1>, xt::pytensor<double, 1>>,
"setElastic",
py::arg("K_elem"),
py::arg("G_elem"));

cls.def(
"setPlastic",
&SUB::System::setPlastic,
&SUB::System::setPlastic<
xt::pytensor<double, 1>,
xt::pytensor<double, 1>,
xt::pytensor<double, 2>>,
"setPlastic",
py::arg("K_elem"),
py::arg("G_elem"),
py::arg("epsy_elem"));

cls.def("reset_epsy", &SUB::System::reset_epsy, "reset_epsy", py::arg("epsy_elem"));
cls.def(
"reset_epsy",
&SUB::System::reset_epsy<xt::pytensor<double, 2>>,
"reset_epsy",
py::arg("epsy_elem"));

cls.def(
"isHomogeneousElastic", &SUB::System::isHomogeneousElastic, "isHomogeneousElastic");
Expand Down