[petsc-users] PetscOptionsSetValue syntax

Karthikeyan Chockalingam - STFC UKRI karthikeyan.chockalingam at stfc.ac.uk
Fri Nov 18 08:03:56 CST 2022


Thank you. It worked!

Best,
Karthik.

From: Pierre Jolivet <pierre at joliv.et>
Date: Friday, 18 November 2022 at 13:56
To: Chockalingam, Karthikeyan (STFC,DL,HC) <karthikeyan.chockalingam at stfc.ac.uk>
Cc: petsc-users at mcs.anl.gov <petsc-users at mcs.anl.gov>
Subject: Re: [petsc-users] PetscOptionsSetValue syntax



On 18 Nov 2022, at 2:47 PM, Karthikeyan Chockalingam - STFC UKRI <karthikeyan.chockalingam at stfc.ac.uk> wrote:

Thank you. I added

    ierr = KSPSetFromOptions(ksp); CHKERRQ(ierr);

before PetscOptionsSetValue but still I don’t see the ksp iterations or any other info flags I set.
I am not passing anything via the command line and believe PetscOptionsSetValue would set the flags.

If you call KSPSetFromOptions() before you set any options, there is nothing to set.
Usually, you want to delay calling that function up until you are done setting options.

Thanks,
Pierre


Best,
Karthik.


From: Pierre Jolivet <pierre at joliv.et>
Date: Friday, 18 November 2022 at 13:36
To: Chockalingam, Karthikeyan (STFC,DL,HC) <karthikeyan.chockalingam at stfc.ac.uk>
Cc: petsc-users at mcs.anl.gov <petsc-users at mcs.anl.gov>
Subject: Re: [petsc-users] PetscOptionsSetValue syntax


On 18 Nov 2022, at 2:32 PM, Karthikeyan Chockalingam - STFC UKRI via petsc-users <petsc-users at mcs.anl.gov> wrote:

Hello,

I would like to move from code to using options.

   KSP           ksp;
    PC            pc;
    KSPCreate(PETSC_COMM_WORLD, &ksp);
    KSPSetOperators(ksp, A, A);

I tried using PetscOptionsSetValue as below


    ierr = PetscOptionsSetValue(NULL,"-ksp_type", "cg"); CHKERRQ(ierr);

    ierr = PetscOptionsSetValue(NULL,"-pc_type", "jacobi"); CHKERRQ(ierr);

    ierr = PetscOptionsSetValue(NULL, "-ksp_monitor", NULL);CHKERRQ(ierr);

    ierr = PetscOptionsSetValue(NULL, "-ksp_view", NULL);CHKERRQ(ierr);

    ierr = PetscOptionsSetValue(NULL, "-ksp_monitor_true_residual", NULL);CHKERRQ(ierr);

    ierr = PetscOptionsSetValue(NULL, "-ksp_converged_reason", NULL);CHKERRQ(ierr);



    KSPSolve(ksp, b, x);

But I believe none of the string flags where picked up by PETSc. What am I missing?

KSPSetFromOptions()

Thanks,
Pierre



Thank you for your help.

Kind regards,
Karthik.

This email and any attachments are intended solely for the use of the named recipients. If you are not the intended recipient you must not use, disclose, copy or distribute this email or any of its attachments and should notify the sender immediately and delete this email from your system. UK Research and Innovation (UKRI) has taken every reasonable precaution to minimise risk of this email or any attachments containing viruses or malware but the recipient should carry out its own virus and malware checks before opening the attachments. UKRI does not accept any liability for any losses or damages which the recipient may sustain due to presence of any viruses.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20221118/0dfe3869/attachment.html>


More information about the petsc-users mailing list