Commit 530df21a authored by Reuther, Sebastian's avatar Reuther, Sebastian

fixed memory leak problem in PetscSolverGlobalMatrix::solvePetscMatrix() if...

fixed memory leak problem in PetscSolverGlobalMatrix::solvePetscMatrix() if initfile option to remove contant nullspace is used
parent e3884e2e
...@@ -408,6 +408,7 @@ namespace AMDiS { namespace Parallel { ...@@ -408,6 +408,7 @@ namespace AMDiS { namespace Parallel {
MatNullSpace matNullspace; MatNullSpace matNullspace;
Vec nullspaceBasis; Vec nullspaceBasis;
SystemVector *basisVec;
if (nullspace.size() > 0 || if (nullspace.size() > 0 ||
hasConstantNullspace || hasConstantNullspace ||
constNullspaceComponent.size() > 0) { constNullspaceComponent.size() > 0) {
...@@ -415,7 +416,7 @@ namespace AMDiS { namespace Parallel { ...@@ -415,7 +416,7 @@ namespace AMDiS { namespace Parallel {
if (constNullspaceComponent.size() > 0) { if (constNullspaceComponent.size() > 0) {
nullspace.clear(); nullspace.clear();
SystemVector *basisVec = new SystemVector(vec); basisVec = new SystemVector(vec);
basisVec->set(0.0); basisVec->set(0.0);
for (unsigned int i = 0; i < constNullspaceComponent.size(); i++) for (unsigned int i = 0; i < constNullspaceComponent.size(); i++)
basisVec->getDOFVector(constNullspaceComponent[i])->set(1.0); basisVec->getDOFVector(constNullspaceComponent[i])->set(1.0);
...@@ -463,12 +464,16 @@ namespace AMDiS { namespace Parallel { ...@@ -463,12 +464,16 @@ namespace AMDiS { namespace Parallel {
// PETSc. // PETSc.
solve(getVecRhsInterior(), getVecSolInterior()); solve(getVecRhsInterior(), getVecSolInterior());
// delete PETSc stuff
if (nullspace.size() > 0) { if (nullspace.size() > 0) {
MatNullSpaceDestroy(&matNullspace); MatNullSpaceDestroy(&matNullspace);
VecDestroy(&nullspaceBasis); VecDestroy(&nullspaceBasis);
} }
// delete allocated memory
if ((nullspace.size() > 0 || hasConstantNullspace) && constNullspaceComponent.size() > 0) {
delete basisVec;
}
// === Transfere values from PETSc's solution vectors to the DOF vectors. === // === Transfere values from PETSc's solution vectors to the DOF vectors. ===
PetscScalar *vecPointer; PetscScalar *vecPointer;
......
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