MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
solver.cc File Reference
#include "mbconfig.h"
#include "mbdefs.h"
#include <cstdlib>
#include <cstring>
#include <limits>
#include <ac/unistd.h>
#include <cerrno>
#include <csignal>
#include <cfloat>
#include <cmath>
#include <vector>
#include <algorithm>
#include "ac/sys_sysinfo.h"
#include "solver.h"
#include "dataman.h"
#include "mtdataman.h"
#include "thirdorderstepsol.h"
#include "nr.h"
#include "linesearch.h"
#include "bicg.h"
#include "gmres.h"
#include "solman.h"
#include "readlinsol.h"
#include "ls.h"
#include "naivewrap.h"
#include "Rot.hh"
#include "cleanup.h"
#include "drive_.h"
#include "TimeStepControl.h"
#include "solver_impl.h"
#include "ac/lapack.h"
#include "ac/arpack.h"
#include "eigjdqz.h"
Include dependency graph for solver.cc:

Go to the source code of this file.

Functions

int mbdyn_stop_at_end_of_iteration (void)
 
int mbdyn_stop_at_end_of_time_step (void)
 
void mbdyn_set_stop_at_end_of_iteration (void)
 
void mbdyn_set_stop_at_end_of_time_step (void)
 
void mbdyn_signal_init (int pre)
 
int mbdyn_reserve_stack (unsigned long size)
 
static int do_eig (const doublereal &b, const doublereal &re, const doublereal &im, const doublereal &h, doublereal &sigma, doublereal &omega, doublereal &csi, doublereal &freq)
 
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)
 

Function Documentation

static int do_eig ( const doublereal b,
const doublereal re,
const doublereal im,
const doublereal h,
doublereal sigma,
doublereal omega,
doublereal csi,
doublereal freq 
)
static

Definition at line 3922 of file solver.cc.

References copysign(), M_PI, and grad::sqrt().

Referenced by output_eigenvalues().

3926 {
3927  // denominator
3928  doublereal d = re + b;
3929  d *= d;
3930  d += im*im;
3931  d *= h/2.;
3932 
3933  // real & imag
3934  sigma = (re*re - b*b + im*im)/d;
3935  omega = 2.*b*im/d;
3936 
3937  // frequency and damping factor
3938  if (im != 0.) {
3939  d = sigma*sigma + omega*omega;
3940  if (d > std::numeric_limits<doublereal>::epsilon()) {
3941  csi = -100*sigma/sqrt(d);
3942 
3943  } else {
3944  csi = 0.;
3945  }
3946 
3947  freq = omega/(2*M_PI);
3948 
3949  } else {
3950  if (std::abs(sigma) < std::numeric_limits<doublereal>::epsilon()) {
3951  csi = 0.;
3952 
3953  } else {
3954  csi = -100.*copysign(1, sigma);
3955  }
3956 
3957  freq = 0.;
3958  }
3959 
3960  return 0;
3961 }
#define M_PI
Definition: gradienttest.cc:67
doublereal copysign(doublereal x, doublereal y)
Definition: gradient.h:97
GradientExpression< UnaryExpr< FuncSqrt, Expr > > sqrt(const GradientExpression< Expr > &u)
Definition: gradient.h:2974
double doublereal
Definition: colamd.c:52

Here is the call graph for this function:

int mbdyn_reserve_stack ( unsigned long  size)

Definition at line 254 of file solver.cc.

References buf.

Referenced by RTSolverBase::Init().

255 {
256  int buf[size];
257 
258 #ifdef HAVE_MEMSET
259  memset(buf, 0, size*sizeof(int));
260 #else /* !HAVE_MEMSET */
261  for (unsigned long i = 0; i < size; i++) {
262  buf[i] = 0;
263  }
264 #endif /* !HAVE_MEMSET */
265 
266 #ifdef HAVE_MLOCKALL
267  return mlockall(MCL_CURRENT | MCL_FUTURE);
268 #else /* !HAVE_MLOCKALL */
269  return 0;
270 #endif /* !HAVE_MLOCKALL */
271 }
static doublereal buf[BUFSIZE]
Definition: discctrl.cc:333
void mbdyn_set_stop_at_end_of_iteration ( void  )

Definition at line 192 of file solver.cc.

193 {
194 #ifdef HAVE_SIGNAL
195  ::mbdyn_keep_going = MBDYN_STOP_AT_END_OF_ITERATION;
196 #endif // HAVE_SIGNAL
197 }
void mbdyn_set_stop_at_end_of_time_step ( void  )

Definition at line 200 of file solver.cc.

Referenced by InverseSolver::Advance(), LoadIncNorm::AfterConvergence(), and ExtFileHandlerEDGE::Recv_pre().

201 {
202 #ifdef HAVE_SIGNAL
203  ::mbdyn_keep_going = MBDYN_STOP_AT_END_OF_TIME_STEP;
204 #endif // HAVE_SIGNAL
205 }
void mbdyn_signal_init ( int  pre)

Definition at line 208 of file solver.cc.

Referenced by InverseSolver::Prepare(), and Solver::Prepare().

209 {
210 #ifdef HAVE_SIGNAL
211 #if defined(__FreeBSD__)
212  __sighandler_t *hdl;
213 #else // ! defined(__FreeBSD__)
214  __sighandler_t hdl;
215 #endif // ! defined(__FreeBSD__)
216 
217  if (pre) {
218  hdl = mbdyn_really_exit_handler;
219 
220  } else {
221  hdl = mbdyn_modify_final_time_handler;
222  }
223  /*
224  * FIXME: don't do this if compiling with USE_RTAI
225  * Re FIXME: use sigaction() ...
226  */
227  ::mbdyn_sh_term = signal(SIGTERM, hdl);
228  if (::mbdyn_sh_term == SIG_IGN) {
229  signal(SIGTERM, SIG_IGN);
230  }
231 
232  ::mbdyn_sh_int = signal(SIGINT, hdl);
233  if (::mbdyn_sh_int == SIG_IGN) {
234  signal(SIGINT, SIG_IGN);
235  }
236 
237 #ifdef SIGHUP
238  ::mbdyn_sh_hup = signal(SIGHUP, hdl);
239  if (::mbdyn_sh_hup == SIG_IGN) {
240  signal(SIGHUP, SIG_IGN);
241  }
242 #endif // SIGHUP
243 
244 #ifdef SIGPIPE
245  ::mbdyn_sh_pipe = signal(SIGPIPE, hdl);
246  if (::mbdyn_sh_pipe == SIG_IGN) {
247  signal(SIGPIPE, SIG_IGN);
248  }
249 #endif // SIGPIPE
250 #endif /* HAVE_SIGNAL */
251 }
int mbdyn_stop_at_end_of_iteration ( void  )

Definition at line 172 of file solver.cc.

Referenced by ExtFileHandlerEDGE::CheckFlag(), LineSearchSolver::LineSearch(), ExtFileHandlerEDGE::Recv_pre(), ExtFileHandler::Recv_pre(), ExtFileHandlerEDGE::Send_pre(), ExtFileHandler::Send_pre(), ExtFileHandlerEDGE::SendFlag(), BiCGStab::Solve(), NewtonRaphsonSolver::Solve(), and Gmres::Solve().

173 {
174 #ifdef HAVE_SIGNAL
175  return ::mbdyn_keep_going >= MBDYN_STOP_AT_END_OF_ITERATION;
176 #else // ! HAVE_SIGNAL
177  return 0;
178 #endif // ! HAVE_SIGNAL
179 }
int mbdyn_stop_at_end_of_time_step ( void  )

Definition at line 182 of file solver.cc.

Referenced by InverseSolver::Advance(), Solver::Advance(), InverseSolver::Prepare(), Solver::Prepare(), and Solver::Start().

183 {
184 #ifdef HAVE_SIGNAL
185  return ::mbdyn_keep_going >= MBDYN_STOP_AT_END_OF_TIME_STEP;
186 #else // ! HAVE_SIGNAL
187  return 0;
188 #endif // ! HAVE_SIGNAL
189 }
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 
)
static

Definition at line 3965 of file solver.cc.

References do_eig(), Solver::EigenAnalysis::dParam, Solver::EigenAnalysis::dUpperFreq, grad::fabs(), DataManager::GetOutFile(), VectorHandler::iGetSize(), and R.

3972 {
3973  std::ostream& Out = pDM->GetOutFile();
3974 
3975  /* Output? */
3976  Out << "Mode n. " " " " Real " " " " Imag " " " " " " Damp % " " Freq Hz" << std::endl;
3977 
3978  integer iNVec = R.iGetSize();
3979 
3980  for (int iCnt = 1; iCnt <= iNVec; iCnt++) {
3981  doublereal b = pBeta ? (*pBeta)(iCnt) : 1.;
3982  doublereal re = R(iCnt) + dShiftR;
3983  doublereal im = I(iCnt);
3984  doublereal sigma;
3985  doublereal omega;
3986  doublereal csi;
3987  doublereal freq;
3988 
3989  if (iCnt < iLow || iCnt > iHigh) {
3990  vOut[iCnt - 1] = false;
3991  continue;
3992  }
3993 
3994  const doublereal& h = pEA->dParam;
3995  do_eig(b, re, im, h, sigma, omega, csi, freq);
3996 
3997  if (freq < pEA->dLowerFreq || freq > pEA->dUpperFreq) {
3998  vOut[iCnt - 1] = false;
3999  continue;
4000  }
4001 
4002  vOut[iCnt - 1] = true;
4003 
4004  Out << std::setw(8) << iCnt << ": "
4005  << std::setw(12) << sigma << " + " << std::setw(12) << omega << " j";
4006 
4007  if (fabs(csi) > std::numeric_limits<doublereal>::epsilon()) {
4008  Out << " " << std::setw(12) << csi;
4009  } else {
4010  Out << " " << std::setw(12) << 0.;
4011  }
4012 
4013  Out << " " << std::setw(12) << freq;
4014 
4015  Out << std::endl;
4016  }
4017 }
doublereal dParam
Definition: solver.h:158
doublereal dUpperFreq
Definition: solver.h:164
virtual integer iGetSize(void) const =0
GradientExpression< UnaryExpr< FuncFabs, Expr > > fabs(const GradientExpression< Expr > &u)
Definition: gradient.h:2973
std::ostream & GetOutFile(void) const
Definition: dataman.h:325
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
static int do_eig(const doublereal &b, const doublereal &re, const doublereal &im, const doublereal &h, doublereal &sigma, doublereal &omega, doublereal &csi, doublereal &freq)
Definition: solver.cc:3922
Mat3x3 R

Here is the call graph for this function: