diff --git a/include/GooseFEM/VectorPartitionedTyings.h b/include/GooseFEM/VectorPartitionedTyings.h index b357049..4a485a4 100644 --- a/include/GooseFEM/VectorPartitionedTyings.h +++ b/include/GooseFEM/VectorPartitionedTyings.h @@ -1,97 +1,159 @@ /** Methods to switch between storage types based on a mesh and DOFs that are partitioned in: - unknown DOFs - prescribed DOFs - dependent DOFs \file VectorPartitionedTyings.h \copyright Copyright 2017. Tom de Geus. All rights reserved. \license This project is released under the GNU Public License (GPLv3). */ #ifndef GOOSEFEM_VECTORPARTITIONEDTYINGS_H #define GOOSEFEM_VECTORPARTITIONEDTYINGS_H #include "config.h" #include #include namespace GooseFEM { -/* - "nodevec" - nodal vectors - [nnode, ndim] - "elemvec" - nodal vectors stored per element - [nelem, nne, ndim] - "dofval" - DOF values - [ndof] - "dofval_u" - DOF values (Unknown) "== dofval[iiu]" - [nnu] - "dofval_p" - DOF values (Prescribed) "== dofval[iiu]" - [nnp] -*/ +/** +Class to switch between storage types. In particular: +- "nodevec": nodal vectors [#nnode, #ndim]. +- "elemvec": nodal vectors stored per element [nelem, #nne, #ndim]. +- "dofval": DOF values [#ndof]. +- "dofval_u": DOF values (Unknown), `== dofval[iiu]`, [#nnu]. +- "dofval_p": DOF values (Prescribed), `== dofval[iiu]`, [#nnp]. +*/ class VectorPartitionedTyings : public Vector { public: - // Constructor + VectorPartitionedTyings() = default; + /** + Constructor. + + \param conn connectivity [#nelem, #nne]. + \param dofs DOFs per node [#nnode, #ndim]. + \param Cdu See Tyings::Periodic::Cdu(). + \param Cdp See Tyings::Periodic::Cdp(). + \param Cdi See Tyings::Periodic::Cdi(). + */ VectorPartitionedTyings( const xt::xtensor& conn, const xt::xtensor& dofs, const Eigen::SparseMatrix& Cdu, const Eigen::SparseMatrix& Cdp, const Eigen::SparseMatrix& Cdi); - // Dimensions - size_t nnu() const; // number of independent, unknown DOFs - size_t nnp() const; // number of independent, prescribed DOFs - size_t nni() const; // number of independent DOFs - size_t nnd() const; // number of dependent DOFs + /** + \return Number of dependent DOFs. + */ + size_t nnd() const; + + /** + \return Number of independent DOFs. + */ + size_t nni() const; + + /** + \return Number of independent unknown DOFs. + */ + size_t nnu() const; + + /** + \return Number of independent prescribed DOFs. + */ + size_t nnp() const; + + /** + Dependent DOFs. + + \return List of DOF numbers. + */ + xt::xtensor iid() const; + + /** + Independent DOFs. + + \return List of DOF numbers. + */ + xt::xtensor iii() const; - // DOF lists - xt::xtensor iiu() const; // independent, unknown DOFs - xt::xtensor iip() const; // independent, prescribed DOFs - xt::xtensor iii() const; // independent DOFs - xt::xtensor iid() const; // dependent DOFs + /** + Independent unknown DOFs. - // Copy (part of) nodevec/dofval to another nodevec/dofval + \return List of DOF numbers. + */ + xt::xtensor iiu() const; + + /** + Independent prescribed DOFs. + + \return List of DOF numbers. + */ + xt::xtensor iip() const; + + /** + Copy (part of) "dofval" to another "dofval": dofval_dest[iip()] = dofval_src[iip()]. + + \param dofval_src DOF values, iip() updated, [#ndof]. + \param dofval_dest DOF values, iip() updated, [#ndof]. + */ void copy_p( - const xt::xtensor& dofval_src, xt::xtensor& dofval_dest) const; // "iip" updated + const xt::xtensor& dofval_src, xt::xtensor& dofval_dest) const; + + /** + Convert to "dofval" (overwrite entries that occur more than once). + Only the independent DOFs are retained. + + \param nodevec nodal vectors [#nnode, #ndim]. + \return dofval[iii()] [#nni]. + */ + xt::xtensor AsDofs_i(const xt::xtensor& nodevec) const; + + /** + Same as InterpQuad_vector(), but writing to preallocated return. - // Convert to "dofval" (overwrite entries that occur more than once) + \param nodevec [#nnode, #ndim]. + \param dofval_i [#nni]. + \param apply_tyings If `true` the dependent DOFs are eliminated. + */ void asDofs_i( const xt::xtensor& nodevec, xt::xtensor& dofval_i, bool apply_tyings = true) const; - - // Auto-allocation of the functions above - xt::xtensor AsDofs_i(const xt::xtensor& nodevec) const; - private: - // Bookkeeping - xt::xtensor m_iiu; // unknown DOFs [nnu] - xt::xtensor m_iip; // prescribed DOFs [nnp] - xt::xtensor m_iid; // dependent DOFs [nnd] - - // Dimensions - size_t m_nnu; // number of independent, unknown DOFs - size_t m_nnp; // number of independent, prescribed DOFs - size_t m_nni; // number of independent DOFs - size_t m_nnd; // number of dependent DOFs - - // Tyings - Eigen::SparseMatrix m_Cdu; - Eigen::SparseMatrix m_Cdp; - Eigen::SparseMatrix m_Cdi; - Eigen::SparseMatrix m_Cud; - Eigen::SparseMatrix m_Cpd; - Eigen::SparseMatrix m_Cid; - - // equivalent Eigen functions - + xt::xtensor m_iiu; ///< See iiu(). + xt::xtensor m_iip; ///< See iip(). + xt::xtensor m_iid; ///< See iid(). + size_t m_nnu; ///< See nnu(). + size_t m_nnp; ///< See nnp(). + size_t m_nni; ///< See nni(). + size_t m_nnd; ///< See nnd(). + Eigen::SparseMatrix m_Cdu; ///< Tying matrix, see Tyings::Periodic::Cdu(). + Eigen::SparseMatrix m_Cdp; ///< Tying matrix, see Tyings::Periodic::Cdp(). + Eigen::SparseMatrix m_Cdi; ///< Tying matrix, see Tyings::Periodic::Cdi(). + Eigen::SparseMatrix m_Cud; ///< Transpose of "m_Cdu". + Eigen::SparseMatrix m_Cpd; ///< Transpose of "m_Cdp". + Eigen::SparseMatrix m_Cid; ///< Transpose of "m_Cdi". + + /** + Convert to "dofval" (overwrite entries that occur more than once). + Only the dependent DOFs are retained. + + \param nodevec nodal vectors [#nnode, #ndim]. + \return dofval[iid()] [#nnd]. + */ Eigen::VectorXd Eigen_asDofs_d(const xt::xtensor& nodevec) const; }; } // namespace GooseFEM #include "VectorPartitionedTyings.hpp" #endif