1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "lduMatrix.H"
28 #include "IOstreams.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 defineTypeNameAndDebug(lduMatrix, 1);
37 const Foam::scalar Foam::lduMatrix::great_ = 1.0e+20;
38 const Foam::scalar Foam::lduMatrix::small_ = 1.0e-20;
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 Foam::lduMatrix::lduMatrix(const lduMesh& mesh)
52 Foam::lduMatrix::lduMatrix(const lduMatrix& A)
61 lowerPtr_ = new scalarField(*(A.lowerPtr_));
66 diagPtr_ = new scalarField(*(A.diagPtr_));
71 upperPtr_ = new scalarField(*(A.upperPtr_));
76 Foam::lduMatrix::lduMatrix(lduMatrix& A, bool reUse)
87 lowerPtr_ = A.lowerPtr_;
93 diagPtr_ = A.diagPtr_;
99 upperPtr_ = A.upperPtr_;
107 lowerPtr_ = new scalarField(*(A.lowerPtr_));
112 diagPtr_ = new scalarField(*(A.diagPtr_));
117 upperPtr_ = new scalarField(*(A.upperPtr_));
123 Foam::lduMatrix::lduMatrix
130 lowerPtr_(new scalarField(is)),
131 diagPtr_(new scalarField(is)),
132 upperPtr_(new scalarField(is))
136 Foam::lduMatrix::~lduMatrix()
155 Foam::scalarField& Foam::lduMatrix::lower()
161 lowerPtr_ = new scalarField(*upperPtr_);
165 lowerPtr_ = new scalarField(lduAddr().lowerAddr().size(), 0.0);
173 Foam::scalarField& Foam::lduMatrix::diag()
177 diagPtr_ = new scalarField(lduAddr().size(), 0.0);
184 Foam::scalarField& Foam::lduMatrix::upper()
190 upperPtr_ = new scalarField(*lowerPtr_);
194 upperPtr_ = new scalarField(lduAddr().lowerAddr().size(), 0.0);
202 const Foam::scalarField& Foam::lduMatrix::lower() const
204 if (!lowerPtr_ && !upperPtr_)
206 FatalErrorIn("lduMatrix::lower() const")
207 << "lowerPtr_ or upperPtr_ unallocated"
208 << abort(FatalError);
222 const Foam::scalarField& Foam::lduMatrix::diag() const
226 FatalErrorIn("const scalarField& lduMatrix::diag() const")
227 << "diagPtr_ unallocated"
228 << abort(FatalError);
235 const Foam::scalarField& Foam::lduMatrix::upper() const
237 if (!lowerPtr_ && !upperPtr_)
239 FatalErrorIn("lduMatrix::upper() const")
240 << "lowerPtr_ or upperPtr_ unallocated"
241 << abort(FatalError);
255 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
257 Foam::Ostream& Foam::operator<<(Ostream& os, const lduMatrix& ldum)
261 os << "Lower triangle = "
275 os << "Upper triangle = "
280 os.check("Ostream& operator<<(Ostream&, const lduMatrix&");
286 // ************************************************************************* //