diff --git a/src/cell/cell_traits.hh b/src/cell/cell_traits.hh index 7437fae..442e9b0 100644 --- a/src/cell/cell_traits.hh +++ b/src/cell/cell_traits.hh @@ -1,59 +1,58 @@ /** * @file cell_traits.hh * * @author Till Junge * * @date 19 Jan 2018 * * @brief Provides traits for Eigen solvers to be able to use Cells * * Copyright © 2018 Till Junge * * µSpectre is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser 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 Lesser 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. * * Additional permission under GNU GPL version 3 section 7 * * If you modify this Program, or any covered work, by linking or combining it * with proprietary FFT implementations or numerical libraries, containing parts * covered by the terms of those libraries' licenses, the licensors of this * Program grant you additional permission to convey the resulting work. */ #include "common/common.hh" #include #ifndef SRC_CELL_CELL_TRAITS_HH_ #define SRC_CELL_CELL_TRAITS_HH_ namespace muSpectre { - template - class CellAdaptor; + template class CellAdaptor; } // namespace muSpectre namespace Eigen { namespace internal { using Dim_t = muSpectre::Dim_t; //!< universal index type using Real = muSpectre::Real; //!< universal real value type template struct traits> : public Eigen::internal::traits> {}; } // namespace internal } // namespace Eigen #endif // SRC_CELL_CELL_TRAITS_HH_ diff --git a/src/materials/material_anisotropic.hh b/src/materials/material_anisotropic.hh index 305d3da..5f9a7b6 100644 --- a/src/materials/material_anisotropic.hh +++ b/src/materials/material_anisotropic.hh @@ -1,154 +1,152 @@ /** * @file material_anisotropic.hh * * @author Ali Falsafi * * @date 9 Jul 2018 * * @brief Base class for materials (constitutive models) * * Copyright © 2017 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 GNU Emacs; see the file COPYING. If not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef MATERIAL_ANISOTROPIC_H #define MATERIAL_ANISOTROPIC_H #include "materials/material_base.hh" #include "materials/material_muSpectre_base.hh" #include "common/common.hh" #include "common/T4_map_proxy.hh" namespace muSpectre { - template - class MaterialAnisotropic; + template class MaterialAnisotropic; // traits for anisotropic material template struct MaterialMuSpectre_traits> { using Parent = MaterialMuSpectre_traits; //!< base for elasticity //! global field collection using GFieldCollection_t = typename MaterialBase::GFieldCollection_t; //! expected map type for strain fields using StrainMap_t = MatrixFieldMap; //! expected map type for stress fields using StressMap_t = MatrixFieldMap; //! expected map type for tangent stiffness fields using TangentMap_t = T4MatrixFieldMap; //! declare what type of strain measure your law takes as input constexpr static auto strain_measure{StrainMeasure::GreenLagrange}; //! declare what type of stress measure your law yields as output constexpr static auto stress_measure{StressMeasure::PK2}; //! anisotropicity without internal variables using InternalVariables = std::tuple<>; }; /** * Material implementation for anisotropic constitutive law */ template class MaterialAnisotropic : public MaterialMuSpectre, DimS, DimM> { //! base class using Parent = MaterialMuSpectre; using Stiffness_t = T4Mat; //! traits of this material using traits = MaterialMuSpectre_traits; //! this law does not have any internal variables using InternalVariables = typename traits::InternalVariables; public: EIGEN_MAKE_ALIGNED_OPERATOR_NEW using parent = MaterialMuSpectre, DimS, DimM>; //! global field collection using GFieldCollection_t = typename MaterialBase::GFieldCollection_t; //! expected map type for tangent stiffness fields using Tangent_t = T4MatrixFieldMap; //! Default constructor MaterialAnisotropic() = delete; // constructor // a std::vector is utilized as the input of the constructor to // enable us to check its length so to prevent user mistake MaterialAnisotropic(std::string name, std::vector input_c); //! Copy constructor MaterialAnisotropic(const MaterialAnisotropic & other) = delete; //! Move constructor MaterialAnisotropic(MaterialAnisotropic && other) = delete; //! Destructor virtual ~MaterialAnisotropic() = default; - template - inline decltype(auto) evaluate_stress(s_t && E); + template inline decltype(auto) evaluate_stress(s_t && E); /** * evaluates both second Piola-Kirchhoff stress and stiffness given * the Green-Lagrange strain (or Cauchy stress and stiffness if * called with a small strain tensor) and the local stiffness tensor. */ template inline decltype(auto) evaluate_stress_tangent(s_t && E); /** * return the empty internals tuple */ InternalVariables & get_internals() { return this->internal_variables; }; // takes the elements of the C and makes it: static auto c_maker(std::vector input) -> Stiffness_t; protected: Stiffness_t C; //!< stiffness tensor //! empty tuple InternalVariables internal_variables{}; }; /* ---------------------------------------------------------------------- */ template template decltype(auto) MaterialAnisotropic::evaluate_stress(s_t && E) { return Matrices::tensmult(this->C, E); } /* ---------------------------------------------------------------------- */ template template decltype(auto) MaterialAnisotropic::evaluate_stress_tangent(s_t && E) { return std::make_tuple(evaluate_stress(E), this->C); } } // namespace muSpectre #endif diff --git a/src/materials/material_linear_elastic4.cc b/src/materials/material_linear_elastic4.cc index 73be1db..6147043 100644 --- a/src/materials/material_linear_elastic4.cc +++ b/src/materials/material_linear_elastic4.cc @@ -1,79 +1,79 @@ /** * @file material_linear_elastic4.cc * * @author Richard Leute MaterialLinearElastic4::MaterialLinearElastic4(std::string name) : Parent{name}, lambda_field{make_field( "local first Lame constant", this->internal_fields)}, mu_field{ make_field("local second Lame constant(shear modulus)", this->internal_fields)}, internal_variables{lambda_field.get_const_map(), mu_field.get_const_map()} {} /* ---------------------------------------------------------------------- */ template void MaterialLinearElastic4::add_pixel( const Ccoord_t & /*pixel*/) { throw std::runtime_error( "this material needs pixels with Youngs modulus and Poisson ratio."); } /* ---------------------------------------------------------------------- */ template void MaterialLinearElastic4::add_pixel(const Ccoord_t & pixel, const Real & Young_modulus, const Real & Poisson_ratio) { this->internal_fields.add_pixel(pixel); // store the first(lambda) and second(mu) Lame constant in the field Real lambda = Hooke::compute_lambda(Young_modulus, Poisson_ratio); Real mu = Hooke::compute_mu(Young_modulus, Poisson_ratio); this->lambda_field.push_back(lambda); this->mu_field.push_back(mu); } template class MaterialLinearElastic4; template class MaterialLinearElastic4; template class MaterialLinearElastic4; } // namespace muSpectre