Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MoReFEM
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
46
Issues
46
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MoReFEM
CoreLibrary
MoReFEM
Commits
60f3714a
Commit
60f3714a
authored
Jun 25, 2020
by
GILLES Sebastien
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#1535
Replace more Internal() by InternalForReadOnly().
parent
6e19b300
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
29 deletions
+40
-29
Sources/ThirdParty/Wrappers/Petsc/Matrix/MatrixOperations.hpp
...ces/ThirdParty/Wrappers/Petsc/Matrix/MatrixOperations.hpp
+8
-5
Sources/ThirdParty/Wrappers/Petsc/Matrix/MatrixOperations.hxx
...ces/ThirdParty/Wrappers/Petsc/Matrix/MatrixOperations.hxx
+32
-24
No files found.
Sources/ThirdParty/Wrappers/Petsc/Matrix/MatrixOperations.hpp
View file @
60f3714a
...
...
@@ -156,14 +156,14 @@ namespace MoReFEM
*/
template
<
class
MatrixT
,
class
MatrixU
class
MatrixT
,
class
MatrixU
>
std
::
enable_if_t
<
std
::
is_base_of
<
Internal
::
Wrappers
::
Petsc
::
BaseMatrix
,
MatrixT
>::
value
&&
std
::
is_base_of
<
Internal
::
Wrappers
::
Petsc
::
BaseMatrix
,
MatrixU
>::
value
,
void
std
::
is_base_of
<
Internal
::
Wrappers
::
Petsc
::
BaseMatrix
,
MatrixT
>::
value
&&
std
::
is_base_of
<
Internal
::
Wrappers
::
Petsc
::
BaseMatrix
,
MatrixU
>::
value
,
void
>
MatTranspose
(
MatrixT
&
matrix1
,
MatrixU
&
matrix2
,
...
...
@@ -403,6 +403,9 @@ namespace MoReFEM
* \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.
* \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
<
...
...
Sources/ThirdParty/Wrappers/Petsc/Matrix/MatrixOperations.hxx
View file @
60f3714a
...
...
@@ -154,9 +154,9 @@ namespace MoReFEM
case
DoReuseMatrix
::
yes
:
{
result
=
out
.
Internal
();
error_code
=
::
MatMatMatMult
(
matrix1
.
Internal
(),
matrix2
.
Internal
(),
matrix3
.
Internal
(),
error_code
=
::
MatMatMatMult
(
matrix1
.
Internal
ForReadOnly
(),
matrix2
.
Internal
ForReadOnly
(),
matrix3
.
Internal
ForReadOnly
(),
MAT_REUSE_MATRIX
,
PETSC_DEFAULT
,
&
result
);
...
...
@@ -166,9 +166,9 @@ namespace MoReFEM
}
case
DoReuseMatrix
::
no
:
{
error_code
=
::
MatMatMatMult
(
matrix1
.
Internal
(),
matrix2
.
Internal
(),
matrix3
.
Internal
(),
error_code
=
::
MatMatMatMult
(
matrix1
.
Internal
ForReadOnly
(),
matrix2
.
Internal
ForReadOnly
(),
matrix3
.
Internal
ForReadOnly
(),
MAT_INITIAL_MATRIX
,
PETSC_DEFAULT
,
&
result
);
...
...
@@ -261,29 +261,37 @@ namespace MoReFEM
const
char
*
invoking_file
,
int
invoking_line
,
DoReuseMatrix
do_reuse_matrix
)
{
static_assert
(
std
::
is_const
<
MatrixU
>
()
==
false
);
Mat
result
;
int
error_code
{};
switch
(
do_reuse_matrix
)
{
case
DoReuseMatrix
::
no
:
{
error_code
=
::
MatTranspose
(
matrix1
.
Internal
(),
MAT_INITIAL_MATRIX
,
&
result
);
error_code
=
::
MatTranspose
(
matrix1
.
Internal
ForReadOnly
(),
MAT_INITIAL_MATRIX
,
&
result
);
matrix2
.
SetFromPetscMat
(
result
);
break
;
}
case
DoReuseMatrix
::
yes
:
{
result
=
matrix2
.
Internal
();
error_code
=
::
MatTranspose
(
matrix1
.
Internal
(),
MAT_REUSE_MATRIX
,
&
result
);
error_code
=
::
MatTranspose
(
matrix1
.
Internal
ForReadOnly
(),
MAT_REUSE_MATRIX
,
&
result
);
break
;
}
case
DoReuseMatrix
::
in_place
:
{
result
=
matrix1
.
Internal
();
assert
(
matrix1
.
Internal
()
==
matrix2
.
Internal
()
&&
"For in place transpose both arguments"
"are expected to be pointers to the"
"same PETSc matrix object."
);
error_code
=
::
MatTranspose
(
matrix1
.
Internal
(),
MAT_INPLACE_MATRIX
,
&
result
);
result
=
matrix2
.
Internal
();
assert
(
matrix1
.
InternalForReadOnly
()
==
matrix2
.
Internal
()
&&
"For in place transpose both arguments"
"are expected to be pointers to the"
"same PETSc matrix object."
);
// < 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
;
}
}
// switch
...
...
@@ -368,8 +376,8 @@ namespace MoReFEM
{
result
=
matrix3
.
Internal
();
error_code
=
::
MatTransposeMatMult
(
matrix1
.
Internal
(),
matrix2
.
Internal
(),
error_code
=
::
MatTransposeMatMult
(
matrix1
.
Internal
ForReadOnly
(),
matrix2
.
Internal
ForReadOnly
(),
MAT_REUSE_MATRIX
,
PETSC_DEFAULT
,
&
result
);
...
...
@@ -378,8 +386,8 @@ namespace MoReFEM
}
case
DoReuseMatrix
::
no
:
{
error_code
=
::
MatTransposeMatMult
(
matrix1
.
Internal
(),
matrix2
.
Internal
(),
error_code
=
::
MatTransposeMatMult
(
matrix1
.
Internal
ForReadOnly
(),
matrix2
.
Internal
ForReadOnly
(),
MAT_INITIAL_MATRIX
,
PETSC_DEFAULT
,
&
result
);
...
...
@@ -429,8 +437,8 @@ namespace MoReFEM
case
DoReuseMatrix
::
yes
:
{
result
=
matrix3
.
Internal
();
error_code
=
::
MatMatTransposeMult
(
matrix1
.
Internal
(),
matrix2
.
Internal
(),
error_code
=
::
MatMatTransposeMult
(
matrix1
.
Internal
ForReadOnly
(),
matrix2
.
Internal
ForReadOnly
(),
MAT_REUSE_MATRIX
,
PETSC_DEFAULT
,
&
result
);
...
...
@@ -438,8 +446,8 @@ namespace MoReFEM
}
case
DoReuseMatrix
::
no
:
{
error_code
=
::
MatMatTransposeMult
(
matrix1
.
Internal
(),
matrix2
.
Internal
(),
error_code
=
::
MatMatTransposeMult
(
matrix1
.
Internal
ForReadOnly
(),
matrix2
.
Internal
ForReadOnly
(),
MAT_INITIAL_MATRIX
,
PETSC_DEFAULT
,
&
result
);
...
...
@@ -528,7 +536,7 @@ namespace MoReFEM
IS
*
cperm
,
const
char
*
invoking_file
,
int
invoking_line
)
{
int
error_code
=
::
MatGetOrdering
(
A
.
Internal
(),
int
error_code
=
::
MatGetOrdering
(
A
.
Internal
ForReadOnly
(),
type
,
rperm
,
cperm
);
...
...
@@ -573,8 +581,8 @@ namespace MoReFEM
MatrixV
&
X
,
const
char
*
invoking_file
,
int
invoking_line
)
{
int
error_code
=
::
MatMatSolve
(
A
.
Internal
(),
B
.
Internal
(),
int
error_code
=
::
MatMatSolve
(
A
.
Internal
ForReadOnly
(),
B
.
Internal
ForReadOnly
(),
X
.
Internal
());
if
(
error_code
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment