Changeset a24b80


Ignore:
Timestamp:
Jun 11, 2012, 3:01:12 PM (13 years ago)
Author:
Julian Iseringhausen <isering@…>
Children:
290aa3
Parents:
2d4211
Message:

Simplified API.

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

Files:
14 edited

Legend:

Unmodified
Added
Removed
  • src/mg.cpp

    r2d4211 ra24b80  
    125125}
    126126
    127 void MG::SetInterface(VMG::Interface* interface, VMG::Comm* comm)
    128 {
    129   interface->Register("INTERFACE");
    130 
    131   Multigrid* sol = new Multigrid(comm, interface);
    132   Multigrid* rhs = new Multigrid(comm, interface);
     127/*
     128 * Post init communication class
     129 */
     130void MG::PostInit()
     131{
     132  Multigrid* sol = new Multigrid(GetComm(), GetInterface());
     133  sol->Register("SOL");
     134
     135  Multigrid* rhs = new Multigrid(GetComm(), GetInterface());
     136  rhs->Register("RHS");
     137
    133138  TempGrid* temp = new TempGrid();
    134 
    135   sol->Register("SOL");
    136   rhs->Register("RHS");
    137139  temp->Register("TEMPGRID");
    138140
     
    140142  new ObjectStorage<int>("MINLEVEL", sol->MinLevel());
    141143  new ObjectStorage<int>("MAXLEVEL", sol->MaxLevel());
    142 }
    143 
    144 /*
    145  * Post init communication class
    146  */
    147 void MG::PostInit()
    148 {
     144
    149145  GetComm()->PostInit(*GetSol(), *GetRhs());
    150146}
  • src/mg.hpp

    r2d4211 ra24b80  
    5757  }
    5858
    59   static void SetInterface(Interface* interface, Comm* comm);
    60 
    6159  static VMG::Comm* GetComm();
    6260  static VMG::Discretization* GetDiscretization();
  • src/units/particle/interface_fcs.cpp

    r2d4211 ra24b80  
    5454#include "smoother/gsrb_poisson_2.hpp"
    5555#include "smoother/gsrb_poisson_4.hpp"
    56 #ifdef HAVE_LAPACK
    57 #include "solver/dgesv.hpp"
    58 #include "solver/dsysv.hpp"
    59 #else
    6056#include "solver/givens.hpp"
    61 #endif
    6257#include "solver/solver_regular.hpp"
    6358#include "solver/solver_singular.hpp"
     
    116111  const bool singular = periodic[0] * periodic[1] * periodic[2];
    117112
    118   /*
    119    * Register communication class.
    120    */
    121   Comm* comm = new Particle::CommMPI(boundary, new DomainDecompositionMPI(), mpi_comm);
     113  Comm* comm;
     114  Discretization* discretization;
     115  Interface* interface;
     116  LevelOperator* lop;
     117  Smoother* smoother;
     118  Solver* solver;
     119
     120  /*
     121   * Choose multigrid components
     122   */
     123  if (singular) {
     124
     125    comm = new Particle::CommMPI(boundary, new DomainDecompositionMPI(), mpi_comm);
     126    discretization = new DiscretizationPoissonFD(discretization_order);
     127    interface = new InterfaceParticles(boundary, 2, level, Vector(box_offset), box_size, near_field_cells, 0, 1.0);
     128    lop = new LevelOperatorCS(Stencils::RestrictionFullWeight, Stencils::InterpolationTrilinear);
     129    solver = new Givens<SolverSingular>();
     130
     131    Techniques::SetCorrectionSchemePeriodic(interface->MinLevel(), interface->MaxLevel(), cycle_type);
     132
     133  }else {
     134
     135    comm = new Particle::CommMPI(boundary, new DomainDecompositionMPI(), mpi_comm);
     136    discretization = new DiscretizationPoissonFV(discretization_order);
     137    interface = new InterfaceParticles(boundary, 2, level, Vector(box_offset), box_size, near_field_cells, 2, 1.6);
     138    lop = new LevelOperatorFAS(Stencils::RestrictionFullWeight, Stencils::Injection, Stencils::InterpolationTrilinear);
     139    solver = new Givens<SolverRegular>();
     140
     141    Techniques::SetFullApproximationSchemeDirichlet(interface->MinLevel(), interface->MaxLevel(), cycle_type);
     142
     143  }
     144
     145  /*
     146   * Use Gauss-Seidel Red-Black ordering
     147   */
     148  if (discretization_order == 2)
     149    smoother = new GaussSeidelRBPoisson2();
     150  else
     151    smoother = new GaussSeidelRBPoisson4();
     152
     153  /*
     154   * Register multigrid components
     155   */
    122156  comm->Register("COMM");
    123 
    124   /*
    125    * Register particle interface.
    126    */
    127   Interface* interface;
    128   if (singular)
    129     interface = new InterfaceParticles(boundary, 2, level, Vector(box_offset), box_size, near_field_cells, 0, 1.0);
    130   else
    131     interface = new InterfaceParticles(boundary, 2, level, Vector(box_offset), box_size, near_field_cells, 2, 1.6);
    132   MG::SetInterface(interface, comm);
    133 
    134   /*
    135    * Define discretization of the Poisson equation.
    136    * Finite volumes for locally refined grids and
    137    * finite differences otherwise.
    138    */
    139   Discretization* discretization;
    140   if (singular)
    141     discretization = new DiscretizationPoissonFD(discretization_order);
    142   else
    143     discretization = new DiscretizationPoissonFV(discretization_order);
    144157  discretization->Register("DISCRETIZATION");
    145 
    146   /*
    147    * Use a correction scheme multigrid algorithm with full weight stencils.
    148    * Since we use the Gauss-Seidel RB smoother here, this may be replaced
    149    * with a half-weight version once debugging is finished.
    150    */
    151   LevelOperator* lop;
    152   if (singular)
    153     lop = new LevelOperatorCS(Stencils::RestrictionFullWeight, Stencils::InterpolationTrilinear);
    154   else
    155     lop = new LevelOperatorFAS(Stencils::RestrictionFullWeight, Stencils::Injection, Stencils::InterpolationTrilinear);
     158  interface->Register("INTERFACE");
    156159  lop->Register("LEVEL_OPERATOR");
    157 
    158   /*
    159    * Use Gauss-Seidel Red-Black ordering
    160    */
    161   if (discretization_order == 2) {
    162     Smoother* smoother = new GaussSeidelRBPoisson2();
    163     smoother->Register("SMOOTHER");
    164   }else {
    165     Smoother* smoother = new GaussSeidelRBPoisson4();
    166     smoother->Register("SMOOTHER");
    167   }
    168 
    169   /*
    170    * Use LAPACK solver when available, otherwise use Givens rotations.
    171    */
    172 #ifdef HAVE_LAPACK
    173   Solver* solver = (singular ?
    174                     static_cast<Solver*>(new DSYSV<SolverSingular>()) :
    175                     static_cast<Solver*>(new DGESV<SolverRegular>()));
    176 #else
    177   Solver* solver = (singular ?
    178                     static_cast<Solver*>(new Givens<SolverSingular>()) :
    179                     static_cast<Solver*>(new Givens<SolverRegular>()));
    180 #endif
     160  smoother->Register("SMOOTHER");
    181161  solver->Register("SOLVER");
    182 
    183   /*
    184    * Set commands for the actual multigrid cycle
    185    */
    186   if (singular)
    187     Techniques::SetCorrectionSchemePeriodic(interface->MinLevel(), interface->MaxLevel(), cycle_type);
    188   else
    189     Techniques::SetFullApproximationSchemeDirichlet(interface->MinLevel(), interface->MaxLevel(), cycle_type);
    190162
    191163  /*
     
    200172
    201173  /*
     174   * Post init
     175   */
     176  MG::PostInit();
     177
     178  /*
    202179   * Check whether the library is correctly initialized now.
    203180   */
    204181  MG::IsInitialized();
    205 
    206   /*
    207    * Post init communication class
    208    */
    209   MG::PostInit();
    210182}
    211183
  • test/unit_test/library/dirichlet_cs.cpp

    r2d4211 ra24b80  
    6464
    6565    Interface* interface = new VMGInterfaces::InterfaceSinus(sine_factor, comm->BoundaryConditions(), 2, 6, 0.0, 1.0);
    66     MG::SetInterface(interface, comm);
     66    interface->Register("INTERFACE");
    6767
    6868    Discretization* discretization = new DiscretizationPoissonFD(2);
     
    8989    factory.RegisterObjectStorage("MAX_ITERATION", 7);
    9090
     91    MG::PostInit();
     92
    9193    MG::IsInitialized();
    9294  }
  • test/unit_test/library/dirichlet_cs_mpi.cpp

    r2d4211 ra24b80  
    7171
    7272    Interface* interface = new VMGInterfaces::InterfaceSinus(sine_factor, comm->BoundaryConditions(), 2, 6, 0.0, 1.0);
    73     MG::SetInterface(interface, comm);
     73    interface->Register("INTERFACE");
    7474
    7575    Discretization* discretization = new DiscretizationPoissonFD(2);
     
    9696    factory.RegisterObjectStorage("MAX_ITERATION", 7);
    9797
     98    MG::PostInit();
     99
    98100    MG::IsInitialized();
    99 
    100     MG::PostInit();
    101101  }
    102102
  • test/unit_test/library/dirichlet_fas.cpp

    r2d4211 ra24b80  
    6363
    6464    Interface* interface = new VMGInterfaces::InterfaceSinus(sine_factor, comm->BoundaryConditions(), 2, 6, 0.0, 1.0);
    65     MG::SetInterface(interface, comm);
     65    interface->Register("INTERFACE");
    6666
    6767    Discretization* discretization = new DiscretizationPoissonFD(2);
     
    8989    factory.RegisterObjectStorage("MAX_ITERATION", 7);
    9090
     91    MG::PostInit();
     92
    9193    MG::IsInitialized();
    9294  }
  • test/unit_test/library/dirichlet_fas_lr.cpp

    r2d4211 ra24b80  
    6363
    6464    Interface* interface = new VMGInterfaces::InterfaceSinus(sine_factor, comm->BoundaryConditions(), 2, 6, 0.0, 1.0, 2, 1.6);
    65     MG::SetInterface(interface, comm);
     65    interface->Register("INTERFACE");
    6666
    6767    Discretization* discretization = new DiscretizationPoissonFV(2);
     
    8989    factory.RegisterObjectStorage("MAX_ITERATION", 8);
    9090
     91    MG::PostInit();
     92
    9193    MG::IsInitialized();
    9294  }
  • test/unit_test/library/dirichlet_fas_lr_mpi.cpp

    r2d4211 ra24b80  
    7272
    7373    Interface* interface = new VMGInterfaces::InterfaceSinus(sine_factor, comm->BoundaryConditions(), 2, 6, 0.0, 1.0, 2, 1.6);
    74     MG::SetInterface(interface, comm);
     74    interface->Register("INTERFACE");
    7575
    7676    Discretization* discretization = new DiscretizationPoissonFV(2);
     
    9898    factory.RegisterObjectStorage("MAX_ITERATION", 8);
    9999
     100    MG::PostInit();
     101
    100102    MG::IsInitialized();
    101 
    102     MG::PostInit();
    103103  }
    104104
  • test/unit_test/library/dirichlet_fas_mpi.cpp

    r2d4211 ra24b80  
    7272
    7373    Interface* interface = new VMGInterfaces::InterfaceSinus(sine_factor, comm->BoundaryConditions(), 2, 6, 0.0, 1.0);
    74     MG::SetInterface(interface, comm);
     74    interface->Register("INTERFACE");
    7575
    7676    Discretization* discretization = new DiscretizationPoissonFD(2);
     
    9898    factory.RegisterObjectStorage("MAX_ITERATION", 7);
    9999
     100    MG::PostInit();
     101
    100102    MG::IsInitialized();
    101 
    102     MG::PostInit();
    103103  }
    104104
  • test/unit_test/library/periodic_cs.cpp

    r2d4211 ra24b80  
    6363
    6464    Interface* interface = new VMGInterfaces::InterfaceSinus(sine_factor, comm->BoundaryConditions(), 2, 6, 0.0, 1.0);
    65     MG::SetInterface(interface, comm);
     65    interface->Register("INTERFACE");
    6666
    6767    Discretization* discretization = new DiscretizationPoissonFD(2);
     
    8888    factory.RegisterObjectStorage("MAX_ITERATION", 7);
    8989
     90    MG::PostInit();
     91
    9092    MG::IsInitialized();
    9193  }
  • test/unit_test/library/periodic_cs_mpi.cpp

    r2d4211 ra24b80  
    7171
    7272    Interface* interface = new VMGInterfaces::InterfaceSinus(sine_factor, comm->BoundaryConditions(), 2, 6, 0.0, 1.0);
    73     MG::SetInterface(interface, comm);
     73    interface->Register("INTERFACE");
    7474
    7575    Discretization* discretization = new DiscretizationPoissonFD(2);
     
    9696    factory.RegisterObjectStorage("MAX_ITERATION", 7);
    9797
     98    MG::PostInit();
     99
    98100    MG::IsInitialized();
    99 
    100     MG::PostInit();
    101101  }
    102102
  • test/unit_test/library/periodic_fas.cpp

    r2d4211 ra24b80  
    6262
    6363    Interface* interface = new VMGInterfaces::InterfaceSinus(sine_factor, comm->BoundaryConditions(), 2, 6, 0.0, 1.0);
    64     MG::SetInterface(interface, comm);
     64    interface->Register("INTERFACE");
    6565
    6666    Discretization* discretization = new DiscretizationPoissonFD(2);
     
    8787    factory.RegisterObjectStorage("MAX_ITERATION", 7);
    8888
     89    MG::PostInit();
     90
    8991    MG::IsInitialized();
    9092  }
  • test/unit_test/library/periodic_fas_mpi.cpp

    r2d4211 ra24b80  
    7171
    7272  Interface* interface = new VMGInterfaces::InterfaceSinus(sine_factor, comm->BoundaryConditions(), 2, 6, 0.0, 1.0);
    73   MG::SetInterface(interface, comm);
     73  interface->Register("INTERFACE");
    7474
    7575  Discretization* discretization = new DiscretizationPoissonFD(2);
     
    9696  factory.RegisterObjectStorage("MAX_ITERATION", 7);
    9797
     98  MG::PostInit();
     99
    98100  MG::IsInitialized();
    99 
    100   MG::PostInit();
    101101  }
    102102
  • test/unit_test/unit_test/smoother_test.cpp

    r2d4211 ra24b80  
    5656
    5757    Interface* interface = new VMGInterfaces::InterfaceSinus(2.0*Math::pi, boundary, 4, 4, 0.0, 1.0);
    58     MG::SetInterface(interface, comm);
     58    interface->Register("INTERFACE");
     59
     60    MG::PostInit();
    5961
    6062    interface->ImportRightHandSide(*MG::GetRhs());
Note: See TracChangeset for help on using the changeset viewer.