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

View file

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