OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
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 - 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 "spoolessparsemtrx.h"
36 #include "engngm.h"
37 #include "sparsemtrxtype.h"
38 #include "classfactory.h"
39 
40 namespace oofem {
41 REGISTER_SparseMtrx(SpoolesSparseMtrx, SMT_SpoolesMtrx);
42 
43 SparseMtrx *
45 {
46  OOFEM_ERROR("Not implemented");
47  return NULL;
48 }
49 
50 void
52 {
53  double alpha = 1.0, beta = 0.0;
54  int result;
55 
56  answer.resize( this->giveNumberOfColumns() );
57  answer.zero();
58 
59  if ( sflag == SPOOLES_SYMMETRIC ) {
60  result = InpMtx_sym_gmvm( this->mtrx, & beta, 1, answer.givePointer(), & alpha, 1, x.givePointer() );
61  } else if ( sflag == SPOOLES_NONSYMMETRIC ) {
62  result = InpMtx_nonsym_gmvm( this->mtrx, & beta, 1, answer.givePointer(), & alpha, 1, x.givePointer() );
63  } else {
64  OOFEM_ERROR("unsupported symmetry flag");
65  exit(1);
66  }
67 }
68 
69 void
71 {
72  OOFEM_ERROR("unsupported");
73 }
74 
75 void
77 {
78  double alpha = 1.0, beta = 0.0;
79  int result;
80  answer.resize( this->giveNumberOfRows() );
81  answer.zero();
82 
83  if ( sflag == SPOOLES_SYMMETRIC ) {
84  result = InpMtx_sym_gmvm( this->mtrx, & beta, 1, answer.givePointer(), & alpha, 1, x.givePointer() );
85  } else if ( sflag == SPOOLES_NONSYMMETRIC ) {
86  result = InpMtx_nonsym_gmvm_T( this->mtrx, & beta, 1, answer.givePointer(), & alpha, 1, x.givePointer() );
87  } else {
88  OOFEM_ERROR("unsupported symmetry flag");
89  }
90 
91  if ( result != 1 ) {
92  OOFEM_ERROR("error code from InpMtx_(non)sym_gmvm %d", result);
93  }
94 }
95 
96 int
98 {
99  // Determine number of equations and estimate number of nonzero entries
100  int neq = eModel->giveNumberOfDomainEquations(di, ut);
101  int nent = neq * 5;
102 
103 
104  this->mtrx = InpMtx_new();
105  InpMtx_init(this->mtrx, INPMTX_BY_ROWS, type, nent, neq);
106  nRows = nColumns = neq;
107  return true;
108 }
109 
110 int
112 {
113  int i, j, ac1, ac2, ndofe;
114 
115  ndofe = mat.giveNumberOfRows();
116 
117  for ( i = 1; i <= ndofe; i++ ) {
118  ac1 = loc.at(i);
119  if ( ac1 == 0 ) {
120  continue;
121  }
122 
123  for ( j = 1; j <= ndofe; j++ ) {
124  ac2 = loc.at(j);
125  if ( ac2 == 0 ) {
126  continue;
127  }
128 
129  if ( ac1 > ac2 ) {
130  continue;
131  }
132 
133  InpMtx_inputRealEntry( this->mtrx, ac1 - 1, ac2 - 1, mat.at(i, j) );
134  }
135  }
136 
137  // increment version
138  this->version++;
139  return 1;
140 }
141 
142 int
143 SpoolesSparseMtrx :: assemble(const IntArray &rloc, const IntArray &cloc, const FloatMatrix &mat)
144 {
145  int i, j, ii, jj, dim1, dim2;
146 
147  dim1 = mat.giveNumberOfRows();
148  dim2 = mat.giveNumberOfColumns();
149  for ( i = 1; i <= dim1; i++ ) {
150  ii = rloc.at(i);
151  if ( ii ) {
152  for ( j = 1; j <= dim2; j++ ) {
153  jj = cloc.at(j);
154  if ( jj ) {
155  InpMtx_inputRealEntry( this->mtrx, ii - 1, jj - 1, mat.at(i, j) );
156  }
157  }
158  }
159  }
160 
161  // increment version
162  this->version++;
163 
164  return 1;
165 }
166 
167 void
169 {
170  InpMtx_clearData(this->mtrx);
171 }
172 
173 double &
175 {
176  OOFEM_ERROR("unsupported");
177  abort();
178 }
179 
180 double
181 SpoolesSparseMtrx :: at(int i, int j) const
182 {
183  OOFEM_ERROR("unsupported");
184  return 0.0;
185 }
186 
187 void
189 {
190  InpMtx_writeStats(this->mtrx, stdout);
191 }
192 
193 void
195 {
196  InpMtx_writeForHumanEye(this->mtrx, stdout);
197 }
198 } // end namespace oofem
int giveNumberOfColumns() const
Returns number of columns of receiver.
Definition: floatmatrix.h:158
int nColumns
Number of columns.
Definition: sparsemtrx.h:69
virtual int giveNumberOfDomainEquations(int di, const UnknownNumberingScheme &num)
Returns number of equations for given domain in active (current time step) time step.
Definition: engngm.C:391
Spooles sparse mtrx representation.
virtual void zero()
Zeroes the receiver.
virtual int assemble(const IntArray &loc, const FloatMatrix &mat)
Assembles sparse matrix from contribution of local elements.
virtual void timesT(const FloatArray &x, FloatArray &answer) const
Evaluates .
virtual void printYourself() const
Prints receiver to stdout. Works only for relatively small matrices.
Class implementing an array of integers.
Definition: intarray.h:61
int & at(int i)
Coefficient access function.
Definition: intarray.h:103
int nRows
Number of rows.
Definition: sparsemtrx.h:67
virtual double & at(int i, int j)
Returns coefficient at position (i,j).
int giveNumberOfRows() const
Returns number of rows of receiver.
Definition: sparsemtrx.h:114
#define OOFEM_ERROR(...)
Definition: error.h:61
REGISTER_SparseMtrx(CompCol, SMT_CompCol)
Abstract base class allowing to control the way, how equations are assigned to individual DOFs...
virtual void printStatistics() const
Prints the receiver statistics (one-line) to stdout.
virtual SparseMtrx * GiveCopy() const
Returns a newly allocated copy of receiver.
double at(int i, int j) const
Coefficient access function.
Definition: floatmatrix.h:176
SparseMtrxVersionType version
Allows to track if receiver changes.
Definition: sparsemtrx.h:80
Class representing vector of real numbers.
Definition: floatarray.h:82
Implementation of matrix containing floating point numbers.
Definition: floatmatrix.h:94
void zero()
Zeroes all coefficients of receiver.
Definition: floatarray.C:658
const double * givePointer() const
Gives the pointer to the raw data, breaking encapsulation.
Definition: floatarray.h:469
virtual int buildInternalStructure(EngngModel *eModel, int di, const UnknownNumberingScheme &s)
Builds internal structure of receiver.
int giveNumberOfColumns() const
Returns number of columns of receiver.
Definition: sparsemtrx.h:116
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.
virtual void times(const FloatArray &x, FloatArray &answer) const
Evaluates .
int giveNumberOfRows() const
Returns number of rows of receiver.
Definition: floatmatrix.h:156
void resize(int s)
Resizes receiver towards requested size.
Definition: floatarray.C:631

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