File Matrix.h#
- Copyright
Copyright 2017. Tom de Geus. All rights reserved.
- License: This project is released under the GNU Public License (GPLv3).
-
namespace GooseFEM
Toolbox to perform finite element computations.
-
class Matrix : public GooseFEM::MatrixBase<Matrix>
- #include <GooseFEM/Matrix.h>
Sparse matrix.
See GooseFEM::Vector() for bookkeeping definitions.
Public Functions
-
Matrix() = default#
-
inline Matrix(const array_type::tensor<size_t, 2> &conn, const array_type::tensor<size_t, 2> &dofs)
Constructor.
-
inline const Eigen::SparseMatrix<double> &data() const
Pointer to data.
-
inline void set(const array_type::tensor<size_t, 1> &rows, const array_type::tensor<size_t, 1> &cols, const array_type::tensor<double, 2> &matrix)
Overwrite matrix.
- Parameters:
rows – Row numbers [m].
cols – Column numbers [n].
matrix – Data entries
matrix(i, j)
forrows(i), cols(j)
[m, n].
-
inline void add(const array_type::tensor<size_t, 1> &rows, const array_type::tensor<size_t, 1> &cols, const array_type::tensor<double, 2> &matrix)
Add matrix.
- Parameters:
rows – Row numbers [m].
cols – Column numbers [n].
matrix – Data entries
matrix(i, j)
forrows(i), cols(j)
[m, n].
Private Functions
Private Members
- friend MatrixBase< Matrix >
-
bool m_changed = true#
Signal changes to data.
-
Eigen::SparseMatrix<double> m_A#
The matrix.
Friends
- friend class MatrixSolver
-
Matrix() = default#
-
template<class D>
class MatrixBase - #include <GooseFEM/Matrix.h>
CRTP base class for a matrix.
Subclassed by GooseFEM::MatrixPartitionedBase< MatrixDiagonalPartitioned >, GooseFEM::MatrixPartitionedBase< MatrixPartitioned >, GooseFEM::MatrixPartitionedBase< MatrixPartitionedTyings >, GooseFEM::MatrixPartitionedBase< D >
Public Types
-
using derived_type = D
Underlying type.
Public Functions
-
inline size_t nelem() const
Number of elements.
- Returns:
Unsigned integer.
-
inline size_t nne() const
Number of nodes per element.
- Returns:
Unsigned integer.
-
inline size_t nnode() const
Number of nodes.
- Returns:
Unsigned integer.
-
inline size_t ndim() const
Number of dimensions.
- Returns:
Unsigned integer.
-
inline size_t ndof() const
Number of DOFs.
- Returns:
Unsigned integer.
-
inline const array_type::tensor<size_t, 2> &dofs() const
DOFs per node.
-
inline const array_type::tensor<size_t, 2> &conn() const
Connectivity.
-
inline std::array<size_t, 3> shape_elemmat() const
Shape of “elemmat”.
-
template<class T>
inline void assemble(const T &elemmat) Assemble from “elemmat”.
-
inline array_type::tensor<double, 2> Todense() const
Copy as dense matrix.
-
template<class T>
inline void todense(T &ret) const Copy to dense matrix.
-
inline array_type::tensor<double, 2> Dot(const array_type::tensor<double, 2> &x) const
Dot-product \( b_i = A_{ij} x_j \).
-
inline array_type::tensor<double, 1> Dot(const array_type::tensor<double, 1> &x) const
Dot-product \( b_i = A_{ij} x_j \).
-
inline void dot(const array_type::tensor<double, 2> &x, array_type::tensor<double, 2> &b) const
Dot-product \( b_i = A_{ij} x_j \).
-
inline void dot(const array_type::tensor<double, 1> &x, array_type::tensor<double, 1> &b) const
Dot-product \( b_i = A_{ij} x_j \).
Protected Attributes
-
array_type::tensor<size_t, 2> m_conn#
-
array_type::tensor<size_t, 2> m_dofs#
-
bool m_changed = true#
Signal changes to data.
Private Functions
-
inline auto derived_cast() -> derived_type&#
-
inline auto derived_cast() const -> const derived_type&#
-
using derived_type = D
-
template<class D>
class MatrixPartitionedBase : public GooseFEM::MatrixBase<D> - #include <GooseFEM/Matrix.h>
CRTP base class for a partitioned matrix.
Subclassed by GooseFEM::MatrixPartitionedTyingsBase< MatrixPartitionedTyings >, GooseFEM::MatrixPartitionedTyingsBase< D >
Public Types
-
using derived_type = D
Underlying type.
Public Functions
-
inline size_t nnu() const
Number of unknown DOFs.
- Returns:
Unsigned integer.
-
inline size_t nnp() const
Number of prescribed DOFs.
- Returns:
Unsigned integer.
-
inline const array_type::tensor<size_t, 1> &iiu() const
Unknown DOFs.
- Returns:
[nnu].
-
inline const array_type::tensor<size_t, 1> &iip() const
Prescribed DOFs.
- Returns:
[nnp].
-
inline array_type::tensor<double, 2> Reaction(const array_type::tensor<double, 2> &x, const array_type::tensor<double, 2> &b) const
Right-hand-size for corresponding to the prescribed DOFs:
\( b_p = A_{pu} * x_u + A_{pp} * x_p \)
and assemble them to the appropriate places in “nodevec”.
-
inline array_type::tensor<double, 1> Reaction(const array_type::tensor<double, 1> &x, const array_type::tensor<double, 1> &b) const
Same as Reaction(const array_type::tensor<double, 2>&, const array_type::tensor<double, 2>&), but of “dofval” input and output.
-
inline void reaction(const array_type::tensor<double, 2> &x, array_type::tensor<double, 2> &b) const
Same as Reaction(const array_type::tensor<double, 2>&, const array_type::tensor<double, 2>&), but inserting in-place.
-
inline void reaction(const array_type::tensor<double, 1> &x, array_type::tensor<double, 1> &b) const
Same as Reaction(const array_type::tensor<double, 1>&, const array_type::tensor<double, 1>&), but inserting in-place.
-
inline array_type::tensor<double, 1> Reaction_p(const array_type::tensor<double, 1> &x_u, const array_type::tensor<double, 1> &x_p) const
Same as Reaction(const array_type::tensor<double, 1>&, const array_type::tensor<double, 1>&), but with partitioned input and output.
-
inline void reaction_p(const array_type::tensor<double, 1> &x_u, const array_type::tensor<double, 1> &x_p, array_type::tensor<double, 1> &b_p) const
Same as Reaction_p(const array_type::tensor<double, 1>&, const array_type::tensor<double,
1>&), but writing to preallocated output.
Protected Attributes
-
array_type::tensor<size_t, 1> m_iiu#
See iiu()
-
array_type::tensor<size_t, 1> m_iip#
See iip()
Private Functions
-
inline auto derived_cast() -> derived_type&#
-
inline auto derived_cast() const -> const derived_type&#
-
using derived_type = D
-
template<class D>
class MatrixPartitionedTyingsBase : public GooseFEM::MatrixPartitionedBase<D> - #include <GooseFEM/Matrix.h>
CRTP base class for a partitioned matrix with tying.
Public Types
-
using derived_type = D
Underlying type.
Public Functions
-
inline size_t nni() const
Number of independent DOFs.
- Returns:
Unsigned integer.
-
inline size_t nnd() const
Number of dependent DOFs.
- Returns:
Unsigned integer.
-
inline const array_type::tensor<size_t, 1> &iii() const
Independent DOFs.
- Returns:
[nnu].
-
inline const array_type::tensor<size_t, 1> &iid() const
Dependent DOFs.
- Returns:
[nnp].
Protected Attributes
-
array_type::tensor<size_t, 1> m_iii#
See iii()
-
array_type::tensor<size_t, 1> m_iid#
See iid()
Private Functions
-
inline auto derived_cast() -> derived_type&#
-
inline auto derived_cast() const -> const derived_type&#
-
using derived_type = D
-
template<class Solver = Eigen::SimplicialLDLT<Eigen::SparseMatrix<double>>>
class MatrixSolver : public MatrixSolverBase<MatrixSolver<Eigen::SimplicialLDLT<Eigen::SparseMatrix<double>>>>, public MatrixSolverSingleBase<MatrixSolver<Eigen::SimplicialLDLT<Eigen::SparseMatrix<double>>>> - #include <GooseFEM/Matrix.h>
Solve \( x = A^{-1} b \), for
A
of the GooseFEM::Matrix() class.You can solve for multiple right-hand-sides using one factorisation.
Public Functions
-
MatrixSolver() = default#
Private Functions
-
MatrixSolver() = default#
-
template<class D>
class MatrixSolverBase - #include <GooseFEM/Matrix.h>
CRTP base class for a solver class.
Public Types
-
using derived_type = D
Underlying type.
Public Functions
-
template<class M>
inline void solve(M &A, const array_type::tensor<double, 2> &b, array_type::tensor<double, 2> &x) Solve \( x = A^{-1} b \).
- Parameters:
A – GooseFEM (sparse) matrix, see e.g. GooseFEM::Matrix().
b – nodevec [nelem, ndim].
x – (overwritten) nodevec [nelem, ndim].
-
template<class M>
inline void solve(M &A, const array_type::tensor<double, 1> &b, array_type::tensor<double, 1> &x) Solve \( x = A^{-1} b \).
- Parameters:
A – GooseFEM (sparse) matrix, see e.g. GooseFEM::Matrix().
b – dofval [ndof].
x – (overwritten) dofval [ndof].
Private Functions
-
inline auto derived_cast() -> derived_type&#
-
inline auto derived_cast() const -> const derived_type&#
-
using derived_type = D
-
template<class D>
class MatrixSolverPartitionedBase - #include <GooseFEM/Matrix.h>
CRTP base class for a extra functions for a partitioned solver class.
Public Types
-
using derived_type = D
Underlying type.
Public Functions
-
template<class M>
inline array_type::tensor<double, 2> Solve(M &A, const array_type::tensor<double, 2> &b, const array_type::tensor<double, 2> &x) Solve \( x = A^{-1} b \).
- Parameters:
A – GooseFEM (sparse) matrix, see e.g. GooseFEM::Matrix().
b – nodevec [nelem, ndim].
x – nodevec [nelem, ndim].
- Returns:
x nodevec [nelem, ndim].
-
template<class M>
inline array_type::tensor<double, 1> Solve(M &A, const array_type::tensor<double, 1> &b, const array_type::tensor<double, 1> &x) Solve \( x = A^{-1} b \).
- Parameters:
A – GooseFEM (sparse) matrix, see e.g. GooseFEM::Matrix().
b – dofval [ndof].
x – nodevec [nelem, ndim].
- Returns:
x dofval [ndof].
Private Functions
-
inline auto derived_cast() -> derived_type&#
-
inline auto derived_cast() const -> const derived_type&#
-
using derived_type = D
-
template<class D>
class MatrixSolverSingleBase - #include <GooseFEM/Matrix.h>
CRTP base class for a solver class.
Public Types
-
using derived_type = D
Underlying type.
Public Functions
-
template<class M>
inline array_type::tensor<double, 2> Solve(M &A, const array_type::tensor<double, 2> &b) Solve \( x = A^{-1} b \).
- Parameters:
A – GooseFEM (sparse) matrix, see e.g. GooseFEM::Matrix().
b – nodevec [nelem, ndim].
- Returns:
x nodevec [nelem, ndim].
-
template<class M>
inline array_type::tensor<double, 1> Solve(M &A, const array_type::tensor<double, 1> &b) Solve \( x = A^{-1} b \).
- Parameters:
A – GooseFEM (sparse) matrix, see e.g. GooseFEM::Matrix().
b – dofval [ndof].
- Returns:
x dofval [ndof].
Private Functions
-
inline auto derived_cast() -> derived_type&#
-
inline auto derived_cast() const -> const derived_type&#
-
using derived_type = D
-
class Matrix : public GooseFEM::MatrixBase<Matrix>