Commit cc1e03a8 authored by mattijs's avatar mattijs
Browse files

ENH: lduMatrix: added I/O

parent 47c87f48
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -25,6 +25,7 @@ License
#include "lduMatrix.H"
#include "IOstreams.H"
#include "Switch.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -116,17 +117,27 @@ Foam::lduMatrix::lduMatrix(lduMatrix& A, bool reUse)
}
Foam::lduMatrix::lduMatrix
(
const lduMesh& mesh,
Istream& is
)
Foam::lduMatrix::lduMatrix(const lduMesh& mesh, Istream& is)
:
lduMesh_(mesh),
lowerPtr_(new scalarField(is)),
diagPtr_(new scalarField(is)),
upperPtr_(new scalarField(is))
{}
lduMesh_(mesh)
{
Switch hasLow(is);
Switch hasDiag(is);
Switch hasUp(is);
if (hasLow)
{
lowerPtr_ = new scalarField(is);
}
if (hasDiag)
{
diagPtr_ = new scalarField(is);
}
if (hasUp)
{
upperPtr_ = new scalarField(is);
}
}
Foam::lduMatrix::~lduMatrix()
......@@ -252,25 +263,86 @@ const Foam::scalarField& Foam::lduMatrix::upper() const
Foam::Ostream& Foam::operator<<(Ostream& os, const lduMatrix& ldum)
{
if (ldum.lowerPtr_)
Switch hasLow = ldum.hasLower();
Switch hasDiag = ldum.hasDiag();
Switch hasUp = ldum.hasUpper();
os << hasLow << token::SPACE << hasDiag << token::SPACE
<< hasUp << token::SPACE;
if (hasLow)
{
os << ldum.lower();
}
if (hasDiag)
{
os << "Lower triangle = "
<< *ldum.lowerPtr_
<< endl << endl;
os << ldum.diag();
}
if (ldum.diagPtr_)
if (hasUp)
{
os << ldum.upper();
}
os.check("Ostream& operator<<(Ostream&, const lduMatrix&");
return os;
}
Foam::Ostream& Foam::operator<<(Ostream& os, const InfoProxy<lduMatrix>& ip)
{
const lduMatrix& ldum = ip.t_;
Switch hasLow = ldum.hasLower();
Switch hasDiag = ldum.hasDiag();
Switch hasUp = ldum.hasUpper();
os << "Lower:" << hasLow
<< " Diag:" << hasDiag
<< " Upper:" << hasUp << endl;
if (hasLow)
{
os << "lower:" << ldum.lower().size() << endl;
}
if (hasDiag)
{
os << "diag :" << ldum.diag().size() << endl;
}
if (hasUp)
{
os << "diagonal = "
<< *ldum.diagPtr_
<< endl << endl;
os << "upper:" << ldum.upper().size() << endl;
}
if (ldum.upperPtr_)
if (hasLow)
{
os << "lower contents:" << endl;
forAll(ldum.lower(), i)
{
os << "i:" << i << "\t" << ldum.lower()[i] << endl;
}
os << endl;
}
if (hasDiag)
{
os << "Upper triangle = "
<< *ldum.upperPtr_
<< endl << endl;
os << "diag contents:" << endl;
forAll(ldum.diag(), i)
{
os << "i:" << i << "\t" << ldum.diag()[i] << endl;
}
os << endl;
}
if (hasUp)
{
os << "upper contents:" << endl;
forAll(ldum.upper(), i)
{
os << "i:" << i << "\t" << ldum.upper()[i] << endl;
}
os << endl;
}
os.check("Ostream& operator<<(Ostream&, const lduMatrix&");
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -58,6 +58,7 @@ SourceFiles
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
#include "solverPerformance.H"
#include "InfoProxy.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -691,6 +692,16 @@ public:
tmp<Field<Type> > faceH(const tmp<Field<Type> >&) const;
// Info
//- Return info proxy.
// Used to print matrix information to a stream
InfoProxy<lduMatrix> info() const
{
return *this;
}
// Member operators
void operator=(const lduMatrix&);
......@@ -707,6 +718,7 @@ public:
// Ostream operator
friend Ostream& operator<<(Ostream&, const lduMatrix&);
friend Ostream& operator<<(Ostream&, const InfoProxy<lduMatrix>&);
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment