https://gitlab.opengeosys.org/ogs/ogs.git
Raw File
Tip revision: 35f70a518dfea2ad7f008b434362c2e1cbf2866b authored by Wenqing Wang on 12 October 2021, 09:12:02 UTC
[PythonBC] Corrected the dimension used in ShapeMatrixPolicyType
Tip revision: 35f70a5
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