Ignore:
Timestamp:
Feb 2, 2012, 1:58:12 PM (14 years ago)
Author:
Julian Iseringhausen <isering@…>
Children:
32ff22
Parents:
01be70
Message:

Parallel performance update.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/interface/interface_particles.cpp

    r01be70 r894a5f  
    2222#include "base/index.hpp"
    2323#include "base/linked_cell_list.hpp"
    24 #include "base/timer.hpp"
    2524#include "base/vector.hpp"
    2625#include "comm/comm.hpp"
     
    3534void InterfaceParticles::ImportRightHandSide(Multigrid& multigrid)
    3635{
    37   Timer::Start("Particle/Grid Interpolation");
    38 
    3936  Index index_global, index_local, index;
    4037  Vector pos_rel, pos_abs, grid_val;
    4138
    4239  Factory& factory = MG::GetFactory();
     40  Comm& comm = *MG::GetComm();
    4341
    4442  const int& near_field_cells = factory.GetObjectStorageVal<int>("PARTICLE_NEAR_FIELD_CELLS");
    4543
    46   TempGrid* temp_grid = GetTempGrid(0);
    4744  Grid& grid = multigrid(multigrid.GlobalMaxLevel());
    48   LocalIndices local = grid.Local();
    49 
    50   // We don't need a boundary on this grid
    51   local.End() -= local.Begin();
    52   local.Begin() = 0;
    53   local.BoundaryBegin1() = local.BoundaryEnd1() = 0;
    54   local.BoundaryBegin2() = local.BoundaryEnd2() = 0;
    55 
    56   // Set grid size of intermediate temporary grid
    57   for (int i=0; i<3; ++i) {
    58 
    59     if (local.HasHalo1()[i]) {
    60       local.HaloBegin1()[i] = 0;
    61       local.HaloEnd1()[i] = local.Begin()[i] = near_field_cells+1;
    62       local.End()[i] = local.Begin()[i] + local.Size()[i];
    63     }
    64 
    65     if (local.HasHalo2()[i]) {
    66       local.HaloBegin2()[i] = local.End()[i];
    67       local.HaloEnd2()[i] = local.HaloBegin2()[i] + near_field_cells+1;
    68     }
    69 
    70   }
    71 
    72   local.SizeTotal() = local.Size() +
    73                       local.HaloEnd1() - local.HaloBegin1() +
    74                       local.HaloEnd2() - local.HaloBegin2();
    75 
    76   temp_grid->SetProperties(grid.Global(), local, grid.Extent());
    77   temp_grid->Clear();
     45  Grid& particle_grid = comm.GetParticleGrid();
     46
     47  particle_grid.Clear();
    7848
    7949  /*
     
    8151   */
    8252  particles.clear();
    83   MG::GetComm()->CommParticles(grid, particles);
     53  comm.CommParticles(grid, particles);
    8454
    8555  /*
     
    9363    particle_charges += iter->Charge();
    9464  particle_charges = MG::GetComm()->GlobalSumRoot(particle_charges);
    95   MG::GetComm()->PrintStringOnce("Particle list charge sum: %e", particle_charges);
     65  comm.PrintStringOnce("Particle list charge sum: %e", particle_charges);
    9666#endif
    9767
    9868  for (iter=particles.begin(); iter!=particles.end(); ++iter)
    99     spl.SetSpline(*temp_grid, *iter, near_field_cells);
     69    spl.SetSpline(particle_grid, *iter, near_field_cells);
    10070
    10171  // Communicate charges over halo
    102   MG::GetComm()->CommFromGhosts(*temp_grid);
     72  comm.CommFromGhosts(particle_grid);
    10373
    10474  // Assign charge values to the right hand side
     
    10676    for (index.Y()=0; index.Y()<grid.Local().Size().Y(); ++index.Y())
    10777      for (index.Z()=0; index.Z()<grid.Local().Size().Z(); ++index.Z())
    108         grid(index + grid.Local().Begin()) = temp_grid->GetVal(index + temp_grid->Local().Begin());
    109 
    110   Timer::Stop("Particle/Grid Interpolation");
     78        grid(index + grid.Local().Begin()) = particle_grid.GetVal(index + particle_grid.Local().Begin());
    11179
    11280#ifdef DEBUG_OUTPUT
     
    11684    charge_sum += grid.GetVal(*grid_iter);
    11785  charge_sum = MG::GetComm()->GlobalSum(charge_sum);
    118   MG::GetComm()->PrintStringOnce("Grid charge sum: %e", charge_sum);
     86  comm.PrintStringOnce("Grid charge sum: %e", charge_sum);
    11987#endif
    12088}
     
    12290void InterfaceParticles::ExportSolution(Grid& grid)
    12391{
    124   Timer::Start("Grid/Particle Interpolation");
    125 
    12692  Index index;
    12793  vmg_float length;
     
    135101
    136102  Factory& factory = MG::GetFactory();
    137   Comm* comm = MG::GetComm();
     103  Comm& comm = *MG::GetComm();
    138104
    139105  /*
     
    161127   * The parameters of this grid have been set in the import step.
    162128   */
    163   TempGrid* temp_grid = GetTempGrid(0);
     129  Grid& particle_grid = comm.GetParticleGrid();
    164130
    165131  for (index.X()=0; index.X()<grid.Local().Size().X(); ++index.X())
    166132    for (index.Y()=0; index.Y()<grid.Local().Size().Y(); ++index.Y())
    167133      for (index.Z()=0; index.Z()<grid.Local().Size().Z(); ++index.Z())
    168         (*temp_grid)(index + temp_grid->Local().Begin()) = grid.GetVal(index + grid.Local().Begin());
    169 
    170   comm->CommToGhosts(*temp_grid);
     134        particle_grid(index + particle_grid.Local().Begin()) = grid.GetVal(index + grid.Local().Begin());
     135
     136  comm.CommToGhosts(particle_grid);
    171137
    172138  /*
     
    177143
    178144    // Interpolate long range part of potential
    179     p_iter->Pot() = 0.5 * (Helper::InterpolateTrilinear(p_iter->Pos(), *temp_grid) - p_iter->Charge() * spl.GetAntiDerivativeZero());
    180 
    181 #ifdef DEBUG_OUTPUT
    182     e_long += 0.5 * p_iter->Charge() * Helper::InterpolateTrilinear(p_iter->Pos(), *temp_grid);
     145    p_iter->Pot() = 0.5 * (Helper::InterpolateTrilinear(p_iter->Pos(), particle_grid) - p_iter->Charge() * spl.GetAntiDerivativeZero());
     146
     147#ifdef DEBUG_OUTPUT
     148    e_long += 0.5 * p_iter->Charge() * Helper::InterpolateTrilinear(p_iter->Pos(), particle_grid);
    183149    e_self += 0.5 * p_iter->Charge() * p_iter->Charge() * spl.GetAntiDerivativeZero();
    184150#endif
     
    186152  }
    187153
    188   comm->CommAddPotential(particles);
     154  comm.CommAddPotential(particles);
    189155
    190156  /*
     
    195161  Grid::iterator iter;
    196162
    197   comm->CommLCListGhosts(grid, lc);
     163  comm.CommLCListGhosts(grid, lc);
    198164
    199165  for (iter=lc.Iterators().Local().Begin(); iter!=lc.Iterators().Local().End(); ++iter)
     
    213179              }
    214180
    215   comm->CommAddPotential(lc);
    216 
    217   Timer::Stop("Grid/Particle Interpolation");
     181  comm.CommAddPotential(lc);
    218182
    219183#ifdef DEBUG_OUTPUT
     
    223187    e += p[i] * q[i];
    224188
    225   e = comm->GlobalSumRoot(e);
    226   e_long = comm->GlobalSumRoot(e_long);
    227   e_self = comm->GlobalSumRoot(e_self);
    228 
    229   comm->PrintStringOnce("E_long:  %e", e_long);
    230   comm->PrintStringOnce("E_short: %e", e - e_long + e_self);
    231   comm->PrintStringOnce("E_self:  %e", e_self);
    232   comm->PrintStringOnce("E_total: %e", e);
     189  e = comm.GlobalSumRoot(e);
     190  e_long = comm.GlobalSumRoot(e_long);
     191  e_self = comm.GlobalSumRoot(e_self);
     192
     193  comm.PrintStringOnce("E_long:  %e", e_long);
     194  comm.PrintStringOnce("E_short: %e", e - e_long + e_self);
     195  comm.PrintStringOnce("E_self:  %e", e_self);
     196  comm.PrintStringOnce("E_total: %e", e);
    233197
    234198#endif /* DEBUG_OUTPUT */
Note: See TracChangeset for help on using the changeset viewer.