| 1 | /**
|
|---|
| 2 | * @file interface.cpp
|
|---|
| 3 | * @author Julian Iseringhausen <isering@ins.uni-bonn.de>
|
|---|
| 4 | * @date Mon Apr 18 12:55:48 2011
|
|---|
| 5 | *
|
|---|
| 6 | * @brief VMG::Interface
|
|---|
| 7 | *
|
|---|
| 8 | */
|
|---|
| 9 |
|
|---|
| 10 | #ifdef HAVE_CONFIG_H
|
|---|
| 11 | #include <config.h>
|
|---|
| 12 | #endif
|
|---|
| 13 |
|
|---|
| 14 | #include <algorithm>
|
|---|
| 15 | #include <cmath>
|
|---|
| 16 |
|
|---|
| 17 | #include "base/helper.hpp"
|
|---|
| 18 | #include "interface/interface.hpp"
|
|---|
| 19 |
|
|---|
| 20 | using namespace VMG;
|
|---|
| 21 |
|
|---|
| 22 | void Interface::InitInterface(const Vector& box_offset, const vmg_float& box_size,
|
|---|
| 23 | const int& coarseningSteps, const vmg_float& alpha)
|
|---|
| 24 | {
|
|---|
| 25 | Index size_factor_max = 1;
|
|---|
| 26 | int num_cells;
|
|---|
| 27 |
|
|---|
| 28 | const Vector box_center = box_offset + 0.5 * box_size;
|
|---|
| 29 |
|
|---|
| 30 | for (int i=levelMax; i>=levelMin; --i) {
|
|---|
| 31 |
|
|---|
| 32 | global.push_back(GlobalIndices());
|
|---|
| 33 | extent.push_back(SpatialExtent());
|
|---|
| 34 |
|
|---|
| 35 | num_cells = Helper::intpow(2, i);
|
|---|
| 36 |
|
|---|
| 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;
|
|---|
| 42 |
|
|---|
| 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 | }
|
|---|
| 58 |
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 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 | }
|
|---|
| 70 |
|
|---|
| 71 | levelMin = levelMax - global.size() + 1;
|
|---|
| 72 | }
|
|---|