Commit c3dc225d authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

added Environment for MPI initialization

parent 73513f33
......@@ -95,7 +95,7 @@ void run_periodic()
int main(int argc, char** argv)
{
AMDiS::init(argc, argv);
Environment env(argc, argv);
auto b = [](auto const& x){ return x[0] < 1.e-8 || x[1] < 1.e-8 || x[0] > 1.0-1.e-8 || x[1] > 1.0-1.e-8; };
......@@ -119,6 +119,5 @@ int main(int argc, char** argv)
run_periodic();
AMDiS::finalize();
return 0;
}
......@@ -13,7 +13,7 @@ using Param = LagrangeBasis<Grid, 1, 1>;
int main(int argc, char** argv)
{
AMDiS::init(argc, argv);
Environment env(argc, argv);
ProblemStat<Param> prob("ch");
prob.initialize(INIT_ALL);
......@@ -68,6 +68,5 @@ int main(int argc, char** argv)
AdaptInstationary adapt("adapt", prob, adaptInfo, probInstat, adaptInfo);
adapt.adapt();
AMDiS::finalize();
return 0;
}
......@@ -17,7 +17,7 @@ using ElliptProblem = ProblemStat<ElliptParam>;
int main(int argc, char** argv)
{
AMDiS::init(argc, argv);
Environment env(argc, argv);
using namespace Dune::Indices;
......@@ -39,6 +39,5 @@ int main(int argc, char** argv)
prob.solve(adaptInfo);
prob.writeFiles(adaptInfo, true);
AMDiS::finalize();
return 0;
}
......@@ -18,7 +18,7 @@ using ElliptProblem = ProblemStat<Param>;
int main(int argc, char** argv)
{
AMDiS::init(argc, argv);
Environment env(argc, argv);
int numLevels = GRIDDIM == 2 ? 8 : 5;
if (argc > 2)
......@@ -92,6 +92,5 @@ int main(int argc, char** argv)
msg("{:<5} | {:<12} | {:<12} | {:<12} | {:<12} | {:<12}",
i+1, widths[i], errL2[i], errH1[i], eocL2[i], eocH1[i]);
AMDiS::finalize();
return 0;
}
......@@ -21,7 +21,7 @@ using HeatProblemInstat = ProblemInstat<HeatParam>;
int main(int argc, char** argv)
{
AMDiS::init(argc, argv);
Environment env(argc, argv);
HeatProblem prob("heat");
prob.initialize(INIT_ALL);
......@@ -55,6 +55,5 @@ int main(int argc, char** argv)
AdaptInstationary adapt("adapt", prob, adaptInfo, probInstat, adaptInfo);
adapt.adapt();
AMDiS::finalize();
return 0;
}
......@@ -12,7 +12,7 @@ using Basis = TaylorHoodBasis<Grid>;
int main(int argc, char** argv)
{
AMDiS::init(argc, argv);
Environment env(argc, argv);
ProblemStat<Basis> prob("stokes");
prob.initialize(INIT_ALL);
......@@ -89,6 +89,5 @@ int main(int argc, char** argv)
// output solution
prob.writeFiles(adaptInfo);
AMDiS::finalize();
return 0;
}
......@@ -51,7 +51,7 @@ void run(Grid& grid)
int main(int argc, char** argv)
{
AMDiS::init(argc, argv);
Environment env(argc, argv);
// 2d grids
......@@ -85,6 +85,5 @@ int main(int argc, char** argv)
Dune::YaspGrid<3> grid4({1.0,1.0,1.0},{2,2,2});
run(grid4);
AMDiS::finalize();
return 0;
}
......@@ -79,7 +79,7 @@ void run(Grid& grid)
int main(int argc, char** argv)
{
AMDiS::init(argc, argv);
Environment env(argc, argv);
#if HAVE_DUNE_SPGRID
Dune::SPCube<double,2> cube({0.0,0.0},{1.0,1.0});
......@@ -92,6 +92,5 @@ int main(int argc, char** argv)
Dune::YaspGrid<2> grid2({1.0,1.0}, {2,2});
run(grid2);
AMDiS::finalize();
return 0;
}
......@@ -10,7 +10,7 @@ using StokesProblem = ProblemStat<StokesParam>;
int main(int argc, char** argv)
{
AMDiS::init(argc, argv);
Environment env(argc, argv);
StokesProblem prob("stokes");
prob.initialize(INIT_ALL);
......@@ -58,6 +58,5 @@ int main(int argc, char** argv)
// output solution
prob.writeFiles(adaptInfo);
AMDiS::finalize();
return 0;
}
......@@ -10,7 +10,7 @@ using StokesProblem = ProblemStat<StokesParam>;
int main(int argc, char** argv)
{
AMDiS::init(argc, argv);
Environment env(argc, argv);
StokesProblem prob("stokes");
prob.initialize(INIT_ALL);
......@@ -58,6 +58,5 @@ int main(int argc, char** argv)
// output solution
prob.writeFiles(adaptInfo);
AMDiS::finalize();
return 0;
}
......@@ -11,7 +11,7 @@ using StokesProblem = ProblemStat<StokesParam>;
int main(int argc, char** argv)
{
AMDiS::init(argc, argv);
Environment env(argc, argv);
StokesProblem prob("stokes");
prob.initialize(INIT_ALL);
......@@ -48,6 +48,5 @@ int main(int argc, char** argv)
// output solution
prob.writeFiles(adaptInfo);
AMDiS::finalize();
return 0;
}
......@@ -15,7 +15,7 @@ using ElliptProblem = ProblemStat<ElliptParam>;
int main(int argc, char** argv)
{
AMDiS::init(argc, argv);
Environment env(argc, argv);
ElliptProblem prob("ellipt");
prob.initialize(INIT_ALL);
......@@ -53,6 +53,5 @@ int main(int argc, char** argv)
prob.solve(adaptInfo);
prob.writeFiles(adaptInfo, true);
AMDiS::finalize();
return 0;
}
#include "AMDiS.hpp"
// AMDiS includes
#include <amdis/Initfile.hpp>
#include <amdis/Output.hpp>
namespace AMDiS
{
Dune::MPIHelper& init(int& argc, char**& argv, std::string const& initFileName)
{
// Maybe initialize MPI
static Dune::MPIHelper& mpiHelper = Dune::MPIHelper::instance(argc, argv);
Parameters::clearData();
if (initFileName.empty() && argc > 1) {
Parameters::init(argv[1]);
} else if (!initFileName.empty()) {
Parameters::init(initFileName);
} else {
warning("No initfile specified. Using default values for all parameters.");
}
return mpiHelper;
}
void finalize()
{}
} // end namespace AMDiS
......@@ -4,16 +4,11 @@
# include "config.h"
#endif
// std c++ headers
#include <string>
#include <dune/common/exceptions.hh> // We use exceptions
#include <dune/common/parallel/mpihelper.hh>
namespace AMDiS
{
Dune::MPIHelper& init(int& argc, char**& argv, std::string const& initFileName = "");
void finalize();
} // end namespace AMDiS
#include <amdis/AdaptInfo.hpp>
#include <amdis/Environment.hpp>
#include <amdis/Initfile.hpp>
#include <amdis/LinearAlgebra.hpp>
#include <amdis/Output.hpp>
#include <amdis/ProblemStat.hpp>
namespace AMDiS {} // end namespace AMDiS
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "AdaptInfo.hpp"
// std c++ headers
......
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "AdaptInstationary.hpp"
// AMDiS includes
......
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "AdaptStationary.hpp"
// AMDiS includes
......
......@@ -4,7 +4,7 @@ dune_library_add_sources(amdis SOURCES
AdaptInfo.cpp
AdaptInstationary.cpp
AdaptStationary.cpp
AMDiS.cpp
Environment.cpp
Initfile.cpp
InitfileParser.cpp
ProblemInstatBase.cpp
......@@ -31,6 +31,7 @@ install(FILES
DataTransfer.inc.hpp
DirichletBC.hpp
DirichletBC.inc.hpp
Environment.hpp
FileWriter.hpp
FileWriterInterface.hpp
Flag.hpp
......
......@@ -14,6 +14,7 @@
#include <dune/common/fvector.hh>
#include <dune/common/hash.hh>
#include <dune/grid/common/geometry.hh>
#include <dune/grid/common/mcmgmapper.hh>
#include <dune/grid/common/rangegenerators.hh>
......
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "Environment.hpp"
// AMDiS includes
#include <amdis/Initfile.hpp>
#include <amdis/Output.hpp>
namespace AMDiS
{
Environment::Environment(std::string const& initFileName)
{
Parameters::clearData();
if (!initFileName.empty())
Parameters::init(initFileName);
}
Environment::Environment(int& argc, char**& argv, std::string const& initFileName)
: Environment(initFileName)
{
auto& helper = Dune::MPIHelper::instance(argc, argv);
auto& mpi = Mpi::instance();
mpi.registerMpiHelper(helper);
Parameters::clearData();
if (initFileName.empty()) {
if (argc > 1)
Parameters::init(argv[1]);
else
warning("No initfile specified. Using default values for all parameters.");
}
}
} // end namespace AMDiS
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment