diff --git a/src/fe_engine/element_classes/element_class_segment_2_inline_impl.cc b/src/fe_engine/element_classes/element_class_segment_2_inline_impl.cc index b3546e8c7..6a10d3d63 100644 --- a/src/fe_engine/element_classes/element_class_segment_2_inline_impl.cc +++ b/src/fe_engine/element_classes/element_class_segment_2_inline_impl.cc @@ -1,121 +1,127 @@ /** * @file element_class_segment_2_inline_impl.cc * * @author Nicolas Richart * * @date creation: Fri Jul 16 2010 * @date last modification: Wed Oct 11 2017 * * @brief Specialization of the element_class class for the type _segment_2 * * @section LICENSE * * Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * * Akantu 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 of the License, or (at your option) any later version. * * Akantu 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with Akantu. If not, see . * * @section DESCRIPTION * * @verbatim q --x--------|--------x---> x -1 0 1 @endverbatim * * @subsection shapes Shape functions * @f{eqnarray*}{ * w_1(x) &=& 1/2(1 - x) \\ * w_2(x) &=& 1/2(1 + x) * @f} * * @subsection quad_points Position of quadrature points * @f{eqnarray*}{ * x_{q} &=& 0 * @f} */ /* -------------------------------------------------------------------------- */ AKANTU_DEFINE_ELEMENT_CLASS_PROPERTY(_segment_2, _gt_segment_2, _itp_lagrange_segment_2, _ek_regular, 1, _git_segment, 1); /* -------------------------------------------------------------------------- */ template <> template inline void InterpolationElement<_itp_lagrange_segment_2>::computeShapes( const vector_type & natural_coords, vector_type & N) { /// natural coordinate Real c = natural_coords(0); /// shape functions N(0) = 0.5 * (1 - c); N(1) = 0.5 * (1 + c); } /* -------------------------------------------------------------------------- */ template <> template inline void InterpolationElement<_itp_lagrange_segment_2>::computeDNDS( __attribute__((unused)) const vector_type & natural_coords, matrix_type & dnds) { /// dN1/de dnds(0, 0) = -.5; /// dN2/de dnds(0, 1) = .5; } /* -------------------------------------------------------------------------- */ template<> template inline void InterpolationElement<_itp_lagrange_segment_2>::computeDN2DS2( __attribute__((unused)) const vector_type & natural_coords, matrix_type & dn2ds2) { /** * @f[ * dn2ds2 = \left( * \begin{array}{} * @f] */ dn2ds2 *= 0; } /* -------------------------------------------------------------------------- */ template <> inline void InterpolationElement<_itp_lagrange_segment_2>::computeSpecialJacobian( const Matrix & dxds, Real & jac) { jac = dxds.norm(); } /* -------------------------------------------------------------------------- */ template <> inline Real GeometricalElement<_gt_segment_2>::getInradius(const Matrix & coord) { + if (coord.rows() == 2) { + return Math::distance_2d(coord(0).storage(), coord(1).storage()); + } + if (coord.rows() == 3) { + return Math::distance_3d(coord(0).storage(), coord(1).storage()); + } return std::abs(coord(0, 0) - coord(0, 1)); } // /* -------------------------------------------------------------------------- // */ // template<> inline bool ElementClass<_segment_2>::contains(const Vector // & natural_coords) { // if (natural_coords(0) < -1.) return false; // if (natural_coords(0) > 1.) return false; // return true; // } /* -------------------------------------------------------------------------- */