30 template<
class Form,
class Type>
35 v_ =
new Type[size()];
42 template<
class Form,
class Type>
49 if (mRows_ < 0 || nCols_ < 0)
52 <<
"Incorrect m, n " << mRows_ <<
", " << nCols_
60 template<
class Form,
class Type>
67 if (mRows_ < 0 || nCols_ < 0)
70 <<
"Incorrect m, n " << mRows_ <<
", " << nCols_
78 const label mn = size();
79 for (
label i=0; i<mn; i++)
87 template<
class Form,
class Type>
94 if (mRows_ < 0 || nCols_ < 0)
97 <<
"Incorrect m, n " << mRows_ <<
", " << nCols_
105 const label mn = size();
106 for (
label i=0; i<mn; i++)
114 template<
class Form,
class Type>
125 const label mn = size();
126 for (
label i=0; i<mn; i++)
134 template<
class Form,
class Type>
135 template<
class Form2>
146 const label mn = size();
147 for (
label i=0; i<mn; i++)
155 template<
class Form,
class Type>
156 template<
class MatrixType>
167 for (
label i=0; i<mRows_; i++)
169 for (
label j=0; j<nCols_; j++)
171 (*this)(i,j) = Mb(i,j);
177 template<
class Form,
class Type>
178 template<
class MatrixType>
189 for (
label i=0; i<mRows_; i++)
191 for (
label j=0; j<nCols_; j++)
193 (*this)(i,j) = Mb(i,j);
201 template<
class Form,
class Type>
213 template<
class Form,
class Type>
227 template<
class Form,
class Type>
243 template<
class Form,
class Type>
251 for (
label i=0; i<minM; i++)
253 for (
label j=0; j<minN; j++)
255 newMatrix(i, j) = (*this)(i, j);
263 template<
class Form,
class Type>
269 for (
label i=0; i<m(); i++)
271 for (
label j=0; j<
n(); j++)
283 template<
class Form,
class Type>
289 <<
"Attempted assignment to self" 293 if (mRows_ != M.mRows_ || nCols_ != M.nCols_)
303 const label mn = size();
304 for (
label i=0; i<mn; i++)
312 template<
class Form,
class Type>
313 template<
class MatrixType>
314 void Foam::Matrix<Form, Type>::operator=
319 for (
label i=0; i<mRows_; i++)
321 for (
label j=0; j<nCols_; j++)
323 (*this)(i,j) = Mb(i,j);
329 template<
class Form,
class Type>
330 template<
class MatrixType>
331 void Foam::Matrix<Form, Type>::operator=
336 for (
label i=0; i<mRows_; i++)
338 for (
label j=0; j<nCols_; j++)
340 (*this)(i,j) = Mb(i,j);
346 template<
class Form,
class Type>
351 const label mn = size();
352 for (
label i=0; i<mn; i++)
360 template<
class Form,
class Type>
365 const label mn = size();
366 for (
label i=0; i<mn; i++)
376 template<
class Form,
class Type>
384 const Type* Mv = M.
v();
386 for (
label i=1; i<mn; i++)
388 if (Mv[i] > Mv[curMaxI])
408 template<
class Form,
class Type>
416 const Type* Mv = M.
v();
418 for (
label i=1; i<mn; i++)
420 if (Mv[i] < Mv[curMinI])
442 template<
class Form,
class Type>
445 Form nM(M.
m(), M.
n());
450 const Type* Mv = M.
v();
453 for (
label i=0; i<mn; i++)
463 template<
class Form,
class Type>
469 <<
"Attempt to add matrices with different numbers of rows: " 470 << A.
m() <<
", " << B.
m()
477 <<
"Attempt to add matrices with different numbers of columns: " 478 << A.
n() <<
", " << B.
n()
482 Form AB(A.
m(), A.
n());
485 const Type* Av = A.
v();
486 const Type* Bv = B.
v();
489 for (
label i=0; i<mn; i++)
491 ABv[i] = Av[i] + Bv[i];
498 template<
class Form,
class Type>
504 <<
"Attempt to add matrices with different numbers of rows: " 505 << A.
m() <<
", " << B.
m()
512 <<
"Attempt to add matrices with different numbers of columns: " 513 << A.
n() <<
", " << B.
n()
517 Form AB(A.
m(), A.
n());
520 const Type* Av = A.
v();
521 const Type* Bv = B.
v();
524 for (
label i=0; i<mn; i++)
526 ABv[i] = Av[i] - Bv[i];
533 template<
class Form,
class Type>
536 Form sM(M.
m(), M.
n());
541 const Type* Mv = M.
v();
544 for (
label i=0; i<mn; i++)
554 template<
class Form,
class Type>
557 Form sM(M.
m(), M.
n());
562 const Type* Mv = M.
v();
565 for (
label i=0; i<mn; i++)
575 template<
class Form,
class Type>
578 Form sM(M.
m(), M.
n());
583 const Type* Mv = M.
v();
586 for (
label i=0; i<mn; i++)
596 template<
class Form1,
class Form2,
class Type>
607 <<
"Attempt to multiply incompatible matrices:" <<
nl 608 <<
"Matrix A : " << A.m() <<
" x " << A.n() <<
nl 609 <<
"Matrix B : " << B.m() <<
" x " << B.n() <<
nl 610 <<
"In order to multiply matrices, columns of A must equal " 622 for (
label i=0; i<AB.m(); i++)
624 for (
label j=0; j<AB.n(); j++)
628 AB(i, j) += A(i,
k)*B(
k, j);
637 template<
class Form,
class Type>
644 if (M.n() !=
f.size())
647 <<
"Attempt to multiply incompatible matrix and field:" <<
nl 648 <<
"Matrix : " << M.m() <<
" x " << M.n() <<
nl 649 <<
"Field : " <<
f.size() <<
" rows" <<
nl 650 <<
"In order to multiply a matrix M and field f, " 651 "columns of M must equal rows of f" 658 for (
label i=0; i<M.m(); i++)
660 for (
label j=0; j<M.n(); j++)
662 Mf[i] +=
M(i, j)*
f[j];
label m() const
Return the number of rows in the block.
label n() const
Return the number of columns.
Abstract template class to provide the form resulting from.
tmp< fvMatrix< Type > > operator*(const volScalarField::Internal &, const fvMatrix< Type > &)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Form T() const
Return the transpose of the matrix.
label m() const
Return the number of rows in the block.
T & ref() const
Return non-const reference or generate a fatal error.
A templated block of an (m x n) matrix of type <MatrixType>.
void setSize(const label m, const label n)
Resize the matrix preserving the elements.
label k
Boltzmann constant.
tmp< fvMatrix< Type > > operator/(const fvMatrix< Type > &, const volScalarField::Internal &)
Matrix()
Null constructor.
label n() const
Return the number of columns in the block.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().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))
label size() const
Return the number of elements in matrix (m*n)
Pre-declare SubField and related Field type.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
tmp< fvMatrix< Type > > operator-(const fvMatrix< Type > &)
tmp< fvMatrix< Type > > operator+(const fvMatrix< Type > &, const fvMatrix< Type > &)
void clear()
Clear the Matrix, i.e. set sizes to zero.
errorManip< error > abort(error &err)
A templated (m x n) matrix of objects of <T>.
label n() const
Return the number of columns in the block.
void operator=(const mType &)
Assignment operator. Takes linear time.
label m() const
Return the number of rows.
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
A class for managing temporary objects.
const Type * v() const
Return element vector of the constant Matrix.
void transfer(mType &)
Transfer the contents of the argument Matrix into this Matrix.