Maj terminée. Pour consulter la release notes associée voici le lien :
https://about.gitlab.com/releases/2021/07/07/critical-security-release-gitlab-14-0-4-released/

Commit 60f3714a authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#1535 Replace more Internal() by InternalForReadOnly().

parent 6e19b300
...@@ -156,14 +156,14 @@ namespace MoReFEM ...@@ -156,14 +156,14 @@ namespace MoReFEM
*/ */
template template
< <
class MatrixT, class MatrixT,
class MatrixU class MatrixU
> >
std::enable_if_t std::enable_if_t
< <
std::is_base_of<Internal::Wrappers::Petsc::BaseMatrix, MatrixT>::value std::is_base_of<Internal::Wrappers::Petsc::BaseMatrix, MatrixT>::value
&& std::is_base_of<Internal::Wrappers::Petsc::BaseMatrix, MatrixU>::value, && std::is_base_of<Internal::Wrappers::Petsc::BaseMatrix, MatrixU>::value,
void void
> >
MatTranspose(MatrixT& matrix1, MatTranspose(MatrixT& matrix1,
MatrixU& matrix2, MatrixU& matrix2,
...@@ -403,6 +403,9 @@ namespace MoReFEM ...@@ -403,6 +403,9 @@ namespace MoReFEM
* \param[in] matrix2 B 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[out] matrix3 C in B in C = A * B^T. The matrix must be not allocated when this function is called.
* \copydoc doxygen_hide_invoking_file_and_line * \copydoc doxygen_hide_invoking_file_and_line
*
* \attention It is not advised to use this wrapper (at least currently: as of PETSc v1.13.2, there is no support for this operation
* for MPIAIJ and MPIAIJ matrices - so the code you would write with it will not run in parallel.
*/ */
template template
< <
......
...@@ -154,9 +154,9 @@ namespace MoReFEM ...@@ -154,9 +154,9 @@ namespace MoReFEM
case DoReuseMatrix::yes: case DoReuseMatrix::yes:
{ {
result = out.Internal(); result = out.Internal();
error_code = ::MatMatMatMult(matrix1.Internal(), error_code = ::MatMatMatMult(matrix1.InternalForReadOnly(),
matrix2.Internal(), matrix2.InternalForReadOnly(),
matrix3.Internal(), matrix3.InternalForReadOnly(),
MAT_REUSE_MATRIX, MAT_REUSE_MATRIX,
PETSC_DEFAULT, PETSC_DEFAULT,
&result); &result);
...@@ -166,9 +166,9 @@ namespace MoReFEM ...@@ -166,9 +166,9 @@ namespace MoReFEM
} }
case DoReuseMatrix::no: case DoReuseMatrix::no:
{ {
error_code = ::MatMatMatMult(matrix1.Internal(), error_code = ::MatMatMatMult(matrix1.InternalForReadOnly(),
matrix2.Internal(), matrix2.InternalForReadOnly(),
matrix3.Internal(), matrix3.InternalForReadOnly(),
MAT_INITIAL_MATRIX, MAT_INITIAL_MATRIX,
PETSC_DEFAULT, PETSC_DEFAULT,
&result); &result);
...@@ -261,29 +261,37 @@ namespace MoReFEM ...@@ -261,29 +261,37 @@ namespace MoReFEM
const char* invoking_file, int invoking_line, const char* invoking_file, int invoking_line,
DoReuseMatrix do_reuse_matrix) DoReuseMatrix do_reuse_matrix)
{ {
static_assert(std::is_const<MatrixU>() == false);
Mat result; Mat result;
int error_code {}; int error_code {};
switch (do_reuse_matrix) switch (do_reuse_matrix)
{ {
case DoReuseMatrix::no: case DoReuseMatrix::no:
{ {
error_code = ::MatTranspose(matrix1.Internal(), MAT_INITIAL_MATRIX, &result); error_code = ::MatTranspose(matrix1.InternalForReadOnly(), MAT_INITIAL_MATRIX, &result);
matrix2.SetFromPetscMat(result); matrix2.SetFromPetscMat(result);
break; break;
} }
case DoReuseMatrix::yes: case DoReuseMatrix::yes:
{ {
result = matrix2.Internal(); result = matrix2.Internal();
error_code = ::MatTranspose(matrix1.Internal(), MAT_REUSE_MATRIX, &result); error_code = ::MatTranspose(matrix1.InternalForReadOnly(), MAT_REUSE_MATRIX, &result);
break; break;
} }
case DoReuseMatrix::in_place: case DoReuseMatrix::in_place:
{ {
result = matrix1.Internal(); result = matrix2.Internal();
assert(matrix1.Internal() == matrix2.Internal() && "For in place transpose both arguments" assert(matrix1.InternalForReadOnly() == matrix2.Internal() && "For in place transpose both arguments"
"are expected to be pointers to the" "are expected to be pointers to the"
"same PETSc matrix object."); "same PETSc matrix object.");
error_code = ::MatTranspose(matrix1.Internal(), MAT_INPLACE_MATRIX, &result); // < note: Internal() and InternalForReadOnly() actually provide the same to the underlying
// pointer, but matrix1 might be const in some calls for the other values of do_reuse_matrix
// so Internal() couldn't be called on it reliably - to do so I would have to introduce
// a template class to enable partial specialization (I NEVER want to have to specify explicitly
// the matrix template parameters...).
error_code = ::MatTranspose(matrix2.Internal(), MAT_INPLACE_MATRIX, &result);
break; break;
} }
} // switch } // switch
...@@ -368,8 +376,8 @@ namespace MoReFEM ...@@ -368,8 +376,8 @@ namespace MoReFEM
{ {
result = matrix3.Internal(); result = matrix3.Internal();
error_code = ::MatTransposeMatMult(matrix1.Internal(), error_code = ::MatTransposeMatMult(matrix1.InternalForReadOnly(),
matrix2.Internal(), matrix2.InternalForReadOnly(),
MAT_REUSE_MATRIX, MAT_REUSE_MATRIX,
PETSC_DEFAULT, PETSC_DEFAULT,
&result); &result);
...@@ -378,8 +386,8 @@ namespace MoReFEM ...@@ -378,8 +386,8 @@ namespace MoReFEM
} }
case DoReuseMatrix::no: case DoReuseMatrix::no:
{ {
error_code = ::MatTransposeMatMult(matrix1.Internal(), error_code = ::MatTransposeMatMult(matrix1.InternalForReadOnly(),
matrix2.Internal(), matrix2.InternalForReadOnly(),
MAT_INITIAL_MATRIX, MAT_INITIAL_MATRIX,
PETSC_DEFAULT, PETSC_DEFAULT,
&result); &result);
...@@ -429,8 +437,8 @@ namespace MoReFEM ...@@ -429,8 +437,8 @@ namespace MoReFEM
case DoReuseMatrix::yes: case DoReuseMatrix::yes:
{ {
result = matrix3.Internal(); result = matrix3.Internal();
error_code = ::MatMatTransposeMult(matrix1.Internal(), error_code = ::MatMatTransposeMult(matrix1.InternalForReadOnly(),
matrix2.Internal(), matrix2.InternalForReadOnly(),
MAT_REUSE_MATRIX, MAT_REUSE_MATRIX,
PETSC_DEFAULT, PETSC_DEFAULT,
&result); &result);
...@@ -438,8 +446,8 @@ namespace MoReFEM ...@@ -438,8 +446,8 @@ namespace MoReFEM
} }
case DoReuseMatrix::no: case DoReuseMatrix::no:
{ {
error_code = ::MatMatTransposeMult(matrix1.Internal(), error_code = ::MatMatTransposeMult(matrix1.InternalForReadOnly(),
matrix2.Internal(), matrix2.InternalForReadOnly(),
MAT_INITIAL_MATRIX, MAT_INITIAL_MATRIX,
PETSC_DEFAULT, PETSC_DEFAULT,
&result); &result);
...@@ -528,7 +536,7 @@ namespace MoReFEM ...@@ -528,7 +536,7 @@ namespace MoReFEM
IS *cperm, IS *cperm,
const char* invoking_file, int invoking_line) const char* invoking_file, int invoking_line)
{ {
int error_code = ::MatGetOrdering(A.Internal(), int error_code = ::MatGetOrdering(A.InternalForReadOnly(),
type, type,
rperm, rperm,
cperm); cperm);
...@@ -573,8 +581,8 @@ namespace MoReFEM ...@@ -573,8 +581,8 @@ namespace MoReFEM
MatrixV& X, MatrixV& X,
const char* invoking_file, int invoking_line) const char* invoking_file, int invoking_line)
{ {
int error_code = ::MatMatSolve(A.Internal(), int error_code = ::MatMatSolve(A.InternalForReadOnly(),
B.Internal(), B.InternalForReadOnly(),
X.Internal()); X.Internal());
if (error_code) if (error_code)
......
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