From 8bf583ea7bdbc5372e5db99ab5ba8d45af84e930 Mon Sep 17 00:00:00 2001
From: Thomas Witkowski <thomas.witkowski@gmx.de>
Date: Fri, 10 Oct 2008 07:54:02 +0000
Subject: [PATCH] * Added first test

---
 AMDiS/test/init/compute_displacement.1d |  58 +++++++++++
 AMDiS/test/macro/macro.stand.1d         |  15 +++
 AMDiS/test/src/compute_displacement.cc  | 130 ++++++++++++++++++++++++
 3 files changed, 203 insertions(+)
 create mode 100644 AMDiS/test/init/compute_displacement.1d
 create mode 100644 AMDiS/test/macro/macro.stand.1d
 create mode 100644 AMDiS/test/src/compute_displacement.cc

diff --git a/AMDiS/test/init/compute_displacement.1d b/AMDiS/test/init/compute_displacement.1d
new file mode 100644
index 00000000..6860fb18
--- /dev/null
+++ b/AMDiS/test/init/compute_displacement.1d
@@ -0,0 +1,58 @@
+dimension of world:                      1
+
+vecelliptMesh->macro file name:          ./macro/macro.stand.1d
+vecelliptMesh->global refinements:       1
+
+vecellipt->mesh:                         vecelliptMesh
+vecellipt->dim:                          1
+vecellipt->refinement set[0]:            0
+vecellipt->refinement set[1]:            1
+
+vecellipt->components:                                     2
+
+vecellipt->polynomial degree[0]:         1
+vecellipt->polynomial degree[1]:         1
+
+vecellipt->solver:                       bicgstab
+vecellipt->solver->max iteration:        10000
+vecellipt->solver->restart:              10  %  only used for GMRES
+vecellipt->solver->tolerance:            1.e-6
+vecellipt->solver->info:                 2
+vecellipt->solver->left precon:          no
+vecellipt->solver->right precon:         no
+
+vecellipt->estimator[0]:                 residual
+vecellipt->estimator[0]->error norm:     1 % 1: H1_NORM, 2: L2_NORM
+vecellipt->estimator[0]->C0:             0.1 % constant of element residual
+vecellipt->estimator[0]->C1:             0.1 % constant of jump residual
+vecellipt->estimator[0]->C2:             0.0 % constant of coarsening estimate
+
+vecellipt->marker[0]->strategy:          3   % 0: no adaption 1: GR 2: MS 3: ES 4:GERS
+vecellipt->marker[0]->MSGamma:           0.5
+
+vecellipt->estimator[1]:                 residual
+vecellipt->estimator[1]->error norm:     1 % 1: H1_NORM, 2: L2_NORM
+vecellipt->estimator[1]->C0:             0.1 % constant of element residual
+vecellipt->estimator[1]->C1:             0.1 % constant of jump residual
+vecellipt->estimator[1]->C2:             0.0 % constant of coarsening estimate
+
+vecellipt->marker[1]->strategy:          3   % 0: no adaption 1: GR 2: MS 3: ES 4:GERS
+vecellipt->marker[1]->MSGamma:           0.5
+
+vecellipt->adapt[0]->coarsen allowed:    1
+vecellipt->adapt[1]->coarsen allowed:    1
+
+vecellipt->adapt[0]->tolerance:          1e-6
+vecellipt->adapt[1]->tolerance:          1
+
+vecellipt->adapt->max iteration:         3
+vecellipt->adapt->refine bisections:     2
+
+vecellipt->output[0]->filename:          bieq0
+vecellipt->output[0]->ParaView format:      1
+
+vecellipt->output[1]->filename:          bieq1
+vecellipt->output[1]->ParaView format:      1
+
+WAIT: 0
+
diff --git a/AMDiS/test/macro/macro.stand.1d b/AMDiS/test/macro/macro.stand.1d
new file mode 100644
index 00000000..4d23c363
--- /dev/null
+++ b/AMDiS/test/macro/macro.stand.1d
@@ -0,0 +1,15 @@
+DIM: 1
+DIM_OF_WORLD: 1
+
+number of elements: 1  
+number of vertices: 2  
+
+element vertices:
+0 1 
+
+element boundaries:
+1 1
+
+vertex coordinates:
+ 0.0  
+ 1.0
diff --git a/AMDiS/test/src/compute_displacement.cc b/AMDiS/test/src/compute_displacement.cc
new file mode 100644
index 00000000..3e24c3c5
--- /dev/null
+++ b/AMDiS/test/src/compute_displacement.cc
@@ -0,0 +1,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<std::vector<int> > correctResults(0);
+  std::vector<int> 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;
+}
+
+
-- 
GitLab