Commit fef0447d authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#889 Petsc: add wrappers to the functions MatTransposedMatMult and MatMatTransposedMult.

parent e1a8f110
......@@ -259,19 +259,22 @@ namespace HappyHeart
{
auto& interpolator = GetNonCstFluidMassInterpolationMatrix();
const auto& foo = GetInterpMassFromSolidMesh().GetInterpolationMatrix();
Wrappers::Petsc::MatMatMult(GetExpandMass().GetInterpolationMatrix(),
GetInterpMassFromSolidMesh().GetInterpolationMatrix(),
foo,
interpolator,
__FILE__, __LINE__);
auto& inverse_interpolator = GetNonCstInverseFluidMassInterpolationMatrix();
Wrappers::Petsc::MatMatMult(GetInterpMassFromSolidMesh().GetInterpolationMatrix(),
GetReduceToMass().GetInterpolationMatrix(),
inverse_interpolator,
__FILE__, __LINE__);
GlobalMatrix transposed(foo.GetColNumberingSubset(), foo.GetRowNumberingSubset());
Wrappers::Petsc::MatTransposeMatMult(foo,
GetReduceToMass().GetInterpolationMatrix(),
inverse_interpolator,
__FILE__, __LINE__);
}
......
......@@ -324,6 +324,65 @@ namespace HappyHeart
const char* invoking_file, int invoking_line);
/*!
* \brief Performs Matrix-Matrix Multiplication C = A^T * B.
*
* \todo #684 Investigate to use the argument fill, which provides an estimation of the non zero of the
* resulting matrix. Currently PETSC_DEFAULT is used.
*
* \param[in] matrix1 A in C = A^T * B.
* \param[in] matrix2 B in C = A^T * B.
* \param[out] matrix3 C in B in C = A^T * B. The matrix must be not allocated when this function is called.
* \param[in] invoking_file File that invoked the function or class; usually __FILE__.
* \param[in] invoking_line File that invoked the function or class; usually __LINE__.
*/
template
<
class MatrixT,
class MatrixU
>
std::enable_if_t
<
std::is_base_of<Private::BaseMatrix, MatrixT>::value
&& std::is_base_of<Private::BaseMatrix, MatrixU>::value,
void
>
MatTransposeMatMult(const MatrixT& matrix1,
const MatrixT& matrix2,
MatrixU& matrix3,
const char* invoking_file, int invoking_line);
/*!
* \brief Performs Matrix-Matrix Multiplication C = A * B^T.
*
* \todo #684 Investigate to use the argument fill, which provides an estimation of the non zero of the
* resulting matrix. Currently PETSC_DEFAULT is used.
*
* \param[in] matrix1 A in C = A * B^T.
* \param[in] matrix2 B in C = A * B^T.
* \param[out] matrix3 C in B in C = A * B^T. The matrix must be not allocated when this function is called.
* \param[in] invoking_file File that invoked the function or class; usually __FILE__.
* \param[in] invoking_line File that invoked the function or class; usually __LINE__.
*/
template
<
class MatrixT,
class MatrixU
>
std::enable_if_t
<
std::is_base_of<Private::BaseMatrix, MatrixT>::value
&& std::is_base_of<Private::BaseMatrix, MatrixU>::value,
void
>
MatMatTransposeMult(const MatrixT& matrix1,
const MatrixT& matrix2,
MatrixU& matrix3,
const char* invoking_file, int invoking_line);
} //namespace Petsc
......
......@@ -309,6 +309,83 @@ namespace HappyHeart
}
template
<
class MatrixT,
class MatrixU
>
std::enable_if_t
<
std::is_base_of<Private::BaseMatrix, MatrixT>::value
&& std::is_base_of<Private::BaseMatrix, MatrixU>::value,
void
>
MatTransposeMatMult(const MatrixT& matrix1,
const MatrixT& matrix2,
MatrixU& matrix3,
const char* invoking_file, int invoking_line)
{
Mat result;
int error_code = ::MatTransposeMatMult(matrix1.Internal(),
matrix2.Internal(),
MAT_INITIAL_MATRIX,
PETSC_DEFAULT,
&result);
matrix3.SetFromPetscMat(result);
if (error_code)
throw ExceptionNS::Exception(error_code, "MatTransposeMatMult", invoking_file, invoking_line);
}
/*!
* \brief Performs Matrix-Matrix Multiplication C = A * B^T.
*
* \todo #684 Investigate to use the argument fill, which provides an estimation of the non zero of the
* resulting matrix. Currently PETSC_DEFAULT is used.
*
* \param[in] matrix1 A in C = A * B^T.
* \param[in] matrix2 B in C = A * B^T.
* \param[out] matrix3 C in B in C = A * B^T. The matrix must be not allocated when this function is called.
* \param[in] invoking_file File that invoked the function or class; usually __FILE__.
* \param[in] invoking_line File that invoked the function or class; usually __LINE__.
*/
template
<
class MatrixT,
class MatrixU
>
std::enable_if_t
<
std::is_base_of<Private::BaseMatrix, MatrixT>::value
&& std::is_base_of<Private::BaseMatrix, MatrixU>::value,
void
>
MatMatTransposeMult(const MatrixT& matrix1,
const MatrixT& matrix2,
MatrixU& matrix3,
const char* invoking_file, int invoking_line)
{
Mat result;
int error_code = ::MatMatTransposeMult(matrix1.Internal(),
matrix2.Internal(),
MAT_INITIAL_MATRIX,
PETSC_DEFAULT,
&result);
matrix3.SetFromPetscMat(result);
if (error_code)
throw ExceptionNS::Exception(error_code, "MatMatTransposeMult", invoking_file, invoking_line);
}
} //namespace Petsc
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment