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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/interface/interface_fcs.cpp

    r66f24d rdfed1c  
    1919
    2020#include "base/object.hpp"
    21 #include "comm/comm_serial.hpp"
     21#include "base/timer.hpp"
     22#include "comm/comm_mpi.hpp"
     23#include "comm/domain_decomposition_mpi.hpp"
    2224#include "interface/interface_fcs.h"
    2325#include "interface/interface_particles.hpp"
     
    3335#include "solver/givens.hpp"
    3436#endif
    35 #include "solver/solver_dirichlet.hpp"
    36 #include "solver/solver_periodic.hpp"
     37#include "solver/solver_regular.hpp"
     38#include "solver/solver_singular.hpp"
    3739
    3840using namespace VMG;
    3941
    40 void VMGInterfaceFCSInit(vmg_int level, vmg_int periodic, vmg_int spline_degree,
    41                          vmg_int max_iter, vmg_int smoothing_steps, vmg_int gamma,
    42                          vmg_float precision, vmg_float box_begin, vmg_float box_end,
    43                          MPI_Comm mpi_comm)
    44 {
    45   const BC bc = (periodic ? Periodic : Dirichlet);
    46 
    47   /*
    48    * Register all the parameters for later use.
    49    */
    50   new ObjectStorage<int>("LEVEL_FCS", level);
    51   new ObjectStorage<int>("PERIODIC_FCS", periodic);
    52   new ObjectStorage<int>("SPLINE_DEGREE_FCS", spline_degree);
    53   new ObjectStorage<int>("MAX_ITER_FCS", max_iter);
    54   new ObjectStorage<int>("SMOOTHING_STEPS_FCS", smoothing_steps);
    55   new ObjectStorage<int>("GAMMA_FCS", gamma);
    56   new ObjectStorage<vmg_float>("PRECISION_FCS", precision);
    57   new ObjectStorage<vmg_float>("BOX_BEGIN_FCS", box_begin);
    58   new ObjectStorage<vmg_float>("BOX_END_FCS", box_end);
    59   new ObjectStorage<MPI_Comm>("MPI_COMM_FCS", mpi_comm);
     42namespace VMGBackupSettings
     43{
     44  static vmg_int level = -1;
     45  static vmg_int periodic[3] = {-1, -1, -1};
     46  static vmg_int max_iter = -1;
     47  static vmg_int smoothing_steps = -1;
     48  static vmg_int gamma = -1;
     49  static vmg_float precision = -1;
     50  static vmg_float box_offset[3];
     51  static vmg_float box_size = -1.0;
     52  static vmg_int near_field_cells = -1;
     53  static MPI_Comm mpi_comm;
     54}
     55
     56static void VMG_fcs_init(vmg_int level, vmg_int* periodic,vmg_int max_iter,
     57                         vmg_int smoothing_steps, vmg_int gamma, vmg_float precision,
     58                         vmg_float* box_offset, vmg_float box_size,
     59                         vmg_int near_field_cells, MPI_Comm mpi_comm)
     60{
     61  VMGBackupSettings::level = level;
     62  std::memcpy(VMGBackupSettings::periodic, periodic, 3*sizeof(vmg_int));
     63  VMGBackupSettings::max_iter = max_iter;
     64  VMGBackupSettings::smoothing_steps = smoothing_steps;
     65  VMGBackupSettings::gamma = gamma;
     66  VMGBackupSettings::precision = precision;
     67  std::memcpy(VMGBackupSettings::box_offset, box_offset, 3*sizeof(vmg_float));
     68  VMGBackupSettings::box_size = box_size;
     69  VMGBackupSettings::near_field_cells = near_field_cells;
     70  VMGBackupSettings::mpi_comm = mpi_comm;
     71
     72  const Boundary boundary(periodic[0] ? Periodic : Open,
     73                          periodic[1] ? Periodic : Open,
     74                          periodic[2] ? Periodic : Open);
     75
     76  const bool singular = periodic[0] * periodic[1] * periodic[2];
    6077
    6178  /*
    6279   * Register communication class.
    63    * For now, parallel version is not yet released.
    64    */
    65   Comm* comm = new CommSerial(bc);
     80   */
     81  Comm* comm = new CommMPI(boundary, new DomainDecompositionMPI());
    6682  comm->Register("COMM");
    6783
     
    6985   * Register particle interface.
    7086   */
    71   Interface* interface = new VMG::InterfaceParticles(bc, 2, level, box_begin, box_end);
     87  Interface* interface = new VMG::InterfaceParticles(boundary, 2, level, Vector(box_offset), box_size, near_field_cells);
    7288  MG::SetInterface(interface, comm);
    7389
     
    96112   */
    97113#ifdef HAVE_LAPACK
    98   Solver* solver = (periodic ?
    99                     static_cast<Solver*>(new DSYSV<SolverPeriodic>()) :
    100                     static_cast<Solver*>(new DGESV<SolverDirichlet>()));
     114  Solver* solver = (singular ?
     115                    static_cast<Solver*>(new DSYSV<SolverSingular>()) :
     116                    static_cast<Solver*>(new DGESV<SolverRegular>()));
    101117#else
    102   Solver* solver = (periodic ?
    103                     static_cast<Solver*>(new Givens<SolverPeriodic>()) :
    104                     static_cast<Solver*>(new Givens<SolverDirichlet>()));
     118  Solver* solver = (singular ?
     119                    static_cast<Solver*>(new Givens<SolverSingular>()) :
     120                    static_cast<Solver*>(new Givens<SolverRegular>()));
    105121#endif
    106122  solver->Register("SOLVER");
     
    109125   * Set commands for the actual multigrid cycle
    110126   */
    111   if (periodic)
     127  if (singular)
    112128    Techniques::SetCorrectionSchemePeriodic(2, level, gamma);
    113129  else
     
    122138  new ObjectStorage<int>("MAX_ITERATION", max_iter);
    123139
     140  new ObjectStorage<int>("PARTICLE_NEAR_FIELD_CELLS", near_field_cells);
     141
    124142  /*
    125143   * Check whether the library is correctly initialized now.
     
    128146}
    129147
    130 void VMGInterfaceFCSRun(vmg_float* x, vmg_float* q, vmg_float* p, vmg_float* f, vmg_int num_particles_local)
     148void VMG_fcs_setup(vmg_int level, vmg_int* periodic, vmg_int max_iter,
     149                   vmg_int smoothing_steps, vmg_int gamma, vmg_float precision,
     150                   vmg_float* box_offset, vmg_float box_size,
     151                   vmg_int near_field_cells, MPI_Comm mpi_comm)
     152{
     153  if (VMGBackupSettings::level != level ||
     154      VMGBackupSettings::periodic[0] != periodic[0] ||
     155      VMGBackupSettings::periodic[1] != periodic[1] ||
     156      VMGBackupSettings::periodic[2] != periodic[2] ||
     157      VMGBackupSettings::max_iter != max_iter ||
     158      VMGBackupSettings::smoothing_steps != smoothing_steps ||
     159      VMGBackupSettings::gamma != gamma ||
     160      VMGBackupSettings::precision != precision ||
     161      VMGBackupSettings::box_offset[0] != box_offset[0] ||
     162      VMGBackupSettings::box_offset[1] != box_offset[1] ||
     163      VMGBackupSettings::box_offset[2] != box_offset[2] ||
     164      VMGBackupSettings::box_size != box_size ||
     165      VMGBackupSettings::near_field_cells != near_field_cells ||
     166      VMGBackupSettings::mpi_comm != mpi_comm) {
     167
     168    VMG_fcs_destroy();
     169    VMG_fcs_init(level, periodic, max_iter,
     170                 smoothing_steps, gamma, precision,
     171                 box_offset, box_size, near_field_cells,
     172                 mpi_comm);
     173
     174  }
     175}
     176
     177void VMG_fcs_run(vmg_float* x, vmg_float* q, vmg_float* p, vmg_float* f, vmg_int num_particles_local)
    131178{
    132179  /*
    133180   * Register parameters for later use.
    134181   */
    135   new ObjectStorage<vmg_float*>("X_FCS", x);
    136   new ObjectStorage<vmg_float*>("Q_FCS", q);
    137   new ObjectStorage<vmg_float*>("P_FCS", p);
    138   new ObjectStorage<vmg_float*>("F_FCS", f);
    139   new ObjectStorage<vmg_int>("NUM_PARTICLES_LOCAL_FCS", num_particles_local);
     182  new ObjectStorage<vmg_float*>("PARTICLE_POS_ARRAY", x);
     183  new ObjectStorage<vmg_float*>("PARTICLE_CHARGE_ARRAY", q);
     184  new ObjectStorage<vmg_float*>("PARTICLE_POTENTIAL_ARRAY", p);
     185  new ObjectStorage<vmg_float*>("PARTICLE_FORCE_ARRAY", f);
     186  new ObjectStorage<vmg_int>("PARTICLE_NUM_LOCAL", num_particles_local);
    140187
    141188  /*
     
    145192}
    146193
    147 void VMGInterfaceFCSDestroy(void)
     194void VMG_fcs_print_timer()
     195{
     196  Timer::Print();
     197}
     198
     199void VMG_fcs_destroy(void)
    148200{
    149201  /*
Note: See TracChangeset for help on using the changeset viewer.