OOFEM 3.0
Loading...
Searching...
No Matches
spoolessparsemtrx.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 "spoolessparsemtrx.h"
36#include "engngm.h"
37#include "sparsemtrxtype.h"
38#include "classfactory.h"
39
40namespace oofem {
42
43void
44SpoolesSparseMtrx :: times(const FloatArray &x, FloatArray &answer) const
45{
46 double alpha = 1.0, beta = 0.0;
47 int result;
48
49 answer.resize( this->giveNumberOfColumns() );
50 answer.zero();
51
52 if ( sflag == SPOOLES_SYMMETRIC ) {
53 result = InpMtx_sym_gmvm( this->mtrx, & beta, 1, answer.givePointer(), & alpha, 1, x.givePointer() );
54 } else if ( sflag == SPOOLES_NONSYMMETRIC ) {
55 result = InpMtx_nonsym_gmvm( this->mtrx, & beta, 1, answer.givePointer(), & alpha, 1, x.givePointer() );
56 } else {
57 OOFEM_ERROR("unsupported symmetry flag");
58 exit(1);
59 }
60}
61
62void
63SpoolesSparseMtrx :: times(double x)
64{
65 OOFEM_ERROR("unsupported");
66}
67
68void
69SpoolesSparseMtrx :: timesT(const FloatArray &x, FloatArray &answer) const
70{
71 double alpha = 1.0, beta = 0.0;
72 int result;
73 answer.resize( this->giveNumberOfRows() );
74 answer.zero();
75
76 if ( sflag == SPOOLES_SYMMETRIC ) {
77 result = InpMtx_sym_gmvm( this->mtrx, & beta, 1, answer.givePointer(), & alpha, 1, x.givePointer() );
78 } else if ( sflag == SPOOLES_NONSYMMETRIC ) {
79 result = InpMtx_nonsym_gmvm_T( this->mtrx, & beta, 1, answer.givePointer(), & alpha, 1, x.givePointer() );
80 } else {
81 OOFEM_ERROR("unsupported symmetry flag");
82 }
83
84 if ( result != 1 ) {
85 OOFEM_ERROR("error code from InpMtx_(non)sym_gmvm %d", result);
86 }
87}
88
89int
90SpoolesSparseMtrx :: buildInternalStructure(EngngModel *eModel, int di, const UnknownNumberingScheme &s)
91{
92 // Determine number of equations and estimate number of nonzero entries
93 int neq = eModel->giveNumberOfDomainEquations(di, ut);
94 int nent = neq * 5;
95
96
97 this->mtrx = InpMtx_new();
98 InpMtx_init(this->mtrx, INPMTX_BY_ROWS, type, nent, neq);
99 nRows = nColumns = neq;
100 return true;
101}
102
103int
104SpoolesSparseMtrx :: assemble(const IntArray &loc, const FloatMatrix &mat)
105{
106 int ndofe = mat.giveNumberOfRows();
107
108 for ( int i = 1; i <= ndofe; i++ ) {
109 int ac1 = loc.at(i);
110 if ( ac1 == 0 ) {
111 continue;
112 }
113
114 for ( int j = 1; j <= ndofe; j++ ) {
115 int ac2 = loc.at(j);
116 if ( ac2 == 0 ) {
117 continue;
118 }
119
120 if ( ac1 > ac2 ) {
121 continue;
122 }
123
124 InpMtx_inputRealEntry( this->mtrx, ac1 - 1, ac2 - 1, mat.at(i, j) );
125 }
126 }
127
128 this->version++;
129 return 1;
130}
131
132int
133SpoolesSparseMtrx :: assemble(const IntArray &rloc, const IntArray &cloc, const FloatMatrix &mat)
134{
135 int dim1 = mat.giveNumberOfRows();
136 int dim2 = mat.giveNumberOfColumns();
137 for ( int i = 1; i <= dim1; i++ ) {
138 int ii = rloc.at(i);
139 if ( ii ) {
140 for ( int j = 1; j <= dim2; j++ ) {
141 int jj = cloc.at(j);
142 if ( jj ) {
143 InpMtx_inputRealEntry( this->mtrx, ii - 1, jj - 1, mat.at(i, j) );
144 }
145 }
146 }
147 }
148
149 this->version++;
150
151 return 1;
152}
153
154void
155SpoolesSparseMtrx :: zero()
156{
157 InpMtx_clearData(this->mtrx);
158}
159
160double &
161SpoolesSparseMtrx :: at(int i, int j)
162{
163 OOFEM_ERROR("unsupported");
164 abort();
165}
166
167double
168SpoolesSparseMtrx :: at(int i, int j) const
169{
170 OOFEM_ERROR("unsupported");
171 return 0.0;
172}
173
174void
175SpoolesSparseMtrx :: printStatistics() const
176{
177 InpMtx_writeStats(this->mtrx, stdout);
178}
179
180void
181SpoolesSparseMtrx :: printYourself() const
182{
183 InpMtx_writeForHumanEye(this->mtrx, stdout);
184}
185} // end namespace oofem
#define REGISTER_SparseMtrx(class, type)
virtual int giveNumberOfDomainEquations(int di, const UnknownNumberingScheme &num)
Definition engngm.C:452
void resize(Index s)
Definition floatarray.C:94
void zero()
Zeroes all coefficients of receiver.
Definition floatarray.C:683
const double * givePointer() const
Definition floatarray.h:506
int giveNumberOfColumns() const
Returns number of columns of receiver.
int giveNumberOfRows() const
Returns number of rows of receiver.
double at(std::size_t i, std::size_t j) const
int & at(std::size_t i)
Definition intarray.h:104
int nColumns
Number of columns.
Definition sparsemtrx.h:71
SparseMtrxVersionType version
Definition sparsemtrx.h:82
int giveNumberOfRows() const
Returns number of rows of receiver.
Definition sparsemtrx.h:114
int giveNumberOfColumns() const
Returns number of columns of receiver.
Definition sparsemtrx.h:116
int nRows
Number of rows.
Definition sparsemtrx.h:69
#define OOFEM_ERROR(...)
Definition error.h:79
@ SMT_SpoolesMtrx
Spooles sparse mtrx representation.

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