https://gitlab.opengeosys.org/ogs/ogs.git
Raw File
Tip revision: 7222138215e483a7c33a74097a6e48d99e14b42a authored by Norbert Grunwald on 04 October 2021, 18:43:56 UTC
Merge branch 'remove_heat_capacity' into 'master'
Tip revision: 7222138
TransposeInPlace.h
/**
 * \file
 * \copyright
 * Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org)
 *            Distributed under a Modified BSD License.
 *              See accompanying file LICENSE.txt or
 *              http://www.opengeosys.org/project/license
 */

#pragma once

#include <vector>

#include "MathLib/LinAlg/Eigen/EigenMapTools.h"

namespace ProcessLib
{
/// In-place transpose. A helper function for the integration point data
/// getters.
/// For time being Eigen's transposeInPlace doesn't work for non-square mapped
/// matrices.
template <int Components, typename StoreValuesFunction>
std::vector<double> transposeInPlace(
    StoreValuesFunction const& store_values_function)
{
    std::vector<double> result;
    store_values_function(result);
    MathLib::toMatrix<
        Eigen::Matrix<double, Eigen::Dynamic, Components, Eigen::RowMajor>>(
        result, result.size() / Components, Components) =
        MathLib::toMatrix<
            Eigen::Matrix<double, Components, Eigen::Dynamic, Eigen::RowMajor>>(
            result, Components, result.size() / Components)
            .transpose()
            .eval();

    return result;
}

}  // namespace ProcessLib
back to top