inline _3dArray<T> &_3dArray<T>::operator=(const _3dArray &rhs) { if (&rhs != this) { set_size(rhs.m_extents[0], rhs.m_extents[1], rhs.m_extents[2]); std::copy(rhs.begin(), rhs.end(), m_storage); } return *this; }
template <typename T> inline _3dArray<T>::_3dArray(const _3dArray &other) { if (!other.is_empty()) { init_memory(other.m_extents[0], other.m_extents[1], other.m_extents[2]); std::copy(other.begin(), other.end(), m_storage); } else init_empty(); }
inline _3dArray<T> &_3dArray<T>::operator+=(const _3dArray<T> &other) { if ((this->extent(0) != other.extent(0)) || (this->extent(1) != other.extent(1)) || (this->extent(2) != other.extent(2))) std::runtime_error("_3dArray<T> operator+=: Array sizes don't agree."); for (size_t i = 0; i < this->extent(2); ++i) for (size_t j = 0; j < this->extent(1); ++j) for (size_t k = 0; k < this->extent(0); ++k) (*this)(k, j, i) += other(k, j, i); return *this; }
void evaluateShapeFunctionsWithDune(const arma::Mat<CoordinateType> &local, LocalDofIndex localDofIndex, _3dArray<ValueType> &result, const DuneBasis &basis = DuneBasis()) { typedef typename DuneBasis::Traits Traits; assert(local.n_rows == Traits::dimDomain); assert(localDofIndex == ALL_DOFS || (localDofIndex >= 0 && localDofIndex < basis.size())); const int functionCount = localDofIndex == ALL_DOFS ? basis.size() : 1; const int pointCount = local.n_cols; typename Traits::DomainType point; std::vector<typename Traits::RangeType> values; result.set_size(Traits::dimRange, functionCount, pointCount); for (int pointIndex = 0; pointIndex < pointCount; ++pointIndex) { for (int dim = 0; dim < Traits::dimDomain; ++dim) point[dim] = local(dim, pointIndex); basis.evaluateFunction(point, values); if (localDofIndex == ALL_DOFS) for (int functionIndex = 0; functionIndex < functionCount; ++functionIndex) for (int dim = 0; dim < Traits::dimRange; ++dim) result(dim, functionIndex, pointIndex) = values[functionIndex][dim]; else for (int dim = 0; dim < Traits::dimRange; ++dim) result(dim, 0, pointIndex) = values[localDofIndex][dim]; } }
/** \brief Return number of points at which the shape functions have been * calculated. */ int pointCount() const { return std::max<int>(values.extent(2), derivatives.extent(3)); }
/** \brief Return number of shape functions. */ int functionCount() const { return std::max<int>(values.extent(1), derivatives.extent(2)); }
/** \brief Return number of components of shape functions. */ int componentCount() const { return std::max<int>(values.extent(0), derivatives.extent(0)); }