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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.