1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/libraries/libmbmath/ls.cc,v 1.24 2017/01/12 14:43:53 masarati Exp $ */
2 /*
3 * MBDyn (C) is a multibody analysis code.
4 * http://www.mbdyn.org
5 *
6 * Copyright (C) 1996-2017
7 *
8 * Pierangelo Masarati <masarati@aero.polimi.it>
9 * Paolo Mantegazza <mantegazza@aero.polimi.it>
10 *
11 * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
12 * via La Masa, 34 - 20156 Milano, Italy
13 * http://www.aero.polimi.it
14 *
15 * Changing this copyright notice is forbidden.
16 *
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation (version 2 of the License).
20 *
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 */
31
32 /* solution manager */
33
34 #include "mbconfig.h" /* This goes first in every *.c,*.cc file */
35
36 #include <string.h> /* for memset() */
37
38 #include <iostream>
39 #include <iomanip>
40
41 #include "solman.h"
42 #include "ls.h"
43
44 /* LinearSolver - begin */
45
LinearSolver(SolutionManager * psm)46 LinearSolver::LinearSolver(SolutionManager *psm)
47 : pSM(psm), bHasBeenReset(true), pdRhs(0), pdSol(0)
48 {
49 NO_OP;
50 }
51
~LinearSolver(void)52 LinearSolver::~LinearSolver(void)
53 {
54 NO_OP;
55 }
56
57 #ifdef DEBUG
58 void
IsValid(void) const59 LinearSolver::IsValid(void) const
60 {
61 ASSERT(pSM);
62 ASSERT(pdRhs);
63 ASSERT(pdSol);
64 }
65 #endif /* DEBUG */
66
67 void
Reset(void)68 LinearSolver::Reset(void)
69 {
70 bHasBeenReset = true;
71 }
72
73 void
SolveT(void) const74 LinearSolver::SolveT(void) const
75 {
76 silent_cerr("LinearSolver::SolveT() not supported" << std::endl);
77 throw ErrGeneric(MBDYN_EXCEPT_ARGS);
78 }
79
80 void
SetSolutionManager(SolutionManager * psm)81 LinearSolver::SetSolutionManager(SolutionManager *psm)
82 {
83 pSM = psm;
84 }
85
86 /* ritorna il puntatore al vettore del residuo */
87 doublereal *
pdGetResVec(void) const88 LinearSolver::pdGetResVec(void) const
89 {
90 return pdRhs;
91 }
92
93 /* sposta il puntatore al vettore del residuo */
94 doublereal *
pdSetResVec(doublereal * pd)95 LinearSolver::pdSetResVec(doublereal* pd)
96 {
97 doublereal *p = pdRhs;
98
99 pdRhs = pd;
100
101 return p;
102 }
103
104 /* ritorna il puntatore al vettore della soluzione */
105 doublereal *
pdGetSolVec(void) const106 LinearSolver::pdGetSolVec(void) const
107 {
108 return pdSol;
109 }
110
111 /* sposta il puntatore al vettore della soluzione */
112 doublereal *
pdSetSolVec(doublereal * pd)113 LinearSolver::pdSetSolVec(doublereal* pd)
114 {
115 doublereal *p = pdSol;
116
117 pdSol = pd;
118
119 return p;
120 }
121
122 void
MakeCompactForm(SparseMatrixHandler & mh,std::vector<doublereal> & Ax,std::vector<integer> & Ar,std::vector<integer> & Ac,std::vector<integer> & Ap) const123 LinearSolver::MakeCompactForm(SparseMatrixHandler& mh,
124 std::vector<doublereal>& Ax,
125 std::vector<integer>& Ar,
126 std::vector<integer>& Ac,
127 std::vector<integer>& Ap) const
128 {
129 NO_OP;
130 }
131
bGetConditionNumber(doublereal & dCond)132 bool LinearSolver::bGetConditionNumber(doublereal& dCond)
133 {
134 return false; // true means that the condition number was returned in dCond
135 }
136
137 /* LinearSolver - end */
138
139