diff --git a/include/GooseFEM/Vector.h b/include/GooseFEM/Vector.h index 6ad79cb..c5ebd7b 100644 --- a/include/GooseFEM/Vector.h +++ b/include/GooseFEM/Vector.h @@ -1,111 +1,171 @@ /* (c - GPLv3) T.W.J. de Geus (Tom) | tom@geus.me | www.geus.me | github.com/tdegeus/GooseFEM */ #ifndef GOOSEFEM_VECTOR_H #define GOOSEFEM_VECTOR_H #include "config.h" namespace GooseFEM { /** Class to switch between: +- "dofval": DOF values, shape: ``[ndof]``. - "nodevec": nodal vectors, shape ``[nnode, ndim]``. - "elemvec": nodal vectors stored per element, shape: ``[nelem, nne, ndim]``. -- "dofval": DOF values, shape: ``[ndof]``. */ class Vector { public: Vector() = default; /** Constructor. \param conn Connectivity, shape ``[nelem, nne]``. \param dofs DOFs per node, shape ``[nnode, ndim]``. */ Vector(const xt::xtensor& conn, const xt::xtensor& dofs); - // Dimensions - size_t nelem() const; // number of elements - size_t nne() const; // number of nodes per element - size_t nnode() const; // number of nodes - size_t ndim() const; // number of dimensions - size_t ndof() const; // number of DOFs + /** + Get number of elements. + + \return unsigned int + */ + size_t nelem() const; + + /** + Get number of nodes per element. + + \return unsigned int + */ + size_t nne() const; + + /** + Get number of nodes. + + \return unsigned int + */ + size_t nnode() const; + + /** + Get number of dimensions. + + \return unsigned int + */ + size_t ndim() const; + + /** + Get number of DOFs. + + \return unsigned int + */ + size_t ndof() const; // DOF lists xt::xtensor dofs() const; // DOFs // Copy nodevec to another nodevec void copy(const xt::xtensor& nodevec_src, xt::xtensor& nodevec_dest) const; // Convert to "dofval" (overwrite entries that occur more than once) -- (auto allocation below) void asDofs(const xt::xtensor& nodevec, xt::xtensor& dofval) const; void asDofs(const xt::xtensor& elemvec, xt::xtensor& dofval) const; // Convert to "nodevec" (overwrite entries that occur more than once) -- (auto allocation below) void asNode(const xt::xtensor& dofval, xt::xtensor& nodevec) const; void asNode(const xt::xtensor& elemvec, xt::xtensor& nodevec) const; - // Convert to "elemvec" (overwrite entries that occur more than once) -- (auto allocation below) + /** + Convert to ``elemvec`` (overwrite entries that occur more than once). + This function writes to the fully allocated last argument. + To use auto-allocation use AsElement(). + + \param dofval input [ndof()]. + \param elemvec output [nelem(), nne(), ndim()]. + */ void asElement(const xt::xtensor& dofval, xt::xtensor& elemvec) const; + + /** + Convert to ``elemvec`` (overwrite entries that occur more than once). + This function writes to the fully allocated last argument. + To use auto-allocation use AsElement(). + + \param nodevec input [nnode(), ndim()]. + \param elemvec output [nelem(), nne(), ndim()]. + */ void asElement(const xt::xtensor& nodevec, xt::xtensor& elemvec) const; // Assemble "dofval" (adds entries that occur more that once) -- (auto allocation below) void assembleDofs(const xt::xtensor& nodevec, xt::xtensor& dofval) const; void assembleDofs(const xt::xtensor& elemvec, xt::xtensor& dofval) const; // Assemble "nodevec" (adds entries that occur more that once) -- (auto allocation below) void assembleNode(const xt::xtensor& elemvec, xt::xtensor& nodevec) const; // Auto-allocation of the functions above xt::xtensor AsDofs(const xt::xtensor& nodevec) const; xt::xtensor AsDofs(const xt::xtensor& elemvec) const; xt::xtensor AsNode(const xt::xtensor& dofval) const; xt::xtensor AsNode(const xt::xtensor& elemvec) const; + + /** + Convert to ``elemvec`` (overwrite entries that occur more than once). + See asElement() to avoid allocation of return data. + + \param dofval [ndof()]. + \return ``elemvec`` [nelem(), nne(), ndim()]. + */ xt::xtensor AsElement(const xt::xtensor& dofval) const; + + /** + Convert to ``elemvec`` (overwrite entries that occur more than once). + See asElement() to avoid allocation of return data. + + \param nodevec [nnode(), ndim()]. + \return ``elemvec`` [nelem(), nne(), ndim()]. + */ xt::xtensor AsElement(const xt::xtensor& nodevec) const; xt::xtensor AssembleDofs(const xt::xtensor& nodevec) const; xt::xtensor AssembleDofs(const xt::xtensor& elemvec) const; xt::xtensor AssembleNode(const xt::xtensor& elemvec) const; xt::xtensor Copy( const xt::xtensor& nodevec_src, const xt::xtensor& nodevec_dest) const; // Get shape of dofval, nodevec, elemvec std::array ShapeDofval() const; std::array ShapeNodevec() const; std::array ShapeElemvec() const; std::array ShapeElemmat() const; // Get zero-allocated dofval, nodevec, elemvec xt::xtensor AllocateDofval() const; xt::xtensor AllocateNodevec() const; xt::xtensor AllocateElemvec() const; xt::xtensor AllocateElemmat() const; xt::xtensor AllocateDofval(double val) const; xt::xtensor AllocateNodevec(double val) const; xt::xtensor AllocateElemvec(double val) const; xt::xtensor AllocateElemmat(double val) const; protected: xt::xtensor m_conn; ///< Connectivity ``[nelem, nne]`` xt::xtensor m_dofs; ///< DOF-numbers per node ``[nnode, ndim]`` size_t m_nelem; ///< Number of elements size_t m_nne; ///< Number of nodes per element size_t m_nnode; ///< Number of nodes size_t m_ndim; ///< Number of dimensions size_t m_ndof; ///< Number of DOFs }; } // namespace GooseFEM #include "Vector.hpp" #endif