57 #include <ac/unistd.h>
64 #include "ac/sys_sysinfo.h"
84 #include "ac/lapack.h"
85 #include "ac/arpack.h"
105 MBDYN_KEEP_GOING = 0,
106 MBDYN_STOP_AT_END_OF_TIME_STEP = 1,
107 MBDYN_STOP_AT_END_OF_ITERATION = 2,
112 volatile sig_atomic_t mbdyn_keep_going = MBDYN_KEEP_GOING;
113 #if defined(__FreeBSD__)
114 __sighandler_t *mbdyn_sh_term = SIG_DFL;
115 __sighandler_t *mbdyn_sh_int = SIG_DFL;
116 __sighandler_t *mbdyn_sh_hup = SIG_DFL;
117 __sighandler_t *mbdyn_sh_pipe = SIG_DFL;
118 #else // !defined(__FreeBSD__)
119 __sighandler_t mbdyn_sh_term = SIG_DFL;
120 __sighandler_t mbdyn_sh_int = SIG_DFL;
121 __sighandler_t mbdyn_sh_hup = SIG_DFL;
122 __sighandler_t mbdyn_sh_pipe = SIG_DFL;
123 #endif // !defined(__FreeBSD__)
126 mbdyn_really_exit_handler(
int signum)
128 ::mbdyn_keep_going = MBDYN_STOP_NOW;
131 signal(signum, ::mbdyn_sh_term);
135 signal(signum, ::mbdyn_sh_int);
140 signal(signum, ::mbdyn_sh_hup);
146 signal(signum, ::mbdyn_sh_pipe);
157 mbdyn_modify_last_iteration_handler(
int signum)
159 ::mbdyn_keep_going = MBDYN_STOP_AT_END_OF_ITERATION;
160 signal(signum, mbdyn_really_exit_handler);
164 mbdyn_modify_final_time_handler(
int signum)
166 ::mbdyn_keep_going = MBDYN_STOP_AT_END_OF_TIME_STEP;
167 signal(signum, mbdyn_modify_last_iteration_handler);
175 return ::mbdyn_keep_going >= MBDYN_STOP_AT_END_OF_ITERATION;
176 #else // ! HAVE_SIGNAL
178 #endif // ! HAVE_SIGNAL
185 return ::mbdyn_keep_going >= MBDYN_STOP_AT_END_OF_TIME_STEP;
186 #else // ! HAVE_SIGNAL
188 #endif // ! HAVE_SIGNAL
195 ::mbdyn_keep_going = MBDYN_STOP_AT_END_OF_ITERATION;
196 #endif // HAVE_SIGNAL
203 ::mbdyn_keep_going = MBDYN_STOP_AT_END_OF_TIME_STEP;
204 #endif // HAVE_SIGNAL
211 #if defined(__FreeBSD__)
213 #else // ! defined(__FreeBSD__)
215 #endif // ! defined(__FreeBSD__)
218 hdl = mbdyn_really_exit_handler;
221 hdl = mbdyn_modify_final_time_handler;
227 ::mbdyn_sh_term = signal(SIGTERM, hdl);
228 if (::mbdyn_sh_term == SIG_IGN) {
229 signal(SIGTERM, SIG_IGN);
232 ::mbdyn_sh_int = signal(SIGINT, hdl);
233 if (::mbdyn_sh_int == SIG_IGN) {
234 signal(SIGINT, SIG_IGN);
238 ::mbdyn_sh_hup = signal(SIGHUP, hdl);
239 if (::mbdyn_sh_hup == SIG_IGN) {
240 signal(SIGHUP, SIG_IGN);
245 ::mbdyn_sh_pipe = signal(SIGPIPE, hdl);
246 if (::mbdyn_sh_pipe == SIG_IGN) {
247 signal(SIGPIPE, SIG_IGN);
259 memset(buf, 0, size*
sizeof(
int));
261 for (
unsigned long i = 0; i < size; i++) {
267 return mlockall(MCL_CURRENT | MCL_FUTURE);
275 const std::string& sInFName,
276 const std::string& sOutFName,
277 unsigned int nThreads,
280 #ifdef USE_MULTITHREAD
290 sInputFileName(sInFName),
291 sOutputFileName(sOutFName),
296 iNumPreviousVectors(2),
306 dInitialTimeStep(1.),
307 dMaxResidual(std::numeric_limits<
doublereal>::max()),
308 dMaxResidualDiff(std::numeric_limits<
doublereal>::max()),
309 eTimeStepLimit(TS_SOFT_LIMIT),
312 eAbortAfter(AFTER_UNKNOWN),
313 RegularType(INT_UNKNOWN),
314 DummyType(INT_UNKNOWN),
318 pFirstRegularStep(0),
320 pCurrStepIntegrator(0),
322 pRhoAlgebraicRegular(0),
324 pRhoAlgebraicDummy(0),
330 bTrueNewtonRaphson(
true),
332 iIterationsBeforeAssembly(0),
360 eStatus(SOLVER_STATUS_UNINITIALIZED),
361 bOutputCounter(
false),
362 outputCounterPrefix(),
363 outputCounterPostfix(),
366 dTest(std::numeric_limits<double>::max()),
367 dSolTest(std::numeric_limits<double>::max()),
374 ASSERT(!sInFName.empty());
377 #ifdef USE_MULTITHREAD
379 Solver::ThreadPrepare(
void)
386 silent_cout(
"no multithread requested "
387 "with a potential of " << n
388 <<
" CPUs" << std::endl);
405 silent_cerr(
"Prepare() must be called first" << std::endl);
414 #ifdef USE_MULTITHREAD
423 int mpi_finalize = 0;
447 #ifdef USE_MULTITHREAD
454 #if defined(USE_UMFPACK)
457 #elif defined(USE_Y12)
464 silent_cerr(
"unable to select a CC-capable solver"
471 silent_cout(
"Creating multithread solver "
472 "with " << nThreads <<
" threads "
479 MultiThreadDataManager,
480 MultiThreadDataManager(
HP,
495 silent_cout(
"Creating scalar solver "
515 log <<
"Symbol table:" << std::endl;
520 log <<
"Environment:" << std::endl;
521 for (
int i = 0;
environ[i] != NULL; i++) {
522 log <<
" " <<
environ[i] << std::endl;
524 #endif // HAVE_ENVIRON
543 Out <<
"End of Input; no simulation or assembly is required."
550 Out <<
"End of Initial Assembly; no simulation is required."
605 iUnkStates = (iRUnkStates < iFUnkStates) ? iFUnkStates : iRUnkStates;
619 pdWorkSpace+((iNumPreviousVectors)+ivec)*iNumDofs));
685 pResTest = pResTestScale;
766 bind2nd(std::greater<doublereal>(),
dTime));
833 silent_cout(std::endl);
843 silent_cerr(
"Initial derivatives calculation " <<
iStIter
844 <<
" does not converge; aborting..." << std::endl
845 <<
"(hint: try playing with the \"derivatives coefficient\" value)" << std::endl);
861 silent_cerr(
"Initial derivatives failed because no pivot element "
862 "could be found for column " << err.
iCol
864 "aborting..." << std::endl);
871 silent_cerr(
"Simulation ended during the derivatives steps:\n" << eos.
what() <<
"\n");
885 Out <<
"# Derivatives solution step at time " <<
dInitialTime
887 <<
" iterations with " <<
dTest
888 <<
" error" << std::endl;
891 DEBUGCOUT(
"Derivatives solution step has been performed successfully"
892 " in " <<
iStIter <<
" iterations" << std::endl);
897 External::SendInitial();
908 Out <<
"End of derivatives; no simulation is required."
917 Out <<
"Interrupted during derivatives computation." << std::endl;
979 silent_cerr(
"First dummy step does not converge; "
981 <<
" cannot be reduced further; "
982 "aborting..." << std::endl);
998 silent_cerr(
"First dummy step failed because no pivot element "
999 "could be found for column " << err.
iCol
1001 "aborting..." << std::endl);
1008 silent_cerr(
"Simulation ended during the first dummy step:\n"
1009 << eos.
what() <<
"\n");
1030 #ifdef DEBUG_FICTITIOUS
1033 Out <<
"Interrupted during first dummy step." << std::endl;
1037 #ifdef DEBUG_FICTITIOUS
1047 for (
int iSubStep = 2;
1076 silent_cerr(
"Dummy step " << iSubStep
1077 <<
" does not converge; "
1079 <<
" cannot be reduced further; "
1080 "aborting..." << std::endl);
1097 silent_cerr(
"Dummy step " << iSubStep
1098 <<
" failed because no pivot element "
1099 "could be found for column " << err.
iCol
1101 "aborting..." << std::endl);
1108 silent_cerr(
"Simulation ended during the dummy steps:\n"
1109 << eos.
what() <<
"\n");
1121 Out <<
"Step " <<
lStep
1125 <<
" error " <<
dTest << std::endl;
1130 <<
" of step " <<
lStep
1131 <<
" has been successfully completed "
1132 "in " <<
iStIter <<
" iterations"
1137 #ifdef DEBUG_FICTITIOUS
1140 Out <<
"Interrupted during dummy steps."
1148 Out <<
"# Initial solution after dummy steps "
1150 <<
" performed in " <<
iStIter
1151 <<
" iterations with " <<
dTest
1152 <<
" error" << std::endl;
1156 "Dummy steps have been successfully completed "
1157 "in " <<
iStIter <<
" iterations" << std::endl);
1160 External::SendInitial();
1169 <<
"# Key for lines starting with \"Step\":"
1171 <<
"# Step Time TStep NIter ResErr SolErr SolConv Out"
1186 Out <<
"End of dummy steps; no simulation is required."
1192 Out <<
"Interrupted during dummy steps." << std::endl;
1208 silent_cerr(
"Start() must be called after Prepare()" << std::endl);
1216 pNLS->SetExternal(External::REGULAR);
1221 DEBUGCOUT(
"Step " <<
lStep <<
" has been successfully completed "
1222 "in " <<
iStIter <<
" iterations" << std::endl);
1241 IfFirstStepIsToBeRepeated:
1246 silent_cout(std::endl);
1263 " from " << dOldCurrTimeStep
1265 <<
" during first step after "
1268 goto IfFirstStepIsToBeRepeated;
1272 silent_cerr(
"Max iterations number "
1274 <<
" has been reached during "
1275 "first step, Time=" <<
dTime <<
"; "
1277 <<
" cannot be reduced further; "
1278 "aborting..." << std::endl);
1296 silent_cerr(
"First step failed because no pivot element "
1297 "could be found for column " << err.
iCol
1299 "aborting..." << std::endl);
1306 silent_cerr(
"Simulation ended during the first regular step:\n"
1307 << eos.
what() <<
"\n");
1321 Out <<
"Interrupted during first step." << std::endl;
1350 std::vector<doublereal>::iterator i = std::find_if(
EigAn.
Analyses.begin(),
1382 silent_cerr(
"Started() must be called first" << std::endl);
1393 <<
"End of simulation at time "
1394 <<
dTime <<
" after "
1395 <<
lStep <<
" steps;" << std::endl
1397 <<
"total iterations: " <<
iTotIter << std::endl
1399 <<
"total error: " <<
dTotErr << std::endl);
1409 <<
"Simulation is stopped by RTAI task" << std::endl
1410 <<
"Simulation ended at time "
1411 <<
dTime <<
" after "
1412 <<
lStep <<
" steps;" << std::endl
1413 <<
"total iterations: " <<
iTotIter << std::endl
1415 <<
"total error: " <<
dTotErr << std::endl);
1421 || (MPI_Finalized(&mpi_finalize), mpi_finalize)
1430 <<
"Interrupted!" << std::endl
1431 <<
"Simulation ended at time "
1432 <<
dTime <<
" after "
1433 <<
lStep <<
" steps;" << std::endl
1434 <<
"total iterations: " <<
iTotIter << std::endl
1436 <<
"total error: " <<
dTotErr << std::endl);
1455 IfStepIsToBeRepeated:
1461 silent_cout(std::endl);
1478 " from " << dOldCurrTimeStep
1481 <<
lStep <<
" after "
1484 goto IfStepIsToBeRepeated;
1489 <<
"Max iterations number "
1491 <<
" has been reached during "
1492 "Step=" <<
lStep <<
", "
1495 <<
" cannot be reduced further; "
1496 "aborting..." << std::endl);
1507 " from " << dOldCurrTimeStep
1510 <<
lStep <<
" after "
1513 goto IfStepIsToBeRepeated;
1518 <<
"Simulation diverged after "
1519 <<
iStIter <<
" iterations, before "
1520 "reaching max iteration number "
1522 <<
" during Step=" <<
lStep <<
", "
1525 <<
" cannot be reduced further; "
1526 "aborting..." << std::endl);
1535 <<
"Simulation failed because no pivot element "
1536 "could be found for column " << err.
iCol
1538 "after " <<
iStIter <<
" iterations "
1539 "during step " <<
lStep <<
"; "
1540 "aborting..." << std::endl);
1548 <<
"Simulation ended during a regular step:\n"
1549 << eos.
what() <<
"\n");
1557 silent_cout(
"Simulation ended at time "
1558 <<
dTime <<
" after "
1559 <<
lStep <<
" steps;" << std::endl
1560 <<
"total iterations: " <<
iTotIter << std::endl
1562 <<
"total error: " <<
dTotErr << std::endl);
1580 Out <<
"Step " <<
lStep
1592 silent_cout(
"Step " << std::setw(5) <<
lStep
1595 <<
" " << std::setw(4) <<
iStIter
1596 <<
" " << std::setw(13) <<
dTest
1597 <<
" " << std::setw(13) <<
dSolTest
1604 <<
" has been successfully completed "
1605 "in " <<
iStIter <<
" iterations" << std::endl);
1616 std::vector<doublereal>::iterator i = std::find_if(
EigAn.
Analyses.begin(),
1653 if (
qX[ivec] != 0) {
1720 out <<
"begin: initial value;" << std::endl;
1723 out <<
" # initial time: " <<
pDM->
dGetTime() <<
";"
1733 out <<
" initial time: " <<
pDM->
dGetTime()<<
";" << std::endl
1734 <<
" final time: " <<
dFinalTime <<
";" << std::endl
1745 out <<
"Crank Nicolson; " << std::endl;
1759 out <<
"thirdorder, ";
1761 out <<
"ad hoc;" << std::endl;
1766 out <<
"implicit euler;" << std::endl;
1773 out <<
" max iterations: " << std::abs(iMI);
1774 if (iMI < 0) out <<
", at most";
1780 out <<
", test, norm" ;
1783 out <<
", test, minmax" ;
1788 silent_cerr(
"unhandled nonlinear solver test type" << std::endl);
1799 out <<
", test, norm" ;
1802 out <<
", test, minmax" ;
1810 <<
";" << std::endl;
1829 out <<
" # nonlinear solver: matrix free;" << std::endl;
1833 out <<
" nonlinear solver: newton raphson";
1837 out <<
", keep jacobian matrix";
1840 out <<
", honor element requests";
1843 out <<
";" << std::endl;
1847 out <<
"end: initial value;" << std::endl << std::endl;
1858 static const char*
const sKeyWords[] = {
1867 "min" "time" "step",
1868 "max" "time" "step",
1872 "modify" "residual" "test",
1873 "enforce" "constraint" "equations",
1875 "fictitious" "steps" "number",
1876 "fictitious" "steps" "ratio",
1877 "fictitious" "steps" "tolerance",
1878 "fictitious" "steps" "max" "iterations",
1881 "dummy" "steps" "number",
1882 "dummy" "steps" "ratio",
1883 "dummy" "steps" "tolerance",
1884 "dummy" "steps" "max" "iterations",
1891 "fictitious" "steps" ,
1900 "jacobian" "matrix",
1904 "matrix" "condition" "number",
1905 "solver" "condition" "number",
1910 "fictitious" "steps" "method" ,
1911 "dummy" "steps" "method",
1914 "Crank" "Nicholson" ,
1922 "derivatives" "coefficient",
1923 "derivatives" "tolerance",
1924 "derivatives" "max" "iterations",
1941 "interface" "solver",
1944 "interface" "linear" "solver",
1950 "nonlinear" "solver",
1958 "full" "jacobian" "matrix",
1986 ENFORCE_CONSTRAINT_EQUATIONS,
1987 FICTITIOUSSTEPSNUMBER,
1988 FICTITIOUSSTEPSRATIO,
1989 FICTITIOUSSTEPSTOLERANCE,
1990 FICTITIOUSSTEPSMAXITERATIONS,
1994 DUMMYSTEPSTOLERANCE,
1995 DUMMYSTEPSMAXITERATIONS,
2020 FICTITIOUSSTEPSMETHOD,
2031 DERIVATIVESCOEFFICIENT,
2032 DERIVATIVESTOLERANCE,
2033 DERIVATIVESMAXITERATIONS,
2053 INTERFACELINEARSOLVER,
2082 silent_cerr(
"Error: <begin> expected at line "
2083 << HP.
GetLineData() <<
"; aborting..." << std::endl);
2089 pedantic_cout(
"warning: \"begin: multistep\" is deprecated; "
2090 "use \"begin: initial value;\" instead." << std::endl);
2095 silent_cerr(
"Error: \"begin: initial value;\" expected at line "
2096 << HP.
GetLineData() <<
"; aborting..." << std::endl);
2100 bool bMethod(
false);
2101 bool bDummyStepsMethod(
false);
2110 bool bModResTest =
false;
2111 bool bSetScaleAlgebraic =
false;
2121 integer iDerivativesCoefMaxIter = 0;
2124 #ifdef USE_MULTITHREAD
2125 bool bSolverThreads(
false);
2126 unsigned nSolverThreads = 0;
2134 switch (CurrKeyWord) {
2143 dFinalTime = std::numeric_limits<doublereal>::max();
2151 silent_cerr(
"warning: final time " <<
dFinalTime
2152 <<
" is less than initial time "
2154 <<
"this will cause the simulation"
2155 " to abort" << std::endl);
2165 silent_cerr(
"warning, null initial time step"
2166 " is not allowed" << std::endl);
2169 silent_cerr(
"warning, negative initial time step"
2170 " is not allowed;" << std::endl
2172 <<
" will be considered" << std::endl);
2181 silent_cerr(
"invalid min time step " << e.
Get() <<
" (must be positive) [" << e.
what() <<
"] at line " << HP.
GetLineData() << std::endl);
2211 silent_cout(
"no max time step limit will be"
2212 " considered" << std::endl);
2215 silent_cerr(
"negative max time step"
2216 " is not allowed" << std::endl);
2221 case FICTITIOUSSTEPSNUMBER:
2222 case DUMMYSTEPSNUMBER:
2227 silent_cerr(
"negative dummy steps number"
2228 " is illegal" << std::endl);
2232 silent_cerr(
"warning, a single dummy step"
2233 " may be useless" << std::endl);
2240 case FICTITIOUSSTEPSRATIO:
2241 case DUMMYSTEPSRATIO:
2244 silent_cerr(
"negative dummy steps ratio"
2245 " is illegal" << std::endl);
2250 silent_cerr(
"warning, dummy steps ratio"
2251 " is larger than one." << std::endl
2252 <<
"Something like 1.e-3 should"
2253 " be safer ..." << std::endl);
2260 case FICTITIOUSSTEPSTOLERANCE:
2261 case DUMMYSTEPSTOLERANCE:
2262 dDummyStepsTolerance = HP.
GetReal();
2263 if (dDummyStepsTolerance <= 0.) {
2264 silent_cerr(
"negative dummy steps"
2265 " tolerance is illegal" << std::endl);
2269 "Dummy steps tolerance: "
2270 << dDummyStepsTolerance << std::endl);
2275 switch (WhenToAbort) {
2279 "Simulation will abort after"
2280 " data input" << std::endl);
2286 "Simulation will abort after"
2287 " initial assembly" << std::endl);
2293 "Simulation will abort after"
2294 " derivatives solution" << std::endl);
2297 case FICTITIOUSSTEPS:
2301 "Simulation will abort after"
2302 " dummy steps solution" << std::endl);
2306 silent_cerr(
"Don't know when to abort,"
2307 " so I'm going to abort now" << std::endl);
2314 bool setOutput =
false;
2316 while (HP.
IsArg()) {
2318 switch (OutputFlag) {
2337 case JACOBIANMATRIX:
2353 case MATRIX_COND_NUM:
2359 const double P = HP.
GetReal();
2361 silent_cerr(
"Only inf or 1 norm are supported for condition numbers at line " << HP.
GetLineData() << std::endl);
2371 case SOLVER_COND_NUM:
2386 silent_cerr(
"Warning, unknown output flag "
2388 <<
"; ignored" << std::endl);
2407 silent_cerr(
"error: multiple definition"
2408 " of integration method at line "
2416 case CRANKNICHOLSON:
2417 silent_cout(
"warning: \"crank nicolson\" is the correct spelling "
2428 int iOrder = HP.
GetInt();
2439 silent_cerr(
"unhandled BDF order " << iOrder << std::endl);
2451 silent_cerr(
"integration method \"nostro\" "
2452 "is deprecated; use \"ms\" "
2496 silent_cerr(
"Unknown integration method at line "
2503 case FICTITIOUSSTEPSMETHOD:
2504 case DUMMYSTEPSMETHOD: {
2505 if (bDummyStepsMethod) {
2506 silent_cerr(
"error: multiple definition "
2507 "of dummy steps integration method "
2512 bDummyStepsMethod =
true;
2516 case CRANKNICHOLSON:
2517 silent_cout(
"warning: \"crank nicolson\" is the correct spelling" << std::endl);
2527 int iOrder = HP.
GetInt();
2538 silent_cerr(
"unhandled BDF order " << iOrder << std::endl);
2589 silent_cerr(
"Unknown integration method at line " << HP.
GetLineData() << std::endl);
2608 silent_cerr(
"warning, residual tolerance "
2610 "using default value " << dTol
2629 silent_cerr(
"unknown test "
2638 silent_cerr(
"it's a nonsense "
2639 "to scale a disabled test; "
2656 if (dSolutionTol != 0.) {
2669 silent_cerr(
"unknown test "
2678 }
else if (dTol == 0.) {
2679 silent_cerr(
"need solution tolerance "
2680 "with null residual tolerance"
2685 if (dSolutionTol < 0.) {
2687 silent_cerr(
"warning, solution tolerance "
2689 "solution test is disabled"
2693 if (dTol == 0. && dSolutionTol == 0.) {
2694 silent_cerr(
"both residual and solution "
2695 "tolerances are zero" << std::endl);
2700 <<
", " << dSolutionTol << std::endl);
2705 if (HP.
IsKeyWord(
"differential" "equations")) {
2709 silent_cerr(
"error: max residual for differential equations "
2710 "must be greater than zero at line "
2720 silent_cerr(
"error: max residual must be greater than zero at line "
2728 case DERIVATIVESTOLERANCE: {
2729 dDerivativesTol = HP.
GetReal();
2730 if (dDerivativesTol <= 0.) {
2732 silent_cerr(
"warning, derivatives "
2733 "tolerance <= 0.0 is illegal; "
2734 "using default value "
2739 "Derivatives tolerance = "
2745 case MAXITERATIONS: {
2749 silent_cerr(
"warning, max iterations "
2750 "< 1 is illegal; using default value "
2763 case MODIFY_RES_TEST:
2765 silent_cerr(
"\"modify residual test\" "
2766 "not supported by schur data manager "
2768 <<
"; ignored" << std::endl);
2772 "Modify residual test" << std::endl);
2776 case ENFORCE_CONSTRAINT_EQUATIONS:
2777 if (HP.
IsKeyWord(
"constraint" "violations")) {
2780 bSetScaleAlgebraic = !HP.
IsKeyWord(
"scale" "factor");
2782 if (!bSetScaleAlgebraic) {
2785 }
else if (HP.
IsKeyWord(
"constraint" "violation" "rates")) {
2788 silent_cerr(
"Keyword \"constraint violations\" or "
2789 "\"constraint violation rates\" expected at line "
2796 case DERIVATIVESMAXITERATIONS: {
2797 iDerivativesMaxIterations = HP.
GetInt();
2798 if (iDerivativesMaxIterations < 1) {
2800 silent_cerr(
"warning, derivatives "
2801 "max iterations < 1 is illegal; "
2802 "using default value "
2803 << iDerivativesMaxIterations
2808 << iDerivativesMaxIterations
2813 case FICTITIOUSSTEPSMAXITERATIONS:
2814 case DUMMYSTEPSMAXITERATIONS: {
2815 iDummyStepsMaxIterations = HP.
GetInt();
2816 if (iDummyStepsMaxIterations < 1) {
2818 silent_cerr(
"warning, dummy steps "
2819 "max iterations < 1 is illegal; "
2820 "using default value "
2821 << iDummyStepsMaxIterations
2826 << iDummyStepsMaxIterations
2831 case DERIVATIVESCOEFFICIENT: {
2832 const bool bAutoDerivCoef = HP.
IsKeyWord(
"auto");
2834 if (!bAutoDerivCoef) {
2838 silent_cerr(
"warning, derivatives "
2839 "coefficient <= 0. is illegal; "
2840 "using default value "
2848 if (bAutoDerivCoef || HP.
IsKeyWord(
"auto")) {
2850 iDerivativesCoefMaxIter = HP.
GetInt();
2851 if (iDerivativesCoefMaxIter < 0) {
2852 silent_cerr(
"number of iterations must be greater than or equal to zero at line " << HP.
GetLineData() << std::endl);
2857 iDerivativesCoefMaxIter = 6;
2861 dDerivativesCoefFactor = HP.
GetReal();
2863 if (dDerivativesCoefFactor <= 1.) {
2864 silent_cerr(
"factor must be greater than one at line " << HP.
GetLineData() << std::endl);
2873 case NEWTONRAPHSON: {
2874 pedantic_cout(
"Newton Raphson is deprecated; use "
2875 "\"nonlinear solver: newton raphson "
2876 "[ , modified, <steps> ]\" instead"
2888 "Newton-Raphson will be used; "
2889 "matrix will be assembled "
2892 <<
" iterations" << std::endl);
2896 silent_cerr(
"warning: unknown case; "
2897 "using default" << std::endl);
2911 pedantic_cout(
"\"end: multistep;\" is deprecated; "
2912 "use \"end: initial value;\" instead." << std::endl);
2917 silent_cerr(
"\"end: initial value;\" expected "
2919 <<
"; aborting..." << std::endl);
2930 <<
": POD analysis not supported (ignored)"
2932 for (; HP.
IsArg();) {
2944 int iNumTimes = HP.
GetInt();
2945 if (iNumTimes <= 0) {
2946 silent_cerr(
"invalid number of eigenanalysis times "
2953 for (std::vector<doublereal>::iterator i =
EigAn.
Analyses.begin();
2958 silent_cerr(
"eigenanalysis times must be in strict ascending order "
2978 while (HP.
IsArg()) {
2982 }
else if (HP.
IsKeyWord(
"output" "matrices")) {
2985 }
else if (HP.
IsKeyWord(
"output" "full" "matrices")) {
2987 silent_cerr(
"\"output full matrices\" needs eigenanalysis support" << std::endl);
2992 }
else if (HP.
IsKeyWord(
"output" "sparse" "matrices")) {
2995 }
else if (HP.
IsKeyWord(
"output" "eigenvectors")) {
2997 silent_cerr(
"\"output eigenvectors\" needs eigenanalysis support" << std::endl);
3002 }
else if (HP.
IsKeyWord(
"output" "geometry")) {
3005 }
else if (HP.
IsKeyWord(
"matrix" "output" "precision")) {
3008 silent_cerr(
"negative or null \"matrix output precision\" "
3014 }
else if (HP.
IsKeyWord(
"results" "output" "precision")) {
3017 silent_cerr(
"negative or null \"results output precision\" "
3023 }
else if (HP.
IsKeyWord(
"upper" "frequency" "limit")) {
3026 silent_cerr(
"invalid \"upper frequency limit\" "
3032 }
else if (HP.
IsKeyWord(
"lower" "frequency" "limit")) {
3035 silent_cerr(
"invalid \"lower frequency limit\" "
3041 }
else if (HP.
IsKeyWord(
"use" "lapack")) {
3043 silent_cerr(
"eigenanalysis routine already selected "
3050 #else // !USE_LAPACK
3051 silent_cerr(
"\"use lapack\" "
3052 "needs to configure --with-lapack "
3056 #endif // !USE_LAPACK
3058 }
else if (HP.
IsKeyWord(
"use" "arpack")) {
3060 silent_cerr(
"eigenanalysis routine already selected "
3070 silent_cerr(
"invalid number of eigenvalues "
3080 silent_cerr(
"invalid number of Arnoldi vectors "
3081 "(must be > NEV+2) "
3088 silent_cerr(
"warning, possibly incorrect number of Arnoldi vectors "
3089 "(should be > 2*NEV) "
3096 silent_cerr(
"tolerance must be non-negative "
3101 #else // !USE_ARPACK
3102 silent_cerr(
"\"use arpack\" "
3103 "needs to configure --with-arpack "
3107 #endif // !USE_ARPACK
3109 }
else if (HP.
IsKeyWord(
"use" "jdqz")) {
3111 silent_cerr(
"eigenanalysis routine already selected "
3121 silent_cerr(
"invalid number of eigenvalues "
3131 silent_cerr(
"invalid size of the search space "
3132 "(must be >= 20 && >= 2*kmax) "
3142 silent_cerr(
"tolerance must be non-negative "
3145 EigAn.
jdqz.
eps = std::numeric_limits<doublereal>::epsilon();
3148 silent_cerr(
"\"use jdqz\" "
3149 "needs to configure --with-jdqz "
3169 silent_cerr(
"unknown balance option "
3175 }
else if (HP.
IsKeyWord(
"suffix" "width")) {
3183 }
else if (HP.
IsKeyWord(
"suffix" "format")) {
3188 silent_cerr(
"unknown option "
3211 silent_cerr(
"sparse matrices output "
3212 "incompatible with lapack "
3224 silent_cerr(
"full matrices output "
3225 "incompatible with arpack "
3237 silent_cerr(
"full matrices output "
3238 "incompatible with jdqz "
3276 silent_cerr(
"warning: \"eigenanalysis\" not supported; ignored" << std::endl);
3281 silent_cerr(
"\"solver\" keyword at line "
3283 <<
" is deprecated; "
3284 "use \"linear solver\" instead"
3290 case INTERFACESOLVER:
3291 silent_cerr(
"\"interface solver\" keyword at line "
3293 <<
" is deprecated; "
3294 "use \"interface linear solver\" "
3295 "instead" << std::endl);
3296 case INTERFACELINEARSOLVER:
3300 silent_cerr(
"Interface solver only allowed "
3301 "when compiled with MPI support" << std::endl);
3305 case NONLINEARSOLVER:
3324 silent_cerr(
"unknown nonlinear solver "
3346 pedantic_cout(
"Use of deprecated \"keep jacobian\" "
3350 }
else if (HP.
IsKeyWord(
"keep" "jacobian" "matrix")) {
3358 "assembled at most "
3363 if (HP.
IsKeyWord(
"honor" "element" "requests")) {
3367 "request to update "
3368 "the preconditioner"
3374 while (HP.
IsArg()) {
3378 silent_cerr(
"tolerance x must be greater than or equal to zero at line " << HP.
GetLineData() << std::endl);
3381 }
else if (HP.
IsKeyWord(
"tolerance" "min")) {
3384 silent_cerr(
"tolerance min must be greater than or equal to zero at line " << HP.
GetLineData() << std::endl);
3387 }
else if (HP.
IsKeyWord(
"max" "iterations")) {
3390 silent_cerr(
"max iterations must be greater than or equal to zero at line " << HP.
GetLineData() << std::endl);
3396 silent_cerr(
"alpha must be greater than or equal to zero at line " << HP.
GetLineData() << std::endl);
3399 }
else if (HP.
IsKeyWord(
"lambda" "min")) {
3402 silent_cerr(
"lambda min must be greater than or equal to zero at line " << HP.
GetLineData() << std::endl);
3412 }
else if (HP.
IsKeyWord(
"lambda" "factor" "min")) {
3415 silent_cerr(
"lambda factor min must be in between zero and one at line" << HP.
GetLineData() << std::endl);
3418 }
else if (HP.
IsKeyWord(
"max" "step")) {
3421 silent_cerr(
"max step must be greater than zero at line " << HP.
GetLineData() << std::endl);
3424 }
else if (HP.
IsKeyWord(
"zero" "gradient")) {
3433 silent_cerr(
"Keyword \"continue\" expected at line " << HP.
GetLineData() << std::endl);
3436 }
else if (HP.
IsKeyWord(
"divergence" "check")) {
3445 silent_cerr(
"divergence check factor must be greater than zero at line " << HP.
GetLineData() << std::endl);
3456 silent_cerr(
"Keyword \"cubic\" or \"factor\" expected at line " << HP.
GetLineData() << std::endl);
3459 }
else if (HP.
IsKeyWord(
"scale" "newton" "step")) {
3468 silent_cerr(
"min scale must be in range [0-1] at line " << HP.
GetLineData() << std::endl);
3472 }
else if (HP.
IsKeyWord(
"print" "convergence" "info")) {
3484 }
else if (HP.
IsKeyWord(
"abort" "at" "lambda" "min")) {
3490 }
else if (HP.
IsKeyWord(
"non" "negative" "slope" "continue")) {
3497 silent_cerr(
"Keyword \"tolerance x\", "
3498 "\"tolerance min\", \"max iterations\", \"alpha\", "
3499 "\"lambda min\" \"lambda factor min\", \"max step\" "
3500 "\"divergence check\", \"algorithm\", \"scale newton step\" "
3501 "\"print convergence info\", \"verbose\", "
3502 "\"abort at lambda min\" "
3503 "or \"zero gradient\" expected at line " << HP.
GetLineData() << std::endl);
3526 silent_cerr(
"unknown iterative "
3546 "steps for iterative "
3577 case FULLJACOBIANMATRIX:
3583 "before recomputing "
3584 "the preconditioner: "
3588 if (HP.
IsKeyWord(
"honor" "element" "requests")) {
3592 "request to update "
3593 "the preconditioner"
3602 silent_cerr(
"unknown "
3625 #ifdef USE_MULTITHREAD
3629 silent_cerr(
"got " << n <<
" CPUs "
3638 silent_cerr(
"configure with "
3639 "--enable-multithread "
3640 "for multithreaded assembly"
3645 #ifdef USE_MULTITHREAD
3650 #ifdef USE_MULTITHREAD
3651 bool bAssembly =
false;
3652 bool bSolver =
false;
3655 #endif // USE_MULTITHREAD
3658 #ifdef USE_MULTITHREAD
3661 #endif // USE_MULTITHREAD
3664 #ifdef USE_MULTITHREAD
3667 #endif // USE_MULTITHREAD
3670 #ifdef USE_MULTITHREAD
3672 #endif // USE_MULTITHREAD
3675 #ifdef USE_MULTITHREAD
3676 if (bAll || bAssembly) {
3680 if (bAll || bSolver) {
3681 bSolverThreads =
true;
3682 nSolverThreads = nt;
3685 silent_cerr(
"configure with "
3686 "--enable-multithread "
3687 "for multithreaded assembly"
3695 silent_cerr(
"unknown description at line "
3705 pedantic_cout(
"No time step control strategy defined; defaulting to NoChange time step control" );
3749 iDerivativesMaxIterations,
3751 iDerivativesCoefMaxIter,
3752 dDerivativesCoefFactor));
3760 iDummyStepsMaxIterations,
3770 iDummyStepsMaxIterations,
3779 iDummyStepsMaxIterations,
3790 iDummyStepsMaxIterations,
3802 iDummyStepsMaxIterations,
3809 iDummyStepsMaxIterations,
3819 dSolutionTol, iDummyStepsMaxIterations,
3824 silent_cerr(
"unknown dummy steps integration method"
3900 silent_cerr(
"Unknown integration method" << std::endl);
3905 if (bSetScaleAlgebraic) {
3909 #ifdef USE_MULTITHREAD
3910 if (bSolverThreads) {
3912 silent_cerr(
"linear solver "
3914 <<
" does not support "
3915 "threaded solution" << std::endl);
3934 sigma = (re*re - b*b + im*im)/d;
3939 d = sigma*sigma + omega*omega;
3940 if (d > std::numeric_limits<doublereal>::epsilon()) {
3941 csi = -100*sigma/
sqrt(d);
3947 freq = omega/(2*
M_PI);
3950 if (std::abs(sigma) < std::numeric_limits<doublereal>::epsilon()) {
3971 std::vector<bool>& vOut)
3976 Out <<
"Mode n. " " " " Real " " " " Imag " " " " " " Damp % " " Freq Hz" << std::endl;
3980 for (
int iCnt = 1; iCnt <= iNVec; iCnt++) {
3989 if (iCnt < iLow || iCnt > iHigh) {
3990 vOut[iCnt - 1] =
false;
3995 do_eig(b, re, im, h, sigma, omega, csi, freq);
3997 if (freq < pEA->dLowerFreq || freq > pEA->
dUpperFreq) {
3998 vOut[iCnt - 1] =
false;
4002 vOut[iCnt - 1] =
true;
4004 Out << std::setw(8) << iCnt <<
": "
4005 << std::setw(12) << sigma <<
" + " << std::setw(12) << omega <<
" j";
4007 if (
fabs(csi) > std::numeric_limits<doublereal>::epsilon()) {
4008 Out <<
" " << std::setw(12) << csi;
4010 Out <<
" " << std::setw(12) << 0.;
4013 Out <<
" " << std::setw(12) << freq;
4025 bool bNewLine,
const unsigned uCurr)
4058 integer iILO = 1, iIHI = iSize;
4066 iMinWorkSize = 8*iSize;
4088 iMinWorkSize = 6*iSize;
4090 __FC_DECL__(dggevx)(
4123 if (bNewLine && silent_err) {
4124 silent_cerr(std::endl);
4127 silent_cerr(
"dggev[x]() query for worksize failed "
4128 "INFO=" << iInfo << std::endl);
4133 if (iWorkSize < iMinWorkSize) {
4134 if (bNewLine && silent_err) {
4135 silent_cerr(std::endl);
4138 silent_cerr(
"dggev[x]() asked for a worksize " << iWorkSize
4139 <<
" less than the minimum, " << iMinWorkSize
4140 <<
"; using the minimum" << std::endl);
4141 iWorkSize = iMinWorkSize;
4149 int iTmpSize = 2*(iSize*iSize) + 3*iSize + iWorkSize;
4151 iTmpSize += 2*iSize;
4154 #if defined HAVE_MEMSET
4156 #else // !HAVE_MEMSET
4157 for (
int iCnt = iTmpSize; iCnt-- > 0; ) {
4160 #endif // !HAVE_MEMSET
4171 pdTmp += iSize*iSize;
4175 pdTmp += iSize*iSize;
4189 LScale.
Attach(iSize, pdTmp);
4192 RScale.
Attach(iSize, pdTmp);
4209 const_cast<doublereal *>(MatB.
pdGetMat()),
4223 std::vector<integer> iIWORK(iSize + 6);
4225 __FC_DECL__(dggevx)(
4233 const_cast<doublereal *>(MatB.
pdGetMat()),
4258 Out <<
"Info: " << iInfo <<
", ";
4263 <<
" BALANC=\"" << sB <<
"\""
4266 <<
" ABNRM=" << dABNRM
4267 <<
" BBNRM=" << dBBNRM
4270 }
else if (iInfo < 0) {
4271 const char *arg[] = {
4292 const char *argx[] = {
4325 const char **argv = (sB[0] ==
'N' ? arg : argx );
4328 Out <<
"argument #" << -iInfo
4329 <<
" (" << argv[-iInfo - 1] <<
") "
4330 <<
"was passed an illegal value" << std::endl;
4332 }
else if (iInfo > 0 && iInfo <= iSize) {
4337 Out <<
"the QZ iteration failed, but eigenvalues "
4338 << iInfo + 1 <<
"->" << iSize <<
" should be correct"
4341 }
else if (iInfo > iSize) {
4342 const char*
const sErrs[] = {
4343 "DHGEQZ (other than QZ iteration failed in DHGEQZ)",
4348 Out <<
"error return from " << sErrs[iInfo - iSize - 1]
4352 std::vector<bool> vOut(iSize);
4367 #endif // USE_LAPACK
4375 bool bNewLine,
const unsigned uCurr)
4392 std::vector<doublereal> RESID;
4394 std::vector<doublereal> V;
4398 std::vector<doublereal> WORKD;
4399 std::vector<doublereal> WORKL;
4409 silent_cerr(
"eig_arpack: invalid NEV=" << NEV <<
" > size of problem (=" << N <<
")" << std::endl);
4414 RESID.resize(N, 0.);
4417 silent_cerr(
"eig_arpack: invalid NCV=" << NCV <<
" > size of problem (=" << N <<
")" << std::endl);
4423 V.resize(N*(NCV + 1), 0.);
4429 WORKD.resize(3*N, 0.);
4430 LWORKL = 3*NCV*NCV + 6*NCV;
4431 WORKL.resize(LWORKL, 0.);
4436 const bool bOutputStatus = isatty(fileno(stderr));
4439 __FC_DECL__(dnaupd)(&IDO, &BMAT[0], &N, &WHICH[0], &NEV,
4440 &TOL, &RESID[0], &NCV, &V[0], &LDV, &IPARAM[0], &IPNTR[0],
4441 &WORKD[0], &WORKL[0], &LWORKL, &INFO);
4444 std::cout <<
"cnt=" << cnt <<
": IDO=" << IDO <<
", INFO=" << INFO << std::endl;
4448 ASSERT(IPNTR[0] - 1 <= 2*N);
4449 ASSERT(IPNTR[1] - 1 <= 2*N);
4498 static const int CNT = 100;
4500 if (bOutputStatus && !(cnt % CNT)) {
4501 if (bNewLine && silent_err) {
4502 silent_cerr(std::endl);
4505 silent_cerr(
"\r" "cnt=" << cnt);
4509 if (bNewLine && silent_err) {
4510 silent_cerr(std::endl);
4513 silent_cerr((cnt >= CNT ?
"\n" :
"")
4514 <<
"ARPACK: interrupted" << std::endl);
4517 }
while (IDO == 1 || IDO == -1);
4519 if (bOutputStatus) {
4520 if (bNewLine && silent_err) {
4521 silent_cerr(std::endl);
4524 silent_cerr(
"\r" "cnt=" << cnt << std::endl);
4529 if (bNewLine && silent_err) {
4530 silent_cerr(std::endl);
4533 silent_cerr(
"ARPACK error after " << cnt <<
" iterations; "
4534 "IDO=" << IDO <<
", INFO=" << INFO << std::endl);
4543 if (bNewLine && silent_err) {
4544 silent_cerr(std::endl);
4547 silent_cerr(
"INFO=1: Maximum number of iterations taken. "
4548 "All possible eigenvalues of OP have been found. IPARAM(5) "
4549 "returns the number of wanted converged Ritz values "
4550 "(currently = " << IPARAM[4] <<
"; requested NEV = " << NEV <<
")."
4555 if (bNewLine && silent_err) {
4556 silent_cerr(std::endl);
4559 silent_cerr(
"INFO=2: No longer an informational error. Deprecated starting "
4560 "with release 2 of ARPACK."
4565 if (bNewLine && silent_err) {
4566 silent_cerr(std::endl);
4569 silent_cerr(
"INFO=3: No shifts could be applied during a cycle of the "
4570 "implicitly restarted Arnoldi iteration. One possibility "
4571 "is to increase the size of NCV (currently = " << NCV <<
") "
4572 "relative to NEV (currently = " << NEV <<
"). "
4573 "See remark 4 in dnaupd(3)."
4578 if (bNewLine && silent_err) {
4579 silent_cerr(std::endl);
4582 silent_cerr(
"INFO=" << INFO <<
": undocumented value." << std::endl);
4587 Out <<
"INFO: " << INFO << std::endl;
4590 for (
int ii = 0; ii < 11; ii++) {
4591 std::cerr <<
"IPARAM(" << ii + 1 <<
")=" << IPARAM[ii] << std::endl;
4595 logical RVEC =
true;
4596 const char *HOWMNY =
"A";
4597 std::vector<logical> SELECT(NCV);
4598 std::vector<doublereal> D(2*NCV);
4600 std::vector<doublereal> Z(N*(NCV + 1));
4602 std::vector<doublereal> WORKEV(3*NCV);
4605 std::cerr <<
"dneupd:" << std::endl
4606 <<
"RVEC = " << RVEC << std::endl
4607 <<
"HOWMNY = " << HOWMNY << std::endl
4608 <<
"SELECT(" << NCV <<
")" << std::endl
4609 <<
"DR(" << NEV + 1 <<
")" << std::endl
4610 <<
"DI(" << NEV + 1 <<
")" << std::endl
4611 <<
"Z(" << N <<
", " << NEV + 1 <<
")" << std::endl
4612 <<
"LDZ = " << LDZ << std::endl
4613 <<
"SIGMAR = " << SIGMAR << std::endl
4614 <<
"SIGMAI = " << SIGMAI << std::endl
4615 <<
"WORKEV(" << 3*NCV <<
")" << std::endl
4616 <<
"BMAT = " << BMAT << std::endl
4617 <<
"N = " << N << std::endl
4618 <<
"WHICH = " << WHICH << std::endl
4619 <<
"NEV = " << NEV << std::endl
4620 <<
"TOL = " << TOL << std::endl
4621 <<
"RESID(" << N <<
")" << std::endl
4622 <<
"NCV = " << NCV << std::endl
4623 <<
"V(" << N <<
", " << NCV <<
")" << std::endl
4624 <<
"LDV = " << LDV << std::endl
4625 <<
"IPARAM(" <<
sizeof(IPARAM)/
sizeof(IPARAM[0]) <<
")" << std::endl
4626 <<
"IPNTR(" <<
sizeof(IPNTR)/
sizeof(IPNTR[0]) <<
")" << std::endl
4627 <<
"WORKD(" << 3*N <<
")" << std::endl
4628 <<
"WORKL(" << LWORKL <<
")" << std::endl
4629 <<
"LWORKL = " << LWORKL << std::endl
4630 <<
"INFO = " << INFO << std::endl;
4633 __FC_DECL__(dneupd)(&RVEC, &HOWMNY[0], &SELECT[0], &DR[0], &DI[0],
4634 &Z[0], &LDZ, &SIGMAR, &SIGMAI, &WORKEV[0],
4635 &BMAT[0], &N, &WHICH[0], &NEV,
4636 &TOL, &RESID[0], &NCV, &V[0], &LDV, &IPARAM[0], &IPNTR[0],
4637 &WORKD[0], &WORKL[0], &LWORKL, &INFO);
4639 int nconv = IPARAM[4];
4644 std::vector<bool> vOut(nconv);
4652 std::vector<doublereal *> ZC(nconv);
4659 if (bNewLine && silent_err) {
4660 silent_cerr(std::endl);
4663 silent_cerr(
"no converged Ritz coefficients" << std::endl);
4666 #endif // USE_ARPACK
4674 bool bNewLine,
const unsigned uCurr)
4679 MBJDQZ mbjdqz(MatA, MatB);
4722 std::vector<doublecomplex> alpha;
4723 std::vector<doublecomplex> beta;
4724 std::vector<doublecomplex> eivec;
4727 doublecomplex target = { 1., 0. };
4740 std::vector<doublecomplex> zwork;
4745 lwork = 4 + m + 5*jmax + 3*kmax;
4749 lwork = 10 + 6*l + 5*jmax + 3*kmax;
4758 eivec.resize(n*kmax);
4759 zwork.resize(n*lwork);
4783 if (bNewLine && silent_err) {
4784 silent_cerr(std::endl);
4787 silent_cerr(
"\r" "cnt=" << mbjdqz.Cnt() << std::endl);
4795 if (beta[
c].i != 0.) {
4798 AlphaR(
c + 1) = (alpha[
c].r*beta[
c].r + alpha[
c].i*beta[
c].i)/d;
4799 AlphaI(
c + 1) = (alpha[
c].i*beta[
c].r - alpha[
c].r*beta[
c].i)/d;
4802 Beta(
c + 1) = beta[
c].r;
4803 AlphaR(
c + 1) = alpha[
c].r;
4804 AlphaI(
c + 1) = alpha[
c].i;
4807 std::vector<bool> vOut(nconv);
4816 doublecomplex *p = &eivec[0] - 1;
4819 if (AlphaI(
c) == 0.) {
4820 for (
integer r = 1; r <= n; r++) {
4825 for (
integer r = 1; r <= n; r++) {
4827 VR(r,
c + 1) = p[n + r].i;
4842 if (bNewLine && silent_err) {
4843 silent_cerr(std::endl);
4846 silent_cerr(
"no converged eigenpairs" << std::endl);
4865 DEBUGCOUT(
"Solver::Eig(): performing eigenanalysis" << std::endl);
4905 pDM->
AssJac(*pMatA, -h/2.);
4906 pDM->
AssJac(*pMatB, h/2.);
4910 <<
"Matrix A:" << std::endl << *pMatA << std::endl
4911 <<
"Matrix B:" << std::endl << *pMatB << std::endl);
4918 std::stringstream postfix_ss;
4932 postfix_ss << uCurr;
4943 if (dynamic_cast<const NaiveMatrixHandler *>(pMatB)) {
4953 eig_lapack(pMatA, pMatB, pDM, &
EigAn, bNewLine, uCurr);
4955 #endif // USE_LAPACK
4959 eig_arpack(pMatA, pSM, pDM, &
EigAn, bNewLine, uCurr);
4961 #endif // USE_ARPACK
4965 eig_jdqz(pMatA, pMatB, pDM, &
EigAn, bNewLine, uCurr);
5008 #ifdef HAVE_UMFPACK_TIC_DISABLE
5022 umfpack_tic_disable();
5024 #endif // HAVE_UMFPACK_TIC_DISABLE
5050 silent_cerr(
"apparently solver "
5052 <<
" is not allowed as interface solver "
5053 "for SchurSolutionManager" << std::endl);
5065 silent_cerr(
"Configure --with-mpi to enable Schur solver" << std::endl);
5093 pedantic_cout(
"unknown matrix free solver type; "
5094 "using default" << std::endl);
5112 pedantic_cout(
"unknown nonlinear solver type; using default"
5140 <<
"\n\tnumstates = " << iStates << std::endl);
5153 integer iLWS = iWorkSpaceSize;
5182 silent_cerr(
"No linear solver defined" << std::endl);
5207 if (pDerivativeSteps) {
5212 if (dErr > dMaxResidual) {
5213 if (dCurrTimeStep > 2 * dMinTimeStep) {
5214 if (outputIters()) {
5216 if (!bParallel || MBDynComm.Get_rank() == 0)
5219 silent_cerr(
"warning: current residual = " << dErr
5220 <<
" > maximum residual = " << dMaxResidual
5229 if (dErrDiff > dMaxResidualDiff) {
5230 if (dCurrTimeStep > 2 * dMinTimeStep) {
5231 if (outputIters()) {
5233 if (!bParallel || MBDynComm.Get_rank() == 0)
5236 silent_cerr(
"warning: current residual for differential equations = " << dErrDiff
5237 <<
" > maximum residual = " << dMaxResidualDiff
5246 switch (eTimeStepLimit) {
5250 case TS_HARD_LIMIT: {
5251 const doublereal dMaxTS = MaxTimeStep.dGet();
5253 if (dCurrTimeStep > dMaxTS && dCurrTimeStep > dMinTimeStep) {
5254 if (outputIters()) {
5256 if (!bParallel || MBDynComm.Get_rank() == 0)
5259 silent_cerr(
"warning: current time step = "
5261 <<
" > hard limit of the maximum time step = "
5262 << dMaxTS << std::endl);
void SetScale(VectorHandler &XScale) const
void ReadLinSol(LinSol &cs, HighParser &HP, bool bAllowEmpty)
integer * GetDofsList(DofType who) const
integer iGetNumRows(void) const
#define DEBUG_LEVEL_MATCH(level)
static const doublereal dDefaultMinTimeStep
std::string outputCounterPrefix
std::ostream & RestartLinSol(std::ostream &out, const LinSol &cs)
virtual bool Prepare(void)
RTSolverBase * ReadRTSolver(Solver *pS, MBDynParser &HP)
void OutputEigParams(const doublereal &dTime, const doublereal &dCoef, const unsigned uCurrEigSol, const int iResultsPrecision)
static const doublereal defaultIterativeEtaMax
unsigned GetSolverFlags(void) const
void InitTimeStepData(void)
struct EigenAnalysis EigAn
enum NonlinearSolverOptions::ScaleFlags eScaleFlags
std::vector< doublereal > Analyses
StepIntegrator * pCurrStepIntegrator
virtual void SetScale(const VectorHandler *pScl)
bool outputCounter(void) const
#define MBDYN_EXCEPT_ARGS
void SetOutputMeter(DriveCaller *pOM)
#define DEBUGCOUTFNAME(fname)
virtual void ResizeReset(integer)
virtual integer GetInt(integer iDefval=0)
void SetOutputFlags(unsigned OF)
StepIntegratorType RegularType
void OutputEigOpen(const std::string &postfix)
std::vector< doublereal >::iterator currAnalysis
bool OutputEigClose(void)
doublereal dScaleAlgebraic
virtual void OutputTypes(const bool fpred)
static const doublereal defaultIterativeTau
bool EndOfSimulation(void) const
virtual void PrintResidual(const VectorHandler &Res, integer iIterCnt) const
StepIntegrator * pFirstRegularStep
doublereal dGetTime(void) const
virtual const std::string & GetDofDescription(int i) const
SolutionManager *const GetSolutionManager(integer iNLD, integer iLWS=0) const
virtual bool Output(long lStep, const doublereal &dTime, const doublereal &dTimeStep, bool force=false) const
const char * what(void) const
std::string sOutputFileName
virtual void Wait(void)=0
virtual void BeforePredict(VectorHandler &X, VectorHandler &XP, VectorHandler &XPrev, VectorHandler &XPPrev) const
virtual void CheckTimeStepLimit(doublereal dErr, doublereal dErrDiff) const
enum Solver::TimeStepFlags eTimeStepLimit
bool outputMsg(void) const
#define SAFEDELETEARR(pnt)
StepIntegrator::StepChange CurrStep
virtual MyVectorHandler * pSolHdl(void) const
virtual doublereal Advance(Solver *pS, const doublereal TStep, const doublereal dAlph, const StepChange StType, std::deque< MyVectorHandler * > &qX, std::deque< MyVectorHandler * > &qXPrime, MyVectorHandler *const pX, MyVectorHandler *const pXPrime, integer &EffIter, doublereal &Err, doublereal &SolErr)=0
virtual MyVectorHandler * pResHdl(void) const
integer iDummyStepsNumber
doublereal dDummyStepsRatio
virtual void SetDriveHandler(const DriveHandler *driveHandler)=0
bool SetNumThreads(unsigned nt)
StepIntegrator * pDerivativeSteps
virtual integer GetIntegratorMaxIters(void) const
#define DEBUG_LEVEL(level)
const DriveHandler * pGetDrvHdl(void) const
integer iNumPreviousVectors
void SetDataManager(DataManager *pDatMan)
NonlinearSolver::Type NonlinearSolverType
void OutputEigFullMatrices(const MatrixHandler *pmMatA, const MatrixHandler *pmMatB, const unsigned uCurrEigSol, const int iMatrixPrecision)
static const doublereal dDefaultDummyStepsRatio
void OutputEigGeometry(const unsigned uCurrSol, const int iResultsPrecision)
virtual integer iGetSize(void) const =0
integer iIterationsBeforeAssembly
GradientExpression< UnaryExpr< FuncFabs, Expr > > fabs(const GradientExpression< Expr > &u)
static const integer iDefaultPreconditionerSteps
static void output_eigenvalues(const VectorHandler *pBeta, const VectorHandler &R, const VectorHandler &I, const doublereal &dShiftR, DataManager *pDM, const Solver::EigenAnalysis *pEA, integer iLow, integer iHigh, std::vector< bool > &vOut)
bool outputStep(void) const
std::ostream & Restart(std::ostream &out, DataManager::eRestart type) const
virtual void StopCommanded(void)=0
virtual std::ostream & Restart(std::ostream &out) const =0
static const doublereal dDefaultDerivativesCoefficient
std::deque< MyVectorHandler * > qXPrime
virtual bool GetYesNoOrBool(bool bDefval=false)
DriveCaller * pOutputMeter
virtual void Reset(void)=0
int mbdyn_stop_at_end_of_iteration(void)
std::string sInputFileName
void DestroyTimeStepData(void)
virtual integer TotalAssembledJacobian(void)
void SetupSolmans(integer iStates, bool bCanBeParallel=false)
struct LineSearchParameters LineSearch
void mbdyn_signal_init(int pre)
void ReadData(MBDynParser &HP)
virtual clock_t GetCPUTime(void) const
bool SetSolver(SolverType t, unsigned f=SOLVER_FLAGS_NONE)
MatrixFreeSolver::SolverType MFSolverType
static const integer iDefaultMaxIterations
virtual void OutputEigPrepare(const integer iNumAnalyses, const integer iSize)
void SetValue(VectorHandler &X, VectorHandler &XP)
doublereal dDivergenceCheck
virtual void PrintSolution(const VectorHandler &Sol, integer iIterCnt) const
void LinkToSolution(VectorHandler &XCurr, VectorHandler &XPrimeCurr)
virtual void SetDrvHdl(const DriveHandler *pDH)
NonlinearSolverTest::Type SolTest
std::ostream & GetOutFile(void) const
static const integer iDefaultDummyStepsNumber
int mbdyn_reserve_stack(unsigned long size)
void AddOutputFlags(unsigned OF)
#define SAFENEW(pnt, item)
GradientExpression< UnaryExpr< FuncLog, Expr > > log(const GradientExpression< Expr > &u)
static const integer iDefaultIterationsBeforeAssembly
virtual MatrixHandler * pMatHdl(void) const =0
struct Solver::EigenAnalysis::JDQZ jdqz
bool AddSolverFlags(unsigned f)
NonlinearSolver *const AllocateNonlinearSolver()
SolutionManager *const AllocateSolman(integer iNLD, integer iLWS=0)
virtual bool IsKeyWord(const char *sKeyWord)
StepIntegrator * pRegularSteps
void DelOutputFlags(unsigned OF)
doublereal dInitialTimeStep
static const doublereal dDefaultMaxTimeStep
doublereal copysign(doublereal x, doublereal y)
void OutputEigSparseMatrices(const MatrixHandler *pmMatA, const MatrixHandler *pmMatB, const unsigned uCurrEigSol, const int iMatrixPrecision)
virtual doublereal GetIntegratorDTol(void) const
virtual const char * GetStringWithDelims(enum Delims Del=DEFAULTDELIM, bool escape=true)
virtual void OutputPrepare(void)
virtual void AssJac(MatrixHandler &JacHdl, doublereal dCoef)
StepIntegrator * pFirstDummyStep
virtual void SetTest(NonlinearSolverTest *pr, NonlinearSolverTest *ps)
void mbdyn_set_stop_at_end_of_iteration(void)
virtual bool IsStopCommanded(void)
doublereal dIterertiveTau
static const doublereal dDefaultDummyStepsTolerance
virtual MathParser & GetMathParser(void)
DriveCaller * pRhoRegular
doublereal dIterertiveEtaMax
virtual clock_t GetCPUTime(void) const
int mbdyn_stop_at_end_of_time_step(void)
#define ASSERT(expression)
StepIntegrator * pDummySteps
GradientExpression< UnaryExpr< FuncSqrt, Expr > > sqrt(const GradientExpression< Expr > &u)
void SetOutputDriveHandler(const DriveHandler *pDH)
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
DriveCaller * pGetDriveCaller(void) const
void SetTime(const doublereal &dTime, const doublereal &dTimeStep=-1., const integer &iStep=-1, bool bServePending=true)
virtual doublereal dGetNewStepTime(StepIntegrator::StepChange currStep, doublereal iPerformedIters)=0
virtual bool Advance(void)
virtual DriveCaller * pCopy(void) const =0
virtual void SetDriveHandler(const DriveHandler *pDH)
static const doublereal dDefaultTol
void OutputEigenvectors(const VectorHandler *pBeta, const VectorHandler &R, const VectorHandler &I, const doublereal &dShiftR, const MatrixHandler *pVL, const MatrixHandler &VR, const std::vector< bool > &vOut, const unsigned uCurrEigSol, const int iResultsPrecision)
SolverType GetSolver(void) const
static std::stack< cleanup * > c
const doublereal * pdGetMat(void) const
virtual void PrintResidual(const VectorHandler &Res, integer iIterCnt) const
doublereal dMaxResidualDiff
Dof * pGetDofsList(void) const
StepIntegratorType DummyType
std::deque< MyVectorHandler * > qX
SolutionManager *const AllocateSchurSolman(integer iStates)
integer HowManyDofs(DofType who) const
virtual int GetWord(void)
NonlinearSolverTest::Type ResTest
virtual integer GetIntegratorNumPreviousStates(void) const
std::ostream & GetLogFile(void) const
std::string outputCounterPostfix
Preconditioner::PrecondType PcType
void Set(const DriveCaller *pDC)
doublereal dGet(const doublereal &dVar) const
MyVectorHandler * pXPrime
integer iGetWorkSpaceSize(void) const
virtual void PrintSolution(const VectorHandler &Sol, integer iIterCnt) const
TimeStepControl * ReadTimeStepData(Solver *s, MBDynParser &HP)
#define SAFENEWARR(pnt, item, sz)
Solver(MBDynParser &HP, const std::string &sInputFileName, const std::string &sOutputFileName, unsigned int nThreads, bool bParallel=false)
DriveCaller * GetDriveCaller(bool bDeferred=false)
doublereal dGetInitialMaxTimeStep() const
doublereal dLambdaFactMin
DriveCaller * pRhoAlgebraicDummy
virtual void Init(integer iMaxIterations, doublereal dMinTimeStep, const DriveOwner &MaxTimeStep, doublereal dInitialTimeStep)=0
void Attach(integer iSize, doublereal *pd, integer iMSize=0)
const char *const GetSolverName(void) const
void Eig(bool bNewLine=false)
static doublereal buf[BUFSIZE]
virtual doublereal * pdGetVec(void) const
integer iIterativeMaxSteps
struct Solver::EigenAnalysis::ARPACK arpack
virtual HighParser::ErrOut GetLineData(void) const
Table & GetSymbolTable(void) const
DriveCaller * pRhoAlgebraicRegular
virtual void Setup(void)=0
SolutionManager * pLocalSM
void OutputEigNaiveMatrices(const MatrixHandler *pmMatA, const MatrixHandler *pmMatB, const unsigned uCurrEigSol, const int iMatrixPrecision)
doublereal dDerivativesCoef
virtual VectorHandler & MatVecMul(VectorHandler &out, const VectorHandler &in) const
void CreatePartition(void)
#define DEBUGLCOUT(level, msg)
static int do_eig(const doublereal &b, const doublereal &re, const doublereal &im, const doublereal &h, doublereal &sigma, doublereal &omega, doublereal &csi, doublereal &freq)
virtual integer iGetNumRows(void) const
void mbdyn_set_stop_at_end_of_time_step(void)
virtual integer iGetNumRows(void) const =0
integer iGetNumDofs(void) const
virtual integer GetIntegratorNumUnknownStates(void) const
virtual doublereal GetIntegratorDSolTol(void) const
virtual doublereal GetReal(const doublereal &dDefval=0.0)