PetscSolver.cc 1.01 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
//
// Software License for AMDiS
//
// Copyright (c) 2010 Dresden University of Technology 
// All rights reserved.
// Authors: Simon Vey, Thomas Witkowski et al.
//
// This file is part of AMDiS
//
// See also license.opensource.txt in the distribution.


Thomas Witkowski's avatar
Thomas Witkowski committed
13
#include "parallel/PetscSolver.h"
14
#include "parallel/StdMpi.h"
15
#include "parallel/MpiHelper.h"
16 17 18

namespace AMDiS {

Thomas Witkowski's avatar
Thomas Witkowski committed
19 20
  using namespace std;

21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
  void PetscSolver::printSolutionInfo(AdaptInfo *adaptInfo,
				      bool iterationCounter, 
				      bool residual)
  {
    FUNCNAME("PetscSolver::printSolutionInfo()");

    if (iterationCounter) {
      int iterations = 0;
      KSPGetIterationNumber(solver, &iterations);
      MSG("  Number of iterations: %d\n", iterations);
      adaptInfo->setSolverIterations(iterations);
    }

    if (residual) {
      double norm = 0.0;
      MatMult(petscMatrix, petscSolVec, petscTmpVec);
      VecAXPY(petscTmpVec, -1.0, petscRhsVec);
      VecNorm(petscTmpVec, NORM_2, &norm);
      MSG("  Residual norm: %e\n", norm);
    }
  }

43
}