coupling_matrix.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_COUPLING_MATRIX_H
21 #define LIBMESH_COUPLING_MATRIX_H
22 
23 // Local Includes
24 #include "libmesh/libmesh_common.h"
25 
26 // C++ includes
27 #include <vector>
28 
29 namespace libMesh
30 {
31 
32 
33 
34 
43 {
44 public:
45 
49  explicit
50  CouplingMatrix (const unsigned int n=0);
51 
55  unsigned char operator() (const unsigned int i,
56  const unsigned int j) const;
57 
62  unsigned char & operator() (const unsigned int i,
63  const unsigned int j);
64 
69  unsigned int size() const;
70 
75  void resize(const unsigned int n);
76 
80  void clear();
81 
85  bool empty() const;
86 
87 private:
88 
95  std::vector<unsigned char> _values;
96 
100  unsigned int _size;
101 };
102 
103 
104 
105 
106 
107 
108 //--------------------------------------------------
109 // CouplingMatrix inline methods
110 inline
111 CouplingMatrix::CouplingMatrix (const unsigned int n) :
112  _values(), _size(n)
113 {
114  this->resize(n);
115 }
116 
117 
118 
119 inline
120 unsigned char CouplingMatrix::operator() (const unsigned int i,
121  const unsigned int j) const
122 {
123  libmesh_assert_less (i, _size);
124  libmesh_assert_less (j, _size);
125 
126  return _values[i*_size + j];
127 }
128 
129 
130 
131 inline
132 unsigned char & CouplingMatrix::operator() (const unsigned int i,
133  const unsigned int j)
134 {
135  libmesh_assert_less (i, _size);
136  libmesh_assert_less (j, _size);
137 
138  return _values[i*_size + j];
139 }
140 
141 
142 
143 inline
144 unsigned int CouplingMatrix::size() const
145 {
146  return _size;
147 }
148 
149 
150 
151 inline
152 void CouplingMatrix::resize(const unsigned int n)
153 {
154  _size = n;
155 
156  _values.resize(_size*_size);
157 
158  for (unsigned int i=0; i<_values.size(); i++)
159  _values[i] = 0;
160 }
161 
162 
163 
164 inline
166 {
167  _size = 0;
168 
169  _values.clear();
170 }
171 
172 
173 
174 inline
176 {
177  return (_size == 0);
178 }
179 
180 
181 } // namespace libMesh
182 
183 
184 #endif // LIBMESH_COUPLING_MATRIX_H

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:04 UTC

Hosted By:
SourceForge.net Logo