Re: [petsc-users] question on PCLSC with matrix blocks of type MATNEST

2024-02-13 Thread Zhang, Hong via petsc-users
Pierre,
Please review 
https://gitlab.com/petsc/petsc/-/merge_requests/7292#5479b9c001ff78d18f5236b7e21d8b1cb9acf476
I moved your checking PetscCheck((*C)->ops->productsymbolic,...) from 
MatProduct_Private() to MatProductSymbolic() .
With this fix, you can run ex195 with
./ex195 -test_nest*nest or ./ex195 -test_matproduct
...
[0]PETSC ERROR: No support for this operation for this object type
[0]PETSC ERROR: Unspecified symbolic phase for product AB with A nest, B nest. 
Call MatProductSetFromOptions() first or the product is not supported

Both tests give the same error output.

In the design of MatProduct routines, we set API calling process as
MatProductCreate()
MatProductSetType()
MatProductSetFromOptions() //determines the implementations of symbolic and 
numeric products, must be called!
MatProductSymbolic()
MatProductNumeric()

Hong


From: Pierre Jolivet 
Sent: Tuesday, February 13, 2024 2:48 PM
To: Zhang, Hong 
Cc: petsc-users@mcs.anl.gov ; Hana Honnerová 

Subject: Re: [petsc-users] question on PCLSC with matrix blocks of type MATNEST



On 13 Feb 2024, at 9:21 PM, Zhang, Hong via petsc-users 
 wrote:

Pierre,
I can repeat your change in ex27.c on petsc-release. However, replacing
+Mat D;
+PetscCall(MatMatMult(C, C, MAT_INITIAL_MATRIX, PETSC_DECIDE, ));
+PetscCall(MatDestroy());
with
 PetscCall(MatCreateNest(PETSC_COMM_WORLD, 2, NULL, 2, NULL, array, ));
+Mat D;
+PetscCall(MatProductCreate(C, C, NULL, ));
+PetscCall(MatProductSetType(D, MATPRODUCT_AB));
+PetscCall(MatProductSetFromOptions(D));
+PetscCall(MatProductSymbolic(D));
+PetscCall(MatProductNumeric(D));
+PetscCall(MatDestroy());

Sure, I fixed a single MatProduct bug, my guts tell me there are other 
unhandled corner cases, and you indeed found another one.

./ex27 -f  farzad_B_rhs -truncate -solve_augmented
...
[0]PETSC ERROR: Petsc has generated inconsistent data
[0]PETSC ERROR: Unspecified symbolic phase for product AB with A nest, B nest. 
Call MatProductSetFromOptions() first or the product is not supported
...
[0]PETSC ERROR: #1 MatProductSymbolic() at 
/Users/hongzhang-sun/soft/petsc/src/mat/interface/matproduct.c:807
[0]PETSC ERROR: #2 main() at ex27.c:250

i.e., same confusing error message as reported by Hana, because this calling 
process does not call MatProduct_Private() with your fix. A fix to this is to 
modify the error message in MatProductSymbolic():

--- a/src/mat/interface/matproduct.c
+++ b/src/mat/interface/matproduct.c
@@ -804,7 +804,7 @@ PetscErrorCode MatProductSymbolic(Mat mat)
 ...
-PetscCheck(!missing, PetscObjectComm((PetscObject)mat), PETSC_ERR_PLIB, 
"Unspecified symbolic phase for product %s. Call MatProductSetFromOptions() 
first", errstr);
+PetscCheck(!missing, PetscObjectComm((PetscObject)mat), PETSC_ERR_PLIB, 
"Unspecified symbolic phase for product %s. Call MatProductSetFromOptions() 
first or the product is not supported", errstr);

I don’t see how this is less confusing.
In fact, to me, error message with conditionals in the sentence but without 
PETSc telling the value of each expression of the conditionals is infuriating.
How do I know if MatProductSetFromOptions() has not been called, or if the 
product is not supported?
This is very difficult to debug, to me, and if it would be possible to catch 
this with two different checks, it would be much better.
But the current design of MatProduct may not allow us to do it, so I will not 
be opposed to such a change.
Maybe add a Boolean à la pc->setupcalled or pc->setfromoptionscalled in the 
MatProduct structure to be able to distinguish better the cause of the failure?

Thanks,
Pierre

with this fix, I get
./ex27 -f farzad_B_rhs -truncate -solve_augmented
...
[0]PETSC ERROR: Petsc has generated inconsistent data
[0]PETSC ERROR: Unspecified symbolic phase for product AB with A nest, B nest. 
Call MatProductSetFromOptions() first or the product is not supported

If you agree with this fix, I'll create a MR for it.
Hong



From: Pierre Jolivet 
Sent: Tuesday, February 13, 2024 12:08 AM
To: Zhang, Hong 
Cc: Hana Honnerová ; petsc-users@mcs.anl.gov 

Subject: Re: [petsc-users] question on PCLSC with matrix blocks of type MATNEST



On 13 Feb 2024, at 12:33 AM, Zhang, Hong  wrote:

Pierre,
I just modified the error message of MatProductSymbolic() and added a testing 
segment in src/mat/tests/ex195.c. I have not pushed my change yet.

Your fix at 
https://gitlab.com/petsc/petsc/-/commit/9dcea022de3b0309e5c16b8c554ad9c85dea29cf?merge_request_iid=7283
 is more general. Has this fix merged to release and main? With latest main and 
release, I get same previous error message.

I don’t (anymore, but could prior to my fix).
The trigger is MatMatMult() with MAT_INITIAL_MATRIX in PCSetUp_LSC().
Reproducible with:
diff --git a/src/ksp/ksp/tutorials/ex27.c b/src/ksp/ksp/tutorials/ex27.c
index 116b7df8522..9bdf4d7334a 100644
--- 

Re: [petsc-users] question on PCLSC with matrix blocks of type MATNEST

2024-02-13 Thread Pierre Jolivet


> On 13 Feb 2024, at 9:21 PM, Zhang, Hong via petsc-users 
>  wrote:
> 
> Pierre,
> I can repeat your change in ex27.c on petsc-release. However, replacing 
> +Mat D;
> +PetscCall(MatMatMult(C, C, MAT_INITIAL_MATRIX, PETSC_DECIDE, ));
> +PetscCall(MatDestroy());
> with
>  PetscCall(MatCreateNest(PETSC_COMM_WORLD, 2, NULL, 2, NULL, array, ));
> +Mat D;
> +PetscCall(MatProductCreate(C, C, NULL, ));
> +PetscCall(MatProductSetType(D, MATPRODUCT_AB));
> +PetscCall(MatProductSetFromOptions(D));
> +PetscCall(MatProductSymbolic(D));
> +PetscCall(MatProductNumeric(D));
> +PetscCall(MatDestroy());

Sure, I fixed a single MatProduct bug, my guts tell me there are other 
unhandled corner cases, and you indeed found another one.

> ./ex27 -f  farzad_B_rhs -truncate -solve_augmented
> ...
> [0]PETSC ERROR: Petsc has generated inconsistent data
> [0]PETSC ERROR: Unspecified symbolic phase for product AB with A nest, B 
> nest. Call MatProductSetFromOptions() first or the product is not supported
> ...
> [0]PETSC ERROR: #1 MatProductSymbolic() at 
> /Users/hongzhang-sun/soft/petsc/src/mat/interface/matproduct.c:807
> [0]PETSC ERROR: #2 main() at ex27.c:250
> 
> i.e., same confusing error message as reported by Hana, because this calling 
> process does not call MatProduct_Private() with your fix. A fix to this is to 
> modify the error message in MatProductSymbolic():
> 
> --- a/src/mat/interface/matproduct.c
> +++ b/src/mat/interface/matproduct.c
> @@ -804,7 +804,7 @@ PetscErrorCode MatProductSymbolic(Mat mat)
>  ...
> -PetscCheck(!missing, PetscObjectComm((PetscObject)mat), PETSC_ERR_PLIB, 
> "Unspecified symbolic phase for product %s. Call MatProductSetFromOptions() 
> first", errstr);
> +PetscCheck(!missing, PetscObjectComm((PetscObject)mat), PETSC_ERR_PLIB, 
> "Unspecified symbolic phase for product %s. Call MatProductSetFromOptions() 
> first or the product is not supported", errstr);

I don’t see how this is less confusing.
In fact, to me, error message with conditionals in the sentence but without 
PETSc telling the value of each expression of the conditionals is infuriating.
How do I know if MatProductSetFromOptions() has not been called, or if the 
product is not supported?
This is very difficult to debug, to me, and if it would be possible to catch 
this with two different checks, it would be much better.
But the current design of MatProduct may not allow us to do it, so I will not 
be opposed to such a change.
Maybe add a Boolean à la pc->setupcalled or pc->setfromoptionscalled in the 
MatProduct structure to be able to distinguish better the cause of the failure?

Thanks,
Pierre

> with this fix, I get 
> ./ex27 -f farzad_B_rhs -truncate -solve_augmented
> ...
> [0]PETSC ERROR: Petsc has generated inconsistent data
> [0]PETSC ERROR: Unspecified symbolic phase for product AB with A nest, B 
> nest. Call MatProductSetFromOptions() first or the product is not supported
> 
> If you agree with this fix, I'll create a MR for it.
> Hong
> 
> 
> From: Pierre Jolivet 
> Sent: Tuesday, February 13, 2024 12:08 AM
> To: Zhang, Hong 
> Cc: Hana Honnerová ; petsc-users@mcs.anl.gov 
> 
> Subject: Re: [petsc-users] question on PCLSC with matrix blocks of type 
> MATNEST
>  
> 
> 
>> On 13 Feb 2024, at 12:33 AM, Zhang, Hong  wrote:
>> 
>> Pierre,
>> I just modified the error message of MatProductSymbolic() and added a 
>> testing segment in src/mat/tests/ex195.c. I have not pushed my change yet.
>> 
>> Your fix at 
>> https://gitlab.com/petsc/petsc/-/commit/9dcea022de3b0309e5c16b8c554ad9c85dea29cf?merge_request_iid=7283
>>  is more general. Has this fix merged to release and main? With latest main 
>> and release, I get same previous error message.
> 
> I don’t (anymore, but could prior to my fix).
> The trigger is MatMatMult() with MAT_INITIAL_MATRIX in PCSetUp_LSC().
> Reproducible with:
> diff --git a/src/ksp/ksp/tutorials/ex27.c b/src/ksp/ksp/tutorials/ex27.c
> index 116b7df8522..9bdf4d7334a 100644
> --- a/src/ksp/ksp/tutorials/ex27.c
> +++ b/src/ksp/ksp/tutorials/ex27.c
> @@ -245,2 +245,5 @@ int main(int argc, char **args)
>  PetscCall(MatCreateNest(PETSC_COMM_WORLD, 2, NULL, 2, NULL, array, ));
> +Mat D;
> +PetscCall(MatMatMult(C, C, MAT_INITIAL_MATRIX, PETSC_DECIDE, ));
> +PetscCall(MatDestroy());
>  if (!sbaij) PetscCall(MatNestSetVecType(C, VECNEST));
> Which now generates:
> $ ./ex27 -f ${DATAFILESPATH}/matrices/farzad_B_rhs -truncate -solve_augmented 
> Failed to load RHS, so use a vector of all ones.
> Failed to load initial guess, so use a vector of all zeros.
> [0]PETSC ERROR: - Error Message 
> --
> [0]PETSC ERROR: No support for this operation for this object type
> [0]PETSC ERROR: MatProduct AB not supported for nest and nest
> [0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
> 
> Thanks,
> Pierre
> 
>> Hong
>> 
>> From: Pierre 

Re: [petsc-users] question on PCLSC with matrix blocks of type MATNEST

2024-02-13 Thread Zhang, Hong via petsc-users
Pierre,
I can repeat your change in ex27.c on petsc-release. However, replacing
+Mat D;
+PetscCall(MatMatMult(C, C, MAT_INITIAL_MATRIX, PETSC_DECIDE, ));
+PetscCall(MatDestroy());
with
 PetscCall(MatCreateNest(PETSC_COMM_WORLD, 2, NULL, 2, NULL, array, ));
+Mat D;
+PetscCall(MatProductCreate(C, C, NULL, ));
+PetscCall(MatProductSetType(D, MATPRODUCT_AB));
+PetscCall(MatProductSetFromOptions(D));
+PetscCall(MatProductSymbolic(D));
+PetscCall(MatProductNumeric(D));
+PetscCall(MatDestroy());
./ex27 -f  farzad_B_rhs -truncate -solve_augmented
...
[0]PETSC ERROR: Petsc has generated inconsistent data
[0]PETSC ERROR: Unspecified symbolic phase for product AB with A nest, B nest. 
Call MatProductSetFromOptions() first or the product is not supported
...
[0]PETSC ERROR: #1 MatProductSymbolic() at 
/Users/hongzhang-sun/soft/petsc/src/mat/interface/matproduct.c:807
[0]PETSC ERROR: #2 main() at ex27.c:250

i.e., same confusing error message as reported by Hana, because this calling 
process does not call MatProduct_Private() with your fix. A fix to this is to 
modify the error message in MatProductSymbolic():

--- a/src/mat/interface/matproduct.c
+++ b/src/mat/interface/matproduct.c
@@ -804,7 +804,7 @@ PetscErrorCode MatProductSymbolic(Mat mat)
 ...
-PetscCheck(!missing, PetscObjectComm((PetscObject)mat), PETSC_ERR_PLIB, 
"Unspecified symbolic phase for product %s. Call MatProductSetFromOptions() 
first", errstr);
+PetscCheck(!missing, PetscObjectComm((PetscObject)mat), PETSC_ERR_PLIB, 
"Unspecified symbolic phase for product %s. Call MatProductSetFromOptions() 
first or the product is not supported", errstr);

with this fix, I get
./ex27 -f farzad_B_rhs -truncate -solve_augmented
...
[0]PETSC ERROR: Petsc has generated inconsistent data
[0]PETSC ERROR: Unspecified symbolic phase for product AB with A nest, B nest. 
Call MatProductSetFromOptions() first or the product is not supported

If you agree with this fix, I'll create a MR for it.
Hong



From: Pierre Jolivet 
Sent: Tuesday, February 13, 2024 12:08 AM
To: Zhang, Hong 
Cc: Hana Honnerová ; petsc-users@mcs.anl.gov 

Subject: Re: [petsc-users] question on PCLSC with matrix blocks of type MATNEST



On 13 Feb 2024, at 12:33 AM, Zhang, Hong  wrote:

Pierre,
I just modified the error message of MatProductSymbolic() and added a testing 
segment in src/mat/tests/ex195.c. I have not pushed my change yet.

Your fix at 
https://gitlab.com/petsc/petsc/-/commit/9dcea022de3b0309e5c16b8c554ad9c85dea29cf?merge_request_iid=7283
 is more general. Has this fix merged to release and main? With latest main and 
release, I get same previous error message.

I don’t (anymore, but could prior to my fix).
The trigger is MatMatMult() with MAT_INITIAL_MATRIX in PCSetUp_LSC().
Reproducible with:
diff --git a/src/ksp/ksp/tutorials/ex27.c b/src/ksp/ksp/tutorials/ex27.c
index 116b7df8522..9bdf4d7334a 100644
--- a/src/ksp/ksp/tutorials/ex27.c
+++ b/src/ksp/ksp/tutorials/ex27.c
@@ -245,2 +245,5 @@ int main(int argc, char **args)
 PetscCall(MatCreateNest(PETSC_COMM_WORLD, 2, NULL, 2, NULL, array, ));
+Mat D;
+PetscCall(MatMatMult(C, C, MAT_INITIAL_MATRIX, PETSC_DECIDE, ));
+PetscCall(MatDestroy());
 if (!sbaij) PetscCall(MatNestSetVecType(C, VECNEST));
Which now generates:
$ ./ex27 -f ${DATAFILESPATH}/matrices/farzad_B_rhs -truncate -solve_augmented
Failed to load RHS, so use a vector of all ones.
Failed to load initial guess, so use a vector of all zeros.
[0]PETSC ERROR: - Error Message 
--
[0]PETSC ERROR: No support for this operation for this object type
[0]PETSC ERROR: MatProduct AB not supported for nest and nest
[0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.

Thanks,
Pierre

Hong


From: Pierre Jolivet 
Sent: Sunday, February 11, 2024 7:43 AM
To: Zhang, Hong 
Cc: Hana Honnerová ; petsc-users@mcs.anl.gov 

Subject: Re: [petsc-users] question on PCLSC with matrix blocks of type MATNEST


On 8 Feb 2024, at 5:37 PM, Zhang, Hong via petsc-users 
 wrote:

Hana,
"product AB with A nest, B nest" is not supported by PETSc. I do not know why 
PETSc does not display such an error message. I'll check it.

Did you?
A naive fix is to simply add the missing PetscCheck() in MatProduct_Private() 
right after 
MatProductSetFromOptions()https://petsc.org/release/src/mat/interface/matrix.c.html#line10026
 (notice that it is there line 10048 in the other code branch)
I have this at 
https://gitlab.com/petsc/petsc/-/commit/9dcea022de3b0309e5c16b8c554ad9c85dea29cf?merge_request_iid=7283
 (coupled with code refactoring to avoid missing any other operations), but 
maybe we could do things more elegantly.

Thanks,
Pierre

Hong

From: petsc-users  on behalf of Hana Honnerová 

Sent: Thursday, February 8, 2024 4:45 AM
To: 

Re: [petsc-users] question on PCLSC with matrix blocks of type MATNEST

2024-02-12 Thread Pierre Jolivet


> On 13 Feb 2024, at 12:33 AM, Zhang, Hong  wrote:
> 
> Pierre,
> I just modified the error message of MatProductSymbolic() and added a testing 
> segment in src/mat/tests/ex195.c. I have not pushed my change yet.
> 
> Your fix at 
> https://gitlab.com/petsc/petsc/-/commit/9dcea022de3b0309e5c16b8c554ad9c85dea29cf?merge_request_iid=7283
>  is more general. Has this fix merged to release and main? With latest main 
> and release, I get same previous error message.

I don’t (anymore, but could prior to my fix).
The trigger is MatMatMult() with MAT_INITIAL_MATRIX in PCSetUp_LSC().
Reproducible with:
diff --git a/src/ksp/ksp/tutorials/ex27.c b/src/ksp/ksp/tutorials/ex27.c
index 116b7df8522..9bdf4d7334a 100644
--- a/src/ksp/ksp/tutorials/ex27.c
+++ b/src/ksp/ksp/tutorials/ex27.c
@@ -245,2 +245,5 @@ int main(int argc, char **args)
 PetscCall(MatCreateNest(PETSC_COMM_WORLD, 2, NULL, 2, NULL, array, ));
+Mat D;
+PetscCall(MatMatMult(C, C, MAT_INITIAL_MATRIX, PETSC_DECIDE, ));
+PetscCall(MatDestroy());
 if (!sbaij) PetscCall(MatNestSetVecType(C, VECNEST));
Which now generates:
$ ./ex27 -f ${DATAFILESPATH}/matrices/farzad_B_rhs -truncate -solve_augmented 
Failed to load RHS, so use a vector of all ones.
Failed to load initial guess, so use a vector of all zeros.
[0]PETSC ERROR: - Error Message 
--
[0]PETSC ERROR: No support for this operation for this object type
[0]PETSC ERROR: MatProduct AB not supported for nest and nest
[0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.

Thanks,
Pierre

> Hong
> 
> From: Pierre Jolivet 
> Sent: Sunday, February 11, 2024 7:43 AM
> To: Zhang, Hong 
> Cc: Hana Honnerová ; petsc-users@mcs.anl.gov 
> 
> Subject: Re: [petsc-users] question on PCLSC with matrix blocks of type 
> MATNEST
>  
> 
> On 8 Feb 2024, at 5:37 PM, Zhang, Hong via petsc-users 
>  wrote:
> 
> Hana,
> "product AB with A nest, B nest" is not supported by PETSc. I do not know why 
> PETSc does not display such an error message. I'll check it.
> 
> Did you?
> A naive fix is to simply add the missing PetscCheck() in MatProduct_Private() 
> right after 
> MatProductSetFromOptions()https://petsc.org/release/src/mat/interface/matrix.c.html#line10026
>  (notice that it is there line 10048 in the other code branch)
> I have this at 
> https://gitlab.com/petsc/petsc/-/commit/9dcea022de3b0309e5c16b8c554ad9c85dea29cf?merge_request_iid=7283
>  (coupled with code refactoring to avoid missing any other operations), but 
> maybe we could do things more elegantly.
> 
> Thanks,
> Pierre
> 
> Hong
> From: petsc-users  on behalf of Hana 
> Honnerová 
> Sent: Thursday, February 8, 2024 4:45 AM
> To: petsc-users@mcs.anl.gov 
> Subject: [petsc-users] question on PCLSC with matrix blocks of type MATNEST
>  
> Hi all,
> I am trying to solve linear systems arising from isogeometric discretization 
> (similar to FEM) of the Navier-Stokes equations in parallel using PETSc. The 
> linear systems are of saddle-point type, so I would like to use the 
> PCFIELDSPLIT preconditioner with the -pc_fieldsplit_detect_saddle_point 
> option, Schur complement factorization and the LSC Schur complement 
> preconditioner. I do not provide any user-defined operators for PCLSC in my 
> codes (at least for now).
> I store the matrix as a MATNEST consisting of 4 blocks (F for 
> velocity-velocity part, Bt for velocity-pressure part, B for 
> pressure-velocity part and NULL for pressure-pressure part). It is also 
> convenient for me to store the blocks F, Bt and B as another MATNEST 
> consisting of blocks corresponding to individual velocity components. 
> 
> However, in this setting, I get the following error message:
> [0]PETSC ERROR: Petsc has generated inconsistent data
> [0]PETSC ERROR: Unspecified symbolic phase for product AB with A nest, B 
> nest. Call MatProductSetFromOptions() first
> [0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
> [0]PETSC ERROR: Petsc Release Version 3.20.4, unknown 
> [0]PETSC ERROR: 
> /home/hhornik/gismo/build-petsc-mpi/RelWithDebInfo/bin/gsINSSolverPETScTest 
> on a arch-debug named ThinkPad-T14 by hhornik Thu Feb  8 11:04:17 2024
> [0]PETSC ERROR: Configure options PETSC_ARCH=arch-debug --with-debugging=1 
> --download-mumps --download-scalapack
> [0]PETSC ERROR: #1 MatProductSymbolic() at 
> /home/hhornik/Software/PETSc/src/mat/interface/matproduct.c:807
> [0]PETSC ERROR: #2 MatProduct_Private() at 
> /home/hhornik/Software/PETSc/src/mat/interface/matrix.c:10027
> [0]PETSC ERROR: #3 MatMatMult() at 
> /home/hhornik/Software/PETSc/src/mat/interface/matrix.c:10103
> [0]PETSC ERROR: #4 PCSetUp_LSC() at 
> /home/hhornik/Software/PETSc/src/ksp/pc/impls/lsc/lsc.c:79
> [0]PETSC ERROR: #5 PCSetUp() at 
> /home/hhornik/Software/PETSc/src/ksp/pc/interface/precon.c:1080
> [0]PETSC ERROR: #6 KSPSetUp() at 
> /home/hhornik/Software/PETSc/src/ksp/ksp/interface/itfunc.c:415
> [0]PETSC 

Re: [petsc-users] question on PCLSC with matrix blocks of type MATNEST

2024-02-12 Thread Zhang, Hong via petsc-users
Pierre,
I just modified the error message of MatProductSymbolic() and added a testing 
segment in src/mat/tests/ex195.c. I have not pushed my change yet.

Your fix at 
https://gitlab.com/petsc/petsc/-/commit/9dcea022de3b0309e5c16b8c554ad9c85dea29cf?merge_request_iid=7283
 is more general. Has this fix merged to release and main? With latest main and 
release, I get same previous error message.
Hong


From: Pierre Jolivet 
Sent: Sunday, February 11, 2024 7:43 AM
To: Zhang, Hong 
Cc: Hana Honnerová ; petsc-users@mcs.anl.gov 

Subject: Re: [petsc-users] question on PCLSC with matrix blocks of type MATNEST


On 8 Feb 2024, at 5:37 PM, Zhang, Hong via petsc-users 
 wrote:

Hana,
"product AB with A nest, B nest" is not supported by PETSc. I do not know why 
PETSc does not display such an error message. I'll check it.

Did you?
A naive fix is to simply add the missing PetscCheck() in MatProduct_Private() 
right after MatProductSetFromOptions() 
https://petsc.org/release/src/mat/interface/matrix.c.html#line10026 (notice 
that it is there line 10048 in the other code branch)
I have this at 
https://gitlab.com/petsc/petsc/-/commit/9dcea022de3b0309e5c16b8c554ad9c85dea29cf?merge_request_iid=7283
 (coupled with code refactoring to avoid missing any other operations), but 
maybe we could do things more elegantly.

Thanks,
Pierre

Hong

From: petsc-users  on behalf of Hana Honnerová 

Sent: Thursday, February 8, 2024 4:45 AM
To: petsc-users@mcs.anl.gov 
Subject: [petsc-users] question on PCLSC with matrix blocks of type MATNEST

Hi all,
I am trying to solve linear systems arising from isogeometric discretization 
(similar to FEM) of the Navier-Stokes equations in parallel using PETSc. The 
linear systems are of saddle-point type, so I would like to use the 
PCFIELDSPLIT preconditioner with the -pc_fieldsplit_detect_saddle_point option, 
Schur complement factorization and the LSC Schur complement preconditioner. I 
do not provide any user-defined operators for PCLSC in my codes (at least for 
now).
I store the matrix as a MATNEST consisting of 4 blocks (F for velocity-velocity 
part, Bt for velocity-pressure part, B for pressure-velocity part and NULL for 
pressure-pressure part). It is also convenient for me to store the blocks F, Bt 
and B as another MATNEST consisting of blocks corresponding to individual 
velocity components.

However, in this setting, I get the following error message:
[0]PETSC ERROR: Petsc has generated inconsistent data
[0]PETSC ERROR: Unspecified symbolic phase for product AB with A nest, B nest. 
Call MatProductSetFromOptions() first
[0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
[0]PETSC ERROR: Petsc Release Version 3.20.4, unknown
[0]PETSC ERROR: 
/home/hhornik/gismo/build-petsc-mpi/RelWithDebInfo/bin/gsINSSolverPETScTest on 
a arch-debug named ThinkPad-T14 by hhornik Thu Feb  8 11:04:17 2024
[0]PETSC ERROR: Configure options PETSC_ARCH=arch-debug --with-debugging=1 
--download-mumps --download-scalapack
[0]PETSC ERROR: #1 MatProductSymbolic() at 
/home/hhornik/Software/PETSc/src/mat/interface/matproduct.c:807
[0]PETSC ERROR: #2 MatProduct_Private() at 
/home/hhornik/Software/PETSc/src/mat/interface/matrix.c:10027
[0]PETSC ERROR: #3 MatMatMult() at 
/home/hhornik/Software/PETSc/src/mat/interface/matrix.c:10103
[0]PETSC ERROR: #4 PCSetUp_LSC() at 
/home/hhornik/Software/PETSc/src/ksp/pc/impls/lsc/lsc.c:79
[0]PETSC ERROR: #5 PCSetUp() at 
/home/hhornik/Software/PETSc/src/ksp/pc/interface/precon.c:1080
[0]PETSC ERROR: #6 KSPSetUp() at 
/home/hhornik/Software/PETSc/src/ksp/ksp/interface/itfunc.c:415
[0]PETSC ERROR: #7 KSPSolve_Private() at 
/home/hhornik/Software/PETSc/src/ksp/ksp/interface/itfunc.c:832
[0]PETSC ERROR: #8 KSPSolve() at 
/home/hhornik/Software/PETSc/src/ksp/ksp/interface/itfunc.c:1079
[0]PETSC ERROR: #9 PCApply_FieldSplit_Schur() at 
/home/hhornik/Software/PETSc/src/ksp/pc/impls/fieldsplit/fieldsplit.c:1165
[0]PETSC ERROR: #10 PCApply() at 
/home/hhornik/Software/PETSc/src/ksp/pc/interface/precon.c:498
[0]PETSC ERROR: #11 KSP_PCApply() at 
/home/hhornik/Software/PETSc/include/petsc/private/kspimpl.h:383
[0]PETSC ERROR: #12 KSPFGMRESCycle() at 
/home/hhornik/Software/PETSc/src/ksp/ksp/impls/gmres/fgmres/fgmres.c:123
[0]PETSC ERROR: #13 KSPSolve_FGMRES() at 
/home/hhornik/Software/PETSc/src/ksp/ksp/impls/gmres/fgmres/fgmres.c:235
[0]PETSC ERROR: #14 KSPSolve_Private() at 
/home/hhornik/Software/PETSc/src/ksp/ksp/interface/itfunc.c:906
[0]PETSC ERROR: #15 KSPSolve() at 
/home/hhornik/Software/PETSc/src/ksp/ksp/interface/itfunc.c:1079
[0]PETSC ERROR: #16 applySolver() at 
/home/hhornik/gismo/optional/gsIncompressibleFlow/src/gsINSSolver.hpp:531

I could not find any solution for this so far. My question is: Is it possible 
to use the LSC preconditioner in such case, where the matrix blocks are of type 
MATNEST? And if so, how?
Thank you,
Hana Honnerova



Re: [petsc-users] question on PCLSC with matrix blocks of type MATNEST

2024-02-11 Thread Pierre Jolivet

> On 8 Feb 2024, at 5:37 PM, Zhang, Hong via petsc-users 
>  wrote:
> 
> Hana,
> "product AB with A nest, B nest" is not supported by PETSc. I do not know why 
> PETSc does not display such an error message. I'll check it.

Did you?
A naive fix is to simply add the missing PetscCheck() in MatProduct_Private() 
right after MatProductSetFromOptions() 
https://petsc.org/release/src/mat/interface/matrix.c.html#line10026 (notice 
that it is there line 10048 in the other code branch)
I have this at 
https://gitlab.com/petsc/petsc/-/commit/9dcea022de3b0309e5c16b8c554ad9c85dea29cf?merge_request_iid=7283
 (coupled with code refactoring to avoid missing any other operations), but 
maybe we could do things more elegantly.

Thanks,
Pierre

> Hong
> From: petsc-users  on behalf of Hana 
> Honnerová 
> Sent: Thursday, February 8, 2024 4:45 AM
> To: petsc-users@mcs.anl.gov 
> Subject: [petsc-users] question on PCLSC with matrix blocks of type MATNEST
>  
> Hi all,
> I am trying to solve linear systems arising from isogeometric discretization 
> (similar to FEM) of the Navier-Stokes equations in parallel using PETSc. The 
> linear systems are of saddle-point type, so I would like to use the 
> PCFIELDSPLIT preconditioner with the -pc_fieldsplit_detect_saddle_point 
> option, Schur complement factorization and the LSC Schur complement 
> preconditioner. I do not provide any user-defined operators for PCLSC in my 
> codes (at least for now).
> I store the matrix as a MATNEST consisting of 4 blocks (F for 
> velocity-velocity part, Bt for velocity-pressure part, B for 
> pressure-velocity part and NULL for pressure-pressure part). It is also 
> convenient for me to store the blocks F, Bt and B as another MATNEST 
> consisting of blocks corresponding to individual velocity components. 
> 
> However, in this setting, I get the following error message:
> [0]PETSC ERROR: Petsc has generated inconsistent data
> [0]PETSC ERROR: Unspecified symbolic phase for product AB with A nest, B 
> nest. Call MatProductSetFromOptions() first
> [0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
> [0]PETSC ERROR: Petsc Release Version 3.20.4, unknown 
> [0]PETSC ERROR: 
> /home/hhornik/gismo/build-petsc-mpi/RelWithDebInfo/bin/gsINSSolverPETScTest 
> on a arch-debug named ThinkPad-T14 by hhornik Thu Feb  8 11:04:17 2024
> [0]PETSC ERROR: Configure options PETSC_ARCH=arch-debug --with-debugging=1 
> --download-mumps --download-scalapack
> [0]PETSC ERROR: #1 MatProductSymbolic() at 
> /home/hhornik/Software/PETSc/src/mat/interface/matproduct.c:807
> [0]PETSC ERROR: #2 MatProduct_Private() at 
> /home/hhornik/Software/PETSc/src/mat/interface/matrix.c:10027
> [0]PETSC ERROR: #3 MatMatMult() at 
> /home/hhornik/Software/PETSc/src/mat/interface/matrix.c:10103
> [0]PETSC ERROR: #4 PCSetUp_LSC() at 
> /home/hhornik/Software/PETSc/src/ksp/pc/impls/lsc/lsc.c:79
> [0]PETSC ERROR: #5 PCSetUp() at 
> /home/hhornik/Software/PETSc/src/ksp/pc/interface/precon.c:1080
> [0]PETSC ERROR: #6 KSPSetUp() at 
> /home/hhornik/Software/PETSc/src/ksp/ksp/interface/itfunc.c:415
> [0]PETSC ERROR: #7 KSPSolve_Private() at 
> /home/hhornik/Software/PETSc/src/ksp/ksp/interface/itfunc.c:832
> [0]PETSC ERROR: #8 KSPSolve() at 
> /home/hhornik/Software/PETSc/src/ksp/ksp/interface/itfunc.c:1079
> [0]PETSC ERROR: #9 PCApply_FieldSplit_Schur() at 
> /home/hhornik/Software/PETSc/src/ksp/pc/impls/fieldsplit/fieldsplit.c:1165
> [0]PETSC ERROR: #10 PCApply() at 
> /home/hhornik/Software/PETSc/src/ksp/pc/interface/precon.c:498
> [0]PETSC ERROR: #11 KSP_PCApply() at 
> /home/hhornik/Software/PETSc/include/petsc/private/kspimpl.h:383
> [0]PETSC ERROR: #12 KSPFGMRESCycle() at 
> /home/hhornik/Software/PETSc/src/ksp/ksp/impls/gmres/fgmres/fgmres.c:123
> [0]PETSC ERROR: #13 KSPSolve_FGMRES() at 
> /home/hhornik/Software/PETSc/src/ksp/ksp/impls/gmres/fgmres/fgmres.c:235
> [0]PETSC ERROR: #14 KSPSolve_Private() at 
> /home/hhornik/Software/PETSc/src/ksp/ksp/interface/itfunc.c:906
> [0]PETSC ERROR: #15 KSPSolve() at 
> /home/hhornik/Software/PETSc/src/ksp/ksp/interface/itfunc.c:1079
> [0]PETSC ERROR: #16 applySolver() at 
> /home/hhornik/gismo/optional/gsIncompressibleFlow/src/gsINSSolver.hpp:531
> 
> I could not find any solution for this so far. My question is: Is it possible 
> to use the LSC preconditioner in such case, where the matrix blocks are of 
> type MATNEST? And if so, how?
> Thank you,
> Hana Honnerova



Re: [petsc-users] question on PCLSC with matrix blocks of type MATNEST

2024-02-08 Thread Zhang, Hong via petsc-users
Hana,
"product AB with A nest, B nest" is not supported by PETSc. I do not know why 
PETSc does not display such an error message. I'll check it.
Hong

From: petsc-users  on behalf of Hana Honnerová 

Sent: Thursday, February 8, 2024 4:45 AM
To: petsc-users@mcs.anl.gov 
Subject: [petsc-users] question on PCLSC with matrix blocks of type MATNEST


Hi all,

I am trying to solve linear systems arising from isogeometric discretization 
(similar to FEM) of the Navier-Stokes equations in parallel using PETSc. The 
linear systems are of saddle-point type, so I would like to use the 
PCFIELDSPLIT preconditioner with the -pc_fieldsplit_detect_saddle_point option, 
Schur complement factorization and the LSC Schur complement preconditioner. I 
do not provide any user-defined operators for PCLSC in my codes (at least for 
now).

I store the matrix as a MATNEST consisting of 4 blocks (F for velocity-velocity 
part, Bt for velocity-pressure part, B for pressure-velocity part and NULL for 
pressure-pressure part). It is also convenient for me to store the blocks F, Bt 
and B as another MATNEST consisting of blocks corresponding to individual 
velocity components.

However, in this setting, I get the following error message:

[0]PETSC ERROR: Petsc has generated inconsistent data
[0]PETSC ERROR: Unspecified symbolic phase for product AB with A nest, B nest. 
Call MatProductSetFromOptions() first
[0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
[0]PETSC ERROR: Petsc Release Version 3.20.4, unknown
[0]PETSC ERROR: 
/home/hhornik/gismo/build-petsc-mpi/RelWithDebInfo/bin/gsINSSolverPETScTest on 
a arch-debug named ThinkPad-T14 by hhornik Thu Feb  8 11:04:17 2024
[0]PETSC ERROR: Configure options PETSC_ARCH=arch-debug --with-debugging=1 
--download-mumps --download-scalapack
[0]PETSC ERROR: #1 MatProductSymbolic() at 
/home/hhornik/Software/PETSc/src/mat/interface/matproduct.c:807
[0]PETSC ERROR: #2 MatProduct_Private() at 
/home/hhornik/Software/PETSc/src/mat/interface/matrix.c:10027
[0]PETSC ERROR: #3 MatMatMult() at 
/home/hhornik/Software/PETSc/src/mat/interface/matrix.c:10103
[0]PETSC ERROR: #4 PCSetUp_LSC() at 
/home/hhornik/Software/PETSc/src/ksp/pc/impls/lsc/lsc.c:79
[0]PETSC ERROR: #5 PCSetUp() at 
/home/hhornik/Software/PETSc/src/ksp/pc/interface/precon.c:1080
[0]PETSC ERROR: #6 KSPSetUp() at 
/home/hhornik/Software/PETSc/src/ksp/ksp/interface/itfunc.c:415
[0]PETSC ERROR: #7 KSPSolve_Private() at 
/home/hhornik/Software/PETSc/src/ksp/ksp/interface/itfunc.c:832
[0]PETSC ERROR: #8 KSPSolve() at 
/home/hhornik/Software/PETSc/src/ksp/ksp/interface/itfunc.c:1079
[0]PETSC ERROR: #9 PCApply_FieldSplit_Schur() at 
/home/hhornik/Software/PETSc/src/ksp/pc/impls/fieldsplit/fieldsplit.c:1165
[0]PETSC ERROR: #10 PCApply() at 
/home/hhornik/Software/PETSc/src/ksp/pc/interface/precon.c:498
[0]PETSC ERROR: #11 KSP_PCApply() at 
/home/hhornik/Software/PETSc/include/petsc/private/kspimpl.h:383
[0]PETSC ERROR: #12 KSPFGMRESCycle() at 
/home/hhornik/Software/PETSc/src/ksp/ksp/impls/gmres/fgmres/fgmres.c:123
[0]PETSC ERROR: #13 KSPSolve_FGMRES() at 
/home/hhornik/Software/PETSc/src/ksp/ksp/impls/gmres/fgmres/fgmres.c:235
[0]PETSC ERROR: #14 KSPSolve_Private() at 
/home/hhornik/Software/PETSc/src/ksp/ksp/interface/itfunc.c:906
[0]PETSC ERROR: #15 KSPSolve() at 
/home/hhornik/Software/PETSc/src/ksp/ksp/interface/itfunc.c:1079
[0]PETSC ERROR: #16 applySolver() at 
/home/hhornik/gismo/optional/gsIncompressibleFlow/src/gsINSSolver.hpp:531

I could not find any solution for this so far. My question is: Is it possible 
to use the LSC preconditioner in such case, where the matrix blocks are of type 
MATNEST? And if so, how?

Thank you,
Hana Honnerova