36 #ifndef _MATRIXEPETRASTRUCTURED_HPP_ 37 #define _MATRIXEPETRASTRUCTURED_HPP_ 39 #include <lifev/core/LifeV.hpp> 41 #include <lifev/core/array/MapEpetra.hpp> 42 #include <lifev/core/array/MapVector.hpp> 43 #include <lifev/core/array/MatrixEpetra.hpp> 44 #include <lifev/core/array/MatrixBlockStructure.hpp> 45 #include <lifev/core/array/MatrixEpetraStructuredView.hpp> 71 template <
typename DataType>
72 class MatrixEpetraStructured :
public MatrixEpetra<DataType>
76 typedef MatrixEpetraStructuredView<DataType> block_type;
77 typedef std::shared_ptr<block_type> block_ptrType;
83 MatrixEpetraStructured (
const MapEpetra& map,
int numEntries = 50,
bool ignoreNonLocalValues =
false );
90 MatrixEpetraStructured (
const MapVector<MapEpetra>& vector,
int numEntries = 50,
bool ignoreNonLocalValues =
false );
93 MatrixEpetraStructured (
const MatrixEpetra<DataType>& matrix );
96 MatrixEpetraStructured (
const MatrixEpetraStructured& matrix );
99 ~MatrixEpetraStructured();
111 void setBlockStructure (
const std::vector<UInt>& blockNumRows,
112 const std::vector<UInt>& blockNumColumns );
123 void setBlockStructure (
const MapVector<MapEpetra>& mapVector );
126 void setBlockStructure (
const MatrixBlockStructure& blockStructure );
129 void setBlockStructure (
const VectorBlockStructure& rowsBlockStructure,
130 const VectorBlockStructure& columnsBlockStructure );
133 void setBlockStructure (
const VectorBlockStructure& vectorBlockStructure );
145 UInt blockNumRows (
const UInt& rowIndex )
const;
151 UInt blockNumColumns (
const UInt& columnIndex )
const;
159 void blockView (
const UInt& rowIndex,
160 const UInt& columnIndex,
170 block_ptrType block (
const UInt& rowIndex,
const UInt& columnIndex );
173 VectorBlockStructure rowsBlockStructure()
const;
176 VectorBlockStructure columnsBlockStructure()
const;
179 MatrixBlockStructure blockStructure()
const;
188 std::shared_ptr<MatrixEpetraStructured<DataType> > transpose()
190 return std::static_pointer_cast<MatrixEpetraStructured<DataType> > (
this->MatrixEpetra<DataType>::transpose() );
197 MatrixBlockStructure M_blockStructure;
207 template <
typename DataType>
208 MatrixEpetraStructured<DataType>::MatrixEpetraStructured (
const MapEpetra& map,
int numEntries,
bool ignoreNonLocalValues ) :
209 MatrixEpetra<DataType> ( map, numEntries, ignoreNonLocalValues ),
210 M_blockStructure ( map )
217 template <
typename DataType>
218 MatrixEpetraStructured<DataType>::MatrixEpetraStructured (
const MapVector<MapEpetra>& vector,
int numEntries,
bool ignoreNonLocalValues ) :
219 MatrixEpetra<DataType> (
typename MatrixEpetra<DataType>::matrix_ptrtype() ), M_blockStructure ( vector )
221 ASSERT ( vector.nbMap() > 0 ,
"Map vector empty, impossible to construct a MatrixBlockMonolithicEpetra!" );
223 MapEpetra myMap ( vector.totalMap() );
225 this->mapPtr().reset (
new MapEpetra ( myMap ) );
226 this->matrixPtr().reset (
new typename MatrixEpetra<DataType>::matrix_type ( Copy, *myMap.map ( Unique ), numEntries, ignoreNonLocalValues ) );
230 template <
typename DataType>
231 MatrixEpetraStructured<DataType>::MatrixEpetraStructured (
const MatrixEpetra<DataType>& matrix ) :
232 MatrixEpetra<DataType> ( matrix ),
233 M_blockStructure ( matrix.map() )
236 template <
typename DataType>
237 MatrixEpetraStructured<DataType>::MatrixEpetraStructured (
const MatrixEpetraStructured& matrix ) :
238 MatrixEpetra<DataType> ( matrix ),
239 M_blockStructure ( matrix.M_blockStructure )
242 template <
typename DataType>
243 MatrixEpetraStructured<DataType>::~MatrixEpetraStructured()
249 template <
typename DataType>
251 MatrixEpetraStructured<DataType>::setBlockStructure (
const std::vector<UInt>& blockNumRows,
252 const std::vector<UInt>& blockNumColumns )
254 ASSERT ( blockNumRows.size() > 0,
"No way to build a matrix with 0 block rows" );
255 ASSERT ( blockNumColumns.size() > 0,
"No way to build a matrix with 0 block columns" );
258 M_blockStructure.setBlockStructure ( blockNumRows, blockNumColumns );
261 template <
typename DataType>
263 MatrixEpetraStructured<DataType>::setBlockStructure (
const MapVector<MapEpetra>& mapVector )
265 ASSERT ( mapVector.nbMap() > 0 ,
"Map vector empty, impossible to set the block structure" );
267 M_blockStructure.setBlockStructure ( mapVector );
269 ASSERT (
this->matrixPtr()->NumGlobalCols() == M_blockStructure.numRows(),
" Incompatible block structure (global size does not match) " );
270 ASSERT (
this->matrixPtr()->NumGlobalRows() == M_blockStructure.numColumns(),
" Incompatible block structure (global size does not match) " );
273 template <
typename DataType>
275 MatrixEpetraStructured<DataType>::setBlockStructure (
const MatrixBlockStructure& blockStructure )
277 M_blockStructure.setBlockStructure ( blockStructure );
280 template <
typename DataType>
282 MatrixEpetraStructured<DataType>::setBlockStructure (
const VectorBlockStructure& rowsBlockStructure,
283 const VectorBlockStructure& columnsBlockStructure )
285 M_blockStructure.setBlockStructure ( rowsBlockStructure, columnsBlockStructure );
288 template <
typename DataType>
290 MatrixEpetraStructured<DataType>::setBlockStructure (
const VectorBlockStructure& vectorBlockStructure )
292 M_blockStructure.setBlockStructure ( vectorBlockStructure, vectorBlockStructure );
298 template <
typename DataType>
300 MatrixEpetraStructured<DataType>::blockNumRows (
const UInt& rowIndex )
const 302 return M_blockStructure.blockNumRows ( rowIndex );
305 template <
typename DataType>
307 MatrixEpetraStructured<DataType>::blockNumColumns (
const UInt& columnIndex )
const 309 return M_blockStructure.blockNumColumns ( columnIndex );
312 template <
typename DataType>
314 MatrixEpetraStructured<DataType>::blockView (
const UInt& rowIndex,
315 const UInt& columnIndex,
318 mbv.setup ( M_blockStructure.rowBlockFirstIndex ( rowIndex ),
319 M_blockStructure.columnBlockFirstIndex ( columnIndex ),
320 M_blockStructure.blockNumRows ( rowIndex ),
321 M_blockStructure.blockNumColumns ( columnIndex ),
325 template <
typename DataType>
326 typename MatrixEpetraStructured<DataType>::block_ptrType
327 MatrixEpetraStructured<DataType>::block (
const UInt& rowIndex,
const UInt& columnIndex )
329 block_ptrType matrixBlockView (
new block_type );
331 matrixBlockView->setup ( M_blockStructure.rowBlockFirstIndex ( rowIndex ),
332 M_blockStructure.columnBlockFirstIndex ( columnIndex ),
333 M_blockStructure.blockNumRows ( rowIndex ),
334 M_blockStructure.blockNumColumns ( columnIndex ),
337 return matrixBlockView;
340 template <
typename DataType>
342 MatrixEpetraStructured<DataType>::rowsBlockStructure()
const 344 return M_blockStructure.rowsBlockStructure();
347 template <
typename DataType>
349 MatrixEpetraStructured<DataType>::columnsBlockStructure()
const 351 return M_blockStructure.columnsBlockStructure();
354 template <
typename DataType>
356 MatrixEpetraStructured<DataType>::blockStructure()
const 358 return M_blockStructure;
void assignFunction(bcBase_Type &base)
Assign the function to the base of the BCHandler.
uint32_type UInt
generic unsigned integer (used mainly for addressing)