OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
sparselinsystemnm.C
Go to the documentation of this file.
1 /*
2  *
3  * ##### ##### ###### ###### ### ###
4  * ## ## ## ## ## ## ## ### ##
5  * ## ## ## ## #### #### ## # ##
6  * ## ## ## ## ## ## ## ##
7  * ## ## ## ## ## ## ## ##
8  * ##### ##### ## ###### ## ##
9  *
10  *
11  * OOFEM : Object Oriented Finite Element Code
12  *
13  * Copyright (C) 1993 - 2013 Borek Patzak
14  *
15  *
16  *
17  * Czech Technical University, Faculty of Civil Engineering,
18  * Department of Structural Mechanics, 166 29 Prague, Czech Republic
19  *
20  * This library is free software; you can redistribute it and/or
21  * modify it under the terms of the GNU Lesser General Public
22  * License as published by the Free Software Foundation; either
23  * version 2.1 of the License, or (at your option) any later version.
24  *
25  * This program is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28  * Lesser General Public License for more details.
29  *
30  * You should have received a copy of the GNU Lesser General Public
31  * License along with this library; if not, write to the Free Software
32  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33  */
34 
35 #include "sparselinsystemnm.h"
36 #include "floatmatrix.h"
37 #include "floatarray.h"
38 #include "sparsemtrx.h"
39 
40 namespace oofem {
42 { }
43 
45 { }
46 
48 {
49  NM_Status status = NM_None;
50  int neq = A.giveNumberOfRows();
51  int nrhs = B.giveNumberOfColumns();
52  if ( A.giveNumberOfRows() != B.giveNumberOfRows() ) {
53  OOFEM_ERROR("A and B matrix mismatch");
54  }
55  FloatArray bi(neq), xi(neq);
56  if ( X.giveNumberOfRows() != neq || X.giveNumberOfColumns() != nrhs ) {
57  X.resize(neq, nrhs);
58  }
59  for ( int i = 1; i <= nrhs; ++i ) {
60  B.copyColumn(bi, i);
61  X.copyColumn(xi, i);
62  status = this->solve(A, bi, xi);
63  if ( status & NM_NoSuccess ) {
64  return status;
65  }
66  X.setColumn(xi, i);
67  }
68  return status;
69 }
70 } // end namespace oofem
int giveNumberOfColumns() const
Returns number of columns of receiver.
Definition: floatmatrix.h:158
virtual NM_Status solve(SparseMtrx &A, FloatArray &b, FloatArray &x)=0
Solves the given sparse linear system of equations .
Class and object Domain.
Definition: domain.h:115
Base class for all matrices stored in sparse format.
Definition: sparsemtrx.h:60
This base class is an abstraction for numerical algorithm.
Definition: nummet.h:80
unsigned long NM_Status
Mask defining NumMetod Status; which can be asked after finishing computation by Numerical Method...
Definition: nmstatus.h:44
#define NM_NoSuccess
Numerical method failed to solve problem.
Definition: nmstatus.h:48
SparseLinearSystemNM(Domain *d, EngngModel *m)
Constructor.
int giveNumberOfRows() const
Returns number of rows of receiver.
Definition: sparsemtrx.h:114
#define OOFEM_ERROR(...)
Definition: error.h:61
#define NM_None
Definition: nmstatus.h:46
Class representing vector of real numbers.
Definition: floatarray.h:82
Implementation of matrix containing floating point numbers.
Definition: floatmatrix.h:94
void resize(int rows, int cols)
Checks size of receiver towards requested bounds.
Definition: floatmatrix.C:1358
virtual ~SparseLinearSystemNM()
Destructor.
void copyColumn(FloatArray &dest, int c) const
Fetches the values from the specified column.
Definition: floatmatrix.C:662
void setColumn(const FloatArray &src, int c)
Sets the values of the matrix in specified column.
Definition: floatmatrix.C:648
Abstract base class representing the "problem" under consideration.
Definition: engngm.h:181
the oofem namespace is to define a context or scope in which all oofem names are defined.
int giveNumberOfRows() const
Returns number of rows of receiver.
Definition: floatmatrix.h:156

This page is part of the OOFEM documentation. Copyright (c) 2011 Borek Patzak
Project e-mail: info@oofem.org
Generated at Tue Jan 2 2018 20:07:31 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011