Skip to content
Snippets Groups Projects
Commit fe853ba7 authored by graeser's avatar graeser Committed by graeser
Browse files

Allow to test with more refinement by command line argument

[[Imported from SVN: r6047]]
parent ded337a0
No related branches found
No related tags found
No related merge requests found
#include <config.h>
#include <iostream>
#include <sstream>
// dune-common includes
#include <dune/common/bitsetvector.hh>
......@@ -19,8 +22,6 @@
#include "common.hh"
#define DIMENSION 2
template <class DomainType, class RangeType>
class ConstantFunction :
public Dune::VirtualFunction<DomainType, RangeType>
......@@ -108,7 +109,7 @@ void solveObstacleProblemByTNNMG(const GridType& grid, const MatrixType& mat, Ve
template <class GridType>
bool checkWithGrid(const GridType& grid)
bool checkWithGrid(const GridType& grid, const std::string fileName="")
{
bool passed = true;
......@@ -147,9 +148,12 @@ bool checkWithGrid(const GridType& grid)
solveObstacleProblemByTNNMG(grid, A, u, rhs, ignore);
typename Dune::VTKWriter<GridView> vtkWriter(gridView);
vtkWriter.addVertexData(u, "solution");
vtkWriter.write("obstacletnnmgtest_solution");
if (fileName!="")
{
typename Dune::VTKWriter<GridView> vtkWriter(gridView);
vtkWriter.addVertexData(u, "solution");
vtkWriter.write(fileName);
}
return passed;
......@@ -157,7 +161,7 @@ bool checkWithGrid(const GridType& grid)
template <int dim>
bool checkWithYaspGrid(int refine)
bool checkWithYaspGrid(int refine, const std::string fileName="")
{
bool passed = true;
......@@ -176,7 +180,7 @@ bool checkWithYaspGrid(int refine)
std::cout << "Number of levels: " << (grid.maxLevel()+1) << std::endl;
std::cout << "Number of leaf nodes: " << grid.leafView().size(dim) << std::endl;
passed = passed and checkWithGrid(grid);
passed = passed and checkWithGrid(grid, fileName);
return passed;
......@@ -187,14 +191,23 @@ bool checkWithYaspGrid(int refine)
int main(int argc, char** argv) try
{
static const int dim = DIMENSION;
bool passed(true);
passed = passed and checkWithYaspGrid<1>(15);
passed = passed and checkWithYaspGrid<2>(10);
passed = passed and checkWithYaspGrid<3>(5);
int refine1d = 16;
int refine2d = 8;
int refine3d = 5;
if (argc>1)
std::istringstream(argv[1]) >> refine1d;
if (argc>2)
std::istringstream(argv[2]) >> refine2d;
if (argc>3)
std::istringstream(argv[3]) >> refine3d;
passed = passed and checkWithYaspGrid<1>(refine1d, "obstacletnnmgtest_yasp_1d_solution");
passed = passed and checkWithYaspGrid<2>(refine2d, "obstacletnnmgtest_yasp_2d_solution");
passed = passed and checkWithYaspGrid<3>(refine3d, "obstacletnnmgtest_yasp_3d_solution");
return passed ? 0 : 1;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment