2010-08-24 06:11:18 -05:00
|
|
|
// $Id$
|
2009-06-18 12:06:44 -05:00
|
|
|
/*****************************************************************************
|
2010-05-25 08:27:16 -05:00
|
|
|
* Copyright (C) 20010 by Markus Wolff *
|
|
|
|
* Copyright (C) 2007-2008 by Bernd Flemisch *
|
|
|
|
* Copyright (C) 2008-2009 by Andreas Lauser *
|
2009-06-18 12:06:44 -05:00
|
|
|
* Institute of Hydraulic Engineering *
|
|
|
|
* University of Stuttgart, Germany *
|
|
|
|
* email: <givenname>.<name>@iws.uni-stuttgart.de *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version, as long as this copyright notice *
|
|
|
|
* is included in its original form. *
|
|
|
|
* *
|
|
|
|
* This program is distributed WITHOUT ANY WARRANTY. *
|
|
|
|
*****************************************************************************/
|
2010-10-01 10:08:25 -05:00
|
|
|
#include "config.h" /*@\label{tutorial-decoupled:include-begin}@*/
|
2009-06-10 07:08:28 -05:00
|
|
|
|
2010-10-01 10:08:25 -05:00
|
|
|
#include "tutorialproblem_decoupled.hh" /*@\label{tutorial-decoupled:include-problem-header}@*/
|
2009-06-10 07:08:28 -05:00
|
|
|
|
2010-05-25 08:27:16 -05:00
|
|
|
#include <dune/grid/common/gridinfo.hh>
|
2009-09-08 05:38:51 -05:00
|
|
|
|
2010-05-25 08:27:16 -05:00
|
|
|
#include <dune/common/exceptions.hh>
|
|
|
|
#include <dune/common/mpihelper.hh>
|
2009-06-10 07:08:28 -05:00
|
|
|
|
2010-05-25 08:27:16 -05:00
|
|
|
#include <iostream>
|
2010-10-01 10:08:25 -05:00
|
|
|
#include <boost/format.hpp> /*@\label{tutorial-decoupled:include-end}@*/
|
2009-06-10 07:08:28 -05:00
|
|
|
|
|
|
|
|
2010-10-01 10:08:25 -05:00
|
|
|
////////////////////////////////////////////
|
|
|
|
// function to check the input parameters
|
|
|
|
////////////////////////////////////////////
|
2010-05-25 08:27:16 -05:00
|
|
|
void usage(const char *progname)
|
|
|
|
{
|
|
|
|
std::cout << boost::format("usage: %s [--restart restartTime] tEnd\n")%progname;
|
|
|
|
exit(1);
|
|
|
|
}
|
2009-06-10 07:08:28 -05:00
|
|
|
|
2010-10-01 10:08:25 -05:00
|
|
|
////////////////////////
|
|
|
|
// the main function
|
|
|
|
////////////////////////
|
2010-05-25 08:27:16 -05:00
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
try {
|
2010-10-01 10:08:25 -05:00
|
|
|
typedef TTAG(TutorialProblemDecoupled) TypeTag; /*@\label{tutorial-decoupled:set-type-tag}@*/
|
|
|
|
typedef GET_PROP_TYPE(TypeTag, PTAG(Scalar)) Scalar; /*@\label{tutorial-decoupled:retrieve-types-begin}@*/
|
2010-08-05 07:11:43 -05:00
|
|
|
typedef GET_PROP_TYPE(TypeTag, PTAG(Grid)) Grid;
|
2010-05-25 08:27:16 -05:00
|
|
|
typedef GET_PROP_TYPE(TypeTag, PTAG(Problem)) Problem;
|
2010-10-01 10:08:25 -05:00
|
|
|
typedef Dune::FieldVector<Scalar, Grid::dimensionworld> GlobalPosition; /*@\label{tutorial-decoupled:retrieve-types-end}@*/
|
2010-05-25 08:27:16 -05:00
|
|
|
|
|
|
|
// initialize MPI, finalize is done automatically on exit
|
2010-10-01 10:08:25 -05:00
|
|
|
Dune::MPIHelper::instance(argc, argv); /*@\label{tutorial-decoupled:init-mpi}@*/
|
2010-05-25 08:27:16 -05:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// parse the command line arguments
|
|
|
|
////////////////////////////////////////////////////////////
|
2010-10-01 10:08:25 -05:00
|
|
|
if (argc < 2) /*@\label{tutorial-decoupled:parse-args-begin}@*/
|
2010-05-25 08:27:16 -05:00
|
|
|
usage(argv[0]);
|
|
|
|
|
|
|
|
// deal with the restart stuff
|
|
|
|
int argPos = 1;
|
|
|
|
bool restart = false;
|
|
|
|
double restartTime = 0;
|
|
|
|
if (std::string("--restart") == argv[argPos]) {
|
|
|
|
restart = true;
|
|
|
|
++argPos;
|
|
|
|
|
|
|
|
std::istringstream(argv[argPos++]) >> restartTime;
|
|
|
|
}
|
2010-10-01 10:08:25 -05:00
|
|
|
// output in case of wrong numbers of input parameters
|
2010-05-25 08:27:16 -05:00
|
|
|
if (argc - argPos != 1) {
|
|
|
|
usage(argv[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// read the initial time step and the end time
|
|
|
|
double tEnd, dt;
|
|
|
|
std::istringstream(argv[argPos++]) >> tEnd;
|
2010-10-01 10:08:25 -05:00
|
|
|
dt = tEnd; /*@\label{tutorial-decoupled:parse-args-end}@*/
|
2010-05-25 08:27:16 -05:00
|
|
|
|
|
|
|
// create the grid
|
2010-10-01 10:08:25 -05:00
|
|
|
Grid *gridPtr = GET_PROP(TypeTag, PTAG(Grid))::create(); /*@\label{tutorial-decoupled:create-grid}@*/
|
|
|
|
|
2009-06-10 07:08:28 -05:00
|
|
|
|
2010-05-25 08:27:16 -05:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// instantiate and run the concrete problem
|
|
|
|
////////////////////////////////////////////////////////////
|
2009-06-10 07:08:28 -05:00
|
|
|
|
2010-10-01 10:08:25 -05:00
|
|
|
Problem problem(gridPtr->leafView()); /*@\label{tutorial-decoupled:instantiate-problem}@*/
|
2009-06-10 07:08:28 -05:00
|
|
|
|
2010-11-08 12:02:44 -06:00
|
|
|
// load restart file if necessary
|
2010-10-01 10:08:25 -05:00
|
|
|
if (restart) /*@\label{tutorial-decoupled:restart}@*/
|
2010-05-25 08:27:16 -05:00
|
|
|
problem.deserialize(restartTime);
|
2009-06-10 07:08:28 -05:00
|
|
|
|
2010-10-01 10:08:25 -05:00
|
|
|
// define simulation parameters
|
|
|
|
problem.timeManager().init(problem, 0, dt, tEnd, !restart); /*@\label{tutorial-decoupled:initTimeManager}@*/
|
2010-05-25 08:27:16 -05:00
|
|
|
// run the simulation
|
2010-10-01 10:08:25 -05:00
|
|
|
problem.timeManager().run(); /*@\label{tutorial-decoupled:execute}@*/
|
2009-06-10 07:08:28 -05:00
|
|
|
return 0;
|
|
|
|
}
|
2010-05-25 08:27:16 -05:00
|
|
|
catch (Dune::Exception &e) {
|
2009-06-10 07:08:28 -05:00
|
|
|
std::cerr << "Dune reported error: " << e << std::endl;
|
|
|
|
}
|
2010-05-25 08:27:16 -05:00
|
|
|
catch (...) {
|
|
|
|
std::cerr << "Unknown exception thrown!\n";
|
|
|
|
throw;
|
2009-06-10 07:08:28 -05:00
|
|
|
}
|
2010-05-25 08:27:16 -05:00
|
|
|
|
|
|
|
return 3;
|
2009-06-10 07:08:28 -05:00
|
|
|
}
|