MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
ImplicitStepIntegrator Class Reference

#include <stepsol.h>

Inheritance diagram for ImplicitStepIntegrator:
Collaboration diagram for ImplicitStepIntegrator:

Public Member Functions

 ImplicitStepIntegrator (const integer MaxIt, const doublereal dT, const doublereal dSolutionTol, const integer stp, const integer sts, const bool bmod_res_test)
 
virtual ~ImplicitStepIntegrator (void)
 
virtual void EvalProd (doublereal Tau, const VectorHandler &f0, const VectorHandler &w, VectorHandler &z) const
 
virtual doublereal TestScale (const NonlinearSolverTest *pTest, doublereal &dCoef) const
 
- Public Member Functions inherited from StepIntegrator
 StepIntegrator (const integer MaxIt, const doublereal dT, const doublereal dSolutionTol, const integer stp, const integer sts)
 
virtual ~StepIntegrator (void)
 
void SetDataManager (DataManager *pDatMan)
 
virtual integer GetIntegratorNumPreviousStates (void) const
 
virtual integer GetIntegratorNumUnknownStates (void) const
 
virtual integer GetIntegratorMaxIters (void) const
 
virtual doublereal GetIntegratorDTol (void) const
 
virtual doublereal GetIntegratorDSolTol (void) const
 
virtual void OutputTypes (const bool fpred)
 
virtual void SetDriveHandler (const DriveHandler *pDH)
 
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
 
- Public Member Functions inherited from NonlinearProblem
virtual ~NonlinearProblem (void)
 
virtual void Residual (VectorHandler *pRes) const =0
 
virtual void Jacobian (MatrixHandler *pJac) const =0
 
virtual void Update (const VectorHandler *pSol) const =0
 

Protected Attributes

VectorHandlerpXCurr
 
VectorHandlerpXPrimeCurr
 
bool bModResTest
 
- Protected Attributes inherited from StepIntegrator
DataManagerpDM
 
const DataManager::DofVecTypepDofs
 
bool outputPred
 
integer MaxIters
 
doublereal dTol
 
doublereal dSolTol
 
integer steps
 
integer unkstates
 

Private Attributes

MyVectorHandler XTau
 
MyVectorHandler SavedState
 
MyVectorHandler SavedDerState
 
bool bEvalProdCalledFirstTime
 

Additional Inherited Members

- Public Types inherited from StepIntegrator
enum  { DIFFERENTIAL = 0, ALGEBRAIC = 1 }
 
enum  StepChange { NEWSTEP, REPEATSTEP }
 
- Protected Member Functions inherited from StepIntegrator
template<class T >
void UpdateLoop (const T *const t, void(T::*pUpd)(const int DCount, const DofOrder::Order Order, const VectorHandler *const pSol) const, const VectorHandler *const pSol=0) const
 

Detailed Description

Definition at line 151 of file stepsol.h.

Constructor & Destructor Documentation

ImplicitStepIntegrator::ImplicitStepIntegrator ( const integer  MaxIt,
const doublereal  dT,
const doublereal  dSolutionTol,
const integer  stp,
const integer  sts,
const bool  bmod_res_test 
)

Definition at line 124 of file stepsol.cc.

References NO_OP.

130 : StepIntegrator(MaxIt, dT, dSolutionTol, stp, sts),
132 pXCurr(0),
133 pXPrimeCurr(0),
134 bModResTest(bmod_res_test)
135 {
136  NO_OP;
137 }
StepIntegrator(const integer MaxIt, const doublereal dT, const doublereal dSolutionTol, const integer stp, const integer sts)
Definition: stepsol.cc:51
bool bEvalProdCalledFirstTime
Definition: stepsol.h:160
#define NO_OP
Definition: myassert.h:74
VectorHandler * pXPrimeCurr
Definition: stepsol.h:164
VectorHandler * pXCurr
Definition: stepsol.h:163
ImplicitStepIntegrator::~ImplicitStepIntegrator ( void  )
virtual

Definition at line 139 of file stepsol.cc.

References NO_OP.

140 {
141  NO_OP;
142 }
#define NO_OP
Definition: myassert.h:74

Member Function Documentation

void ImplicitStepIntegrator::EvalProd ( doublereal  Tau,
const VectorHandler f0,
const VectorHandler w,
VectorHandler z 
) const
virtual

Implements NonlinearProblem.

Definition at line 145 of file stepsol.cc.

References ASSERT, bEvalProdCalledFirstTime, copysign(), f0, grad::fabs(), VectorHandler::iGetSize(), VectorHandler::InnerProd(), VectorHandler::Norm(), StepIntegrator::pDM, pXCurr, pXPrimeCurr, VectorHandler::Reset(), MyVectorHandler::Reset(), NonlinearProblem::Residual(), MyVectorHandler::Resize(), SavedDerState, SavedState, VectorHandler::ScalarMul(), MyVectorHandler::ScalarMul(), NonlinearProblem::Update(), DataManager::Update(), and XTau.

147 {
148  /* matrix-free product
149  *
150  * J(XCurr) * w = -||w|| * (Res(XCurr + sigma * Tau * w/||w||) - f0) / (sigma * Tau)
151  *
152  */
154  XTau.Resize(w.iGetSize());
157  bEvalProdCalledFirstTime = false;
158  }
159 
160  SavedState = *pXCurr;
162 
163  /* if w = 0; J * w = 0 */
164  ASSERT(pDM != NULL);
165 
166  doublereal nw = w.Norm();
167  if (nw < std::numeric_limits<doublereal>::epsilon()) {
168  z.Reset();
169  return;
170  }
171  doublereal sigma = pXCurr->InnerProd(w);
172  sigma /= nw;
173  if (fabs(sigma) > std::numeric_limits<doublereal>::epsilon()) {
174  doublereal xx = (fabs( sigma) <= 1.) ? 1. : fabs(sigma);
175  Tau = copysign(Tau*xx, sigma);
176  }
177  Tau /= nw;
178 #ifdef DEBUG_ITERATIVE
179  std::cout << "Tau " << Tau << std::endl;
180 #endif /* DEBUG_ITERATIVE */
181 
182  XTau.Reset();
183  z.Reset();
184  XTau.ScalarMul(w, Tau);
185  Update(&XTau);
186 #ifdef USE_EXTERNAL
187  External::SendFreeze();
188 #endif /* USE_EXTERNAL */
189  /* deal with throwing elements: do not honor their requests while perfoming matrix free update */
190  try {
191  Residual(&z);
192  }
194  }
195  XTau.ScalarMul(XTau, -1.);
196 
197  /* riporta tutto nelle condizioni inziali */
198 #if 0
199  Update(&XTau);
200 #endif
201  *pXCurr = SavedState;
203  pDM->Update();
204  z -= f0;
205  z.ScalarMul(z, -1./Tau);
206 }
virtual void Reset(void)=0
bool bEvalProdCalledFirstTime
Definition: stepsol.h:160
static double * f0
virtual doublereal InnerProd(const VectorHandler &VH) const
Definition: vh.cc:269
virtual void Residual(VectorHandler *pRes) const =0
MyVectorHandler XTau
Definition: stepsol.h:157
virtual integer iGetSize(void) const =0
virtual doublereal Norm(void) const
Definition: vh.cc:262
GradientExpression< UnaryExpr< FuncFabs, Expr > > fabs(const GradientExpression< Expr > &u)
Definition: gradient.h:2973
virtual VectorHandler & ScalarMul(const VectorHandler &VH, const doublereal &d)
Definition: vh.cc:519
virtual void Resize(integer iSize)
Definition: vh.cc:347
DataManager * pDM
Definition: stepsol.h:93
MyVectorHandler SavedState
Definition: stepsol.h:158
doublereal copysign(doublereal x, doublereal y)
Definition: gradient.h:97
virtual VectorHandler & ScalarMul(const VectorHandler &VH, const doublereal &d)
Definition: vh.cc:145
VectorHandler * pXPrimeCurr
Definition: stepsol.h:164
VectorHandler * pXCurr
Definition: stepsol.h:163
MyVectorHandler SavedDerState
Definition: stepsol.h:159
#define ASSERT(expression)
Definition: colamd.c:977
virtual void Reset(void)
Definition: vh.cc:459
virtual void Update(void) const
Definition: dataman2.cc:2511
virtual void Update(const VectorHandler *pSol) const =0
double doublereal
Definition: colamd.c:52

Here is the call graph for this function:

doublereal ImplicitStepIntegrator::TestScale ( const NonlinearSolverTest pTest,
doublereal dCoef 
) const
virtual

Implements NonlinearProblem.

Reimplemented in StepNIntegrator, and DerivativeSolver.

Definition at line 210 of file stepsol.cc.

References ASSERT, bModResTest, DofOrder::DIFFERENTIAL, NonlinearSolverTest::dScaleCoef(), VectorHandler::iGetSize(), StepIntegrator::pDofs, and pXPrimeCurr.

Referenced by StepNIntegrator::TestScale().

211 {
212  dCoef = 1.;
213 
214  if (bModResTest) {
215 #ifdef USE_MPI
216 #warning "ImplicitStepIntegrator::TestScale() not available with Schur solution"
217 #endif /* USE_MPI */
218 
219  doublereal dXPr = 0.;
220 
221  DataManager::DofIterator_const CurrDof = pDofs->begin();
222 
223  for (int iCntp1 = 1; iCntp1 <= pXPrimeCurr->iGetSize();
224  iCntp1++, ++CurrDof)
225  {
226  ASSERT(CurrDof != pDofs->end());
227 
228  if (CurrDof->Order == DofOrder::DIFFERENTIAL) {
229  doublereal d = pXPrimeCurr->operator()(iCntp1);
230  doublereal d2 = d*d;
231 
232  doublereal ds = pTest->dScaleCoef(iCntp1);
233  doublereal ds2 = ds*ds;
234  d2 *= ds2;
235 
236  dXPr += d2;
237  }
238  /* else if ALGEBRAIC: non aggiunge nulla */
239  }
240 
241  return 1./(1. + dXPr);
242 
243  } else {
244  return 1.;
245  }
246 }
virtual integer iGetSize(void) const =0
const DataManager::DofVecType * pDofs
Definition: stepsol.h:94
VectorHandler * pXPrimeCurr
Definition: stepsol.h:164
DofVecType::const_iterator DofIterator_const
Definition: dataman.h:802
#define ASSERT(expression)
Definition: colamd.c:977
virtual const doublereal & dScaleCoef(const integer &iIndex) const
Definition: nonlin.cc:167
double doublereal
Definition: colamd.c:52

Here is the call graph for this function:

Member Data Documentation

bool ImplicitStepIntegrator::bEvalProdCalledFirstTime
mutableprivate

Definition at line 160 of file stepsol.h.

Referenced by EvalProd().

bool ImplicitStepIntegrator::bModResTest
protected

Definition at line 165 of file stepsol.h.

Referenced by TestScale().

MyVectorHandler ImplicitStepIntegrator::SavedDerState
mutableprivate

Definition at line 159 of file stepsol.h.

Referenced by EvalProd().

MyVectorHandler ImplicitStepIntegrator::SavedState
mutableprivate

Definition at line 158 of file stepsol.h.

Referenced by EvalProd().

MyVectorHandler ImplicitStepIntegrator::XTau
mutableprivate

Definition at line 157 of file stepsol.h.

Referenced by EvalProd().


The documentation for this class was generated from the following files: