OOFEM 3.0
Loading...
Searching...
No Matches
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 - 2025 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
40namespace oofem {
41SparseLinearSystemNM :: SparseLinearSystemNM(Domain *d, EngngModel *m) : NumericalMethod(d, m)
42{ }
43
44SparseLinearSystemNM :: ~SparseLinearSystemNM()
45{ }
46
47ConvergedReason SparseLinearSystemNM :: solve(SparseMtrx &A, FloatMatrix &B, FloatMatrix &X)
48{
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 != CR_CONVERGED ) {
64 return status;
65 }
66 X.setColumn(xi, i);
67 }
68 return status;
69}
70} // end namespace oofem
void copyColumn(FloatArray &dest, int c) const
void resize(Index rows, Index cols)
Definition floatmatrix.C:79
int giveNumberOfColumns() const
Returns number of columns of receiver.
void setColumn(const FloatArray &src, int c)
int giveNumberOfRows() const
Returns number of rows of receiver.
NumericalMethod(Domain *d, EngngModel *m)
Definition nummet.h:94
int giveNumberOfRows() const
Returns number of rows of receiver.
Definition sparsemtrx.h:114
#define OOFEM_ERROR(...)
Definition error.h:79
FloatArrayF< N > solve(FloatMatrixF< N, N > mtrx, const FloatArrayF< N > &b, double zeropiv=1e-20)

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011