Page MenuHomec4science

hooke.cpp
No OneTemporary

File Metadata

Created
Fri, May 3, 21:30

hooke.cpp

/**
* @file
* @section LICENSE
*
* Copyright (©) 2016-2020 EPFL (École Polytechnique Fédérale de Lausanne),
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "hooke.hh"
#include "influence.hh"
#include "loop.hh"
#include "model.hh"
/* -------------------------------------------------------------------------- */
namespace tamaas {
template <model_type type>
void Hooke<type>::apply(GridBase<Real>& strain, GridBase<Real>& stress) const {
constexpr auto dim = model_type_traits<type>::dimension;
const influence::ElasticHelper<dim> elasticity(
this->model->getShearModulus(), this->model->getPoissonRatio());
// Checking incompressibility
if (elasticity.nu == 0.5)
TAMAAS_EXCEPTION("Incompressibility error");
// Checking number of components
if (strain.getNbComponents() == dim * dim) {
Loop::loop([&elasticity](auto sigma,
auto epsilon) { sigma = elasticity(epsilon); },
range<MatrixProxy<Real, dim, dim>>(stress),
range<MatrixProxy<const Real, dim, dim>>(strain));
}
// in case we have voigt notation
else if (strain.getNbComponents() == voigt_size<dim>::value) {
Loop::loop([&elasticity](auto sigma,
auto epsilon) { sigma = elasticity(epsilon); },
range<SymMatrixProxy<Real, dim>>(stress),
range<SymMatrixProxy<const Real, dim>>(strain));
}
else
TAMAAS_EXCEPTION("Strain components do not match dimension");
}
/* -------------------------------------------------------------------------- */
template class Hooke<model_type::basic_1d>;
template class Hooke<model_type::basic_2d>;
template class Hooke<model_type::surface_1d>;
template class Hooke<model_type::surface_2d>;
template class Hooke<model_type::volume_1d>;
template class Hooke<model_type::volume_2d>;
} // namespace tamaas

Event Timeline