Commit 140b26b9 authored by Lukas Riedel's avatar Lukas Riedel 📝

added smaller executable for parallel testing

parent 922850de
......@@ -2,5 +2,8 @@ add_subdirectory(interface)
add_subdirectory(solver)
add_subdirectory(impl)
add_executable("parallel" parallel.cc)
target_link_dune_default_libraries("parallel")
add_executable("dorie" dorie.cc)
dune_target_link_libraries(dorie doriesim)
\ No newline at end of file
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <dune/dorie/dorie.hh> // System and DUNE Headers
#include <dune/dorie/interface/simulation.cc>
namespace Dune{
namespace Dorie{
/// Resolve the second (default) template parameter of YaspGrid
template<int dim>
using YaspGrid = Dune::YaspGrid<dim>;
}
}
template<typename Traits>
using Sim = Dune::Dorie::Simulation<Traits>;
template<int dim, int order>
using Simplex = Dune::Dorie::BaseTraits<Dune::UGGrid,
Dune::GeometryType::BasicType::simplex,dim,order,true,false>;
template<int dim, int order>
using SimplexAdaptive = Dune::Dorie::BaseTraits<Dune::UGGrid,
Dune::GeometryType::BasicType::simplex,dim,order,true,true>;
template<int dim, int order>
using Cube = Dune::Dorie::BaseTraits<Dune::Dorie::YaspGrid,
Dune::GeometryType::BasicType::cube,dim,order,true,false>;
template<int dim, int order>
using CubeAdaptive = Dune::Dorie::BaseTraits<Dune::UGGrid,
Dune::GeometryType::BasicType::cube,dim,order,true,true>;
int main(int argc, char** argv)
{
try{
Dune::Timer timer;
//Initialize Mpi
Dune::MPIHelper& helper = Dune::MPIHelper::instance(argc, argv);
if (argc!=2)
DUNE_THROW(Dune::IOError,"No parameter file specified!");
const std::string inifilename = argv[1];
// Read ini file
Dune::ParameterTree inifile;
Dune::ParameterTreeParser ptreeparser;
ptreeparser.readINITree(inifilename,inifile);
// Read necessary variables
const std::string gtype = inifile.get<std::string>("grid.gridType");
const int dim = inifile.get<int>("grid.dimensions");
const int FEorder = inifile.get<int>("grid.FEorder");
const int verbose = inifile.get<int>("output.verbose");
const std::string outputPath = inifile.get<std::string>("output.outputPath");
const bool adaptivity = inifile.get<bool>("adaptivity.useAdaptivity");
// Attempt to create output directory
mkdir(outputPath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
int result = access(outputPath.c_str(), W_OK);
if (result != 0)
DUNE_THROW(Dune::IOError,"Output folder " << outputPath << " not writable");
if (helper.rank()==0){
std::cout << "INPUT FILE: " << inifilename << std::endl;
std::cout << "BC FILE: " << inifile.get<std::string>("boundary.file") << std::endl;
std::cout << "OUTPUT PATH: " << inifile.get<std::string>("output.outputPath") << std::endl;
if (verbose>0){
if(Dune::MPIHelper::isFake) std::cout << "MPI: SEQUENTIAL RUN" << std::endl;
else std::cout << "MPI: PARALLEL RUN ON " << helper.size() << " PROCESS(ES)" << std::endl;
}
}
if (dim==2)
{
if (gtype == "gmsh"){
auto grid = Dune::Dorie::build_grid_gmsh<Dune::UGGrid<2>>(inifile,helper);
if(adaptivity){
switch(FEorder){
case 1:{
Sim<SimplexAdaptive<2,1>> sim(helper,grid,inifile);
sim.run();
break;
}
default:
DUNE_THROW(Dune::NotImplemented,"Finite Element Order (grid.FEorder) not supported!");
}
}
else{ // no adaptivity
switch(FEorder){
case 1:{
Sim<Simplex<2,1>> sim(helper,grid,inifile);
sim.run();
break;
}
default:
DUNE_THROW(Dune::NotImplemented,"Finite Element Order (grid.FEorder) not supported!");
}
}
}
else if (gtype == "rectangular"){
if(adaptivity){
auto grid = Dune::Dorie::build_grid_cube<Dune::UGGrid<2>>(inifile,helper);
switch(FEorder){
case 1:{
Sim<CubeAdaptive<2,1>> sim(helper,grid,inifile);
sim.run();
break;
}
default:
DUNE_THROW(Dune::NotImplemented,"Finite Element Order (grid.FEorder) not supported!");
}
}
else{ // no adaptivity
auto grid = Dune::Dorie::build_grid_cube<Dune::YaspGrid<2>>(inifile,helper);
switch(FEorder){
case 1:{
Sim<Cube<2,1>> sim(helper,grid,inifile);
sim.run();
break;
}
default:
DUNE_THROW(Dune::NotImplemented,"Finite Element Order (grid.FEorder) not supported!");
}
}
}
else
DUNE_THROW(Dune::NotImplemented,"Grid Type not supported!");
}
// grid_dim != 2,3
else{
DUNE_THROW(Dune::NotImplemented,"Number of dimensions (grid.dimensions) not supported!");
}
if(helper.rank()==0){
std::cout << "PROGRAM TERMINATED SUCCESSFULLY" << std::endl;
std::cout << "::: Execution time "
<< std::setw(12) << std::setprecision(4) << std::scientific
<< timer.elapsed() << std::endl;
}
return 0;
}
catch (Dune::Exception &e){
std::cerr << "Dune reported error: " << e << std::endl;
return 1;
}
catch (...){
std::cerr << "Unknown exception thrown!" << std::endl;
throw;
return 1;
}
}
\ No newline at end of file
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