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.cpp

    r66f24d rdfed1c  
    1212#endif
    1313
     14#include <algorithm>
    1415#include <cmath>
    1516
     
    1920using namespace VMG;
    2021
    21 Interface::Interface(BC boundary, int levelMin_, int levelMax_, vmg_float box_begin_, vmg_float box_end_,
    22                      int coarseningSteps, vmg_float alpha)
     22void Interface::InitInterface(const Vector& box_offset, const vmg_float& box_size,
     23                              const int& coarseningSteps, const vmg_float& alpha)
    2324{
    24   bc = boundary;
    25   levelMin = levelMin_;
    26   levelMax = levelMax_;
     25  Index size_factor_max = 1;
     26  int num_cells;
    2727
    28   bool restricted = false;
     28  const Vector box_center = box_offset + 0.5 * box_size;
    2929
    30   const vmg_float box_center = 0.5 * (box_begin_ + box_end_);
    31   const vmg_float box_size = box_end_ - box_begin_;
    32 
    33   for (int i=0; i<coarseningSteps; ++i) {
     30  for (int i=levelMax; i>=levelMin; --i) {
    3431
    3532    global.push_back(GlobalIndices());
    3633    extent.push_back(SpatialExtent());
    3734
    38     extent.back().SizeFactor() = Helper::intpow(2, static_cast<int>(log(pow(alpha, i+1)) / log(2.0) + 1.0));
     35    num_cells = Helper::intpow(2, i);
    3936
    40     extent.back().Size() = box_size * static_cast<Vector>(extent.back().SizeFactor());
    41     extent.back().Begin() = box_center - 0.5 * extent.back().Size();
    42     extent.back().End() = extent.back().Begin() + extent.back().Size();
    43     extent.back().MeshWidth() = pow(2.0, i-levelMax);
     37    extent.back().SizeFactor() = 1;
     38    extent.back().Size() = box_size;
     39    extent.back().Begin() = box_offset;
     40    extent.back().End() = box_offset + box_size;
     41    extent.back().MeshWidth() = box_size / num_cells;
    4442
    45     global.back().Size() = static_cast<Index>(static_cast<Vector>(extent.back().Size()) / extent.back().MeshWidth() + 0.5) + 1;
    46     global.back().Begin() = 0;
    47     global.back().End() = global.back().Size();
     43    global.back().SizeGlobal() = num_cells + 1;
     44    global.back().SizeLocal() = num_cells + 1;
     45    global.back().BeginFinest() = 0;
     46    global.back().BeginLocal() = 0;
     47    global.back().EndLocal() = num_cells + 1;
     48
     49    if (i == levelMax) {
     50      global.back().SizeFinest() = num_cells + 1;
     51      global.back().EndFinest() = num_cells + 1;
     52      global.back().BoundaryType() = GlobalMax;
     53    }else {
     54      global.back().SizeFinest() = (++global.rbegin())->SizeFinest();
     55      global.back().EndFinest() = (++global.rbegin())->SizeFinest();
     56      global.back().BoundaryType() = GlobalCoarsened;
     57    }
    4858
    4959  }
    5060
    51   for (int i=0; i<coarseningSteps; ++i) {
    52 
    53     if (restricted) {
    54       global[i].BoundaryType() = GlobalCoarsened;
    55     }else if (extent[i].SizeFactor() == extent.back().SizeFactor()) {
    56       global[i].BoundaryType() = GlobalMax;
    57       restricted = true;
    58     }else {
    59       global[i].BoundaryType() = LocallyRefined;
    60     }
    61 
    62     if (i==0) {
    63       global[0].AlignmentBegin() = (global[0].Size() - static_cast<int>( pow(2.0, levelMax) + 0.5) - 1) / 2;
    64     }else if (global[i].BoundaryType() == LocallyRefined)
    65       global[i].AlignmentBegin() = (extent[i].Size() - extent[i-1].Size()) * pow(2.0, levelMax-i-1) + 0.5;
    66     else if (global[i].BoundaryType() == GlobalMax)
    67       global[i].AlignmentBegin() = (extent[i].Size() - extent[i-1].Size()) * pow(2.0, levelMax-i-1) - 0.5;
    68     else
    69       global[i].AlignmentBegin() = 0;
    70 
    71     global[i].AlignmentEnd() = global[i].Size() - global[i].AlignmentBegin();
    72   }
    73 
    74   while (global.size() == 0 || global.back().Size().Max() > Helper::intpow(2,levelMin)+1) {
    75 
    76     global.push_back(GlobalIndices());
    77     extent.push_back(SpatialExtent());
    78 
    79     extent.back().SizeFactor() = (global.size() > 1 ? (++extent.rbegin())->Size() : 1);
    80     extent.back().Size() = (global.size() > 1 ?  (++extent.rbegin())->Size() : box_size);
    81     extent.back().Begin() = box_center - 0.5 * static_cast<Vector>(extent.back().Size());
    82     extent.back().End() = extent.back().Begin() + extent.back().Size();
    83     extent.back().MeshWidth() = pow(2.0, static_cast<int>(global.size())-levelMax-1);
    84 
    85     global.back().Size() = static_cast<Index>(static_cast<Vector>(extent.back().Size()) / extent.back().MeshWidth() + 0.5) + 1;
    86     global.back().Begin() = 0;
    87     global.back().End() = global.back().Size();
    88 
    89     if (global.size() > 1)
    90       global.back().BoundaryType() = GlobalCoarsened;
    91     else
    92       global.back().BoundaryType() = GlobalMax;
    93 
    94     global.back().AlignmentBegin() = 0;
    95     global.back().AlignmentEnd() = global.back().Size();
    96 
    97   }
    98 
    99   if (boundary == Periodic)
    100     for (std::vector<GlobalIndices>::iterator iter=global.begin(); iter!=global.end(); ++iter)
    101       iter->Size() -= 1;
     61  for (int i=0; i<3; ++i)
     62    if (bc[i] == Periodic)
     63      for (unsigned int j=0; j<global.size(); ++j) {
     64        global[j].SizeGlobal()[i] -= 1;
     65        global[j].SizeFinest()[i] -= Helper::intpow(2, j);
     66        global[j].SizeLocal()[i] -= 1;
     67        global[j].EndLocal()[i] -= 1;
     68        global[j].EndFinest()[i] -= Helper::intpow(2, j);
     69      }
    10270
    10371  levelMin = levelMax - global.size() + 1;
Note: See TracChangeset for help on using the changeset viewer.