[petsc-users] Unconditional jump or move depends on uninitialised value(s)
Tu, Jiannan
Jiannan_Tu at uml.edu
Wed May 10 12:38:22 CDT 2023
Hi Barry,
Thank you for your advice. I didn't send the function because it is a little bit long. The function is attached.
Your reply reminds me I should need also to check all the other local variables besides vector X (which the error messages give me the impression the array from the vector X is the cause). I'll see what gcc complier options I should use to detect the use of declared variables that are not initialized.
Jiannan
________________________________
From: Barry Smith <bsmith at petsc.dev>
Sent: Tuesday, May 9, 2023 11:16 PM
To: Tu, Jiannan <Jiannan_Tu at uml.edu>
Cc: petsc-users at mcs.anl.gov <petsc-users at mcs.anl.gov>; Zhang, Hong <hongzhang at anl.gov>
Subject: Re: [petsc-users]Unconditional jump or move depends on uninitialised value(s)
CAUTION: This email was sent from outside the UMass Lowell network.
It would have been best to send formfunctions.cpp: since that is where the problem is. Likely you have a local variable (hence the message "stack-allocation") in that function that is not initialized but that you use to fill up the function array values.
Valgrind does not detect all uses of unitialized memory, it only detects them when they would change a flow direction in the code, like in an if () test. This is why the problem pops up in the VecNorm() and not if you just call your function from main(). There are compiler options to detect the use of used declared variables that are not initialized which might help you find the problem at compile time.
Barry
On May 9, 2023, at 10:59 PM, Tu, Jiannan <Jiannan_Tu at uml.edu> wrote:
I am using PETSC SNES to solve a nonlinear equation system resulted from discretization of partial differential equations. When I use Valgrind to check my program, there are lots of errors of ‘Unconditional jump or move depends on uninitialised value(s)’ produced. The errors occur in the function routine set by SNESSetFunction(snes, NULL, formfunctions, ¶ms). Even using only one MPI process such errors occur. It seems solution vector X is not initialized through SNESSolve(). But if the formfunctions() is called directly from main(), there are no errors. I really don’t understand why. Could you please help me identify what is going wrong?
Thank you very much,
Jiannan
-------------------------------------------------
The error message is like the following example
Conditional jump or move depends on uninitialised value(s)
==866758== at 0xA19178C: sqrt (w_sqrt_compat.c:31)
==866758== by 0x4EA9E4C: VecNorm_Seq (bvec2.c:227)
==866758== by 0x4F705C8: VecNorm (rvector.c:228)
==866758== by 0x65D5B16: SNESSolve_NEWTONLS (ls.c:179)
==866758== by 0x673093F: SNESSolve (snes.c:4809)
==866758== by 0x12F607: main (iditm3d.cpp:138)
==866758== Uninitialised value was created by a stack allocation
==866758== at 0x11AC36: functions(Field***, Field***, Field***, int, int, int, int, int, int, AppCtx*, Field***) (formfunctions.cpp:16)
functions() is called within the formfunctions(). The code snippet using SNES solver is
int formfunctions(SNES, Vec, Vec, void *ctx);
int jacobian(SNES, Vec, Mat, Mat, void *ctx);
DMDACreate3d(MPI_COMM_WORLD,DM_BOUNDARY_GHOSTED,DM_BOUNDARY_GHOSTED,DM_BOUNDARY_PERIODIC,
DMDA_STENCIL_STAR,a1,a2,a3,PETSC_DECIDE,PETSC_DECIDE,1,a4,2,NULL,NULL,NULL,&da);
DMSetFromOptions(da);
DMSetUp(da);
DMCreateGlobalVector(da, &X);
VecDuplicate(X, ¶ms.U);
VecDuplicate(X, ¶ms.Xn);
/* set up grids and related geometric parameters. Set up initial solution vector X */
if (initialize(da, X, ¶ms) < 0) exit(-1);
SNES snes;
SNESCreate(MPI_COMM_WORLD, &snes);
SNESSetType(snes, SNESNEWTONLS);
SNESSetFromOptions(snes);
SNESSetDM(snes, da);
SNESSetFunction(snes, NULL, formfunctions, ¶ms);
KSP ksp;
SNESGetKSP(snes, &ksp);
KSPSetType(ksp, KSPFGMRES);
KSPSetFromOptions(ksp);
PC pc;
KSPGetPC(ksp, &pc);
PCSetType(pc, PCJACOBI);
PCSetFromOptions(pc);
Mat A;
DMSetMatrixPreallocateOnly(da, PETSC_FALSE);
DMSetMatType(da, MATMPIAIJ);
DMDASetBlockFills(da, dfill, ofill);
DMCreateMatrix(da, &A);
SNESSetJacobian(snes, A, A, jacobian, ¶ms);
SNESSetSolution(snes, X); //set initial guess of the solution
SNESSolve(snes, PETSC_NULL, X); //iterative solver to find the solution
From: Zhang, Hong<mailto:hongzhang at anl.gov>
Sent: Tuesday, February 21, 2023 11:21 PM
To: Tu, Jiannan<mailto:Jiannan_Tu at uml.edu>
Cc: Barry Smith<mailto:bsmith at petsc.dev>; Hong Zhang<mailto:hong.zhang at aspiritech.org>; Constantinescu, Emil M.<mailto:emconsta at anl.gov>; petsc-users<mailto:petsc-users at mcs.anl.gov>
Subject: Re: [petsc-users] TS failed due to diverged_step_rejected
CAUTION: This email was sent from outside the UMass Lowell network.
On Feb 21, 2023, at 8:54 PM, Tu, Jiannan <Jiannan_Tu at uml.edu<mailto:Jiannan_Tu at uml.edu>> wrote:
CN or BEular doesn’t work. They produce negative densities at the lower boundary even RHS functions are positive. So for TS, all equations must include udot?
You have algebraic constraints only for the boundary points. For all the other points, you must have udot in IFunction. I recommend you to take a look at the example src/ts/tutorials/ex25.c
Hong (Mr.)
Thank you,
Jiannan
From: Zhang, Hong<mailto:hongzhang at anl.gov>
Sent: Monday, February 20, 2023 11:07 AM
To: Tu, Jiannan<mailto:Jiannan_Tu at uml.edu>
Cc: Barry Smith<mailto:bsmith at petsc.dev>; Hong Zhang<mailto:hong.zhang at aspiritech.org>; Constantinescu, Emil M.<mailto:emconsta at anl.gov>; petsc-users<mailto:petsc-users at mcs.anl.gov>
Subject: Re: [petsc-users] TS failed due to diverged_step_rejected
CAUTION: This email was sent from outside the UMass Lowell network.
If you have to include the boundary points, I would suggest starting from a fully implicit solver such as CN or BEuler with a finite-difference approximated Jacobian. When this works for a small scale setting, you can build up more functionalities such as IMEX and analytical Jacobians and extend the problem to a larger scale. But the udot issue needs to be fixed in the first place.
Hong (Mr.)
On Feb 19, 2023, at 9:23 PM, Tu, Jiannan <Jiannan_Tu at uml.edu<mailto:Jiannan_Tu at uml.edu>> wrote:
It is the second order derivative of, say electron temperature = 0 at the boundary.
I am not sure how I can exclude the boundary points because the values of unknowns must be specified at the boundary. Are there any other solvers, e.g., CN, good to solve the equation system?
Thank you,
Jiannan
From: Zhang, Hong<mailto:hongzhang at anl.gov>
Sent: Sunday, February 19, 2023 4:48 PM
To: Tu, Jiannan<mailto:Jiannan_Tu at uml.edu>
Cc: Barry Smith<mailto:bsmith at petsc.dev>; Hong Zhang<mailto:hong.zhang at aspiritech.org>; Constantinescu, Emil M.<mailto:emconsta at anl.gov>; petsc-users<mailto:petsc-users at mcs.anl.gov>
Subject: Re: [petsc-users] TS failed due to diverged_step_rejected
CAUTION: This email was sent from outside the UMass Lowell network.
It is fine to drop udot for the boundary points, but you need to keep udot for all the other points.
In addition, which boundary condition do you use in IFunction? The way you are treating the boundary points actually leads to a system of differential-algebraic equations, which could be difficult to solve with the ARKIMEX solver. Can you try to exclude the boundary points from the computational domain so that you will have just a system of ODEs?
Hong (Mr.)
On Feb 18, 2023, at 4:28 PM, Tu, Jiannan <Jiannan_Tu at uml.edu<mailto:Jiannan_Tu at uml.edu>> wrote:
Thanks for the instruction. This is the boundary condition and there is no udot in the equation. I think this is the way to define IFunction at the boundary. Maybe I’m wrong? Or is there some way to introduce udot into the specification of the equation at the boundary from the aspect of the implementation for TS?
Thank you,
Jiannan
From: Zhang, Hong<mailto:hongzhang at anl.gov>
Sent: Saturday, February 18, 2023 12:40 PM
To: Tu, Jiannan<mailto:Jiannan_Tu at uml.edu>
Cc: Barry Smith<mailto:bsmith at petsc.dev>; Hong Zhang<mailto:hong.zhang at aspiritech.org>; Constantinescu, Emil M.<mailto:emconsta at anl.gov>; petsc-users<mailto:petsc-users at mcs.anl.gov>
Subject: Re: [petsc-users] TS failed due to diverged_step_rejected
You don't often get email from hongzhang at anl.gov<mailto:hongzhang at anl.gov>. Learn why this is important<https://aka.ms/LearnAboutSenderIdentification>
CAUTION: This email was sent from outside the UMass Lowell network.
On Feb 18, 2023, at 8:44 AM, Tu, Jiannan <Jiannan_Tu at uml.edu<mailto:Jiannan_Tu at uml.edu>> wrote:
The RHS function at the bottom boundary is determined by the boundary condition, which is the second order derivative = 0, i.e. G(u) = 2*X[i=1] – X[i=2]. Then in IFunction, F(u, udot) = X[i=0].
This might be the problem. Your F(u, udot) is missing udot according to your description. Take a simple ODE udot = f(u) + g(u) for example. One way to partition this ODE is to define F = udot - f(u) as the IFunction and G = g(u) as the RHSFunction.
Hong (Mr.)
Thank you,
Jiannan
From: Zhang, Hong<mailto:hongzhang at anl.gov>
Sent: Friday, February 17, 2023 11:54 PM
To: Tu, Jiannan<mailto:Jiannan_Tu at uml.edu>
Cc: Barry Smith<mailto:bsmith at petsc.dev>; Hong Zhang<mailto:hong.zhang at aspiritech.org>; Constantinescu, Emil M.<mailto:emconsta at anl.gov>; petsc-users<mailto:petsc-users at mcs.anl.gov>
Subject: Re: [petsc-users] TS failed due to diverged_step_rejected
You don't often get email from hongzhang at anl.gov<mailto:hongzhang at anl.gov>. Learn why this is important<https://aka.ms/LearnAboutSenderIdentification>
CAUTION: This email was sent from outside the UMass Lowell network.
On Feb 17, 2023, at 6:19 PM, Tu, Jiannan <Jiannan_Tu at uml.edu<mailto:Jiannan_Tu at uml.edu>> wrote:
I need to find out what causes negative temperature first. Following is the message with adaptivity turned off. The G(u) gives right-hand equation for electron temperature at bottom boundary. The F(u, u’) function is F(u, u’) = X = G(u) and the jacobian element is d F(u, u’) / dX =1.
This looks strange. Can you elaborate a bit on your partitioned ODE? For example, how are your F(u,udot) (IFunction) and G(u) (RHSFunction) defined?
A good IMEX example can be found at ts/tutorial/advection-diffusion-reaction/ex5.c (and reaction_diffusion.c).
Hong (Mr.)
The solution from TSStep is checked for positivity of densities and temperatures.
>From the message below, it is seen that G(u) > 0 (I added output of right-hand equation for electron temperature). The solution for electron temperature X should be X * jacobian element = G(u) > 0 since jacobian element = 1. I don’t understand why it becomes negative. Is my understanding of TS formula incorrect?
Thank you,
Jiannan
----------------------------------
G(u) = 1.86534e-07
0 SNES Function norm 2.274473072183e+03
1 SNES Function norm 8.641749325070e-04
Nonlinear solve converged due to CONVERGED_FNORM_RELATIVE iterations 1
G(u) = 1.86534e-07
0 SNES Function norm 8.716501970511e-02
1 SNES Function norm 2.213263548813e-04
2 SNES Function norm 2.779985176426e-08
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 2
G(u) = 1.86534e-07
0 SNES Function norm 3.177195995186e-01
1 SNES Function norm 3.607702491344e-04
2 SNES Function norm 4.345809629121e-08
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 2
G(u) = 1.86534e-07
TSAdapt none arkimex 0:3 step 0 accepted t=42960 + 2.189e-02 dt=2.189e-02
electron temperature = -3.6757e-15 at (i, j, k) = (0, 1, 0)
From: Barry Smith<mailto:bsmith at petsc.dev>
Sent: Friday, February 17, 2023 3:45 PM
To: Tu, Jiannan<mailto:Jiannan_Tu at uml.edu>; Hong Zhang<mailto:hong.zhang at aspiritech.org>; Emil Constantinescu<mailto:emconsta at anl.gov>
Cc: petsc-users<mailto:petsc-users at mcs.anl.gov>
Subject: Re: [petsc-users] TS failed due to diverged_step_rejected
CAUTION: This email was sent from outside the UMass Lowell network.
On Feb 17, 2023, at 3:32 PM, Tu, Jiannan <Jiannan_Tu at uml.edu<mailto:Jiannan_Tu at uml.edu>> wrote:
The ts_type arkimex is used. There is right hand-side function RHSFunction set by TSSetRHSFunction() and also stiff function set by TSSetIFunction().
With adaptivity shut off, TS can finish its first time step after the 3rd “Nonlinear solve converged due to …”. The solution gives negative electron and neutral temperatures at the bottom boundary. I need to fix the negative temperatures and see how the code works.
BTW, what is this ts_adapt? Is it by default on?
It is default for some of the TSTypes (in particular, the better ones). It adapts the timestep to ensure some local error estimate is below a certain tolerance. As Matt notes normally as it tries smaller and smaller time steps the local error estimate would get smaller and smaller; this is not happening here, hence the error.
Have you tried with the argument -ts_arkimex_fully_implicit ?
I am not an expert but my guess is something is "odd" about your functions, either the RHSFunction or the Function or both. Do you have a hierarchy of models for your problem? Could you try runs with fewer terms in your functions, that may be producing the difficulties? If you can determine what triggers the problem with the local error estimators, that might help the experts in ODE solution (not me) determine what could be going wrong.
Barry
Thank you,
Jiannan
From: Matthew Knepley<mailto:knepley at gmail.com>
Sent: Friday, February 17, 2023 3:15 PM
To: Tu, Jiannan<mailto:Jiannan_Tu at uml.edu>
Cc: Barry Smith<mailto:bsmith at petsc.dev>; petsc-users<mailto:petsc-users at mcs.anl.gov>
Subject: Re: [petsc-users] TS failed due to diverged_step_rejected
CAUTION: This email was sent from outside the UMass Lowell network.
I am not sure what TS you are using, but the estimate of the local truncation error is 91.4, and does not seem
to change when you make the step smaller, so something is off. You can shut off the adaptivity using
-ts_adapt_type none
Thanks,
Matt
On Fri, Feb 17, 2023 at 3:01 PM Tu, Jiannan <Jiannan_Tu at uml.edu<mailto:Jiannan_Tu at uml.edu>> wrote:
These are what I got with the options you suggested.
Thank you,
Jiannan
-------------------------------------------------------------------------------
0 SNES Function norm 2.274473072186e+03
1 SNES Function norm 1.673091274668e-03
Nonlinear solve converged due to CONVERGED_FNORM_RELATIVE iterations 1
0 SNES Function norm 8.715428433630e-02
1 SNES Function norm 4.995727626692e-04
2 SNES Function norm 5.498018152230e-08
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 2
0 SNES Function norm 3.237461568254e-01
1 SNES Function norm 7.988531005091e-04
2 SNES Function norm 1.280948196292e-07
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 2
TSAdapt basic arkimex 0:3 step 0 rejected t=42960 + 2.189e-02 dt=4.374e-03 wlte= 91.4 wltea= -1 wlter= -1
0 SNES Function norm 2.274473072186e+03
1 SNES Function norm 4.881903203545e-04
Nonlinear solve converged due to CONVERGED_FNORM_RELATIVE iterations 1
0 SNES Function norm 7.562592690785e-02
1 SNES Function norm 1.143078818923e-04
2 SNES Function norm 9.834547907735e-09
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 2
0 SNES Function norm 2.683968949758e-01
1 SNES Function norm 1.838028436639e-04
2 SNES Function norm 9.470813523140e-09
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 2
TSAdapt basic arkimex 0:3 step 0 rejected t=42960 + 4.374e-03 dt=4.374e-04 wlte= 91.4 wltea= -1 wlter= -1
0 SNES Function norm 2.274473072186e+03
1 SNES Function norm 1.821562431175e-04
Nonlinear solve converged due to CONVERGED_FNORM_RELATIVE iterations 1
0 SNES Function norm 1.005443458812e-01
1 SNES Function norm 3.633336946661e-05
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
0 SNES Function norm 1.515368382715e-01
1 SNES Function norm 3.389298316830e-05
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
TSAdapt basic arkimex 0:3 step 0 rejected t=42960 + 4.374e-04 dt=4.374e-05 wlte= 91.4 wltea= -1 wlter= -1
0 SNES Function norm 2.274473072186e+03
1 SNES Function norm 4.541003359206e-05
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
0 SNES Function norm 1.713800906043e-01
1 SNES Function norm 1.179958172167e-05
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
0 SNES Function norm 2.020265094117e-01
1 SNES Function norm 1.513971290464e-05
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
TSAdapt basic arkimex 0:3 step 0 rejected t=42960 + 4.374e-05 dt=4.374e-06 wlte= 91.4 wltea= -1 wlter= -1
0 SNES Function norm 2.274473072186e+03
1 SNES Function norm 6.090269704320e-06
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
0 SNES Function norm 2.136603895703e-01
1 SNES Function norm 1.877474016012e-06
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
0 SNES Function norm 3.127812462507e-01
1 SNES Function norm 2.713146825704e-06
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
TSAdapt basic arkimex 0:3 step 0 rejected t=42960 + 4.374e-06 dt=4.374e-07 wlte= 91.4 wltea= -1 wlter= -1
0 SNES Function norm 2.274473072186e+03
1 SNES Function norm 2.793512213059e-06
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
0 SNES Function norm 2.205196267430e-01
1 SNES Function norm 2.572653773308e-06
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
0 SNES Function norm 3.260057361977e-01
1 SNES Function norm 2.705816087598e-06
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
TSAdapt basic arkimex 0:3 step 0 rejected t=42960 + 4.374e-07 dt=4.374e-08 wlte= 91.4 wltea= -1 wlter= -1
0 SNES Function norm 2.274473072186e+03
1 SNES Function norm 2.764855860446e-05
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
0 SNES Function norm 2.212505522844e-01
1 SNES Function norm 2.958996472386e-05
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
0 SNES Function norm 3.273222034162e-01
1 SNES Function norm 2.994512887620e-05
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
TSAdapt basic arkimex 0:3 step 0 rejected t=42960 + 4.374e-08 dt=4.374e-09 wlte= 91.4 wltea= -1 wlter= -1
0 SNES Function norm 2.274473072186e+03
1 SNES Function norm 3.317240589134e-04
Nonlinear solve converged due to CONVERGED_FNORM_RELATIVE iterations 1
0 SNES Function norm 2.213246532918e-01
1 SNES Function norm 2.799468604767e-04
Nonlinear solve converged due to CONVERGED_SNORM_RELATIVE iterations 1
0 SNES Function norm 3.274570888397e-01
1 SNES Function norm 3.066048050994e-04
Nonlinear solve converged due to CONVERGED_SNORM_RELATIVE iterations 1
TSAdapt basic arkimex 0:3 step 0 rejected t=42960 + 4.374e-09 dt=4.374e-10 wlte= 91.4 wltea= -1 wlter= -1
0 SNES Function norm 2.274473072189e+03
1 SNES Function norm 2.653507278572e-03
Nonlinear solve converged due to CONVERGED_FNORM_RELATIVE iterations 1
0 SNES Function norm 2.213869585841e-01
1 SNES Function norm 2.177156902895e-03
Nonlinear solve converged due to CONVERGED_SNORM_RELATIVE iterations 1
0 SNES Function norm 3.275136370365e-01
1 SNES Function norm 1.962849131557e-03
Nonlinear solve converged due to CONVERGED_SNORM_RELATIVE iterations 1
TSAdapt basic arkimex 0:3 step 0 rejected t=42960 + 4.374e-10 dt=4.374e-11 wlte= 91.4 wltea= -1 wlter= -1
0 SNES Function norm 2.274473072218e+03
1 SNES Function norm 5.664907315679e-03
Nonlinear solve converged due to CONVERGED_FNORM_RELATIVE iterations 1
0 SNES Function norm 2.223208399368e-01
1 SNES Function norm 5.688863091415e-03
Nonlinear solve converged due to CONVERGED_SNORM_RELATIVE iterations 1
0 SNES Function norm 3.287121218919e-01
1 SNES Function norm 4.085338521320e-03
Nonlinear solve converged due to CONVERGED_SNORM_RELATIVE iterations 1
TSAdapt basic arkimex 0:3 step 0 rejected t=42960 + 4.374e-11 dt=4.374e-12 wlte= 91.4 wltea= -1 wlter= -1
0 SNES Function norm 2.274473071968e+03
1 SNES Function norm 4.694691905235e-04
Nonlinear solve converged due to CONVERGED_FNORM_RELATIVE iterations 1
0 SNES Function norm 2.211786508657e-01
1 SNES Function norm 1.503497433939e-04
Nonlinear solve converged due to CONVERGED_SNORM_RELATIVE iterations 1
0 SNES Function norm 3.272667798977e-01
1 SNES Function norm 2.176132327279e-04
Nonlinear solve converged due to CONVERGED_SNORM_RELATIVE iterations 1
TSAdapt basic arkimex 0:3 step 0 rejected t=42960 + 4.374e-12 dt=4.374e-13 wlte= 91.4 wltea= -1 wlter= -1
[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
[0]PETSC ERROR:
[0]PETSC ERROR: TSStep has failed due to DIVERGED_STEP_REJECTED
[0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
[0]PETSC ERROR: Petsc Release Version 3.16.6, Mar 30, 2022
[0]PETSC ERROR: ./iditm3d on a named office by jtu Fri Feb 17 14:54:22 2023
[0]PETSC ERROR: Configure options --prefix=/usr/local --with-mpi-dir=/usr/local --with-fc=0 --with-openmp --with-hdf5-dir=/usr/local --download-f2cblaslapack=1
[0]PETSC ERROR: #1 TSStep() at /home/jtu/Downloads/petsc-3.16.6/src/ts/interface/ts.c:3583
From: Barry Smith<mailto:bsmith at petsc.dev>
Sent: Friday, February 17, 2023 12:58 PM
To: Tu, Jiannan<mailto:Jiannan_Tu at uml.edu>
Cc: petsc-users<mailto:petsc-users at mcs.anl.gov>
Subject: Re: [petsc-users] TS failed due to diverged_step_rejected
CAUTION: This email was sent from outside the UMass Lowell network.
Can you please run with also the options -ts_monitor -ts_adapt_monitor ?
The output is confusing because it prints that the Nonlinear solve has converged but then TSStep has failed due to DIVERGED_STEP_REJECTED which seems contradictory
On Feb 17, 2023, at 12:09 PM, Tu, Jiannan <Jiannan_Tu at uml.edu<mailto:Jiannan_Tu at uml.edu>> wrote:
My code uses TS to solve a set of multi-fluid MHD equations. The jacobian is provided with function F(t, u, u'). Both linear and nonlinear solvers converge but snes repeats itself until gets "TSStep has failed due to diverged_step_rejected."
Is it because I used TSStep rather than TSSolve? I have checked the condition number. The condition number with pc_type asm is about 1 (without precondition it is about 4x10^4). The maximum ratio of off-diagonal jacobian element over diagonal element is about 21.
Could you help me to identify what is going wrong?
Thank you very much!
Jiannan
---------------------------------------------------------------------------------------------------
Run command with options
mpiexec -n $1 ./iditm3d -ts_type arkimex -snes_tyep ngmres -ksp_type gmres -pc_type asm \
-ts_rtol 1.0e-4 -ts_atol 1.0e-4 -snes_monitor -snes_rtol 1.0e-4 -snes_atol 1.0e-4 \
-snes_converged_reason
The output message is
Start time advancing ...
0 SNES Function norm 2.274473072186e+03
1 SNES Function norm 1.673091274668e-03
Nonlinear solve converged due to CONVERGED_FNORM_RELATIVE iterations 1
0 SNES Function norm 8.715428433630e-02
1 SNES Function norm 4.995727626692e-04
2 SNES Function norm 5.498018152230e-08
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 2
0 SNES Function norm 3.237461568254e-01
1 SNES Function norm 7.988531005091e-04
2 SNES Function norm 1.280948196292e-07
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 2
0 SNES Function norm 2.274473072186e+03
1 SNES Function norm 4.881903203545e-04
Nonlinear solve converged due to CONVERGED_FNORM_RELATIVE iterations 1
0 SNES Function norm 7.562592690785e-02
1 SNES Function norm 1.143078818923e-04
2 SNES Function norm 9.834547907735e-09
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 2
0 SNES Function norm 2.683968949758e-01
1 SNES Function norm 1.838028436639e-04
2 SNES Function norm 9.470813523140e-09
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 2
0 SNES Function norm 2.274473072186e+03
1 SNES Function norm 1.821562431175e-04
Nonlinear solve converged due to CONVERGED_FNORM_RELATIVE iterations 1
0 SNES Function norm 1.005443458812e-01
1 SNES Function norm 3.633336946661e-05
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
0 SNES Function norm 1.515368382715e-01
1 SNES Function norm 3.389298316830e-05
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
0 SNES Function norm 2.274473072186e+03
1 SNES Function norm 4.541003359206e-05
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
0 SNES Function norm 1.713800906043e-01
1 SNES Function norm 1.179958172167e-05
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
0 SNES Function norm 2.020265094117e-01
1 SNES Function norm 1.513971290464e-05
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
0 SNES Function norm 2.274473072186e+03
1 SNES Function norm 6.090269704320e-06
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
0 SNES Function norm 2.136603895703e-01
1 SNES Function norm 1.877474016012e-06
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
0 SNES Function norm 3.127812462507e-01
1 SNES Function norm 2.713146825704e-06
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
0 SNES Function norm 2.274473072186e+03
1 SNES Function norm 2.793512213059e-06
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
0 SNES Function norm 2.205196267430e-01
1 SNES Function norm 2.572653773308e-06
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
0 SNES Function norm 3.260057361977e-01
1 SNES Function norm 2.705816087598e-06
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
0 SNES Function norm 2.274473072186e+03
1 SNES Function norm 2.764855860446e-05
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
0 SNES Function norm 2.212505522844e-01
1 SNES Function norm 2.958996472386e-05
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
0 SNES Function norm 3.273222034162e-01
1 SNES Function norm 2.994512887620e-05
Nonlinear solve converged due to CONVERGED_FNORM_ABS iterations 1
0 SNES Function norm 2.274473072186e+03
1 SNES Function norm 3.317240589134e-04
Nonlinear solve converged due to CONVERGED_FNORM_RELATIVE iterations 1
0 SNES Function norm 2.213246532918e-01
1 SNES Function norm 2.799468604767e-04
Nonlinear solve converged due to CONVERGED_SNORM_RELATIVE iterations 1
0 SNES Function norm 3.274570888397e-01
1 SNES Function norm 3.066048050994e-04
Nonlinear solve converged due to CONVERGED_SNORM_RELATIVE iterations 1
0 SNES Function norm 2.274473072189e+03
1 SNES Function norm 2.653507278572e-03
Nonlinear solve converged due to CONVERGED_FNORM_RELATIVE iterations 1
0 SNES Function norm 2.213869585841e-01
1 SNES Function norm 2.177156902895e-03
Nonlinear solve converged due to CONVERGED_SNORM_RELATIVE iterations 1
0 SNES Function norm 3.275136370365e-01
1 SNES Function norm 1.962849131557e-03
Nonlinear solve converged due to CONVERGED_SNORM_RELATIVE iterations 1
0 SNES Function norm 2.274473072218e+03
1 SNES Function norm 5.664907315679e-03
Nonlinear solve converged due to CONVERGED_FNORM_RELATIVE iterations 1
0 SNES Function norm 2.223208399368e-01
1 SNES Function norm 5.688863091415e-03
Nonlinear solve converged due to CONVERGED_SNORM_RELATIVE iterations 1
0 SNES Function norm 3.287121218919e-01
1 SNES Function norm 4.085338521320e-03
Nonlinear solve converged due to CONVERGED_SNORM_RELATIVE iterations 1
0 SNES Function norm 2.274473071968e+03
1 SNES Function norm 4.694691905235e-04
Nonlinear solve converged due to CONVERGED_FNORM_RELATIVE iterations 1
0 SNES Function norm 2.211786508657e-01
1 SNES Function norm 1.503497433939e-04
Nonlinear solve converged due to CONVERGED_SNORM_RELATIVE iterations 1
0 SNES Function norm 3.272667798977e-01
1 SNES Function norm 2.176132327279e-04
Nonlinear solve converged due to CONVERGED_SNORM_RELATIVE iterations 1
[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------
[0]PETSC ERROR:
[0]PETSC ERROR: TSStep has failed due to DIVERGED_STEP_REJECTED
[0]PETSC ERROR: See https://petsc.org/release/faq/ for trouble shooting.
[0]PETSC ERROR: Petsc Release Version 3.16.6, Mar 30, 2022
[0]PETSC ERROR: ./iditm3d on a named office by jtu Fri Feb 17 11:59:43 2023
[0]PETSC ERROR: Configure options --prefix=/usr/local --with-mpi-dir=/usr/local --with-fc=0 --with-openmp --with-hdf5-dir=/usr/local --download-f2cblaslapack=1
[0]PETSC ERROR: #1 TSStep() at /home/jtu/Downloads/petsc-3.16.6/src/ts/interface/ts.c:3583
--
What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener
https://www.cse.buffalo.edu/~knepley/<http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20230510/c0fc4668/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: formfunctions.cpp
Type: text/x-c++src
Size: 37248 bytes
Desc: formfunctions.cpp
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20230510/c0fc4668/attachment-0001.bin>
More information about the petsc-users
mailing list