/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA \*---------------------------------------------------------------------------*/ #include "simpleMatrix.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template Foam::simpleMatrix::simpleMatrix(const label mSize) : scalarMatrix(mSize), source_(mSize, pTraits::zero) {} template Foam::simpleMatrix::simpleMatrix ( const scalarMatrix& matrix, const Field& source ) : scalarMatrix(matrix), source_(source) {} template Foam::simpleMatrix::simpleMatrix(Istream& is) : scalarMatrix(is), source_(is) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template Foam::Field Foam::simpleMatrix::solve() const { scalarMatrix tmpMatrix = *this; Field sourceSol = source_; scalarMatrix::solve(tmpMatrix, sourceSol); return sourceSol; } template Foam::Field Foam::simpleMatrix::LUsolve() const { scalarMatrix luMatrix = *this; Field sourceSol = source_; scalarMatrix::LUsolve(luMatrix, sourceSol); return sourceSol; } // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template void Foam::simpleMatrix::operator=(const simpleMatrix& m) { if (this == &m) { FatalErrorIn("simpleMatrix::operator=(const simpleMatrix&)") << "Attempted assignment to self" << abort(FatalError); } if (n() != m.n()) { FatalErrorIn("simpleMatrix::operator=(const simpleMatrix&)") << "Different size matrices" << abort(FatalError); } if (source_.size() != m.source_.size()) { FatalErrorIn("simpleMatrix::operator=(const simpleMatrix&)") << "Different size source vectors" << abort(FatalError); } scalarMatrix::operator=(m); source_ = m.source_; } // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // template Foam::simpleMatrix Foam::operator+ ( const simpleMatrix& m1, const simpleMatrix& m2 ) { return simpleMatrix ( static_cast(m1) + static_cast(m2), m1.source_ + m2.source_ ); } template Foam::simpleMatrix Foam::operator- ( const simpleMatrix& m1, const simpleMatrix& m2 ) { return simpleMatrix ( static_cast(m1) - static_cast(m2), m1.source_ - m2.source_ ); } template Foam::simpleMatrix Foam::operator*(const scalar s, const simpleMatrix& m) { return simpleMatrix(s*m.matrix_, s*m.source_); } // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // template Foam::Ostream& Foam::operator<<(Ostream& os, const simpleMatrix& m) { os << static_cast(m) << nl << m.source_; return os; } // ************************************************************************* //