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 {
MatNullSpace matNullspace;
Vec nullspaceBasis;
SystemVector *basisVec;
if (nullspace.size() > 0 ||
hasConstantNullspace ||
constNullspaceComponent.size() > 0) {
......@@ -415,7 +416,7 @@ namespace AMDiS { namespace Parallel {
if (constNullspaceComponent.size() > 0) {
nullspace.clear();
SystemVector *basisVec = new SystemVector(vec);
basisVec = new SystemVector(vec);
basisVec->set(0.0);
for (unsigned int i = 0; i < constNullspaceComponent.size(); i++)
basisVec->getDOFVector(constNullspaceComponent[i])->set(1.0);
......@@ -463,12 +464,16 @@ namespace AMDiS { namespace Parallel {
// PETSc.
solve(getVecRhsInterior(), getVecSolInterior());
// delete PETSc stuff
if (nullspace.size() > 0) {
MatNullSpaceDestroy(&matNullspace);
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. ===
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