diff --git a/src/cosserat-continuum.cc b/src/cosserat-continuum.cc index a8a6b3ca9ee0412d5b7c84c1a02f760e4c77a289..45a2918c0d7384b6b8e3df5846a20080e7508a76 100644 --- a/src/cosserat-continuum.cc +++ b/src/cosserat-continuum.cc @@ -40,6 +40,7 @@ #include <dune/gfe/nonplanarcosseratshellenergy.hh> #include <dune/gfe/cosseratvtkwriter.hh> #include <dune/gfe/cosseratvtkreader.hh> +#include <dune/gfe/vtkreader.hh> #include <dune/gfe/geodesicfeassembler.hh> #include <dune/gfe/riemanniantrsolver.hh> @@ -165,7 +166,17 @@ int main (int argc, char *argv[]) try } else { std::string path = parameterSet.get<std::string>("path"); std::string gridFile = parameterSet.get<std::string>("gridFile"); - grid = shared_ptr<GridType>(GmshReader<GridType>::read(path + "/" + gridFile)); + + // Guess the grid file format by looking at the file name suffix + auto dotPos = gridFile.rfind('.'); + if (dotPos == std::string::npos) + DUNE_THROW(IOError, "Could not determine grid input file format"); + std::string suffix = gridFile.substr(dotPos, gridFile.length()-dotPos); + + if (suffix == ".msh") + grid = shared_ptr<GridType>(GmshReader<GridType>::read(path + "/" + gridFile)); + else if (suffix == ".vtu" or suffix == ".vtp") + grid = VTKReader<GridType>::read(path + "/" + gridFile); } grid->globalRefine(numLevels-1);