Matrix.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2019-2022 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::Matrix
29 
30 Description
31  A templated (m x n) matrix of objects of <T>.
32  The layout is (mRows x nCols) - row-major order:
33 
34  \verbatim
35  (0,0)
36  +---> j [nCols]
37  |
38  |
39  v
40  i [mRows]
41  \endverbatim
42 
43 SourceFiles
44  Matrix.C
45  MatrixI.H
46  MatrixIO.C
47 
48 \*---------------------------------------------------------------------------*/
49 
50 #ifndef Foam_Matrix_H
51 #define Foam_Matrix_H
52 
53 #include "uLabel.H"
54 #include "Pair.H"
55 #include "Field.H"
56 #include "autoPtr.H"
57 #include "complex.H"
58 
59 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60 
61 namespace Foam
62 {
63 
64 // Forward Declarations
65 template<class Form, class Type> class Matrix;
66 template<class MatrixType> class ConstMatrixBlock;
67 template<class MatrixType> class MatrixBlock;
68 
69 template<class Form, class Type>
71 
72 template<class Form, class Type>
73 Ostream& operator<<(Ostream& os, const Matrix<Form, Type>& mat);
74 
75 
76 /*---------------------------------------------------------------------------*\
77  Class Matrix Declaration
78 \*---------------------------------------------------------------------------*/
79 
80 template<class Form, class Type>
81 class Matrix
82 {
83  // Private Data
84 
85  //- Number of rows and columns in Matrix
86  label mRows_, nCols_;
87 
88  //- Vector of values of type Type
89  Type* __restrict__ v_;
90 
91 
92  // Private Member Functions
93 
94  //- Allocate storage for the contents
95  inline void doAlloc();
96 
97  //- Right-multiply Matrix by a column vector (A * x)
98  template<class ListType>
99  tmp<Field<Type>> AmulImpl(const ListType& x) const;
100 
101  //- Left-multiply Matrix by a row vector (x * A)
102  template<class ListType>
103  tmp<Field<Type>> TmulImpl(const ListType& x) const;
104 
105 
106 public:
107 
108  //- Matrix type
109  typedef Matrix<Form, Type> mType;
110 
111  //- Component type
112  typedef Type cmptType;
113 
114 
115  // Static Member Functions
117  //- Return a null Matrix
118  inline static const Matrix<Form, Type>& null();
119 
120 
121  // Iterators
122 
123  //- Random access iterator for traversing a Matrix
124  typedef Type* iterator;
125 
126  //- Random access iterator for traversing a Matrix
127  typedef const Type* const_iterator;
128 
129 
130  // Constructors
131 
132  //- Default construct (empty matrix)
133  inline Matrix() noexcept;
134 
135  //- Construct given number of rows/columns
136  Matrix(const label m, const label n);
138  //- Construct with given number of rows/columns
139  //- initializing all elements to zero
140  Matrix(const label m, const label n, const Foam::zero);
141 
142  //- Construct with given number of rows/columns
143  //- initializing all elements to the given value
144  Matrix(const label m, const label n, const Type& val);
145 
146  //- Construct given number of rows/columns
147  inline explicit Matrix(const labelPair& dims);
148 
149  //- Construct given number of rows/columns
150  //- initializing all elements to zero
151  inline Matrix(const labelPair& dims, const Foam::zero);
152 
153  //- Construct with given number of rows/columns
154  //- initializing all elements to the given value
155  inline Matrix(const labelPair& dims, const Type& val);
156 
157  //- Copy construct
158  Matrix(const Matrix<Form, Type>& mat);
159 
160  //- Move construct
161  Matrix(Matrix<Form, Type>&& mat);
162 
163  //- Copy constructor from Matrix of a different form
164  template<class Form2>
165  explicit Matrix(const Matrix<Form2, Type>& mat);
166 
167  //- Construct from a block of another Matrix
168  template<class MatrixType>
169  Matrix(const ConstMatrixBlock<MatrixType>& Mb);
170 
171  //- Construct from a block of another Matrix
172  template<class MatrixType>
173  Matrix(const MatrixBlock<MatrixType>& Mb);
174 
175  //- Construct from Istream.
176  explicit Matrix(Istream& is);
177 
178  //- Clone
179  inline autoPtr<mType> clone() const;
180 
181 
182  //- Destructor
183  ~Matrix();
184 
185 
186  // Member Functions
187 
188  // Access
189 
190  //- The number of rows
191  inline label m() const noexcept;
192 
193  //- The number of columns
194  inline label n() const noexcept;
195 
196  //- The number of elements in Matrix (m*n)
197  inline label size() const;
198 
199  //- Return row/column sizes
200  inline labelPair sizes() const;
201 
202  //- Return true if Matrix is empty (i.e., size() is zero)
203  inline bool empty() const noexcept;
204 
205  //- Return const pointer to the first data element, which can also
206  //- be used to address into Matrix contents
207  inline const Type* cdata() const noexcept;
208 
209  //- Return pointer to the first data element, which can also
210  //- be used to address into Matrix contents
211  inline Type* data() noexcept;
212 
213  //- Return pointer to the underlying array serving as data storage,
214  //- reinterpreted as byte data.
215  // \note Only meaningful for contiguous data
216  inline const char* cdata_bytes() const noexcept;
217 
218  //- Return pointer to the underlying array serving as data storage,
219  //- reinterpreted as byte data.
220  // \note Only meaningful for contiguous data
221  inline char* data_bytes() noexcept;
222 
223  //- Number of contiguous bytes for the Matrix data,
224  //- no runtime check that the type is actually contiguous
225  // \note Only meaningful for contiguous data
226  inline std::streamsize size_bytes() const noexcept;
227 
228  //- Number of contiguous bytes for the Matrix data,
229  //- runtime FatalError if type is not contiguous
230  std::streamsize byteSize() const;
231 
232  //- Return const pointer to data in the specified row
233  // Subscript checking only with FULLDEBUG
234  inline const Type* rowData(const label irow) const;
235 
236  //- Return pointer to data in the specified row
237  // Subscript checking only with FULLDEBUG
238  inline Type* rowData(const label irow);
239 
240  //- Linear addressing const element access
241  // Subscript checking only with FULLDEBUG
242  inline const Type& at(const label idx) const;
243 
244  //- Linear addressing element access
245  // Subscript checking only with FULLDEBUG
246  inline Type& at(const label idx);
247 
248  // Block Access (const)
249 
250  //- Return const column or column's subset of Matrix
251  // Return entire column by its index: M.subColumn(a);
252  // Return subset of a column starting from rowIndex: M.subColumn(a, b);
253  // Return subset of a column starting from rowIndex with szRows elems:
254  // M.subColumn(a, b, c);
256  (
257  const label colIndex,
258  const label rowIndex = 0,
259  label len = -1
260  ) const;
261 
262  //- Return const row or const row's subset of Matrix
263  // Return entire row by its index: M.subRow(a);
264  // Return subset of a row starting from columnIndex: M.subRow(a,b);
265  // Return subset of a row starting from columnIndex with szCols elems:
266  // M.subRow(a, b, c);
268  (
269  const label rowIndex,
270  const label colIndex = 0,
271  label len = -1
272  ) const;
273 
274  //- Return const sub-block of Matrix
275  // Sub-block starting at columnIndex & rowIndex indices
277  (
278  const label rowIndex,
279  const label colIndex,
280  label szRows = -1,
281  label szCols = -1
282  ) const;
283 
284  //- Access Field as a ConstMatrixBlock
285  template<class VectorSpace>
287  (
288  const label rowIndex,
289  const label colIndex
290  ) const;
291 
292  // Block Access (non-const)
293 
294  //- Return column or column's subset of Matrix
295  inline MatrixBlock<mType> subColumn
296  (
297  const label colIndex,
298  const label rowIndex = 0,
299  label len = -1
300  );
301 
302  //- Return row or row's subset of Matrix
303  inline MatrixBlock<mType> subRow
304  (
305  const label rowIndex,
306  const label colIndex = 0,
307  label len = -1
308  );
309 
310  //- Return sub-block of Matrix
311  inline MatrixBlock<mType> subMatrix
312  (
313  const label rowIndex,
314  const label colIndex,
315  label szRows = -1,
316  label szCols = -1
317  );
318 
319  //- Access Field as a MatrixBlock
320  template<class VectorSpace>
321  inline MatrixBlock<mType> block
322  (
323  const label rowIndex,
324  const label colIndex
325  );
326 
327  // Check
328 
329  //- Check index i is within valid range [0, m)
330  inline void checki(const label irow) const;
331 
332  //- Check index j is within valid range [0, n)
333  inline void checkj(const label jcol) const;
334 
335  //- Check that dimensions are positive, non-zero
336  inline void checkSize() const;
337 
338  //- True if all entries have identical values, and Matrix is non-empty
339  inline bool uniform() const;
340 
341  // Edit
342 
343  //- Clear Matrix, i.e. set sizes to zero
344  void clear();
345 
346  //- Release storage management of Matrix contents by transferring
347  //- management to a List
348  List<Type> release();
349 
350  //- Swap contents
351  void swap(Matrix<Form, Type>& mat);
352 
353  //- Transfer the contents of the argument Matrix into this Matrix
354  //- and annul the argument Matrix
355  void transfer(Matrix<Form, Type>& mat);
356 
357  //- Change Matrix dimensions, preserving the elements
358  void resize(const label m, const label n);
359 
360  //- Change Matrix dimensions \em without preserving existing content
361  void resize_nocopy(const label mrow, const label ncol);
362 
363  //- Change Matrix dimensions, preserving the elements
364  inline void setSize(const label m, const label n);
365 
366  //- Resize Matrix without reallocating storage (unsafe)
367  inline void shallowResize(const label m, const label n);
368 
369  //- Round elements with magnitude smaller than tol (SMALL) to zero
370  void round(const scalar tol = SMALL);
371 
372 
373  // Operations
374 
375  //- Return conjugate transpose of Matrix
376  Form T() const;
377 
378  //- Return non-conjugate transpose of Matrix
379  Form transpose() const;
380 
381  //- Right-multiply Matrix by a column vector (A * x)
382  inline tmp<Field<Type>> Amul(const UList<Type>& x) const;
383 
384  //- Right-multiply Matrix by a column vector (A * x)
385  template<class Addr>
386  inline tmp<Field<Type>> Amul
387  (
388  const IndirectListBase<Type, Addr>& x
389  ) const;
390 
391  //- Left-multiply Matrix by a row vector (x * A)
392  inline tmp<Field<Type>> Tmul(const UList<Type>& x) const;
393 
394  //- Left-multiply Matrix by a row vector (x * A)
395  template<class Addr>
396  inline tmp<Field<Type>> Tmul
397  (
398  const IndirectListBase<Type, Addr>& x
399  ) const;
400 
401  //- Extract the diagonal elements. Method may change in the future.
402  List<Type> diag() const;
403 
404  //- Assign diagonal of Matrix
405  void diag(const UList<Type>& list);
406 
407  //- Return the trace
408  Type trace() const;
409 
410  //- Return L2-Norm of chosen column
411  // Optional without sqrt for parallel usage.
412  scalar columnNorm(const label colIndex, const bool noSqrt=false) const;
413 
414  //- Return Frobenius norm of Matrix
415  // Optional without sqrt for parallel usage.
416  scalar norm(const bool noSqrt=false) const;
417 
418 
419  // Member Operators
420 
421  //- Return const pointer to data in the specified row - rowData().
422  // Subscript checking only with FULLDEBUG
423  inline const Type* operator[](const label irow) const;
424 
425  //- Return pointer to data in the specified row - rowData().
426  // Subscript checking only with FULLDEBUG
427  inline Type* operator[](const label irow);
428 
429  //- (i, j) const element access operator
430  // Subscript checking only with FULLDEBUG
431  inline const Type& operator()(const label irow, const label jcol) const;
432 
433  //- (i, j) element access operator
434  // Subscript checking only with FULLDEBUG
435  inline Type& operator()(const label irow, const label jcol);
436 
437  //- Copy assignment. Takes linear time.
438  void operator=(const Matrix<Form, Type>& mat);
439 
440  //- Move assignment
441  void operator=(Matrix<Form, Type>&& mat);
442 
443  //- Assignment to a block of another Matrix
444  template<class MatrixType>
445  void operator=(const ConstMatrixBlock<MatrixType>& Mb);
446 
447  //- Assignment to a block of another Matrix
448  template<class MatrixType>
449  void operator=(const MatrixBlock<MatrixType>& Mb);
450 
451  //- Assignment of all elements to zero
452  void operator=(const Foam::zero);
453 
454  //- Assignment of all elements to the given value
455  void operator=(const Type& val);
456 
457  //- Matrix addition
458  void operator+=(const Matrix<Form, Type>& other);
459 
460  //- Matrix subtraction
461  void operator-=(const Matrix<Form, Type>& other);
462 
463  //- Matrix scalar addition
464  void operator+=(const Type& s);
465 
466  //- Matrix scalar subtraction
467  void operator-=(const Type& s);
468 
469  //- Matrix scalar multiplication
470  void operator*=(const Type& s);
471 
472  //- Matrix scalar division
473  void operator/=(const Type& s);
474 
475 
476  // Random Access Iterator (non-const)
477 
478  //- Return an iterator to begin traversing a Matrix
479  inline iterator begin() noexcept;
480 
481  //- Return an iterator to end traversing a Matrix
482  inline iterator end() noexcept;
483 
484 
485  // Random Access Iterator (const)
486 
487  //- Return const_iterator to begin traversing a constant Matrix
488  inline const_iterator cbegin() const noexcept;
489 
490  //- Return const_iterator to end traversing a constant Matrix
491  inline const_iterator cend() const noexcept;
492 
493  //- Return const_iterator to begin traversing a constant Matrix
494  inline const_iterator begin() const noexcept;
495 
496  //- Return const_iterator to end traversing a constant Matrix
497  inline const_iterator end() const noexcept;
498 
499 
500  // IO
501 
502  //- Read Matrix from Istream, discarding existing contents.
503  bool readMatrix(Istream& is);
504 
505  //- Write Matrix, with line-breaks in ASCII when length exceeds
506  //- shortLen.
507  // Using '0' suppresses line-breaks entirely.
508  Ostream& writeMatrix(Ostream& os, const label shortLen=0) const;
509 
510 
511  // Housekeeping
512 
513  //- The number of rows - same as m()
514  inline label mRows() const noexcept
515  {
516  return mRows_;
517  }
518 
519  //- The number of rows - same as m()
520  inline label nRows() const noexcept
521  {
522  return mRows_;
523  }
524 
525  //- The number of columns - same as n()
526  inline label nCols() const noexcept
527  {
528  return nCols_;
529  }
530 
531 
532  //- Deprecated(2019-04) raw data pointer, const access
533  // \deprecated(2019-04) - use cdata() method
534  FOAM_DEPRECATED_FOR(2019-04, "cdata() method")
535  const Type* v() const
536  {
537  return v_;
538  }
539 
540  //- Deprecated(2019-04) raw data pointer, non-const access
541  // \deprecated(2019-04) - use data() method
542  FOAM_DEPRECATED_FOR(2019-04, "data() method")
543  Type* v()
544  {
545  return v_;
546  }
547 
548  //- Deprecated(2019-04) - use subMatrix()
549  // \deprecated(2019-04) - use subMatrix()
550  FOAM_DEPRECATED_FOR(2019-04, "subMatrix() method")
551  ConstMatrixBlock<mType> block
552  (
553  const label m,
554  const label n,
555  const label mStart,
556  const label nStart
557  ) const
558  {
559  return this->subMatrix(mStart, nStart, m, n);
560  }
561 
562  //- Deprecated(2019-04) - use subMatrix()
563  // \deprecated(2019-04) - use subMatrix()
564  FOAM_DEPRECATED_FOR(2019-04, "subMatrix() method")
565  MatrixBlock<mType> block
566  (
567  const label m,
568  const label n,
569  const label mStart,
570  const label nStart
571  )
572  {
573  return this->subMatrix(mStart, nStart, m, n);
574  }
575 
576 
577  //- Deprecated(2019-04) - use subColumn()
578  // \deprecated(2019-04) - use subColumn()
579  FOAM_DEPRECATED_FOR(2019-04, "subColumn() method")
580  ConstMatrixBlock<mType> col
581  (
582  const label m,
583  const label mStart,
584  const label nStart
585  ) const
586  {
587  return this->subColumn(nStart, mStart, m);
588  }
589 
590  //- Deprecated(2019-04) - use subColumn()
591  // \deprecated(2019-04) - use subColumn()
592  FOAM_DEPRECATED_FOR(2019-04, "subColumn() method")
593  MatrixBlock<mType> col
594  (
595  const label m,
596  const label mStart,
597  const label nStart
598  )
599  {
600  return this->subColumn(nStart, mStart, m);
601  }
602 
603  //- Deleted(2019-04) - use subColumn()
604  // \deprecated(2019-04) - use subColumn()
605  void col(const label m, const label rowStart) const = delete;
606 
607  //- Deleted(2019-04) - use subColumn()
608  // \deprecated(2019-04) - use subColumn()
609  void col(const label m, const label rowStart) = delete;
610 };
611 
612 
613 // * * * * * * * * * * * * * * * IOstream Operator * * * * * * * * * * * * * //
614 
615 //- Read Matrix from Istream, discarding contents of existing Matrix.
616 template<class Form, class Type>
617 Istream& operator>>(Istream& is, Matrix<Form, Type>& mat)
618 {
619  mat.readMatrix(is);
620  return is;
621 }
622 
623 
624 //- Write Matrix to Ostream, as per Matrix::writeMatrix() with
625 //- default length, which is given by Detail::ListPolicy::short_length
626 template<class Form, class Type>
627 Ostream& operator<<(Ostream& os, const Matrix<Form, Type>& mat)
628 {
629  return mat.writeMatrix(os, Detail::ListPolicy::short_length<Type>::value);
630 }
631 
632 
633 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
634 
635 } // End namespace Foam
636 
637 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
638 
639 #include "MatrixI.H"
640 
641 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
642 
643 #ifdef NoRepository
644  #include "Matrix.C"
645  #include "MatrixIO.C"
646 #endif
647 
648 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
649 
650 #endif
651 
652 // ************************************************************************* //
void shallowResize(const label m, const label n)
Resize Matrix without reallocating storage (unsafe)
Definition: MatrixI.H:475
void resize(const label m, const label n)
Change Matrix dimensions, preserving the elements.
Definition: Matrix.C:318
ConstMatrixBlock< mType > subColumn(const label colIndex, const label rowIndex=0, label len=-1) const
Return const column or column&#39;s subset of Matrix.
Definition: MatrixI.H:282
ConstMatrixBlock< mType > subRow(const label rowIndex, const label colIndex=0, label len=-1) const
Return const row or const row&#39;s subset of Matrix.
Definition: MatrixI.H:307
autoPtr< mType > clone() const
Clone.
Definition: MatrixI.H:73
tmp< Field< Type > > Tmul(const UList< Type > &x) const
Left-multiply Matrix by a row vector (x * A)
Definition: MatrixI.H:505
Form T() const
Return conjugate transpose of Matrix.
Definition: Matrix.C:386
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
tmp< Field< Type > > Amul(const UList< Type > &x) const
Right-multiply Matrix by a column vector (A * x)
Definition: MatrixI.H:484
scalar columnNorm(const label colIndex, const bool noSqrt=false) const
Return L2-Norm of chosen column.
Definition: Matrix.C:474
label n() const noexcept
The number of columns.
Definition: MatrixI.H:96
Templated vector space.
Definition: VectorSpace.H:52
A templated block of an (m x n) matrix of type <MatrixType>.
Definition: Matrix.H:62
void setSize(const label m, const label n)
Change Matrix dimensions, preserving the elements.
Definition: MatrixI.H:468
List< Type > release()
Release storage management of Matrix contents by transferring management to a List.
Definition: Matrix.C:264
iterator begin() noexcept
Return an iterator to begin traversing a Matrix.
Definition: MatrixI.H:528
Base for lists with indirect addressing, templated on the list contents type and the addressing type...
void transfer(Matrix< Form, Type > &mat)
Transfer the contents of the argument Matrix into this Matrix and annul the argument Matrix...
Definition: Matrix.C:298
bool empty() const noexcept
Return true if Matrix is empty (i.e., size() is zero)
Definition: MatrixI.H:117
bool readMatrix(Istream &is)
Read Matrix from Istream, discarding existing contents.
Definition: MatrixIO.C:45
ConstMatrixBlock< mType > subMatrix(const label rowIndex, const label colIndex, label szRows=-1, label szCols=-1) const
Return const sub-block of Matrix.
Definition: MatrixI.H:332
class FOAM_DEPRECATED_FOR(2017-05, "Foam::Enum") NamedEnum
Definition: NamedEnum.H:65
label nCols() const noexcept
The number of columns - same as n()
Definition: Matrix.H:736
char * data_bytes() noexcept
Return pointer to the underlying array serving as data storage, reinterpreted as byte data...
Definition: MatrixI.H:216
Ostream & writeMatrix(Ostream &os, const label shortLen=0) const
Write Matrix, with line-breaks in ASCII when length exceeds shortLen.
Definition: MatrixIO.C:136
static const Matrix< Form, Type > & null()
Return a null Matrix.
Definition: MatrixI.H:82
label size() const
The number of elements in Matrix (m*n)
Definition: MatrixI.H:103
Type trace() const
Return the trace.
Definition: Matrix.C:457
Generic templated field type.
Definition: Field.H:62
const Type & at(const label idx) const
Linear addressing const element access.
Definition: MatrixI.H:250
List< Type > diag() const
Extract the diagonal elements. Method may change in the future.
Definition: Matrix.C:420
Type * iterator
Random access iterator for traversing a Matrix.
Definition: Matrix.H:137
label nRows() const noexcept
The number of rows - same as m()
Definition: Matrix.H:728
labelPair sizes() const
Return row/column sizes.
Definition: MatrixI.H:110
Istream & operator>>(Istream &, directionInfo &)
iterator end() noexcept
Return an iterator to end traversing a Matrix.
Definition: MatrixI.H:536
scalar norm(const bool noSqrt=false) const
Return Frobenius norm of Matrix.
Definition: Matrix.C:491
void clear()
Clear Matrix, i.e. set sizes to zero.
Definition: Matrix.C:250
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:99
const Type * cdata() const noexcept
Return const pointer to the first data element, which can also be used to address into Matrix content...
Definition: MatrixI.H:195
label m() const noexcept
The number of rows.
Definition: MatrixI.H:89
void checki(const label irow) const
Check index i is within valid range [0, m)
Definition: MatrixI.H:124
void swap(Matrix< Form, Type > &mat)
Swap contents.
Definition: Matrix.C:284
A templated (m x n) matrix of objects of <T>. The layout is (mRows x nCols) - row-major order: ...
Creates a single block of cells from point coordinates, numbers of cells in each direction and an exp...
Definition: block.H:54
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:55
const direction noexcept
Definition: Scalar.H:258
Type cmptType
Component type.
Definition: Matrix.H:121
std::streamsize size_bytes() const noexcept
Number of contiguous bytes for the Matrix data, no runtime check that the type is actually contiguous...
Definition: MatrixI.H:223
OBJstream os(runTime.globalPath()/outputName)
Database for solution data, solver performance and other reduced data.
Definition: data.H:52
const char * cdata_bytes() const noexcept
Return pointer to the underlying array serving as data storage, reinterpreted as byte data...
Definition: MatrixI.H:209
const Type * const_iterator
Random access iterator for traversing a Matrix.
Definition: Matrix.H:142
std::streamsize byteSize() const
Number of contiguous bytes for the Matrix data, runtime FatalError if type is not contiguous...
Definition: Matrix.C:505
const Type * v() const
Deprecated(2019-04) raw data pointer, const access.
Definition: Matrix.H:748
const_iterator cend() const noexcept
Return const_iterator to end traversing a constant Matrix.
Definition: MatrixI.H:552
const Type * rowData(const label irow) const
Return const pointer to data in the specified row.
Definition: MatrixI.H:230
label mRows() const noexcept
The number of rows - same as m()
Definition: Matrix.H:720
Matrix< Form, Type > mType
Matrix type.
Definition: Matrix.H:116
Form transpose() const
Return non-conjugate transpose of Matrix.
Definition: Matrix.C:403
void checkj(const label jcol) const
Check index j is within valid range [0, n)
Definition: MatrixI.H:142
Matrix() noexcept
Default construct (empty matrix)
Definition: MatrixI.H:42
void round(const scalar tol=SMALL)
Round elements with magnitude smaller than tol (SMALL) to zero.
Definition: Matrix.C:373
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
const_iterator cbegin() const noexcept
Return const_iterator to begin traversing a constant Matrix.
Definition: MatrixI.H:544
void resize_nocopy(const label mrow, const label ncol)
Change Matrix dimensions without preserving existing content.
Definition: Matrix.C:343
A class for managing temporary objects.
Definition: HashPtrTable.H:50
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
ConstMatrixBlock< mType > col(const label m, const label mStart, const label nStart) const
Deprecated(2019-04) - use subColumn()
Definition: Matrix.H:806
ConstMatrixBlock< mType > block(const label rowIndex, const label colIndex) const
Access Field as a ConstMatrixBlock.
Namespace for OpenFOAM.
void checkSize() const
Check that dimensions are positive, non-zero.
Definition: MatrixI.H:160