From dcc20a376753dba118c9b5151d96894edcc58e26 Mon Sep 17 00:00:00 2001 From: Christoph Lehmann <christoph.lehmann@ufz.de> Date: Mon, 4 Jul 2016 12:52:16 +0200 Subject: [PATCH] [NL] moved some code --- .../DOFTableUtil.cpp} | 29 +++++-------------- NumLib/DOF/DOFTableUtil.h | 27 +++++++++++++++++ 2 files changed, 35 insertions(+), 21 deletions(-) rename NumLib/{Assembler/VectorMatrixAssembler.h => DOF/DOFTableUtil.cpp} (63%) create mode 100644 NumLib/DOF/DOFTableUtil.h diff --git a/NumLib/Assembler/VectorMatrixAssembler.h b/NumLib/DOF/DOFTableUtil.cpp similarity index 63% rename from NumLib/Assembler/VectorMatrixAssembler.h rename to NumLib/DOF/DOFTableUtil.cpp index 4697be7d5dc..2e88356152e 100644 --- a/NumLib/Assembler/VectorMatrixAssembler.h +++ b/NumLib/DOF/DOFTableUtil.cpp @@ -7,28 +7,20 @@ * */ -#ifndef NUMLIB_VECTORMATRIXASSEMBLER_H_ -#define NUMLIB_VECTORMATRIXASSEMBLER_H_ - -#include "NumLib/ODESolver/Types.h" -#include "NumLib/DOF/LocalToGlobalIndexMap.h" +#include "DOFTableUtil.h" +#include <cassert> namespace NumLib { - -namespace detail -{ -inline std::vector<GlobalIndexType> -getIndices(std::size_t const id, - NumLib::LocalToGlobalIndexMap const& dof_table) +std::vector<GlobalIndexType> getIndices( + std::size_t const id, NumLib::LocalToGlobalIndexMap const& dof_table) { assert(dof_table.size() > id); std::vector<GlobalIndexType> indices; // Local matrices and vectors will always be ordered by component // no matter what the order of the global matrix is. - for (unsigned c = 0; c < dof_table.getNumberOfComponents(); ++c) - { + for (unsigned c = 0; c < dof_table.getNumberOfComponents(); ++c) { auto const& idcs = dof_table(id, c).rows; indices.reserve(indices.size() + idcs.size()); indices.insert(indices.end(), idcs.begin(), idcs.end()); @@ -37,22 +29,17 @@ getIndices(std::size_t const id, return indices; } -inline std::vector<double> -getLocalNodalDOFs(GlobalVector const& x, - std::vector<GlobalIndexType> const& dof_indices) +std::vector<double> getLocalNodalDOFs( + GlobalVector const& x, std::vector<GlobalIndexType> const& dof_indices) { std::vector<double> local_x; local_x.reserve(dof_indices.size()); - for (auto i : dof_indices) - { + for (auto i : dof_indices) { // TODO save some function calls to x[i] local_x.emplace_back(x[i]); } return local_x; } -} // namespace detail } // namespace NumLib - -#endif // NUMLIB_VECTORMATRIXASSEMBLER_H_ diff --git a/NumLib/DOF/DOFTableUtil.h b/NumLib/DOF/DOFTableUtil.h new file mode 100644 index 00000000000..0bb9ee998b3 --- /dev/null +++ b/NumLib/DOF/DOFTableUtil.h @@ -0,0 +1,27 @@ +/** + * \copyright + * Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#ifndef NUMLIB_DOF_DOFTABLEUTIL_H +#define NUMLIB_DOF_DOFTABLEUTIL_H + +#include "NumLib/DOF/LocalToGlobalIndexMap.h" + +namespace NumLib +{ +//! Returns nodal indices for the item identified by \c id from the given +//! \c dof_table. +std::vector<GlobalIndexType> getIndices( + std::size_t const id, NumLib::LocalToGlobalIndexMap const& dof_table); + +//! Returns the values for the given \c dof_indices from the vector \c x. +std::vector<double> getLocalNodalDOFs( + GlobalVector const& x, std::vector<GlobalIndexType> const& dof_indices); +} // namespace NumLib + +#endif // NUMLIB_DOF_DOFTABLEUTIL_H -- GitLab