Changeset 4571da for src/grid/grid.cpp


Ignore:
Timestamp:
Apr 27, 2012, 11:34:57 PM (14 years ago)
Author:
Julian Iseringhausen <isering@…>
Children:
1a92cf
Parents:
b2154a3
Message:

vmg: Implement fourth-order discretization of the Poisson equation.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/grid/grid.cpp

    rb2154a3 r4571da  
    2525using namespace VMG;
    2626
    27 vmg_float Grid::correction;
    28 
    2927void Grid::InitGrid()
    3028{
     
    112110    avg += GetVal(*iter);
    113111
    114   avg /= Local().Size().Product();
     112  avg = MG::GetComm()->GlobalSum(avg);
     113  avg /= Global().GlobalSize().Product();
     114
     115#ifdef DEBUG_OUTPUT
     116  MG::GetComm()->PrintStringOnce("Global constraint enforcement: %e", avg);
     117#endif
    115118
    116119  for (iter = Iterators().Local().Begin(); iter != Iterators().Local().End(); ++iter)
     
    126129    val += GetVal(*iter);
    127130
    128   val = MG::GetComm()->GlobalSum(val);
    129 
    130   if (fabs(val) > Global().GlobalSize().Product() * std::numeric_limits<vmg_float>::epsilon()) {
     131  val = MG::GetComm()->GlobalSum(val) / Global().GlobalSize().Product();
     132
     133  if (std::abs(val) > std::numeric_limits<vmg_float>::epsilon()) {
    131134
    132135#ifdef DEBUG_OUTPUT
     
    134137#endif
    135138
    136     val *= Helper::pow_2(this->Extent().MeshWidth().Max());
    137139    for (iter = Iterators().Local().Begin(); iter != Iterators().Local().End(); ++iter)
    138140      (*this)(*iter) -= val;
     
    155157#endif
    156158
    157   for (Grid::iterator iter = Iterators().CompleteGrid().Begin(); iter != Iterators().CompleteGrid().End(); ++iter)
    158     (*this)(*iter) = rhs.GetVal(*iter);
     159  std::memcpy(grid, rhs.grid, local.SizeTotal().Product()*sizeof(vmg_float));
    159160}
    160161
Note: See TracChangeset for help on using the changeset viewer.