/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation \\/ 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 3 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, see . \*---------------------------------------------------------------------------*/ #include "LLTMatrix.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template Foam::LLTMatrix::LLTMatrix() {} template Foam::LLTMatrix::LLTMatrix(const SquareMatrix& M) { decompose(M); } // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // template void Foam::LLTMatrix::decompose(const SquareMatrix& M) { SquareMatrix& LLT = *this; // Initialise the LLT decomposition matrix to M LLT = M; const label m = LLT.m(); for (label i=0; i i) { LLT(i, j) = Zero; continue; } Type sum = LLT(i, j); for (label k=0; k j) { LLT(i, j) = sum/LLT(j, j); } else if (sum > 0) { LLT(i, i) = sqrt(sum); } else { FatalErrorInFunction << "Cholesky decomposition failed, " "matrix is not symmetric positive definite" << abort(FatalError); } } } } template void Foam::LLTMatrix::solve ( Field& x, const Field& source ) const { // If x and source are different initialise x = source if (&x != &source) { x = source; } const SquareMatrix& LLT = *this; const label m = LLT.m(); for (label i=0; i= 0; i--) { Type sum = x[i]; for (label j=i + 1; j Foam::tmp> Foam::LLTMatrix::solve ( const Field& source ) const { tmp> tx(new Field(this->m())); Field& x = tx.ref(); solve(x, source); return tx; } // ************************************************************************* //