File Vector.h#

Methods to switch between storage types based on a mesh.

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 Vector
#include <GooseFEM/Vector.h>

Class to switch between storage types.

In particular:

  • “dofval”: DOF values [ndof].

  • ”nodevec”: nodal vectors [nnode, ndim].

  • ”elemvec”: nodal vectors stored per element [nelem, nne, ndim].

Subclassed by GooseFEM::VectorPartitioned, GooseFEM::VectorPartitionedTyings

Public Functions

Vector() = default#
template<class S, class T>
inline Vector(const S &conn, const T &dofs)

Constructor.

Parameters
inline size_t nelem() const
Returns

Number of elements.

inline size_t nne() const
Returns

Number of nodes per element.

inline size_t nnode() const
Returns

Number of nodes.

inline size_t ndim() const
Returns

Number of dimensions.

inline size_t ndof() const
Returns

Number of DOFs.

inline const array_type::tensor<size_t, 2> &conn() const
Returns

Connectivity (nodes per element) [nelem, nne].

inline const array_type::tensor<size_t, 2> &dofs() const
Returns

DOFs per node [nnode, ndim]

template<class T>
inline T Copy(const T &nodevec_src, const T &nodevec_dest) const

Copy “nodevec” to another “nodevec”.

Parameters
Returns

nodevec output [nnode, ndim]

template<class T>
inline void copy(const T &nodevec_src, T &nodevec_dest) const

Copy “nodevec” to another “nodevec”.

Parameters
template<class T>
inline array_type::tensor<double, 1> AsDofs(const T &arg) const

Convert “nodevec” or “elemvec” to “dofval” (overwrite entries that occur more than once).

Parameters

arg – nodevec [nnode, ndim] or elemvec [nelem, nne, ndim]

Returns

dofval [ndof]

template<class T, class R>
inline void asDofs(const T &arg, R &ret) const

Convert “nodevec” or “elemvec” to “dofval” (overwrite entries that occur more than once).

Parameters
template<class T>
inline array_type::tensor<double, 2> AsNode(const T &arg) const

Convert “dofval” or “elemvec” to “nodevec” (overwrite entries that occur more than once).

Parameters

arg – dofval [ndof] or elemvec [nelem, nne, ndim]

Returns

nodevec output [nnode, ndim]

template<class T, class R>
inline void asNode(const T &arg, R &ret) const

Convert “dofval” or “elemvec” to “nodevec” (overwrite entries that occur more than once).

Parameters
template<class T>
inline array_type::tensor<double, 3> AsElement(const T &arg) const

Convert “dofval” or “nodevec” to “elemvec” (overwrite entries that occur more than once).

Parameters

arg – dofval [ndof] or nodevec [nnode, ndim].

Returns

elemvec output [nelem, nne, ndim].

template<class T, class R>
inline void asElement(const T &arg, R &ret) const

Convert “dofval” or “nodevec” to “elemvec” (overwrite entries that occur more than once).

Parameters
template<class T>
inline array_type::tensor<double, 1> AssembleDofs(const T &arg) const

Assemble “nodevec” or “elemvec” to “dofval” (adds entries that occur more that once).

Parameters

arg – nodevec [nnode, ndim] or elemvec [nelem, nne, ndim]

Returns

dofval output [ndof]

template<class T, class R>
inline void assembleDofs(const T &arg, R &ret) const

Assemble “nodevec” or “elemvec” to “dofval” (adds entries that occur more that once).

Parameters
template<class T>
inline array_type::tensor<double, 2> AssembleNode(const T &arg) const

Assemble “elemvec” to “nodevec” (adds entries that occur more that once.

Parameters

arg – elemvec [nelem, nne, ndim]

Returns

nodevec output [nnode, ndim]

template<class T, class R>
inline void assembleNode(const T &arg, R &ret) const

Assemble “elemvec” to “nodevec” (adds entries that occur more that once.

Parameters
inline std::array<size_t, 1> shape_dofval() const

Shape of “dofval”.

Returns

[ndof]

inline std::array<size_t, 2> shape_nodevec() const

Shape of “nodevec”.

Returns

[nnode, ndim]

inline std::array<size_t, 3> shape_elemvec() const

Shape of “elemvec”.

Returns

[nelem, nne, ndim]

inline std::array<size_t, 3> shape_elemmat() const

Shape of “elemmat”.

Returns

[nelem, nne * ndim, nne * ndim]

inline array_type::tensor<double, 1> allocate_dofval() const

Allocated “dofval”.

Returns

[ndof]

inline array_type::tensor<double, 1> allocate_dofval(double val) const

Allocated and initialised “dofval”.

Parameters

val – value to which to initialise.

Returns

[ndof]

inline array_type::tensor<double, 2> allocate_nodevec() const

Allocated “nodevec”.

Returns

[nnode, ndim]

inline array_type::tensor<double, 2> allocate_nodevec(double val) const

Allocated and initialised “nodevec”.

Parameters

val – value to which to initialise.

Returns

[nnode, ndim]

inline array_type::tensor<double, 3> allocate_elemvec() const

Allocated “elemvec”.

Returns

[nelem, nne, ndim]

inline array_type::tensor<double, 3> allocate_elemvec(double val) const

Allocated and initialised “elemvec”.

Parameters

val – value to which to initialise.

Returns

[nelem, nne, ndim]

inline array_type::tensor<double, 3> allocate_elemmat() const

Allocated “elemmat”.

Returns

[nelem, nne * ndim, nne * ndim]

inline array_type::tensor<double, 3> allocate_elemmat(double val) const

Allocated and initialised “elemmat”.

Parameters

val – value to which to initialise.

Returns

[nelem, nne * ndim, nne * ndim]

Protected Attributes

array_type::tensor<size_t, 2> m_conn#

See conn()

array_type::tensor<size_t, 2> m_dofs#

See dofs()

size_t m_nelem#

See nelem.

size_t m_nne#

See nne.

size_t m_nnode#

See nnode.

size_t m_ndim#

See ndim.

size_t m_ndof#

See ndof.

Private Functions

template<class T, class R, typename std::enable_if_t<!xt::has_fixed_rank_t<T>::value, int> = 0>
inline void asDofs_impl(const T &arg, R &ret) const#

Distribution to relevant implementation of.

Convert “nodevec” or “elemvec” to “dofval” (overwrite entries that occur more than once).

Parameters
template<class T, class R, typename std::enable_if_t<xt::get_rank<T>::value == 2, int> = 0>
inline void asDofs_impl(const T &arg, R &ret) const#

Distribution to relevant implementation of.

Convert “nodevec” or “elemvec” to “dofval” (overwrite entries that occur more than once).

Parameters
template<class T, class R, typename std::enable_if_t<xt::get_rank<T>::value == 3, int> = 0>
inline void asDofs_impl(const T &arg, R &ret) const#

Distribution to relevant implementation of.

Convert “nodevec” or “elemvec” to “dofval” (overwrite entries that occur more than once).

Parameters
template<class T, class R, typename std::enable_if_t<!xt::has_fixed_rank_t<T>::value, int> = 0>
inline void asNode_impl(const T &arg, R &ret) const#

Distribution to relevant implementation of.

Convert “dofval” or “elemvec” to “nodevec” (overwrite entries that occur more than once).

Parameters
template<class T, class R, typename std::enable_if_t<xt::get_rank<T>::value == 1, int> = 0>
inline void asNode_impl(const T &arg, R &ret) const#

Distribution to relevant implementation of.

Convert “dofval” or “elemvec” to “nodevec” (overwrite entries that occur more than once).

Parameters
template<class T, class R, typename std::enable_if_t<xt::get_rank<T>::value == 3, int> = 0>
inline void asNode_impl(const T &arg, R &ret) const#

Distribution to relevant implementation of.

Convert “dofval” or “elemvec” to “nodevec” (overwrite entries that occur more than once).

Parameters
template<class T, class R, typename std::enable_if_t<!xt::has_fixed_rank_t<T>::value, int> = 0>
inline void asElement_impl(const T &arg, R &ret) const#

Distribution to relevant implementation of.

Convert “dofval” or “nodevec” to “elemvec” (overwrite entries that occur more than once).

Parameters
template<class T, class R, typename std::enable_if_t<xt::get_rank<T>::value == 1, int> = 0>
inline void asElement_impl(const T &arg, R &ret) const#

Distribution to relevant implementation of.

Convert “dofval” or “nodevec” to “elemvec” (overwrite entries that occur more than once).

Parameters
template<class T, class R, typename std::enable_if_t<xt::get_rank<T>::value == 2, int> = 0>
inline void asElement_impl(const T &arg, R &ret) const#

Distribution to relevant implementation of.

Convert “dofval” or “nodevec” to “elemvec” (overwrite entries that occur more than once).

Parameters
template<class T, class R, typename std::enable_if_t<!xt::has_fixed_rank_t<T>::value, int> = 0>
inline void assembleDofs_impl(const T &arg, R &ret) const#

Distribution to relevant implementation of.

Assemble “nodevec” or “elemvec” to “dofval” (adds entries that occur more that once).

Parameters
template<class T, class R, typename std::enable_if_t<xt::get_rank<T>::value == 2, int> = 0>
inline void assembleDofs_impl(const T &arg, R &ret) const#

Distribution to relevant implementation of.

Assemble “nodevec” or “elemvec” to “dofval” (adds entries that occur more that once).

Parameters
template<class T, class R, typename std::enable_if_t<xt::get_rank<T>::value == 3, int> = 0>
inline void assembleDofs_impl(const T &arg, R &ret) const#

Distribution to relevant implementation of.

Assemble “nodevec” or “elemvec” to “dofval” (adds entries that occur more that once).

Parameters
template<class T, class R, typename std::enable_if_t<!xt::has_fixed_rank_t<T>::value, int> = 0>
inline void assembleNode_impl(const T &arg, R &ret) const#

Distribution to relevant implementation of.

Assemble “elemvec” to “nodevec” (adds entries that occur more that once.

Parameters
template<class T, class R, typename std::enable_if_t<xt::get_rank<T>::value == 3, int> = 0>
inline void assembleNode_impl(const T &arg, R &ret) const#

Distribution to relevant implementation of.

Assemble “elemvec” to “nodevec” (adds entries that occur more that once.

Parameters
template<class T, class R>
inline void asDofs_impl_nodevec(const T &arg, R &ret) const#

Implementation for ‘nodevec’ input of.

Convert “nodevec” or “elemvec” to “dofval” (overwrite entries that occur more than once).

Parameters
template<class T, class R>
inline void asDofs_impl_elemvec(const T &arg, R &ret) const#

Implementation for ‘elemvec’ input of.

Convert “nodevec” or “elemvec” to “dofval” (overwrite entries that occur more than once).

Parameters
template<class T, class R>
inline void asNode_impl_dofval(const T &arg, R &ret) const#

Implementation for ‘dofval’ input of.

Convert “dofval” or “elemvec” to “nodevec” (overwrite entries that occur more than once).

Parameters
template<class T, class R>
inline void asNode_impl_elemvec(const T &arg, R &ret) const#

Implementation for ‘elemvec’ input of.

Convert “dofval” or “elemvec” to “nodevec” (overwrite entries that occur more than once).

Parameters
template<class T, class R>
inline void asElement_impl_dofval(const T &arg, R &ret) const#

Implementation for ‘dofval’ input of.

Convert “dofval” or “nodevec” to “elemvec” (overwrite entries that occur more than once).

Parameters
template<class T, class R>
inline void asElement_impl_nodevec(const T &arg, R &ret) const#

Implementation for ‘nodevec’ input of.

Convert “dofval” or “nodevec” to “elemvec” (overwrite entries that occur more than once).

Parameters
template<class T, class R>
inline void assembleDofs_impl_nodevec(const T &arg, R &ret) const#

Implementation for ‘nodevec’ input of.

Assemble “nodevec” or “elemvec” to “dofval” (adds entries that occur more that once).

Parameters
template<class T, class R>
inline void assembleDofs_impl_elemvec(const T &arg, R &ret) const#

Implementation for ‘elemvec’ input of.

Assemble “nodevec” or “elemvec” to “dofval” (adds entries that occur more that once).

Parameters
template<class T, class R>
inline void assembleNode_impl_elemvec(const T &arg, R &ret) const#

Implementation for ‘elemvec’ input of.

Assemble “elemvec” to “nodevec” (adds entries that occur more that once.

Parameters