Changeset ac6d04 for src/solver


Ignore:
Timestamp:
Apr 10, 2012, 1:55:49 PM (14 years ago)
Author:
Julian Iseringhausen <isering@…>
Children:
a40eea
Parents:
d24c2f
Message:

Merge recent changes of the vmg library into ScaFaCos.

Includes a fix for the communication problems on Jugene.

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

Location:
src/solver
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/solver/dgesv.hpp

    rd24c2f rac6d04  
    4848  {Init();}
    4949
     50  DGESV(int size) :
     51    T(size)
     52  {Init();}
     53
    5054  virtual ~DGESV();
    5155
     56protected:
     57  void Compute();
     58
    5259private:
    53   void Compute();
    5460  void Init();
    5561  void Realloc();
  • src/solver/dsysv.hpp

    rd24c2f rac6d04  
    6767  {Init();}
    6868
     69  DSYSV(int size) :
     70    T(size)
     71  {Init();}
     72
    6973  virtual ~DSYSV();
     74
     75protected:
     76  void Compute();
    7077
    7178private:
    7279  void Init();
    7380  void Realloc();
    74   void Compute();
    7581
    7682  char la_uplo;
  • src/solver/givens.hpp

    rd24c2f rac6d04  
    2222class Givens : public T
    2323{
    24 private:
     24public:
     25  Givens() :
     26    T()
     27  {}
     28
     29  Givens(int size) :
     30    T(size)
     31  {}
     32
     33protected:
    2534  void Compute();
    2635};
  • src/solver/solver.cpp

    rd24c2f rac6d04  
    2727#endif
    2828
    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);
     29  if (rhs.Global().LocalSize().Product() > 0) {
     30    this->Realloc(rhs);
     31    this->AssembleMatrix(rhs);
     32    this->Compute();
     33    this->ExportSol(sol, rhs);
     34  }
    3735}
    3836
     
    5452void Solver::Realloc(Grid& sol)
    5553{
    56   this->Realloc(sol.Global().SizeGlobal().Product());
     54  this->Realloc(sol.Global().GlobalSize().Product());
    5755}
  • src/solver/solver.hpp

    rd24c2f rac6d04  
    2020#include "mg.hpp"
    2121
    22 namespace VMGTests
    23 {
    24 class SolverTestSuite;
    25 }
    26 
    2722namespace VMG
    2823{
     
    3126{
    3227public:
    33   friend class VMGTests::SolverTestSuite;
    34 
    3528  Solver()
    3629  {
    3730    size = 0;
     31  }
     32
     33  Solver(int size) :
     34    size(size)
     35  {
     36    this->Realloc(size);
    3837  }
    3938
     
    4443  void Run(Grid& sol, Grid& rhs);
    4544
    46 private:
    47 
    48   virtual void Compute() = 0; ///< Solves the system of equations
    49   virtual void AssembleMatrix(const Grid& rhs) = 0; ///< Assembles all matrices and vectors.
    50   virtual void ExportSol(Grid& sol, Grid& rhs) = 0; ///< Exports the solution back to a given mesh.
    51 
    52   std::vector<vmg_float> A, b, x;
    53   int size;
    54 
    55 protected:
    5645  void Realloc(int n);
    5746  void Realloc(Grid& x);
     
    7362
    7463  const int& Size() const {return size;}
     64
     65protected:
     66  virtual void Compute() = 0; ///< Solves the system of equations
     67
     68private:
     69  virtual void AssembleMatrix(const Grid& rhs) = 0; ///< Assembles all matrices and vectors.
     70  virtual void ExportSol(Grid& sol, Grid& rhs) = 0; ///< Exports the solution back to a given mesh.
     71
     72  std::vector<vmg_float> A, b, x;
     73  int size;
    7574};
    7675
  • src/solver/solver_regular.cpp

    rd24c2f rac6d04  
    3838#endif
    3939
    40   this->Realloc(rhs.Global().SizeGlobal().Product());
     40  this->Realloc(rhs.Global().GlobalSize().Product());
    4141
    4242  for (grid_iter = rhs.Iterators().Local().Begin(); grid_iter != rhs.Iterators().Local().End(); ++grid_iter) {
    4343
    44     mat_index = rhs.GlobalLinearIndex(*grid_iter + rhs.Global().BeginLocal());
     44    mat_index = rhs.GlobalLinearIndex(*grid_iter + rhs.Global().LocalBegin());
    4545
    4646    assert(mat_index >= 0 && mat_index<this->Size());
     
    5656    for (stencil_iter = A.begin(); stencil_iter != A.end(); ++stencil_iter) {
    5757
    58       mat_index2 = rhs.GlobalLinearIndex(*grid_iter + rhs.Global().BeginLocal() + stencil_iter->Disp());
     58      mat_index2 = rhs.GlobalLinearIndex(*grid_iter + rhs.Global().LocalBegin() + stencil_iter->Disp());
    5959
    6060      assert(mat_index2 >= 0 && mat_index2<this->Size());
     
    6969    for (grid_iter = rhs.Iterators().Boundary1()[i].Begin(); grid_iter != rhs.Iterators().Boundary1()[i].End(); ++grid_iter) {
    7070
    71       mat_index = rhs.GlobalLinearIndex(*grid_iter + rhs.Global().BeginLocal());
     71      mat_index = rhs.GlobalLinearIndex(*grid_iter + rhs.Global().LocalBegin());
    7272
    7373      assert(mat_index >= 0 && mat_index<this->Size());
     
    8484    for (grid_iter = rhs.Iterators().Boundary2()[i].Begin(); grid_iter != rhs.Iterators().Boundary2()[i].End(); ++grid_iter) {
    8585
    86       mat_index = rhs.GlobalLinearIndex(*grid_iter + rhs.Global().BeginLocal());
     86      mat_index = rhs.GlobalLinearIndex(*grid_iter + rhs.Global().LocalBegin());
    8787
    8888      assert(mat_index >= 0 && mat_index<this->Size());
     
    110110
    111111  for (Grid::iterator iter = sol.Iterators().CompleteGrid().Begin(); iter != sol.Iterators().CompleteGrid().End(); ++iter) {
    112     index = sol.GlobalLinearIndex(sol.Global().BeginLocal() + *iter - offset);
     112    index = sol.GlobalLinearIndex(sol.Global().LocalBegin() + *iter - offset);
    113113    sol(*iter) = this->Sol(index);
    114114  }
  • src/solver/solver_regular.hpp

    rd24c2f rac6d04  
    2020class SolverRegular : public Solver
    2121{
     22public:
     23  SolverRegular() :
     24    Solver()
     25  {}
     26
     27  SolverRegular(int size) :
     28    Solver(size)
     29  {}
     30
    2231private:
    2332  void AssembleMatrix(const Grid& rhs); ///< Assembles all matrices and vectors.
  • src/solver/solver_singular.cpp

    rd24c2f rac6d04  
    4242
    4343  // Make sure that arrays are big enough to hold expanded system of equations
    44   this->Realloc(rhs.Global().SizeGlobal().Product() + 1);
     44  this->Realloc(rhs.Global().GlobalSize().Product() + 1);
    4545
    4646  for (grid_iter = rhs.Iterators().Local().Begin(); grid_iter != rhs.Iterators().Local().End(); ++grid_iter) {
    4747
    4848    // Compute 1-dimensional index from 3-dimensional grid
    49     index = rhs.GlobalLinearIndex(*grid_iter - rhs.Local().Begin() + rhs.Global().BeginLocal());
     49    index = rhs.GlobalLinearIndex(*grid_iter - rhs.Local().Begin() + rhs.Global().LocalBegin());
    5050
    5151    // Check if we computed the index correctly
     
    6464    for (stencil_iter = A.begin(); stencil_iter != A.end(); ++stencil_iter) {
    6565
    66       i = *grid_iter - rhs.Local().Begin() + rhs.Global().BeginLocal() + stencil_iter->Disp();
     66      i = *grid_iter - rhs.Local().Begin() + rhs.Global().LocalBegin() + stencil_iter->Disp();
    6767
    6868      for (int j=0; j<3; ++j)
    6969        if (comm->BoundaryConditions()[j] == Periodic) {
    7070          if (i[j] < 0)
    71             i[j] += rhs.Global().SizeGlobal()[j];
    72           else if (i[j] >= rhs.Global().SizeGlobal()[j])
    73             i[j] -= rhs.Global().SizeGlobal()[j];
     71            i[j] += rhs.Global().GlobalSize()[j];
     72          else if (i[j] >= rhs.Global().GlobalSize()[j])
     73            i[j] -= rhs.Global().GlobalSize()[j];
    7474        }
    7575
     
    8787    row_sum += iter->Val();
    8888
    89   if (fabs(row_sum) <= std::numeric_limits<vmg_float>::epsilon()) {
     89  if (std::abs(row_sum) <= (A.size()+1) * std::numeric_limits<vmg_float>::epsilon()) {
    9090
    9191    // Expand equation system in order to make the system regular.
     
    108108{
    109109  int index;
     110  const vmg_float correction = this->Sol(this->Size()-1);
    110111
    111112  for (int i=0; i<sol.Local().Size().X(); i++)
     
    114115
    115116        // Compute global 1-dimensional index
    116         index = sol.GlobalLinearIndex(sol.Global().BeginLocal().X()+i,
    117                                       sol.Global().BeginLocal().Y()+j,
    118                                       sol.Global().BeginLocal().Z()+k);
     117        index = sol.GlobalLinearIndex(sol.Global().LocalBegin().X()+i,
     118                                      sol.Global().LocalBegin().Y()+j,
     119                                      sol.Global().LocalBegin().Z()+k);
    119120
    120121        // Set solution
    121         sol(sol.Local().Begin().X()+i, sol.Local().Begin().Y()+j, sol.Local().Begin().Z()+k) = this->Sol(index);
     122        sol(sol.Local().Begin().X()+i, sol.Local().Begin().Y()+j, sol.Local().Begin().Z()+k) = this->Sol(index) - correction;
    122123
    123124      }
  • src/solver/solver_singular.hpp

    rd24c2f rac6d04  
    2020class SolverSingular : public Solver
    2121{
     22public:
     23  SolverSingular() :
     24    Solver()
     25  {}
     26
     27  SolverSingular(int size) :
     28    Solver(size)
     29  {}
     30
    2231private:
    2332  void AssembleMatrix(const Grid& rhs); ///< Assembles all matrices and vectors.
Note: See TracChangeset for help on using the changeset viewer.