diff --git a/include/GooseFEM/Element.h b/include/GooseFEM/Element.h index 38c4906..ebafa89 100644 --- a/include/GooseFEM/Element.h +++ b/include/GooseFEM/Element.h @@ -1,630 +1,632 @@ /** Convenience methods for integration point data. \file Element.h \copyright Copyright 2017. Tom de Geus. All rights reserved. \license This project is released under the GNU Public License (GPLv3). */ #ifndef GOOSEFEM_ELEMENT_H #define GOOSEFEM_ELEMENT_H #include "config.h" #include "Allocate.h" namespace GooseFEM { /** Element quadrature and interpolation. */ namespace Element { /** Convert nodal vector with ("nodevec", shape:``[nnode, ndim]``) to nodal vector stored per element ("elemvec", shape: ``[nelem, nne, ndim]``). \param conn Connectivity. \param nodevec "nodevec". \return "elemvec". */ inline xt::xtensor asElementVector( const xt::xtensor& conn, const xt::xtensor& nodevec); /** Assemble nodal vector stored per element ("elemvec", shape ``[nelem, nne, ndim]``) to nodal vector ("nodevec", shape ``[nnode, ndim]``). \param conn Connectivity. \param elemvec "elemvec". \return "nodevec". */ inline xt::xtensor assembleNodeVector( const xt::xtensor& conn, const xt::xtensor& elemvec); /** Check that DOFs leave no holes. \param dofs DOFs ("nodevec") \return ``true`` if there are no holds. */ template inline bool isSequential(const E& dofs); /** Check that all of the matrices stored per elemmat (shape: ``[nelem, nne * ndim, nne * ndim]``) are diagonal. \param elemmat Element-vectors ("elemmat") \return ``true`` if all element matrices are diagonal. */ bool isDiagonal(const xt::xtensor& elemmat); /** Base quadrature-class. This class does not have a specific element-type in mind, it is used mostly internally to derive from such that common methods do not have to be reimplementation. \tparam ne Number of nodes per element. \tparam nd Number of dimensions for node vectors. \tparam td Number of dimensions for integration point tensors. */ template class QuadratureBase { public: QuadratureBase() = default; /** Constructor */ QuadratureBase(size_t nelem, size_t nip); /** Number of elements. \return Scalar. */ size_t nelem() const; /** Number of nodes per element. \return Scalar. */ size_t nne() const; /** Number of dimensions for node vectors. \return Scalar. */ size_t ndim() const; /** Number of dimensions for integration point tensors. \return Scalar. */ size_t tdim() const; /** Number of integration points. \return Scalar. */ size_t nip() const; /** Convert "qscalar" to "qtensor" of certain rank. Fully allocated output passed as reference, use AsTensor to allocate and return data. \param qscalar A "qscalar". \param qtensor A "qtensor". */ template void asTensor(const xt::xtensor& qscalar, xt::xtensor& qtensor) const; /** Convert "qscalar" to "qtensor" of certain rank. \param "qscalar". \return "qtensor". */ template xt::xtensor AsTensor(const xt::xtensor& qscalar) const; /** Convert "qscalar" to "qtensor" of certain rank. \param rank Tensor rank. \param qscalar A "qscalar". \return "qtensor". */ template xt::xarray AsTensor(size_t rank, const xt::xtensor& qscalar) const; /** Get the shape of an "elemvec". \returns [#nelem, #nne, #ndim]. */ std::array shape_elemvec() const; /** Get the shape of an "elemmat". \returns [#nelem, #nne * #ndim, #nne * #ndim]. */ std::array shape_elemmat() const; /** Get the shape of a "qtensor" of a certain rank (0 = scalar, 1, vector, 2 = 2nd-order tensor, etc.). Default: rank = 0, a.k.a. scalar. \returns [#nelem, #nip, #tdim, ...]. */ template std::array shape_qtensor() const; /** Get the shape of a "qtensor" of a certain rank (0 = scalar, 1, vector, 2 = 2nd-order tensor, etc.). \param rank The tensor rank. \returns [#nelem, #nip, #tdim, ...]. */ std::vector shape_qtensor(size_t rank) const; /** Get the shape of a "qscalar" (a "qtensor" of rank 0) \returns [#nelem, #nip]. */ std::vector shape_qscalar() const; /** Get an allocated `xt::xtensor` to store a "elemvec". Note: the container is not (zero-)initialised. \returns `xt::xarray` container of the correct shape. */ template xt::xtensor allocate_elemvec() const; /** Get an allocated and initialised `xt::xarray` to store a "elemvec". \param val The value to which to initialise all items. \returns `xt::xtensor` container of the correct shape. */ template xt::xtensor allocate_elemvec(T val) const; /** Get an allocated `xt::xtensor` to store a "elemmat". Note: the container is not (zero-)initialised. \returns `xt::xarray` container of the correct shape. */ template xt::xtensor allocate_elemmat() const; /** Get an allocated and initialised `xt::xarray` to store a "elemmat". \param val The value to which to initialise all items. \returns `xt::xtensor` container of the correct shape. */ template xt::xtensor allocate_elemmat(T val) const; /** Get an allocated `xt::xtensor` to store a "qtensor" of a certain rank (0 = scalar, 1, vector, 2 = 2nd-order tensor, etc.). Default: rank = 0, a.k.a. scalar. Note: the container is not (zero-)initialised. \returns [#nelem, #nip]. */ template xt::xtensor allocate_qtensor() const; /** Get an allocated and initialised `xt::xtensor` to store a "qtensor" of a certain rank (0 = scalar, 1, vector, 2 = 2nd-order tensor, etc.). Default: rank = 0, a.k.a. scalar. \param val The value to which to initialise all items. \returns `xt::xtensor` container of the correct shape (and rank). */ template xt::xtensor allocate_qtensor(T val) const; /** Get an allocated `xt::xarray` to store a "qtensor" of a certain rank (0 = scalar, 1, vector, 2 = 2nd-order tensor, etc.). Note: the container is not (zero-)initialised. \param rank The tensor rank. \returns `xt::xarray` container of the correct shape. */ template xt::xarray allocate_qtensor(size_t rank) const; /** Get an allocated and initialised `xt::xarray` to store a "qtensor" of a certain rank (0 = scalar, 1, vector, 2 = 2nd-order tensor, etc.). \param rank The tensor rank. \param val The value to which to initialise all items. \returns `xt::xtensor` container of the correct shape (and rank). */ template xt::xarray allocate_qtensor(size_t rank, T val) const; /** Get an allocated `xt::xtensor` to store a "qscalar" (a "qtensor" of rank 0). Note: the container is not (zero-)initialised. \returns `xt::xarray` container of the correct shape. */ template xt::xtensor allocate_qscalar() const; /** Get an allocated and initialised `xt::xarray` to store a "qscalar" (a "qtensor" of rank 0). \param val The value to which to initialise all items. \returns `xt::xtensor` container of the correct shape (and rank). */ template xt::xtensor allocate_qscalar(T val) const; /** \cond */ template [[ deprecated ]] std::array ShapeQtensor() const; [[ deprecated ]] std::vector ShapeQtensor(size_t rank) const; template [[ deprecated ]] xt::xtensor AllocateQtensor() const; [[ deprecated ]] std::vector ShapeQscalar() const; template [[ deprecated ]] xt::xtensor AllocateQtensor(T val) const; template [[ deprecated ]] xt::xarray AllocateQtensor(size_t rank) const; template [[ deprecated ]] xt::xarray AllocateQtensor(size_t rank, T val) const; template [[ deprecated ]] xt::xtensor AllocateQscalar() const; template [[ deprecated ]] xt::xtensor AllocateQscalar(T val) const; /** \endcond */ protected: /** Wrapper of constructor, for derived classes. */ void initQuadratureBase(size_t nelem, size_t nip); protected: size_t m_nelem; ///< Number of elements. size_t m_nip; ///< Number of integration points per element. constexpr static size_t m_nne = ne; ///< Number of nodes per element. constexpr static size_t m_ndim = nd; ///< Number of dimensions for nodal vectors. constexpr static size_t m_tdim = td; ///< Number of dimensions for integration point tensors. }; /** Interpolation and quadrature for a generic element in Cartesian coordinates. Naming convention: - ``elemmat``: matrices stored per element, [#nelem, #nne * #ndim, #nne * #ndim] - ``elemvec``: nodal vectors stored per element, [#nelem, #nne, #ndim] - ``qtensor``: integration point tensor, [#nelem, #nip, #tdim, #tdim] - ``qscalar``: integration point scalar, [#nelem, #nip] */ template class QuadratureBaseCartesian : public QuadratureBase { public: QuadratureBaseCartesian() = default; virtual ~QuadratureBaseCartesian(){}; /** Constructor with custom integration. - During construction the values of the shape functions and the shape function gradients - (in local and global) coordinates are computed. They can be reused without any cost. - They only have to be recomputed when the nodal position changes. - In that case use update_x() to update the nodal positions and to recompute the - shape functions and their gradients. + The following is pre-computed during construction: + - the shape functions, + - the shape function gradients (in local and global) coordinates, + - the integration points volumes. + They can be reused without any cost. + They only have to be recomputed when the nodal position changes + (note that they are assumed to be constant under a small-strain assumption). + In that case use update_x() to update the nodal positions and + to recompute the above listed quantities. \param x nodal coordinates (``elemvec``). \param xi Integration point coordinates (local coordinates) [#nip]. \param w Integration point weights [#nip]. \param N Shape functions in local coordinates [#nip, #nne]. \param dNdxi Shape function gradient w.r.t. local coordinates [#nip, #nne, #ndim]. */ QuadratureBaseCartesian( const xt::xtensor& x, const xt::xtensor& xi, const xt::xtensor& w, const xt::xtensor& N, const xt::xtensor& dNdxi); /** Update the nodal positions. - This recomputes the values of the shape functions and the shape function gradients - (in local and global) coordinates. - Under the small deformations assumption this should not be called. + This recomputes: + - the shape functions, + - the shape function gradients (in local and global) coordinates, + - the integration points volumes. + Under the small deformations assumption this function should not be called. \param x nodal coordinates (``elemvec``). Shape should match the earlier definition. */ void update_x(const xt::xtensor& x); /** Get the shape function gradients (in global coordinates). - Note that the functions and their gradients are precomputed upon construction, - or updated when calling update_x(). \return ``gradN`` stored per element, per integration point [#nelem, #nip, #nne, #ndim]. */ virtual xt::xtensor GradN() const; /** Get the integration volume. - Note that the functions and their gradients are precomputed upon construction, - or updated when calling update_x(). \return volume stored per element, per integration point [#nelem, #nip]. */ xt::xtensor dV() const; /** Interpolate element vector. Note that the functions and their gradients are precomputed upon construction, or updated when calling update_x(). \param elemvec nodal vector stored per element (shape: [#nelem, #nne, #ndim]). \return integration point vector (shape: [#nelem, #nip, #ndim]). */ xt::xtensor Interp_N_vector(const xt::xtensor& elemvec) const; /** Same as Interp_N_vector(), but writing to preallocated return. \param elemvec nodal vector stored per element (shape: [#nelem, #nne, #ndim]). \param qvector integration point vector, overwritten (shape: [#nelem, #nip, #ndim]). */ virtual void interp_N_vector( const xt::xtensor& elemvec, xt::xtensor& qvector) const; /** Element-by-element: dyadic product of the shape function gradients and a nodal vector. Typical input: nodal displacements. Typical output: quadrature point strains. Within one element:: for e in range(nelem): for q in range(nip): for m in range(nne): qtensor(e, q, i, j) += dNdx(e, q, m, i) * elemvec(e, m, j) Note that the functions and their gradients are precomputed upon construction, or updated when calling update_x(). \param elemvec [#nelem, #nne, #ndim] \return qtensor [#nelem, #nip, #tdim, #tdim] */ xt::xtensor GradN_vector(const xt::xtensor& elemvec) const; /** Same as GradN_vector(), but writing to preallocated return. \param elemvec [#nelem, #nne, #ndim] \param qtensor overwritten [#nelem, #nip, #tdim, #tdim] */ virtual void gradN_vector( const xt::xtensor& elemvec, xt::xtensor& qtensor) const; /** The transposed output of GradN_vector(). Within one element:: for e in range(nelem): for q in range(nip): for m in range(nne): qtensor(e, q, j, i) += dNdx(e, q, m, i) * elemvec(e, m, j) \param elemvec [#nelem, #nne, #ndim] \return qtensor [#nelem, #nip, #tdim, #tdim] */ xt::xtensor GradN_vector_T(const xt::xtensor& elemvec) const; /** Same as GradN_vector_T(), but writing to preallocated return. \param elemvec [#nelem, #nne, #ndim] \param qtensor overwritten [#nelem, #nip, #tdim, #tdim] */ virtual void gradN_vector_T( const xt::xtensor& elemvec, xt::xtensor& qtensor) const; /** The symmetric output of GradN_vector(). Without one element:: for e in range(nelem): for q in range(nip): for m in range(nne): qtensor(e, q, i, j) += 0.5 * dNdx(e, q, m, i) * elemvec(e, m, j) qtensor(e, q, j, i) += 0.5 * dNdx(e, q, m, i) * elemvec(e, m, j) \param elemvec [#nelem, #nne, #ndim] \return qtensor [#nelem, #nip, #tdim, #tdim] */ xt::xtensor SymGradN_vector(const xt::xtensor& elemvec) const; /** Same as SymGradN_vector(), but writing to preallocated return. \param elemvec [#nelem, #nne, #ndim] \param qtensor overwritten [#nelem, #nip, #tdim, #tdim] */ virtual void symGradN_vector( const xt::xtensor& elemvec, xt::xtensor& qtensor) const; /** Element-by-element: integral of the scalar product of the shape function with a scalar. Within one one element:: for e in range(nelem): for q in range(nip): for m in range(nne): for n in range(nne): elemmat(e, m * ndim + i, n * ndim + i) += N(e, q, m) * qscalar(e, q) * N(e, q, n) * dV(e, q) with ``i`` a tensor dimension. Note that the functions and their gradients are precomputed upon construction, or updated when calling update_x(). \param qscalar [#nelem, #nip] \return elemmat [#nelem, #nne * #ndim, #nne * #ndim] */ xt::xtensor Int_N_scalar_NT_dV(const xt::xtensor& qscalar) const; /** Same as Int_N_scalar_NT_dV(), but writing to preallocated return. \param qscalar [#nelem, #nip] \param elemmat overwritten [#nelem, #nne * #ndim, #nne * #ndim] */ virtual void int_N_scalar_NT_dV( const xt::xtensor& qscalar, xt::xtensor& elemmat) const; /** Element-by-element: integral of the dot product of the shape function gradients with a second order tensor. Typical input: stress. Typical output: nodal force. Within one one element:: for e in range(nelem): for q in range(nip): for m in range(nne): elemvec(e, m, j) += dNdx(e, q, m, i) * qtensor(e, q, i, j) * dV(e, q) with ``i`` and ``j`` tensor dimensions. Note that the functions and their gradients are precomputed upon construction, or updated when calling update_x(). \param qtensor [#nelem, #nip, #ndim, #ndim] \return elemvec [#nelem, #nne. #ndim] */ xt::xtensor Int_gradN_dot_tensor2_dV(const xt::xtensor& qtensor) const; /** Same as Int_gradN_dot_tensor2_dV(), but writing to preallocated return. \param qtensor [#nelem, #nip, #ndim, #ndim] \param elemvec overwritten [#nelem, #nne. #ndim] */ virtual void int_gradN_dot_tensor2_dV( const xt::xtensor& qtensor, xt::xtensor& elemvec) const; // Integral of the dot product // elemmat(m*2+j, n*2+k) += dNdx(m,i) * qtensor(i,j,k,l) * dNdx(n,l) * dV /** Element-by-element: integral of the dot products of the shape function gradients with a fourth order tensor. Typical input: stiffness tensor. Typical output: stiffness matrix. Within one one element:: for e in range(nelem): for q in range(nip): for m in range(nne): for n in range(nne): elemmat(e, m * ndim + j, n * ndim + k) += dNdx(e, q, m, i) * qtensor(e, q, i, j, k, l) * dNdx(e, q, n, l) * dV(e, q) with ``i``, ``j``, ``k``, and ``l`` tensor dimensions. Note that the functions and their gradients are precomputed upon construction, or updated when calling update_x(). \param qtensor [#nelem, #nip, #ndim, #ndim, #ndim, #ndim] \return elemmat [#nelem, #nne * #ndim, #nne * #ndim] */ xt::xtensor Int_gradN_dot_tensor4_dot_gradNT_dV( const xt::xtensor& qtensor) const; /** Same as Int_gradN_dot_tensor4_dot_gradNT_dV(), but writing to preallocated return. \param qtensor [#nelem, #nip, #ndim, #ndim, #ndim, #ndim] \param elemmat overwritten [#nelem, #nne * #ndim, #nne * #ndim] */ virtual void int_gradN_dot_tensor4_dot_gradNT_dV( const xt::xtensor& qtensor, xt::xtensor& elemmat) const; protected: /** Constructor alias. \param x nodal coordinates (``elemvec``). \param xi Integration point coordinates (local coordinates) [#nip]. \param w Integration point weights [#nip]. \param N Shape functions in the integration points [#nip, #nne]. \param dNdxi Shape function gradient w.r.t. local coordinates [#nip, #nne, #ndim]. */ void initQuadratureBaseCartesian( const xt::xtensor& x, const xt::xtensor& xi, const xt::xtensor& w, const xt::xtensor& N, const xt::xtensor& dNdxi); /** Compute m_vol and m_dNdx based on current m_x. */ virtual void compute_dN(); protected: using QuadratureBase::m_nelem; using QuadratureBase::m_nip; using QuadratureBase::m_nne; using QuadratureBase::m_ndim; using QuadratureBase::m_tdim; xt::xtensor m_x; ///< nodal positions stored per element [#nelem, #nne, #ndim] xt::xtensor m_w; ///< weight of each integration point [nip] xt::xtensor m_xi; ///< local coordinate of each integration point [#nip, #ndim] xt::xtensor m_N; ///< shape functions [#nip, #nne] xt::xtensor m_dNxi; ///< shape function grad. wrt local coor. [#nip, #nne, #ndim] xt::xtensor m_dNx; ///< shape function grad. wrt global coor. [#nelem, #nip, #nne, #ndim] xt::xtensor m_vol; ///< integration point volume [#nelem, #nip] }; } // namespace Element } // namespace GooseFEM #include "Element.hpp" #endif diff --git a/include/GooseFEM/ElementHex8.h b/include/GooseFEM/ElementHex8.h index 980e0da..1386fd3 100644 --- a/include/GooseFEM/ElementHex8.h +++ b/include/GooseFEM/ElementHex8.h @@ -1,141 +1,153 @@ /** Quadrature for 8-noded hexahedral element in 3d (GooseFEM::Mesh::ElementType::Hex8), in a Cartesian coordinate system. \file ElementHex8.h \copyright Copyright 2017. Tom de Geus. All rights reserved. \license This project is released under the GNU Public License (GPLv3). */ #ifndef GOOSEFEM_ELEMENTHEX8_H #define GOOSEFEM_ELEMENTHEX8_H #include "config.h" namespace GooseFEM { namespace Element { /** 8-noded hexahedral element in 3d (GooseFEM::Mesh::ElementType::Hex8). */ namespace Hex8 { /** gauss quadrature: quadrature points such that integration is exact for these bi-linear elements:: */ namespace Gauss { /** Number of integration points:: nip = nne = 8 \return unsigned int */ inline size_t nip(); /** Integration point coordinates (local coordinates). \return Coordinates [nip(), ``ndim``], with ``ndim = 3``. */ inline xt::xtensor xi(); /** Integration point weights. \return Coordinates [nip()]. */ inline xt::xtensor w(); } // namespace Gauss /** nodal quadrature: quadrature points coincide with the nodes. The order is the same as in the connectivity. */ namespace Nodal { /** Number of integration points:: nip = nne = 8 \return unsigned int */ inline size_t nip(); /** Integration point coordinates (local coordinates). \return Coordinates [nip(), ``ndim``], with ``ndim = 3``. */ inline xt::xtensor xi(); /** Integration point weights. \return Coordinates [nip()]. */ inline xt::xtensor w(); } // namespace Nodal /** Interpolation and quadrature. Fixed dimensions: - ``ndim = 3``: number of dimensions. - ``nne = 8``: number of nodes per element. Naming convention: - ``elemmat``: matrices stored per element, [nelem(), nne() * ndim(), nne() * ndim()] - ``elemvec``: nodal vectors stored per element, [nelem(), nne(), ndim()] - ``qtensor``: integration point tensor, [nelem(), nip(), ndim(), ndim()] - ``qscalar``: integration point scalar, [nelem(), nip()] */ class Quadrature : public GooseFEM::Element::QuadratureBaseCartesian<8, 3, 3> { public: Quadrature() = default; /** Constructor: use default Gauss integration. - During construction the values of the shape functions and the shape function gradients - (in local and global) coordinates are computed. They can be reused without any cost. - They only have to be recomputed when the nodal position changes, taken care of in update_x(). + The following is pre-computed during construction: + - the shape functions, + - the shape function gradients (in local and global) coordinates, + - the integration points volumes. + They can be reused without any cost. + They only have to be recomputed when the nodal position changes + (note that they are assumed to be constant under a small-strain assumption). + In that case use update_x() to update the nodal positions and + to recompute the above listed quantities. \param x nodal coordinates (``elemvec``). */ Quadrature(const xt::xtensor& x); /** Constructor with custom integration. - During construction the values of the shape functions and the shape function gradients - (in local and global) coordinates are computed. They can be reused without any cost. - They only have to be recomputed when the nodal position changes, taken care of in update_x(). + The following is pre-computed during construction: + - the shape functions, + - the shape function gradients (in local and global) coordinates, + - the integration points volumes. + They can be reused without any cost. + They only have to be recomputed when the nodal position changes + (note that they are assumed to be constant under a small-strain assumption). + In that case use update_x() to update the nodal positions and + to recompute the above listed quantities. \param x nodal coordinates (``elemvec``). \param xi Integration point coordinates (local coordinates) [nip()]. \param w Integration point weights [nip()]. */ Quadrature( const xt::xtensor& x, const xt::xtensor& xi, const xt::xtensor& w); void int_N_scalar_NT_dV( const xt::xtensor& qscalar, xt::xtensor& elemmat) const override; void int_gradN_dot_tensor2_dV( const xt::xtensor& qtensor, xt::xtensor& elemvec) const override; }; } // namespace Hex8 } // namespace Element } // namespace GooseFEM #include "ElementHex8.hpp" #endif diff --git a/include/GooseFEM/ElementQuad4.h b/include/GooseFEM/ElementQuad4.h index a1213f0..e8adbd4 100644 --- a/include/GooseFEM/ElementQuad4.h +++ b/include/GooseFEM/ElementQuad4.h @@ -1,208 +1,216 @@ /** Quadrature for 4-noded quadrilateral element in 2d (GooseFEM::Mesh::ElementType::Quad4), in a Cartesian coordinate system. \file ElementQuad4.h \copyright Copyright 2017. Tom de Geus. All rights reserved. \license This project is released under the GNU Public License (GPLv3). */ #ifndef GOOSEFEM_ELEMENTQUAD4_H #define GOOSEFEM_ELEMENTQUAD4_H #include "config.h" #include "Element.h" namespace GooseFEM { namespace Element { /** 4-noded quadrilateral element in 2d (GooseFEM::Mesh::ElementType::Quad4). */ namespace Quad4 { /** Gauss quadrature: quadrature points such that integration is exact for this bi-linear element:: + ----------- + | | | 3 2 | | | | 0 1 | | | + ----------- + */ namespace Gauss { /** Number of integration points:: nip = nne = 4 \return unsigned int */ inline size_t nip(); /** Integration point coordinates (local coordinates). \return Coordinates [#nip, ``ndim``], with ``ndim = 2``. */ inline xt::xtensor xi(); /** Integration point weights. \return Coordinates [#nip]. */ inline xt::xtensor w(); } // namespace Gauss /** nodal quadrature: quadrature points coincide with the nodes. The order is the same as in the connectivity:: 3 -- 2 | | 0 -- 1 */ namespace Nodal { /** Number of integration points:: nip = nne = 4 \return unsigned int */ inline size_t nip(); /** Integration point coordinates (local coordinates). \return Coordinates [#nip, ``ndim``], with ``ndim = 2``. */ inline xt::xtensor xi(); /** Integration point weights. \return Coordinates [#nip]. */ inline xt::xtensor w(); } // namespace Nodal /** midpoint quadrature: quadrature points in the middle of the element:: + ------- + | | | 0 | | | + ------- + */ namespace MidPoint { /** Number of integration points:: nip = 1 \return unsigned int */ inline size_t nip(); /** Integration point coordinates (local coordinates). \return Coordinates [#nip, ``ndim``], with ``ndim = 2``. */ inline xt::xtensor xi(); /** Integration point weights. \return Coordinates [#nip]. */ inline xt::xtensor w(); } // namespace MidPoint /** Interpolation and quadrature. Fixed dimensions: - ``ndim = 2``: number of dimensions. - ``nne = 4``: number of nodes per element. Naming convention: - ``elemmat``: matrices stored per element, [#nelem, #nne * #ndim, #nne * #ndim] - ``elemvec``: nodal vectors stored per element, [#nelem, #nne, #ndim] - ``qtensor``: integration point tensor, [#nelem, #nip, #ndim, #ndim] - ``qscalar``: integration point scalar, [#nelem, #nip] */ class Quadrature : public GooseFEM::Element::QuadratureBaseCartesian<4, 2, 2> { public: Quadrature() = default; /** Constructor: use default Gauss integration. - During construction the values of the shape functions and the shape function gradients - (in local and global) coordinates are computed. They can be reused without any cost. - They only have to be recomputed when the nodal position changes. - In that case use update_x() to update the nodal positions and to recompute the - shape functions and their gradients. + The following is pre-computed during construction: + - the shape functions, + - the shape function gradients (in local and global) coordinates, + - the integration points volumes. + They can be reused without any cost. + They only have to be recomputed when the nodal position changes + (note that they are assumed to be constant under a small-strain assumption). + In that case use update_x() to update the nodal positions and + to recompute the above listed quantities. \param x nodal coordinates (``elemvec``). */ Quadrature(const xt::xtensor& x); /** Constructor with custom integration. - During construction the values of the shape functions and the shape function gradients - (in local and global) coordinates are computed. They can be reused without any cost. - They only have to be recomputed when the nodal position changes. - In that case use update_x() to update the nodal positions and to recompute the - shape functions and their gradients. + The following is pre-computed during construction: + - the shape functions, + - the shape function gradients (in local and global) coordinates, + - the integration points volumes. + They can be reused without any cost. + They only have to be recomputed when the nodal position changes + (note that they are assumed to be constant under a small-strain assumption). + In that case use update_x() to update the nodal positions and + to recompute the above listed quantities. \param x nodal coordinates (``elemvec``). \param xi Integration point coordinates (local coordinates) [#nip]. \param w Integration point weights [#nip]. */ Quadrature( const xt::xtensor& x, const xt::xtensor& xi, const xt::xtensor& w); void interp_N_vector( const xt::xtensor& elemvec, xt::xtensor& qvector) const override; void gradN_vector( const xt::xtensor& elemvec, xt::xtensor& qtensor) const override; void gradN_vector_T( const xt::xtensor& elemvec, xt::xtensor& qtensor) const override; void symGradN_vector( const xt::xtensor& elemvec, xt::xtensor& qtensor) const override; void int_N_scalar_NT_dV( const xt::xtensor& qscalar, xt::xtensor& elemmat) const override; void int_gradN_dot_tensor2_dV( const xt::xtensor& qtensor, xt::xtensor& elemvec) const override; protected: void compute_dN() override; }; } // namespace Quad4 } // namespace Element } // namespace GooseFEM #include "ElementQuad4.hpp" #endif diff --git a/include/GooseFEM/ElementQuad4Axisymmetric.h b/include/GooseFEM/ElementQuad4Axisymmetric.h index 380d014..b9892ef 100644 --- a/include/GooseFEM/ElementQuad4Axisymmetric.h +++ b/include/GooseFEM/ElementQuad4Axisymmetric.h @@ -1,115 +1,123 @@ /** Quadrature for 4-noded quadrilateral element in 2d (GooseFEM::Mesh::ElementType::Quad4), in an axisymmetric coordinated system. \file ElementQuad4Axisymmetric.h \copyright Copyright 2017. Tom de Geus. All rights reserved. \license This project is released under the GNU Public License (GPLv3). */ #ifndef GOOSEFEM_ELEMENTQUAD4AXISYMMETRIC_H #define GOOSEFEM_ELEMENTQUAD4AXISYMMETRIC_H #include "config.h" namespace GooseFEM { namespace Element { namespace Quad4 { /** Interpolation and quadrature. Fixed dimensions: - ``ndim = 2``: number of dimensions. - ``tdim = 3``: number of dimensions or tensor. - ``nne = 4``: number of nodes per element. Naming convention: - ``elemmat``: matrices stored per element, [#nelem, #nne * #ndim, #nne * #ndim] - ``elemvec``: nodal vectors stored per element, [#nelem, #nne, #ndim] - ``qtensor``: integration point tensor, [#nelem, #nip, #tdim, #tdim] - ``qscalar``: integration point scalar, [#nelem, #nip] */ class QuadratureAxisymmetric : public GooseFEM::Element::QuadratureBaseCartesian<4, 2, 3> { public: QuadratureAxisymmetric() = default; /** Constructor: use default Gauss integration. - During construction the values of the shape functions and the shape function gradients - (in local and global) coordinates are computed. They can be reused without any cost. - They only have to be recomputed when the nodal position changes. - In that case use update_x() to update the nodal positions and to recompute the - shape functions and their gradients. + The following is pre-computed during construction: + - the shape functions, + - the shape function gradients (in local and global) coordinates, + - the integration points volumes. + They can be reused without any cost. + They only have to be recomputed when the nodal position changes + (note that they are assumed to be constant under a small-strain assumption). + In that case use update_x() to update the nodal positions and + to recompute the above listed quantities. \param x nodal coordinates (``elemvec``). */ QuadratureAxisymmetric(const xt::xtensor& x); /** Constructor with custom integration. - During construction the values of the shape functions and the shape function gradients - (in local and global) coordinates are computed. They can be reused without any cost. - They only have to be recomputed when the nodal position changes. - In that case use update_x() to update the nodal positions and to recompute the - shape functions and their gradients. + The following is pre-computed during construction: + - the shape functions, + - the shape function gradients (in local and global) coordinates, + - the integration points volumes. + They can be reused without any cost. + They only have to be recomputed when the nodal position changes + (note that they are assumed to be constant under a small-strain assumption). + In that case use update_x() to update the nodal positions and + to recompute the above listed quantities. \param x nodal coordinates (``elemvec``). \param xi Integration point coordinates (local coordinates) [#nip]. \param w Integration point weights [#nip]. */ QuadratureAxisymmetric( const xt::xtensor& x, const xt::xtensor& xi, const xt::xtensor& w); /** Get the B-matrix (shape function gradients) (in global coordinates). Note that the functions and their gradients are precomputed upon construction, or updated when calling update_x(). \return ``B`` matrix stored per element, per integration point [#nelem, #nne, #tdim, #tdim, #tdim] */ xt::xtensor B() const; // qtensor(e, q, i, j) += B(e, q, m, i, j, k) * elemvec(e, q, m, k) void gradN_vector( const xt::xtensor& elemvec, xt::xtensor& qtensor) const override; void gradN_vector_T( const xt::xtensor& elemvec, xt::xtensor& qtensor) const override; void symGradN_vector( const xt::xtensor& elemvec, xt::xtensor& qtensor) const override; // elemmat(e, q, m * ndim + i, n * ndim + i) += // N(e, q, m) * qscalar(e, q) * N(e, q, n) * dV(e, q) void int_N_scalar_NT_dV( const xt::xtensor& qscalar, xt::xtensor& elemmat) const override; // fm = ( Bm^T : qtensor ) dV void int_gradN_dot_tensor2_dV( const xt::xtensor& qtensor, xt::xtensor& elemvec) const override; // Kmn = ( Bm^T : qtensor : Bn ) dV void int_gradN_dot_tensor4_dot_gradNT_dV( const xt::xtensor& qtensor, xt::xtensor& elemmat) const override; protected: void compute_dN() override; private: xt::xtensor GradN() const override; private: xt::xtensor m_B; ///< B-matrix [#nelem, #nne, #tdim, #tdim, #tdim] }; } // namespace Quad4 } // namespace Element } // namespace GooseFEM #include "ElementQuad4Axisymmetric.hpp" #endif diff --git a/include/GooseFEM/ElementQuad4Planar.h b/include/GooseFEM/ElementQuad4Planar.h index dc15db7..6c641f4 100644 --- a/include/GooseFEM/ElementQuad4Planar.h +++ b/include/GooseFEM/ElementQuad4Planar.h @@ -1,101 +1,109 @@ /** Quadrature for 4-noded quadrilateral element in 2d (GooseFEM::Mesh::ElementType::Quad4), in a Cartesian coordinate system. The different with ElementQuad4.h is that here the tensors live in 3d and are assumed plane strain. \file ElementQuad4Planar.h \copyright Copyright 2017. Tom de Geus. All rights reserved. \license This project is released under the GNU Public License (GPLv3). */ #ifndef GOOSEFEM_ELEMENTQUAD4PLANAR_H #define GOOSEFEM_ELEMENTQUAD4PLANAR_H #include "config.h" namespace GooseFEM { namespace Element { namespace Quad4 { /** Interpolation and quadrature. Similar to Element::Quad4::Quadrature with the only different that quadrature point tensors are 3d ("plane strain") while the mesh is 2d. Fixed dimensions: - ``ndim = 2``: number of dimensions. - ``tdim = 3``: number of dimensions or tensor. - ``nne = 4``: number of nodes per element. Naming convention: - ``elemmat``: matrices stored per element, [#nelem, #nne * #ndim, #nne * #ndim] - ``elemvec``: nodal vectors stored per element, [#nelem, #nne, #ndim] - ``qtensor``: integration point tensor, [#nelem, #nip, #tdim, #tdim] - ``qscalar``: integration point scalar, [#nelem, #nip] */ class QuadraturePlanar : public GooseFEM::Element::QuadratureBaseCartesian<4, 2, 3> { public: QuadraturePlanar() = default; /** Constructor: use default Gauss integration. - During construction the values of the shape functions and the shape function gradients - (in local and global) coordinates are computed. They can be reused without any cost. - They only have to be recomputed when the nodal position changes. - In that case use update_x() to update the nodal positions and to recompute the - shape functions and their gradients. + The following is pre-computed during construction: + - the shape functions, + - the shape function gradients (in local and global) coordinates, + - the integration points volumes. + They can be reused without any cost. + They only have to be recomputed when the nodal position changes + (note that they are assumed to be constant under a small-strain assumption). + In that case use update_x() to update the nodal positions and + to recompute the above listed quantities. \param x nodal coordinates (``elemvec``). \param thick out-of-plane thickness (incorporated in the element volume). */ QuadraturePlanar(const xt::xtensor& x, double thick = 1.0); /** Constructor with custom integration. - During construction the values of the shape functions and the shape function gradients - (in local and global) coordinates are computed. They can be reused without any cost. - They only have to be recomputed when the nodal position changes. - In that case use update_x() to update the nodal positions and to recompute the - shape functions and their gradients. + The following is pre-computed during construction: + - the shape functions, + - the shape function gradients (in local and global) coordinates, + - the integration points volumes. + They can be reused without any cost. + They only have to be recomputed when the nodal position changes + (note that they are assumed to be constant under a small-strain assumption). + In that case use update_x() to update the nodal positions and + to recompute the above listed quantities. \param x nodal coordinates (``elemvec``). \param xi Integration point coordinates (local coordinates) [#nip]. \param w Integration point weights [#nip]. \param thick out-of-plane thickness (incorporated in the element volume). */ QuadraturePlanar( const xt::xtensor& x, const xt::xtensor& xi, const xt::xtensor& w, double thick = 1.0); void gradN_vector( const xt::xtensor& elemvec, xt::xtensor& qtensor) const override; void gradN_vector_T( const xt::xtensor& elemvec, xt::xtensor& qtensor) const override; void symGradN_vector( const xt::xtensor& elemvec, xt::xtensor& qtensor) const override; void int_N_scalar_NT_dV( const xt::xtensor& qscalar, xt::xtensor& elemmat) const override; void int_gradN_dot_tensor2_dV( const xt::xtensor& qtensor, xt::xtensor& elemvec) const override; protected: void compute_dN() override; private: double m_thick; ///< out-of-plane thickness }; } // namespace Quad4 } // namespace Element } // namespace GooseFEM #include "ElementQuad4Planar.hpp" #endif