/** * @file stress_transformations_PK2_impl.hh * * @author Till Junge * * @date 29 Oct 2018 * * @brief Implementation of stress conversions for PK2 stress * * Copyright © 2018 Till Junge * * µSpectre is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3, or (at * your option) any later version. * * µSpectre is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with µSpectre; see the file COPYING. If not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef SRC_MATERIALS_STRESS_TRANSFORMATIONS_PK2_IMPL_HH_ #define SRC_MATERIALS_STRESS_TRANSFORMATIONS_PK2_IMPL_HH_ namespace muSpectre { namespace MatTB { namespace internal { /* ---------------------------------------------------------------------- */ /** * Specialisation for the case where we get material stress * (Piola-Kirchhoff-2, PK2) */ template struct PK1_stress : public PK1_stress { //! returns the converted stress template inline static decltype(auto) compute(Strain_t && F, Stress_t && S) { return F * S; } }; /* ---------------------------------------------------------------------- */ /** * Specialisation for the case where we get material stress * (Piola-Kirchhoff-2, PK2) derived with respect to * Green-Lagrange strain */ template struct PK1_stress : public PK1_stress { //! base class using Parent = PK1_stress; using Parent::compute; //! returns the converted stress and stiffness template inline static decltype(auto) compute(Strain_t && F, Stress_t && S, Tangent_t && C) { using T4 = typename std::remove_reference_t::PlainObject; using Tmap = T4MatMap; T4 K; Tmap Kmap{K.data()}; K.setZero(); for (int i = 0; i < Dim; ++i) { for (int m = 0; m < Dim; ++m) { for (int n = 0; n < Dim; ++n) { get(Kmap, i, m, i, n) += S(m, n); for (int j = 0; j < Dim; ++j) { for (int r = 0; r < Dim; ++r) { for (int s = 0; s < Dim; ++s) { get(Kmap, i, m, j, n) += F(i, r) * get(C, r, m, s, n) * (F(j, s)); } } } } } } auto && P = compute(std::forward(F), std::forward(S)); return std::make_tuple(std::move(P), std::move(K)); } }; /* ---------------------------------------------------------------------- */ /** * Specialisation for the case where we get material stress * (Piola-Kirchhoff-2, PK2) derived with respect to * the placement Gradient (F) */ template struct PK1_stress : public PK1_stress { //! base class using Parent = PK1_stress; using Parent::compute; //! returns the converted stress and stiffness template inline static decltype(auto) compute(Strain_t && F, Stress_t && S, Tangent_t && C) { using T4 = typename std::remove_reference_t::PlainObject; using Tmap = T4MatMap; T4 K; Tmap Kmap{K.data()}; K.setZero(); for (int i = 0; i < Dim; ++i) { for (int m = 0; m < Dim; ++m) { for (int n = 0; n < Dim; ++n) { get(Kmap, i, m, i, n) += S(m, n); for (int j = 0; j < Dim; ++j) { for (int r = 0; r < Dim; ++r) { get(Kmap, i, m, j, n) += F(i, r) * get(C, r, m, j, n); } } } } } auto && P = compute(std::forward(F), std::forward(S)); return std::make_tuple(std::move(P), std::move(K)); } }; } // namespace internal } // namespace MatTB } // namespace muSpectre #endif // SRC_MATERIALS_STRESS_TRANSFORMATIONS_PK2_IMPL_HH_