Bugfix: simple matrix operations

This commit is contained in:
Hrvoje Jasak 2017-01-24 16:44:43 +00:00
parent 78a9142214
commit 5ad239d7ec
2 changed files with 28 additions and 15 deletions

View file

@ -258,8 +258,7 @@ public:
); );
// Destructor //- Destructor
virtual ~solver() virtual ~solver()
{} {}
@ -418,8 +417,7 @@ public:
); );
// Destructor //- Destructor
virtual ~smoother() virtual ~smoother()
{} {}
@ -556,8 +554,7 @@ public:
); );
// Destructor //- Destructor
virtual ~preconditioner() virtual ~preconditioner()
{} {}
@ -635,8 +632,7 @@ public:
} }
// Destructor //- Destructor
virtual ~lduMatrix(); virtual ~lduMatrix();
@ -700,6 +696,11 @@ public:
return (lowerPtr_); return (lowerPtr_);
} }
bool empty() const
{
return (!diagPtr_ && !lowerPtr_ && !upperPtr_);
}
bool diagonal() const bool diagonal() const
{ {
return (diagPtr_ && !lowerPtr_ && !upperPtr_); return (diagPtr_ && !lowerPtr_ && !upperPtr_);

View file

@ -143,6 +143,12 @@ void Foam::lduMatrix::negate()
void Foam::lduMatrix::operator+=(const lduMatrix& A) void Foam::lduMatrix::operator+=(const lduMatrix& A)
{ {
// Escape empty matrix
if (A.empty())
{
return;
}
if (A.diagPtr_) if (A.diagPtr_)
{ {
diag() += A.diag(); diag() += A.diag();
@ -211,6 +217,12 @@ void Foam::lduMatrix::operator+=(const lduMatrix& A)
void Foam::lduMatrix::operator-=(const lduMatrix& A) void Foam::lduMatrix::operator-=(const lduMatrix& A)
{ {
// Escape empty matrix
if (A.empty())
{
return;
}
if (A.diagPtr_) if (A.diagPtr_)
{ {
diag() -= A.diag(); diag() -= A.diag();