Changeset dfed1c for src/solver


Ignore:
Timestamp:
Nov 22, 2011, 9:22:10 PM (14 years ago)
Author:
Julian Iseringhausen <isering@…>
Children:
facba0
Parents:
66f24d
Message:

Major vmg update.

git-svn-id: https://svn.version.fz-juelich.de/scafacos/trunk@1136 5161e1c8-67bf-11de-9fd5-51895aff932f

Location:
src/solver
Files:
2 added
2 deleted
3 edited
2 moved

Legend:

Unmodified
Added
Removed
  • src/solver/dsysv.hpp

    r66f24d rdfed1c  
    7878  vmg_float *la_A, *la_A_orig, *la_B, *la_B_orig, *la_work, *la_work2;
    7979
    80   int cur_lapack_size, max_lapack_size;;
     80  int cur_lapack_size, max_lapack_size;
    8181};
    8282
  • src/solver/solver.cpp

    r66f24d rdfed1c  
    1616using namespace VMG;
    1717
     18void Solver::Run(Grid& sol, Grid& rhs)
     19{
     20#ifdef DEBUG_MATRIX_CHECKS
     21  sol.IsConsistent();
     22  rhs.IsConsistent();
     23#endif
     24
     25#ifdef DEBUG
     26  sol.IsCompatible(rhs);
     27#endif
     28
     29  Comm* comm = MG::GetComm();
     30
     31  Grid& rhsGlobal = comm->GetGlobalCoarseGrid(*rhs.Father());
     32
     33  this->Realloc(rhsGlobal);
     34  this->AssembleMatrix(rhsGlobal);
     35  this->Compute();
     36  this->ExportSol(sol, rhs);
     37}
     38
    1839void Solver::Realloc(int n)
    1940{
    2041  //Reallocate memory if necessary
    21   this->vec_size = n;
     42  this->size = n;
    2243
    23   if (n > this->max_size) {
     44  if (static_cast<int>(A.size()) < n*n)
     45    A.resize(n*n);
    2446
    25     delete [] b;
    26     delete [] x;
    27     for (int i=0; i<this->max_size; i++)
    28       delete [] A[i];
    29     delete [] A;
     47  if (static_cast<int>(b.size()) < n)
     48    b.resize(n);
    3049
    31     b = new vmg_float[n];
    32     x = new vmg_float[n];
    33     A = new vmg_float*[n];
    34     for (int i=0; i<n; i++)
    35       A[i] = new vmg_float[n];
    36 
    37     this->max_size = n;
    38 
    39   }
     50  if (static_cast<int>(x.size()) < n)
     51    x.resize(n);
    4052}
    4153
    4254void Solver::Realloc(Grid& sol)
    4355{
    44   this->Realloc(sol.Global().Size().Product());
     56  this->Realloc(sol.Global().SizeGlobal().Product());
    4557}
  • src/solver/solver.hpp

    r66f24d rdfed1c  
    1010#ifndef SOLVER_HPP_
    1111#define SOLVER_HPP_
     12
     13#include <vector>
    1214
    1315#include "base/discretization.hpp"
     
    3335  Solver()
    3436  {
    35     max_size = 0;
    36     vec_size = 0;
    37     b = NULL;
    38     x = NULL;
    39     A = NULL;
     37    size = 0;
    4038  }
    4139
    4240  virtual ~Solver()
    4341  {
    44     delete [] b;
    45     delete [] x;
    46     for (int i=0; i<max_size; i++)
    47       delete [] A[i];
    48     delete [] A;
    4942  }
    5043
    51   void Run(Grid& sol, Grid& rhs)
    52   {
    53 #ifdef DEBUG
    54     sol.IsConsistent();
    55     rhs.IsConsistent();
    56     sol.IsCompatible(rhs);
    57 #endif
    58 
    59     Grid *rhsGlobal = MG::GetComm()->CommMergeGrids(rhs);
    60 
    61     this->Realloc(*rhsGlobal);
    62     this->AssembleMatrix(*rhsGlobal);
    63     this->Compute();
    64     this->ExportSol(sol, rhs);
    65   }
     44  void Run(Grid& sol, Grid& rhs);
    6645
    6746private:
     
    7150  virtual void ExportSol(Grid& sol, Grid& rhs) = 0; ///< Exports the solution back to a given mesh.
    7251
    73   vmg_float **A, *b, *x;
    74   int max_size, vec_size;
     52  std::vector<vmg_float> A, b, x;
     53  int size;
    7554
    7655protected:
     
    8059  vmg_float& Mat(int i, int j)
    8160  {
    82     return A[i][j];
     61    return A[j+size*i];
    8362  }
    8463
     
    9372  }
    9473
    95   const int& Size() const {return vec_size;}
    96   const int& MemSize()  const {return max_size;}
     74  const int& Size() const {return size;}
    9775};
    9876
  • src/solver/solver_regular.hpp

    r66f24d rdfed1c  
    11/**
    2  * @file   solver_dirichlet.hpp
     2 * @file   solver_regular.hpp
    33 * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
    44 * @date   Mon Apr 18 13:11:47 2011
    55 *
    6  * @brief  VMG::SolverDirichlet
     6 * @brief  VMG::SolverRegular
    77 *
    88 */
    99
    10 #ifndef SOLVER_DIRICHLET_HPP_
    11 #define SOLVER_DIRICHLET_HPP_
     10#ifndef SOLVER_REGULAR_HPP_
     11#define SOLVER_REGULAR_HPP_
    1212
    1313#include "solver.hpp"
     
    1818class Multigrid;
    1919
    20 class SolverDirichlet : public Solver
     20class SolverRegular : public Solver
    2121{
    2222private:
     
    2727}
    2828
    29 #endif /* SOLVER_DIRICHLET_HPP_ */
     29#endif /* SOLVER_REGULAR_HPP_ */
  • src/solver/solver_singular.hpp

    r66f24d rdfed1c  
    11/**
    2  * @file   solver_periodic.hpp
     2 * @file   solver_singular.hpp
    33 * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
    44 * @date   Mon Apr 18 13:12:18 2011
    55 *
    6  * @brief  VMG::SolverPeriodic
     6 * @brief  VMG::SolverSingular
    77 *
    88 */
    99
    10 #ifndef SOLVER_PERIODIC_HPP_
    11 #define SOLVER_PERIODIC_HPP_
     10#ifndef SOLVER_SINGULAR_HPP_
     11#define SOLVER_SINGULAR_HPP_
    1212
    1313#include "solver/solver.hpp"
     
    1818class Multigrid;
    1919
    20 class SolverPeriodic : public Solver
     20class SolverSingular : public Solver
    2121{
    2222private:
     
    2727}
    2828
    29 #endif /* SOLVER_PERIODIC_HPP_ */
     29#endif /* SOLVER_SINGULAR_HPP_ */
Note: See TracChangeset for help on using the changeset viewer.