compute_displacement.cc 4.53 KB
 Thomas Witkowski committed Oct 10, 2008 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 ``````#include "AMDiS.h" using namespace std; using namespace AMDiS; // =========================================================================== // ===== main program ======================================================== // =========================================================================== int main(int argc, char* argv[]) { FUNCNAME("main"); // ===== init parameters ===== Parameters::init(false, "./init/compute_displacement.1d"); // ===== create and init the scalar problem ===== ProblemVec vecellipt("vecellipt"); vecellipt.initialize(INIT_ALL); // Works only with global refinement = 1 and one macro element, i.e., two // leave elements in the starting mesh. TEST_EXIT(vecellipt.getMesh(0)->getNumberOfLeaves() == 2)("Wrong macro mesh\n!"); TEST_EXIT(vecellipt.getMesh(1)->getNumberOfLeaves() == 2)("Wrong macro mesh\n!"); // Construct the following mesh (shown as a hierachy tree, a is the macro // element, and b and c construct the starting mesh): // // a // / \ // b c // / \ // / \ // d e // / \ / \ // f g h i // / \ / \ // j k l m // / \ / \ // n o p q // / \ // r s // // The nodes {j, n, o, g, h, p, r, s, m , c} are the leave elements of the // resulting mesh. Mesh *mesh = vecellipt.getMesh(0); Element *el = mesh->getMacroElement(0)->getElement(); el->getChild(0)->setMark(1); vecellipt.getRefinementManager(0)->refineMesh(mesh); el->getChild(0)->getChild(0)->setMark(1); el->getChild(0)->getChild(1)->setMark(1); vecellipt.getRefinementManager(0)->refineMesh(mesh); el->getChild(0)->getChild(0)->getChild(0)->setMark(1); el->getChild(0)->getChild(1)->getChild(1)->setMark(1); vecellipt.getRefinementManager(0)->refineMesh(mesh); el->getChild(0)->getChild(0)->getChild(0)->getChild(1)->setMark(1); el->getChild(0)->getChild(1)->getChild(1)->getChild(0)->setMark(1); vecellipt.getRefinementManager(0)->refineMesh(mesh); el->getChild(0)->getChild(1)->getChild(1)->getChild(0)->getChild(1)->setMark(1); vecellipt.getRefinementManager(0)->refineMesh(mesh); TEST_EXIT(mesh->getNumberOfLeaves() == 10)("Wrong number of leaves!\n"); // Create an array with the expected results of dual traverse. In i-th // step we check the level of the large element (tmp[0]), the level of // the small element (tmp[1]) and the displacement (tmp[2]). std::vector > correctResults(0); std::vector tmp(3); tmp[0] = 1; tmp[1] = 4; tmp[2] = 0; correctResults.push_back(tmp); tmp[0] = 1; tmp[1] = 5; tmp[2] = 2; correctResults.push_back(tmp); tmp[0] = 1; tmp[1] = 5; tmp[2] = 3; correctResults.push_back(tmp); tmp[0] = 1; tmp[1] = 3; tmp[2] = 1; correctResults.push_back(tmp); tmp[0] = 1; tmp[1] = 3; tmp[2] = 2; correctResults.push_back(tmp); tmp[0] = 1; tmp[1] = 5; tmp[2] = 12; correctResults.push_back(tmp); tmp[0] = 1; tmp[1] = 6; tmp[2] = 26; correctResults.push_back(tmp); tmp[0] = 1; tmp[1] = 6; tmp[2] = 27; correctResults.push_back(tmp); tmp[0] = 1; tmp[1] = 4; tmp[2] = 7; correctResults.push_back(tmp); tmp[0] = 1; tmp[1] = 1; tmp[2] = 0; correctResults.push_back(tmp); // Create everything for the dual traverse, start the dual traverse and // compare the result with the expected ones. DualTraverse dualTraverse; ElInfo *rowElInfo, *colElInfo; ElInfo *largeElInfo, *smallElInfo; Flag flag = Mesh::CALL_LEAF_EL | Mesh::FILL_COORDS | Mesh::FILL_DET | Mesh::FILL_GRD_LAMBDA | Mesh::FILL_NEIGH; int i = 0; bool cont = dualTraverse.traverseFirst(vecellipt.getMesh(0), vecellipt.getMesh(1), -1, -1, flag, flag, &rowElInfo, &colElInfo, &smallElInfo, &largeElInfo); while (cont) { TEST_EXIT(correctResults[i][0] == largeElInfo->getLevel()) ("Wrong level of large element!\n"); TEST_EXIT(correctResults[i][1] == smallElInfo->getLevel()) ("Wrong level of small element!\n"); TEST_EXIT(correctResults[i][2] == smallElInfo->getDisplacement()) ("Wrong displacement of small element!\n"); i++; cont = dualTraverse.traverseNext(&rowElInfo, &colElInfo, &smallElInfo, &largeElInfo); } return 0; } ``````