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

#include <naivewrap.h>

Inheritance diagram for NaiveSparseSolutionManager:
Collaboration diagram for NaiveSparseSolutionManager:

Public Member Functions

 NaiveSparseSolutionManager (const integer Dim, const doublereal dMP=1.e-9, const ScaleOpt &scale=ScaleOpt())
 
virtual ~NaiveSparseSolutionManager (void)
 
virtual void MatrReset (void)
 
virtual void Solve (void)
 
virtual MatrixHandlerpMatHdl (void) const
 
virtual MyVectorHandlerpResHdl (void) const
 
virtual MyVectorHandlerpSolHdl (void) const
 
- Public Member Functions inherited from SolutionManager
 SolutionManager (void)
 
virtual ~SolutionManager (void)
 
virtual void LinkToSolution (VectorHandler &XCurr, VectorHandler &XPrimeCurr)
 
virtual void MatrInitialize (void)
 
virtual void SolveT (void)
 
doublerealpdSetResVec (doublereal *pd)
 
doublerealpdSetSolVec (doublereal *pd)
 
bool bGetConditionNumber (doublereal &dCond) const
 

Protected Member Functions

template<class MH >
void ScaleMatrixAndRightHandSide (MH &mh)
 
template<typename MH >
MatrixScale< MH > & GetMatrixScale ()
 
void ScaleSolution (void)
 

Protected Attributes

NaiveMatrixHandlerA
 
MyVectorHandler VH
 
ScaleOpt scale
 
MatrixScaleBasepMatScale
 
- Protected Attributes inherited from SolutionManager
LinearSolverpLS
 

Additional Inherited Members

- Public Types inherited from SolutionManager
enum  ScaleWhen { SCALEW_NEVER = 0, SCALEW_ONCE, SCALEW_ALWAYS }
 
enum  ScaleAlgorithm {
  SCALEA_NONE, SCALEA_UNDEF, SCALEA_ROW_MAX, SCALEA_ROW_SUM,
  SCALEA_COL_MAX, SCALEA_COL_SUM, SCALEA_LAPACK, SCALEA_ITERATIVE,
  SCALEA_ROW_MAX_COL_MAX
}
 
enum  ScaleFlags {
  SCALEF_DEFAULT = 0x0u, SCALEF_WARN = 0x1u, SCALEF_VERBOSE = 0x2u, SCALEF_COND_NUM_1 = 0x4u,
  SCALEF_COND_NUM_INF = 0x8u, SCALEF_COND_NUM = SCALEF_COND_NUM_1 | SCALEF_COND_NUM_INF
}
 

Detailed Description

Definition at line 75 of file naivewrap.h.

Constructor & Destructor Documentation

NaiveSparseSolutionManager::NaiveSparseSolutionManager ( const integer  Dim,
const doublereal  dMP = 1.e-9,
const ScaleOpt scale = ScaleOpt() 
)

Definition at line 151 of file naivewrap.cc.

References A, SolutionManager::ScaleOpt::algorithm, NaiveMatrixHandler::NaiveMatrixHandler(), NaiveMatrixHandler::NaiveSolver, MyVectorHandler::pdGetVec(), LinearSolver::pdSetResVec(), LinearSolver::pdSetSolVec(), SolutionManager::pLS, SAFENEWWITHCONSTRUCTOR, scale, SolutionManager::SCALEA_NONE, SolutionManager::SCALEA_UNDEF, SolutionManager::SCALEW_NEVER, LinearSolver::SetSolutionManager(), VH, and SolutionManager::ScaleOpt::when.

153 : A(0),
154 VH(Dim),
155 scale(s),
156 pMatScale(0)
157 {
158  switch (scale.algorithm) {
159  case SCALEA_NONE:
160  case SCALEA_UNDEF:
161  scale.when = SCALEW_NEVER; // Default scaling is not supported for this solver
162  break;
163 
164  default:
165  // Allocate MatrixScale<T> on demand
166  ;
167  }
168 
171 
174 
175  pLS->SetSolutionManager(this);
176 }
MatrixScaleBase * pMatScale
Definition: naivewrap.h:81
MyVectorHandler VH
Definition: naivewrap.h:78
void SetSolutionManager(SolutionManager *pSM)
Definition: ls.cc:81
doublereal * pdSetResVec(doublereal *pd)
Definition: ls.cc:95
doublereal * pdSetSolVec(doublereal *pd)
Definition: ls.cc:113
NaiveMatrixHandler * A
Definition: naivewrap.h:77
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
Definition: mynewmem.h:698
ScaleAlgorithm algorithm
Definition: solman.h:145
LinearSolver * pLS
Definition: solman.h:151
virtual doublereal * pdGetVec(void) const
Definition: vh.h:245

Here is the call graph for this function:

NaiveSparseSolutionManager::~NaiveSparseSolutionManager ( void  )
virtual

Definition at line 178 of file naivewrap.cc.

References A, pMatScale, and SAFEDELETE.

179 {
180  if (A != 0) {
181  SAFEDELETE(A);
182  A = 0;
183  }
184 
185  if (pMatScale != 0) {
187  }
188 }
MatrixScaleBase * pMatScale
Definition: naivewrap.h:81
NaiveMatrixHandler * A
Definition: naivewrap.h:77
#define SAFEDELETE(pnt)
Definition: mynewmem.h:710

Member Function Documentation

template<typename MH >
MatrixScale< MH > & NaiveSparseSolutionManager::GetMatrixScale ( )
protected

Definition at line 223 of file naivewrap.cc.

References MatrixScale< T >::Allocate(), pMatScale, and scale.

224 {
225  if (pMatScale == 0) {
227  }
228 
229  // Will throw std::bad_cast if the type does not match
230  return dynamic_cast<MatrixScale<MH>&>(*pMatScale);
231 }
MatrixScaleBase * pMatScale
Definition: naivewrap.h:81
static MatrixScale< T > * Allocate(const SolutionManager::ScaleOpt &scale)
Definition: dgeequ.h:313

Here is the call graph for this function:

void NaiveSparseSolutionManager::MatrReset ( void  )
virtual

Implements SolutionManager.

Reimplemented in NaiveSparsePermSolutionManager< T >.

Definition at line 191 of file naivewrap.cc.

References SolutionManager::pLS, and LinearSolver::Reset().

Referenced by NaiveSparsePermSolutionManager< T >::MatrReset().

192 {
193  pLS->Reset();
194 }
virtual void Reset(void)
Definition: ls.cc:68
LinearSolver * pLS
Definition: solman.h:151

Here is the call graph for this function:

MatrixHandler * NaiveSparseSolutionManager::pMatHdl ( void  ) const
virtual

Implements SolutionManager.

Definition at line 256 of file naivewrap.cc.

References A.

257 {
258  return A;
259 }
NaiveMatrixHandler * A
Definition: naivewrap.h:77
MyVectorHandler * NaiveSparseSolutionManager::pResHdl ( void  ) const
virtual

Implements SolutionManager.

Definition at line 263 of file naivewrap.cc.

References VH.

264 {
265  return &VH;
266 }
MyVectorHandler VH
Definition: naivewrap.h:78
MyVectorHandler * NaiveSparseSolutionManager::pSolHdl ( void  ) const
virtual

Implements SolutionManager.

Definition at line 270 of file naivewrap.cc.

References VH.

271 {
272  return &VH;
273 }
MyVectorHandler VH
Definition: naivewrap.h:78
template<class MH >
void NaiveSparseSolutionManager::ScaleMatrixAndRightHandSide ( MH &  mh)
protected

Definition at line 199 of file naivewrap.cc.

References MatrixScaleBase::bGetInitialized(), LinearSolver::bReset(), MatrixScale< T >::ComputeScaleFactors(), SolutionManager::pLS, MatrixScaleBase::Report(), scale, MatrixScale< T >::ScaleMatrix(), MatrixScaleBase::ScaleRightHandSide(), SolutionManager::SCALEW_ALWAYS, SolutionManager::SCALEW_NEVER, VH, and SolutionManager::ScaleOpt::when.

Referenced by Solve().

200 {
201  if (scale.when != SCALEW_NEVER) {
202  MatrixScale<MH>& rMatScale = GetMatrixScale<MH>();
203 
204  if (pLS->bReset()) {
205  if (!rMatScale.bGetInitialized()
207  // (re)compute
208  rMatScale.ComputeScaleFactors(mh);
209  }
210  // in any case scale matrix and right-hand-side
211  rMatScale.ScaleMatrix(mh);
212 
213  if (silent_err) {
214  rMatScale.Report(std::cerr);
215  }
216  }
217 
218  rMatScale.ScaleRightHandSide(VH);
219  }
220 }
MyVectorHandler VH
Definition: naivewrap.h:78
bool bGetInitialized() const
Definition: dgeequ.h:59
bool ComputeScaleFactors(const T &mh)
Definition: dgeequ.h:305
std::ostream & Report(std::ostream &os) const
Definition: dgeequ.cc:52
VectorHandler & ScaleRightHandSide(VectorHandler &bVH) const
Definition: dgeequ.h:216
LinearSolver * pLS
Definition: solman.h:151
bool bReset(void) const
Definition: ls.h:89
T & ScaleMatrix(T &mh) const
Definition: dgeequ.h:274

Here is the call graph for this function:

void NaiveSparseSolutionManager::ScaleSolution ( void  )
protected

Definition at line 234 of file naivewrap.cc.

References ASSERT, pMatScale, scale, MatrixScaleBase::ScaleSolution(), SolutionManager::SCALEW_NEVER, VH, and SolutionManager::ScaleOpt::when.

Referenced by Solve().

235 {
236  if (scale.when != SCALEW_NEVER) {
237  ASSERT(pMatScale != 0);
238  // scale solution
240  }
241 }
MatrixScaleBase * pMatScale
Definition: naivewrap.h:81
MyVectorHandler VH
Definition: naivewrap.h:78
#define ASSERT(expression)
Definition: colamd.c:977
VectorHandler & ScaleSolution(VectorHandler &xVH) const
Definition: dgeequ.h:225

Here is the call graph for this function:

void NaiveSparseSolutionManager::Solve ( void  )
virtual

Implements SolutionManager.

Reimplemented in NaiveSparsePermSolutionManager< T >.

Definition at line 245 of file naivewrap.cc.

References A, SolutionManager::pLS, ScaleMatrixAndRightHandSide(), ScaleSolution(), and LinearSolver::Solve().

246 {
248 
249  pLS->Solve();
250 
251  ScaleSolution();
252 }
void ScaleMatrixAndRightHandSide(MH &mh)
Definition: naivewrap.cc:199
NaiveMatrixHandler * A
Definition: naivewrap.h:77
virtual void Solve(void) const =0
LinearSolver * pLS
Definition: solman.h:151

Here is the call graph for this function:

Member Data Documentation

MatrixScaleBase* NaiveSparseSolutionManager::pMatScale
protected

Definition at line 81 of file naivewrap.h.

Referenced by GetMatrixScale(), ScaleSolution(), and ~NaiveSparseSolutionManager().

ScaleOpt NaiveSparseSolutionManager::scale
protected
MyVectorHandler NaiveSparseSolutionManager::VH
mutableprotected

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