Alternative of exit(-1)

For developers writing C++, Fortran, Java, code who have questions or comments to make.

Moderators: silvia, selimgunay, Moderators

Post Reply
maksins
Posts: 32
Joined: Sun Jun 19, 2011 10:28 am
Location: University at Buffalo

Alternative of exit(-1)

Post by maksins »

For some elements in OpenSees (bearing elements), when the failure is encountered, the program crashes due to command exit(-1). This is fine for a single analysis, but when I am running multiple analysis in a loop, it creates me prolem. I was wondering if there's an alternative of exit(-1) command I could use in my element code, so that it stops the analysis without crashing OpenSees.exe and move on to the next analysis in the loop?
Manish Kumar
Department of Civil, Structural and Environmental Engineering
University at Buffalo, The State University of New York

http://www.manishkumar.org
fmk
Site Admin
Posts: 5884
Joined: Fri Jun 11, 2004 2:33 pm
Location: UC Berkeley
Contact:

Re: Alternative of exit(-1)

Post by fmk »

if the method is non-void return an error (a negative integer), if void, use a static variable to keep track of possible errors with the void methods and in an update or some method that will be called later during the analysis, return an error if the static variable has been set (resetting the variable before you actually return the error).
maksins
Posts: 32
Joined: Sun Jun 19, 2011 10:28 am
Location: University at Buffalo

Re: Alternative of exit(-1)

Post by maksins »

Thanks Frank,
I did what you suggested and I am able to proceed with my analysis. However, I was wondering if there was a way to return a specific error value, for example -7, to know if it fails due to buckling and not due to other solution algorithm convergence problems? Also, then I won't have to check with modified Newton Raphson with initial stiffness for convergence and I can directly get out of the loop.
I am using the following in my .cpp file to return a negative value:
[code]
if (tag==1) {
tag=0;
return -1; //return any negative integer
}
else {
return 0;
}
[/code]

And my analysis abort with following messages:

OpenSees > source call.tcl
ElastomericX element - Written by Manish Kumar, University at Buffalo, 2012
Gravity analysis completed SUCCESSFULLY
Domain::update - domain failed in update
Newmark::update() - failed to update the domain
WARNING NewtonRaphson::solveCurrentStep() -the Integrator failed in update()
DirectIntegrationAnalysis::analyze() - the Algorithm failed at time 2.73
OpenSees > analyze failed, returned: -3 error flag
regular newton failed .. lets try an initial stiffness for this step
Domain::update - domain failed in update
Newmark::update() - failed to update the domain
WARNING ModifiedNewton::solveCurrentStep() -the Integrator failed in update()
DirectIntegrationAnalysis::analyze() - the Algorithm failed at time 2.73
OpenSees > analyze failed, returned: -3 error flag
Transient analysis 1 completed FAILED with error code -3
OpenSees>

Can I return custom error values using TCL_Error? I don't know what files I will need to inherit for that in my .h and .cpp files. Right now, I can not use it.
Manish Kumar
Department of Civil, Structural and Environmental Engineering
University at Buffalo, The State University of New York

http://www.manishkumar.org
Post Reply